feat(agc): count why draws begin render passes #11361

Merged
johandavidcm merged 1 commit from upstream-pr/11361 into main 2026-10-28 04:25:04 +00:00
johandavidcm commented 2026-10-26 08:29:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by johandavidcm on 2026-10-26T08:29:08Z.


What

The [draws] line counts how many render passes the recorded draws began and how many continued the open one, not why a draw could not continue. Yakuza 0 Director's Cut (PPSA31327) records about 1,000 passes per frame, one every 8 draws; each break costs the pass's attachment store and load and two ALL_COMMANDS barriers (the pass end, the next pass's leading barrier), and which of those breaks a change could avoid is not visible in any line today.

  • Recorder::StartDrawPass returns why the draw begins a pass (PassBreak, next to PassHazard in PassHazards.hpp): the batch is new (the first draw of a batch, also after a submit), a non-draw command, a label store, the sample counter or a sample segment closed the previous pass, the draw asked for a pass of its own (forced), the pass key differs, or one of the six PassHazard values. The batch remembers which caller closed its last pass (RenderPass::closedBy, set by endOpenRenderPass), so a draw that finds no open pass names that caller.
  • Draw keeps the reason in the draw's outcome; the [draws] line prints the non-zero reasons of the 10 s window in parentheses after render passes N begun, and Graphics::DrawPassBreaks() returns the cumulative counts, as DrawPassTotals() does for the pass counts.
  • No behaviour changes: the decisions are the ones StartDrawPass already makes; the change records which branch was taken. No environment variable is added.

In PPSA31327 (Kamurocho gameplay, APS5_PROFILE_DRAW=1, APS5_DRAW_PIPELINE=1 APS5_DRAW_INPUTS_IN_PLACE=1), one 10 s report of the [draws] line now reads, in the part this changes:

[draws] 350779 draws ... render passes 46103 begun (new batch 6315, command 698, key 35458, image 3632), 304676 draws continued one; ...

Over the last four reports of the run, 77 % of the passes begin because the pass key differs, 14 % because the batch is new, 8 % on an image hazard and 1.5 % after a non-draw command. With APS5_BATCH_CAP=0 the new-batch breaks fall from about 6,300 to 1,100 per 10 s and the key breaks stay at about 35,000, so the batch cap is not where most passes end.

Tested

Windows 11 Pro 26200, WinLibs GCC 15.2.0, Release, BUILD_TESTING=ON, head 57cb47b6b on main f616a1397.

New test agc_driver_pass_break_reasons (tests/execution/PassBreakReasons.cpp): six draws through a Recorder into four-sample color and depth targets, reading DrawPassTotals() and DrawPassBreaks() around each: the first draw of a batch (new batch), the first draw after Submit (new batch), a draw with the open pass's key and no hazard (continued, no reason counted), a draw after Commands() ran for a non-draw command (command), a draw that keeps the color target and switches depth targets (image: the shared multisampled attachment), and a draw into targets the open pass does not touch (key).

  • With StartDrawPass reporting key for every draw that finds no open pass (the closedBy read replaced by a constant), it fails with the first draw of a batch was not counted once as 'new batch': 1 begun, 0 continued; key 1.
  • With the change it passes, also with --repeat until-fail:20.

Pass with the change: agc_driver_address_passes, agc_driver_address_passes_targets_split, agc_driver_multisampled_pass_order, agc_driver_pass_input_hazard, agc_driver_pipelined_metadata_pass, agc_driver_pipelined_metadata_pass_draw_pipeline, agc_driver_presentation_pass, agc_pass_hazards, agc_driver_graphics.

With ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (Vulkan SDK 1.4.363.0; the loader log shows the layer inserted), ctest -R <those tests> -V passes on main f616a1397 (9 of 9) and on the change (10 of 10, with the new test); both logs show Insert instance layer "VK_LAYER_KHRONOS_validation" (VK_LOADER_DEBUG=layer), neither contains was not found but was requested by env var VK_INSTANCE_LAYERS, and neither contains a VUID- line (0 on main, 0 on the change).

PPSA31327 01.015.000, gameplay in Kamurocho, scripted boot through the first dialogue, on main 6cd36e651 + #8098 + the port of #6192 with and without this commit (the same base on both sides; only this commit differs):

  • One profile run (APS5_PROFILE_DRAW=1) for the line above, and one with APS5_BATCH_CAP=0.
  • Frame dumps (APS5_DUMP_FRAMES=600, every 40th frame) at the same points of the scene match between the two builds: the intro, the title screen and two gameplay frames in the street.
  • Two alternated clean pairs, p50 base / change: 226.5 / 232.7 ms and 227.0 / 228.3 ms. The counting runs only under APS5_PROFILE_DRAW, so the clean runs execute the same work; the difference is within this scene's run-to-run spread (up to 15 ms between runs of one build).

Not a performance change; no A/B pairs.

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 (PPSA31327 #6722 is the title it was measured on)
  • GPUs tested: NVIDIA GeForce RTX 4070, driver 621.01, Windows 11 Pro 26200
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5014368087 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11361). Originally posted by [johandavidcm](https://github.com/johandavidcm) on 2026-10-26T08:29:08Z. --- ### What The `[draws]` line counts how many render passes the recorded draws began and how many continued the open one, not why a draw could not continue. Yakuza 0 Director's Cut (PPSA31327) records about 1,000 passes per frame, one every 8 draws; each break costs the pass's attachment store and load and two `ALL_COMMANDS` barriers (the pass end, the next pass's leading barrier), and which of those breaks a change could avoid is not visible in any line today. - `Recorder::StartDrawPass` returns why the draw begins a pass (`PassBreak`, next to `PassHazard` in `PassHazards.hpp`): the batch is new (the first draw of a batch, also after a submit), a non-draw command, a label store, the sample counter or a sample segment closed the previous pass, the draw asked for a pass of its own (`forced`), the pass key differs, or one of the six `PassHazard` values. The batch remembers which caller closed its last pass (`RenderPass::closedBy`, set by `endOpenRenderPass`), so a draw that finds no open pass names that caller. - `Draw` keeps the reason in the draw's outcome; the `[draws]` line prints the non-zero reasons of the 10 s window in parentheses after `render passes N begun`, and `Graphics::DrawPassBreaks()` returns the cumulative counts, as `DrawPassTotals()` does for the pass counts. - No behaviour changes: the decisions are the ones `StartDrawPass` already makes; the change records which branch was taken. No environment variable is added. In PPSA31327 (Kamurocho gameplay, `APS5_PROFILE_DRAW=1`, `APS5_DRAW_PIPELINE=1 APS5_DRAW_INPUTS_IN_PLACE=1`), one 10 s report of the `[draws]` line now reads, in the part this changes: ``` [draws] 350779 draws ... render passes 46103 begun (new batch 6315, command 698, key 35458, image 3632), 304676 draws continued one; ... ``` Over the last four reports of the run, 77 % of the passes begin because the pass key differs, 14 % because the batch is new, 8 % on an image hazard and 1.5 % after a non-draw command. With `APS5_BATCH_CAP=0` the new-batch breaks fall from about 6,300 to 1,100 per 10 s and the key breaks stay at about 35,000, so the batch cap is not where most passes end. ### Tested Windows 11 Pro 26200, WinLibs GCC 15.2.0, Release, `BUILD_TESTING=ON`, head 57cb47b6b on `main` f616a1397. **New test `agc_driver_pass_break_reasons`** (`tests/execution/PassBreakReasons.cpp`): six draws through a `Recorder` into four-sample color and depth targets, reading `DrawPassTotals()` and `DrawPassBreaks()` around each: the first draw of a batch (`new batch`), the first draw after `Submit` (`new batch`), a draw with the open pass's key and no hazard (continued, no reason counted), a draw after `Commands()` ran for a non-draw command (`command`), a draw that keeps the color target and switches depth targets (`image`: the shared multisampled attachment), and a draw into targets the open pass does not touch (`key`). - With `StartDrawPass` reporting `key` for every draw that finds no open pass (the `closedBy` read replaced by a constant), it fails with `the first draw of a batch was not counted once as 'new batch': 1 begun, 0 continued; key 1`. - With the change it passes, also with `--repeat until-fail:20`. **Pass with the change:** `agc_driver_address_passes`, `agc_driver_address_passes_targets_split`, `agc_driver_multisampled_pass_order`, `agc_driver_pass_input_hazard`, `agc_driver_pipelined_metadata_pass`, `agc_driver_pipelined_metadata_pass_draw_pipeline`, `agc_driver_presentation_pass`, `agc_pass_hazards`, `agc_driver_graphics`. With `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1` and `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` (Vulkan SDK 1.4.363.0; the loader log shows the layer inserted), `ctest -R <those tests> -V` passes on `main` f616a1397 (9 of 9) and on the change (10 of 10, with the new test); both logs show `Insert instance layer "VK_LAYER_KHRONOS_validation"` (`VK_LOADER_DEBUG=layer`), neither contains `was not found but was requested by env var VK_INSTANCE_LAYERS`, and neither contains a `VUID-` line (0 on `main`, 0 on the change). **PPSA31327 01.015.000**, gameplay in Kamurocho, scripted boot through the first dialogue, on `main` 6cd36e651 + #8098 + the port of #6192 with and without this commit (the same base on both sides; only this commit differs): - One profile run (`APS5_PROFILE_DRAW=1`) for the line above, and one with `APS5_BATCH_CAP=0`. - Frame dumps (`APS5_DUMP_FRAMES=600`, every 40th frame) at the same points of the scene match between the two builds: the intro, the title screen and two gameplay frames in the street. - Two alternated clean pairs, p50 base / change: 226.5 / 232.7 ms and 227.0 / 228.3 ms. The counting runs only under `APS5_PROFILE_DRAW`, so the clean runs execute the same work; the difference is within this scene's run-to-run spread (up to 15 ms between runs of one build). Not a performance change; no A/B pairs. ### 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 (PPSA31327 #6722 is the title it was measured on) - [x] GPUs tested: NVIDIA GeForce RTX 4070, driver 621.01, Windows 11 Pro 26200 - [x] AI-assisted: yes
MarcZX10 commented 2026-10-26 08:41:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T08:41:51Z.

Review: APPROVED


Reviewed exact head 8717b03c1c8ffbedfcb75fa7bae493e9edb57b5f against current main 204c6747d0a1cbaf932def3dea0778810cc3935e. This is instrumentation-only: each close path records its reason, the next draw consumes that reason, and continued draws are excluded from break counts. The reporting window snapshots cumulative reason counters, and the unit test checks both reason deltas and pass/continuation deltas. I found no behavior change or blocking issue in the diff.

The author reports nine existing Vulkan tests pass on baseline and ten on the change, with the new test repeated 20 times, validation layer loaded, and no VUID output. The title run and GPU are also described in the PR. I did not independently run the Windows/Vulkan suite or title. Hosted eligibility, conventions, intake, labels and report checks pass; build/product jobs are skipped by path policy. The branch is 3 commits ahead of current main, has a clean merge preview, and main has not changed the touched paths since its base.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5649362870 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11361#pullrequestreview-5649362870). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-26T08:41:51Z. **Review:** APPROVED --- Reviewed exact head `8717b03c1c8ffbedfcb75fa7bae493e9edb57b5f` against current `main` `204c6747d0a1cbaf932def3dea0778810cc3935e`. This is instrumentation-only: each close path records its reason, the next draw consumes that reason, and continued draws are excluded from break counts. The reporting window snapshots cumulative reason counters, and the unit test checks both reason deltas and pass/continuation deltas. I found no behavior change or blocking issue in the diff. The author reports nine existing Vulkan tests pass on baseline and ten on the change, with the new test repeated 20 times, validation layer loaded, and no VUID output. The title run and GPU are also described in the PR. I did not independently run the Windows/Vulkan suite or title. Hosted eligibility, conventions, intake, labels and report checks pass; build/product jobs are skipped by path policy. The branch is 3 commits ahead of current main, has a clean merge preview, and main has not changed the touched paths since its base.
MarcZX10 commented 2026-10-26 10:03:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T10:03:28Z.

Review: DISMISSED


The instrumentation diff and the author-reported paired Vulkan-validation/title tests were reviewed on the earlier base 19af7f44e4. The exact head is still 8717b03c1c8ffbedfcb75fa7bae493e9edb57b5f, now 116 commits behind current main 5b5d24cb22. The merge preview is clean, the six changed paths have no main-side edits since the merge base, and current-main conventions and diff checks pass. However, CONTRIBUTING.md requires branches based on current main; please rebase/sync and rerun the focused agc_driver_pass_break_reasons validation-layer test on the resulting head before approval. The previously reported Windows/title runs remain useful evidence but do not cover that new head. Hosted policy checks pass; product jobs are skipped by path policy.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5650266181 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11361#pullrequestreview-5650266181). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-26T10:03:28Z. **Review:** DISMISSED --- The instrumentation diff and the author-reported paired Vulkan-validation/title tests were reviewed on the earlier base `19af7f44e4`. The exact head is still `8717b03c1c8ffbedfcb75fa7bae493e9edb57b5f`, now 116 commits behind current `main` `5b5d24cb22`. The merge preview is clean, the six changed paths have no main-side edits since the merge base, and current-main conventions and diff checks pass. However, `CONTRIBUTING.md` requires branches based on current `main`; please rebase/sync and rerun the focused `agc_driver_pass_break_reasons` validation-layer test on the resulting head before approval. The previously reported Windows/title runs remain useful evidence but do not cover that new head. Hosted policy checks pass; product jobs are skipped by path policy.
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!11361
No description provided.