From b96ea162c4f2baf57cb04c3cdc8a84aa2fd545bd Mon Sep 17 00:00:00 2001 From: Jeroen Trappers Date: Fri, 4 Dec 2026 21:43:08 +0100 Subject: [PATCH] pvr/g5p: refuse a draw into a colour attachment that is not stored A G5P pipeline writes its colour outputs to the render's end-of-tile targets. A colour attachment with store op DONT_CARE (and no resolve) is not one of them, so g5p_mrt_draw_check() can count one target on both sides while the draw's output really goes through another attachment's end-of-tile setup. With a 32-bit channel format (R32_*, R32G32_*) the fragment job then never finishes and the device is lost. That draw is reached once refused work is skipped: in the render-pass input-attachment cases, the subpass that reads the attachment is refused (image_deref_load), and its pass is no longer dropped as a whole. With pvr_skip_refused_work on, every renderpass1.*.formats.{r32,r32g32}_*.input.*.dont_care.draw case hung the fragment job on an iPhone 6s. Refuse the draw unless every colour attachment of the subpass is an end-of-tile target, or resolves into one. Two cases stay allowed: the driver's own vkCmdClearAttachments quads, which write a constant and have not hung, and a render with no end-of-tile target at all, whose outputs go nowhere (occlusion queries draw like that). Generated-by: LLM Signed-off-by: Jeroen Trappers --- src/imagination/vulkan/pvr_arch_g5p_gfx.c | 3 +++ src/imagination/vulkan/pvr_arch_g5p_mrt.c | 27 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/imagination/vulkan/pvr_arch_g5p_gfx.c b/src/imagination/vulkan/pvr_arch_g5p_gfx.c index 3b3ca02a343..c7782af9854 100644 --- a/src/imagination/vulkan/pvr_arch_g5p_gfx.c +++ b/src/imagination/vulkan/pvr_arch_g5p_gfx.c @@ -1920,6 +1920,8 @@ PVR_PER_ARCH(g5p_clear_attachments)(struct pvr_cmd_buffer *cmd_buffer, uint32_t * dirty for it and again for the application's state put back */ const bool a7 = PVR_HAS_FEATURE(&cmd_buffer->device->pdevice->dev_info, apple_g3); const struct pvr_g5p_draw draw = { .count = 3, .instances = 1 }; + /* the driver's own draws (g5p_mrt_draw_check() lets a clear into a colour attachment that is not stored) */ + pvr_g5p_internal_pipeline++; for (uint32_t r = 0; r < rect_count && result == VK_SUCCESS; r++) { /* the scissor: the rectangle (within the render area: the draw intersects it) */ dyn->vp.scissors[0] = rects[r].rect; @@ -1931,6 +1933,7 @@ PVR_PER_ARCH(g5p_clear_attachments)(struct pvr_cmd_buffer *cmd_buffer, uint32_t result = pvr_arch_g5p_cmd_draw(cmd_buffer, &draw); } } + pvr_g5p_internal_pipeline--; cs->gfx_pipeline = saved_pipeline; cs->vertex_bindings[0] = saved_binding; diff --git a/src/imagination/vulkan/pvr_arch_g5p_mrt.c b/src/imagination/vulkan/pvr_arch_g5p_mrt.c index bf6d34ca220..3fb19cf6ed2 100644 --- a/src/imagination/vulkan/pvr_arch_g5p_mrt.c +++ b/src/imagination/vulkan/pvr_arch_g5p_mrt.c @@ -24,6 +24,8 @@ #include "pvr_g5p_mrt.h" #include "pvr_hw_pass.h" #include "pvr_image.h" +#include "pvr_pass.h" +#include "pvr_g5p_shader_dump.h" /* Two 32-bit integer targets of one format (dEQP's ShaderExecutor: a mat2xN @@ -184,5 +186,30 @@ PVR_PER_ARCH(g5p_mrt_draw_check)(struct pvr_cmd_buffer *cmd_buffer, unsigned pip const unsigned rn = hw_render->eot_surface_count == 3 ? 4 : hw_render->eot_surface_count; if ((rn > 1 || pn > 1) && pn != rn) return G5P_REFUSE(cmd_buffer, "the pipeline writes %u colour targets, the pass has %u", pn, rn); + + /* The pipeline's outputs go to the render's end-of-tile targets, so each colour attachment of the + * subpass has to be one (or resolve into one). An attachment that is not stored (store op DONT_CARE) + * is not: the draw would write it through another attachment's end-of-tile setup, and with a 32-bit + * channel format (R32, R32G32) the fragment job never finishes. The driver's own clear quads + * (vkCmdClearAttachments) are left alone: they write a constant and have not hung. So is a render + * with no end-of-tile target at all: the outputs go nowhere (occlusion queries draw like that). */ + if (info->pass && !info->dr_info && !pvr_g5p_internal_pipeline && hw_render->eot_surface_count) { + const struct pvr_render_subpass *sp = &info->pass->subpasses[info->subpass_idx]; + + for (unsigned c = 0; c < sp->color_count; c++) { + const uint32_t a = sp->color_attachments[c]; + const uint32_t r = sp->resolve_attachments ? sp->resolve_attachments[c] : VK_ATTACHMENT_UNUSED; + bool eot = false; + + if (a == VK_ATTACHMENT_UNUSED) + continue; + for (unsigned t = 0; t < hw_render->eot_surface_count && !eot; t++) + eot = hw_render->eot_surfaces[t].attachment_idx == a || + (r != VK_ATTACHMENT_UNUSED && hw_render->eot_surfaces[t].attachment_idx == r); + if (!eot) + return G5P_REFUSE(cmd_buffer, "colour attachment %u of subpass %u is not stored (no end-of-tile " + "target)", c, info->subpass_idx); + } + } return VK_SUCCESS; }