summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3DBase
diff options
context:
space:
mode:
authorazhirnov <zh1dron@gmail.com>2020-11-12 15:23:20 +0000
committerazhirnov <zh1dron@gmail.com>2020-11-12 15:23:20 +0000
commitf8d57c40eb9a7f8f54494aa348cc01c15e56ee41 (patch)
tree2e0ec5ae93d6676af939391dc11ac3e1f4b3e834 /Graphics/GraphicsEngineD3DBase
parentfixed and improved shader binding (diff)
downloadDiligentCore-f8d57c40eb9a7f8f54494aa348cc01c15e56ee41.tar.gz
DiligentCore-f8d57c40eb9a7f8f54494aa348cc01c15e56ee41.zip
remap resource binding for DirectX 12
Diffstat (limited to 'Graphics/GraphicsEngineD3DBase')
-rw-r--r--Graphics/GraphicsEngineD3DBase/include/D3DShaderResourceLoader.hpp3
-rw-r--r--Graphics/GraphicsEngineD3DBase/include/ShaderResources.hpp10
2 files changed, 8 insertions, 5 deletions
diff --git a/Graphics/GraphicsEngineD3DBase/include/D3DShaderResourceLoader.hpp b/Graphics/GraphicsEngineD3DBase/include/D3DShaderResourceLoader.hpp
index b12ef6ae..5d5f847e 100644
--- a/Graphics/GraphicsEngineD3DBase/include/D3DShaderResourceLoader.hpp
+++ b/Graphics/GraphicsEngineD3DBase/include/D3DShaderResourceLoader.hpp
@@ -94,6 +94,9 @@ void LoadD3DShaderResources(TShaderReflection* pShaderReflection,
D3D_SHADER_INPUT_BIND_DESC BindingDesc = {};
pShaderReflection->GetResourceBindingDesc(Res, &BindingDesc);
+ if (BindingDesc.BindPoint == UINT32_MAX)
+ BindingDesc.BindPoint = D3DShaderResourceAttribs::InvalidBindPoint;
+
std::string Name(BindingDesc.Name);
SkipCount = 1;
diff --git a/Graphics/GraphicsEngineD3DBase/include/ShaderResources.hpp b/Graphics/GraphicsEngineD3DBase/include/ShaderResources.hpp
index 926ce209..c5607ce3 100644
--- a/Graphics/GraphicsEngineD3DBase/include/ShaderResources.hpp
+++ b/Graphics/GraphicsEngineD3DBase/include/ShaderResources.hpp
@@ -146,20 +146,20 @@ public:
#endif
}
- D3DShaderResourceAttribs(StringPool& NamesPool, const D3DShaderResourceAttribs& rhs, Uint32 SamplerId) noexcept :
+ D3DShaderResourceAttribs(StringPool& NamesPool, const D3DShaderResourceAttribs& rhs, Uint32 _SamplerId, Uint32 _BindPoint) noexcept :
// clang-format off
D3DShaderResourceAttribs
{
NamesPool.CopyString(rhs.Name),
- rhs.BindPoint,
+ _BindPoint,
rhs.BindCount,
rhs.GetInputType(),
rhs.GetSRVDimension(),
- SamplerId
+ _SamplerId
}
// clang-format on
{
- VERIFY(SamplerId == InvalidSamplerId || (GetInputType() == D3D_SIT_TEXTURE && GetSRVDimension() != D3D_SRV_DIMENSION_BUFFER),
+ VERIFY(_SamplerId == InvalidSamplerId || (GetInputType() == D3D_SIT_TEXTURE && GetSRVDimension() != D3D_SRV_DIMENSION_BUFFER),
"Only texture SRV can be assigned a valid texture sampler");
}
@@ -552,7 +552,7 @@ void ShaderResources::Initialize(TShaderReflection* pShaderReflection,
VERIFY(CurrSampler == GetNumSamplers(), "All samplers must be initialized before texture SRVs");
auto SamplerId = CombinedSamplerSuffix != nullptr ? FindAssignedSamplerId(TexAttribs, CombinedSamplerSuffix) : D3DShaderResourceAttribs::InvalidSamplerId;
- auto* pNewTexSRV = new (&GetTexSRV(CurrTexSRV)) D3DShaderResourceAttribs{ResourceNamesPool, TexAttribs, SamplerId};
+ auto* pNewTexSRV = new (&GetTexSRV(CurrTexSRV)) D3DShaderResourceAttribs{ResourceNamesPool, TexAttribs, SamplerId, TexAttribs.BindPoint};
if (SamplerId != D3DShaderResourceAttribs::InvalidSamplerId)
{
GetSampler(SamplerId).SetTexSRVId(CurrTexSRV);