From 56a1152b096fa6b2ee2a5f087ef05a40ccddecbb Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Wed, 26 Jan 2022 14:50:09 +0100 Subject: [PATCH] radv: always enable VRS 2x2 if flat shading is allowed and safe It should be safe to always enable this even if the application enables per-draw VRS with VkPipelineFragmentShadingRateStateCreateInfoKHR or with the dynamic state. This allows VRS for flat shading pipelines with vkd3d-proton. This was previously disabled because vkd3d-proton needs to always declare the VRS dynamic state due to DX12 VRS logic. Signed-off-by: Samuel Pitoiset --- src/amd/vulkan/radv_pipeline.c | 39 +++++++++++++++------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c index a1f5646a5a27..f4349f7de928 100644 --- a/src/amd/vulkan/radv_pipeline.c +++ b/src/amd/vulkan/radv_pipeline.c @@ -5719,28 +5719,23 @@ gfx103_pipeline_generate_vrs_state(struct radeon_cmdbuf *ctx_cs, vk_find_struct_const(pCreateInfo->pNext, PIPELINE_FRAGMENT_SHADING_RATE_STATE_CREATE_INFO_KHR) || radv_is_state_dynamic(pCreateInfo, VK_DYNAMIC_STATE_FRAGMENT_SHADING_RATE_KHR); - if (!enable_vrs) { - if (gfx103_pipeline_vrs_coarse_shading(pipeline)) { - /* Enable VRS coarse shading 2x2 if the driver determined that - * it's safe to enable. - */ - mode = V_028064_VRS_COMB_MODE_OVERRIDE; - rate_x = rate_y = 1; - } else if (pipeline->device->force_vrs != RADV_FORCE_VRS_NONE) { - /* Force enable vertex VRS if requested by the user. */ - radeon_set_context_reg( - ctx_cs, R_028848_PA_CL_VRS_CNTL, - S_028848_SAMPLE_ITER_COMBINER_MODE(V_028848_VRS_COMB_MODE_OVERRIDE) | - S_028848_VERTEX_RATE_COMBINER_MODE(V_028848_VRS_COMB_MODE_OVERRIDE)); - - /* If the shader is using discard, turn off coarse shading - * because discard at 2x2 pixel granularity degrades quality - * too much. MIN allows sample shading but not coarse shading. - */ - struct radv_shader *ps = pipeline->shaders[MESA_SHADER_FRAGMENT]; - - mode = ps->info.ps.can_discard ? V_028064_VRS_COMB_MODE_MIN : V_028064_VRS_COMB_MODE_PASSTHRU; - } + if (gfx103_pipeline_vrs_coarse_shading(pipeline)) { + /* Enable VRS coarse shading 2x2 if the driver determined that it's safe to enable. */ + mode = V_028064_VRS_COMB_MODE_OVERRIDE; + rate_x = rate_y = 1; + } else if (!enable_vrs && pipeline->device->force_vrs != RADV_FORCE_VRS_NONE) { + /* Force enable vertex VRS if requested by the user. */ + radeon_set_context_reg( + ctx_cs, R_028848_PA_CL_VRS_CNTL, + S_028848_SAMPLE_ITER_COMBINER_MODE(V_028848_VRS_COMB_MODE_OVERRIDE) | + S_028848_VERTEX_RATE_COMBINER_MODE(V_028848_VRS_COMB_MODE_OVERRIDE)); + + /* If the shader is using discard, turn off coarse shading because discard at 2x2 pixel + * granularity degrades quality too much. MIN allows sample shading but not coarse shading. + */ + struct radv_shader *ps = pipeline->shaders[MESA_SHADER_FRAGMENT]; + + mode = ps->info.ps.can_discard ? V_028064_VRS_COMB_MODE_MIN : V_028064_VRS_COMB_MODE_PASSTHRU; } radeon_set_context_reg(ctx_cs, R_028064_DB_VRS_OVERRIDE_CNTL, -- GitLab