mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +01:00
[dxvk] Use packed depth-stencil state
This commit is contained in:
parent
a933bec72c
commit
079b480602
@ -2223,8 +2223,8 @@ namespace dxvk {
|
|||||||
m_flags.set(DxvkContextFlag::GpDirtyDepthBounds);
|
m_flags.set(DxvkContextFlag::GpDirtyDepthBounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_state.gp.state.dsEnableDepthBoundsTest != depthBounds.enableDepthBounds) {
|
if (m_state.gp.state.ds.enableDepthBoundsTest() != depthBounds.enableDepthBounds) {
|
||||||
m_state.gp.state.dsEnableDepthBoundsTest = depthBounds.enableDepthBounds;
|
m_state.gp.state.ds.setEnableDepthBoundsTest(depthBounds.enableDepthBounds);
|
||||||
m_flags.set(DxvkContextFlag::GpDirtyPipelineState);
|
m_flags.set(DxvkContextFlag::GpDirtyPipelineState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2305,12 +2305,15 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
void DxvkContext::setDepthStencilState(const DxvkDepthStencilState& ds) {
|
void DxvkContext::setDepthStencilState(const DxvkDepthStencilState& ds) {
|
||||||
m_state.gp.state.dsEnableDepthTest = ds.enableDepthTest;
|
m_state.gp.state.ds = DxvkDsInfo(
|
||||||
m_state.gp.state.dsEnableDepthWrite = ds.enableDepthWrite;
|
ds.enableDepthTest,
|
||||||
m_state.gp.state.dsEnableStencilTest = ds.enableStencilTest;
|
ds.enableDepthWrite,
|
||||||
m_state.gp.state.dsDepthCompareOp = ds.depthCompareOp;
|
m_state.gp.state.ds.enableDepthBoundsTest(),
|
||||||
m_state.gp.state.dsStencilOpFront = ds.stencilOpFront;
|
ds.enableStencilTest,
|
||||||
m_state.gp.state.dsStencilOpBack = ds.stencilOpBack;
|
ds.depthCompareOp);
|
||||||
|
|
||||||
|
m_state.gp.state.dsFront = DxvkDsStencilOp(ds.stencilOpFront);
|
||||||
|
m_state.gp.state.dsBack = DxvkDsStencilOp(ds.stencilOpBack);
|
||||||
|
|
||||||
m_flags.set(DxvkContextFlag::GpDirtyPipelineState);
|
m_flags.set(DxvkContextFlag::GpDirtyPipelineState);
|
||||||
}
|
}
|
||||||
|
@ -358,13 +358,13 @@ namespace dxvk {
|
|||||||
dsInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
|
dsInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
|
||||||
dsInfo.pNext = nullptr;
|
dsInfo.pNext = nullptr;
|
||||||
dsInfo.flags = 0;
|
dsInfo.flags = 0;
|
||||||
dsInfo.depthTestEnable = state.dsEnableDepthTest;
|
dsInfo.depthTestEnable = state.ds.enableDepthTest();
|
||||||
dsInfo.depthWriteEnable = state.dsEnableDepthWrite && !util::isDepthReadOnlyLayout(passFormat.depth.layout);
|
dsInfo.depthWriteEnable = state.ds.enableDepthWrite() && !util::isDepthReadOnlyLayout(passFormat.depth.layout);
|
||||||
dsInfo.depthCompareOp = state.dsDepthCompareOp;
|
dsInfo.depthCompareOp = state.ds.depthCompareOp();
|
||||||
dsInfo.depthBoundsTestEnable = state.dsEnableDepthBoundsTest;
|
dsInfo.depthBoundsTestEnable = state.ds.enableDepthBoundsTest();
|
||||||
dsInfo.stencilTestEnable = state.dsEnableStencilTest;
|
dsInfo.stencilTestEnable = state.ds.enableStencilTest();
|
||||||
dsInfo.front = state.dsStencilOpFront;
|
dsInfo.front = state.dsFront.state();
|
||||||
dsInfo.back = state.dsStencilOpBack;
|
dsInfo.back = state.dsBack.state();
|
||||||
dsInfo.minDepthBounds = 0.0f;
|
dsInfo.minDepthBounds = 0.0f;
|
||||||
dsInfo.maxDepthBounds = 1.0f;
|
dsInfo.maxDepthBounds = 1.0f;
|
||||||
|
|
||||||
|
@ -329,6 +329,113 @@ namespace dxvk {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Packed depth-stencil metadata
|
||||||
|
*
|
||||||
|
* Stores some flags and the depth-compare op in
|
||||||
|
* two bytes. Stencil ops are stored separately.
|
||||||
|
*/
|
||||||
|
class DxvkDsInfo {
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
DxvkDsInfo() = default;
|
||||||
|
|
||||||
|
DxvkDsInfo(
|
||||||
|
VkBool32 enableDepthTest,
|
||||||
|
VkBool32 enableDepthWrite,
|
||||||
|
VkBool32 enableDepthBoundsTest,
|
||||||
|
VkBool32 enableStencilTest,
|
||||||
|
VkCompareOp depthCompareOp)
|
||||||
|
: m_enableDepthTest (uint16_t(enableDepthTest)),
|
||||||
|
m_enableDepthWrite (uint16_t(enableDepthWrite)),
|
||||||
|
m_enableDepthBoundsTest (uint16_t(enableDepthBoundsTest)),
|
||||||
|
m_enableStencilTest (uint16_t(enableStencilTest)),
|
||||||
|
m_depthCompareOp (uint16_t(depthCompareOp)),
|
||||||
|
m_reserved (0) { }
|
||||||
|
|
||||||
|
VkBool32 enableDepthTest() const {
|
||||||
|
return VkBool32(m_enableDepthTest);
|
||||||
|
}
|
||||||
|
|
||||||
|
VkBool32 enableDepthWrite() const {
|
||||||
|
return VkBool32(m_enableDepthWrite);
|
||||||
|
}
|
||||||
|
|
||||||
|
VkBool32 enableDepthBoundsTest() const {
|
||||||
|
return VkBool32(m_enableDepthBoundsTest);
|
||||||
|
}
|
||||||
|
|
||||||
|
VkBool32 enableStencilTest() const {
|
||||||
|
return VkBool32(m_enableStencilTest);
|
||||||
|
}
|
||||||
|
|
||||||
|
VkCompareOp depthCompareOp() const {
|
||||||
|
return VkCompareOp(m_depthCompareOp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setEnableDepthBoundsTest(VkBool32 enableDepthBoundsTest) {
|
||||||
|
m_enableDepthBoundsTest = VkBool32(enableDepthBoundsTest);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
uint16_t m_enableDepthTest : 1;
|
||||||
|
uint16_t m_enableDepthWrite : 1;
|
||||||
|
uint16_t m_enableDepthBoundsTest : 1;
|
||||||
|
uint16_t m_enableStencilTest : 1;
|
||||||
|
uint16_t m_depthCompareOp : 3;
|
||||||
|
uint16_t m_reserved : 9;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Packed stencil op
|
||||||
|
*
|
||||||
|
* Stores various stencil op parameters
|
||||||
|
* for one single face in four bytes.
|
||||||
|
*/
|
||||||
|
class DxvkDsStencilOp {
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
DxvkDsStencilOp() = default;
|
||||||
|
|
||||||
|
DxvkDsStencilOp(VkStencilOpState state)
|
||||||
|
: m_failOp (uint32_t(state.failOp)),
|
||||||
|
m_passOp (uint32_t(state.passOp)),
|
||||||
|
m_depthFailOp (uint32_t(state.depthFailOp)),
|
||||||
|
m_compareOp (uint32_t(state.compareOp)),
|
||||||
|
m_reserved (0),
|
||||||
|
m_compareMask (uint32_t(state.compareMask)),
|
||||||
|
m_writeMask (uint32_t(state.writeMask)) { }
|
||||||
|
|
||||||
|
VkStencilOpState state() const {
|
||||||
|
VkStencilOpState result;
|
||||||
|
result.failOp = VkStencilOp(m_failOp);
|
||||||
|
result.passOp = VkStencilOp(m_passOp);
|
||||||
|
result.depthFailOp = VkStencilOp(m_depthFailOp);
|
||||||
|
result.compareOp = VkCompareOp(m_compareOp);
|
||||||
|
result.compareMask = m_compareMask;
|
||||||
|
result.writeMask = m_writeMask;
|
||||||
|
result.reference = 0;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
uint32_t m_failOp : 3;
|
||||||
|
uint32_t m_passOp : 3;
|
||||||
|
uint32_t m_depthFailOp : 3;
|
||||||
|
uint32_t m_compareOp : 3;
|
||||||
|
uint32_t m_reserved : 4;
|
||||||
|
uint32_t m_compareMask : 8;
|
||||||
|
uint32_t m_writeMask : 8;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Packed graphics pipeline state
|
* \brief Packed graphics pipeline state
|
||||||
*
|
*
|
||||||
@ -359,7 +466,7 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool useDynamicStencilRef() const {
|
bool useDynamicStencilRef() const {
|
||||||
return dsEnableStencilTest;
|
return ds.enableStencilTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool useDynamicDepthBias() const {
|
bool useDynamicDepthBias() const {
|
||||||
@ -367,7 +474,7 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool useDynamicDepthBounds() const {
|
bool useDynamicDepthBounds() const {
|
||||||
return dsEnableDepthBoundsTest;
|
return ds.enableDepthBoundsTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool useDynamicBlendConstants() const {
|
bool useDynamicBlendConstants() const {
|
||||||
@ -389,14 +496,7 @@ namespace dxvk {
|
|||||||
DxvkIlInfo il;
|
DxvkIlInfo il;
|
||||||
DxvkRsInfo rs;
|
DxvkRsInfo rs;
|
||||||
DxvkMsInfo ms;
|
DxvkMsInfo ms;
|
||||||
|
DxvkDsInfo ds;
|
||||||
VkBool32 dsEnableDepthTest;
|
|
||||||
VkBool32 dsEnableDepthWrite;
|
|
||||||
VkBool32 dsEnableDepthBoundsTest;
|
|
||||||
VkBool32 dsEnableStencilTest;
|
|
||||||
VkCompareOp dsDepthCompareOp;
|
|
||||||
VkStencilOpState dsStencilOpFront;
|
|
||||||
VkStencilOpState dsStencilOpBack;
|
|
||||||
|
|
||||||
VkBool32 omEnableLogicOp;
|
VkBool32 omEnableLogicOp;
|
||||||
VkLogicOp omLogicOp;
|
VkLogicOp omLogicOp;
|
||||||
@ -405,6 +505,8 @@ namespace dxvk {
|
|||||||
|
|
||||||
uint32_t scSpecConstants[MaxNumSpecConstants];
|
uint32_t scSpecConstants[MaxNumSpecConstants];
|
||||||
|
|
||||||
|
DxvkDsStencilOp dsFront;
|
||||||
|
DxvkDsStencilOp dsBack;
|
||||||
DxvkIlAttribute ilAttributes [DxvkLimits::MaxNumVertexAttributes];
|
DxvkIlAttribute ilAttributes [DxvkLimits::MaxNumVertexAttributes];
|
||||||
DxvkIlBinding ilBindings [DxvkLimits::MaxNumVertexBindings];
|
DxvkIlBinding ilBindings [DxvkLimits::MaxNumVertexBindings];
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user