summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3DBase
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-10-17 16:56:34 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-10-17 16:56:34 +0000
commite7b18160a758b30dd6b701b4aa6f43c9c2061ccf (patch)
treea990292cb0a24d6b23eec9011ad2c06b4cfa1f0a /Graphics/GraphicsEngineD3DBase
parentAdded buffer mode validation when binding buffer views (diff)
downloadDiligentCore-e7b18160a758b30dd6b701b4aa6f43c9c2061ccf.tar.gz
DiligentCore-e7b18160a758b30dd6b701b4aa6f43c9c2061ccf.zip
All backends: added resource dimension validation when setting shader variables
Diffstat (limited to 'Graphics/GraphicsEngineD3DBase')
-rw-r--r--Graphics/GraphicsEngineD3DBase/include/ShaderResources.hpp4
-rw-r--r--Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp33
2 files changed, 37 insertions, 0 deletions
diff --git a/Graphics/GraphicsEngineD3DBase/include/ShaderResources.hpp b/Graphics/GraphicsEngineD3DBase/include/ShaderResources.hpp
index b5446ec3..2843f9f0 100644
--- a/Graphics/GraphicsEngineD3DBase/include/ShaderResources.hpp
+++ b/Graphics/GraphicsEngineD3DBase/include/ShaderResources.hpp
@@ -192,6 +192,10 @@ public:
return static_cast<D3D_SRV_DIMENSION>(SRVDimension);
}
+ RESOURCE_DIMENSION GetResourceDimension() const;
+
+ bool IsMultisample() const;
+
bool IsCombinedWithSampler() const
{
return GetCombinedSamplerId() != InvalidSamplerId;
diff --git a/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp b/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp
index 75ec17ea..498e31a2 100644
--- a/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp
+++ b/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp
@@ -454,6 +454,39 @@ HLSLShaderResourceDesc D3DShaderResourceAttribs::GetHLSLResourceDesc() const
return ResourceDesc;
}
+RESOURCE_DIMENSION D3DShaderResourceAttribs::GetResourceDimension() const
+{
+ switch (GetSRVDimension())
+ {
+ // clang-format off
+ case D3D_SRV_DIMENSION_BUFFER: return RESOURCE_DIM_BUFFER;
+ case D3D_SRV_DIMENSION_TEXTURE1D: return RESOURCE_DIM_TEX_1D;
+ case D3D_SRV_DIMENSION_TEXTURE1DARRAY: return RESOURCE_DIM_TEX_1D_ARRAY;
+ case D3D_SRV_DIMENSION_TEXTURE2D: return RESOURCE_DIM_TEX_2D;
+ case D3D_SRV_DIMENSION_TEXTURE2DARRAY: return RESOURCE_DIM_TEX_2D_ARRAY;
+ case D3D_SRV_DIMENSION_TEXTURE2DMS: return RESOURCE_DIM_TEX_2D;
+ case D3D_SRV_DIMENSION_TEXTURE2DMSARRAY: return RESOURCE_DIM_TEX_2D_ARRAY;
+ case D3D_SRV_DIMENSION_TEXTURE3D: return RESOURCE_DIM_TEX_3D;
+ case D3D_SRV_DIMENSION_TEXTURECUBE: return RESOURCE_DIM_TEX_CUBE;
+ case D3D_SRV_DIMENSION_TEXTURECUBEARRAY: return RESOURCE_DIM_TEX_CUBE_ARRAY;
+ // clang-format on
+ default:
+ return RESOURCE_DIM_BUFFER;
+ }
+}
+
+bool D3DShaderResourceAttribs::IsMultisample() const
+{
+ switch (GetSRVDimension())
+ {
+ case D3D_SRV_DIMENSION_TEXTURE2DMS:
+ case D3D_SRV_DIMENSION_TEXTURE2DMSARRAY:
+ return true;
+ default:
+ return false;
+ }
+}
+
HLSLShaderResourceDesc ShaderResources::GetHLSLShaderResourceDesc(Uint32 Index) const
{
DEV_CHECK_ERR(Index < m_TotalResources, "Resource index (", Index, ") is out of range");