summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngine
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-06-27 04:14:20 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-06-27 04:14:20 +0000
commitecd151d725ec446be7718995ed110de1678d7d8f (patch)
tree95955d04de4b7d76488d06ac963833751eea5b81 /Graphics/GraphicsEngine
parentImproved SRB data allocation in D3D11 backend; removed AdaptiveFixedBlockAllo... (diff)
downloadDiligentCore-ecd151d725ec446be7718995ed110de1678d7d8f.tar.gz
DiligentCore-ecd151d725ec446be7718995ed110de1678d7d8f.zip
Reworked shader memory alloction for resource layouts in D3D12 pipeline implementation
Diffstat (limited to 'Graphics/GraphicsEngine')
-rw-r--r--Graphics/GraphicsEngine/include/PipelineStateBase.h21
-rw-r--r--Graphics/GraphicsEngine/interface/PipelineState.h15
2 files changed, 22 insertions, 14 deletions
diff --git a/Graphics/GraphicsEngine/include/PipelineStateBase.h b/Graphics/GraphicsEngine/include/PipelineStateBase.h
index 77c82cf5..80813fba 100644
--- a/Graphics/GraphicsEngine/include/PipelineStateBase.h
+++ b/Graphics/GraphicsEngine/include/PipelineStateBase.h
@@ -60,8 +60,6 @@ public:
m_LayoutElements( PSODesc.GraphicsPipeline.InputLayout.NumElements, LayoutElement(), STD_ALLOCATOR_RAW_MEM(LayoutElement, GetRawAllocator(), "Allocator for vector<LayoutElement>" ) ),
m_NumShaders(0)
{
- memset(m_ppShaders, 0, sizeof(m_ppShaders));
-
if (this->m_Desc.IsComputePipeline)
{
const auto &ComputePipeline = PSODesc.ComputePipeline;
@@ -73,7 +71,7 @@ public:
#define VALIDATE_SHADER_TYPE(Shader, ExpectedType, ShaderName)\
if (Shader && Shader->GetDesc().ShaderType != ExpectedType) \
{ \
- LOG_ERROR_AND_THROW( GetShaderTypeLiteralName(Shader->GetDesc().ShaderType), " is not valid type for ", ShaderName, " shader" );\
+ LOG_ERROR_AND_THROW( GetShaderTypeLiteralName(Shader->GetDesc().ShaderType), " is not a valid type for ", ShaderName, " shader" );\
}
VALIDATE_SHADER_TYPE(ComputePipeline.pCS, SHADER_TYPE_COMPUTE, "compute")
@@ -208,6 +206,19 @@ public:
IShader* const* GetShaders()const{return m_ppShaders;}
Uint32 GetNumShaders()const{return m_NumShaders;}
+ template<typename ShaderType>
+ ShaderType* GetShader(Uint32 ShaderInd)
+ {
+ VERIFY_EXPR(ShaderInd < m_NumShaders);
+ return ValidatedCast<ShaderType>(m_ppShaders[ShaderInd]);
+ }
+ template<typename ShaderType>
+ ShaderType* GetShader(Uint32 ShaderInd)const
+ {
+ VERIFY_EXPR(ShaderInd < m_NumShaders);
+ return ValidatedCast<ShaderType>(m_ppShaders[ShaderInd]);
+ }
+
// This function only compares shader resource layout hashes, so
// it can potentially give false negatives
bool IsIncompatibleWith(IPipelineState *pPSO)const
@@ -230,8 +241,8 @@ protected:
RefCntAutoPtr<IShader> m_pDS; ///< Strong reference to the domain shader
RefCntAutoPtr<IShader> m_pHS; ///< Strong reference to the hull shader
RefCntAutoPtr<IShader> m_pCS; ///< Strong reference to the compute shader
- IShader *m_ppShaders[5]; ///< Array of pointers to shaders that this PSO uses
- Uint32 m_NumShaders; ///< Number of shaders that this PSO uses
+ IShader* m_ppShaders[5] = {}; ///< Array of pointers to the shaders used by this PSO
+ Uint32 m_NumShaders = 0; ///< Number of shaders that this PSO uses
size_t m_ShaderResourceLayoutHash = 0;///< Hash computed from the shader resource layout
};
diff --git a/Graphics/GraphicsEngine/interface/PipelineState.h b/Graphics/GraphicsEngine/interface/PipelineState.h
index 34962f2e..0c642f3f 100644
--- a/Graphics/GraphicsEngine/interface/PipelineState.h
+++ b/Graphics/GraphicsEngine/interface/PipelineState.h
@@ -62,19 +62,19 @@ struct SampleDesc
struct GraphicsPipelineDesc
{
/// Vertex shader to be used with the pipeline
- IShader *pVS = nullptr;
+ IShader* pVS = nullptr;
/// Pixel shader to be used with the pipeline
- IShader *pPS = nullptr;
+ IShader* pPS = nullptr;
/// Domain shader to be used with the pipeline
- IShader *pDS = nullptr;
+ IShader* pDS = nullptr;
/// Hull shader to be used with the pipeline
- IShader *pHS = nullptr;
+ IShader* pHS = nullptr;
/// Geometry shader to be used with the pipeline
- IShader *pGS = nullptr;
+ IShader* pGS = nullptr;
//D3D12_STREAM_OUTPUT_DESC StreamOutput;
@@ -136,10 +136,7 @@ struct GraphicsPipelineDesc
struct ComputePipelineDesc
{
/// Compute shader to be used with the pipeline
- IShader *pCS;
- ComputePipelineDesc() :
- pCS(nullptr)
- {}
+ IShader* pCS = nullptr;
};
/// Pipeline state description