perf(graphics): retain vertex descriptor decode plans #1313

Closed
TibixDev wants to merge 1 commit from upstream-pr/1313 into main
TibixDev commented 2026-10-07 23:17:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TibixDev on 2026-10-07T23:17:12Z.


What

Retain immutable vertex semantic/read plans in the current draw decode. Read live attribute and buffer tables on each use, coalescing only adjacent referenced words. Preserve original semantic ordering, duplicate semantics, format overrides and exact guest-read coverage.

Rebuilt directly on main d146ec1b6, dropping #1311 and the old draw-plan stack. Preserve current raw-header handling, the short user-data header ABI, static preparation, and merged-stage hidden user words.

Tested

Fedora 44, GCC 16.2.1, Release:

  • Vertex-stage, PM4, graphics and prepared-graphics CTests pass in 3.20 seconds. Graphics uses RX 6600 RADV core/synchronization validation.
  • Fixtures cover changed roots/descriptors, immutable header ownership, duplicate/reordered semantics, all 32 descriptors, exact read coverage, guard-page boundaries, concurrent readers, static ABI with no guest reads and merged-stage hidden user words.
  • Same-binary benchmark using process CPU time against the exact decoder extracted from main, with identical live-table mutations and read tracking. Six alternating runs per mode, pinned CPU, 100,000 calls/case. For 1/4/16/32 semantics: main medians 0.152/0.465/1.812/3.162 µs; retained plan 0.113/0.121/0.149/0.195 µs; rebuilding the plan every call 0.149/0.197/0.277/0.346 µs. Checksums match. The one-semantic cold result is within measurement noise; these component figures do not establish title frame-time gains.
  • Conventions and diff checks pass.

No new isolated in-game performance result or Windows test. Full Linux/Windows PR CI requires the collaborator-dispatched workflow.

Checklist

  • Based on main; related work checked.
  • One topic.
  • No new code comments.
  • Unsupported paths still throw.
  • No notes, logs, images or third-party additions in the repository.
  • General behavior.
  • Depends on: none.
  • AI-assisted: yes.

Verified title integration

Verified runtime smoke test: a freshly NID-patched #1313 library (c1eaeb47f2a8cb515aa7a8b818012322a2702928d309c38a5877f55c8f91f6bd) differs from main and contains VertexStagePlan; /proc confirms that the game loaded it. With the identical experimental NGS dependency and APS5_VERIFY_DRAW_RECIPE=1, a 120-second Skyrim run reached the PRESS ANY BUTTON screen. The log reports 3,064 decode comparisons with zero differences and no unexpected exception. It ended at the imposed timeout (124). This is a correctness smoke test, not a title-performance or full-gameplay result.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4779637563 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1313). Originally posted by [TibixDev](https://github.com/TibixDev) on 2026-10-07T23:17:12Z. --- ### What Retain immutable vertex semantic/read plans in the current draw decode. Read live attribute and buffer tables on each use, coalescing only adjacent referenced words. Preserve original semantic ordering, duplicate semantics, format overrides and exact guest-read coverage. Rebuilt directly on main `d146ec1b6`, dropping #1311 and the old draw-plan stack. Preserve current raw-header handling, the short user-data header ABI, static preparation, and merged-stage hidden user words. ### Tested Fedora 44, GCC 16.2.1, Release: - Vertex-stage, PM4, graphics and prepared-graphics CTests pass in 3.20 seconds. Graphics uses RX 6600 RADV core/synchronization validation. - Fixtures cover changed roots/descriptors, immutable header ownership, duplicate/reordered semantics, all 32 descriptors, exact read coverage, guard-page boundaries, concurrent readers, static ABI with no guest reads and merged-stage hidden user words. - Same-binary benchmark using process CPU time against the exact decoder extracted from main, with identical live-table mutations and read tracking. Six alternating runs per mode, pinned CPU, 100,000 calls/case. For 1/4/16/32 semantics: main medians 0.152/0.465/1.812/3.162 µs; retained plan 0.113/0.121/0.149/0.195 µs; rebuilding the plan every call 0.149/0.197/0.277/0.346 µs. Checksums match. The one-semantic cold result is within measurement noise; these component figures do not establish title frame-time gains. - Conventions and diff checks pass. No new isolated in-game performance result or Windows test. Full Linux/Windows PR CI requires the collaborator-dispatched workflow. ### Checklist - [x] Based on main; related work checked. - [x] One topic. - [x] No new code comments. - [x] Unsupported paths still throw. - [x] No notes, logs, images or third-party additions in the repository. - [x] General behavior. - [x] Depends on: none. - [x] AI-assisted: yes. ### Verified title integration Verified runtime smoke test: a freshly NID-patched #1313 library (`c1eaeb47f2a8cb515aa7a8b818012322a2702928d309c38a5877f55c8f91f6bd`) differs from main and contains `VertexStagePlan`; `/proc` confirms that the game loaded it. With the identical experimental NGS dependency and `APS5_VERIFY_DRAW_RECIPE=1`, a 120-second Skyrim run reached the PRESS ANY BUTTON screen. The log reports 3,064 decode comparisons with zero differences and no unexpected exception. It ended at the imposed timeout (124). This is a correctness smoke test, not a title-performance or full-gameplay result.
TibixDev commented 2026-10-08 07:12:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TibixDev on 2026-10-08T07:12:03Z.


