From 7e6440ca6f6e9baf6a93be17c132d5870f287965 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: (cherry picked from commit 02138d96fd311133df13db6099304d7dbbf8f95e) --- .pick_status.json | 2 +- src/freedreno/vulkan/tu_cmd_buffer.cc | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index 6d05597a17e..d45a4c6d4b2 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -3104,7 +3104,7 @@ "description": "tu: Prevent GPU hang with occlusion query + certain depth state", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/freedreno/vulkan/tu_cmd_buffer.cc b/src/freedreno/vulkan/tu_cmd_buffer.cc index c1853e87b24..cdd4e1fb9f6 100644 --- a/src/freedreno/vulkan/tu_cmd_buffer.cc +++ b/src/freedreno/vulkan/tu_cmd_buffer.cc @@ -6362,6 +6362,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.per_samp || !vk_format_has_depth(depth_format) || !ds_test_enable)) {