From 02138d96fd311133df13db6099304d7dbbf8f95e Mon Sep 17 00:00:00 2001 From: Danylo Piliaiev Date: Wed, 8 Oct 2025 16:03:13 +0200 Subject: [PATCH] tu: Prevent GPU hang with occlusion query + certain depth state This state combination wedges something in GPU causing hang. Forcing A6XX_LATE_Z prevents it. Prop driver does the same. CC: mesa-stable Signed-off-by: Danylo Piliaiev Part-of: --- src/freedreno/vulkan/tu_cmd_buffer.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/freedreno/vulkan/tu_cmd_buffer.cc b/src/freedreno/vulkan/tu_cmd_buffer.cc index 2803782ae05..9c9c39379ed 100644 --- a/src/freedreno/vulkan/tu_cmd_buffer.cc +++ b/src/freedreno/vulkan/tu_cmd_buffer.cc @@ -6594,6 +6594,18 @@ tu6_build_depth_plane_z_mode(struct tu_cmd_buffer *cmd, struct tu_cs *cs) cmd->state.occlusion_query_may_be_running) zmode = A6XX_EARLY_Z_LATE_Z; + VkCompareOp compare_op = + cmd->vk.dynamic_graphics_state.ds.depth.compare_op; + /* This state combination wedges something in GPU causing hang. + * Forcing A6XX_LATE_Z prevents it. Prop driver does the same. + */ + if (zmode == A6XX_EARLY_Z_LATE_Z && !depth_write && + cmd->state.occlusion_query_may_be_running && + (compare_op == VK_COMPARE_OP_ALWAYS || + compare_op == VK_COMPARE_OP_NEVER)) { + zmode = A6XX_LATE_Z; + } + if (zmode == A6XX_EARLY_Z_LATE_Z && (cmd->state.stencil_written_on_depth_fail || fs->fs.sample_shading || !vk_format_has_depth(depth_format) || !ds_test_enable)) {