1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-30 20:52:11 +01:00

[dxvk] Refactored blend state

This commit is contained in:
Philip Rebohle 2017-12-08 00:51:10 +01:00
parent 84605a1310
commit 6a9743ead7
4 changed files with 51 additions and 34 deletions

View File

@ -74,32 +74,30 @@ namespace dxvk {
/** /**
* \brief Blend state * \brief Logic op state
* * Defines a logic op.
* Stores the color blend state for each
* available framebuffer attachment.
*/ */
class DxvkBlendState : public RcObject { struct DxvkLogicOpState {
VkBool32 enableLogicOp;
public: VkLogicOp logicOp;
};
DxvkBlendState(
VkBool32 enableLogicOp,
VkLogicOp logicOp, /**
uint32_t attachmentCount, * \brief Blend mode for a single attachment
const VkPipelineColorBlendAttachmentState* attachmentState); *
* Stores the blend state for a single color attachment.
const VkPipelineColorBlendStateCreateInfo& info() const { * Blend modes can be set separately for each attachment.
return m_info; */
} struct DxvkBlendMode {
VkBool32 blendEnable;
private: VkBlendFactor srcColorBlendFactor;
VkBlendFactor dstColorBlendFactor;
std::array<VkPipelineColorBlendAttachmentState, VkBlendOp colorBlendOp;
DxvkLimits::MaxNumRenderTargets> m_attachments; VkBlendFactor srcAlphaBlendFactor;
VkBlendFactor dstAlphaBlendFactor;
VkPipelineColorBlendStateCreateInfo m_info; VkBlendOp alphaBlendOp;
VkColorComponentFlags colorWriteMask;
}; };

View File

@ -427,12 +427,18 @@ namespace dxvk {
} }
void DxvkContext::setBlendState( void DxvkContext::setLogicOpState(
const Rc<DxvkBlendState>& state) { const DxvkLogicOpState& state) {
if (m_state.co.blendState != state) { m_state.lo = state;
m_state.co.blendState = state; m_flags.set(DxvkContextFlag::GpDirtyPipelineState);
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);
} }

View File

@ -305,11 +305,21 @@ namespace dxvk {
const DxvkDepthStencilState& state); const DxvkDepthStencilState& state);
/** /**
* \brief Sets color blend state * \brief Sets logic op state
* \param [in] state New state object * \param [in] state New state object
*/ */
void setBlendState( void setLogicOpState(
const Rc<DxvkBlendState>& state); 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: private:

View File

@ -57,6 +57,8 @@ namespace dxvk {
struct DxvkOutputMergerState { struct DxvkOutputMergerState {
uint32_t sampleMask = 0xFFFFFFFFu; uint32_t sampleMask = 0xFFFFFFFFu;
Rc<DxvkFramebuffer> framebuffer; Rc<DxvkFramebuffer> framebuffer;
std::array<DxvkBlendMode, DxvkLimits::MaxNumRenderTargets> blendModes;
}; };
@ -94,6 +96,7 @@ namespace dxvk {
DxvkRasterizerState rs; DxvkRasterizerState rs;
DxvkMultisampleState ms; DxvkMultisampleState ms;
DxvkDepthStencilState ds; DxvkDepthStencilState ds;
DxvkLogicOpState lo;
DxvkVertexInputState vi; DxvkVertexInputState vi;
DxvkViewportState vp; DxvkViewportState vp;