fix(shader): keep mesh register windows out of local memory on NVIDIA #12233
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12233"
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 beardsciences on 2026-10-28T04:08:40Z.
What
On NVIDIA's proprietary driver, function arrays that the driver keeps in local memory return wrong values in subgroups 1–3 of a mesh workgroup when they are read under a data-dependent branch. Subgroup 0 is correct, and the same reads without a branch are correct. A wave64 geometry program that uses relative VGPR addressing (
v_movrels/v_movreld) keeps its registers in the vector window, which is two such arrays per invocation, so waves 1–3 of a 256-thread NGG group lose register writes.v3 = v22 << 2in the setup block. They never cleared their candidate primitive slots, read 0 there, and wrote 76 degenerate triangles over wave 0's 6, so the 3D menu drew spikes.On that driver a mesh program's window now lives in a storage buffer:
APS5_NO_MESH_WINDOW_BUFFER=1keeps the arrays. Other drivers are unchanged.Cost, measured in PPSA07550's 3D main menu with #7893 (needed to reach it), RTX 3060 Ti, warm caches,
APS5_TRACE_SECONDS=260:60and no other trace or profile switch, two alternating runs per build.mainis a59fd393ec6d (3a2b919816+ #789376bea988bf), which draws the corrupt scene; the change is a6abcf9de1ec (this PR + the same #7893 head):main+ #7893, run 1main+ #7893, run 2The window buffer costs about 18–19 ms of GPU time per present in this menu. All four summaries report
trace_dropped(the event buffers of the queue worker and the draw committer filled after 9–38 s);totals_fullis false for every thread, so the summary numbers are complete. Traces andtools/trace_digest.pyoutput attached.Only mesh programs that keep a vector window for relative register addressing (
v_movrels/v_movreld) take this path, and only on NVIDIA's proprietary driver; every other shader, and every other driver, is compiled as onmain. The fastermainframes above render the corrupt scene, so the cost buys correct output rather than slowing down working output.Summary lines
Overlap: the overlap comment lists #6416, #6751, #6959, #7392, #8246, #10547, #10846, #11557, #11951, #12548 and #12662. None of them implements this or needs it, and this needs none of them: each adds its own flag, field, environment row or debt line next to this PR's (
SpirvTarget,CompiledShaderArtifact, the cache key,SpirvEmitterState, the draw paths inDraw.cpp,ENVIRONMENT.md,debt/shader.md), so whichever merges second keeps both lines. #6959 also changesEmitMeshEntryPoint, but in the layer output, not around the window claim and release.Tested
Windows 11, NVIDIA GeForce RTX 3060 Ti, driver 621.01 (32.0.16.2101).
mainis3a2b919816, the change is this PR on it (7f0e19dd6d).Validation,
mainand the change:ctest --test-dir build -R "mesh|vector_window|relative|window_lane|ngg|provoking" -VwithANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation; both logs attached. Neither containswas not found but was requested by env var VK_INSTANCE_LAYERS; the layer reports the same 10 messages in both, allWARNING-VkImageSubresourceRange-layerCount-compatibility, and noVUID-error.mainpasses 26 of 26, the change 27 of 27 (the extra test isagc_driver_mesh_vector_window_waves, whichmaindoes not have).New GPU test
agc_driver_mesh_vector_window_waves: a hand-written wave64 geometry program with 256 threads (no title code) fills 128 window registers with ordinary register writes. It reads them back throughv_movrelsunders_and_saveexec_b64+s_cbranch_execz, plus three direct reads, and stores a mismatch count per thread. WithAPS5_NO_MESH_WINDOW_BUFFER=1it fails in waves 1–3 (wrong threads per wave: 0 64 64 64), 2 of 2 runs. With this PR it passes, 2 of 2.MediEvil: Resurrection (PPSA07550), Sony's PSP emulator wrapping UCUS98620, together with #7893 (without it the menu aborts on a triangle-fan refusal first). The 3D main menu and its idle camera fly-through render correctly; on
main+ #7893 they show polygons stretched into spikes. Screenshots attached; the last visual check of the menu was oncccdaa2734, and on3a2b919816the traced runs above run the same menu.Before:

main+ #7893, main menu. Polygons stretched into spikes.After: this PR + #7893, the same menu.

After: this PR + #7893, during the menu's idle camera fly-through.

