fix(agc): continue a direct mesh draw past the X group limit in Z #13894
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13894"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by hugodearaujo on 2026-10-31T11:34:01Z.
What
A direct draw on the mesh path runs one mesh workgroup per
primitivesPerGroupprimitives, all in X:vkCmdDrawMeshTasksEXT(groups, instances, 1). Whengroupsis overmaxMeshWorkGroupCount[0], the draw stops the title:RADV reports 65,535 for X, Y and Z and 4,194,304 in total. A fast-launch point list (one primitive and one vertex per group) of more than 65,535 points is enough to hit it.
The change. Groups past the X limit go on in Z:
MeshGridFortakeslayers = ceil(groups / maxX)andcolumns = ceil(groups / layers), so the groups spread evenly and at mostlayers - 1groups are spare. When the draw needs layers, a layer holds at most 65,535 groups even on a device whose X limit is higher, so the stride below fits in 16 bits. Instances stay in Y. A grid that is over the Z limit or the total limit still stops the draw with the same message; the total is checked by dividing the limit, so the product of the three factors can't wrap. A draw with no instances keeps its split and dispatches zero Y groups, as before.WorkgroupId.x + WorkgroupId.z * strideand computes the group's first primitive from it, so the primitive index (and the index or vertex it reads) follows. A draw in one layer pushes 0, so its number isWorkgroupId.xwhatever the device reports for the other components; the mesh program readsNumWorkgroupsonly wheremainalready did.groups <= maxX, every indirect draw and every draw of captured tessellation output pushes a stride of 0 and gets the same number as before.Not changed: indirect mesh draws (CPU-read and GPU-resolved records) still draw nothing when a record needs more groups than X allows, as
ResolveMeshArgumentsand its tests state.Tested
Arch Linux, RX 9070 XT, RADV (Mesa 26.2.6), Release:
CONTROL Resonant (PPSA34547),
mainde83e8f270+ #11580 + #12458 (the title needs both to reach gameplay). In the opening room, holding L1 at the pillar stops the title within seconds, in 2 of 2 runs (886 s and 541 s after launch). A diagnostic build that printed the draw at the stop showed:With this change cherry-picked onto the same build (together with a one-line fault-report change that only touches
BdaResources::CheckFault), the second run held L1 at the pillar with no stop, went through the cutscene that follows, the "Choose your Aberrant form" prompt and the walk out of the containment cell ("Orientation: Leave the Oldest House"), and ran its full 1,500 s with nothing from amdgpu in the kernel log. The first run of that build never reached the pillar: the GPU ring timed out during the opening cutscene, 309 s after launch (ring gfx_0.0.0 timeout, the ring reset succeeded; the AGC markers name an unfinished compute dispatch, program 0x1004260100). None of the three runs without this change hung there, and the change does reach every mesh program (ate011e34ad7each one readNumWorkgroups.x; it now readsWorkgroupId.zand the pushed stride instead), so I can't rule out a link. I've seen it once.agc_driver_mesh: a new non-indexed fast-launch draw of 65,575 one-primitive groups, 65,535 degenerate ones followed by the test's 40 triangles, checks that the 40 triangles are drawn. On RADV it takes two layers of 32,788 groups (one spare). Withmain'sDraw.cppandDraw.hpp, it fails withmesh draw exceeds workgroup count limits; with the pushed stride forced to 0, it fails withfast-launch draw of 65,575 one-primitive groups: triangle 0 was not rendered in its color, pixel (16, 24, 40, 255).agc_driver_graphics:MeshGridForagainst made-up limits (X 1,000, Y 600, Z 3 or 10, total 4,000): one layer at the X limit with a stride of 0 (also for 1 group and for 999 groups with 3 instances), an even split over two and three layers with the stride equal to the columns, instances kept in Y, zero instances keeping the split, and no grid past the Z limit, the total limit or the Y limit, or for zero groups. With the GTX 1650's limits below (X and total 4,194,304), 65,575 and 4,194,304 groups stay in one layer with a stride of 0 and 4,194,305 are refused. With an X limit of 100,000, 100,000 groups stay in one layer and 100,001 and 196,605 groups split into layers of 50,001 and 65,535. A product past 64 bits (X 800,000,000, Y, Z and total 4,294,967,295, 4,294,967,295 groups and instances) is refused.NVIDIA report (GTX 1650, below). At
e011e34ad7the shader readNumWorkgroups.xandWorkgroupId.zat the start of every mesh program, and the first mesh draw failed on that GPU. I dumped the SPIR-V of the test's 43 mesh programs ate011e34ad7and on this head, for RADV's target and for a 32-lane subgroup target like NVIDIA's (the first program):spirv-val --target-env vulkan1.3accepts all of them (SPIR-V 1.4,gl_NumWorkGroupsandgl_WorkGroupIDarev3uintInput variables in theOpEntryPointinterface, with theirBuiltIndecorations). With a Z count of 1,WorkgroupId.zis 0 by the spec and the old expression equalsxwhateverNumWorkgroups.xholds, so on that driver the mesh program must have seen a non-zeroWorkgroupId.z, or the driver compiled the two reads differently from the spec; I can't tell which without the hardware. This head stops depending on them: a draw in one layer multipliesWorkgroupId.zby a pushed 0, and a device whose X limit equals its total limit (as on that GPU) never splits a draw.Validation layer,
e011e34ad7against7806d47120, same machine, same settings and test list as below: 11 of 11 pass on each, the loader inserted the layer 15 times on each, nowas not found but was requestedline and noVUID-message on either.Validation layer,
mainc3c45d73abagainst this branch, same machine,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1,ANYPS5_REQUIRE_VULKAN=1,VK_LOADER_DEBUG=layer,ctest -Vonagc_driver_graphics,agc_driver_mesh,agc_mesh_output_budget,agc_driver_mesh_barycentric_emulation,agc_driver_mesh_draw_relocation,agc_driver_mesh_index_cache,agc_driver_mesh_provoking_layer,agc_driver_mesh_provoking_vertex,agc_driver_mesh_vector_window_waves,agc_driver_tessellationandagc_driver_tessellation_geometry: 11 of 11 pass on each tree, the loader inserted the layer 15 times on each, nowas not found but was requestedline and noVUID-message on either.mainruns its ownagc_driver_mesh, without the new draw.Only RADV was tested on this head. A device whose X limit is above 65,575 draws the new test case in one layer, so it checks the draw but not the split.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T11:36:29Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The new direct-mesh grid path turns a zero-instance draw into an exception, although the previous path dispatched zero Y workgroups.
What I ran
Reviewed head
aa836fbcf7ddb6a9856cdd56f4c667c4cca5f7d9against basecbed91529193c47194bef11811906c7cb6054af1; the merge preview was clean against that base. Environment: Linux x86_64, Python 3.11.2, GCC 12.2.0. No build or C++ test was run.Results
mainatcbed91529193c47194bef11811906c7cb6054af1Graphics.cppandMesh.cppare listed incore/libs/prx/libSceAgcDriver/CMakeLists.txtUnedited local check output
Negative control
Draw.cppmesh draw exceeds workgroup count limits; not independently run by metriangle 0 was not rendered in its color; not independently run by meFindings
Blocking
A direct mesh draw with
draw.instanceCount == 0now gets{0, 0, 0}fromMeshGridFor, then failsRequire(grid.groups != 0)before recording the draw. On the base, the code allowed the same case through its bounds checks and passedinstanceCountasgroupCountY, recording zero Y workgroups. This changes a no-work draw into a runtime failure. Please preserve zero-instance draws as no-ops (for example, mark the prepared draw asnothingbefore the nonzero-grid check) and add a regression test for the preparation/dispatch path; the current helper-only test does not exercise this call-site behavior.Non-blocking
The PR description reports an otherwise unexplained GPU ring timeout in one of two changed-build title runs, before the target mesh draw; I could not independently determine whether it is related. The other reported run and focused GPU tests pass, so this is not the basis for the requested changes.
Sources
Not verified
No local build,
agc_driver_graphics,agc_driver_mesh, console behavior, or independent GPU/title run was performed. The GPU and validation-layer runs in the PR description are author-reported evidence, not local runs.To get this to a good state
Please handle zero-instance direct mesh draws as no-ops and cover the caller path, then update the PR. I will rerun the same no-build checks and review the new head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T12:23:23Z.
Review: APPROVED
Re-checked — new head, looks good
The updated grid preserves zero-instance draws and bounds the total-workgroup check without multiplication overflow, resolving both previously reported blockers.
What I ran
Reviewed exact head
e011e34ad7e874fe147dcd599adb55d0abe7224aagainst PR basecbed91529193c47194bef11811906c7cb6054af1and livemain60bdb061356db736928eee431cd8bd4c9ba68036. The current-main merge preview is clean (201e280a167756b08398995c236665a9dc800f41). Environment: Linux x86-64, GCC 12.2.0, Python 3.11.2. I did not build locally or run C++ tests.Results
All conventions checks passed.201e280a167756b08398995c236665a9dc800f41agc_driver_graphicsandagc_driver_meshpass on this exact head under the validation layer, with no VUIDs; not independently run hereUnedited local output
git diff --checkproduced no output and exited 0.git merge-tree --write-treeprinted:Negative control
Findings
Blocking
None found on this head.
Non-blocking
None.
Sources
Not verified
I did not run a local build, C++ tests, or a console test. The two GPU results are author-reported. macOS relinker checks were queued and the Windows product check was still running at review time.
To get this to a good state
No source changes are requested. Let the pending hosted checks finish; I will recheck if the head changes.