anv: Implement VK_EXT_conservative_rasterization
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4480 Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9960>
This commit is contained in:
parent
bbb00f739c
commit
d5b56debde
|
@ -258,6 +258,7 @@ get_device_extensions(const struct anv_physical_device *device,
|
|||
.EXT_calibrated_timestamps = device->has_reg_timestamp,
|
||||
.EXT_conditional_rendering = device->info.gen >= 8 ||
|
||||
device->info.is_haswell,
|
||||
.EXT_conservative_rasterization = device->info.gen >= 9,
|
||||
.EXT_custom_border_color = device->info.gen >= 8,
|
||||
.EXT_depth_clip_enable = true,
|
||||
.EXT_descriptor_indexing = device->has_a64_buffer_access &&
|
||||
|
@ -2120,6 +2121,33 @@ void anv_GetPhysicalDeviceProperties2(
|
|||
|
||||
vk_foreach_struct(ext, pProperties->pNext) {
|
||||
switch (ext->sType) {
|
||||
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CONSERVATIVE_RASTERIZATION_PROPERTIES_EXT: {
|
||||
/* TODO: Real limits */
|
||||
VkPhysicalDeviceConservativeRasterizationPropertiesEXT *properties =
|
||||
(VkPhysicalDeviceConservativeRasterizationPropertiesEXT *)ext;
|
||||
/* There's nothing in the public docs about this value as far as I
|
||||
* can tell. However, this is the value the Windows driver reports
|
||||
* and there's a comment on a rejected HW feature in the internal
|
||||
* docs that says:
|
||||
*
|
||||
* "This is similar to conservative rasterization, except the
|
||||
* primitive area is not extended by 1/512 and..."
|
||||
*
|
||||
* That's a bit of an obtuse reference but it's the best we've got
|
||||
* for now.
|
||||
*/
|
||||
properties->primitiveOverestimationSize = 1.0f / 512.0f;
|
||||
properties->maxExtraPrimitiveOverestimationSize = 0.0f;
|
||||
properties->extraPrimitiveOverestimationSizeGranularity = 0.0f;
|
||||
properties->primitiveUnderestimation = false;
|
||||
properties->conservativePointAndLineRasterization = false;
|
||||
properties->degenerateTrianglesRasterized = true;
|
||||
properties->degenerateLinesRasterized = false;
|
||||
properties->fullyCoveredFragmentShaderInputVariable = false;
|
||||
properties->conservativeRasterizationPostDepthCoverage = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CUSTOM_BORDER_COLOR_PROPERTIES_EXT: {
|
||||
VkPhysicalDeviceCustomBorderColorPropertiesEXT *properties =
|
||||
(VkPhysicalDeviceCustomBorderColorPropertiesEXT *)ext;
|
||||
|
|
|
@ -576,6 +576,18 @@ const uint32_t genX(vk_to_gen_front_face)[] = {
|
|||
[VK_FRONT_FACE_CLOCKWISE] = 0
|
||||
};
|
||||
|
||||
#if GEN_GEN >= 9
|
||||
static VkConservativeRasterizationModeEXT
|
||||
vk_conservative_rasterization_mode(const VkPipelineRasterizationStateCreateInfo *rs_info)
|
||||
{
|
||||
const VkPipelineRasterizationConservativeStateCreateInfoEXT *cr =
|
||||
vk_find_struct_const(rs_info, PIPELINE_RASTERIZATION_CONSERVATIVE_STATE_CREATE_INFO_EXT);
|
||||
|
||||
return cr ? cr->conservativeRasterizationMode :
|
||||
VK_CONSERVATIVE_RASTERIZATION_MODE_DISABLED_EXT;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
emit_rs_state(struct anv_graphics_pipeline *pipeline,
|
||||
const VkPipelineInputAssemblyStateCreateInfo *ia_info,
|
||||
|
@ -700,6 +712,12 @@ emit_rs_state(struct anv_graphics_pipeline *pipeline,
|
|||
raster.ViewportZClipTestEnable = pipeline->depth_clip_enable;
|
||||
#endif
|
||||
|
||||
#if GEN_GEN >= 9
|
||||
raster.ConservativeRasterizationEnable =
|
||||
vk_conservative_rasterization_mode(rs_info) !=
|
||||
VK_CONSERVATIVE_RASTERIZATION_MODE_DISABLED_EXT;
|
||||
#endif
|
||||
|
||||
raster.GlobalDepthOffsetEnableSolid = rs_info->depthBiasEnable;
|
||||
raster.GlobalDepthOffsetEnableWireframe = rs_info->depthBiasEnable;
|
||||
raster.GlobalDepthOffsetEnablePoint = rs_info->depthBiasEnable;
|
||||
|
@ -2089,7 +2107,8 @@ emit_3dstate_ps(struct anv_graphics_pipeline *pipeline,
|
|||
#if GEN_GEN >= 8
|
||||
static void
|
||||
emit_3dstate_ps_extra(struct anv_graphics_pipeline *pipeline,
|
||||
struct anv_subpass *subpass)
|
||||
struct anv_subpass *subpass,
|
||||
const VkPipelineRasterizationStateCreateInfo *rs_info)
|
||||
{
|
||||
const struct brw_wm_prog_data *wm_prog_data = get_wm_prog_data(pipeline);
|
||||
|
||||
|
@ -2121,12 +2140,16 @@ emit_3dstate_ps_extra(struct anv_graphics_pipeline *pipeline,
|
|||
ps.PixelShaderPullsBary = wm_prog_data->pulls_bary;
|
||||
|
||||
ps.InputCoverageMaskState = ICMS_NONE;
|
||||
if (wm_prog_data->uses_sample_mask) {
|
||||
if (wm_prog_data->post_depth_coverage)
|
||||
ps.InputCoverageMaskState = ICMS_DEPTH_COVERAGE;
|
||||
else
|
||||
ps.InputCoverageMaskState = ICMS_INNER_CONSERVATIVE;
|
||||
}
|
||||
if (!wm_prog_data->uses_sample_mask)
|
||||
ps.InputCoverageMaskState = ICMS_NONE;
|
||||
else if (wm_prog_data->post_depth_coverage)
|
||||
ps.InputCoverageMaskState = ICMS_DEPTH_COVERAGE;
|
||||
else if (wm_prog_data->inner_coverage &&
|
||||
vk_conservative_rasterization_mode(rs_info) !=
|
||||
VK_CONSERVATIVE_RASTERIZATION_MODE_DISABLED_EXT)
|
||||
ps.InputCoverageMaskState = ICMS_INNER_CONSERVATIVE;
|
||||
else
|
||||
ps.InputCoverageMaskState = ICMS_INNER_CONSERVATIVE;
|
||||
#else
|
||||
ps.PixelShaderUsesInputCoverageMask = wm_prog_data->uses_sample_mask;
|
||||
#endif
|
||||
|
@ -2329,7 +2352,8 @@ genX(graphics_pipeline_create)(
|
|||
cb_info, ms_info, line_info);
|
||||
emit_3dstate_ps(pipeline, cb_info, ms_info);
|
||||
#if GEN_GEN >= 8
|
||||
emit_3dstate_ps_extra(pipeline, subpass);
|
||||
emit_3dstate_ps_extra(pipeline, subpass,
|
||||
pCreateInfo->pRasterizationState);
|
||||
|
||||
if (!(dynamic_states & ANV_CMD_DIRTY_DYNAMIC_PRIMITIVE_TOPOLOGY))
|
||||
emit_3dstate_vf_topology(pipeline);
|
||||
|
|
Loading…
Reference in New Issue