summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineVulkan
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/GraphicsEngineVulkan
parentFixed two minor merge issues (diff)
downloadDiligentCore-cbf6f3c8a7e1d4a370d4c9ca2840a143cfbea216.tar.gz
DiligentCore-cbf6f3c8a7e1d4a370d4c9ca2840a143cfbea216.zip
ShaderResourceLayout{D3D12,Vk}: implemented GetShaderName
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
-rw-r--r--Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.hpp12
-rw-r--r--Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp12
2 files changed, 19 insertions, 5 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.hpp b/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.hpp
index a0e40615..5406dee3 100644
--- a/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.hpp
+++ b/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.hpp
@@ -371,7 +371,7 @@ public:
const Char* GetShaderName() const
{
- return ""; // AZ TODO
+ return GetStringPoolData();
}
SHADER_TYPE GetShaderType() const { return m_ShaderType; }
@@ -405,7 +405,7 @@ private:
const VkResource& GetResource(Uint32 r) const
{
VERIFY_EXPR(r < GetTotalResourceCount());
- auto* Resources = reinterpret_cast<const VkResource*>(m_ResourceBuffer.get());
+ const auto* Resources = reinterpret_cast<const VkResource*>(m_ResourceBuffer.get());
return Resources[r];
}
@@ -414,8 +414,16 @@ private:
return m_NumResources[SHADER_RESOURCE_VARIABLE_TYPE_NUM_TYPES];
}
+ const char* GetStringPoolData() const
+ {
+ const auto* ResourceDataEnd = reinterpret_cast<const VkResource*>(m_ResourceBuffer.get()) + GetTotalResourceCount();
+ const auto* SamplerDataEnd = reinterpret_cast<const ImmutableSamplerPtrType*>(ResourceDataEnd) + m_NumImmutableSamplers;
+ return reinterpret_cast<const char*>(SamplerDataEnd);
+ }
+
static constexpr Uint32 InvalidResourceIndex = ~0u;
+ // Maps resource name to its index in m_ResourceBuffer
using ResourceNameToIndex_t = std::unordered_map<HashMapStringKey, Uint32, HashMapStringKey::Hasher>;
StringPool AllocateMemory(const std::vector<const ShaderVkImpl*>& Shaders,
IMemoryAllocator& Allocator,
diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp
index 499c35ef..76bd77ee 100644
--- a/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp
@@ -135,11 +135,15 @@ StringPool ShaderResourceLayoutVk::AllocateMemory(const std::vector<const Shader
VERIFY_EXPR(Shaders.size() > 0);
VERIFY_EXPR(m_ShaderType == SHADER_TYPE_UNKNOWN);
- size_t StringPoolSize = 0;
m_ShaderType = Shaders[0]->GetDesc().ShaderType;
m_IsUsingSeparateSamplers = !Shaders[0]->GetShaderResources()->IsUsingCombinedSamplers();
const Uint32 AllowedTypeBits = GetAllowedTypeBits(AllowedVarTypes, NumAllowedTypes);
+ // Construct shader or shader group name
+ const auto ShaderName = GetShaderGroupName(Shaders);
+
+ size_t StringPoolSize = ShaderName.length() + 1;
+
// Count the number of resources to allocate all needed memory
for (size_t s = 0; s < Shaders.size(); ++s)
{
@@ -202,11 +206,13 @@ StringPool ShaderResourceLayoutVk::AllocateMemory(const std::vector<const Shader
m_ResourceBuffer = std::unique_ptr<void, STDDeleterRawMem<void>>(MemPool.Release(), Allocator);
- VERIFY_EXPR(m_ResourceBuffer.get() == pResources);
- VERIFY_EXPR(m_NumImmutableSamplers == 0 || pImtblSamplers == std::addressof(GetImmutableSampler(0)));
+ VERIFY_EXPR(pResources == nullptr || m_ResourceBuffer.get() == pResources);
+ VERIFY_EXPR(pImtblSamplers == nullptr || pImtblSamplers == std::addressof(GetImmutableSampler(0)));
+ VERIFY_EXPR(pStringData == GetStringPoolData());
StringPool stringPool;
stringPool.AssignMemory(pStringData, StringPoolSize);
+ stringPool.CopyString(ShaderName);
return stringPool;
}