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:
parent
84605a1310
commit
6a9743ead7
@ -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;
|
||||||
|
VkLogicOp logicOp;
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
DxvkBlendState(
|
|
||||||
VkBool32 enableLogicOp,
|
|
||||||
VkLogicOp logicOp,
|
|
||||||
uint32_t attachmentCount,
|
|
||||||
const VkPipelineColorBlendAttachmentState* attachmentState);
|
|
||||||
|
|
||||||
const VkPipelineColorBlendStateCreateInfo& info() const {
|
|
||||||
return m_info;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
std::array<VkPipelineColorBlendAttachmentState,
|
|
||||||
DxvkLimits::MaxNumRenderTargets> m_attachments;
|
|
||||||
|
|
||||||
VkPipelineColorBlendStateCreateInfo m_info;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -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:
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user