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
|
||||
*
|
||||
* 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<VkPipelineColorBlendAttachmentState,
|
||||
DxvkLimits::MaxNumRenderTargets> 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;
|
||||
};
|
||||
|
||||
|
||||
|
@ -427,12 +427,18 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
void DxvkContext::setBlendState(
|
||||
const Rc<DxvkBlendState>& 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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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<DxvkBlendState>& 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:
|
||||
|
||||
|
@ -57,6 +57,8 @@ namespace dxvk {
|
||||
struct DxvkOutputMergerState {
|
||||
uint32_t sampleMask = 0xFFFFFFFFu;
|
||||
Rc<DxvkFramebuffer> framebuffer;
|
||||
|
||||
std::array<DxvkBlendMode, DxvkLimits::MaxNumRenderTargets> blendModes;
|
||||
};
|
||||
|
||||
|
||||
@ -94,6 +96,7 @@ namespace dxvk {
|
||||
DxvkRasterizerState rs;
|
||||
DxvkMultisampleState ms;
|
||||
DxvkDepthStencilState ds;
|
||||
DxvkLogicOpState lo;
|
||||
|
||||
DxvkVertexInputState vi;
|
||||
DxvkViewportState vp;
|
||||
|
Loading…
x
Reference in New Issue
Block a user