Rebased on c081eb90. Updated #1311 after #1134 merged. Non-indexed mesh draws retain the upstream null index descriptor; retained plans and their invalidation coverage remain intact.

Fedora 44 Release: agc_vertex_stage_tests, agc_driver_draw_plan_tests, agc_driver_tests, agc_driver_graphics_tests, agc_driver_pm4_tests build; the targeted tests and contribution checks pass. Windows CI is pending.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6054618121 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1313#issuecomment-6054618121). Originally posted by [TibixDev](https://github.com/TibixDev) on 2026-10-08T07:12:03Z. --- Rebased on `c081eb90`. Updated #1311 after #1134 merged. Non-indexed mesh draws retain the upstream null index descriptor; retained plans and their invalidation coverage remain intact. Fedora 44 Release: `agc_vertex_stage_tests`, `agc_driver_draw_plan_tests`, `agc_driver_tests`, `agc_driver_graphics_tests`, `agc_driver_pm4_tests` build; the targeted tests and contribution checks pass. Windows CI is pending.
adriadam10 commented 2026-10-11 11:39:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T11:39:05Z.

Review: CHANGES_REQUESTED


Thanks for the work here. As it stands this can't land:

  • It conflicts with main in 10 files (DrawCache.hpp/.cpp, DrawCacheStatistics.cpp, DrawCapture.cpp, DrawDecode.cpp, Draw.cpp, Driver.hpp, ShaderInputState.hpp/.cpp, CMakeLists.txt), mostly because of #639: compileDrawStage is now materializeDrawStage, built from invocations prepared at registration.
  • It is stacked on #1311 (and through it on #1191/#1193/#1201/#1202/#1312), which oneandonlydean already asked to rebase onto current main (comment on #1311, 2026-10-09). This PR has to follow once the base is redone.
  • The numbers (0.89 → 0.52 µs/call, reads 1,852 → 570) come from a combined fork, not from this change alone against main. Please re-measure with this PR alone on top of current main.

Once the base is rebased, please rebase this one on top of it, rerun agc_vertex_stage_tests / agc_driver_draw_plan_tests and post the before/after for the vertex-plan commit only.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5483157560 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1313#pullrequestreview-5483157560). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T11:39:05Z. **Review:** CHANGES_REQUESTED --- Thanks for the work here. As it stands this can't land: - It conflicts with `main` in 10 files (`DrawCache.hpp/.cpp`, `DrawCacheStatistics.cpp`, `DrawCapture.cpp`, `DrawDecode.cpp`, `Draw.cpp`, `Driver.hpp`, `ShaderInputState.hpp/.cpp`, `CMakeLists.txt`), mostly because of #639: `compileDrawStage` is now `materializeDrawStage`, built from invocations prepared at registration. - It is stacked on #1311 (and through it on #1191/#1193/#1201/#1202/#1312), which oneandonlydean already asked to rebase onto current `main` (comment on #1311, 2026-10-09). This PR has to follow once the base is redone. - The numbers (0.89 → 0.52 µs/call, reads 1,852 → 570) come from a combined fork, not from this change alone against `main`. Please re-measure with this PR alone on top of current `main`. Once the base is rebased, please rebase this one on top of it, rerun `agc_vertex_stage_tests` / `agc_driver_draw_plan_tests` and post the before/after for the vertex-plan commit only.
TibixDev commented 2026-10-12 04:50:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TibixDev on 2026-10-12T04:50:40Z.


