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/GraphicsEngineD3D12 | |
| 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/GraphicsEngineD3D12')
4 files changed, 9 insertions, 6 deletions
diff --git a/Graphics/GraphicsEngineD3D12/include/ShaderResourcesD3D12.h b/Graphics/GraphicsEngineD3D12/include/ShaderResourcesD3D12.h index c5b2e0d9..ba2036de 100644 --- a/Graphics/GraphicsEngineD3D12/include/ShaderResourcesD3D12.h +++ b/Graphics/GraphicsEngineD3D12/include/ShaderResourcesD3D12.h @@ -88,7 +88,7 @@ class ShaderResourcesD3D12 final : public ShaderResources { public: // Loads shader resources from the compiled shader bytecode - ShaderResourcesD3D12(ID3DBlob *pShaderBytecode, const ShaderDesc &ShdrDesc); + ShaderResourcesD3D12(ID3DBlob* pShaderBytecode, const ShaderDesc& ShdrDesc, const char* CombinedSamplerSuffix); }; } diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp index af353150..0c98369c 100644 --- a/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp @@ -45,7 +45,7 @@ ShaderD3D12Impl::ShaderD3D12Impl(IReferenceCounters* pRefCounters, // Load shader resources auto& Allocator = GetRawAllocator(); auto* pRawMem = ALLOCATE(Allocator, "Allocator for ShaderResources", sizeof(ShaderResourcesD3D12)); - auto* pResources = new (pRawMem) ShaderResourcesD3D12(m_pShaderByteCode, m_Desc); + auto* pResources = new (pRawMem) ShaderResourcesD3D12(m_pShaderByteCode, m_Desc, ShaderCreationAttribs.CombinedSamplerSuffix); m_pShaderResources.reset(pResources, STDDeleterRawMem<ShaderResourcesD3D12>(Allocator)); // Clone only static resources that will be set directly in the shader diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp index 73cb334d..9c48cb76 100644 --- a/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp +++ b/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp @@ -525,7 +525,7 @@ const ShaderResourceLayoutD3D12::D3D12Resource& ShaderResourceLayoutD3D12::GetAs VERIFY(TexSrv.IsValidSampler(), "Texture SRV has no associated sampler"); const auto& SamInfo = GetSampler(TexSrv.Attribs.GetVariableType(), TexSrv.SamplerId); VERIFY(SamInfo.Attribs.GetVariableType() == TexSrv.Attribs.GetVariableType(), "Inconsistent texture and sampler variable types"); - VERIFY(StrCmpSuff(SamInfo.Attribs.Name, TexSrv.Attribs.Name, D3DSamplerSuffix), "Sampler name \"", SamInfo.Attribs.Name, "\" does not match texture name \"", TexSrv.Attribs.Name, '\"'); + //VERIFY(StrCmpSuff(SamInfo.Attribs.Name, TexSrv.Attribs.Name, SamplerSuffix), "Sampler name \"", SamInfo.Attribs.Name, "\" does not match texture name \"", TexSrv.Attribs.Name, '\"'); return SamInfo; } diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderResourcesD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderResourcesD3D12.cpp index d77793ed..d61668bf 100644 --- a/Graphics/GraphicsEngineD3D12/src/ShaderResourcesD3D12.cpp +++ b/Graphics/GraphicsEngineD3D12/src/ShaderResourcesD3D12.cpp @@ -34,7 +34,7 @@ namespace Diligent { -ShaderResourcesD3D12::ShaderResourcesD3D12(ID3DBlob *pShaderBytecode, const ShaderDesc &ShdrDesc) : +ShaderResourcesD3D12::ShaderResourcesD3D12(ID3DBlob* pShaderBytecode, const ShaderDesc& ShdrDesc, const char* CombinedSamplerSuffix) : ShaderResources(ShdrDesc.ShaderType) { Uint32 CurrCB = 0, CurrTexSRV = 0, CurrTexUAV = 0, CurrBufSRV = 0, CurrBufUAV = 0, CurrSampler = 0; @@ -75,12 +75,15 @@ ShaderResourcesD3D12::ShaderResourcesD3D12(ID3DBlob *pShaderBytecode, const Shad { VERIFY(CurrSampler == GetNumSamplers(), "All samplers must be initialized before texture SRVs" ); - 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"); |
