@@ -224,9 +224,9 @@ spv::ExecutionModel ShaderTypeToSpvExecutionModel(SHADER_TYPE ShaderType)
224224 }
225225}
226226
227- const std::string& GetUBName (diligent_spirv_cross::Compiler& Compiler,
228- const diligent_spirv_cross::Resource& UB,
229- const diligent_spirv_cross::ParsedIR::Source& IRSource)
227+ const std::string& GetUBOrSBName (diligent_spirv_cross::Compiler& Compiler,
228+ const diligent_spirv_cross::Resource& UB,
229+ const diligent_spirv_cross::ParsedIR::Source& IRSource)
230230{
231231 // Consider the following HLSL constant buffer:
232232 //
@@ -420,11 +420,12 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator,
420420
421421 size_t ResourceNamesPoolSize = 0 ;
422422 for (const diligent_spirv_cross::Resource& ub : resources.uniform_buffers )
423- ResourceNamesPoolSize += GetUBName (Compiler, ub, ParsedIRSource).length () + 1 ;
423+ ResourceNamesPoolSize += GetUBOrSBName (Compiler, ub, ParsedIRSource).length () + 1 ;
424+ for (const diligent_spirv_cross::Resource& sb : resources.storage_buffers )
425+ ResourceNamesPoolSize += GetUBOrSBName (Compiler, sb, ParsedIRSource).length () + 1 ;
424426 static_assert (Uint32{SPIRVShaderResourceAttribs::ResourceType::NumResourceTypes} == 12 , " Please account for the new resource type below" );
425427 for (auto * pResType :
426428 {
427- &resources.storage_buffers ,
428429 &resources.storage_images ,
429430 &resources.sampled_images ,
430431 &resources.atomic_counters ,
@@ -514,7 +515,7 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator,
514515 Uint32 CurrUB = 0 ;
515516 for (const diligent_spirv_cross::Resource& UB : resources.uniform_buffers )
516517 {
517- const std::string& name = GetUBName (Compiler, UB, ParsedIRSource);
518+ const std::string& name = GetUBOrSBName (Compiler, UB, ParsedIRSource);
518519 const diligent_spirv_cross::SPIRType& Type = Compiler.get_type (UB.type_id );
519520 const size_t Size = Compiler.get_declared_struct_size (Type);
520521 new (&GetUB (CurrUB++)) SPIRVShaderResourceAttribs //
@@ -538,6 +539,7 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator,
538539 Uint32 CurrSB = 0 ;
539540 for (const diligent_spirv_cross::Resource& SB : resources.storage_buffers )
540541 {
542+ const std::string& name = GetUBOrSBName (Compiler, SB, ParsedIRSource);
541543 diligent_spirv_cross::Bitset BufferFlags = Compiler.get_buffer_block_flags (SB.id );
542544 bool IsReadOnly = BufferFlags.get (spv::DecorationNonWritable);
543545
@@ -553,7 +555,7 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator,
553555 {
554556 Compiler,
555557 SB,
556- ResourceNamesPool.CopyString (SB. name ),
558+ ResourceNamesPool.CopyString (name),
557559 ResType,
558560 static_cast <Uint32>(Size),
559561 static_cast <Uint32>(Stride) //
0 commit comments