Rebuilt this on main d146ec1b6 in 726ad7632, without #1311 or its old draw-plan API. The retained plan now belongs to the existing draw decode. It preserves the current short-header ABI, raw shaders, static prepared invocations and hidden user words for merged stages.

Vertex-stage, PM4, graphics and prepared-graphics tests pass; graphics runs with RADV core/synchronization validation. Added static-ABI/no-read and hidden-user-word coverage to the existing mutation, guard-page, ownership and concurrent-reader cases.

Isolated CPU measurements compare main's exact decoder with the retained plan and with rebuilding a plan on every call. Six alternating runs/mode, live table changes, read tracking and matching checksums: for 1/4/16/32 semantics, main 0.152/0.465/1.812/3.162 µs, retained 0.113/0.121/0.149/0.195 µs, cold 0.149/0.197/0.277/0.346 µs. The single-semantic cold case is inconclusive. These are component results, not a title FPS claim.

The seven-file branch is ready for another code review; title benefit and full platform CI remain separate outstanding validation. AI-assisted update.

Verified runtime smoke test: a freshly NID-patched #1313 library (c1eaeb47f2a8cb515aa7a8b818012322a2702928d309c38a5877f55c8f91f6bd) differs from main and contains VertexStagePlan; /proc confirms that the game loaded it. With the identical experimental NGS dependency and APS5_VERIFY_DRAW_RECIPE=1, a 120-second Skyrim run reached the PRESS ANY BUTTON screen. The log reports 3,064 decode comparisons with zero differences and no unexpected exception. It ended at the imposed timeout (124). This is a correctness smoke test, not a title-performance or full-gameplay result.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6117962621 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1313#issuecomment-6117962621). Originally posted by [TibixDev](https://github.com/TibixDev) on 2026-10-12T04:50:40Z. --- Rebuilt this on main `d146ec1b6` in `726ad7632`, without #1311 or its old draw-plan API. The retained plan now belongs to the existing draw decode. It preserves the current short-header ABI, raw shaders, static prepared invocations and hidden user words for merged stages. Vertex-stage, PM4, graphics and prepared-graphics tests pass; graphics runs with RADV core/synchronization validation. Added static-ABI/no-read and hidden-user-word coverage to the existing mutation, guard-page, ownership and concurrent-reader cases. Isolated CPU measurements compare main's exact decoder with the retained plan and with rebuilding a plan on every call. Six alternating runs/mode, live table changes, read tracking and matching checksums: for 1/4/16/32 semantics, main 0.152/0.465/1.812/3.162 µs, retained 0.113/0.121/0.149/0.195 µs, cold 0.149/0.197/0.277/0.346 µs. The single-semantic cold case is inconclusive. These are component results, not a title FPS claim. The seven-file branch is ready for another code review; title benefit and full platform CI remain separate outstanding validation. AI-assisted update. Verified runtime smoke test: a freshly NID-patched #1313 library (`c1eaeb47f2a8cb515aa7a8b818012322a2702928d309c38a5877f55c8f91f6bd`) differs from main and contains `VertexStagePlan`; `/proc` confirms that the game loaded it. With the identical experimental NGS dependency and `APS5_VERIFY_DRAW_RECIPE=1`, a 120-second Skyrim run reached the PRESS ANY BUTTON screen. The log reports 3,064 decode comparisons with zero differences and no unexpected exception. It ended at the imposed timeout (124). This is a correctness smoke test, not a title-performance or full-gameplay result.
adriadam10 commented 2026-10-13 09:08:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T09:08:10Z.

Review: APPROVED


