vulkan/runtime: add support for EXT_depth_bias_control

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23716>
This commit is contained in:
Lionel Landwerlin 2023-06-06 07:55:05 +03:00 committed by Marge Bot
parent 6249ff17ca
commit f39fa39809
2 changed files with 77 additions and 0 deletions

View file

@ -513,6 +513,8 @@ vk_rasterization_state_init(struct vk_rasterization_state *rs,
.provoking_vertex = VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT,
.line.mode = VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT,
.depth_clip_enable = IS_DYNAMIC(RS_DEPTH_CLAMP_ENABLE) ? VK_MESA_DEPTH_CLIP_ENABLE_NOT_CLAMP : VK_MESA_DEPTH_CLIP_ENABLE_FALSE,
.depth_bias.representation = VK_DEPTH_BIAS_REPRESENTATION_LEAST_REPRESENTABLE_VALUE_FORMAT_EXT,
.depth_bias.exact = false,
};
if (!rs_info)
return;
@ -604,6 +606,16 @@ vk_rasterization_state_init(struct vk_rasterization_state *rs,
break;
}
case VK_STRUCTURE_TYPE_DEPTH_BIAS_REPRESENTATION_INFO_EXT: {
const VkDepthBiasRepresentationInfoEXT *dbr_info =
(const VkDepthBiasRepresentationInfoEXT *)ext;
if (!IS_DYNAMIC(RS_DEPTH_BIAS_FACTORS)) {
rs->depth_bias.representation = dbr_info->depthBiasRepresentation;
rs->depth_bias.exact = dbr_info->depthBiasExact;
}
break;
}
default:
break;
}
@ -1770,6 +1782,8 @@ vk_dynamic_graphics_state_copy(struct vk_dynamic_graphics_state *dst,
COPY_IF_SET(RS_DEPTH_BIAS_FACTORS, rs.depth_bias.constant);
COPY_IF_SET(RS_DEPTH_BIAS_FACTORS, rs.depth_bias.clamp);
COPY_IF_SET(RS_DEPTH_BIAS_FACTORS, rs.depth_bias.slope);
COPY_IF_SET(RS_DEPTH_BIAS_FACTORS, rs.depth_bias.representation);
COPY_IF_SET(RS_DEPTH_BIAS_FACTORS, rs.depth_bias.exact);
COPY_IF_SET(RS_LINE_WIDTH, rs.line.width);
COPY_IF_SET(RS_LINE_MODE, rs.line.mode);
COPY_IF_SET(RS_LINE_STIPPLE_ENABLE, rs.line.stipple.enable);
@ -2204,6 +2218,18 @@ vk_common_CmdSetDepthBias(VkCommandBuffer commandBuffer,
rs.depth_bias.clamp, depthBiasClamp);
SET_DYN_VALUE(dyn, RS_DEPTH_BIAS_FACTORS,
rs.depth_bias.slope, depthBiasSlopeFactor);
/** From the Vulkan 1.3.254 spec:
*
* "Calling this function is equivalent to calling vkCmdSetDepthBias2EXT
* without a VkDepthBiasRepresentationInfoEXT in the pNext chain of
* VkDepthBiasInfoEXT."
*/
SET_DYN_VALUE(dyn, RS_DEPTH_BIAS_FACTORS,
rs.depth_bias.representation,
VK_DEPTH_BIAS_REPRESENTATION_LEAST_REPRESENTABLE_VALUE_FORMAT_EXT);
SET_DYN_VALUE(dyn, RS_DEPTH_BIAS_FACTORS,
rs.depth_bias.exact, false);
}
VKAPI_ATTR void VKAPI_CALL
@ -2668,3 +2694,42 @@ vk_common_CmdSetDiscardRectangleModeEXT(VkCommandBuffer commandBuffer,
SET_DYN_VALUE(dyn, DR_MODE, dr.mode, discardRectangleMode);
}
VKAPI_ATTR void VKAPI_CALL
vk_common_CmdSetDepthBias2EXT(
VkCommandBuffer commandBuffer,
const VkDepthBiasInfoEXT* pDepthBiasInfo)
{
VK_FROM_HANDLE(vk_command_buffer, cmd, commandBuffer);
struct vk_dynamic_graphics_state *dyn = &cmd->dynamic_graphics_state;
SET_DYN_VALUE(dyn, RS_DEPTH_BIAS_FACTORS,
rs.depth_bias.constant, pDepthBiasInfo->depthBiasConstantFactor);
SET_DYN_VALUE(dyn, RS_DEPTH_BIAS_FACTORS,
rs.depth_bias.clamp, pDepthBiasInfo->depthBiasClamp);
SET_DYN_VALUE(dyn, RS_DEPTH_BIAS_FACTORS,
rs.depth_bias.slope, pDepthBiasInfo->depthBiasSlopeFactor);
/** From the Vulkan 1.3.254 spec:
*
* "If pNext does not contain a VkDepthBiasRepresentationInfoEXT
* structure, then this command is equivalent to including a
* VkDepthBiasRepresentationInfoEXT with depthBiasExact set to VK_FALSE
* and depthBiasRepresentation set to
* VK_DEPTH_BIAS_REPRESENTATION_LEAST_REPRESENTABLE_VALUE_FORMAT_EXT."
*/
const VkDepthBiasRepresentationInfoEXT *dbr_info =
vk_find_struct_const(pDepthBiasInfo->pNext, DEPTH_BIAS_REPRESENTATION_INFO_EXT);
if (dbr_info) {
SET_DYN_VALUE(dyn, RS_DEPTH_BIAS_FACTORS,
rs.depth_bias.representation, dbr_info->depthBiasRepresentation);
SET_DYN_VALUE(dyn, RS_DEPTH_BIAS_FACTORS,
rs.depth_bias.exact, dbr_info->depthBiasExact);
} else {
SET_DYN_VALUE(dyn, RS_DEPTH_BIAS_FACTORS,
rs.depth_bias.representation,
VK_DEPTH_BIAS_REPRESENTATION_LEAST_REPRESENTABLE_VALUE_FORMAT_EXT);
SET_DYN_VALUE(dyn, RS_DEPTH_BIAS_FACTORS,
rs.depth_bias.exact, false);
}
}

View file

@ -320,6 +320,18 @@ struct vk_rasterization_state {
* MESA_VK_DYNAMIC_RS_DEPTH_BIAS_FACTORS
*/
float slope;
/** VkDepthBiasRepresentationInfoEXT::depthBiasRepresentation
*
* MESA_VK_DYNAMIC_RS_DEPTH_BIAS_FACTORS
*/
VkDepthBiasRepresentationEXT representation;
/** VkDepthBiasRepresentationInfoEXT::depthBiasExact
*
* MESA_VK_DYNAMIC_RS_DEPTH_BIAS_FACTORS
*/
bool exact;
} depth_bias;
struct {