test(agc): validate pixel LDS and expose pipeline statistics #601

Merged
nicolasabosch merged 1 commit from upstream-pr/601 into main 2026-10-05 02:52:43 +00:00
nicolasabosch commented 2026-10-05 02:13:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nicolasabosch on 2026-10-05T02:13:12Z.


What

Pixel shaders emulate LDS with per-invocation storage. #586 reduces its allocation, but the execution tests currently exercise LDS only in compute shaders. This adds a standalone pixel LDS regression and opt-in driver statistics so the same fixture can check results and inspect the compiled pipeline.

  • agc_driver_pixel_lds: a fullscreen 64x32 draw fills three LDS banks at byte offsets 0, 256 and 512 using pixel-dependent permutations, then reads them through a different dynamic index. Each pixel has distinct data. The CPU checks all three results, RGBA coverage and an untouched output-stride guard. Guest wave32/wave64 and statically bounded/unbounded read addresses each run three times: 12 draws, 24,576 pixels and 73,728 checked LDS results per execution. The statically unbounded case has valid runtime addresses.
  • APS5_PIPELINE_STATS=1: enable VK_KHR_pipeline_executable_properties and pipelineExecutableInfo, capture statistics when creating graphics and compute pipelines, and print each executable's stages, subgroup size, statistic values and driver descriptions. Missing support or Vulkan query errors throw. All four statistic formats are handled. Raw driver values are preserved; the setting is off by default.

This PR contains the fixture and diagnostic support only. The implementation from #586 was applied on a separate local comparison branch and is not included here. This PR can merge independently of #586.

Tested

Windows 11 Pro, MinGW-w64 GCC 15.2.0 (supported WinLibs release), Ninja Release build, BUILD_TESTING=ON, ANYPS5_ENABLE_SPIRV_TOOLS=ON, ANYPS5_REQUIRE_VULKAN=1. NVIDIA GeForce RTX 4070 Laptop GPU, driver 616.92, native subgroup size 32. Synthetic RDNA shader fixture; no commercial title or native 64-lane hardware tested.

Validation:

  • cmake --build build --parallel 10: passed.
  • cmake --build build --target libs --parallel 10: passed.
  • ctest --test-dir build --output-on-failure: 229/229 passed, no skips (158.61 s), statistics disabled.
  • With APS5_PIPELINE_STATS=1, ctest --test-dir build -R '^(agc_driver_pixel_lds|agc_driver_lds_atomics64)$' -V: 2/2 passed (3.88 s). Logs contain VS, FS and CS executable statistics; rendering and the 64-bit compute LDS atomics checks pass.
  • The same pixel fixture also passes with #586 locally applied, with the allocation comparison below. #586's agc_shader_memory test passes as well.

Independent comparison: current main ebf29f8d plus this fixture/diagnostic against the same code plus #586 head 3abf1074:

Guest cases Main Function LDS array With #586 Main raw FS Local Memory Size With #586
wave32/wave64, bounded 8192 dwords 192 dwords 68719509504 68719477504
wave32/wave64, unbounded 8192 dwords 8192 dwords 68719509504 68719509504

All 73,728 results passed on both versions. Every case's statistic was stable across its three draws. Binary inspection of the optimized SPIR-V confirms the bounded module changes only the array-length constant, 8192 to 192. The unbounded modules are byte-identical (SHA-256 fc98e3fc653751d5067a07a07b5f98055de6786fb94ffeef791f05ef4486d4bb).