Not tested: AMD and Intel GPUs (the path is not taken there), other NVIDIA GPUs and drivers. TEKKEN: Dark Resurrection (PPSA31371) runs the same emulator, and #10051 reports black and missing triangles with
APS5_NO_WINDOW_NARROWING=1; that may be this bug but was not checked.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-28T04:19:34Z.
Review: CHANGES_REQUESTED
I found one initialization lifetime issue in the host pool setup that should be resolved before merge.
PrepareMeshWindowrecords the header fill into a recorder command buffer and immediately setspool.cleared = true. Recorder batches can be discarded ifvkEndCommandBufferorvkQueueSubmitfails; after that discard, later draws skip the fill even though no submitted command initialized the ticket counter and per-slot locks. The first mesh draw could then spin claiming a slot or reuse stale lock state. Please tie the initialized state to a successfully submitted initialization batch, or use an initialization path whose completion is guaranteed before later mesh draws can use the pool. Also include a focused check for the failed/discarded-first-batch case if feasible. I reviewed the shader indexing, liveness/initialization analysis, cache serialization, descriptor layout and release ordering statically. I could not reproduce the proprietary NVIDIA driver failure or run the new GPU regression test on this host, so I am not approving the driver-specific behavior without the author’s hardware evidence and this lifecycle case being addressed.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T09:20:27Z.
Review: CHANGES_REQUESTED
I rechecked head
77790116601ca240390208a280ad51481acbb5fa. The pool initialization race from my earlier review appears addressed: header initialization now runs in a separate submitted-and-waited batch, and pool readiness is published afterward. The report still does not satisfy the current review requirements:main(316615d042c087942e3fa11f258669abd92c3f27) by 276 commits behind and 3 ahead. Please rebase/update it to currentmain, resolve the newly exposed overlap, and rerun the focused tests.agc_driver_mesh_vector_window_waveson current main and the updated head withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation; provide logs confirming the layer loaded and compare newVUID-findings. The currently reported RTX 3060 Ti runs andAPS5_NO_MESH_WINDOW_BUFFERnegative control are useful, but do not document that required pair or validation result.aps5-summary.jsonllines, attached traces andtrace_digest.pyoutput. Please provide those for the speed claim or remove the unsupported speed comparison.Unblocks: PPSA07550 (no Game bring-up discussion yet). CONTRIBUTING requires the title ID and its Game bring-up discussion, ornone; please add the discussion link or change the line tonone.Conventions passes, but only conventions/labels are reported for this head; I found no current focused GPU validation run. I am keeping changes requested pending the above evidence and rebase.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T21:53:49Z.
Review: CHANGES_REQUESTED
Reviewing exact head
1f9b309c584049a6c6bec2836dc1a969cae4b62cagainst currentmain319621ba2e578bd053b0baba2877fe70520e0737.What I ran
git diff --checkagainst currentmain: passed.git merge-tree --write-treeagainst currentmain: clean merge tree (e7369b6c37aa7841c323a1ae0362c44c9aa9b0e5).Results
git diff --checkagainst currentmainmain750cf6cf48and this PR head, with Vulkan validation enabled and logs attached. Currentmainis319621ba2e578bd053b0baba2877fe70520e0737, so that report does not cover the current base.trace_digest.pyoutputs compare750cf6cf48plus #7893 with this PR plus #7893. They document a substantial GPU-time regression, but do not compare currentmainwith the change.Findings
Blocking
main. The PR's merge base is750cf6cf487f948017295b1f3717af6f886f0f85; currentmainis319621ba2e578bd053b0baba2877fe70520e0737(282 commits ahead of the PR branch). The merge-tree is clean, but the PR template requires a current-main basis, and this branch has not been integrated with the latest base. Please update/rebase it onto currentmain, resolve any newly exposed overlaps, and rerun the focused checks on the updated head.mainand the updated head.AGENTS.mdrequires the same focused tests on both builds, on the same machine and GPU, withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1, andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation; confirm the layer loaded and compare allVUID-lines. The posted pair uses750cf6cf48, not currentmain. Keep the PR Draft until this updated pair is available, or post the pair and update the report.750cf6cf48as “main”; they do not establish the comparison against currentmain. Please rerun the same scene and machine against the updated base and head and attach the matching summary lines, traces, and digest output, or remove the stale comparison from the PR description.The previous pool-initialization concern appears addressed by publishing the descriptor set only after the separately submitted initialization batch completes. I did not independently execute the GPU regression test on this head.
Sources
Not verified
mainvalidation or performance comparison is included in the evidence I checked.To get this to a good state
Rebase/update onto current
main319621ba2e578bd053b0baba2877fe70520e0737, then post fresh same-machine GPU validation logs and trace comparison for that base and the new head. The validation logs should confirm actual layer loading and show no newVUID-errors; the performance evidence should include the paired summary lines, traces, andtrace_digest.pyoutput. Keep the PR Draft until the required GPU pair is available.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T02:09:07Z.
Review: CHANGES_REQUESTED
Re-checked — changes still requested
I reviewed the updated head
7f0e19dd6d15017f8f281c1b3a98d1325f8da3d6against currentmain(3a2b91981651569163768854a1fcdc7193b6667b). The implementation review and updated test evidence address the earlier technical questions. I am keeping this review at Changes requested because the four performance summary lines still recordAPS5_TRACE_DIR; the repository's performance report form instructs reporters not to set otherAPS5_TRACE_*orAPS5_PROFILE_*switches.What I ran
On Linux x86_64 (GCC), I checked the exact PR head and built the focused mesh test in the isolated review build:
python3 tools/check_conventions.py --base upstream/main --head refs/remotes/review/12233git diff --check upstream/main...refs/remotes/review/12233git merge-tree --write-tree upstream/main refs/remotes/review/12233ninja -C /tmp/anyps5-pr12664-build-full agc_driver_mesh_vector_window_waves_testsagc_driver_mesh_vector_window_wavesqemu-x86_64 -cpu HaswellI also downloaded the four attached traces and matching digest outputs and recomputed each digest using
tools/trace_digest.pywith its attached summary. I read both attached Vulkan validation logs; I did not run the Windows/NVIDIA workload locally.Results
main17122221904ecf0f155886fb2f15a7f22fd048c1)WARNING-VkImageSubresourceRange-layerCount-compatibilitywarnings in each; noVUID-errorsRaw local check output
Negative control and hardware evidence
The author reports that the exact current PR head passes the new mesh test twice on an RTX 3060 Ti, while setting
APS5_NO_MESH_WINDOW_BUFFER=1reproduces wrong results in waves 1–3 twice. Their current-head Windows validation run reports 27/27 tests on the change and 26/26 on its matchingmainbaseline, with noVUID-errors. The author also supplied paired baseline/change traces from the same title, scene, and machine. I independently recomputed all four attached digests successfully. These are author-run hardware results, not locally reproduced runs. Details and attachments are in the author's current-head evidence comment.Findings
Blocking
aps5-summary.jsonllines includeAPS5_TRACE_DIR. The current performance report form says not to set any otherAPS5_TRACE_*orAPS5_PROFILE_*switch. The current report therefore does not meet the repository's stated capture procedure, even though its traces are attached and their digests reproduce. Please recapture the same baseline and change runs withoutAPS5_TRACE_DIR(write the traces to the working directory), then replace the four summary lines and attach the corresponding traces and digest outputs. Keep the same title, scene, machine, and fixed input so the comparison remains controlled.Non-blocking
mainis clean. Its documented#7893prerequisite is common to both baseline and change captures, and the report explains why it is needed to reach the scene; the comparison isolates this PR's effect.Not verified locally
I could not run the NVIDIA-specific workload or reproduce the Windows validation/test results on this Linux host. Native CTest stopped at the CPU guard, and QEMU with llvmpipe skipped the test because its Vulkan implementation lacks the required mesh-shader compiler. I therefore do not count those as passing local runtime tests.
To resolve
Please provide the four recaptured summary lines and their matching traces/digests without
APS5_TRACE_DIR. I can then re-check the updated report and clear this request if the capture record complies.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T03:02:00Z.
Review: APPROVED
Re-checked — approved
The requested performance capture correction is complete. The four current summary lines no longer include
APS5_TRACE_DIR, and I reproduced each attached digest from its trace and summary.What I ran
7f0e19dd6d15017f8f281c1b3a98d1325f8da3d6and its updated description/comment.tools/trace_digest.pyon each trace with its matching summary line.Results
APS5_TRACE_SECONDS=260:60is set among trace/profile switchesVUID-errorsAll four full
trace_digest.pyoutputs match the attached reports exactly. The reported baseline and change use the same title, menu scene, fixed input, machine, driver, and warm-cache alternating capture procedure.Negative control
APS5_NO_MESH_WINDOW_BUFFER=1Findings
Blocking
None found on this head. The prior report-format issue is resolved, and the attached trace digests verify against the current captures.
Non-blocking
Sources
Not verified
To get to a good state
No further changes are required for the findings in this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T08:30:34Z.
Review: CHANGES_REQUESTED
Re-reviewed exact head
7f0e19dd6d15017f8f281c1b3a98d1325f8da3d6after the new review comment. The implementation and matched validation/performance evidence remain as reviewed, butdocs/dev/debt/shader.md:196still names “PSPHD” twice. The repository debt convention uses PPSA IDs or “the title”; please replace both names with “the title” (PPSA07550 is already identified in this entry). The current-main merge preview is clean andgit diff --checkpasses. No GPU tests rerun locally.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T13:02:28Z.
Review: APPROVED
Re-checked — new head, approved
The only change since the previously approved head replaces the two title nicknames in the debt entry, resolving the outstanding repository wording request.
What I ran
Reviewed head
6f79055a0001703bc0419fb03a8dabd9ef1a2677against currentmain899ae3d1ad32ccea94dc24e66fdc948ce8a88171. The merge preview is clean (9f92fdb8033189e5630fb23bc56a08ad5b1aaa47). Environment: Debian GNU/Linux 12; GCC 12.2.0; CMake 3.25.1.Results
Raw output
git diff --checkproduced no output and exited 0.git merge-tree --write-treereturned:Negative control
Findings
Blocking
None on this head.
Non-blocking
None on this head.
Sources
Not verified
I did not rerun the GPU workload, Vulkan validation pair, performance captures, or CTest because the changed line is documentation only. Hosted conventions and labels were still pending.
To get this to a good state
No further changes are required for the findings reviewed here. I will rerun these checks if the head changes.