From 3508597aa1b88d1b5a6f78ad53d8abcc32cde2c9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Timur=20Krist=C3=B3f?= Date: Mon, 30 Jan 2023 15:23:12 +0100 Subject: [PATCH] radv: Disable NGG culling when conservative overestimation is used. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Even when small primitive culling is disabled, the face culling algorithm in ac_nir_cull can delete tiny triangles when their area is almost zero. Cc: mesa-stable Signed-off-by: Timur Kristóf Reviewed-by: Samuel Pitoiset Reviewed-by: Marek Olšák Part-of: --- src/amd/vulkan/radv_cmd_buffer.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c index 43a8e96..eecebad 100644 --- a/src/amd/vulkan/radv_cmd_buffer.c +++ b/src/amd/vulkan/radv_cmd_buffer.c @@ -187,7 +187,7 @@ radv_bind_dynamic_state(struct radv_cmd_buffer *cmd_buffer, const struct radv_dy RADV_CMP_COPY(vk.ts.patch_control_points, RADV_DYNAMIC_PATCH_CONTROL_POINTS); RADV_CMP_COPY(vk.ts.domain_origin, RADV_DYNAMIC_TESS_DOMAIN_ORIGIN); - + RADV_CMP_COPY(vk.rs.line.width, RADV_DYNAMIC_LINE_WIDTH); RADV_CMP_COPY(vk.rs.depth_bias.constant, RADV_DYNAMIC_DEPTH_BIAS); RADV_CMP_COPY(vk.rs.depth_bias.clamp, RADV_DYNAMIC_DEPTH_BIAS); @@ -235,7 +235,7 @@ radv_bind_dynamic_state(struct radv_cmd_buffer *cmd_buffer, const struct radv_dy RADV_CMP_COPY(vk.cb.logic_op, RADV_DYNAMIC_LOGIC_OP); RADV_CMP_COPY(vk.cb.color_write_enables, RADV_DYNAMIC_COLOR_WRITE_ENABLE); RADV_CMP_COPY(vk.cb.logic_op_enable, RADV_DYNAMIC_LOGIC_OP_ENABLE); - + RADV_CMP_COPY(vk.fsr.fragment_size.width, RADV_DYNAMIC_FRAGMENT_SHADING_RATE); RADV_CMP_COPY(vk.fsr.fragment_size.height, RADV_DYNAMIC_FRAGMENT_SHADING_RATE); RADV_CMP_COPY(vk.fsr.combiner_ops[0], RADV_DYNAMIC_FRAGMENT_SHADING_RATE); @@ -8401,6 +8401,12 @@ radv_get_ngg_culling_settings(struct radv_cmd_buffer *cmd_buffer, bool vp_y_inve const struct radv_graphics_pipeline *pipeline = cmd_buffer->state.graphics_pipeline; const struct radv_dynamic_state *d = &cmd_buffer->state.dynamic; + /* Disable shader culling entirely when conservative overestimate is used. + * The face culling algorithm can delete very tiny triangles (even if unintended). + */ + if (d->vk.rs.conservative_mode == VK_CONSERVATIVE_RASTERIZATION_MODE_OVERESTIMATE_EXT) + return radv_nggc_none; + /* Cull every triangle when rasterizer discard is enabled. */ if (d->vk.rs.rasterizer_discard_enable) return radv_nggc_front_face | radv_nggc_back_face; @@ -8422,12 +8428,10 @@ radv_get_ngg_culling_settings(struct radv_cmd_buffer *cmd_buffer, bool vp_y_inve if (d->vk.rs.cull_mode & VK_CULL_MODE_BACK_BIT) nggc_settings |= radv_nggc_back_face; - /* Small primitive culling is only valid when conservative overestimation is not used. It's also - * disabled for user sample locations because small primitive culling assumes a sample - * position at (0.5, 0.5). */ - bool uses_conservative_overestimate = - d->vk.rs.conservative_mode == VK_CONSERVATIVE_RASTERIZATION_MODE_OVERESTIMATE_EXT; - if (!uses_conservative_overestimate && !pipeline->uses_user_sample_locations) { + /* Small primitive culling assumes a sample position at (0.5, 0.5) + * so don't enable it with user sample locations. + */ + if (!pipeline->uses_user_sample_locations) { nggc_settings |= radv_nggc_small_primitives; /* small_prim_precision = num_samples / 2^subpixel_bits -- 2.7.4