diff --git a/src/dxvk/dxvk_constant_state.h b/src/dxvk/dxvk_constant_state.h index c0b98c4c9..3d948337c 100644 --- a/src/dxvk/dxvk_constant_state.h +++ b/src/dxvk/dxvk_constant_state.h @@ -74,32 +74,30 @@ namespace dxvk { /** - * \brief Blend state - * - * Stores the color blend state for each - * available framebuffer attachment. + * \brief Logic op state + * Defines a logic op. */ - class DxvkBlendState : public RcObject { - - public: - - DxvkBlendState( - VkBool32 enableLogicOp, - VkLogicOp logicOp, - uint32_t attachmentCount, - const VkPipelineColorBlendAttachmentState* attachmentState); - - const VkPipelineColorBlendStateCreateInfo& info() const { - return m_info; - } - - private: - - std::array m_attachments; - - VkPipelineColorBlendStateCreateInfo m_info; - + struct DxvkLogicOpState { + VkBool32 enableLogicOp; + VkLogicOp logicOp; + }; + + + /** + * \brief Blend mode for a single attachment + * + * Stores the blend state for a single color attachment. + * Blend modes can be set separately for each attachment. + */ + struct DxvkBlendMode { + VkBool32 blendEnable; + VkBlendFactor srcColorBlendFactor; + VkBlendFactor dstColorBlendFactor; + VkBlendOp colorBlendOp; + VkBlendFactor srcAlphaBlendFactor; + VkBlendFactor dstAlphaBlendFactor; + VkBlendOp alphaBlendOp; + VkColorComponentFlags colorWriteMask; }; diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index 0504eceda..a56ba3968 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -427,12 +427,18 @@ namespace dxvk { } - void DxvkContext::setBlendState( - const Rc& state) { - if (m_state.co.blendState != state) { - m_state.co.blendState = state; - m_flags.set(DxvkContextFlag::GpDirtyPipelineState); - } + void DxvkContext::setLogicOpState( + const DxvkLogicOpState& state) { + m_state.lo = state; + m_flags.set(DxvkContextFlag::GpDirtyPipelineState); + } + + + void DxvkContext::setBlendMode( + uint32_t attachment, + const DxvkBlendMode& blendMode) { + m_state.om.blendModes.at(attachment) = blendMode; + m_flags.set(DxvkContextFlag::GpDirtyPipelineState); } diff --git a/src/dxvk/dxvk_context.h b/src/dxvk/dxvk_context.h index f87fe6510..6831cc2e3 100644 --- a/src/dxvk/dxvk_context.h +++ b/src/dxvk/dxvk_context.h @@ -305,11 +305,21 @@ namespace dxvk { const DxvkDepthStencilState& state); /** - * \brief Sets color blend state + * \brief Sets logic op state * \param [in] state New state object */ - void setBlendState( - const Rc& state); + void setLogicOpState( + const DxvkLogicOpState& state); + + /** + * \brief Sets blend mode for an attachment + * + * \param [in] attachment The attachment index + * \param [in] blendMode The blend mode + */ + void setBlendMode( + uint32_t attachment, + const DxvkBlendMode& blendMode); private: diff --git a/src/dxvk/dxvk_context_state.h b/src/dxvk/dxvk_context_state.h index 8fa12c386..849049654 100644 --- a/src/dxvk/dxvk_context_state.h +++ b/src/dxvk/dxvk_context_state.h @@ -57,6 +57,8 @@ namespace dxvk { struct DxvkOutputMergerState { uint32_t sampleMask = 0xFFFFFFFFu; Rc framebuffer; + + std::array blendModes; }; @@ -94,6 +96,7 @@ namespace dxvk { DxvkRasterizerState rs; DxvkMultisampleState ms; DxvkDepthStencilState ds; + DxvkLogicOpState lo; DxvkVertexInputState vi; DxvkViewportState vp;