diff --git a/src/dxvk/dxvk_constant_state.h b/src/dxvk/dxvk_constant_state.h index db02cdf20..054b93c30 100644 --- a/src/dxvk/dxvk_constant_state.h +++ b/src/dxvk/dxvk_constant_state.h @@ -191,7 +191,7 @@ namespace dxvk { struct DxvkConstantStateObjects { - Rc inputAssembly; + Rc inputAssemblyState; Rc inputLayout; Rc rasterizerState; Rc multisampleState; diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index e2f05d162..e33265995 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -145,6 +145,60 @@ namespace dxvk { } + void DxvkContext::setInputAssemblyState( + const Rc& state) { + if (m_state.co.inputAssemblyState != state) { + m_state.co.inputAssemblyState = state; + m_state.flags.set(DxvkContextFlag::GpDirtyPipelineState); + } + } + + + void DxvkContext::setInputLayout( + const Rc& state) { + if (m_state.co.inputLayout != state) { + m_state.co.inputLayout = state; + m_state.flags.set(DxvkContextFlag::GpDirtyPipelineState); + } + } + + + void DxvkContext::setRasterizerState( + const Rc& state) { + if (m_state.co.rasterizerState != state) { + m_state.co.rasterizerState = state; + m_state.flags.set(DxvkContextFlag::GpDirtyPipelineState); + } + } + + + void DxvkContext::setMultisampleState( + const Rc& state) { + if (m_state.co.multisampleState != state) { + m_state.co.multisampleState = state; + m_state.flags.set(DxvkContextFlag::GpDirtyPipelineState); + } + } + + + void DxvkContext::setDepthStencilState( + const Rc& state) { + if (m_state.co.depthStencilState != state) { + m_state.co.depthStencilState = state; + m_state.flags.set(DxvkContextFlag::GpDirtyPipelineState); + } + } + + + void DxvkContext::setBlendState( + const Rc& state) { + if (m_state.co.blendState != state) { + m_state.co.blendState = state; + m_state.flags.set(DxvkContextFlag::GpDirtyPipelineState); + } + } + + void DxvkContext::renderPassBegin() { if (!m_state.flags.test(DxvkContextFlag::GpRenderPassBound) && (m_state.om.framebuffer != nullptr)) { @@ -194,7 +248,14 @@ namespace dxvk { m_state.flags.clr(DxvkContextFlag::GpDirtyPipelineState); DxvkGraphicsPipelineStateInfo gpState; - // TODO fill state object + gpState.inputAssemblyState = m_state.co.inputAssemblyState; + gpState.inputLayout = m_state.co.inputLayout; + gpState.rasterizerState = m_state.co.rasterizerState; + gpState.multisampleState = m_state.co.multisampleState; + gpState.depthStencilState = m_state.co.depthStencilState; + gpState.blendState = m_state.co.blendState; + gpState.renderPass = m_state.om.framebuffer->renderPass(); + gpState.viewportCount = m_state.vp.viewportCount; m_cmd->cmdBindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, m_state.activeGraphicsPipeline->getPipelineHandle(gpState)); diff --git a/src/dxvk/dxvk_context.h b/src/dxvk/dxvk_context.h index df5953bb9..25ee68707 100644 --- a/src/dxvk/dxvk_context.h +++ b/src/dxvk/dxvk_context.h @@ -126,6 +126,48 @@ namespace dxvk { uint32_t vertexOffset, uint32_t firstInstance); + /** + * \brief Sets input assembly state + * \param [in] state New state object + */ + void setInputAssemblyState( + const Rc& state); + + /** + * \brief Sets input layout state + * \param [in] state New state object + */ + void setInputLayout( + const Rc& state); + + /** + * \brief Sets rasterizer state + * \param [in] state New state object + */ + void setRasterizerState( + const Rc& state); + + /** + * \brief Sets multisample state + * \param [in] state New state object + */ + void setMultisampleState( + const Rc& state); + + /** + * \brief Sets depth stencil state + * \param [in] state New state object + */ + void setDepthStencilState( + const Rc& state); + + /** + * \brief Sets color blend state + * \param [in] state New state object + */ + void setBlendState( + const Rc& state); + private: const Rc m_device; diff --git a/src/dxvk/dxvk_graphics.cpp b/src/dxvk/dxvk_graphics.cpp index 316b24ff0..4ebcfc5ec 100644 --- a/src/dxvk/dxvk_graphics.cpp +++ b/src/dxvk/dxvk_graphics.cpp @@ -9,7 +9,7 @@ namespace dxvk { size_t DxvkGraphicsPipelineStateInfo::hash() const { DxvkHashState state; - state.add(hashPtr(this->inputAssembly.ptr())); + state.add(hashPtr(this->inputAssemblyState.ptr())); state.add(hashPtr(this->inputLayout.ptr())); state.add(hashPtr(this->rasterizerState.ptr())); state.add(hashPtr(this->multisampleState.ptr())); @@ -22,7 +22,7 @@ namespace dxvk { bool DxvkGraphicsPipelineStateInfo::operator == (const DxvkGraphicsPipelineStateInfo& other) const { - return this->inputAssembly == other.inputAssembly + return this->inputAssemblyState == other.inputAssemblyState && this->inputLayout == other.inputLayout && this->rasterizerState == other.rasterizerState && this->multisampleState == other.multisampleState diff --git a/src/dxvk/dxvk_graphics.h b/src/dxvk/dxvk_graphics.h index 92b0cc051..c62bf81ae 100644 --- a/src/dxvk/dxvk_graphics.h +++ b/src/dxvk/dxvk_graphics.h @@ -19,7 +19,7 @@ namespace dxvk { * the current pipeline state vector. */ struct DxvkGraphicsPipelineStateInfo { - Rc inputAssembly; + Rc inputAssemblyState; Rc inputLayout; Rc rasterizerState; Rc multisampleState;