summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D11
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-10-18 15:38:21 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-10-18 15:38:21 +0000
commitc2a6a2c4b716d45ddc92ed04bb0ac7fb7200e548 (patch)
tree243f85bb150b677e5ed07532731fc30de88b0ee7 /Graphics/GraphicsEngineD3D11
parentImplemented separate samplers in D3D11 (diff)
downloadDiligentCore-c2a6a2c4b716d45ddc92ed04bb0ac7fb7200e548.tar.gz
DiligentCore-c2a6a2c4b716d45ddc92ed04bb0ac7fb7200e548.zip
Implemented separate samplers in D3D12
Diffstat (limited to 'Graphics/GraphicsEngineD3D11')
-rw-r--r--Graphics/GraphicsEngineD3D11/include/ShaderResourceLayoutD3D11.h12
-rwxr-xr-xGraphics/GraphicsEngineD3D11/src/ShaderResourceLayoutD3D11.cpp28
-rwxr-xr-xGraphics/GraphicsEngineD3D11/src/ShaderResourcesD3D11.cpp2
3 files changed, 23 insertions, 19 deletions
diff --git a/Graphics/GraphicsEngineD3D11/include/ShaderResourceLayoutD3D11.h b/Graphics/GraphicsEngineD3D11/include/ShaderResourceLayoutD3D11.h
index 24284cec..274c0e28 100644
--- a/Graphics/GraphicsEngineD3D11/include/ShaderResourceLayoutD3D11.h
+++ b/Graphics/GraphicsEngineD3D11/include/ShaderResourceLayoutD3D11.h
@@ -250,7 +250,7 @@ private:
const ConstBuffBindInfo& GetCB(Uint32 cb)const
{
VERIFY_EXPR(cb<m_NumCBs);
- return reinterpret_cast<ConstBuffBindInfo*>(m_ResourceBuffer.get())[cb];
+ return reinterpret_cast<const ConstBuffBindInfo*>(m_ResourceBuffer.get())[cb];
}
TexSRVBindInfo& GetTexSRV(Uint32 t)
@@ -261,7 +261,7 @@ private:
const TexSRVBindInfo& GetTexSRV(Uint32 t)const
{
VERIFY_EXPR(t<m_NumTexSRVs);
- return reinterpret_cast<TexSRVBindInfo*>( reinterpret_cast<Uint8*>(m_ResourceBuffer.get()) + m_TexSRVsOffset)[t];
+ return reinterpret_cast<const TexSRVBindInfo*>( reinterpret_cast<const Uint8*>(m_ResourceBuffer.get()) + m_TexSRVsOffset)[t];
}
TexUAVBindInfo& GetTexUAV(Uint32 u)
@@ -272,7 +272,7 @@ private:
const TexUAVBindInfo& GetTexUAV(Uint32 u)const
{
VERIFY_EXPR(u < m_NumTexUAVs);
- return reinterpret_cast<TexUAVBindInfo*>( reinterpret_cast<Uint8*>(m_ResourceBuffer.get()) + m_TexUAVsOffset)[u];
+ return reinterpret_cast<const TexUAVBindInfo*>( reinterpret_cast<const Uint8*>(m_ResourceBuffer.get()) + m_TexUAVsOffset)[u];
}
BuffUAVBindInfo& GetBufUAV(Uint32 u)
@@ -283,7 +283,7 @@ private:
const BuffUAVBindInfo& GetBufUAV(Uint32 u)const
{
VERIFY_EXPR(u < m_NumBufUAVs);
- return reinterpret_cast<BuffUAVBindInfo*>( reinterpret_cast<Uint8*>(m_ResourceBuffer.get()) + m_BuffUAVsOffset)[u];
+ return reinterpret_cast<const BuffUAVBindInfo*>( reinterpret_cast<const Uint8*>(m_ResourceBuffer.get()) + m_BuffUAVsOffset)[u];
}
BuffSRVBindInfo& GetBufSRV(Uint32 s)
@@ -294,7 +294,7 @@ private:
const BuffSRVBindInfo& GetBufSRV(Uint32 s)const
{
VERIFY_EXPR(s < m_NumBufSRVs);
- return reinterpret_cast<BuffSRVBindInfo*>( reinterpret_cast<Uint8*>(m_ResourceBuffer.get()) + m_BuffSRVsOffset)[s];
+ return reinterpret_cast<const BuffSRVBindInfo*>( reinterpret_cast<const Uint8*>(m_ResourceBuffer.get()) + m_BuffSRVsOffset)[s];
}
SamplerBindInfo& GetSampler(Uint32 s)
@@ -305,7 +305,7 @@ private:
const SamplerBindInfo& GetSampler(Uint32 s)const
{
VERIFY_EXPR(s < m_NumSamplers);
- return reinterpret_cast<SamplerBindInfo*>( reinterpret_cast<Uint8*>(m_ResourceBuffer.get()) + m_SamplerOffset)[s];
+ return reinterpret_cast<const SamplerBindInfo*>( reinterpret_cast<const Uint8*>(m_ResourceBuffer.get()) + m_SamplerOffset)[s];
}
template<typename THandleCB,
diff --git a/Graphics/GraphicsEngineD3D11/src/ShaderResourceLayoutD3D11.cpp b/Graphics/GraphicsEngineD3D11/src/ShaderResourceLayoutD3D11.cpp
index 67affc45..00efe57d 100755
--- a/Graphics/GraphicsEngineD3D11/src/ShaderResourceLayoutD3D11.cpp
+++ b/Graphics/GraphicsEngineD3D11/src/ShaderResourceLayoutD3D11.cpp
@@ -186,6 +186,10 @@ void ShaderResourceLayoutD3D11::Initialize(const std::shared_ptr<const ShaderRes
if (TexSRV.ValidSamplerAssigned())
{
const auto& AssignedSamplerAttribs = m_pResources->GetSampler(TexSRV.GetSamplerId());
+ DEV_CHECK_ERR(AssignedSamplerAttribs.GetVariableType() == TexSRV.GetVariableType(),
+ "The type (", GetShaderVariableTypeLiteralName(TexSRV.GetVariableType()),") of texture SRV variable '", TexSRV.Name,
+ "' is not consistent with the type (", GetShaderVariableTypeLiteralName(AssignedSamplerAttribs.GetVariableType()),
+ ") of the sampler '", AssignedSamplerAttribs.Name, "' that is assigned to it");
// Do not assign static sampler to texture SRV as it is initialized directly in the shader resource cache
if (!AssignedSamplerAttribs.IsStaticSampler())
{
@@ -366,7 +370,7 @@ void ShaderResourceLayoutD3D11::ConstBuffBindInfo::BindResource(IDeviceObject* p
{
auto &pResourceCache = m_ParentResLayout.m_pResourceCache;
VERIFY(pResourceCache, "Resource cache is null");
- VERIFY_EXPR(ArrayIndex < Attribs.BindCount);
+ DEV_CHECK_ERR(ArrayIndex < Attribs.BindCount, "Array index (", ArrayIndex, ") is out of range for variable '", Attribs.Name, "'. Max allowed index: ", Attribs.BindCount);
RefCntAutoPtr<BufferD3D11Impl> pBuffD3D11Impl;
if( pBuffer )
@@ -448,7 +452,7 @@ void ShaderResourceLayoutD3D11::TexSRVBindInfo::BindResource(IDeviceObject* pVie
Uint32 ArrayIndex)
{
VERIFY(m_ParentResLayout.m_pResourceCache, "Resource cache is null");
- VERIFY_EXPR(ArrayIndex < Attribs.BindCount);
+ DEV_CHECK_ERR(ArrayIndex < Attribs.BindCount, "Array index (", ArrayIndex, ") is out of range for variable '", Attribs.Name, "'. Max allowed index: ", Attribs.BindCount);
auto& ResourceCache = *m_ParentResLayout.m_pResourceCache;
// We cannot use ValidatedCast<> here as the resource retrieved from the
@@ -502,7 +506,7 @@ void ShaderResourceLayoutD3D11::SamplerBindInfo::BindResource(IDeviceObject* pSa
Uint32 ArrayIndex)
{
VERIFY(m_ParentResLayout.m_pResourceCache != nullptr, "Resource cache is null");
- VERIFY_EXPR(ArrayIndex < Attribs.BindCount);
+ DEV_CHECK_ERR(ArrayIndex < Attribs.BindCount, "Array index (", ArrayIndex, ") is out of range for variable '", Attribs.Name, "'. Max allowed index: ", Attribs.BindCount);
auto& ResourceCache = *m_ParentResLayout.m_pResourceCache;
VERIFY(!Attribs.IsStaticSampler(), "Cannot bind sampler to a static sampler");
@@ -538,7 +542,7 @@ void ShaderResourceLayoutD3D11::BuffSRVBindInfo::BindResource(IDeviceObject* pVi
Uint32 ArrayIndex)
{
VERIFY(m_ParentResLayout.m_pResourceCache != nullptr, "Resource cache is null");
- VERIFY(ArrayIndex < Attribs.BindCount, "Array index is out of range");
+ DEV_CHECK_ERR(ArrayIndex < Attribs.BindCount, "Array index (", ArrayIndex, ") is out of range for variable '", Attribs.Name, "'. Max allowed index: ", Attribs.BindCount);
auto& ResourceCache = *m_ParentResLayout.m_pResourceCache;
// We cannot use ValidatedCast<> here as the resource retrieved from the
@@ -569,7 +573,7 @@ void ShaderResourceLayoutD3D11::TexUAVBindInfo::BindResource(IDeviceObject* pVie
Uint32 ArrayIndex)
{
VERIFY(m_ParentResLayout.m_pResourceCache != nullptr, "Resource cache is null");
- VERIFY(ArrayIndex < Attribs.BindCount, "Array index is out of range");
+ DEV_CHECK_ERR(ArrayIndex < Attribs.BindCount, "Array index (", ArrayIndex, ") is out of range for variable '", Attribs.Name, "'. Max allowed index: ", Attribs.BindCount);
auto& ResourceCache = *m_ParentResLayout.m_pResourceCache;
// We cannot use ValidatedCast<> here as the resource retrieved from the
@@ -600,7 +604,7 @@ void ShaderResourceLayoutD3D11::BuffUAVBindInfo::BindResource(IDeviceObject* pVi
Uint32 ArrayIndex)
{
VERIFY(m_ParentResLayout.m_pResourceCache != nullptr, "Resource cache is null");
- VERIFY(ArrayIndex < Attribs.BindCount, "Array index is out of range");
+ DEV_CHECK_ERR(ArrayIndex < Attribs.BindCount, "Array index (", ArrayIndex, ") is out of range for variable '", Attribs.Name, "'. Max allowed index: ", Attribs.BindCount);
auto& ResourceCache = *m_ParentResLayout.m_pResourceCache;
// We cannot use ValidatedCast<> here as the resource retrieved from the
@@ -799,7 +803,7 @@ Uint32 ShaderResourceLayoutD3D11::GetVariableIndex(const ShaderVariableD3D11Base
Uint32 Index = 0;
if (Offset < m_TexSRVsOffset)
{
- VERIFY(Offset % sizeof(ConstBuffBindInfo) == 0, "Offset is not multiple of sizeof(ConstBuffBindInfo)");
+ DEV_CHECK_ERR(Offset % sizeof(ConstBuffBindInfo) == 0, "Offset is not multiple of sizeof(ConstBuffBindInfo)");
return Index + static_cast<Uint32>(Offset / sizeof(ConstBuffBindInfo));
}
else
@@ -807,7 +811,7 @@ Uint32 ShaderResourceLayoutD3D11::GetVariableIndex(const ShaderVariableD3D11Base
if (Offset < m_TexUAVsOffset)
{
- VERIFY( (Offset - m_TexSRVsOffset) % sizeof(TexSRVBindInfo) == 0, "Offset is not multiple of sizeof(TexSRVBindInfo)");
+ DEV_CHECK_ERR( (Offset - m_TexSRVsOffset) % sizeof(TexSRVBindInfo) == 0, "Offset is not multiple of sizeof(TexSRVBindInfo)");
return Index + static_cast<Uint32>((Offset - m_TexSRVsOffset) / sizeof(TexSRVBindInfo));
}
else
@@ -815,7 +819,7 @@ Uint32 ShaderResourceLayoutD3D11::GetVariableIndex(const ShaderVariableD3D11Base
if (Offset < m_BuffUAVsOffset)
{
- VERIFY( (Offset - m_TexUAVsOffset) % sizeof(TexUAVBindInfo) == 0, "Offset is not multiple of sizeof(TexUAVBindInfo)");
+ DEV_CHECK_ERR( (Offset - m_TexUAVsOffset) % sizeof(TexUAVBindInfo) == 0, "Offset is not multiple of sizeof(TexUAVBindInfo)");
return Index + static_cast<Uint32>((Offset - m_TexUAVsOffset) / sizeof(TexUAVBindInfo));
}
else
@@ -823,7 +827,7 @@ Uint32 ShaderResourceLayoutD3D11::GetVariableIndex(const ShaderVariableD3D11Base
if (Offset < m_BuffSRVsOffset)
{
- VERIFY( (Offset - m_BuffUAVsOffset) % sizeof(BuffUAVBindInfo) == 0, "Offset is not multiple of sizeof(BuffUAVBindInfo)" );
+ DEV_CHECK_ERR( (Offset - m_BuffUAVsOffset) % sizeof(BuffUAVBindInfo) == 0, "Offset is not multiple of sizeof(BuffUAVBindInfo)" );
return Index + static_cast<Uint32>((Offset - m_BuffUAVsOffset) / sizeof(BuffUAVBindInfo));
}
else
@@ -831,7 +835,7 @@ Uint32 ShaderResourceLayoutD3D11::GetVariableIndex(const ShaderVariableD3D11Base
if (Offset < static_cast<std::ptrdiff_t>(m_BuffSRVsOffset + m_NumBufSRVs * sizeof(BuffSRVBindInfo)))
{
- VERIFY( (Offset - m_BuffSRVsOffset) % sizeof(BuffSRVBindInfo) == 0, "Offset is not multiple of sizeof(BuffSRVBindInfo)" );
+ DEV_CHECK_ERR( (Offset - m_BuffSRVsOffset) % sizeof(BuffSRVBindInfo) == 0, "Offset is not multiple of sizeof(BuffSRVBindInfo)" );
return Index + static_cast<Uint32>((Offset - m_BuffSRVsOffset) / sizeof(BuffSRVBindInfo));
}
else
@@ -839,7 +843,7 @@ Uint32 ShaderResourceLayoutD3D11::GetVariableIndex(const ShaderVariableD3D11Base
if (Offset < static_cast<std::ptrdiff_t>(m_SamplerOffset + m_NumSamplers * sizeof(SamplerBindInfo)))
{
- VERIFY( (Offset - m_SamplerOffset) % sizeof(SamplerBindInfo) == 0, "Offset is not multiple of sizeof(SamplerBindInfo)" );
+ DEV_CHECK_ERR( (Offset - m_SamplerOffset) % sizeof(SamplerBindInfo) == 0, "Offset is not multiple of sizeof(SamplerBindInfo)" );
return Index + static_cast<Uint32>((Offset - m_SamplerOffset) / sizeof(SamplerBindInfo));
}
else
diff --git a/Graphics/GraphicsEngineD3D11/src/ShaderResourcesD3D11.cpp b/Graphics/GraphicsEngineD3D11/src/ShaderResourcesD3D11.cpp
index b92c16fe..544d9088 100755
--- a/Graphics/GraphicsEngineD3D11/src/ShaderResourcesD3D11.cpp
+++ b/Graphics/GraphicsEngineD3D11/src/ShaderResourcesD3D11.cpp
@@ -116,7 +116,7 @@ ShaderResourcesD3D11::ShaderResourcesD3D11(RenderDeviceD3D11Impl* pDeviceD3D11Im
for (; ssd < ShdrDesc.NumStaticSamplers; ++ssd)
{
const auto& StaticSamplerDesc = ShdrDesc.StaticSamplers[ssd];
- if (StrCmpSuff(Sam.Name, StaticSamplerDesc.SamplerOrTextureName, CombinedSamplerSuffix))
+ if (StreqSuff(Sam.Name, StaticSamplerDesc.SamplerOrTextureName, CombinedSamplerSuffix))
{
auto &StaticSamplerAttrs = GetStaticSampler(CurrStaticSam++);
StaticSamplerAttrs.first = &Sam;