fix(agc): mark a draw's validate, index and vertex trace stages where they end #14857

Merged
JJenkx merged 1 commit from upstream-pr/14857 into main 2026-11-03 05:10:44 +00:00
JJenkx commented 2026-11-01 20:43:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-11-01T20:43:29Z.


What

Graphics::Draw's trace stages put the time of the index and vertex uploads under validate.

prepareDraw marked validate only after prepareDrawInputs had returned. That function does three things:

  • validates the draw;
  • copies the index buffer and finds its highest index;
  • uploads the vertex buffers.

The code then marked index_upload immediately after validate, so index_upload was always zero-length and never appeared in the trace. In a Goat Simulator 3 (PPSA04158) trace on main 8f55414024, Graphics.Draw.validate totals 1057 ms over the 4 s window, about 50 ms per frame, and Graphics.Draw.index_upload has no events.

prepareDrawInputs now receives the draw's PerformanceTimer and marks each stage where its DrawTimer phase ends:

  • validate at PhaseValidate;
  • index_upload when index validation ends;
  • a new vertex_upload stage at PhaseVertex.

The recipe path (Graphics.DrawWithRecipe) gets the same split. Before this change it recorded only draw_and_resource_release. A draw that returns with inputs.nothing after completing validation now records validate before returning; it records no index or vertex upload stages for work it does not perform.

No behaviour change outside the trace: the draw does the same work in the same order.

Tested

Windows 11 (10.0.22621), AMD Ryzen 9 5950X, AMD Radeon RX 6700 XT, AMD proprietary driver 26.10.1, GCC 15.2.0 UCRT r7, Release.

  • Goat Simulator 3 (PPSA04158), 3840x2160. Same scripted pad input, APS5_TRACE_SECONDS=600:4, and no other trace or profile switch. Draw-stage totals over the 4 s window:

    build Graphics.Draw validate index_upload vertex_upload draw_and_resource_release
    main 8f55414024, run 1 2318 ms (26584) 1057 ms (6944) none n/a 1059 ms
    main 8f55414024, run 2 2674 ms (21744) 857 ms (5648) none n/a 1662 ms
    this change, on 620449652e 2513 ms (30505) 0.02 ms (1) 2.0 ms (84) 1071 ms (6698) 1181 ms
    • On main, the time labelled validate is almost all vertex upload: about 160 µs per draw that uploads vertices. Validation itself is negligible.
    • Index upload is about 24 µs, and only for the few draws that copy an index buffer.
    • This change is attribution only and makes no speed claim. The candidate run's frame time (p50 197 ms) is within the spread of the two main runs (186 ms and 239 ms).
    • Its base differs from the main runs. The rebase onto current main e0caf13600 applied with no conflicts and was rebuilt.
  • Registered tests. On the rebased branch, ctest -R "^agc_.*(draw|perf|trace)" passes 89/89. On 67b98fb4af, the full AGC Vulkan GPU suite with VVL 1.4.363 gives 830/831. The one failure, agc_driver_sample_order_grid_reference, also fails on main on this machine. The VUID set is identical to main.

  • Later Linux qualification: main 0580e5c951a8d436af2976a3f86a980c798ef5c2 and same main plus this PR (34af4558ba68d5ae80caae14ffc2b0d941852da1) each passed the same 89 focused draw/performance/trace tests, with zero skips or VUID IDs and actual Khronos layer insertion on RX 6650 XT / RADV Mesa 26.2.6. Pinned paired evidence; no Linux title trace or speed claim.

  • Not run: macOS; other titles.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: AMD Radeon RX 6700 XT, AMD proprietary driver 26.10.1, Windows 11 10.0.22621
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5111382557 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14857). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-11-01T20:43:29Z. --- ### What `Graphics::Draw`'s trace stages put the time of the index and vertex uploads under `validate`. `prepareDraw` marked `validate` only after `prepareDrawInputs` had returned. That function does three things: - validates the draw; - copies the index buffer and finds its highest index; - uploads the vertex buffers. The code then marked `index_upload` immediately after `validate`, so `index_upload` was always zero-length and never appeared in the trace. In a Goat Simulator 3 (PPSA04158) trace on `main` `8f55414024`, `Graphics.Draw.validate` totals 1057 ms over the 4 s window, about 50 ms per frame, and `Graphics.Draw.index_upload` has no events. `prepareDrawInputs` now receives the draw's `PerformanceTimer` and marks each stage where its `DrawTimer` phase ends: - `validate` at `PhaseValidate`; - `index_upload` when index validation ends; - a new `vertex_upload` stage at `PhaseVertex`. The recipe path (`Graphics.DrawWithRecipe`) gets the same split. Before this change it recorded only `draw_and_resource_release`. A draw that returns with `inputs.nothing` after completing validation now records `validate` before returning; it records no index or vertex upload stages for work it does not perform. No behaviour change outside the trace: the draw does the same work in the same order. ### Tested Windows 11 (10.0.22621), AMD Ryzen 9 5950X, AMD Radeon RX 6700 XT, AMD proprietary driver 26.10.1, GCC 15.2.0 UCRT r7, Release. - **Goat Simulator 3 (PPSA04158), 3840x2160.** Same scripted pad input, `APS5_TRACE_SECONDS=600:4`, and no other trace or profile switch. Draw-stage totals over the 4 s window: | build | `Graphics.Draw` | `validate` | `index_upload` | `vertex_upload` | `draw_and_resource_release` | |---|---|---|---|---|---| | `main` `8f55414024`, run 1 | 2318 ms (26584) | 1057 ms (6944) | none | n/a | 1059 ms | | `main` `8f55414024`, run 2 | 2674 ms (21744) | 857 ms (5648) | none | n/a | 1662 ms | | this change, on `620449652e` | 2513 ms (30505) | 0.02 ms (1) | 2.0 ms (84) | 1071 ms (6698) | 1181 ms | - On `main`, the time labelled `validate` is almost all vertex upload: about 160 µs per draw that uploads vertices. Validation itself is negligible. - Index upload is about 24 µs, and only for the few draws that copy an index buffer. - This change is attribution only and makes no speed claim. The candidate run's frame time (p50 197 ms) is within the spread of the two `main` runs (186 ms and 239 ms). - Its base differs from the `main` runs. The rebase onto current `main` `e0caf13600` applied with no conflicts and was rebuilt. - **Registered tests.** On the rebased branch, `ctest -R "^agc_.*(draw|perf|trace)"` passes 89/89. On `67b98fb4af`, the full AGC Vulkan GPU suite with VVL 1.4.363 gives 830/831. The one failure, `agc_driver_sample_order_grid_reference`, also fails on `main` on this machine. The VUID set is identical to `main`. - **Later Linux qualification:** main `0580e5c951a8d436af2976a3f86a980c798ef5c2` and same main plus this PR (`34af4558ba68d5ae80caae14ffc2b0d941852da1`) each passed the same 89 focused draw/performance/trace tests, with zero skips or VUID IDs and actual Khronos layer insertion on RX 6650 XT / RADV Mesa 26.2.6. [Pinned paired evidence](https://github.com/boykopovar/AnyPS5/pull/14857#issuecomment-6564840437); no Linux title trace or speed claim. - **Not run:** macOS; other titles. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: AMD Radeon RX 6700 XT, AMD proprietary driver 26.10.1, Windows 11 10.0.22621 - [x] AI-assisted: yes
BunnyFl commented 2026-11-02 01:27:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-02T01:27:28Z.