Rebased on current main (one adjacent-line conflict in Draw.cpp with the paClVsOutCntl line, kept both). Checked on the rebased tree: build and the libSceAgcDriver/libSceAgc ctest scope pass, including agc_vertex_stage. The new test does not compile without the change, and swapping the buffer index in VertexStagePlan::Read makes it fail ("changed descriptor or root was not read"). The only failing test here, agc_driver_tessellation, crashes inside RADV's pipeline link on this host and does so on unrelated PRs too. Merging once the full Build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5501248292 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1313#pullrequestreview-5501248292). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-13T09:08:10Z. **Review:** APPROVED --- Rebased on current `main` (one adjacent-line conflict in `Draw.cpp` with the `paClVsOutCntl` line, kept both). Checked on the rebased tree: build and the libSceAgcDriver/libSceAgc ctest scope pass, including `agc_vertex_stage`. The new test does not compile without the change, and swapping the buffer index in `VertexStagePlan::Read` makes it fail ("changed descriptor or root was not read"). The only failing test here, `agc_driver_tessellation`, crashes inside RADV's pipeline link on this host and does so on unrelated PRs too. Merging once the full Build is green.
adriadam10 commented 2026-10-13 10:41:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T10:41:43Z.

Review: CHANGES_REQUESTED


The full Build (windows job) fails on this head: agc_vertex_stage exits with 0xc0000135 (DLL not found) because the test links libc but its ctest entry does not put libc's directory on PATH. Please add, inside the if(BUILD_TESTING) block of agc_vertex_stage_tests in core/libs/prx/libSceAgcDriver/CMakeLists.txt, the same thing the neighbouring tests do:

