29 #include "PipelineState.h" 30 #include "DeviceObjectBase.h" 31 #include "STDAllocator.h" 32 #include "EngineMemory.h" 33 #include "GraphicsAccessories.h" 45 template<
class BaseInterface,
class RenderDeviceBaseInterface>
67 if (ComputePipeline.pCS ==
nullptr)
69 LOG_ERROR_AND_THROW(
"Compute shader is not provided" );
72 #define VALIDATE_SHADER_TYPE(Shader, ExpectedType, ShaderName)\ 73 if (Shader && Shader->GetDesc().ShaderType != ExpectedType) \ 75 LOG_ERROR_AND_THROW( GetShaderTypeLiteralName(Shader->GetDesc().ShaderType), " is not valid type for ", ShaderName, " shader" );\ 79 m_pCS = ComputePipeline.pCS;
92 #undef VALIDATE_SHADER_TYPE 94 m_pVS = GraphicsPipeline.pVS;
95 m_pPS = GraphicsPipeline.pPS;
96 m_pGS = GraphicsPipeline.pGS;
97 m_pDS = GraphicsPipeline.pDS;
98 m_pHS = GraphicsPipeline.pHS;
108 for(
size_t Elem = 0; Elem < InputLayout.NumElements; ++Elem )
109 m_LayoutElements[Elem] = InputLayout.LayoutElements[Elem];
110 this->m_Desc.GraphicsPipeline.InputLayout.LayoutElements = m_LayoutElements.data();
113 for(
auto It = m_LayoutElements.begin(); It != m_LayoutElements.end(); ++It )
116 It->IsNormalized =
false;
118 auto BuffSlot = It->BufferSlot;
119 if( BuffSlot >= _countof(m_TightStrides) )
121 UNEXPECTED(
"Buffer slot (", BuffSlot,
") exceeds the limit (", _countof(m_TightStrides),
")");
125 auto &CurrStride = m_TightStrides[BuffSlot];
126 if( It->RelativeOffset < CurrStride )
128 if( It->RelativeOffset == 0 )
129 It->RelativeOffset = CurrStride;
131 UNEXPECTED(
"Overlapping layout elements" );
134 CurrStride += It->NumComponents * GetValueSize( It->ValueType );
159 IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_PipelineState, TDeviceObjectBase )
161 virtual const Uint32* GetTightStrides()
const 163 return m_TightStrides;
166 IShader* GetVS(){
return m_pVS;}
167 IShader* GetPS(){
return m_pPS;}
168 IShader* GetGS(){
return m_pGS;}
169 IShader* GetDS(){
return m_pDS;}
170 IShader* GetHS(){
return m_pHS;}
171 IShader* GetCS(){
return m_pCS;}
173 IShader*
const* GetShaders()
const{
return m_ppShaders;}
177 std::vector<LayoutElement, STDAllocatorRawMem<LayoutElement> > m_LayoutElements;
static constexpr Uint32 MaxBufferSlots
Maximum number of input buffer slots. D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT == 32...
Definition: Constants.h:33
RefCntAutoPtr< IShader > m_pDS
Strong reference to the domain shader.
Definition: PipelineStateBase.h:187
Render device interface.
Definition: RenderDevice.h:55
Shader interface.
Definition: Shader.h:288
RefCntAutoPtr< IShader > m_pCS
Strong reference to the compute shader.
Definition: PipelineStateBase.h:189
Template class implementing base functionality for a pipeline state object.
Definition: PipelineStateBase.h:46
Namespace for the OpenGL implementation of the graphics engine.
Definition: BufferD3D11Impl.h:34
Pixel (fragment) shader.
Definition: Shader.h:50
RefCntAutoPtr< IShader > m_pVS
Strong reference to the vertex shader.
Definition: PipelineStateBase.h:184
IMemoryAllocator & GetRawAllocator()
Returns raw memory allocator.
Definition: EngineMemory.cpp:46
Hull (tessellation control) shader.
Definition: Shader.h:52
Domain (tessellation evaluation) shader.
Definition: Shader.h:53
PipelineStateBase(IReferenceCounters *pRefCounters, IRenderDevice *pDevice, const PipelineStateDesc &PSODesc, bool bIsDeviceInternal=false)
Definition: PipelineStateBase.h:57
Description of a single element of the input layout.
Definition: InputLayout.h:37
Base implementation of a render device.
Definition: DeviceObjectBase.h:36
Vertex shader.
Definition: Shader.h:49
Uint32 m_NumShaders
Number of shaders that this PSO uses.
Definition: PipelineStateBase.h:191
PipelineStateDesc m_Desc
Object description.
Definition: DeviceObjectBase.h:138
RefCntAutoPtr< IShader > m_pGS
Strong reference to the geometry shader.
Definition: PipelineStateBase.h:186
Half-precision 16-bit floating point.
Definition: GraphicsTypes.h:48
Full-precision 32-bit floating point.
Definition: GraphicsTypes.h:49
ComputePipelineDesc ComputePipeline
Compute pipeline state description. This memeber is ignored if IsComputePipeline == False...
Definition: PipelineState.h:188
InputLayoutDesc InputLayout
Input layout.
Definition: PipelineState.h:124
IShader * m_ppShaders[5]
Array of pointers to shaders that this PSO uses.
Definition: PipelineStateBase.h:190
RefCntAutoPtr< IShader > m_pHS
Strong reference to the hull shader.
Definition: PipelineStateBase.h:188
Template class that implements reference counting.
Definition: RefCntAutoPtr.h:71
bool IsComputePipeline
Flag indicating if pipeline state is a compute pipeline state.
Definition: PipelineState.h:182
GraphicsPipelineDesc GraphicsPipeline
Graphics pipeline state description. This memeber is ignored if IsComputePipeline == True...
Definition: PipelineState.h:185
RefCntAutoPtr< IShader > m_pPS
Strong reference to the pixel shader.
Definition: PipelineStateBase.h:185
Template class implementing base functionality for a device object.
Definition: DeviceObjectBase.h:42
Pipeline state description.
Definition: PipelineState.h:179
Compute shader.
Definition: Shader.h:54
Geometry shader.
Definition: Shader.h:51