summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D11
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-10-11 16:03:03 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-10-11 16:03:03 +0000
commit854fb9130b8030bc9ff94304285eacaa3120cd14 (patch)
tree16d9f0eecd88d9f1aec3ef57d268db48ccaa631b /Graphics/GraphicsEngineD3D11
parentUpdated readme (diff)
downloadDiligentCore-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/GraphicsEngineD3D11')
-rw-r--r--Graphics/GraphicsEngineD3D11/include/ShaderResourcesD3D11.h5
-rw-r--r--Graphics/GraphicsEngineD3D11/src/ShaderD3D11Impl.cpp2
-rwxr-xr-xGraphics/GraphicsEngineD3D11/src/ShaderResourcesD3D11.cpp11
3 files changed, 12 insertions, 6 deletions
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<ShaderResourcesD3D11>(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<MaxBindPointType>(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;