mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-12 13:08:50 +01:00
[dxvk] Expose depth bias representation/exact controls
This commit is contained in:
parent
5fbb0dd4ba
commit
4e9853f608
@ -824,6 +824,12 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
void cmdSetDepthBias2(
|
||||
const VkDepthBiasInfoEXT *depthBiasInfo) {
|
||||
m_vkd->vkCmdSetDepthBias2EXT(m_cmd.execBuffer, depthBiasInfo);
|
||||
}
|
||||
|
||||
|
||||
void cmdSetDepthBounds(
|
||||
float minDepthBounds,
|
||||
float maxDepthBounds) {
|
||||
|
@ -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
|
||||
*
|
||||
* Stores depth bias values.
|
||||
*/
|
||||
struct DxvkDepthBias {
|
||||
float depthBiasConstant;
|
||||
float depthBiasSlope;
|
||||
float depthBiasClamp;
|
||||
float depthBiasConstant;
|
||||
float depthBiasSlope;
|
||||
float depthBiasClamp;
|
||||
|
||||
bool operator == (const DxvkDepthBias& other) const {
|
||||
return depthBiasConstant == other.depthBiasConstant
|
||||
&& depthBiasSlope == other.depthBiasSlope
|
||||
&& depthBiasClamp == other.depthBiasClamp;
|
||||
return depthBiasConstant == other.depthBiasConstant
|
||||
&& depthBiasSlope == other.depthBiasSlope
|
||||
&& depthBiasClamp == other.depthBiasClamp;
|
||||
}
|
||||
|
||||
bool operator != (const DxvkDepthBias& other) const {
|
||||
return depthBiasConstant != other.depthBiasConstant
|
||||
|| depthBiasSlope != other.depthBiasSlope
|
||||
|| depthBiasClamp != other.depthBiasClamp;
|
||||
return depthBiasConstant != other.depthBiasConstant
|
||||
|| depthBiasSlope != other.depthBiasSlope
|
||||
|| depthBiasClamp != other.depthBiasClamp;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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(
|
||||
DxvkDepthBounds depthBounds) {
|
||||
if (m_state.dyn.depthBounds != depthBounds) {
|
||||
@ -5784,10 +5793,24 @@ namespace dxvk {
|
||||
DxvkContextFlag::GpDynamicDepthBias)) {
|
||||
m_flags.clr(DxvkContextFlag::GpDirtyDepthBias);
|
||||
|
||||
m_cmd->cmdSetDepthBias(
|
||||
m_state.dyn.depthBias.depthBiasConstant,
|
||||
m_state.dyn.depthBias.depthBiasClamp,
|
||||
m_state.dyn.depthBias.depthBiasSlope);
|
||||
if (m_device->features().extDepthBiasControl.depthBiasControl) {
|
||||
VkDepthBiasRepresentationInfoEXT depthBiasRepresentation = { VK_STRUCTURE_TYPE_DEPTH_BIAS_REPRESENTATION_INFO_EXT };
|
||||
depthBiasRepresentation.depthBiasRepresentation = m_state.dyn.depthBiasRepresentation.depthBiasRepresentation;
|
||||
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,
|
||||
|
@ -1141,6 +1141,14 @@ namespace dxvk {
|
||||
*/
|
||||
void setDepthBias(
|
||||
DxvkDepthBias depthBias);
|
||||
|
||||
/**
|
||||
* \brief Sets depth bias representation
|
||||
*
|
||||
* \param [in] depthBiasRepresentation Depth bias representation
|
||||
*/
|
||||
void setDepthBiasRepresentation(
|
||||
DxvkDepthBiasRepresentation depthBiasRepresentation);
|
||||
|
||||
/**
|
||||
* \brief Sets depth bounds
|
||||
|
@ -150,12 +150,13 @@ 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;
|
||||
VkCullModeFlags cullMode = VK_CULL_MODE_BACK_BIT;
|
||||
VkFrontFace frontFace = VK_FRONT_FACE_CLOCKWISE;
|
||||
DxvkBlendConstants blendConstants = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
DxvkDepthBias depthBias = { 0.0f, 0.0f, 0.0f };
|
||||
DxvkDepthBiasRepresentation depthBiasRepresentation = { VK_DEPTH_BIAS_REPRESENTATION_LEAST_REPRESENTABLE_VALUE_FORMAT_EXT, false };
|
||||
DxvkDepthBounds depthBounds = { false, 0.0f, 1.0f };
|
||||
uint32_t stencilReference = 0;
|
||||
VkCullModeFlags cullMode = VK_CULL_MODE_BACK_BIT;
|
||||
VkFrontFace frontFace = VK_FRONT_FACE_CLOCKWISE;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user