if(WIN32)
    set_tests_properties(agc_vertex_stage PROPERTIES ENVIRONMENT_MODIFICATION
        "PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()

main also moved: Draw.cpp now conflicts on the paClVsOutCntl line (keep vertexInputs->Read(...) and main's | graphics.layerExports). Please rebase and push; the rest of the diff looked fine on review (new test fails without the change).

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5502302230 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1313#pullrequestreview-5502302230). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-13T10:41:43Z. **Review:** CHANGES_REQUESTED --- The full Build (windows job) fails on this head: `agc_vertex_stage` exits with `0xc0000135` (DLL not found) because the test links `libc` but its ctest entry does not put `libc`'s directory on `PATH`. Please add, inside the `if(BUILD_TESTING)` block of `agc_vertex_stage_tests` in `core/libs/prx/libSceAgcDriver/CMakeLists.txt`, the same thing the neighbouring tests do: ```cmake if(WIN32) set_tests_properties(agc_vertex_stage PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>") endif() ``` `main` also moved: `Draw.cpp` now conflicts on the `paClVsOutCntl` line (keep `vertexInputs->Read(...)` and main's `| graphics.layerExports`). Please rebase and push; the rest of the diff looked fine on review (new test fails without the change).
gunerky commented 2026-10-13 20:46:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gunerky on 2026-10-13T20:46:46Z.


Additional Windows integration and boundary-test evidence for PR head bff970af554a1e928d476e55f217562c36262702, combined locally with main 0aa4cb1c2f2f8936f3985f905697b0070f1f7305. No commit or branch history was rewritten.

The single Draw.cpp conflict was resolved retaining both program.vertexInputs->Read(...) and main's | graphics.layerExports. I applied the requested Windows CTest PATH property and extended the existing Linux-only guardBoundary() fixture to Windows with VirtualAlloc, VirtualProtect(PAGE_NOACCESS) and VirtualFree. This tests a descriptor at the last 16 bytes and an attribute at the last 4 bytes of a readable page, followed by an inaccessible page.

Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0, Python 3.12.14, Ninja Release, BUILD_TESTING=ON, Windows-default SPIRV-Tools OFF, offscreen VideoOut. Graphics tests ran on NVIDIA GeForce RTX 3060, WMI driver 32.0.16.1742.

  • Full Windows build and libs: passed. The runtime libraries were built afresh; the guard probe records libc.prx and libSceAgcDriver.prx loaded from this new build directory.
  • Actual agc_vertex_stage CTest: 3/3, test times 0.16, 0.03, 0.03 seconds; its 30-second timeout is unchanged.
  • A guard-only probe passes. Separate temporary extra-byte attribute and descriptor read mutants are both rejected. Decoder bytes were restored exactly and the original runtime rebuilt; the clean probe passes again. No mutant remains.
  • Conventions against the stated main, test registration (787 executables, none unregistered), and whitespace checks pass.

Full CTest used --parallel 4 --timeout 120, preserving the existing per-test timeouts. The first integration at main dacd78525e537a779682032c0ace7f7af120af05 passed 1091/1098 with seven skips. After incorporating the unrelated NGS2/PosixForWebKit main updates, one full run passed 1091/1099 with seven skips and failed savedata_memory_metadata: std::filesystem::remove_all reported Access denied on its temporary cleanup directory and the process aborted (0xc0000409). That test then passed three serial retries. Full-suite recheck without source changes: 1092/1099 passed, 7 skipped, 0 failed. The failed run is preserved; the cleanup cause is not established or fixed here. The test's imports and changed-file scope show no AGC runtime/code dependency.

The follow-up delta is only the CTest environment property and Windows test-platform branch; the retained-plan implementation remains the PR author's work. The GitHub branch still requires the author's rebase/update. Linux/macOS, PS5 and games: not tested. No title-performance claim is made. AI-assisted: yes, local integration, test-platform adaptation and validation assisted by Codex.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6154870706 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1313#issuecomment-6154870706). Originally posted by [gunerky](https://github.com/gunerky) on 2026-10-13T20:46:46Z. --- Additional Windows integration and boundary-test evidence for PR head `bff970af554a1e928d476e55f217562c36262702`, combined locally with main `0aa4cb1c2f2f8936f3985f905697b0070f1f7305`. No commit or branch history was rewritten. The single `Draw.cpp` conflict was resolved retaining both `program.vertexInputs->Read(...)` and main's `| graphics.layerExports`. I applied the requested Windows CTest PATH property and extended the existing Linux-only `guardBoundary()` fixture to Windows with `VirtualAlloc`, `VirtualProtect(PAGE_NOACCESS)` and `VirtualFree`. This tests a descriptor at the last 16 bytes and an attribute at the last 4 bytes of a readable page, followed by an inaccessible page. Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0, Python 3.12.14, Ninja Release, `BUILD_TESTING=ON`, Windows-default SPIRV-Tools OFF, offscreen VideoOut. Graphics tests ran on NVIDIA GeForce RTX 3060, WMI driver 32.0.16.1742. - Full Windows build and `libs`: passed. The runtime libraries were built afresh; the guard probe records `libc.prx` and `libSceAgcDriver.prx` loaded from this new build directory. - Actual `agc_vertex_stage` CTest: 3/3, test times 0.16, 0.03, 0.03 seconds; its 30-second timeout is unchanged. - A guard-only probe passes. Separate temporary extra-byte attribute and descriptor read mutants are both rejected. Decoder bytes were restored exactly and the original runtime rebuilt; the clean probe passes again. No mutant remains. - Conventions against the stated main, test registration (787 executables, none unregistered), and whitespace checks pass. Full CTest used `--parallel 4 --timeout 120`, preserving the existing per-test timeouts. The first integration at main `dacd78525e537a779682032c0ace7f7af120af05` passed 1091/1098 with seven skips. After incorporating the unrelated NGS2/PosixForWebKit main updates, one full run passed 1091/1099 with seven skips and failed `savedata_memory_metadata`: `std::filesystem::remove_all` reported Access denied on its temporary cleanup directory and the process aborted (`0xc0000409`). That test then passed three serial retries. Full-suite recheck without source changes: 1092/1099 passed, 7 skipped, 0 failed. The failed run is preserved; the cleanup cause is not established or fixed here. The test's imports and changed-file scope show no AGC runtime/code dependency. The follow-up delta is only the CTest environment property and Windows test-platform branch; the retained-plan implementation remains the PR author's work. The GitHub branch still requires the author's rebase/update. Linux/macOS, PS5 and games: not tested. No title-performance claim is made. AI-assisted: yes, local integration, test-platform adaptation and validation assisted by Codex.
oneandonlydean commented 2026-10-14 06:23:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T06:23:45Z.


Closing for now: adriadam10's review from 10-13 (Windows PATH fix, the Draw.cpp rebase) is unanswered, it conflicts with main and the last full build is red on Windows. Reopen with those addressed and before/after numbers from a title scene if you pick it up again.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6162289071 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1313#issuecomment-6162289071). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T06:23:45Z. --- Closing for now: adriadam10's review from 10-13 (Windows PATH fix, the Draw.cpp rebase) is unanswered, it conflicts with main and the last full build is red on Windows. Reopen with those addressed and before/after numbers from a title scene if you pick it up again.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!1313
No description provided.