The Windows driver reports 0x10 in the high 32 bits of Local Memory Size even for the vertex executable with no local memory. A matching NVIDIA forum report describes this behavior. The low 32 bits are 32768 and 768 respectively, agreeing with the SPIR-V allocations; these are disclosed as low-bit observations, not reliable absolute driver-reported byte counts. No FPS improvement or reproduction/fix of the title-specific GPU hang is claimed.

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; no silent stubs added
  • No notes, investigation .md files or images added to the repository
  • No new third-party code
  • Generic behaviour, not specific to one title
  • Depends on: none; complements #586
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4739365537 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/601). Originally posted by [nicolasabosch](https://github.com/nicolasabosch) on 2026-10-05T02:13:12Z. --- ### What Pixel shaders emulate LDS with per-invocation storage. #586 reduces its allocation, but the execution tests currently exercise LDS only in compute shaders. This adds a standalone pixel LDS regression and opt-in driver statistics so the same fixture can check results and inspect the compiled pipeline. - `agc_driver_pixel_lds`: a fullscreen 64x32 draw fills three LDS banks at byte offsets 0, 256 and 512 using pixel-dependent permutations, then reads them through a different dynamic index. Each pixel has distinct data. The CPU checks all three results, RGBA coverage and an untouched output-stride guard. Guest wave32/wave64 and statically bounded/unbounded read addresses each run three times: 12 draws, 24,576 pixels and 73,728 checked LDS results per execution. The statically unbounded case has valid runtime addresses. - `APS5_PIPELINE_STATS=1`: enable `VK_KHR_pipeline_executable_properties` and `pipelineExecutableInfo`, capture statistics when creating graphics and compute pipelines, and print each executable's stages, subgroup size, statistic values and driver descriptions. Missing support or Vulkan query errors throw. All four statistic formats are handled. Raw driver values are preserved; the setting is off by default. This PR contains the fixture and diagnostic support only. The implementation from #586 was applied on a separate local comparison branch and is not included here. This PR can merge independently of #586. ### Tested Windows 11 Pro, MinGW-w64 GCC 15.2.0 (supported WinLibs release), Ninja Release build, `BUILD_TESTING=ON`, `ANYPS5_ENABLE_SPIRV_TOOLS=ON`, `ANYPS5_REQUIRE_VULKAN=1`. NVIDIA GeForce RTX 4070 Laptop GPU, driver 616.92, native subgroup size 32. Synthetic RDNA shader fixture; no commercial title or native 64-lane hardware tested. Validation: - `cmake --build build --parallel 10`: passed. - `cmake --build build --target libs --parallel 10`: passed. - `ctest --test-dir build --output-on-failure`: 229/229 passed, no skips (158.61 s), statistics disabled. - With `APS5_PIPELINE_STATS=1`, `ctest --test-dir build -R '^(agc_driver_pixel_lds|agc_driver_lds_atomics64)$' -V`: 2/2 passed (3.88 s). Logs contain VS, FS and CS executable statistics; rendering and the 64-bit compute LDS atomics checks pass. - The same pixel fixture also passes with #586 locally applied, with the allocation comparison below. #586's `agc_shader_memory` test passes as well. Independent comparison: current main `ebf29f8d` plus this fixture/diagnostic against the same code plus #586 head `3abf1074`: | Guest cases | Main Function LDS array | With #586 | Main raw FS Local Memory Size | With #586 | | --- | ---: | ---: | ---: | ---: | | wave32/wave64, bounded | 8192 dwords | 192 dwords | 68719509504 | 68719477504 | | wave32/wave64, unbounded | 8192 dwords | 8192 dwords | 68719509504 | 68719509504 | All 73,728 results passed on both versions. Every case's statistic was stable across its three draws. Binary inspection of the optimized SPIR-V confirms the bounded module changes only the array-length constant, 8192 to 192. The unbounded modules are byte-identical (SHA-256 `fc98e3fc653751d5067a07a07b5f98055de6786fb94ffeef791f05ef4486d4bb`). The Windows driver reports `0x10` in the high 32 bits of Local Memory Size even for the vertex executable with no local memory. A matching [NVIDIA forum report](https://forums.developer.nvidia.com/t/vkgetpipelineexecutablestatisticskhr-reports-64gb-of-local-memory-size/346960) describes this behavior. The low 32 bits are 32768 and 768 respectively, agreeing with the SPIR-V allocations; these are disclosed as low-bit observations, not reliable absolute driver-reported byte counts. No FPS improvement or reproduction/fix of the title-specific GPU hang is claimed. ### Checklist - [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 - [x] Unimplemented paths throw; no silent stubs added - [x] No notes, investigation `.md` files or images added to the repository - [x] No new third-party code - [x] Generic behaviour, not specific to one title - [x] Depends on: none; complements #586 - [x] AI-assisted: yes
oneandonlydean commented 2026-10-05 02:47:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-05T02:47:28Z.


Thanks, a pixel shader LDS test is a good addition; until now only compute shaders exercised it.

I disassembled the shaders with llvm-mc (gfx1013): the vertex shader and both pixel variants decode as described (32 rounds of three ds_write_b32 at offsets 0, 256 and 512, reads at y & 31 or y, three buffer_store_dword with a stride guard in the fourth dword), and the expected (y - x) & 31 index is right. Since #586 isn't part of this PR, the test is a regression guard and should pass on main as it is.

The statistics path is off unless APS5_PIPELINE_STATS=1 is set: without it, no extension or feature struct is added, pipelineInfo.flags stays 0 as before, and the logging returns on a bool, so normal runs don't change. One small wording point: BUILD.md says it prints statistics for "each newly created graphics or compute pipeline", but the driver's own helper compute pipelines (color transfer, detiler, sample counter, mesh arguments) aren't captured, only the ones built from guest shaders. Saying "guest shader pipelines" would match. That's optional.

It merges cleanly with main and with the open PRs that touch the same files. The CI build was still running when I looked; once it's green, it's ready to merge from my side.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5987230647 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/601#issuecomment-5987230647). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-05T02:47:28Z. --- Thanks, a pixel shader LDS test is a good addition; until now only compute shaders exercised it. I disassembled the shaders with llvm-mc (gfx1013): the vertex shader and both pixel variants decode as described (32 rounds of three `ds_write_b32` at offsets 0, 256 and 512, reads at `y & 31` or `y`, three `buffer_store_dword` with a stride guard in the fourth dword), and the expected `(y - x) & 31` index is right. Since #586 isn't part of this PR, the test is a regression guard and should pass on main as it is. The statistics path is off unless `APS5_PIPELINE_STATS=1` is set: without it, no extension or feature struct is added, `pipelineInfo.flags` stays 0 as before, and the logging returns on a bool, so normal runs don't change. One small wording point: BUILD.md says it prints statistics for "each newly created graphics or compute pipeline", but the driver's own helper compute pipelines (color transfer, detiler, sample counter, mesh arguments) aren't captured, only the ones built from guest shaders. Saying "guest shader pipelines" would match. That's optional. It merges cleanly with main and with the open PRs that touch the same files. The CI build was still running when I looked; once it's green, it's ready to merge from my side.
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!601
No description provided.