diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2018-10-11 16:03:03 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2018-10-11 16:03:03 +0000 |
| commit | 854fb9130b8030bc9ff94304285eacaa3120cd14 (patch) | |
| tree | 16d9f0eecd88d9f1aec3ef57d268db48ccaa631b /Graphics/GraphicsEngineD3DBase | |
| parent | Updated readme (diff) | |
| download | DiligentCore-854fb9130b8030bc9ff94304285eacaa3120cd14.tar.gz DiligentCore-854fb9130b8030bc9ff94304285eacaa3120cd14.zip | |
Fixed https://github.com/DiligentGraphics/DiligentCore/issues/2 (make '_sampler' suffix configurable through shader creation attributes)
Diffstat (limited to 'Graphics/GraphicsEngineD3DBase')
| -rw-r--r-- | Graphics/GraphicsEngineD3DBase/include/ShaderResources.h | 4 | ||||
| -rw-r--r-- | Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp | 5 |
2 files changed, 4 insertions, 5 deletions
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); |
