diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2018-10-27 19:18:36 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2018-10-27 19:18:36 +0000 |
| commit | 42a13a57e3fe892d2f9fb649e1ae1b4511be3b13 (patch) | |
| tree | 728773f3e9f7704e1fb9d7b4fe0ef54ec83ce40f /Graphics/GLSLTools | |
| parent | Moved all HLSL definitions to premable when using glslang; not exposing separ... (diff) | |
| download | DiligentCore-42a13a57e3fe892d2f9fb649e1ae1b4511be3b13.tar.gz DiligentCore-42a13a57e3fe892d2f9fb649e1ae1b4511be3b13.zip | |
Some improvements to SPIRVShaderResources
Diffstat (limited to 'Graphics/GLSLTools')
| -rw-r--r-- | Graphics/GLSLTools/include/SPIRVShaderResources.h | 125 | ||||
| -rw-r--r-- | Graphics/GLSLTools/src/SPIRVShaderResources.cpp | 63 | ||||
| -rw-r--r-- | Graphics/GLSLTools/src/SPIRVUtils.cpp | 2 |
3 files changed, 115 insertions, 75 deletions
diff --git a/Graphics/GLSLTools/include/SPIRVShaderResources.h b/Graphics/GLSLTools/include/SPIRVShaderResources.h index 27764816..7455233e 100644 --- a/Graphics/GLSLTools/include/SPIRVShaderResources.h +++ b/Graphics/GLSLTools/include/SPIRVShaderResources.h @@ -30,7 +30,7 @@ // // m_MemoryBuffer m_TotalResources // | | -// | Uniform Buffers | Storage Buffers | Storage Images | Sampled Images | Atomic Counters | Separate Samplers | Separate Images | Static Samplers | Resource Names | +// | Uniform Buffers | Storage Buffers | Storage Images | Sampled Images | Atomic Counters | Separate Samplers | Separate Images | Immutable Samplers | Resource Names | #include <memory> #include <vector> @@ -69,7 +69,7 @@ inline Uint32 GetAllowedTypeBits(const SHADER_VARIABLE_TYPE* AllowedVarTypes, Ui return AllowedTypeBits; } - +// sizeof(SPIRVShaderResourceAttribs) == 24, msvc x64 struct SPIRVShaderResourceAttribs { enum ResourceType : Uint8 @@ -91,39 +91,79 @@ struct SPIRVShaderResourceAttribs static_assert(SHADER_VARIABLE_TYPE_NUM_TYPES < (1 << VarTypeBits), "Not enough bits to represent SHADER_VARIABLE_TYPE"); static_assert(ResourceType::NumResourceTypes < (1 << ResourceTypeBits), "Not enough bits to represent ResourceType"); - const char *Name; - const Uint16 ArraySize; - const ResourceType Type : ResourceTypeBits; - const SHADER_VARIABLE_TYPE VarType : VarTypeBits; - const Int8 StaticSamplerInd; - static constexpr const Uint32 InvalidSepSmplrOrImgInd = static_cast<Uint32>(-1); - // Used when HLSL shaders are compiled using combined texture samplers. - Uint32 SepSmplrOrImgInd = InvalidSepSmplrOrImgInd; - // Offset in SPIRV words (uint32_t) of binding & descriptor set decorations in SPIRV binary - const uint32_t BindingDecorationOffset; - const uint32_t DescriptorSetDecorationOffset; +/* 0 */const char* const Name; +/* 8 */const Uint16 ArraySize; +/*10.0*/const ResourceType Type : ResourceTypeBits; +/*10.4*/const SHADER_VARIABLE_TYPE VarType : VarTypeBits; +private: + static constexpr const Uint8 InvalidImmutableSamplerInd = static_cast<Uint8>(-1); +/*11*/const Uint8 ImmutableSamplerInd; + + // Defines mapping between separate samplers and seperate images when HLSL-style + // combined texture samplers are in use (i.e. texture2D g_Tex + sampler g_Tex_sampler). +/*12*/ Uint32 SepSmplrOrImgInd = InvalidSepSmplrOrImgInd; +public: + // Offset in SPIRV words (uint32_t) of binding & descriptor set decorations in SPIRV binary +/*16*/const uint32_t BindingDecorationOffset; +/*20*/const uint32_t DescriptorSetDecorationOffset; + - bool ValidSepSamplerAssigned() const + SPIRVShaderResourceAttribs(const spirv_cross::Compiler& Compiler, + const spirv_cross::Resource& Res, + const char* _Name, + ResourceType _Type, + SHADER_VARIABLE_TYPE _VarType, + Int32 _ImmutableSamplerInd, + Uint32 _SamplerOrSepImgInd = InvalidSepSmplrOrImgInd)noexcept; + + bool IsValidSepSamplerAssigned() const { VERIFY_EXPR(Type == SeparateImage); return SepSmplrOrImgInd != InvalidSepSmplrOrImgInd; } - bool ValidSepImageAssigned() const + bool IsValidSepImageAssigned() const { VERIFY_EXPR(Type == SeparateSampler); return SepSmplrOrImgInd != InvalidSepSmplrOrImgInd; } - SPIRVShaderResourceAttribs(const spirv_cross::Compiler& Compiler, - const spirv_cross::Resource& Res, - const char* _Name, - ResourceType _Type, - SHADER_VARIABLE_TYPE _VarType, - Int32 _StaticSamplerInd, - Uint32 _SamplerOrSepImgId = InvalidSepSmplrOrImgInd)noexcept; + Uint32 GetAssignedSepSamplerInd() const + { + VERIFY_EXPR(Type == SeparateImage); + return SepSmplrOrImgInd; + } + + Uint32 GetAssignedSepImageInd() const + { + VERIFY_EXPR(Type == SeparateSampler); + return SepSmplrOrImgInd; + } + + void AssignSeparateSampler(Uint32 SemSamplerInd) + { + VERIFY_EXPR(Type == SeparateImage); + SepSmplrOrImgInd = SemSamplerInd; + } + + void AssignSeparateImage(Uint32 SepImageInd) + { + VERIFY_EXPR(Type == SeparateSampler); + SepSmplrOrImgInd = SepImageInd; + } + + bool IsImmutableSamplerAssigned() const + { + return ImmutableSamplerInd != InvalidImmutableSamplerInd; + } + + Uint32 GetImmutableSamplerInd()const + { + VERIFY(Type == ResourceType::SampledImage || Type == ResourceType::SeparateSampler, "Only sampled images and separate samplers can be assigned immutable samplers"); + return ImmutableSamplerInd; + } String GetPrintName(Uint32 ArrayInd)const { @@ -144,7 +184,8 @@ struct SPIRVShaderResourceAttribs Type == Attribs.Type && VarType == Attribs.VarType && SepSmplrOrImgInd == Attribs.SepSmplrOrImgInd && - (StaticSamplerInd < 0 && Attribs.StaticSamplerInd < 0 || StaticSamplerInd >= 0 && Attribs.StaticSamplerInd >= 0); + ( IsImmutableSamplerAssigned() && Attribs.IsImmutableSamplerAssigned() || + !IsImmutableSamplerAssigned() && !Attribs.IsImmutableSamplerAssigned()); } }; static_assert(sizeof(SPIRVShaderResourceAttribs) % sizeof(void*) == 0, "Size of SPIRVShaderResourceAttribs struct must be multiple of sizeof(void*)" ); @@ -159,10 +200,10 @@ public: const ShaderDesc& shaderDesc, const char* CombinedSamplerSuffix); - SPIRVShaderResources (const SPIRVShaderResources&) = delete; - SPIRVShaderResources (SPIRVShaderResources&&) = delete; - SPIRVShaderResources& operator = (const SPIRVShaderResources&) = delete; - SPIRVShaderResources& operator = (SPIRVShaderResources&&) = delete; + SPIRVShaderResources (const SPIRVShaderResources&) = delete; + SPIRVShaderResources ( SPIRVShaderResources&&) = delete; + SPIRVShaderResources& operator = (const SPIRVShaderResources&) = delete; + SPIRVShaderResources& operator = ( SPIRVShaderResources&&) = delete; ~SPIRVShaderResources(); @@ -175,8 +216,8 @@ public: Uint32 GetNumACs ()const noexcept{ return (m_SeparateSamplerOffset - m_AtomicCounterOffset); } Uint32 GetNumSepSmplrs()const noexcept{ return (m_SeparateImageOffset - m_SeparateSamplerOffset);} Uint32 GetNumSepImgs ()const noexcept{ return (m_TotalResources - m_SeparateImageOffset); } - Uint32 GetTotalResources() const noexcept { return m_TotalResources; } - Uint32 GetNumStaticSamplers()const noexcept { return m_NumStaticSamplers; } + Uint32 GetTotalResources() const noexcept { return m_TotalResources; } + Uint32 GetNumImmutableSamplers()const noexcept { return m_NumImmutableSamplers; } const SPIRVShaderResourceAttribs& GetUB (Uint32 n)const noexcept{ return GetResAttribs(n, GetNumUBs(), 0 ); } const SPIRVShaderResourceAttribs& GetSB (Uint32 n)const noexcept{ return GetResAttribs(n, GetNumSBs(), m_StorageBufferOffset ); } @@ -187,15 +228,15 @@ public: const SPIRVShaderResourceAttribs& GetSepImg (Uint32 n)const noexcept{ return GetResAttribs(n, GetNumSepImgs(), m_SeparateImageOffset ); } const SPIRVShaderResourceAttribs& GetResource(Uint32 n)const noexcept{ return GetResAttribs(n, GetTotalResources(), 0 ); } - ISampler* GetStaticSampler(const SPIRVShaderResourceAttribs& ResAttribs)const noexcept + ISampler* GetImmutableSampler(const SPIRVShaderResourceAttribs& ResAttribs)const noexcept { - if(ResAttribs.StaticSamplerInd < 0) + if (!ResAttribs.IsImmutableSamplerAssigned()) return nullptr; - VERIFY_EXPR(ResAttribs.Type == SPIRVShaderResourceAttribs::ResourceType::SampledImage || ResAttribs.Type == SPIRVShaderResourceAttribs::ResourceType::SeparateSampler); - VERIFY(ResAttribs.StaticSamplerInd < m_NumStaticSamplers, "Static sampler index (", ResAttribs.StaticSamplerInd, ") is out of range. Array size: ", m_NumStaticSamplers); - auto *ResourceMemoryEnd = reinterpret_cast<SPIRVShaderResourceAttribs*>(m_MemoryBuffer.get()) + m_TotalResources; - return reinterpret_cast<SamplerPtrType*>(ResourceMemoryEnd)[ResAttribs.StaticSamplerInd]; + auto ImmutableSamplerInd = ResAttribs.GetImmutableSamplerInd(); + VERIFY(ImmutableSamplerInd < m_NumImmutableSamplers, "Static sampler index (", ImmutableSamplerInd, ") is out of range. Array size: ", m_NumImmutableSamplers); + auto* ResourceMemoryEnd = reinterpret_cast<SPIRVShaderResourceAttribs*>(m_MemoryBuffer.get()) + m_TotalResources; + return reinterpret_cast<SamplerPtrType*>(ResourceMemoryEnd)[ImmutableSamplerInd]; } struct ResourceCounters @@ -307,10 +348,11 @@ public: const char* GetCombinedSamplerSuffix() const { return m_CombinedSamplerSuffix; } bool IsUsingCombinedSamplers() const { return m_CombinedSamplerSuffix != nullptr; } -protected: + +private: void Initialize(IMemoryAllocator& Allocator, const ResourceCounters& Counters, - Uint32 NumStaticSamplers, + Uint32 NumImmutableSamplers, size_t ResourceNamesPoolSize); __forceinline SPIRVShaderResourceAttribs& GetResAttribs(Uint32 n, Uint32 NumResources, Uint32 Offset)noexcept @@ -336,14 +378,13 @@ protected: SPIRVShaderResourceAttribs& GetSepImg (Uint32 n)noexcept{ return GetResAttribs(n, GetNumSepImgs(), m_SeparateImageOffset ); } SPIRVShaderResourceAttribs& GetResource(Uint32 n)noexcept{ return GetResAttribs(n, GetTotalResources(), 0 ); } - SamplerPtrType& GetStaticSampler(Uint32 n)noexcept + SamplerPtrType& GetImmutableSampler(Uint32 n)noexcept { - VERIFY(n < m_NumStaticSamplers, "Static sampler index (", n, ") is out of range. Array size: ", m_NumStaticSamplers); - auto *ResourceMemoryEnd = reinterpret_cast<SPIRVShaderResourceAttribs*>(m_MemoryBuffer.get()) + m_TotalResources; + VERIFY(n < m_NumImmutableSamplers, "Static sampler index (", n, ") is out of range. Array size: ", m_NumImmutableSamplers); + auto* ResourceMemoryEnd = reinterpret_cast<SPIRVShaderResourceAttribs*>(m_MemoryBuffer.get()) + m_TotalResources; return reinterpret_cast<SamplerPtrType*>(ResourceMemoryEnd)[n]; } -private: // Memory buffer that holds all resources as continuous chunk of memory: // | UBs | SBs | StrgImgs | SmplImgs | ACs | SepSamplers | SepImgs | Static Samplers | Resource Names | std::unique_ptr< void, STDDeleterRawMem<void> > m_MemoryBuffer; @@ -359,7 +400,7 @@ private: OffsetType m_SeparateSamplerOffset = 0; OffsetType m_SeparateImageOffset = 0; OffsetType m_TotalResources = 0; - OffsetType m_NumStaticSamplers = 0; + OffsetType m_NumImmutableSamplers = 0; SHADER_TYPE m_ShaderType = SHADER_TYPE_UNKNOWN; }; diff --git a/Graphics/GLSLTools/src/SPIRVShaderResources.cpp b/Graphics/GLSLTools/src/SPIRVShaderResources.cpp index 524a96c6..22c0f279 100644 --- a/Graphics/GLSLTools/src/SPIRVShaderResources.cpp +++ b/Graphics/GLSLTools/src/SPIRVShaderResources.cpp @@ -63,24 +63,25 @@ SPIRVShaderResourceAttribs::SPIRVShaderResourceAttribs(const spirv_cross::Compil const char* _Name, ResourceType _Type, SHADER_VARIABLE_TYPE _VarType, - Int32 _StaticSamplerInd, + Int32 _ImmutableSamplerInd, Uint32 _SepSmplrOrImgInd)noexcept : Name (_Name), ArraySize (GetResourceArraySize<decltype(ArraySize)>(Compiler, Res)), Type (_Type), VarType (_VarType), - StaticSamplerInd (static_cast<decltype(StaticSamplerInd)>(_StaticSamplerInd)), + ImmutableSamplerInd (_ImmutableSamplerInd >= 0 ? static_cast<decltype(ImmutableSamplerInd)>(_ImmutableSamplerInd) : InvalidImmutableSamplerInd), SepSmplrOrImgInd (_SepSmplrOrImgInd), BindingDecorationOffset (GetDecorationOffset(Compiler, Res, spv::Decoration::DecorationBinding)), DescriptorSetDecorationOffset(GetDecorationOffset(Compiler, Res, spv::Decoration::DecorationDescriptorSet)) { - VERIFY(_StaticSamplerInd >= std::numeric_limits<decltype(StaticSamplerInd)>::min() && - _StaticSamplerInd <= std::numeric_limits<decltype(StaticSamplerInd)>::max(), "Static sampler index is out of representable range" ); + VERIFY(_ImmutableSamplerInd < 0 || _ImmutableSamplerInd <= std::numeric_limits<decltype(ImmutableSamplerInd)>::max(), "Static sampler index is out of representable range" ); + VERIFY(_SepSmplrOrImgInd == SPIRVShaderResourceAttribs::InvalidSepSmplrOrImgInd || _Type == ResourceType::SeparateSampler || + _Type == ResourceType::SeparateImage, "Only separate images or separate samplers can be assinged valid SepSmplrOrImgInd value"); } -static Int32 FindStaticSampler(const ShaderDesc& shaderDesc, const std::string& SamplerName, const char* SamplerSuffix) +static Int32 FindImmutableSampler(const ShaderDesc& shaderDesc, const std::string& SamplerName, const char* SamplerSuffix) { - for(Uint32 s=0; s < shaderDesc.NumStaticSamplers; ++s) + for (Uint32 s=0; s < shaderDesc.NumStaticSamplers; ++s) { const auto& StSam = shaderDesc.StaticSamplers[s]; if (StreqSuff(SamplerName.c_str(), StSam.SamplerOrTextureName, SamplerSuffix)) @@ -168,7 +169,7 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator, Uint32 CurrSmplImg = 0; for (const auto &SmplImg : resources.sampled_images) { - auto StaticSamplerInd = FindStaticSampler(shaderDesc, SmplImg.name, nullptr); + auto ImmutableSamplerInd = FindImmutableSampler(shaderDesc, SmplImg.name, nullptr); const auto& type = Compiler.get_type(SmplImg.type_id); auto ResType = type.image.dim == spv::DimBuffer ? SPIRVShaderResourceAttribs::ResourceType::UniformTexelBuffer : @@ -179,7 +180,7 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator, m_ResourceNames.CopyString(SmplImg.name), ResType, GetShaderVariableType(SmplImg.name, shaderDesc), - StaticSamplerInd); + ImmutableSamplerInd); } VERIFY_EXPR(CurrSmplImg == GetNumSmpldImgs()); } @@ -222,7 +223,7 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator, Uint32 CurrSepSmpl = 0; for (const auto &SepSam : resources.separate_samplers) { - auto StaticSamplerInd = FindStaticSampler(shaderDesc, SepSam.name, CombinedSamplerSuffix); + auto ImmutableSamplerInd = FindImmutableSampler(shaderDesc, SepSam.name, CombinedSamplerSuffix); // Use texture or sampler name to derive sampler type auto VarType = GetShaderVariableType(shaderDesc.DefaultVariableType, shaderDesc.VariableDesc, shaderDesc.NumVariables, [&](const char* VarName) @@ -236,7 +237,7 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator, m_ResourceNames.CopyString(SepSam.name), SPIRVShaderResourceAttribs::ResourceType::SeparateSampler, VarType, - StaticSamplerInd); + ImmutableSamplerInd); } VERIFY_EXPR(CurrSepSmpl == GetNumSepSmplrs()); } @@ -254,8 +255,8 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator, auto& SepSmplr = GetSepSmplr(SamplerInd); if (StreqSuff(SepSmplr.Name, SepImg.name.c_str(), CombinedSamplerSuffix)) { - SepSmplr.SepSmplrOrImgInd = static_cast<Uint16>(CurrSepImg); - if (SepSmplr.StaticSamplerInd >= 0) + SepSmplr.AssignSeparateImage(CurrSepImg); + if (SepSmplr.IsImmutableSamplerAssigned()) SamplerInd = NumSepSmpls; break; } @@ -271,9 +272,9 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator, GetShaderVariableType(SepImg.name, shaderDesc), -1, SamplerInd); - if (pNewSepImg->ValidSepSamplerAssigned()) + if (pNewSepImg->IsValidSepSamplerAssigned()) { - const auto& SepSmplr = GetSepSmplr(pNewSepImg->SepSmplrOrImgInd); + const auto& SepSmplr = GetSepSmplr(pNewSepImg->GetAssignedSepSamplerInd()); DEV_CHECK_ERR(SepSmplr.ArraySize == 1 || SepSmplr.ArraySize == pNewSepImg->ArraySize, "Array size (", SepSmplr.ArraySize,") of separate sampler variable '", SepSmplr.Name, "' must be one or same as the array size (", pNewSepImg->ArraySize, @@ -290,9 +291,9 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator, VERIFY(m_ResourceNames.GetRemainingSize() == 0, "Names pool must be empty"); - for (Uint32 s = 0; s < m_NumStaticSamplers; ++s) + for (Uint32 s = 0; s < m_NumImmutableSamplers; ++s) { - SamplerPtrType &pStaticSampler = GetStaticSampler(s); + SamplerPtrType &pStaticSampler = GetImmutableSampler(s); new (std::addressof(pStaticSampler)) SamplerPtrType(); pRenderDevice->CreateSampler(shaderDesc.StaticSamplers[s].Desc, &pStaticSampler); } @@ -362,7 +363,7 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator, for (Uint32 n=0; n < GetNumSepSmplrs(); ++n) { const auto& SepSmplr = GetSepSmplr(n); - if (!SepSmplr.ValidSepImageAssigned()) + if (!SepSmplr.IsValidSepImageAssigned()) LOG_ERROR_MESSAGE("Shader '", shaderDesc.Name, "' uses combined texture samplers, but separate sampler '", SepSmplr.Name, "' is not assigned to any texture"); } } @@ -371,7 +372,7 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator, void SPIRVShaderResources::Initialize(IMemoryAllocator& Allocator, const ResourceCounters& Counters, - Uint32 NumStaticSamplers, + Uint32 NumImmutableSamplers, size_t ResourceNamesPoolSize) { Uint32 CurrentOffset = 0; @@ -393,14 +394,14 @@ void SPIRVShaderResources::Initialize(IMemoryAllocator& Allocator, m_SeparateImageOffset = AdvanceOffset(Counters.NumSepImgs); m_TotalResources = AdvanceOffset(0); - VERIFY(NumStaticSamplers <= MaxOffset, "Max offset exceeded"); - m_NumStaticSamplers = static_cast<OffsetType>(NumStaticSamplers); + VERIFY(NumImmutableSamplers <= MaxOffset, "Max offset exceeded"); + m_NumImmutableSamplers = static_cast<OffsetType>(NumImmutableSamplers); static_assert(sizeof(SPIRVShaderResourceAttribs) % sizeof(void*) == 0, "Size of SPIRVShaderResourceAttribs struct must be multiple of sizeof(void*)"); - static_assert(sizeof(SamplerPtrType) % sizeof(void*) == 0, "Size of SamplerPtrType must be multiple of sizeof(void*)"); - auto MemorySize = m_TotalResources * sizeof(SPIRVShaderResourceAttribs) + - m_NumStaticSamplers * sizeof(SamplerPtrType) + - ResourceNamesPoolSize * sizeof(char); + static_assert(sizeof(SamplerPtrType) % sizeof(void*) == 0, "Size of SamplerPtrType must be multiple of sizeof(void*)"); + auto MemorySize = m_TotalResources * sizeof(SPIRVShaderResourceAttribs) + + m_NumImmutableSamplers * sizeof(SamplerPtrType) + + ResourceNamesPoolSize * sizeof(char); VERIFY_EXPR(GetNumUBs() == Counters.NumUBs); VERIFY_EXPR(GetNumSBs() == Counters.NumSBs); @@ -416,7 +417,7 @@ void SPIRVShaderResources::Initialize(IMemoryAllocator& Allocator, m_MemoryBuffer = std::unique_ptr<void, STDDeleterRawMem<void>>(pRawMem, Allocator); char* NamesPool = reinterpret_cast<char*>(m_MemoryBuffer.get()) + m_TotalResources * sizeof(SPIRVShaderResourceAttribs) + - m_NumStaticSamplers * sizeof(SamplerPtrType); + m_NumImmutableSamplers * sizeof(SamplerPtrType); m_ResourceNames.AssignMemory(NamesPool, ResourceNamesPoolSize); } } @@ -444,8 +445,8 @@ SPIRVShaderResources::~SPIRVShaderResources() for (Uint32 n = 0; n < GetNumSepImgs(); ++n) GetSepImg(n).~SPIRVShaderResourceAttribs(); - for (Uint32 n = 0; n < GetNumStaticSamplers(); ++n) - GetStaticSampler(n).~SamplerPtrType(); + for (Uint32 n = 0; n < GetNumImmutableSamplers(); ++n) + GetImmutableSampler(n).~SamplerPtrType(); } SPIRVShaderResources::ResourceCounters SPIRVShaderResources::CountResources(const SHADER_VARIABLE_TYPE* AllowedVarTypes, @@ -509,7 +510,7 @@ std::string SPIRVShaderResources::DumpResources() ss << "Resource counters (" << GetTotalResources() << " total):" << std::endl << "UBs: " << GetNumUBs() << "; SBs: " << GetNumSBs() << "; Imgs: " << GetNumImgs() << "; Smpl Imgs: " << GetNumSmpldImgs() << "; ACs: " << GetNumACs() << "; Sep Imgs: " << GetNumSepImgs() << "; Sep Smpls: " << GetNumSepSmplrs() << '.' << std::endl - << "Num Static Samplers: " << GetNumStaticSamplers() << std::endl << "Resources:"; + << "Num Static Samplers: " << GetNumImmutableSamplers() << std::endl << "Resources:"; Uint32 ResNum = 0; auto DumpResource = [&ss, &ResNum](const SPIRVShaderResourceAttribs& Res) @@ -522,9 +523,9 @@ std::string SPIRVShaderResources::DumpResources() ss << std::setw(32) << FullResNameSS.str(); ss << " (" << GetShaderVariableTypeLiteralName(Res.VarType) << ")"; - if (Res.StaticSamplerInd >= 0) + if (Res.IsImmutableSamplerAssigned()) { - ss << " Static sampler: " << Int32{ Res.StaticSamplerInd }; + ss << " Immutable sampler: " << Res.GetImmutableSamplerInd(); } ++ResNum; }; @@ -597,7 +598,7 @@ bool SPIRVShaderResources::IsCompatibleWith(const SPIRVShaderResources& Resource GetNumACs() != Resources.GetNumACs() || GetNumSepImgs() != Resources.GetNumSepImgs() || GetNumSepSmplrs() != Resources.GetNumSepSmplrs() || - GetNumStaticSamplers() != Resources.GetNumStaticSamplers() ) + GetNumImmutableSamplers() != Resources.GetNumImmutableSamplers() ) return false; VERIFY_EXPR(GetTotalResources() == Resources.GetTotalResources()); diff --git a/Graphics/GLSLTools/src/SPIRVUtils.cpp b/Graphics/GLSLTools/src/SPIRVUtils.cpp index 1578b194..8f5998d5 100644 --- a/Graphics/GLSLTools/src/SPIRVUtils.cpp +++ b/Graphics/GLSLTools/src/SPIRVUtils.cpp @@ -415,8 +415,6 @@ std::vector<unsigned int> HLSLtoSPIRV(const ShaderCreationAttribs& Attribs, IDat { EShLanguage ShLang = ShaderTypeToShLanguage(Attribs.Desc.ShaderType); glslang::TShader Shader(ShLang); - TBuiltInResource Resources = InitResources(); - EShMessages messages = (EShMessages)(EShMsgSpvRules | EShMsgVulkanRules | EShMsgReadHlsl | EShMsgHlslLegalization); VERIFY_EXPR(Attribs.SourceLanguage == SHADER_SOURCE_LANGUAGE_HLSL); |
