mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +01:00
[dxvk] Implement depth bounds test in backend
This commit is contained in:
parent
5ad212d279
commit
8a3044a342
@ -672,6 +672,15 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void cmdSetDepthBounds(
|
||||||
|
float minDepthBounds,
|
||||||
|
float maxDepthBounds) {
|
||||||
|
m_vkd->vkCmdSetDepthBounds(m_execBuffer,
|
||||||
|
minDepthBounds,
|
||||||
|
maxDepthBounds);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void cmdSetEvent(
|
void cmdSetEvent(
|
||||||
VkEvent event,
|
VkEvent event,
|
||||||
VkPipelineStageFlags stages) {
|
VkPipelineStageFlags stages) {
|
||||||
|
@ -51,6 +51,30 @@ namespace dxvk {
|
|||||||
|| depthBiasClamp != other.depthBiasClamp;
|
|| 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;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,6 +60,7 @@ namespace dxvk {
|
|||||||
DxvkContextFlag::GpDirtyStencilRef,
|
DxvkContextFlag::GpDirtyStencilRef,
|
||||||
DxvkContextFlag::GpDirtyViewport,
|
DxvkContextFlag::GpDirtyViewport,
|
||||||
DxvkContextFlag::GpDirtyDepthBias,
|
DxvkContextFlag::GpDirtyDepthBias,
|
||||||
|
DxvkContextFlag::GpDirtyDepthBounds,
|
||||||
DxvkContextFlag::CpDirtyPipeline,
|
DxvkContextFlag::CpDirtyPipeline,
|
||||||
DxvkContextFlag::CpDirtyPipelineState,
|
DxvkContextFlag::CpDirtyPipelineState,
|
||||||
DxvkContextFlag::CpDirtyResources,
|
DxvkContextFlag::CpDirtyResources,
|
||||||
@ -2018,6 +2019,20 @@ namespace dxvk {
|
|||||||
m_flags.set(DxvkContextFlag::GpDirtyDepthBias);
|
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(
|
void DxvkContext::setStencilReference(
|
||||||
@ -3250,6 +3265,7 @@ namespace dxvk {
|
|||||||
DxvkContextFlag::GpDirtyStencilRef,
|
DxvkContextFlag::GpDirtyStencilRef,
|
||||||
DxvkContextFlag::GpDirtyViewport,
|
DxvkContextFlag::GpDirtyViewport,
|
||||||
DxvkContextFlag::GpDirtyDepthBias,
|
DxvkContextFlag::GpDirtyDepthBias,
|
||||||
|
DxvkContextFlag::GpDirtyDepthBounds,
|
||||||
DxvkContextFlag::GpDirtyPredicate);
|
DxvkContextFlag::GpDirtyPredicate);
|
||||||
|
|
||||||
m_gpActivePipeline = VK_NULL_HANDLE;
|
m_gpActivePipeline = VK_NULL_HANDLE;
|
||||||
@ -3298,6 +3314,7 @@ namespace dxvk {
|
|||||||
// are not dynamic will be invalidated in the command buffer.
|
// are not dynamic will be invalidated in the command buffer.
|
||||||
m_flags.clr(DxvkContextFlag::GpDynamicBlendConstants,
|
m_flags.clr(DxvkContextFlag::GpDynamicBlendConstants,
|
||||||
DxvkContextFlag::GpDynamicDepthBias,
|
DxvkContextFlag::GpDynamicDepthBias,
|
||||||
|
DxvkContextFlag::GpDynamicDepthBounds,
|
||||||
DxvkContextFlag::GpDynamicStencilRef);
|
DxvkContextFlag::GpDynamicStencilRef);
|
||||||
|
|
||||||
m_flags.set(m_state.gp.state.useDynamicBlendConstants()
|
m_flags.set(m_state.gp.state.useDynamicBlendConstants()
|
||||||
@ -3308,6 +3325,10 @@ namespace dxvk {
|
|||||||
? DxvkContextFlag::GpDynamicDepthBias
|
? DxvkContextFlag::GpDynamicDepthBias
|
||||||
: DxvkContextFlag::GpDirtyDepthBias);
|
: DxvkContextFlag::GpDirtyDepthBias);
|
||||||
|
|
||||||
|
m_flags.set(m_state.gp.state.useDynamicDepthBounds()
|
||||||
|
? DxvkContextFlag::GpDynamicDepthBounds
|
||||||
|
: DxvkContextFlag::GpDirtyDepthBounds);
|
||||||
|
|
||||||
m_flags.set(m_state.gp.state.useDynamicStencilRef()
|
m_flags.set(m_state.gp.state.useDynamicStencilRef()
|
||||||
? DxvkContextFlag::GpDynamicStencilRef
|
? DxvkContextFlag::GpDynamicStencilRef
|
||||||
: DxvkContextFlag::GpDirtyStencilRef);
|
: DxvkContextFlag::GpDirtyStencilRef);
|
||||||
@ -3780,6 +3801,15 @@ namespace dxvk {
|
|||||||
m_state.dyn.depthBias.depthBiasClamp,
|
m_state.dyn.depthBias.depthBiasClamp,
|
||||||
m_state.dyn.depthBias.depthBiasSlope);
|
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::GpDirtyViewport,
|
||||||
DxvkContextFlag::GpDirtyBlendConstants,
|
DxvkContextFlag::GpDirtyBlendConstants,
|
||||||
DxvkContextFlag::GpDirtyStencilRef,
|
DxvkContextFlag::GpDirtyStencilRef,
|
||||||
DxvkContextFlag::GpDirtyDepthBias))
|
DxvkContextFlag::GpDirtyDepthBias,
|
||||||
|
DxvkContextFlag::GpDirtyDepthBounds))
|
||||||
this->updateDynamicState();
|
this->updateDynamicState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -778,6 +778,16 @@ namespace dxvk {
|
|||||||
void setDepthBias(
|
void setDepthBias(
|
||||||
DxvkDepthBias depthBias);
|
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
|
* \brief Sets stencil reference
|
||||||
*
|
*
|
||||||
|
@ -37,11 +37,13 @@ namespace dxvk {
|
|||||||
GpDirtyXfbCounters, ///< Counter buffer values are dirty
|
GpDirtyXfbCounters, ///< Counter buffer values are dirty
|
||||||
GpDirtyBlendConstants, ///< Blend constants have changed
|
GpDirtyBlendConstants, ///< Blend constants have changed
|
||||||
GpDirtyDepthBias, ///< Depth bias has changed
|
GpDirtyDepthBias, ///< Depth bias has changed
|
||||||
|
GpDirtyDepthBounds, ///< Depth bounds have changed
|
||||||
GpDirtyStencilRef, ///< Stencil reference has changed
|
GpDirtyStencilRef, ///< Stencil reference has changed
|
||||||
GpDirtyViewport, ///< Viewport state has changed
|
GpDirtyViewport, ///< Viewport state has changed
|
||||||
GpDirtyPredicate, ///< Predicate has changed
|
GpDirtyPredicate, ///< Predicate has changed
|
||||||
GpDynamicBlendConstants, ///< Blend constants are dynamic
|
GpDynamicBlendConstants, ///< Blend constants are dynamic
|
||||||
GpDynamicDepthBias, ///< Depth bias is dynamic
|
GpDynamicDepthBias, ///< Depth bias is dynamic
|
||||||
|
GpDynamicDepthBounds, ///< Depth bounds are dynamic
|
||||||
GpDynamicStencilRef, ///< Stencil reference is dynamic
|
GpDynamicStencilRef, ///< Stencil reference is dynamic
|
||||||
|
|
||||||
CpDirtyPipeline, ///< Compute pipeline binding are out of date
|
CpDirtyPipeline, ///< Compute pipeline binding are out of date
|
||||||
@ -135,6 +137,7 @@ namespace dxvk {
|
|||||||
struct DxvkDynamicState {
|
struct DxvkDynamicState {
|
||||||
DxvkBlendConstants blendConstants = { 0.0f, 0.0f, 0.0f, 0.0f };
|
DxvkBlendConstants blendConstants = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||||
DxvkDepthBias depthBias = { 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;
|
uint32_t stencilReference = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -357,7 +357,7 @@ namespace dxvk {
|
|||||||
dsInfo.depthTestEnable = state.dsEnableDepthTest;
|
dsInfo.depthTestEnable = state.dsEnableDepthTest;
|
||||||
dsInfo.depthWriteEnable = state.dsEnableDepthWrite && !util::isDepthReadOnlyLayout(passFormat.depth.layout);
|
dsInfo.depthWriteEnable = state.dsEnableDepthWrite && !util::isDepthReadOnlyLayout(passFormat.depth.layout);
|
||||||
dsInfo.depthCompareOp = state.dsDepthCompareOp;
|
dsInfo.depthCompareOp = state.dsDepthCompareOp;
|
||||||
dsInfo.depthBoundsTestEnable = VK_FALSE;
|
dsInfo.depthBoundsTestEnable = state.dsEnableDepthBoundsTest;
|
||||||
dsInfo.stencilTestEnable = state.dsEnableStencilTest;
|
dsInfo.stencilTestEnable = state.dsEnableStencilTest;
|
||||||
dsInfo.front = state.dsStencilOpFront;
|
dsInfo.front = state.dsStencilOpFront;
|
||||||
dsInfo.back = state.dsStencilOpBack;
|
dsInfo.back = state.dsStencilOpBack;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user