From 1bc25c855b68420fcf7e567a3278674a73ec490e Mon Sep 17 00:00:00 2001 From: Zan Dobersek Date: Tue, 19 Aug 2025 10:38:18 +0200 Subject: [PATCH] tu: disable LRZ writes also for alpha-to-coverage, FS sample coverage output Currently LRZ writes are disabled when depth writes are enabled but the fragment shader is using discard. Additionally, LRZ writes should be disabled when fragment shader is outputting sample coverage or the pipeline state is enabling alpha-to-coverage which behaves as a discard. This fixes rendering problems on Assetto Corsa. Conditions now used for disabling LRZ writes match one set of conditions under which the EARLY_Z_LATE_Z z-test mode is used. It was assumed that in that mode the LRZ writes in binning will not happen until the late-Z phase, but that's apparently not the case. Signed-off-by: Zan Dobersek Reviewed-by: Danylo Piliaiev Part-of: --- src/freedreno/vulkan/tu_lrz.cc | 3 ++- src/freedreno/vulkan/tu_shader.cc | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/freedreno/vulkan/tu_lrz.cc b/src/freedreno/vulkan/tu_lrz.cc index 6d84f4bd421..e4d8c1211ab 100644 --- a/src/freedreno/vulkan/tu_lrz.cc +++ b/src/freedreno/vulkan/tu_lrz.cc @@ -761,7 +761,8 @@ tu6_calculate_lrz_state(struct tu_cmd_buffer *cmd, gras_lrz_cntl.enable = true; gras_lrz_cntl.lrz_write = z_write_enable && - !(fs->fs.lrz.status & TU_LRZ_FORCE_DISABLE_WRITE); + !(fs->fs.lrz.status & TU_LRZ_FORCE_DISABLE_WRITE) && + !cmd->vk.dynamic_graphics_state.ms.alpha_to_coverage_enable; gras_lrz_cntl.z_write_enable = z_write_enable; gras_lrz_cntl.z_bounds_enable = z_bounds_enable; gras_lrz_cntl.fc_enable = cmd->state.lrz.fast_clear; diff --git a/src/freedreno/vulkan/tu_shader.cc b/src/freedreno/vulkan/tu_shader.cc index c069e743dc8..8fc125f9211 100644 --- a/src/freedreno/vulkan/tu_shader.cc +++ b/src/freedreno/vulkan/tu_shader.cc @@ -2830,7 +2830,7 @@ tu_shader_create(struct tu_device *dev, const struct ir3_shader_variant *fs = shader->variant; shader->fs.sample_shading = fs->sample_shading; shader->fs.has_fdm = key->fragment_density_map; - if (fs->has_kill) + if (fs->has_kill || fs->writes_smask) shader->fs.lrz.status |= TU_LRZ_FORCE_DISABLE_WRITE; if (fs->no_earlyz) shader->fs.lrz.status = TU_LRZ_FORCE_DISABLE_LRZ;