mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-04-01 09:25:24 +02:00
[dxvk,d3d9,d3d11] Refactor logic op state object
This commit is contained in:
parent
abb5db346c
commit
4a5c50b2de
@ -27,8 +27,8 @@ namespace dxvk {
|
|||||||
if (desc.IndependentBlendEnable && desc.RenderTarget[0].LogicOpEnable)
|
if (desc.IndependentBlendEnable && desc.RenderTarget[0].LogicOpEnable)
|
||||||
Logger::warn("D3D11: Per-target logic ops not supported");
|
Logger::warn("D3D11: Per-target logic ops not supported");
|
||||||
|
|
||||||
m_loState.enableLogicOp = desc.RenderTarget[0].LogicOpEnable;
|
m_loState.setLogicOp(desc.RenderTarget[0].LogicOpEnable,
|
||||||
m_loState.logicOp = DecodeLogicOp(desc.RenderTarget[0].LogicOp);
|
DecodeLogicOp(desc.RenderTarget[0].LogicOp));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -96,9 +96,6 @@ namespace dxvk {
|
|||||||
// blend mode array will be identical
|
// blend mode array will be identical
|
||||||
for (uint32_t i = 0; i < m_blendModes.size(); i++)
|
for (uint32_t i = 0; i < m_blendModes.size(); i++)
|
||||||
ctx->setBlendMode(i, m_blendModes.at(i));
|
ctx->setBlendMode(i, m_blendModes.at(i));
|
||||||
|
|
||||||
// Set up logic op state as well
|
|
||||||
ctx->setLogicOpState(m_loState);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,6 +38,10 @@ namespace dxvk {
|
|||||||
return msState;
|
return msState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DxvkLogicOpState GetLoState() const {
|
||||||
|
return m_loState;
|
||||||
|
}
|
||||||
|
|
||||||
void BindToContext(
|
void BindToContext(
|
||||||
DxvkContext* ctx) const;
|
DxvkContext* ctx) const;
|
||||||
|
|
||||||
@ -57,10 +61,10 @@ namespace dxvk {
|
|||||||
|
|
||||||
std::array<DxvkBlendMode, 8> m_blendModes;
|
std::array<DxvkBlendMode, 8> m_blendModes;
|
||||||
DxvkMultisampleState m_msState = { };
|
DxvkMultisampleState m_msState = { };
|
||||||
DxvkLogicOpState m_loState;
|
DxvkLogicOpState m_loState = { };
|
||||||
|
|
||||||
D3D10BlendState m_d3d10;
|
D3D10BlendState m_d3d10;
|
||||||
|
|
||||||
static DxvkBlendMode DecodeBlendMode(
|
static DxvkBlendMode DecodeBlendMode(
|
||||||
const D3D11_RENDER_TARGET_BLEND_DESC1& BlendDesc);
|
const D3D11_RENDER_TARGET_BLEND_DESC1& BlendDesc);
|
||||||
|
|
||||||
|
@ -3371,25 +3371,26 @@ namespace dxvk {
|
|||||||
if (m_state.om.cbState != nullptr) {
|
if (m_state.om.cbState != nullptr) {
|
||||||
EmitCs([
|
EmitCs([
|
||||||
cBlendState = m_state.om.cbState,
|
cBlendState = m_state.om.cbState,
|
||||||
cMsState = m_state.om.cbState->GetMsState(m_state.om.sampleMask)
|
cMsState = m_state.om.cbState->GetMsState(m_state.om.sampleMask),
|
||||||
|
cLoState = m_state.om.cbState->GetLoState()
|
||||||
] (DxvkContext* ctx) {
|
] (DxvkContext* ctx) {
|
||||||
cBlendState->BindToContext(ctx);
|
cBlendState->BindToContext(ctx);
|
||||||
|
|
||||||
ctx->setMultisampleState(cMsState);
|
ctx->setMultisampleState(cMsState);
|
||||||
|
ctx->setLogicOpState(cLoState);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
EmitCs([
|
EmitCs([
|
||||||
cSampleMask = m_state.om.sampleMask
|
cSampleMask = m_state.om.sampleMask
|
||||||
] (DxvkContext* ctx) {
|
] (DxvkContext* ctx) {
|
||||||
DxvkBlendMode cbState;
|
DxvkBlendMode cbState;
|
||||||
DxvkLogicOpState loState;
|
InitDefaultBlendState(&cbState);
|
||||||
InitDefaultBlendState(&cbState, &loState);
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; i++)
|
for (uint32_t i = 0; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; i++)
|
||||||
ctx->setBlendMode(i, cbState);
|
ctx->setBlendMode(i, cbState);
|
||||||
|
|
||||||
ctx->setLogicOpState(loState);
|
|
||||||
ctx->setMultisampleState(InitDefaultMultisampleState(cSampleMask));
|
ctx->setMultisampleState(InitDefaultMultisampleState(cSampleMask));
|
||||||
|
ctx->setLogicOpState(InitDefaultLogicOpState());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4730,13 +4731,12 @@ namespace dxvk {
|
|||||||
InitDefaultRasterizerState(&rsState);
|
InitDefaultRasterizerState(&rsState);
|
||||||
|
|
||||||
DxvkBlendMode cbState;
|
DxvkBlendMode cbState;
|
||||||
DxvkLogicOpState loState;
|
InitDefaultBlendState(&cbState);
|
||||||
InitDefaultBlendState(&cbState, &loState);
|
|
||||||
|
|
||||||
ctx->setInputAssemblyState(iaState);
|
ctx->setInputAssemblyState(iaState);
|
||||||
ctx->setDepthStencilState(InitDefaultDepthStencilState());
|
ctx->setDepthStencilState(InitDefaultDepthStencilState());
|
||||||
ctx->setRasterizerState(rsState);
|
ctx->setRasterizerState(rsState);
|
||||||
ctx->setLogicOpState(loState);
|
ctx->setLogicOpState(InitDefaultLogicOpState());
|
||||||
ctx->setMultisampleState(InitDefaultMultisampleState(D3D11_DEFAULT_SAMPLE_MASK));
|
ctx->setMultisampleState(InitDefaultMultisampleState(D3D11_DEFAULT_SAMPLE_MASK));
|
||||||
|
|
||||||
for (uint32_t i = 0; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; i++)
|
for (uint32_t i = 0; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; i++)
|
||||||
@ -5821,10 +5821,17 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<typename ContextType>
|
||||||
|
DxvkLogicOpState D3D11CommonContext<ContextType>::InitDefaultLogicOpState() {
|
||||||
|
DxvkLogicOpState loState = { };
|
||||||
|
loState.setLogicOp(false, VK_LOGIC_OP_NO_OP);
|
||||||
|
return loState;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename ContextType>
|
template<typename ContextType>
|
||||||
void D3D11CommonContext<ContextType>::InitDefaultBlendState(
|
void D3D11CommonContext<ContextType>::InitDefaultBlendState(
|
||||||
DxvkBlendMode* pCbState,
|
DxvkBlendMode* pCbState) {
|
||||||
DxvkLogicOpState* pLoState) {
|
|
||||||
pCbState->enableBlending = VK_FALSE;
|
pCbState->enableBlending = VK_FALSE;
|
||||||
pCbState->colorSrcFactor = VK_BLEND_FACTOR_ONE;
|
pCbState->colorSrcFactor = VK_BLEND_FACTOR_ONE;
|
||||||
pCbState->colorDstFactor = VK_BLEND_FACTOR_ZERO;
|
pCbState->colorDstFactor = VK_BLEND_FACTOR_ZERO;
|
||||||
@ -5834,9 +5841,6 @@ namespace dxvk {
|
|||||||
pCbState->alphaBlendOp = VK_BLEND_OP_ADD;
|
pCbState->alphaBlendOp = VK_BLEND_OP_ADD;
|
||||||
pCbState->writeMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT
|
pCbState->writeMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT
|
||||||
| VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
|
| VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
|
||||||
|
|
||||||
pLoState->enableLogicOp = VK_FALSE;
|
|
||||||
pLoState->logicOp = VK_LOGIC_OP_NO_OP;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Explicitly instantiate here
|
// Explicitly instantiate here
|
||||||
|
@ -1154,9 +1154,10 @@ namespace dxvk {
|
|||||||
static DxvkMultisampleState InitDefaultMultisampleState(
|
static DxvkMultisampleState InitDefaultMultisampleState(
|
||||||
UINT SampleMask);
|
UINT SampleMask);
|
||||||
|
|
||||||
|
static DxvkLogicOpState InitDefaultLogicOpState();
|
||||||
|
|
||||||
static void InitDefaultBlendState(
|
static void InitDefaultBlendState(
|
||||||
DxvkBlendMode* pCbState,
|
DxvkBlendMode* pCbState);
|
||||||
DxvkLogicOpState* pLoState);
|
|
||||||
|
|
||||||
template<bool AllowFlush = true, typename Cmd>
|
template<bool AllowFlush = true, typename Cmd>
|
||||||
void EmitCs(Cmd&& command) {
|
void EmitCs(Cmd&& command) {
|
||||||
|
@ -82,9 +82,7 @@ namespace dxvk {
|
|||||||
ctx->beginRecording(cDevice->createCommandList());
|
ctx->beginRecording(cDevice->createCommandList());
|
||||||
|
|
||||||
// Disable logic op once and for all.
|
// Disable logic op once and for all.
|
||||||
DxvkLogicOpState loState;
|
DxvkLogicOpState loState = { };
|
||||||
loState.enableLogicOp = VK_FALSE;
|
|
||||||
loState.logicOp = VK_LOGIC_OP_CLEAR;
|
|
||||||
ctx->setLogicOpState(loState);
|
ctx->setLogicOpState(loState);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -312,9 +312,29 @@ namespace dxvk {
|
|||||||
* \brief Logic op state
|
* \brief Logic op state
|
||||||
* Defines a logic op.
|
* Defines a logic op.
|
||||||
*/
|
*/
|
||||||
struct DxvkLogicOpState {
|
class DxvkLogicOpState {
|
||||||
VkBool32 enableLogicOp;
|
|
||||||
VkLogicOp logicOp;
|
public:
|
||||||
|
|
||||||
|
bool logicOpEnable() const {
|
||||||
|
return m_logicOpEnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
VkLogicOp logicOp() const {
|
||||||
|
return VkLogicOp(m_logicOp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setLogicOp(bool enable, VkLogicOp op) {
|
||||||
|
m_logicOpEnable = enable;
|
||||||
|
m_logicOp = uint8_t(op);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
uint8_t m_logicOpEnable : 1;
|
||||||
|
uint8_t m_logicOp : 4;
|
||||||
|
uint8_t m_reserved : 3;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -2925,8 +2925,8 @@ namespace dxvk {
|
|||||||
|
|
||||||
void DxvkContext::setLogicOpState(const DxvkLogicOpState& lo) {
|
void DxvkContext::setLogicOpState(const DxvkLogicOpState& lo) {
|
||||||
m_state.gp.state.om = DxvkOmInfo(
|
m_state.gp.state.om = DxvkOmInfo(
|
||||||
lo.enableLogicOp,
|
lo.logicOpEnable(),
|
||||||
lo.logicOp,
|
lo.logicOp(),
|
||||||
m_state.gp.state.om.feedbackLoop());
|
m_state.gp.state.om.feedbackLoop());
|
||||||
|
|
||||||
m_flags.set(DxvkContextFlag::GpDirtyPipelineState);
|
m_flags.set(DxvkContextFlag::GpDirtyPipelineState);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user