Review: APPROVED


Windows 11, WinLibs GCC 15.2.0 r7, Release, AMD Radeon RX 9070 XT (driver 32.0.32015.7029), Vulkan SDK 1.4.363 validation layer. Head 019e4e00eb merged into upstream/main 93dbd0f82a, and main 93dbd0f82a, built the same way. Same tests on both, with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest -V:

test main this PR
agc_driver_graphics Passed Passed
agc_driver_draw_offset_indices Passed Passed
agc_driver_pixel_ancillary_word Passed Passed

Neither log contains the missing-layer message, and neither has any VUID- or SYNC-HAZARD ID. The built library contains the index_upload and vertex_upload stage names. I didn't capture a title trace, so the stage split itself is checked by reading only.

Read against main: both callers now pass the timer, and the two marks prepareDraw made after prepareDrawInputs returned are gone, so nothing is marked twice. One difference worth stating in the PR: the recipe path (prepareDrawInputs(..., &recipe), ~Draw.cpp:3787) made no marks before. Its validate, index and vertex time now appears under those stages too, instead of under whatever stage came next. Also, a draw that returns early with inputs.nothing after validation now records a validate mark. Both seem like what you want.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5731234092 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14857#pullrequestreview-5731234092). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-02T01:27:28Z. **Review:** APPROVED --- Windows 11, WinLibs GCC 15.2.0 r7, Release, AMD Radeon RX 9070 XT (driver 32.0.32015.7029), Vulkan SDK 1.4.363 validation layer. Head 019e4e00eb merged into upstream/main 93dbd0f82a, and main 93dbd0f82a, built the same way. Same tests on both, with `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest -V`: | test | main | this PR | |---|---|---| | `agc_driver_graphics` | Passed | Passed | | `agc_driver_draw_offset_indices` | Passed | Passed | | `agc_driver_pixel_ancillary_word` | Passed | Passed | Neither log contains the missing-layer message, and neither has any `VUID-` or `SYNC-HAZARD` ID. The built library contains the `index_upload` and `vertex_upload` stage names. I didn't capture a title trace, so the stage split itself is checked by reading only. Read against main: both callers now pass the timer, and the two marks `prepareDraw` made after `prepareDrawInputs` returned are gone, so nothing is marked twice. One difference worth stating in the PR: the recipe path (`prepareDrawInputs(..., &recipe)`, ~Draw.cpp:3787) made no marks before. Its validate, index and vertex time now appears under those stages too, instead of under whatever stage came next. Also, a draw that returns early with `inputs.nothing` after validation now records a `validate` mark. Both seem like what you want.
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!14857
No description provided.