From 854fb9130b8030bc9ff94304285eacaa3120cd14 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Thu, 11 Oct 2018 09:03:03 -0700 Subject: Fixed https://github.com/DiligentGraphics/DiligentCore/issues/2 (make '_sampler' suffix configurable through shader creation attributes) --- Graphics/GraphicsEngineD3DBase/include/ShaderResources.h | 4 +--- Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp | 5 +++-- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'Graphics/GraphicsEngineD3DBase') diff --git a/Graphics/GraphicsEngineD3DBase/include/ShaderResources.h b/Graphics/GraphicsEngineD3DBase/include/ShaderResources.h index c468eebd..b49069dd 100644 --- a/Graphics/GraphicsEngineD3DBase/include/ShaderResources.h +++ b/Graphics/GraphicsEngineD3DBase/include/ShaderResources.h @@ -64,8 +64,6 @@ namespace Diligent { -static const Char* D3DSamplerSuffix = "_sampler"; - inline bool IsAllowedType(SHADER_VARIABLE_TYPE VarType, Uint32 AllowedTypeBits)noexcept { return ((1 << VarType) & AllowedTypeBits) != 0; @@ -390,7 +388,7 @@ protected: D3DShaderResourceAttribs& GetBufUAV (Uint32 n)noexcept{ return GetResAttribs(n, GetNumBufUAV(), m_BufUAVOffset); } D3DShaderResourceAttribs& GetSampler(Uint32 n)noexcept{ return GetResAttribs(n, GetNumSamplers(), m_SamplersOffset); } - Uint32 FindAssignedSamplerId(const D3DShaderResourceAttribs& TexSRV)const; + Uint32 FindAssignedSamplerId(const D3DShaderResourceAttribs& TexSRV, const char* SamplerSuffix)const; private: // Memory buffer that holds all resources as continuous chunk of memory: diff --git a/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp b/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp index f3045121..3ad2dc76 100644 --- a/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp +++ b/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp @@ -153,14 +153,15 @@ void ShaderResources::CountResources(const SHADER_VARIABLE_TYPE *AllowedVarTypes } -Uint32 ShaderResources::FindAssignedSamplerId(const D3DShaderResourceAttribs& TexSRV)const +Uint32 ShaderResources::FindAssignedSamplerId(const D3DShaderResourceAttribs& TexSRV, const char* SamplerSuffix)const { + VERIFY_EXPR(SamplerSuffix != nullptr && *SamplerSuffix != 0); VERIFY_EXPR(TexSRV.GetInputType() == D3D_SIT_TEXTURE); auto NumSamplers = GetNumSamplers(); for (Uint32 s = 0; s < NumSamplers; ++s) { const auto &Sampler = GetSampler(s); - if( StrCmpSuff(Sampler.Name, TexSRV.Name, D3DSamplerSuffix) ) + if( StrCmpSuff(Sampler.Name, TexSRV.Name, SamplerSuffix) ) { VERIFY(Sampler.GetVariableType() == TexSRV.GetVariableType(), "Inconsistent texture and sampler variable types"); VERIFY(Sampler.BindCount == TexSRV.BindCount || Sampler.BindCount == 1, "Sampler assigned to array \"", TexSRV.Name, "\" is expected to be scalar or have the same dimension (",TexSRV.BindCount,"). Actual sampler array dimension : ", Sampler.BindCount); -- cgit v1.2.3