summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D12
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-10-28 03:58:28 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-10-28 03:58:28 +0000
commitcbf6f3c8a7e1d4a370d4c9ca2840a143cfbea216 (patch)
tree587e1bd262ad08c814a4c82032ce9a2ba05f6dbe /Graphics/GraphicsEngineD3D12
parentFixed two minor merge issues (diff)
downloadDiligentCore-cbf6f3c8a7e1d4a370d4c9ca2840a143cfbea216.tar.gz
DiligentCore-cbf6f3c8a7e1d4a370d4c9ca2840a143cfbea216.zip
ShaderResourceLayout{D3D12,Vk}: implemented GetShaderName
Diffstat (limited to 'Graphics/GraphicsEngineD3D12')
-rw-r--r--Graphics/GraphicsEngineD3D12/include/ShaderResourceLayoutD3D12.hpp16
-rw-r--r--Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp12
2 files changed, 21 insertions, 7 deletions
diff --git a/Graphics/GraphicsEngineD3D12/include/ShaderResourceLayoutD3D12.hpp b/Graphics/GraphicsEngineD3D12/include/ShaderResourceLayoutD3D12.hpp
index 1f2b3d2d..f7f2fa13 100644
--- a/Graphics/GraphicsEngineD3D12/include/ShaderResourceLayoutD3D12.hpp
+++ b/Graphics/GraphicsEngineD3D12/include/ShaderResourceLayoutD3D12.hpp
@@ -302,7 +302,7 @@ private:
const Char* GetShaderName() const
{
- return ""; // AZ TODO
+ return GetStringPoolData();
}
@@ -323,14 +323,14 @@ private:
D3D12Resource& GetResource(Uint32 r)
{
VERIFY_EXPR(r < GetTotalResourceCount());
- auto* Resource = reinterpret_cast<D3D12Resource*>(m_ResourceBuffer.get());
- return Resource[r];
+ auto* Resources = reinterpret_cast<D3D12Resource*>(m_ResourceBuffer.get());
+ return Resources[r];
}
const D3D12Resource& GetResource(Uint32 r) const
{
VERIFY_EXPR(r < GetTotalResourceCount());
- auto* Resource = reinterpret_cast<const D3D12Resource*>(m_ResourceBuffer.get());
- return Resource[r];
+ const auto* Resources = reinterpret_cast<const D3D12Resource*>(m_ResourceBuffer.get());
+ return Resources[r];
}
Uint32 GetSrvCbvUavOffset(SHADER_RESOURCE_VARIABLE_TYPE VarType, Uint32 r) const
@@ -362,6 +362,12 @@ private:
return GetResource(m_SamplersOffsets[0] + s);
}
+ const char* GetStringPoolData() const
+ {
+ const auto* Resources = reinterpret_cast<const D3D12Resource*>(m_ResourceBuffer.get());
+ return reinterpret_cast<const char*>(Resources + GetTotalResourceCount());
+ }
+
StringPool AllocateMemory(IMemoryAllocator& Allocator,
const std::array<Uint32, SHADER_RESOURCE_VARIABLE_TYPE_NUM_TYPES>& CbvSrvUavCount,
const std::array<Uint32, SHADER_RESOURCE_VARIABLE_TYPE_NUM_TYPES>& SamplerCount,
diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp
index 34b15c4c..b4bb1f72 100644
--- a/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp
@@ -115,7 +115,8 @@ StringPool ShaderResourceLayoutD3D12::AllocateMemory(IMemoryAllocator&
auto* pStringPoolData = MemPool.ConstructArray<char>(StringPoolSize);
m_ResourceBuffer = std::unique_ptr<void, STDDeleterRawMem<void>>(MemPool.Release(), Allocator);
- VERIFY_EXPR(m_ResourceBuffer.get() == pResources);
+ VERIFY_EXPR(pResources == nullptr || m_ResourceBuffer.get() == pResources);
+ VERIFY_EXPR(pStringPoolData == GetStringPoolData());
StringPool stringPool;
stringPool.AssignMemory(pStringPoolData, StringPoolSize);
@@ -145,12 +146,17 @@ void ShaderResourceLayoutD3D12::Initialize(ID3D12Device*
std::array<Uint32, SHADER_RESOURCE_VARIABLE_TYPE_NUM_TYPES> CbvSrvUavCount = {};
std::array<Uint32, SHADER_RESOURCE_VARIABLE_TYPE_NUM_TYPES> SamplerCount = {};
+ // Maps resource name to its index in m_ResourceBuffer
std::unordered_map<HashMapStringKey, Uint32, HashMapStringKey::Hasher> ResourceNameToIndex;
// Count the number of resources to allocate all needed memory
m_IsUsingSeparateSamplers = !Shaders[0]->GetShaderResources()->IsUsingCombinedTextureSamplers();
m_ShaderType = Shaders[0]->GetDesc().ShaderType;
- size_t StringPoolSize = 0;
+
+ // Construct shader or shader group name
+ const auto ShaderName = GetShaderGroupName(Shaders);
+
+ size_t StringPoolSize = ShaderName.length() + 1;
static constexpr Uint32 InvalidResourceIndex = ~0u;
@@ -225,6 +231,8 @@ void ShaderResourceLayoutD3D12::Initialize(ID3D12Device*
auto stringPool = AllocateMemory(LayoutDataAllocator, CbvSrvUavCount, SamplerCount, StringPoolSize);
+ stringPool.CopyString(ShaderName);
+
std::array<Uint32, SHADER_RESOURCE_VARIABLE_TYPE_NUM_TYPES> CurrCbvSrvUav = {};
std::array<Uint32, SHADER_RESOURCE_VARIABLE_TYPE_NUM_TYPES> CurrSampler = {};
std::array<Uint32, D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER + 1> StaticResCacheTblSizes = {};