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

[dxvk] Implement depth bounds test in backend

This commit is contained in:
Philip Rebohle 2019-04-24 22:39:51 +02:00
parent 5ad212d279
commit 8a3044a342
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
6 changed files with 79 additions and 2 deletions

View File

@ -672,6 +672,15 @@ namespace dxvk {
}
void cmdSetDepthBounds(
float minDepthBounds,
float maxDepthBounds) {
m_vkd->vkCmdSetDepthBounds(m_execBuffer,
minDepthBounds,
maxDepthBounds);
}
void cmdSetEvent(
VkEvent event,
VkPipelineStageFlags stages) {

View File

@ -51,6 +51,30 @@ namespace dxvk {
|| depthBiasClamp != other.depthBiasClamp;
}
};
/**
* \brief Depth bounds
*
* Stores depth bounds values.
*/
struct DxvkDepthBounds {
VkBool32 enableDepthBounds;
float minDepthBounds;
float maxDepthBounds;
bool operator == (const DxvkDepthBounds& other) const {
return enableDepthBounds == other.enableDepthBounds
&& minDepthBounds == other.minDepthBounds
&& maxDepthBounds == other.maxDepthBounds;
}
bool operator != (const DxvkDepthBounds& other) const {
return enableDepthBounds != other.enableDepthBounds
|| minDepthBounds != other.minDepthBounds
|| maxDepthBounds != other.maxDepthBounds;
}
};
/**

View File

@ -60,6 +60,7 @@ namespace dxvk {
DxvkContextFlag::GpDirtyStencilRef,
DxvkContextFlag::GpDirtyViewport,
DxvkContextFlag::GpDirtyDepthBias,
DxvkContextFlag::GpDirtyDepthBounds,
DxvkContextFlag::CpDirtyPipeline,
DxvkContextFlag::CpDirtyPipelineState,
DxvkContextFlag::CpDirtyResources,
@ -2018,6 +2019,20 @@ namespace dxvk {
m_flags.set(DxvkContextFlag::GpDirtyDepthBias);
}
}
void DxvkContext::setDepthBounds(
DxvkDepthBounds depthBounds) {
if (m_state.dyn.depthBounds != depthBounds) {
m_state.dyn.depthBounds = depthBounds;
m_flags.set(DxvkContextFlag::GpDirtyDepthBounds);
}
if (m_state.gp.state.dsEnableDepthBoundsTest != depthBounds.enableDepthBounds) {
m_state.gp.state.dsEnableDepthBoundsTest = depthBounds.enableDepthBounds;
m_flags.set(DxvkContextFlag::GpDirtyPipelineState);
}
}
void DxvkContext::setStencilReference(
@ -3250,6 +3265,7 @@ namespace dxvk {
DxvkContextFlag::GpDirtyStencilRef,
DxvkContextFlag::GpDirtyViewport,
DxvkContextFlag::GpDirtyDepthBias,
DxvkContextFlag::GpDirtyDepthBounds,
DxvkContextFlag::GpDirtyPredicate);
m_gpActivePipeline = VK_NULL_HANDLE;
@ -3298,6 +3314,7 @@ namespace dxvk {
// are not dynamic will be invalidated in the command buffer.
m_flags.clr(DxvkContextFlag::GpDynamicBlendConstants,
DxvkContextFlag::GpDynamicDepthBias,
DxvkContextFlag::GpDynamicDepthBounds,
DxvkContextFlag::GpDynamicStencilRef);
m_flags.set(m_state.gp.state.useDynamicBlendConstants()
@ -3308,6 +3325,10 @@ namespace dxvk {
? DxvkContextFlag::GpDynamicDepthBias
: DxvkContextFlag::GpDirtyDepthBias);
m_flags.set(m_state.gp.state.useDynamicDepthBounds()
? DxvkContextFlag::GpDynamicDepthBounds
: DxvkContextFlag::GpDirtyDepthBounds);
m_flags.set(m_state.gp.state.useDynamicStencilRef()
? DxvkContextFlag::GpDynamicStencilRef
: DxvkContextFlag::GpDirtyStencilRef);
@ -3780,6 +3801,15 @@ namespace dxvk {
m_state.dyn.depthBias.depthBiasClamp,
m_state.dyn.depthBias.depthBiasSlope);
}
if (m_flags.all(DxvkContextFlag::GpDirtyDepthBounds,
DxvkContextFlag::GpDynamicDepthBounds)) {
m_flags.clr(DxvkContextFlag::GpDirtyDepthBounds);
m_cmd->cmdSetDepthBounds(
m_state.dyn.depthBounds.minDepthBounds,
m_state.dyn.depthBounds.maxDepthBounds);
}
}
@ -3858,7 +3888,8 @@ namespace dxvk {
DxvkContextFlag::GpDirtyViewport,
DxvkContextFlag::GpDirtyBlendConstants,
DxvkContextFlag::GpDirtyStencilRef,
DxvkContextFlag::GpDirtyDepthBias))
DxvkContextFlag::GpDirtyDepthBias,
DxvkContextFlag::GpDirtyDepthBounds))
this->updateDynamicState();
}

View File

@ -778,6 +778,16 @@ namespace dxvk {
void setDepthBias(
DxvkDepthBias depthBias);
/**
* \brief Sets depth bounds
*
* Enables or disables the depth bounds test,
* and updates the values if necessary.
* \param [in] depthBounds Depth bounds
*/
void setDepthBounds(
DxvkDepthBounds depthBounds);
/**
* \brief Sets stencil reference
*

View File

@ -37,11 +37,13 @@ namespace dxvk {
GpDirtyXfbCounters, ///< Counter buffer values are dirty
GpDirtyBlendConstants, ///< Blend constants have changed
GpDirtyDepthBias, ///< Depth bias has changed
GpDirtyDepthBounds, ///< Depth bounds have changed
GpDirtyStencilRef, ///< Stencil reference has changed
GpDirtyViewport, ///< Viewport state has changed
GpDirtyPredicate, ///< Predicate has changed
GpDynamicBlendConstants, ///< Blend constants are dynamic
GpDynamicDepthBias, ///< Depth bias is dynamic
GpDynamicDepthBounds, ///< Depth bounds are dynamic
GpDynamicStencilRef, ///< Stencil reference is dynamic
CpDirtyPipeline, ///< Compute pipeline binding are out of date
@ -135,6 +137,7 @@ namespace dxvk {
struct DxvkDynamicState {
DxvkBlendConstants blendConstants = { 0.0f, 0.0f, 0.0f, 0.0f };
DxvkDepthBias depthBias = { 0.0f, 0.0f, 0.0f };
DxvkDepthBounds depthBounds = { false, 0.0f, 1.0f };
uint32_t stencilReference = 0;
};

View File

@ -357,7 +357,7 @@ namespace dxvk {
dsInfo.depthTestEnable = state.dsEnableDepthTest;
dsInfo.depthWriteEnable = state.dsEnableDepthWrite && !util::isDepthReadOnlyLayout(passFormat.depth.layout);
dsInfo.depthCompareOp = state.dsDepthCompareOp;
dsInfo.depthBoundsTestEnable = VK_FALSE;
dsInfo.depthBoundsTestEnable = state.dsEnableDepthBoundsTest;
dsInfo.stencilTestEnable = state.dsEnableStencilTest;
dsInfo.front = state.dsStencilOpFront;
dsInfo.back = state.dsStencilOpBack;