refactor(agc): retain immutable draw plans and local stage work #1311

Closed
TibixDev wants to merge 3 commits from upstream-pr/1311 into main
TibixDev commented 2026-10-07 23:12:39 +00:00 (Migrated from github.com)

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


Status after review

Needs redesign and an isolated benefit after prepared shaders.

I checked the current materializeDrawStage/prepared-invocation path. The retained compile-result work in this branch targets the previous architecture and needs redesign, not conflict-marker cleanup. The existing 0.605 → 0.302 µs component result and combined-fork Skyrim run do not validate that redesign.

The concrete downstream dependency issue is now removed: #1312 and #1313 have been rebuilt directly on main without this branch. They no longer need this stack to land. This branch's compare still includes two inherited #494 shape-cache commits in addition to its own change; that work must be reconciled or removed before a replacement is proposed. No code push here until the remaining retained work has an isolated current-main benefit.

What

Reuse immutable draw plans when only live shader inputs change. Keep temporary stage work in local storage and retain compiled results through recording.

Tested

Earlier branch-specific tests and measurements remain in the discussion. They have not been rerun on a redesigned current-main version of this PR. The review audit and shared NGS-assisted title exploration do not establish that this head is merge-ready. No full Linux/Windows platform CI was dispatched in this pass.

Checklist

  • Current-main implementation and outstanding review requirements complete.
  • Isolated title benefit / reference validation established where required.
  • Depends on: #494 retained-shape work in the existing branch; redesign pending.
  • AI-assisted: yes.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4779601717 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1311). Originally posted by [TibixDev](https://github.com/TibixDev) on 2026-10-07T23:12:39Z. --- ### Status after review **Needs redesign and an isolated benefit after prepared shaders.** I checked the current `materializeDrawStage`/prepared-invocation path. The retained compile-result work in this branch targets the previous architecture and needs redesign, not conflict-marker cleanup. The existing 0.605 → 0.302 µs component result and combined-fork Skyrim run do not validate that redesign. The concrete downstream dependency issue is now removed: #1312 and #1313 have been rebuilt directly on main without this branch. They no longer need this stack to land. This branch's compare still includes two inherited #494 shape-cache commits in addition to its own change; that work must be reconciled or removed before a replacement is proposed. No code push here until the remaining retained work has an isolated current-main benefit. ### What Reuse immutable draw plans when only live shader inputs change. Keep temporary stage work in local storage and retain compiled results through recording. ### Tested Earlier branch-specific tests and measurements remain in the discussion. They have not been rerun on a redesigned current-main version of this PR. The review audit and shared NGS-assisted title exploration do not establish that this head is merge-ready. No full Linux/Windows platform CI was dispatched in this pass. ### Checklist - [ ] Current-main implementation and outstanding review requirements complete. - [ ] Isolated title benefit / reference validation established where required. - [x] Depends on: #494 retained-shape work in the existing branch; redesign pending. - [x] AI-assisted: yes.
TibixDev commented 2026-10-08 07:09:18 +00:00 (Migrated from github.com)

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


Rebased on c081eb90. Preserved merged #1134: non-indexed mesh draws use the null index descriptor. Adapted its simplified descriptor API to retained draw plans and kept the new graphics regression checks. The duplicate #493 prerequisite remains removed; #494 authorship is retained.

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

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6054566973 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1311#issuecomment-6054566973). Originally posted by [TibixDev](https://github.com/TibixDev) on 2026-10-08T07:09:18Z. --- Rebased on `c081eb90`. Preserved merged #1134: non-indexed mesh draws use the null index descriptor. Adapted its simplified descriptor API to retained draw plans and kept the new graphics regression checks. The duplicate #493 prerequisite remains removed; #494 authorship is retained. Fedora 44 Release: `agc_driver_draw_plan_tests`, `agc_driver_tests`, `agc_driver_graphics_tests`, `agc_driver_pm4_tests`, `agc_shader_memory_tests` build; the targeted tests and contribution checks pass. Windows CI is pending.
oneandonlydean commented 2026-10-09 09:21:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T09:21:58Z.


#639 replaced the draw path's compile step: compileDrawStage is now materializeDrawStage, built from invocations prepared at registration. This conflicts there, and the retained compile results need redoing on top of it. Please rebase onto current main (#1312 and #1313 follow), with numbers for this change alone against main.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6078115901 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1311#issuecomment-6078115901). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T09:21:58Z. --- #639 replaced the draw path's compile step: `compileDrawStage` is now `materializeDrawStage`, built from invocations prepared at registration. This conflicts there, and the retained compile results need redoing on top of it. Please rebase onto current main (#1312 and #1313 follow), with numbers for this change alone against main.
adriadam10 commented 2026-10-11 10:31:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T10:31:24Z.

Review: CHANGES_REQUESTED


Following up on the rebase request above: the branch conflicts with current main in CMakeLists.txt, DrawCache.hpp, Driver.hpp, Draw.cpp, DrawCache.cpp, DrawCapture.cpp and DrawDecode.cpp, because #639 moved shader compilation to registration.

  • The retained compile results and local stage work in Draw.cpp / DrawCapture.cpp sit on the old per-draw compile step. They need redoing on top of the prepared invocations from registration, not just a textual rebase.
  • Please post numbers for this change alone against main after that. The current ones (0.605 → 0.302 µs) are a component benchmark, not a draw, and the in-game Skyrim comparison was on a combined fork, not this branch.
  • The PR is stacked on #1191, #1193, #1201 and #1202, all still open, and carries #494's commits. It can't land before them; once they are in (or the dependency is dropped), please leave only this change in the branch.

Welcome to push the rebased version and we'll review it again.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5482959667 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1311#pullrequestreview-5482959667). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T10:31:24Z. **Review:** CHANGES_REQUESTED --- Following up on the rebase request above: the branch conflicts with current `main` in `CMakeLists.txt`, `DrawCache.hpp`, `Driver.hpp`, `Draw.cpp`, `DrawCache.cpp`, `DrawCapture.cpp` and `DrawDecode.cpp`, because #639 moved shader compilation to registration. - The retained compile results and local stage work in `Draw.cpp` / `DrawCapture.cpp` sit on the old per-draw compile step. They need redoing on top of the prepared invocations from registration, not just a textual rebase. - Please post numbers for this change alone against `main` after that. The current ones (0.605 → 0.302 µs) are a component benchmark, not a draw, and the in-game Skyrim comparison was on a combined fork, not this branch. - The PR is stacked on #1191, #1193, #1201 and #1202, all still open, and carries #494's commits. It can't land before them; once they are in (or the dependency is dropped), please leave only this change in the branch. Welcome to push the rebased version and we'll review it again.
TibixDev commented 2026-10-12 04:51:55 +00:00 (Migrated from github.com)

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


Review-pass update:

I checked the current materializeDrawStage/prepared-invocation path. The retained compile-result work in this branch targets the previous architecture and needs redesign, not conflict-marker cleanup. The existing 0.605 → 0.302 µs component result and combined-fork Skyrim run do not validate that redesign.

The concrete downstream dependency issue is now removed: #1312 and #1313 have been rebuilt directly on main without this branch. They no longer need this stack to land. This branch's compare still includes two inherited #494 shape-cache commits in addition to its own change; that work must be reconciled or removed before a replacement is proposed. No code push here until the remaining retained work has an isolated current-main benefit.

I have updated the PR description to match this status. The PR remains open; the outstanding review requirements are not being marked resolved. AI-assisted audit.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6117973952 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1311#issuecomment-6117973952). Originally posted by [TibixDev](https://github.com/TibixDev) on 2026-10-12T04:51:55Z. --- Review-pass update: I checked the current `materializeDrawStage`/prepared-invocation path. The retained compile-result work in this branch targets the previous architecture and needs redesign, not conflict-marker cleanup. The existing 0.605 → 0.302 µs component result and combined-fork Skyrim run do not validate that redesign. The concrete downstream dependency issue is now removed: #1312 and #1313 have been rebuilt directly on main without this branch. They no longer need this stack to land. This branch's compare still includes two inherited #494 shape-cache commits in addition to its own change; that work must be reconciled or removed before a replacement is proposed. No code push here until the remaining retained work has an isolated current-main benefit. I have updated the PR description to match this status. The PR remains open; the outstanding review requirements are not being marked resolved. AI-assisted audit.
eliyarson commented 2026-10-13 22:04:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by eliyarson on 2026-10-13T22:04:00Z.


Notes from a related experiment, in case they help with the "isolated benefit on current main" requirement. Nothing here is a review of the code.

Scene: Hades II hub, Linux, RTX 3080 Ti, main 665ad7da7, APS5_TRACE_SECONDS=150:30, game log not redirected to a file. Two captures of main give frame p50 34.7 ms and 33.2 ms (28.9 and 30.1 FPS); queue worker 0x0 is busy 98.7 % in both, so the single worker is what limits the scene. In the earlier capture on a0f5916a2 (Driver.Packet 34.3 ms per frame) the digest lists Driver.Draw.shader_compile_and_link at 14.0 ms, Graphics.Draw.draw_and_resource_release at 10.3 ms and Shader.DrawStage at 9.7 ms per frame. If the redesign removes the per-stage RecompileResult copy and the per-draw heap vectors, that scene and shader_compile_and_link are where its effect should show up in a trace pair.

I had the same two cuts (no RecompileResult copy per captured stage, inline per-program arrays) in a local branch and dropped them so as not to implement the same functions as this PR. The ShaderMemory run-scan cuts do not overlap and are a separate small PR. Run-to-run spread on this machine is about 4 % between identical main captures, so a gain under that needs repeats before it counts.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6156151775 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1311#issuecomment-6156151775). Originally posted by [eliyarson](https://github.com/eliyarson) on 2026-10-13T22:04:00Z. --- Notes from a related experiment, in case they help with the "isolated benefit on current main" requirement. Nothing here is a review of the code. Scene: Hades II hub, Linux, RTX 3080 Ti, `main` 665ad7da7, `APS5_TRACE_SECONDS=150:30`, game log not redirected to a file. Two captures of `main` give frame p50 34.7 ms and 33.2 ms (28.9 and 30.1 FPS); `queue worker 0x0` is busy 98.7 % in both, so the single worker is what limits the scene. In the earlier capture on `a0f5916a2` (`Driver.Packet` 34.3 ms per frame) the digest lists `Driver.Draw.shader_compile_and_link` at 14.0 ms, `Graphics.Draw.draw_and_resource_release` at 10.3 ms and `Shader.DrawStage` at 9.7 ms per frame. If the redesign removes the per-stage `RecompileResult` copy and the per-draw heap vectors, that scene and `shader_compile_and_link` are where its effect should show up in a trace pair. I had the same two cuts (no `RecompileResult` copy per captured stage, inline per-program arrays) in a local branch and dropped them so as not to implement the same functions as this PR. The `ShaderMemory` run-scan cuts do not overlap and are a separate small PR. Run-to-run spread on this machine is about 4 % between identical `main` captures, so a gain under that needs repeats before it counts.
oneandonlydean commented 2026-10-14 05:16:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T05:16:39Z.


Closing for now: it's parked for a redesign and conflicts with main, and the review points from 10-11 are still open. eliyarson's Hades II note above says where the gain should show (Driver.Draw.shader_compile_and_link with the worker at ~99 %); reopen with a trace pair from that scene if you pick it up again. Thanks @eliyarson.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6161461858 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1311#issuecomment-6161461858). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T05:16:39Z. --- Closing for now: it's parked for a redesign and conflicts with main, and the review points from 10-11 are still open. eliyarson's Hades II note above says where the gain should show (`Driver.Draw.shader_compile_and_link` with the worker at ~99 %); reopen with a trace pair from that scene if you pick it up again. Thanks @eliyarson.

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!1311
No description provided.