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/GraphicsEngineD3D11/include/ShaderResourcesD3D11.h | 5 ++++- Graphics/GraphicsEngineD3D11/src/ShaderD3D11Impl.cpp | 2 +- Graphics/GraphicsEngineD3D11/src/ShaderResourcesD3D11.cpp | 11 +++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) (limited to 'Graphics/GraphicsEngineD3D11') diff --git a/Graphics/GraphicsEngineD3D11/include/ShaderResourcesD3D11.h b/Graphics/GraphicsEngineD3D11/include/ShaderResourcesD3D11.h index da6809e4..ce8cb8ad 100644 --- a/Graphics/GraphicsEngineD3D11/include/ShaderResourcesD3D11.h +++ b/Graphics/GraphicsEngineD3D11/include/ShaderResourcesD3D11.h @@ -84,7 +84,10 @@ class ShaderResourcesD3D11 : public ShaderResources { public: // Loads shader resources from the compiled shader bytecode - ShaderResourcesD3D11(class RenderDeviceD3D11Impl* pDeviceD3D11Impl, ID3DBlob* pShaderBytecode, const ShaderDesc& ShdrDesc); + ShaderResourcesD3D11(class RenderDeviceD3D11Impl* pDeviceD3D11Impl, + ID3DBlob* pShaderBytecode, + const ShaderDesc& ShdrDesc, + const char* CombinedSamplerSuffix); ~ShaderResourcesD3D11(); __forceinline Int32 GetMaxCBBindPoint() const{return m_MaxCBBindPoint; } diff --git a/Graphics/GraphicsEngineD3D11/src/ShaderD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/ShaderD3D11Impl.cpp index ebdf0d23..1549c962 100644 --- a/Graphics/GraphicsEngineD3D11/src/ShaderD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/ShaderD3D11Impl.cpp @@ -78,7 +78,7 @@ ShaderD3D11Impl::ShaderD3D11Impl(IReferenceCounters* pRefCounters, // Load shader resources auto &Allocator = GetRawAllocator(); auto *pRawMem = ALLOCATE(Allocator, "Allocator for ShaderResources", sizeof(ShaderResourcesD3D11)); - auto *pResources = new (pRawMem) ShaderResourcesD3D11(pRenderDeviceD3D11, m_pShaderByteCode, m_Desc); + auto *pResources = new (pRawMem) ShaderResourcesD3D11(pRenderDeviceD3D11, m_pShaderByteCode, m_Desc, CreationAttribs.CombinedSamplerSuffix); m_pShaderResources.reset(pResources, STDDeleterRawMem(Allocator)); // Clone only static resources that will be set directly in the shader diff --git a/Graphics/GraphicsEngineD3D11/src/ShaderResourcesD3D11.cpp b/Graphics/GraphicsEngineD3D11/src/ShaderResourcesD3D11.cpp index 1cf52f39..562dc54d 100755 --- a/Graphics/GraphicsEngineD3D11/src/ShaderResourcesD3D11.cpp +++ b/Graphics/GraphicsEngineD3D11/src/ShaderResourcesD3D11.cpp @@ -34,7 +34,10 @@ namespace Diligent { -ShaderResourcesD3D11::ShaderResourcesD3D11(RenderDeviceD3D11Impl* pDeviceD3D11Impl, ID3DBlob* pShaderBytecode, const ShaderDesc& ShdrDesc) : +ShaderResourcesD3D11::ShaderResourcesD3D11(RenderDeviceD3D11Impl* pDeviceD3D11Impl, + ID3DBlob* pShaderBytecode, + const ShaderDesc& ShdrDesc, + const char* CombinedSamplerSuffix) : ShaderResources(ShdrDesc.ShaderType), m_ShaderName(ShdrDesc.Name), m_StaticSamplers(nullptr, STDDeleterRawMem< void >(GetRawAllocator())) @@ -96,12 +99,12 @@ ShaderResourcesD3D11::ShaderResourcesD3D11(RenderDeviceD3D11Impl* pDeviceD3D11Im VERIFY( TexAttribs.BindPoint + TexAttribs.BindCount-1 <= MaxAllowedBindPoint, "Tex SRV bind point exceeds supported range" ); m_MaxSRVBindPoint = std::max(m_MaxSRVBindPoint, static_cast(TexAttribs.BindPoint + TexAttribs.BindCount-1)); - auto SamplerId = FindAssignedSamplerId(TexAttribs); + auto SamplerId = CombinedSamplerSuffix != nullptr ? FindAssignedSamplerId(TexAttribs, CombinedSamplerSuffix) : D3DShaderResourceAttribs::InvalidSamplerId; new (&GetTexSRV(CurrTexSRV++)) D3DShaderResourceAttribs(m_ResourceNames, TexAttribs, SamplerId); }, ShdrDesc, - D3DSamplerSuffix); + CombinedSamplerSuffix); VERIFY_EXPR(m_ResourceNames.GetRemainingSize() == 0); VERIFY(CurrCB == GetNumCBs(), "Not all CBs are initialized, which will result in a crash when ~D3DShaderResourceAttribs() is called"); @@ -131,7 +134,7 @@ ShaderResourcesD3D11::ShaderResourcesD3D11(RenderDeviceD3D11Impl* pDeviceD3D11Im for (; ssd < ShdrDesc.NumStaticSamplers; ++ssd) { const auto& StaticSamplerDesc = ShdrDesc.StaticSamplers[ssd]; - if (StrCmpSuff(Sam.Name, StaticSamplerDesc.TextureName, D3DSamplerSuffix)) + if (StrCmpSuff(Sam.Name, StaticSamplerDesc.TextureName, CombinedSamplerSuffix)) { auto &StaticSamplerAttrs = GetStaticSampler(CurrStaticSam++); StaticSamplerAttrs.first = &Sam; -- cgit v1.2.3