1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-04 16:24:29 +01:00

[dxvk] Expose depth bias representation/exact controls

This commit is contained in:
Joshua Ashton 2023-06-15 12:38:36 +01:00 committed by Joshie
parent 5fbb0dd4ba
commit 4e9853f608
5 changed files with 78 additions and 19 deletions

View File

@ -824,6 +824,12 @@ namespace dxvk {
} }
void cmdSetDepthBias2(
const VkDepthBiasInfoEXT *depthBiasInfo) {
m_vkd->vkCmdSetDepthBias2EXT(m_cmd.execBuffer, depthBiasInfo);
}
void cmdSetDepthBounds( void cmdSetDepthBounds(
float minDepthBounds, float minDepthBounds,
float maxDepthBounds) { float maxDepthBounds) {

View File

@ -29,26 +29,47 @@ namespace dxvk {
}; };
/**
* \brief Depth bias representation
*
* Stores depth bias representation info.
*/
struct DxvkDepthBiasRepresentation {
VkDepthBiasRepresentationEXT depthBiasRepresentation;
VkBool32 depthBiasExact;
bool operator == (const DxvkDepthBiasRepresentation& other) const {
return depthBiasRepresentation == other.depthBiasRepresentation
&& depthBiasExact == other.depthBiasExact;
}
bool operator != (const DxvkDepthBiasRepresentation& other) const {
return depthBiasRepresentation != other.depthBiasRepresentation
|| depthBiasExact != other.depthBiasExact;
}
};
/** /**
* \brief Depth bias * \brief Depth bias
* *
* Stores depth bias values. * Stores depth bias values.
*/ */
struct DxvkDepthBias { struct DxvkDepthBias {
float depthBiasConstant; float depthBiasConstant;
float depthBiasSlope; float depthBiasSlope;
float depthBiasClamp; float depthBiasClamp;
bool operator == (const DxvkDepthBias& other) const { bool operator == (const DxvkDepthBias& other) const {
return depthBiasConstant == other.depthBiasConstant return depthBiasConstant == other.depthBiasConstant
&& depthBiasSlope == other.depthBiasSlope && depthBiasSlope == other.depthBiasSlope
&& depthBiasClamp == other.depthBiasClamp; && depthBiasClamp == other.depthBiasClamp;
} }
bool operator != (const DxvkDepthBias& other) const { bool operator != (const DxvkDepthBias& other) const {
return depthBiasConstant != other.depthBiasConstant return depthBiasConstant != other.depthBiasConstant
|| depthBiasSlope != other.depthBiasSlope || depthBiasSlope != other.depthBiasSlope
|| depthBiasClamp != other.depthBiasClamp; || depthBiasClamp != other.depthBiasClamp;
} }
}; };

View File

@ -2442,6 +2442,15 @@ namespace dxvk {
} }
void DxvkContext::setDepthBiasRepresentation(
DxvkDepthBiasRepresentation depthBiasRepresentation) {
if (m_state.dyn.depthBiasRepresentation != depthBiasRepresentation) {
m_state.dyn.depthBiasRepresentation = depthBiasRepresentation;
m_flags.set(DxvkContextFlag::GpDirtyDepthBias);
}
}
void DxvkContext::setDepthBounds( void DxvkContext::setDepthBounds(
DxvkDepthBounds depthBounds) { DxvkDepthBounds depthBounds) {
if (m_state.dyn.depthBounds != depthBounds) { if (m_state.dyn.depthBounds != depthBounds) {
@ -5784,10 +5793,24 @@ namespace dxvk {
DxvkContextFlag::GpDynamicDepthBias)) { DxvkContextFlag::GpDynamicDepthBias)) {
m_flags.clr(DxvkContextFlag::GpDirtyDepthBias); m_flags.clr(DxvkContextFlag::GpDirtyDepthBias);
m_cmd->cmdSetDepthBias( if (m_device->features().extDepthBiasControl.depthBiasControl) {
m_state.dyn.depthBias.depthBiasConstant, VkDepthBiasRepresentationInfoEXT depthBiasRepresentation = { VK_STRUCTURE_TYPE_DEPTH_BIAS_REPRESENTATION_INFO_EXT };
m_state.dyn.depthBias.depthBiasClamp, depthBiasRepresentation.depthBiasRepresentation = m_state.dyn.depthBiasRepresentation.depthBiasRepresentation;
m_state.dyn.depthBias.depthBiasSlope); depthBiasRepresentation.depthBiasExact = m_state.dyn.depthBiasRepresentation.depthBiasExact;
VkDepthBiasInfoEXT depthBiasInfo = { VK_STRUCTURE_TYPE_DEPTH_BIAS_INFO_EXT };
depthBiasInfo.pNext = &depthBiasRepresentation;
depthBiasInfo.depthBiasConstantFactor = m_state.dyn.depthBias.depthBiasConstant;
depthBiasInfo.depthBiasClamp = m_state.dyn.depthBias.depthBiasClamp;
depthBiasInfo.depthBiasSlopeFactor = m_state.dyn.depthBias.depthBiasSlope;
m_cmd->cmdSetDepthBias2(&depthBiasInfo);
} else {
m_cmd->cmdSetDepthBias(
m_state.dyn.depthBias.depthBiasConstant,
m_state.dyn.depthBias.depthBiasClamp,
m_state.dyn.depthBias.depthBiasSlope);
}
} }
if (m_flags.all(DxvkContextFlag::GpDirtyDepthBounds, if (m_flags.all(DxvkContextFlag::GpDirtyDepthBounds,

View File

@ -1141,6 +1141,14 @@ namespace dxvk {
*/ */
void setDepthBias( void setDepthBias(
DxvkDepthBias depthBias); DxvkDepthBias depthBias);
/**
* \brief Sets depth bias representation
*
* \param [in] depthBiasRepresentation Depth bias representation
*/
void setDepthBiasRepresentation(
DxvkDepthBiasRepresentation depthBiasRepresentation);
/** /**
* \brief Sets depth bounds * \brief Sets depth bounds

View File

@ -150,12 +150,13 @@ 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 }; DxvkDepthBiasRepresentation depthBiasRepresentation = { VK_DEPTH_BIAS_REPRESENTATION_LEAST_REPRESENTABLE_VALUE_FORMAT_EXT, false };
uint32_t stencilReference = 0; DxvkDepthBounds depthBounds = { false, 0.0f, 1.0f };
VkCullModeFlags cullMode = VK_CULL_MODE_BACK_BIT; uint32_t stencilReference = 0;
VkFrontFace frontFace = VK_FRONT_FACE_CLOCKWISE; VkCullModeFlags cullMode = VK_CULL_MODE_BACK_BIT;
VkFrontFace frontFace = VK_FRONT_FACE_CLOCKWISE;
}; };