diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2019-03-04 02:09:24 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2019-03-04 02:09:24 +0000 |
| commit | 2808b9f671e29e27a4d04f6c8ea21c40d8c573eb (patch) | |
| tree | ef3a16a6b0271385b05127ce2223abc9475b6fc8 /Graphics/GraphicsEngineD3DBase | |
| parent | Implemented shader resource reflectio API in Vk backend (diff) | |
| download | DiligentCore-2808b9f671e29e27a4d04f6c8ea21c40d8c573eb.tar.gz DiligentCore-2808b9f671e29e27a4d04f6c8ea21c40d8c573eb.zip | |
Almost completed refactoring d3d11 backend to comply with the new API
Diffstat (limited to 'Graphics/GraphicsEngineD3DBase')
| -rw-r--r-- | Graphics/GraphicsEngineD3DBase/include/ShaderResources.h | 99 | ||||
| -rw-r--r-- | Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp | 230 |
2 files changed, 227 insertions, 102 deletions
diff --git a/Graphics/GraphicsEngineD3DBase/include/ShaderResources.h b/Graphics/GraphicsEngineD3DBase/include/ShaderResources.h index 64c8fe61..4c38c4f5 100644 --- a/Graphics/GraphicsEngineD3DBase/include/ShaderResources.h +++ b/Graphics/GraphicsEngineD3DBase/include/ShaderResources.h @@ -67,33 +67,35 @@ namespace Diligent { +// sizeof(D3DShaderResourceAttribs) == 16 (x64) struct D3DShaderResourceAttribs { - const char* const Name; +/* 0 */ const char* const Name; - const Uint16 BindPoint; - const Uint16 BindCount; +/* 8 */ const Uint16 BindPoint; +/*10 */ const Uint16 BindCount; private: // 4 4 24 // bit | 0 1 2 3 | 4 5 6 7 | 8 9 10 ... 31 | // | | | | // | InputType | SRV Dim | SamplerOrTexSRVIdBits | - static constexpr const Uint32 ShaderInputTypeBits = 4; - static constexpr const Uint32 SRVDimBits = 4; - static constexpr const Uint32 SamplerOrTexSRVIdBits = 24; + static constexpr const Uint32 ShaderInputTypeBits = 4; + static constexpr const Uint32 SRVDimBits = 4; + static constexpr const Uint32 SamplerOrTexSRVIdBits = 24; static_assert(ShaderInputTypeBits + SRVDimBits + SamplerOrTexSRVIdBits == 32, "Attributes are better be packed into 32 bits"); static_assert(D3D_SIT_UAV_RWSTRUCTURED_WITH_COUNTER < (1 << ShaderInputTypeBits), "Not enough bits to represent D3D_SHADER_INPUT_TYPE"); static_assert(D3D_SRV_DIMENSION_BUFFEREX < (1 << SRVDimBits), "Not enough bits to represent D3D_SRV_DIMENSION"); - // We need to use Uint32 instead of the actual type for reliability and correctness. - // There originally was a problem when the type of InputType was D3D_SHADER_INPUT_TYPE: - // the value of D3D_SIT_UAV_RWBYTEADDRESS (8) was interpreted as -8 (as the underlying enum type - // is signed) causing errors - const Uint32 InputType : ShaderInputTypeBits; // Max value: D3D_SIT_UAV_RWSTRUCTURED_WITH_COUNTER == 11 - const Uint32 SRVDimension : SRVDimBits; // Max value: D3D_SRV_DIMENSION_BUFFEREX == 11 - Uint32 SamplerOrTexSRVId : SamplerOrTexSRVIdBits; // Max value: 1048575 + // We need to use Uint32 instead of the actual type for reliability and correctness. + // There originally was a problem when the type of InputType was D3D_SHADER_INPUT_TYPE: + // the value of D3D_SIT_UAV_RWBYTEADDRESS (8) was interpreted as -8 (as the underlying enum type + // is signed) causing errors +/*12.0*/ const Uint32 InputType : ShaderInputTypeBits; // Max value: D3D_SIT_UAV_RWSTRUCTURED_WITH_COUNTER == 11 +/*12.4*/ const Uint32 SRVDimension : SRVDimBits; // Max value: D3D_SRV_DIMENSION_BUFFEREX == 11 +/*13.0*/ Uint32 SamplerOrTexSRVId : SamplerOrTexSRVIdBits; // Max value: 2^24-1 +/*16 */ // End of structure public: static constexpr const Uint32 InvalidSamplerId = (1 << SamplerOrTexSRVIdBits) - 1; @@ -224,10 +226,6 @@ public: SamplerOrTexSRVId == Attribs.SamplerOrTexSRVId; } - SHADER_RESOURCE_VARIABLE_TYPE FindVariableType(SHADER_TYPE ShaderType, - const PipelineResourceLayoutDesc& ResourceLayoutDesc, - const char* CombinedSamplerSuffix)const; - size_t GetHash()const { return ComputeHash(BindPoint, BindCount, InputType, SRVDimension, SamplerOrTexSRVId); @@ -240,33 +238,37 @@ static_assert(sizeof(D3DShaderResourceAttribs) == sizeof(void*) + sizeof(Uint32) class ShaderResources { public: - ShaderResources(SHADER_TYPE ShaderType); + ShaderResources(SHADER_TYPE ShaderType)noexcept : + m_ShaderType(ShaderType) + { + } - ShaderResources (const ShaderResources&) = delete; - ShaderResources (ShaderResources&&) = delete; - ShaderResources& operator = (const ShaderResources&) = delete; - ShaderResources& operator = (ShaderResources&&) = delete; + ShaderResources (const ShaderResources&) = delete; + ShaderResources ( ShaderResources&&) = delete; + ShaderResources& operator = (const ShaderResources&) = delete; + ShaderResources& operator = ( ShaderResources&&) = delete; ~ShaderResources(); - Uint32 GetNumCBs() const noexcept{ return (m_TexSRVOffset - 0); } - Uint32 GetNumTexSRV() const noexcept{ return (m_TexUAVOffset - m_TexSRVOffset); } - Uint32 GetNumTexUAV() const noexcept{ return (m_BufSRVOffset - m_TexUAVOffset); } - Uint32 GetNumBufSRV() const noexcept{ return (m_BufUAVOffset - m_BufSRVOffset); } - Uint32 GetNumBufUAV() const noexcept{ return (m_SamplersOffset - m_BufUAVOffset); } - Uint32 GetNumSamplers() const noexcept{ return (m_TotalResources - m_SamplersOffset); } - Uint32 GetTotalResources()const noexcept{ return m_TotalResources; } - - const D3DShaderResourceAttribs& GetCB (Uint32 n)const noexcept{ return GetResAttribs(n, GetNumCBs(), 0); } - const D3DShaderResourceAttribs& GetTexSRV (Uint32 n)const noexcept{ return GetResAttribs(n, GetNumTexSRV(), m_TexSRVOffset); } - const D3DShaderResourceAttribs& GetTexUAV (Uint32 n)const noexcept{ return GetResAttribs(n, GetNumTexUAV(), m_TexUAVOffset); } - const D3DShaderResourceAttribs& GetBufSRV (Uint32 n)const noexcept{ return GetResAttribs(n, GetNumBufSRV(), m_BufSRVOffset); } - const D3DShaderResourceAttribs& GetBufUAV (Uint32 n)const noexcept{ return GetResAttribs(n, GetNumBufUAV(), m_BufUAVOffset); } - const D3DShaderResourceAttribs& GetSampler(Uint32 n)const noexcept{ return GetResAttribs(n, GetNumSamplers(), m_SamplersOffset); } + Uint32 GetNumCBs() const noexcept { return (m_TexSRVOffset - 0); } + Uint32 GetNumTexSRV() const noexcept { return (m_TexUAVOffset - m_TexSRVOffset); } + Uint32 GetNumTexUAV() const noexcept { return (m_BufSRVOffset - m_TexUAVOffset); } + Uint32 GetNumBufSRV() const noexcept { return (m_BufUAVOffset - m_BufSRVOffset); } + Uint32 GetNumBufUAV() const noexcept { return (m_SamplersOffset - m_BufUAVOffset); } + Uint32 GetNumSamplers() const noexcept { return (m_TotalResources - m_SamplersOffset); } + Uint32 GetTotalResources()const noexcept { return m_TotalResources; } + + const D3DShaderResourceAttribs& GetCB (Uint32 n)const noexcept { return GetResAttribs(n, GetNumCBs(), 0); } + const D3DShaderResourceAttribs& GetTexSRV (Uint32 n)const noexcept { return GetResAttribs(n, GetNumTexSRV(), m_TexSRVOffset); } + const D3DShaderResourceAttribs& GetTexUAV (Uint32 n)const noexcept { return GetResAttribs(n, GetNumTexUAV(), m_TexUAVOffset); } + const D3DShaderResourceAttribs& GetBufSRV (Uint32 n)const noexcept { return GetResAttribs(n, GetNumBufSRV(), m_BufSRVOffset); } + const D3DShaderResourceAttribs& GetBufUAV (Uint32 n)const noexcept { return GetResAttribs(n, GetNumBufUAV(), m_BufUAVOffset); } + const D3DShaderResourceAttribs& GetSampler(Uint32 n)const noexcept { return GetResAttribs(n, GetNumSamplers(), m_SamplersOffset); } SHADER_TYPE GetShaderType()const noexcept{return m_ShaderType;} - // Processes only resources listed in AllowedVarTypes + ShaderResourceDesc GetShaderResourceDesc(Uint32 Index)const; + template<typename THandleCB, typename THandleSampler, typename THandleTexSRV, @@ -320,14 +322,22 @@ public: bool IsCompatibleWith(const ShaderResources& Resources) const; bool IsUsingCombinedTextureSamplers() const { return m_SamplerSuffix != nullptr; } const char* GetCombinedSamplerSuffix() const { return m_SamplerSuffix; } + const Char* GetShaderName() const { return m_ShaderName; } size_t GetHash()const; + SHADER_RESOURCE_VARIABLE_TYPE FindVariableType(const D3DShaderResourceAttribs& ResourceAttribs, + const PipelineResourceLayoutDesc& ResourceLayout)const; + + Int32 FindStaticSampler(const D3DShaderResourceAttribs& ResourceAttribs, + const PipelineResourceLayoutDesc& ResourceLayoutDesc)const; + D3DShaderResourceCounters CountResources(const PipelineResourceLayoutDesc& ResourceLayout, - SHADER_TYPE ShaderStage, - const char* CombinedSamplerSuffix, const SHADER_RESOURCE_VARIABLE_TYPE* AllowedVarTypes, Uint32 NumAllowedTypes)const noexcept; +#ifdef DEVELOPMENT + void DvpVerifyResourceLayout(const PipelineResourceLayoutDesc& ResourceLayout)const; +#endif protected: template<typename D3D_SHADER_DESC, @@ -373,7 +383,8 @@ private: std::unique_ptr< void, STDDeleterRawMem<void> > m_MemoryBuffer; StringPool m_ResourceNames; - const char* m_SamplerSuffix = nullptr; // The suffix is put into the m_ResourceNames + const char* m_SamplerSuffix = nullptr; // The suffix and the shader name + const char* m_ShaderName = nullptr; // are put into the m_ResourceNames // Offsets in elements of D3DShaderResourceAttribs typedef Uint16 OffsetType; @@ -384,7 +395,7 @@ private: OffsetType m_SamplersOffset = 0; OffsetType m_TotalResources = 0; - SHADER_TYPE m_ShaderType = SHADER_TYPE_UNKNOWN; + const SHADER_TYPE m_ShaderType; }; @@ -403,6 +414,9 @@ void ShaderResources::Initialize(ID3DBlob* pShaderByteCode, [&](const D3DShaderResourceCounters& ResCounters, size_t ResourceNamesPoolSize) { + VERIFY_EXPR(ShaderName != nullptr); + ResourceNamesPoolSize += strlen(ShaderName)+1; + if (CombinedSamplerSuffix != nullptr) ResourceNamesPoolSize += strlen(CombinedSamplerSuffix)+1; @@ -459,6 +473,8 @@ void ShaderResources::Initialize(ID3DBlob* pShaderByteCode, NewResHandler.OnNewTexSRV(*pNewTexSRV); }); + m_ShaderName = m_ResourceNames.CopyString(ShaderName); + if (CombinedSamplerSuffix != nullptr) { m_SamplerSuffix = m_ResourceNames.CopyString(CombinedSamplerSuffix); @@ -504,4 +520,3 @@ namespace std } }; } - diff --git a/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp b/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp index 97107560..613cd96a 100644 --- a/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp +++ b/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp @@ -31,25 +31,6 @@ namespace Diligent { -SHADER_RESOURCE_VARIABLE_TYPE D3DShaderResourceAttribs::FindVariableType(SHADER_TYPE ShaderType, - const PipelineResourceLayoutDesc& ResourceLayoutDesc, - const char* CombinedSamplerSuffix)const -{ - if (GetInputType() == D3D_SIT_SAMPLER) - { - // Only use CombinedSamplerSuffix when looking for the sampler variable type - return GetShaderVariableType(ShaderType, ResourceLayoutDesc.DefaultVariableType, ResourceLayoutDesc.Variables, ResourceLayoutDesc.NumVariables, - [&](const char* VarName) - { - return StreqSuff(Name, VarName, CombinedSamplerSuffix); - }); - } - else - { - return GetShaderVariableType(ShaderType, Name, ResourceLayoutDesc); - } -} - ShaderResources::~ShaderResources() { for(Uint32 n=0; n < GetNumCBs(); ++n) @@ -85,7 +66,7 @@ void ShaderResources::AllocateMemory(IMemoryAllocator& Allocator, return Offset; }; - auto CBOffset = AdvanceOffset(ResCounters.NumCBs); CBOffset; // To suppress warning + auto CBOffset = AdvanceOffset(ResCounters.NumCBs); (void)CBOffset; // To suppress warning m_TexSRVOffset = AdvanceOffset(ResCounters.NumTexSRVs); m_TexUAVOffset = AdvanceOffset(ResCounters.NumTexUAVs); m_BufSRVOffset = AdvanceOffset(ResCounters.NumBufSRVs); @@ -111,15 +92,41 @@ void ShaderResources::AllocateMemory(IMemoryAllocator& Allocator, } } -ShaderResources::ShaderResources(SHADER_TYPE ShaderType): - m_ShaderType(ShaderType) +SHADER_RESOURCE_VARIABLE_TYPE ShaderResources::FindVariableType(const D3DShaderResourceAttribs& ResourceAttribs, + const PipelineResourceLayoutDesc& ResourceLayout)const { + if (ResourceAttribs.GetInputType() == D3D_SIT_SAMPLER) + { + // Only use CombinedSamplerSuffix when looking for the sampler variable type + return GetShaderVariableType(m_ShaderType, ResourceLayout.DefaultVariableType, ResourceLayout.Variables, ResourceLayout.NumVariables, + [&](const char* VarName) + { + return StreqSuff(ResourceAttribs.Name, VarName, m_SamplerSuffix); + }); + } + else + { + return GetShaderVariableType(m_ShaderType, ResourceAttribs.Name, ResourceLayout); + } +} + +Int32 ShaderResources::FindStaticSampler(const D3DShaderResourceAttribs& ResourceAttribs, + const PipelineResourceLayoutDesc& ResourceLayoutDesc)const +{ + VERIFY(ResourceAttribs.GetInputType() == D3D_SIT_SAMPLER, "Sampler is expected"); + + for (Uint32 s=0; s < ResourceLayoutDesc.NumStaticSamplers; ++s) + { + const auto& StSam = ResourceLayoutDesc.StaticSamplers[s]; + if ( ((StSam.ShaderStages & m_ShaderType) != 0) && StreqSuff(ResourceAttribs.Name, StSam.SamplerOrTextureName, m_SamplerSuffix) ) + return s; + } + + return -1; } D3DShaderResourceCounters ShaderResources::CountResources(const PipelineResourceLayoutDesc& ResourceLayout, - SHADER_TYPE ShaderStage, - const char* CombinedSamplerSuffix, const SHADER_RESOURCE_VARIABLE_TYPE* AllowedVarTypes, Uint32 NumAllowedTypes)const noexcept { @@ -129,41 +136,37 @@ D3DShaderResourceCounters ShaderResources::CountResources(const PipelineResource ProcessResources( [&](const D3DShaderResourceAttribs& CB, Uint32) { - auto VarType = CB.FindVariableType(ShaderStage, ResourceLayout, CombinedSamplerSuffix); + auto VarType = FindVariableType(CB, ResourceLayout); if (IsAllowedType(VarType, AllowedTypeBits)) ++Counters.NumCBs; }, [&](const D3DShaderResourceAttribs& Sam, Uint32) { - auto VarType = Sam.FindVariableType(ShaderStage, ResourceLayout, CombinedSamplerSuffix); + auto VarType = FindVariableType(Sam, ResourceLayout); if (IsAllowedType(VarType, AllowedTypeBits)) - { - // Skip static samplers - //if (!Sam.IsStaticSampler()) ++Counters.NumSamplers; - } }, [&](const D3DShaderResourceAttribs& TexSRV, Uint32) { - auto VarType = TexSRV.FindVariableType(ShaderStage, ResourceLayout, CombinedSamplerSuffix); + auto VarType = FindVariableType(TexSRV, ResourceLayout); if (IsAllowedType(VarType, AllowedTypeBits)) ++Counters.NumTexSRVs; }, [&](const D3DShaderResourceAttribs& TexUAV, Uint32) { - auto VarType = TexUAV.FindVariableType(ShaderStage, ResourceLayout, CombinedSamplerSuffix); + auto VarType = FindVariableType(TexUAV, ResourceLayout); if (IsAllowedType(VarType, AllowedTypeBits)) ++Counters.NumTexUAVs; }, [&](const D3DShaderResourceAttribs& BufSRV, Uint32) { - auto VarType = BufSRV.FindVariableType(ShaderStage, ResourceLayout, CombinedSamplerSuffix); + auto VarType = FindVariableType(BufSRV, ResourceLayout); if (IsAllowedType(VarType, AllowedTypeBits)) ++Counters.NumBufSRVs; }, [&](const D3DShaderResourceAttribs& BufUAV, Uint32) { - auto VarType = BufUAV.FindVariableType(ShaderStage, ResourceLayout, CombinedSamplerSuffix); + auto VarType = FindVariableType(BufUAV, ResourceLayout); if (IsAllowedType(VarType, AllowedTypeBits)) ++Counters.NumBufUAVs; } @@ -172,6 +175,82 @@ D3DShaderResourceCounters ShaderResources::CountResources(const PipelineResource return Counters; } +#ifdef DEVELOPMENT +void ShaderResources::DvpVerifyResourceLayout(const PipelineResourceLayoutDesc& ResourceLayout)const +{ + const auto UseCombinedTextureSamplers = IsUsingCombinedTextureSamplers(); + for (Uint32 v = 0; v < ResourceLayout.NumVariables; ++v) + { + const auto& VarDesc = ResourceLayout.Variables[v]; + if (VarDesc.ShaderStages == SHADER_TYPE_UNKNOWN) + { + LOG_WARNING_MESSAGE("No allowed shader stages are specified for ", GetShaderVariableTypeLiteralName(VarDesc.Type), " variable '", VarDesc.Name, "'."); + continue; + } + + if( (VarDesc.ShaderStages & m_ShaderType) == 0) + continue; + + bool VariableFound = false; + for (Uint32 n=0; n < m_TotalResources && !VariableFound; ++n) + { + const auto& Res = GetResAttribs(n, m_TotalResources, 0); + + // Skip samplers if combined texture samplers are used as + // in this case they are not treated as independent variables + if (UseCombinedTextureSamplers && Res.GetInputType() == D3D_SIT_SAMPLER) + continue; + + VariableFound = (strcmp(Res.Name, VarDesc.Name) == 0); + } + + if(!VariableFound) + { + LOG_WARNING_MESSAGE("Variable '", VarDesc.Name, "' is not found in shader '", m_ShaderName, '\''); + } + } + + for (Uint32 s = 0; s < ResourceLayout.NumStaticSamplers; ++s) + { + const auto& StSamDesc = ResourceLayout.StaticSamplers[s]; + if (StSamDesc.ShaderStages == SHADER_TYPE_UNKNOWN) + { + LOG_WARNING_MESSAGE("No allowed shader stages are specified for static sampler '", StSamDesc.SamplerOrTextureName, "'."); + continue; + } + + if ( (StSamDesc.ShaderStages & m_ShaderType) == 0) + continue; + + const auto* TexOrSamName = StSamDesc.SamplerOrTextureName; + + if (UseCombinedTextureSamplers) + { + bool TextureFound = false; + for(Uint32 n=0; n < GetNumTexSRV() && !TextureFound; ++n) + { + const auto& TexSRV = GetTexSRV(n); + TextureFound = (strcmp(TexSRV.Name, TexOrSamName) == 0); + } + if (!TextureFound) + { + LOG_WARNING_MESSAGE("Static sampler specifies a texture '", TexOrSamName, "' that is not found in shader '", m_ShaderName, '\''); + } + } + else + { + bool SamplerFound = false; + for(Uint32 n=0; n < GetNumSamplers() && !SamplerFound; ++n) + { + const auto& Sampler = GetSampler(n); + SamplerFound = (strcmp(Sampler.Name, TexOrSamName) == 0); + } + if (!SamplerFound) + LOG_WARNING_MESSAGE("Static sampler '", TexOrSamName, "' is not found in shader '", m_ShaderName, '\''); + } + } +} +#endif Uint32 ShaderResources::FindAssignedSamplerId(const D3DShaderResourceAttribs& TexSRV, const char* SamplerSuffix)const @@ -237,35 +316,66 @@ bool ShaderResources::IsCompatibleWith(const ShaderResources &Res)const return IsCompatible; } -size_t ShaderResources::GetHash()const +ShaderResourceDesc ShaderResources::GetShaderResourceDesc(Uint32 Index)const { - size_t hash = ComputeHash(GetNumCBs(), GetNumTexSRV(), GetNumTexUAV(), GetNumBufSRV(), GetNumBufUAV(), GetNumSamplers()); - ProcessResources( - [&](const D3DShaderResourceAttribs& CB, Uint32) - { - HashCombine(hash, CB); - }, - [&](const D3DShaderResourceAttribs& Sam, Uint32) - { - HashCombine(hash, Sam); - }, - [&](const D3DShaderResourceAttribs& TexSRV, Uint32) - { - HashCombine(hash, TexSRV); - }, - [&](const D3DShaderResourceAttribs& TexUAV, Uint32) - { - HashCombine(hash, TexUAV); - }, - [&](const D3DShaderResourceAttribs& BufSRV, Uint32) - { - HashCombine(hash, BufSRV); - }, - [&](const D3DShaderResourceAttribs& BufUAV, Uint32) + DEV_CHECK_ERR(Index < m_TotalResources, "Resource index (", Index, ") is out of range"); + ShaderResourceDesc ResourceDesc; + if (Index < m_TotalResources) + { + const auto& Res = GetResAttribs(Index, 0, m_TotalResources); + ResourceDesc.Name = Res.Name; + ResourceDesc.ArraySize = Res.BindCount; + switch(Res.GetInputType()) { - HashCombine(hash, BufUAV); + case D3D_SIT_CBUFFER: + ResourceDesc.Type = SHADER_RESOURCE_TYPE_CONSTANT_BUFFER; + break; + + case D3D_SIT_TBUFFER: + UNSUPPORTED( "TBuffers are not supported" ); + ResourceDesc.Type = SHADER_RESOURCE_TYPE_UNKNOWN; + break; + + case D3D_SIT_TEXTURE: + ResourceDesc.Type = (Res.GetSRVDimension() == D3D_SRV_DIMENSION_BUFFER ? SHADER_RESOURCE_TYPE_BUFFER_SRV : SHADER_RESOURCE_TYPE_TEXTURE_SRV); + break; + + case D3D_SIT_SAMPLER: + ResourceDesc.Type = SHADER_RESOURCE_TYPE_SAMPLER; + break; + + case D3D_SIT_UAV_RWTYPED: + ResourceDesc.Type = (Res.GetSRVDimension() == D3D_SRV_DIMENSION_BUFFER ? SHADER_RESOURCE_TYPE_BUFFER_UAV : SHADER_RESOURCE_TYPE_TEXTURE_UAV); + break; + + case D3D_SIT_STRUCTURED: + case D3D_SIT_BYTEADDRESS: + ResourceDesc.Type = SHADER_RESOURCE_TYPE_BUFFER_SRV; + break; + + case D3D_SIT_UAV_RWSTRUCTURED: + case D3D_SIT_UAV_RWBYTEADDRESS: + case D3D_SIT_UAV_APPEND_STRUCTURED: + case D3D_SIT_UAV_CONSUME_STRUCTURED: + case D3D_SIT_UAV_RWSTRUCTURED_WITH_COUNTER: + ResourceDesc.Type = SHADER_RESOURCE_TYPE_BUFFER_UAV; + break; + + default: + UNEXPECTED("Unknown input type"); } - ); + } + return ResourceDesc; +} + +size_t ShaderResources::GetHash()const +{ + size_t hash = ComputeHash(GetNumCBs(), GetNumTexSRV(), GetNumTexUAV(), GetNumBufSRV(), GetNumBufUAV(), GetNumSamplers()); + for (Uint32 n=0; n < m_TotalResources; ++n) + { + const auto& Res = GetResAttribs(n, m_TotalResources, 0); + HashCombine(hash, Res); + } return hash; } |
