summaryrefslogtreecommitdiffstats
path: root/Graphics
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2021-03-02 05:32:11 +0000
committerassiduous <assiduous@diligentgraphics.com>2021-03-19 00:38:13 +0000
commit7b35bc8486edb3605876e16ee794bee8c7077bcf (patch)
treec1067bf21aeb7f5379d2cecaf81b2c076e97c011 /Graphics
parentFixed few issues with run-time sized arrays in D3D12; enabled test. (diff)
downloadDiligentCore-7b35bc8486edb3605876e16ee794bee8c7077bcf.tar.gz
DiligentCore-7b35bc8486edb3605876e16ee794bee8c7077bcf.zip
RunTimeResourceArray: added constant buffers
Diffstat (limited to 'Graphics')
-rw-r--r--Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp9
-rw-r--r--Graphics/GraphicsEngineD3DBase/include/D3DShaderResourceLoader.hpp9
-rw-r--r--Graphics/ShaderTools/src/DXCompiler.cpp7
3 files changed, 20 insertions, 5 deletions
diff --git a/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp
index d6dff734..549f7065 100644
--- a/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp
@@ -634,6 +634,11 @@ void PipelineStateD3D12Impl::InitRootSignature(const PipelineStateCreateInfo& Cr
"Compile the shader using SM5.1+ or change the resource layout to use only one space.");
}
+#ifdef DILIGENT_DEVELOPMENT
+ // Validate resources before remapping
+ DvpValidateShaderResources(pShader, pLocalRootSig);
+#endif
+
CComPtr<ID3DBlob> pBlob;
if (IsDXILBytecode(pBytecode->GetBufferPointer(), pBytecode->GetBufferSize()))
{
@@ -652,10 +657,6 @@ void PipelineStateD3D12Impl::InitRootSignature(const PipelineStateCreateInfo& Cr
LOG_ERROR_AND_THROW("Failed to remap resource bindings in shader '", pShader->GetDesc().Name, "'.");
}
pBytecode = pBlob;
-
-#ifdef DILIGENT_DEVELOPMENT
- DvpValidateShaderResources(pShader, pLocalRootSig);
-#endif
}
}
}
diff --git a/Graphics/GraphicsEngineD3DBase/include/D3DShaderResourceLoader.hpp b/Graphics/GraphicsEngineD3DBase/include/D3DShaderResourceLoader.hpp
index 1bd4678d..d5cf7e6e 100644
--- a/Graphics/GraphicsEngineD3DBase/include/D3DShaderResourceLoader.hpp
+++ b/Graphics/GraphicsEngineD3DBase/include/D3DShaderResourceLoader.hpp
@@ -102,6 +102,15 @@ void LoadD3DShaderResources(TShaderReflection* pShaderReflection,
SkipCount = 1;
UINT BindCount = BindingDesc.BindCount;
+ if (BindCount == UINT_MAX)
+ {
+ // For some reason
+ // Texture2D g_Textures[]
+ // produces BindCount == 0, but
+ // ConstantBuffer<CBData> g_ConstantBuffers[]
+ // produces BindCount == UINT_MAX
+ BindCount = 0;
+ }
// Handle arrays
// For shader models 5_0 and before, every resource array element is enumerated individually.
diff --git a/Graphics/ShaderTools/src/DXCompiler.cpp b/Graphics/ShaderTools/src/DXCompiler.cpp
index fb2e82e0..681c7cb0 100644
--- a/Graphics/ShaderTools/src/DXCompiler.cpp
+++ b/Graphics/ShaderTools/src/DXCompiler.cpp
@@ -831,7 +831,12 @@ bool DXCompilerImpl::RemapResourceBindings(const TResourceBindingMap& ResourceMa
{
NameAndBinding.second.SrcBindPoint = ResDesc.BindPoint;
NameAndBinding.second.SrcSpace = ResDesc.Space;
- VERIFY_EXPR(ResDesc.BindCount == 0 || NameAndBinding.second.ArraySize >= ResDesc.BindCount);
+ // For some reason
+ // Texture2D g_Textures[]
+ // produces BindCount == 0, but
+ // ConstantBuffer<CBData> g_ConstantBuffers[]
+ // produces BindCount == UINT_MAX
+ VERIFY_EXPR(ResDesc.BindCount == 0 || ResDesc.BindCount == UINT_MAX || NameAndBinding.second.ArraySize >= ResDesc.BindCount);
switch (ResDesc.Type)
{