fix(shader): give a mesh group its output vertex count #23818
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/23818"
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 relativespace2K on 2026-11-19T17:53:42Z.
What
The mesh entry wrote the group's input vertex count into
mergedGroupInfo(s2bits 12-20). The merged NGG program's copy phase also reads that field as its output vertex count, so a geometry program that emits three vertices per input primitive declared only the input count. For the XPSemu probe's pass-through triangle GS (4-vertex strip or fan, 2 input primitives, 6 output vertices) the guest'sGS_ALLOC_REQand copy phase stopped at 4, so the second triangle's vertices 4 and 5 were never copied and its primitive rasterized black. A triangle list hid the bug: each input vertex is also one output vertex.The group output count is now
input primitives * VGT_GS_MAX_VERT_OUT(0x2ce), clamped tomaxVertices; a pass-through program hasVGT_GS_MAX_VERT_OUT == outputPrimitiveSize.maxPrimitivesis the driver's budget for the whole shader, not the group's primitive count: a triangle list with 42 primitives per group and a budget of 85 gave a factor of85 / 42 = 2, so a single input triangle declared 6 output vertices while the pass-through program emitted 3, and the probe read the result back black on a Radeon 860M under LLPC. The budget ratio is not used for the group count. The per-wave input counts inmergedWaveInfo(s3) are unchanged, so the VS and GS invocation masks stay the input counts.pr_overlap.pyflags #20518 (mesh reuse grouping) as touching the same assignment; this change does not depend on it and does not implement it. Whichever lands second needs a small rebase at that line.Tested
Windows 11 IoT Enterprise LTSC 10.0.26300, AMD Radeon RX 6800 XT (AMD Adrenalin 32.0.21045.16010, LLPC), WinLibs GCC 15.2.0 r7, Release.
Probe (the
prepare.reqassets attached to #23642, not committed): a local AGC draw of the pass-through GS0x200240d00and PS0x200241600with the probe's queue-dump draw state,711ab41a6edwithout this change: strip triangle 1 and fan triangle 1 read back black, the reported issue;1ad3ba856fe: strip triangle 1 is green (vertex 4) and fan triangle 1 is cyan (vertex 9); the 9-vertex triangle list and the first strip and fan triangles are unchanged.The follow-up commit
b5886d0898changes the group count from the budget-scaled value toinput primitives * outputPrimitiveSize, because the budget ratio over-declared the single-triangle triangle list in the Radeon 860M report.agc_shader_replay --preparestill prepares all three probe requests on this head. LeandroLP23 reran the probe onb5886d0898on a Radeon 860M under LLPC: the single triangle reads a valid colour again, the strip and fan second triangles stay valid, andget_color_indexmatched all five probe pixels with the two fan reads agreeing.upipibi ran
ctest -R '^agc_driver_mesh'on an RTX 3070 (driver 616.56, Windows 11 26100) at head6ccf2e5fe2merged ontomain61f7f5925c: 9 of 9 tests passed in 3 of 3 runs on bothmainand the head, with 0VUID-lines and the validation layer inserted.einfachama ran the same XPSemu probe on an RTX 4060 (driver 621.24, Windows 11 26300) at head
6ccf2e5fe2merged ontomainbb628f7722:mainlogs the strip1/fan errors in 3 of 3 runs, the PR has no error lines in 3 of 3, withVK geometry shader winding: 0, 0, 0, 0. The 13 focused mesh/request/serializer tests pass 13/13 on both sides, and the 3358-test selection has no new failure; the five it reports also fail onmainon that machine.Rebased onto
mainbe236e32b8. The follow-up commit6ccf2e5fe2replacesoutputPrimitiveSizewith the per-input vertex limit: a group declaresinput primitives * VGT_GS_MAX_VERT_OUToutput vertices, clamped tomaxVertices. This keeps the pass-through results above (VGT_GS_MAX_VERT_OUT == outputPrimitiveSize) and stops an amplifying geometry program from being truncated to three vertices per input point. The value now crossesMeshConfiguration, request format 64 (main took 63 for the trailing emulated-barycentrics flag; older requests fall back tooutputPrimitiveSize), the pipeline, draw and shader-cache keys and the pipeline journal (format 20).request_serializerbuilds and passes on the host; the decode fixture checks that register0x2cereachesMeshConfiguration.ShaderMemory.cppnow expects serialization version 64 (its prefix isNVNQQUAAAAA=, the unsupported fixture is 65) and moves its unsupported-version fixture to 65;verifyMeshConfigurationround-trips twoverticesPerPrimitivevalues and checks that they change the recompile cache key. malekaifa ran the focused five-test set atdc756752d3on an RTX 5080 and on an AMD iGPU, 5/5 on both, and theagc_shader_memoryfailure he saw was the stale version-62 expectation, now updated.The same focused tests on main and on
1ad3ba856fe, withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layerandctest -V:agc_driver_mesh,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_wavesandagc_driver_mesh_wavespass 8/8 on both, the validation layer is inserted, and both logs have 0VUID-lines.python tools/check_conventions.py --base origin/mainreports no errors.Not tested: RADV/Linux, a geometry program that emits fewer vertices than the group budget, and an amplifying geometry draw; the lavapipe host used here has no mesh shader compiler for these programs.
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)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T18:24:23Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change based on the changed hunk; the broader file and runtime behavior were not fully verified.
What I ran
Read the prepared review bundle and targeted repository context with the pinned reader at head
1ad3ba856fe649ebce30bf7d16d7bd1b5a2dba10. No tests or build commands were run.Results
maxVertices.Findings
Blocking
None.
Non-blocking
None.
Sources
The changed assignment and its surrounding mesh input count logic are in
InstructionTranslator.cpp. The mesh output setup consumes allocated vertex and primitive counts inSpirvModuleEmitter.cpp.Not verified
The full changed file was not read; only lines 285–345 were inspected. No tests, build, or runtime probe were run. The probe and test results in the description are author-reported. The supplied review bundle lists one changed file, and that file is included; no excluded changed files were listed.
To get this to a good state
Nothing is required. Optional: run the focused tests and probe on this head to independently confirm the reported behavior.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T04:37:26Z.
Review: COMMENTED
Reviewed — no blocking findings
The change adds a per-input vertex limit to mesh configuration, propagates it through serialization and cache keys, and uses it to size the group output count; I found no concrete defect in the inspected code.
What I ran
Reviewed head
9f27f7ced242f9f9669579b19cb69679cc59dfc4using the prepared diff and pinnedrepo_read.pycontext. No commands or tests were run.Results
files.jsonwas not available through the readerFindings
Blocking
None.
Non-blocking
None.
Not verified
The full text of
core/libs/prx/libSceAgcDriver/tests/Graphics.cppandcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppwas excluded from the prepared bundle; I read only targeted ranges through the pinned reader. I also did not read every included changed file or verify the author-reported test runs, GPU behavior, or builds. The bundle states those two test files were excluded as too large;files.jsonitself could not be read.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T22:41:10Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change; the inspected count derivation and serialization paths support the stated fix, but two changed test files were excluded from review.
What I ran
Reviewed head
6dfbc85a5eb81b90f8da09bb283c90782e3b39e6usingrepo_read.pysearch and targeted reads. No tests or builds were run.Results
Findings
Blocking
None.
Non-blocking
Graphics.cppandShaderMemory.cpptest changes were excluded from the review bundle, so their assertions were not inspected.Not verified
Did not read the changed test files
core/libs/prx/libSceAgcDriver/tests/Graphics.cppandcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppbecause they were excluded as too large. Did not run tests or verify the author-reported hardware results. All other changed files listed in the manifest were read at targeted ranges; the full contents of those files were not read.To get this to a good state
Nothing is required. Optional: inspect the excluded test changes and run the focused tests on the new head.
Imported from boykopovar/AnyPS5. Originally posted by einfachama on 2026-11-21T01:01:06Z.
Review: APPROVED
NVIDIA title run: on an RTX 4060 the XPSemu probe fails on
mainand passes with this PR, 3/3 runs each, with no validation errors and no test regressions.Setup: NVIDIA GeForce RTX 4060, driver 621.24, Windows 11 Pro 26H2 (10.0.26300), Ryzen 7 5800X, MSYS2 UCRT64 GCC 16.2.0, Release, Khronos validation layer 1.4.363. Base
mainbb628f7722; change is head6dfbc85a5emerged onto it withgit merge --no-ff(clean, the PR's 15 files only).mainhas not changed the request serializer, the pipeline journal or the cache key since the PR's basedcdf7809dd, so formats 64 and 20 do not collide.Title: XPSemu Alpha 2.1 (PPSA97358, content version 01.000.000),
PPSA97358.zipfrom the official release https://github.com/ZiZc3/XPSemu/releases/tag/Alpha-2.1, SHA-256494682ff5073985422fd8961cc617b8e3bdbdb2dedd85b69dadbd06f709953e9, which matches the digest GitHub publishes for the asset. No MCPX ROM, BIOS or Xbox games: the probe runs at renderer start-up before the BIOS is needed (Failed to load BIOS '(null)'is logged and XPSemu reaches its welcome screen).Run:
tools/title_run.py PPSA97358 --runs 1(titles.jsonentry, 30 s), three separate invocations per side, so every run starts from a fresh work folder and its owndata/xemu/xemu.log. Every run selected the RTX 4060.mainbb628f7722main+ #23818main, every run:With the PR, every run:
The single-triangle line (
Could not determine triangle rotation) that the earlier budget-ratio head produced on the Radeon 860M does not appear on either side. So the reported black second triangles reproduce on NVIDIA too, and the PR fixes them there.The probe draws into an offscreen target and reads it back, so the screen is XPSemu's welcome screen on both sides; the two attached frames (last kept frame of run 1, downscaled by
title_run.py) are the same.Validation: one more title run per side with
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer. Both logs showInsert instance layer "VK_LAYER_KHRONOS_validation", neither reportswas not found but was requested by env var VK_INSTANCE_LAYERS, and neither has aVUID-line. The probe lines were the same as in the runs above.Tests:
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1, the validation layer andctest -V --timeout 120:request_serializer,agc_shader_memory,agc_driver_graphics,agc_mesh_output_budget,agc_driver_mesh,agc_driver_mesh_barycentric_emulation,_draw_relocation,_index_cache,_provoking_layer,_provoking_vertex,_vector_window_waves,_vector_window_writes,_waves: 13/13 onmainand 13/13 with the PR; layer inserted in both logs, 0VUID-lines in both.tools/select_tests.pyselection for the PR's files on the merge (3358 of 6536 tests),-j16 --timeout 120: 5 failed, 25 skipped, the rest passed. The failures areagc_driver_stencil_plane_memory,agc_driver_store_over_untracked,agc_driver_msaa_dcc_unwatchandagc_storage_write_back_host_retile, which fail onmainon this machine (fixes in #22508, #22764, #22950, #23751), andguest_kernel_sys_pwrite_patched, which fails the same way onmainhere (securing the named shared-memory directory: access denied, a local directory permission). No new failures.Not tested: an amplifying geometry draw (
VGT_GS_MAX_VERT_OUTgreater than the output primitive size): the probe's program hasVGT_GS_MAX_VERT_OUT= 3, so this run confirms the pass-through case only. Also not tested: the head on its own parent rather than merged onto currentmain, other NVIDIA GPUs or drivers, Linux, and real Xbox games in XPSemu (no BIOS or games used).Approve.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T03:00:44Z.
Review: APPROVED
Reviewed — looks good
The reviewed change updates mesh group output counts and carries the per-input vertex limit through request serialization and cache keys; no concrete defect was identified in the inspected code.
What I ran
6ccf2e5fe2021fc446d956fa3986a9a4d48192a8and targeted source ranges viarepo_read.py.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
core/libs/prx/libSceAgcDriver/tests/Graphics.cppandcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppwas excluded from the prepared review folder. The changed ranges and relevant surrounding test code were read through the pinned reader.review/description.md,review/commits.md,review/manifest.json,review/diff.patch,review/README.md; all 14 changed files' added lines and targeted context, including ranges from the two excluded full-text files.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by einfachama on 2026-11-21T04:26:39Z.
Review: APPROVED
Re-check on the rebased head
6ccf2e5fe2: on an RTX 4060 the XPSemu probe still fails onmainand passes with this PR, with no validation errors and the focused tests passing.Setup: same as the first review. NVIDIA GeForce RTX 4060, driver 621.24, Windows 11 Pro 26H2 (10.0.26300), Ryzen 7 5800X, MSYS2 UCRT64 GCC 16.2.0, Release, Khronos validation layer 1.4.363. XPSemu Alpha 2.1 (PPSA97358, content version 01.000.000),
PPSA97358.zipSHA-256494682ff5073985422fd8961cc617b8e3bdbdb2dedd85b69dadbd06f709953e9(same package; extracted files checked against the zip). Basemain5856826928; change is head6ccf2e5fe2merged onto it withgit merge --no-ff(clean, the PR's 15 files only).mainis at request format 63 and pipeline journal format 19, so the PR's 64 and 20 follow on directly.tools/title_run.py PPSA97358 --runs 1(30 s), one invocation per run, each with a fresh work folder and its ownxemu.log. Every run selected the RTX 4060.main5856826928main+ #238186ccf2e5fe2main:With the PR, both runs:
Validation: one more PR-side title run with
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer. The log showsInsert instance layer "VK_LAYER_KHRONOS_validation", does not reportwas not found but was requested by env var VK_INSTANCE_LAYERS, and has 0VUID-lines. The probe printed only the winding line.Tests on the merge, with
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1, the validation layer andctest -V --timeout 120:request_serializer,agc_shader_memory,agc_shader_memory_coherent_atomic_loads,agc_driver_graphics,agc_mesh_output_budget,agc_driver_meshand its_barycentric_emulation,_draw_relocation,_index_cache,_provoking_layer,_provoking_vertex,_vector_window_waves,_vector_window_writes,_waves: 14/14 passed, layer inserted, 0VUID-lines.Not tested, as before: an amplifying geometry draw (the probe's
VGT_GS_MAX_VERT_OUTis 3), the head on its own parent, other GPUs or drivers, Linux, and real Xbox games in XPSemu. The broadselect_tests.pyrun from the first review was not repeated.This re-checks my earlier approval of
6dfbc85a5eon the rebased head6ccf2e5fe2. Approve.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by malekaifa on 2026-11-23T14:26:46Z.
Review: APPROVED
Reviewed exact head
6ccf2e5fe2021fc446d956fa3986a9a4d48192a8and the current 15-file change. The mesh group output count is now derived from input primitive count times the per-input output-vertex limit, capped bymaxVertices, while the input-wave counts remain unchanged. The newverticesPerPrimitivevalue is carried throughMeshConfiguration, request serialization, cache keys, draw/pipeline state, and the pipeline journal; legacy requests fall back tooutputPrimitiveSize.The current head has direct title evidence on NVIDIA and AMD: XPSemu’s strip/fan second triangles fail on main and render correctly with this head, with no new validation errors, while the single-triangle regression introduced by the earlier budget-ratio approach is also cleared. MarcZX10 and einfachama independently approved this exact head, and the focused serializer/mesh checks are green.
One integration constraint remains but is not a defect in this current head: #24906 is also open and independently uses request format 64. Whichever PR lands second must rebase and move its new layout to version 65 (and update fixtures) rather than keeping two layouts under 64. Because both are still open now, no version bump should be made yet.
No blocking finding on this exact head.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-29T11:22:41Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the focused review supports the updated per-group output vertex count and request-format handling.
What I ran
Reviewed head
bd4a08cc3abe27cbda72f67bdd630c1526bb5f28using the prepared diff and pinned repository reader. No commands or tests were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Did not run the test suite or independently verify the reported GPU probes. Read the diff and targeted ranges in all 14 changed files, including the two excluded from the review folder (
core/libs/prx/libSceAgcDriver/tests/Graphics.cppandcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp). The remaining file contents were not read in full; files excluded from the diff by the preparation rules were not reviewed.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-12-03T14:01:41Z.
Review: APPROVED
I read the diff at
bd4a08cc3a. Windows 11, GCC 15.2, merged intomainat6c6b29320fetogether with other open PRs (so not an isolated build), withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1andVK_LAYER_KHRONOS_validationon an RTX 5080 (621.24) and a Radeon iGPU (26.11.2).agc_driver_graphicsandagc_shader_memory: pass on both GPUs. The loader log shows the layer inserted and no "was not found" line, and neither run has aVUID-orSYNC-HAZARDline.Not checked: a title with mesh or NGG primitive groups.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T21:56:58Z.
Review: COMMENTED
Version 65 already identifies the historical mesh-reuse layout that #23811 reads. This branch assigns 65 to a different encoding that adds
verticesPerPrimitiveinside the mesh record. I built the exact serializers from both heads. Each read its own output, but #23811 reportedRequestSerializer: truncated datawhen reading a version-65 request emitted by this head. Please use a distinct wire version and preserve the historical reader. The common mesh and serializer checks are queued.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.