summaryrefslogtreecommitdiffstats
path: root/Graphics/ShaderTools
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-10-05 06:12:01 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-10-05 06:12:01 +0000
commit70a78823b86f3877fd4bc60c4d3ea1b929267df9 (patch)
tree37c8da0ee238ea06b4ff14b430be468c3ba5c3a5 /Graphics/ShaderTools
parentRemoved StringView; using unordered_maps in BLAS, TLAS and SBT (diff)
parentAll backends: removed string pool from shader resource objects as it is only ... (diff)
downloadDiligentCore-70a78823b86f3877fd4bc60c4d3ea1b929267df9.tar.gz
DiligentCore-70a78823b86f3877fd4bc60c4d3ea1b929267df9.zip
Merge branch 'master'
Diffstat (limited to 'Graphics/ShaderTools')
-rw-r--r--Graphics/ShaderTools/include/SPIRVShaderResources.hpp5
-rw-r--r--Graphics/ShaderTools/src/SPIRVShaderResources.cpp34
2 files changed, 21 insertions, 18 deletions
diff --git a/Graphics/ShaderTools/include/SPIRVShaderResources.hpp b/Graphics/ShaderTools/include/SPIRVShaderResources.hpp
index 7a1b93ce..5c35de33 100644
--- a/Graphics/ShaderTools/include/SPIRVShaderResources.hpp
+++ b/Graphics/ShaderTools/include/SPIRVShaderResources.hpp
@@ -348,7 +348,8 @@ private:
void Initialize(IMemoryAllocator& Allocator,
const ResourceCounters& Counters,
Uint32 NumShaderStageInputs,
- size_t ResourceNamesPoolSize);
+ size_t ResourceNamesPoolSize,
+ StringPool& ResourceNamesPool);
SPIRVShaderResourceAttribs& GetResAttribs(Uint32 n, Uint32 NumResources, Uint32 Offset) noexcept
{
@@ -387,8 +388,6 @@ private:
// | UBs | SBs | StrgImgs | SmplImgs | ACs | SepSamplers | SepImgs | Stage Inputs | Resource Names |
std::unique_ptr<void, STDDeleterRawMem<void>> m_MemoryBuffer;
- StringPool m_ResourceNames;
-
const char* m_CombinedSamplerSuffix = nullptr;
const char* m_ShaderName = nullptr;
diff --git a/Graphics/ShaderTools/src/SPIRVShaderResources.cpp b/Graphics/ShaderTools/src/SPIRVShaderResources.cpp
index f21d2075..dbdc81bc 100644
--- a/Graphics/ShaderTools/src/SPIRVShaderResources.cpp
+++ b/Graphics/ShaderTools/src/SPIRVShaderResources.cpp
@@ -338,7 +338,10 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator,
ResCounters.NumSepImgs = static_cast<Uint32>(resources.separate_images.size());
ResCounters.NumInptAtts = static_cast<Uint32>(resources.subpass_inputs.size());
static_assert(SPIRVShaderResourceAttribs::ResourceType::NumResourceTypes == 11, "Please set the new resource type counter here");
- Initialize(Allocator, ResCounters, NumShaderStageInputs, ResourceNamesPoolSize);
+
+ // Resource names pool is only needed to facilitate string allocation.
+ StringPool ResourceNamesPool;
+ Initialize(Allocator, ResCounters, NumShaderStageInputs, ResourceNamesPoolSize, ResourceNamesPool);
{
Uint32 CurrUB = 0;
@@ -348,7 +351,7 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator,
new (&GetUB(CurrUB++))
SPIRVShaderResourceAttribs(Compiler,
UB,
- m_ResourceNames.CopyString(name),
+ ResourceNamesPool.CopyString(name),
SPIRVShaderResourceAttribs::ResourceType::UniformBuffer);
}
VERIFY_EXPR(CurrUB == GetNumUBs());
@@ -366,7 +369,7 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator,
new (&GetSB(CurrSB++))
SPIRVShaderResourceAttribs(Compiler,
SB,
- m_ResourceNames.CopyString(SB.name),
+ ResourceNamesPool.CopyString(SB.name),
ResType);
}
VERIFY_EXPR(CurrSB == GetNumSBs());
@@ -383,7 +386,7 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator,
new (&GetSmpldImg(CurrSmplImg++))
SPIRVShaderResourceAttribs(Compiler,
SmplImg,
- m_ResourceNames.CopyString(SmplImg.name),
+ ResourceNamesPool.CopyString(SmplImg.name),
ResType);
}
VERIFY_EXPR(CurrSmplImg == GetNumSmpldImgs());
@@ -400,7 +403,7 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator,
new (&GetImg(CurrImg++))
SPIRVShaderResourceAttribs(Compiler,
Img,
- m_ResourceNames.CopyString(Img.name),
+ ResourceNamesPool.CopyString(Img.name),
ResType);
}
VERIFY_EXPR(CurrImg == GetNumImgs());
@@ -413,7 +416,7 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator,
new (&GetAC(CurrAC++))
SPIRVShaderResourceAttribs(Compiler,
AC,
- m_ResourceNames.CopyString(AC.name),
+ ResourceNamesPool.CopyString(AC.name),
SPIRVShaderResourceAttribs::ResourceType::AtomicCounter);
}
VERIFY_EXPR(CurrAC == GetNumACs());
@@ -426,7 +429,7 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator,
new (&GetSepSmplr(CurrSepSmpl++))
SPIRVShaderResourceAttribs(Compiler,
SepSam,
- m_ResourceNames.CopyString(SepSam.name),
+ ResourceNamesPool.CopyString(SepSam.name),
SPIRVShaderResourceAttribs::ResourceType::SeparateSampler);
}
VERIFY_EXPR(CurrSepSmpl == GetNumSepSmplrs());
@@ -468,7 +471,7 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator,
auto* pNewSepImg = new (&GetSepImg(CurrSepImg++))
SPIRVShaderResourceAttribs(Compiler,
SepImg,
- m_ResourceNames.CopyString(SepImg.name),
+ ResourceNamesPool.CopyString(SepImg.name),
ResType,
SamplerInd);
if (ResType == SPIRVShaderResourceAttribs::ResourceType::SeparateImage && pNewSepImg->IsValidSepSamplerAssigned())
@@ -492,7 +495,7 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator,
new (&GetInptAtt(CurrSubpassInput++))
SPIRVShaderResourceAttribs(Compiler,
SubpassInput,
- m_ResourceNames.CopyString(SubpassInput.name),
+ ResourceNamesPool.CopyString(SubpassInput.name),
SPIRVShaderResourceAttribs::ResourceType::InputAttachment);
}
VERIFY_EXPR(CurrSubpassInput == GetNumInptAtts());
@@ -502,10 +505,10 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator,
if (CombinedSamplerSuffix != nullptr)
{
- m_CombinedSamplerSuffix = m_ResourceNames.CopyString(CombinedSamplerSuffix);
+ m_CombinedSamplerSuffix = ResourceNamesPool.CopyString(CombinedSamplerSuffix);
}
- m_ShaderName = m_ResourceNames.CopyString(shaderDesc.Name);
+ m_ShaderName = ResourceNamesPool.CopyString(shaderDesc.Name);
if (LoadShaderStageInputs)
{
@@ -516,13 +519,13 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator,
{
const auto& Semantic = Compiler.get_decoration_string(Input.id, spv::Decoration::DecorationHlslSemanticGOOGLE);
new (&GetShaderStageInputAttribs(CurrStageInput++))
- SPIRVShaderStageInputAttribs(m_ResourceNames.CopyString(Semantic), GetDecorationOffset(Compiler, Input, spv::Decoration::DecorationLocation));
+ SPIRVShaderStageInputAttribs(ResourceNamesPool.CopyString(Semantic), GetDecorationOffset(Compiler, Input, spv::Decoration::DecorationLocation));
}
}
VERIFY_EXPR(CurrStageInput == GetNumShaderStageInputs());
}
- VERIFY(m_ResourceNames.GetRemainingSize() == 0, "Names pool must be empty");
+ VERIFY(ResourceNamesPool.GetRemainingSize() == 0, "Names pool must be empty");
//LOG_INFO_MESSAGE(DumpResources());
@@ -542,7 +545,8 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator,
void SPIRVShaderResources::Initialize(IMemoryAllocator& Allocator,
const ResourceCounters& Counters,
Uint32 NumShaderStageInputs,
- size_t ResourceNamesPoolSize)
+ size_t ResourceNamesPoolSize,
+ StringPool& ResourceNamesPool)
{
Uint32 CurrentOffset = 0;
constexpr Uint32 MaxOffset = std::numeric_limits<OffsetType>::max();
@@ -593,7 +597,7 @@ void SPIRVShaderResources::Initialize(IMemoryAllocator& Allocator,
char* NamesPool = reinterpret_cast<char*>(m_MemoryBuffer.get()) +
m_TotalResources * sizeof(SPIRVShaderResourceAttribs) +
m_NumShaderStageInputs * sizeof(SPIRVShaderStageInputAttribs);
- m_ResourceNames.AssignMemory(NamesPool, ResourceNamesPoolSize);
+ ResourceNamesPool.AssignMemory(NamesPool, ResourceNamesPoolSize);
}
}