summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngine
diff options
context:
space:
mode:
authorazhirnov <zh1dron@gmail.com>2020-09-16 19:41:57 +0000
committerazhirnov <zh1dron@gmail.com>2020-09-16 19:41:57 +0000
commita0488c54c6c5017c71198d8b13c9ed75894791de (patch)
treec5c72716c2b970b860b9da0cf1eb3d319237f478 /Graphics/GraphicsEngine
parentAnother improvement to texture format tests in OpenGL (diff)
downloadDiligentCore-a0488c54c6c5017c71198d8b13c9ed75894791de.tar.gz
DiligentCore-a0488c54c6c5017c71198d8b13c9ed75894791de.zip
use NUM_SHADER_TYPES constant instead of magic number, use std::array instead of c-style array.
Diffstat (limited to 'Graphics/GraphicsEngine')
-rw-r--r--Graphics/GraphicsEngine/include/PipelineStateBase.hpp6
-rw-r--r--Graphics/GraphicsEngine/include/ShaderBase.hpp3
-rw-r--r--Graphics/GraphicsEngine/interface/Constants.h4
3 files changed, 10 insertions, 3 deletions
diff --git a/Graphics/GraphicsEngine/include/PipelineStateBase.hpp b/Graphics/GraphicsEngine/include/PipelineStateBase.hpp
index 02a74f85..4d2e408f 100644
--- a/Graphics/GraphicsEngine/include/PipelineStateBase.hpp
+++ b/Graphics/GraphicsEngine/include/PipelineStateBase.hpp
@@ -406,7 +406,7 @@ public:
IShader* GetHS() { return m_pHS; }
IShader* GetCS() { return m_pCS; }
- IShader* const* GetShaders() const { return m_ppShaders; }
+ IShader* const* GetShaders() const { return m_ppShaders.data(); }
Uint32 GetNumShaders() const { return m_NumShaders; }
template <typename ShaderType>
@@ -447,8 +447,8 @@ protected:
RefCntAutoPtr<IRenderPass> m_pRenderPass; ///< Strong reference to the render pass object
- IShader* m_ppShaders[MAX_SHADERS_IN_PIPELINE] = {}; ///< Array of pointers to the shaders used by this PSO
- size_t m_ShaderResourceLayoutHash = 0; ///< Hash computed from the shader resource layout
+ std::array<IShader*, MAX_SHADERS_IN_PIPELINE> m_ppShaders = {}; ///< Array of pointers to the shaders used by this PSO
+ size_t m_ShaderResourceLayoutHash = 0; ///< Hash computed from the shader resource layout
private:
#define LOG_PSO_ERROR_AND_THROW(...) LOG_ERROR_AND_THROW("Description of ", GetPipelineTypeString(this->m_Desc.PipelineType), " PSO '", this->m_Desc.Name, "' is invalid: ", ##__VA_ARGS__)
diff --git a/Graphics/GraphicsEngine/include/ShaderBase.hpp b/Graphics/GraphicsEngine/include/ShaderBase.hpp
index 5b39da79..3beaa9c8 100644
--- a/Graphics/GraphicsEngine/include/ShaderBase.hpp
+++ b/Graphics/GraphicsEngine/include/ShaderBase.hpp
@@ -38,10 +38,13 @@
#include "PlatformMisc.hpp"
#include "EngineMemory.h"
#include "Align.hpp"
+#include "Constants.h"
namespace Diligent
{
+static_assert((1u << (NUM_SHADER_TYPES - 1)) == SHADER_TYPE_LAST, "check shader type enum or shader count");
+
inline SHADER_TYPE GetShaderTypeFromIndex(Int32 Index)
{
return static_cast<SHADER_TYPE>(1 << Index);
diff --git a/Graphics/GraphicsEngine/interface/Constants.h b/Graphics/GraphicsEngine/interface/Constants.h
index dfd17c45..419d6862 100644
--- a/Graphics/GraphicsEngine/interface/Constants.h
+++ b/Graphics/GraphicsEngine/interface/Constants.h
@@ -51,8 +51,12 @@ static const Uint32 MAX_RENDER_TARGETS = DILIGENT_MAX_RENDER_TARGETS;
static const Uint32 MAX_VIEWPORTS = DILIGENT_MAX_VIEWPORTS;
/// Maximum number of shader stages in a pipeline.
+/// (Vertex, Pixel, Geometry, Domain, Hull) or (Amplification, Mesh, Pixel)
static const Uint32 MAX_SHADERS_IN_PIPELINE = 5;
+///// Number of different shader types (Vertex, Pixel, Geometry, Domain, Hull, Compute, Amplification, Mesh)
+static const Uint32 NUM_SHADER_TYPES = 8;
+
// clang-format on
DILIGENT_END_NAMESPACE // namespace Diligent