test(agc): rewrite the GCN tessellation constant buffer between driver draws #25489
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/25489"
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 B-Howell on 2026-11-22T05:24:59Z.
What
Follow-up to #22328, for MarcZX10's optional point there: a driver-level test that rewrites the tessellation constant buffer between draws and confirms the next draw recompiles with the new values. Test only; no driver or recompiler change.
tests/execution/GcnTessellation.cpp(agc_driver_gcn_tessellation) now also submits three on-chip GCN LS-HS-VS draws from PM4 throughsceAgcDriverSubmitDcb. The draws use the same programs, registers and V#; only the buffer memory changes between them:GcnLocal,GcnDomainOnChipInputsandPixelCode, plusGcnHullOnChipBufferScale. That isGcnHullOnChipPassthroughwith one word changed: it writes word 7 of the constant buffer, converted to float, as its patch constant. The domain shader multiplies positions by that patch constant. Word 7 is read like the other words below 9: #22328 folds it into the hull as a constant, so the picture depends on the values the driver read for that draw.VGT_SHADER_STAGES_EN0x45,OC_LDS_ENis clear on the HS and VS, and the draw is aDRAW_INDEX_2of 3 triangle patches. Word 7 is rewritten in place to 1, 0 and 1. Scale 1 must draw patches 0 and 2 white, as the existing direct draws do, and patch 1 has factors 0. Scale 0 must leave every checked pixel at the clear colour.Tested
Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0 r7, RTX 4080 SUPER, driver 621.14.
agc_driver_gcn_tessellationpasses on this branch, 3 of 3 withctest --repeat until-fail:3. It also passes withAPS5_DRAW_PIPELINE=1, withAPS5_DRAW_PIPELINE=1 APS5_PIPELINED_DRAWS=32 APS5_PIPELINE_DISPATCH=1, and withAPS5_PIPELINED_DRAWS=0. WithAPS5_PROFILE_DRAW=1, the hull and domain programs are prepared at each draw.ReadTessellationConstants(DrawCapture.cpp): the second draw fails withrewritten to 0: patch 0 at (0.250000, -0.267000) is (255, 255, 255, 255), expected (16, 24, 40, 255).Draw.cppchange): the third draw fails withrewritten to 1: patch 0 at (0.250000, -0.267000) is (16, 24, 40, 255), expected (255, 255, 255, 255). The draw that is scaled back to 1 reuses the cached draw from scale 0.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer, withVK_ADD_LAYER_PATHset to the LunarG 1.4.363.1 SDK. I ranctest --test-dir build-win -R '^agc_driver_gcn_tessellation$' -Von #22328's head86ed1185e95and on this branch, and both pass:Insert instance layer "VK_LAYER_KHRONOS_validation"line. This branch's log has 2, because the driver makes its own device.was not found but was requested by env var VK_INSTANCE_LAYERS, and neither has aVUID-line.a26d80357de: GO. Two non-blocking points are fixed in27b7bb79370. The test's guest block is now released after the driver shuts down, also when a draw fails. A run with no guest block below 2^40 now reports a skip (77) instead of passing without the driver draws. On27b7bb79370, the test passes again with the validation layer: 2Insert instance layerlines, nowas not found, 0VUID-. The first stale-constants control still fails at the second draw with the same message.check_conventions --base origin/mainpasses. The branch merges cleanly into currentmainand into #22439's head.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1: head27b7bb7937merged ontomain526b7b19d0passes all 96 tests of the changed test files in each of 3 runs, none skipped (https://github.com/boykopovar/AnyPS5/pull/25489#issuecomment-7080609536).27b7bb7937merged ontomain90b6de9c18passesagc_driver_gcn_tessellation,agc_driver_tessellation,agc_tessellation_lowering,agc_driver_graphics,agc_shader_memoryandrequest_serializerin each of 3 runs withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1. The driver draws ran (no skip). No log haswas not foundor aVUID-line, onmainor on the head. Repeating the second stale-draw control by hand fails with the same message. Review ofGcnTessellation.cppfound no problems (https://github.com/boykopovar/AnyPS5/pull/25489#issuecomment-7095912114).pr_overlap --branchtimed out after 300 s, so I checked by hand.GcnTessellation.cppis new in #22328. Of the open PRs with tessellation in the title (#9387, #20111, #22251, #22328, #22439), only #22439 (ours, stacked on #22328) has the file, and it carries it unchanged from #22328.993c3d4c149: merged the updated #22328 (715ebdfed68, with mainea49f32e898); no conflicts. Windows 11, WinLibs GCC 15.2.0 r7, RTX 4080 SUPER,ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer(LunarG 1.4.363.1):request_serializer,agc_driver_gcn_tessellation,agc_driver_tessellation,agc_driver_tessellation_depth_range_remap,agc_driver_tessellation_geometry,agc_driver_graphics,agc_tessellation_loweringandagc_tessellation_factor_ring8/8 onc85928ac038(this head minus #22328's last serializer test);agc_driver_gcn_tessellationpasses with the driver rewrite draws, 7 layer inserts, 0VUID-.main61426d5bf1d7/7 on the same set without the GCN test. Every log loads the layer, none haswas not found, 0VUID-on either side.check_conventionsanddebt_fold.py --checkpass.agc_shader_memory(version fixture updates) was not run locally: Defender quarantines it on Windows; CI covers it.04bddfd765e: merged #2232858c5304937a, no conflicts. Windows 11, WinLibs GCC 15.2.0 r7, RTX 4080 SUPER,ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer(LunarG 1.4.363.1):request_serializer,agc_driver_register_key,agc_driver_gcn_tessellation,agc_driver_tessellation,agc_driver_tessellation_depth_range_remap,agc_driver_tessellation_geometry,agc_driver_graphics,agc_tessellation_lowering,agc_tessellation_factor_ring9/9 (agc_driver_gcn_tessellationwith the driver rewrite draws). Every log loads the layer, nowas not found, 0VUID-.check_conventionsanddebt_fold.py --checkpass.eeda7e7cd82: merged #223288dd935bb29f(tessellation constants read through the draw'sShaderMemory), no conflicts. Windows 11, WinLibs GCC 15.2.0 r7, RTX 4080 SUPER,ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer(LunarG 1.4.363.1):agc_driver_gcn_tessellationpasses, including the constant buffer rewrite draws; nowas not found, 0VUID-.check_conventionspasses.1ec7a550ffe: merged the updated #22328 (a5ae94d2dae, with main9a1d772cf16); no conflicts. Windows 11, WinLibs GCC 15.2.0 r7, RTX 4080 SUPER,ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer(LunarG 1.4.363.1):request_serializer,agc_driver_register_key,agc_driver_gcn_tessellation,agc_driver_tessellation,agc_driver_tessellation_depth_range_remap,agc_driver_tessellation_geometry,agc_driver_graphics,agc_tessellation_lowering,agc_tessellation_factor_ring9/9;main9a1d772cf168/8 on the same set without the GCN test. Every log that creates a device loads the layer, nowas not found, 0VUID-on either side.check_conventionsanddebt_fold.py --checkpass.6ab0c65dc21: merged #223288f95147aa32for MarcZX10's change request (hull with no LDS access):agc_driver_gcn_tessellationnow shows such a draw is refused withgraphics interfaces disagree at location 0 (stage 1 output missing, forhs_output_base0 and above the inputs. Windows 11, WinLibs GCC 15.2.0 r7, RTX 4080 SUPER,ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer(LunarG 1.4.363.1):request_serializer,agc_driver_register_key,agc_driver_gcn_tessellation,agc_driver_tessellation,agc_driver_tessellation_depth_range_remap,agc_driver_tessellation_geometry,agc_driver_graphics,agc_tessellation_lowering,agc_tessellation_factor_ring9/9 on #25489's merge of this head (6ab0c65dc21), 7 layer inserts, nowas not found, 0VUID-;main9a1d772cf168/8 on the same set earlier today.check_conventionsanddebt_fold.py --checkpass.GcnTessellation.cpponly (8f95147aa32...6ab0c65dc21). Windows 11, WinLibs GCC 15.2.0 r7, RTX 4080 SUPER, same validation settings:agc_driver_gcn_tessellationpasses on #22328 head84ed23f1d90with this test diff applied, fails at the second driver draw on that tree with a temporary control that reuses the firstReadTessellationConstantsresult, and passes on6ab0c65dc21. Each log has 2 layer inserts, nowas not found, 0VUID-(comment).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-22T05:42:30Z.
Review: COMMENTED
Reviewed — no blocking findings
The inspected changes show no verified blocking defect, but the review is incomplete because two changed test files were excluded and not all changed files were inspected.
What I ran
Reviewed head
27b7bb79370a19380a1d17ecbcd78ddffd50005eusing the prepared diff and pinned reader. No commands or tests were run.Results
Findings
Blocking
None verified in the inspected material.
Non-blocking
None.
Not verified
Read
description.md,commits.md,manifest.json, anddiff.patch; inspectedcore/libs/prx/libSceAgcDriver/tests/execution/GcnTessellation.cppand the changed tessellation-lowering implementation. The diff and manifest identify the other changed files, but their full contents were not all read.core/libs/prx/libSceAgcDriver/tests/Graphics.cppandcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppwere excluded from the review folder because they were too large; their changed hunks were visible in the prepared diff, but their full files were not reviewed. No build, test, validation-layer, or hardware behavior was independently confirmed.To get this to a good state
Nothing is required. Optional: complete review of the unread changed files before making a formal approval decision.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-27T20:37:10Z.
Review: COMMENTED
Actionable comments posted: 2
93650c55-9861-4c31-a3bd-ec0ec442917cReviewing files that changed from the base of the PR and between
ea49f32e89and993c3d4c14.core/libs/prx/libSceAgcDriver/Execution/include/Driver/Shaders/ShaderRegistry.hppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCapture.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawDecode.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawLookup.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawRegisterKey.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawRelocate.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderDiagnostics.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cppcore/libs/prx/libSceAgcDriver/Graphics/include/State.hppcore/libs/prx/libSceAgcDriver/Graphics/src/PipelineJournal.cppcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/execution/GcnTessellation.cppcore/shader/recompiler/CacheKey.hppcore/shader/recompiler/ControlFlow/src/RequestSerializer.cppcore/shader/recompiler/Optimization/include/Optimization/ShaderStageInputInfo.hppcore/shader/recompiler/Optimization/include/Optimization/TessellationLowering.hppcore/shader/recompiler/Optimization/src/TessellationLowering.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/Translation/src/InstructionTranslator.cppcore/shader/recompiler/Translation/src/ShaderInputInfoBuilder.cppcore/shader/recompiler/tests/RequestSerializerTests.cppdocs/dev/debt/changes/claude-gcn-ls-hs-vs-tessellation.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T20:42:16Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the review found no verified defects, and the reported hardware runs support merging.
What I ran
Reviewed head
993c3d4c1490c184cf5dd3f7b2e44e802951b1bdagainstmainfrom the prepared diff. Read the changed implementation and test hunks throughrepo_read.py; no tests or builds were run. The description reports Windows and NVIDIA/AMD test runs; those results were not independently reproduced here.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The full contents of
core/libs/prx/libSceAgcDriver/tests/Graphics.cppandcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppwere excluded as too large; their changed hunks were read. All other changed files listed in the manifest were included infiles/, but I did not read every full file: I inspected the diff hunks and targeted related code. I did not independently verify CI, reported hardware results, or console behavior.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-27T23:11:26Z.
Review: COMMENTED
Actionable comments posted: 1
382ee93e-a251-4a99-a175-b75bacb1d488Reviewing files that changed from the base of the PR and between
993c3d4c14and04bddfd765.core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawDecode.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cppcore/libs/prx/libSceAgcDriver/Graphics/include/State.hppcore/libs/prx/libSceAgcDriver/tests/RegisterKey.cppcore/libs/prx/libSceAgcDriver/tests/TessellationLowering.cppcore/libs/prx/libSceAgcDriver/tests/execution/GcnTessellation.cppcore/shader/recompiler/Optimization/src/TessellationLowering.cppdocs/dev/debt/changes/claude-gcn-ls-hs-vs-tessellation.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T06:28:50Z.
Review: COMMENTED
Reviewed — no blocking findings
The reviewed head is
eeda7e7cd82dbd529cb3deedd607ed7880a3c8af; targeted source review found no verified blocking defect, while two changed test files were excluded from the review folder and were not read.What I ran
Read the prepared description, commits, manifest, and diff. Used
repo_read.pyto inspect targeted source ranges and search references at the pinned head. No tests or builds were run; reported test results below are author supplied.Results
Findings
Blocking
None verified in the files read.
Non-blocking
None.
Not verified
Did not read
core/libs/prx/libSceAgcDriver/tests/Graphics.cpporcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp; both were marked excluded as too large in the manifest. Did not run tests, build, or validate the author reported GPU and validation layer results. The other 11 changed files were read at least in the relevant diff or source ranges; targeted review focused onDrawCapture.cpp,ShaderMemory.hpp,State.cpp,Draw.cpp,DrawDecode.cpp,DrawLookup.cpp,TessellationLowering.cpp, andRequestSerializer.cpp.To get this to a good state
Nothing is required. Optional: include the two excluded test files in a follow-up review for complete changed file coverage.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T17:24:46Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The on-chip lowering can leave domain-shader reads backed by unwritten hull outputs when the hull shader has no LDS accesses.
What I ran
Reviewed head
1ec7a550ffecb4ce3942181a40bc68434e1ca77a. Read the prepared description, commits, manifest, diff, and file list; usedrepo_read.pyto inspect targeted source context. No tests or builds were run.Results
Negative control
Not run; no test was run to confirm the defect.
Findings
Blocking
localStrideremains zero andpinConstants()leavespassthroughfalse. The later copy is therefore skipped, while the domain stage can still lower on-chip LDS reads to evaluation inputs. Those inputs have no hull-written values. Implement the required input-to-output copy or reject this case when domain reads require hull outputs. The change sets this condition atcore/shader/recompiler/Optimization/src/TessellationLowering.cpp:1662and gates the copy atcore/shader/recompiler/Optimization/src/TessellationLowering.cpp:882. Pinned sourceNon-blocking
None.
Sources
The finding is based on the pinned lowering implementation and its on-chip access rewriting in
TessellationLowering.cpp.Not verified
The prepared diff covers all 29 reviewed paths. Source context was read for
DrawCapture.cpp,Draw.cpp,DrawLookup.cpp,DrawDecode.cpp,CacheKey.hpp,PipelineJournal.cpp, andTessellationLowering.cpp; other changed-path behavior was not independently verified. The full text ofcore/libs/prx/libSceAgcDriver/tests/Graphics.cppwas omitted from the review folder, though its changed hunk was present in the diff. Author-reported test results were not independently confirmed.To get this to a good state
Implement the copy for a hull shader with no LDS accesses, or reject domain reads that would consume unwritten hull outputs. Add a test for that case and rerun the relevant tessellation tests on the new head.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-30T17:36:11Z.
Review: COMMENTED
Architecture findings (1)
Advisory architecture findings (1)
340ded9f-6616-4362-820d-6bc4147501b6Reviewing files that changed from the base of the PR and between
eeda7e7cd8and1ec7a550ff.core/libs/prx/libSceAgcDriver/Execution/include/ShaderMemory.hppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/include/State.hppcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/CacheKey.hppcore/shader/recompiler/Optimization/src/TessellationLowering.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/Translation/src/ShaderInputInfoBuilder.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-30T18:32:48Z.
Review: COMMENTED
Architecture findings (1)
Advisory architecture findings (1)
6e7e7651-6728-4e05-8f2a-e87e8673e880Reviewing files that changed from the base of the PR and between
1ec7a550ffand6ab0c65dc2.core/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/execution/GcnTessellation.cppcore/shader/recompiler/Optimization/src/TessellationLowering.cppdocs/dev/debt/changes/claude-gcn-ls-hs-vs-tessellation.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T18:39:47Z.
Review: APPROVED
Reviewed — looks good
The reviewed changes add GCN on-chip tessellation lowering and draw-time constant capture; the inspected code and reported validation support merging.
What I ran
Reviewed head
6ab0c65dc21c17f7f1b6eba896207c764bf39229; no merged-preview check was run. I inspected the prepared diff and manifest, then usedrepo_read.pyfor pinned source context. No build or tests were run in this review.Results
Negative control
Not run in this review. The PR body reports that temporary stale-constant and cached-draw changes caused the new driver test to fail at the expected draws.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
No local tests, builds, console runs, or hardware behavior were verified. The PR body supplies those test results. The diff and prepared file contents covered all 28 changed paths;
core/libs/prx/libSceAgcDriver/tests/Graphics.cppandcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppdid not have full text infiles/, so their changed hunks were reviewed from the prepared diff. No files were listed as excluded by rule.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T21:31:43Z.
Review: COMMENTED
The driver fixture keeps the V# and PM4 state the same across the 1, 0, 1 rewrites and flushes before reading the color pixels. That exercises the buffer-content dependency at the driver entry point. Please present the test-only diff and red/green result relative to the exact #22328 head. The comparison to
maincurrently includes production changes to tessellation lowering and cache serialization from that stack, so it cannot isolate the new regression. The paired tessellation test is queued on lavapipe.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.