Repository navigation
perf(agc): remember the verdict of a sampler table entry - #25849
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
Nothing blocks this change; the review found no verified defect in the inspected sampler-verdict cache logic.
What I ran
Reviewed head ccb2df2dd6442a9141774fd7e23a75e45f92b481. No commands or tests were run; repository context was read with repo_read.py.
Results
| Check | Result | Note |
|---|---|---|
| Diff and changed code | passed | One changed source file inspected |
| Tests | not run | Author-reported test results were not independently verified |
Findings
Blocking
None.
Non-blocking
None.
Not verified
The full test suite, reported Windows build and Vulkan validation run, performance measurements, and behavior outside the inspected code were not verified. files.json was not available in the review folder; the manifest identifies ShaderResources.cpp as excluded from the folder because it is too large. Its relevant source range and the sampler-table caller were read through repo_read.py.
To get this to a good state
Nothing is required.
|
This pull request is labeled |
|
NVIDIA run on Linux: no regression in the sampler and image table tests. Setup: RTX 3070 8 GB, NVIDIA 610.57.04, Ryzen 5 5600X, Debian 13 (kernel 6.12.115), GCC 13.3.0 Release, validation layer 1.4.335. Base is the merge-base 07336cc, head is ccb2df2.
Every Vulkan test's log selects the RTX 3070 and shows the layer inserted, none reports it missing, and no log has a AI-assisted: yes |
|
@Remi-Bon on head ccb2df2 merged onto main b9c8230, three tests fail on their own with the same check: |
…e context address Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Head Code.
Speed evidence. Missing.
Existing runs.
Probe.
Negative control. None needed. The PR adds no test, and the existing test fails on head and passes on GPU.
Validation.
Host:
AI-assisted: yes |
Speed capture: sampler table verdictsSetup: Windows 11 (26300), AMD Radeon RX 9070, AMD proprietary driver 26.11.2 (LLPC), Ryzen 9 5950X, 32 GB. PPSA01317, Café scene, 3840x2160. Vulkan validation not loaded (speed captures).
Common environment:
Phase totals over the window (ms, from the summary line):
Result: Read this with care: one run per side, no repeat, so run-to-run noise is unmeasured. The worst frame is 87 to 94 s in all four captures (cold compile of split callee parts at Café entry), so frame percentiles above p99 say nothing about this change. aps5-summary.jsonl linesverdict lookup skipped (local test switch verdict memo used (default): tools/trace_digest.py, verdict lookup skipped (local test switch `APS5_LOCAL_NO_SAMPLER_VERDICTS`, memo still filled) (first lines)249 frames over 13501.1 ms (no summary line found) Slowest frames (largest slices inside each, inclusive)
Persistent spikes (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)
Threads (ms per frame)
tools/trace_digest.py, verdict memo used (default) (first lines)237 frames over 13243.8 ms (no summary line found) Slowest frames (largest slices inside each, inclusive)
Persistent spikes (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)
Threads (ms per frame)
AI-assisted: yes |
|
@Helldiverr Fixed in
AI-assisted: yes |
|
@Remi-Bon GPU rerun on RDNA4 (gfx1201) with the AMD Windows driver and the validation layer: the fix holds. The memo key now holds every context field the verdict reads, and no longer the Code. At the head,
Mutations. Each removes one field from the capability list at
After the mutations, the file was restored and the merge rebuilt. GPU.
Speed. Not measured here. Your capture is an A/B inside a downstream tree, with the lookup skipped or used. It is not the Validation.
Host:
AI-assisted: yes |
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
…max reduction Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Pushed 88cf2d4: |
|
Rerun of 88cf2d4 on the R9700 with the validation layer: Remi-Bon, thanks for the follow-up test. This run checks the claim in your reply and the other key fields. Measured (Windows, merge onto
|
| field dropped from the key | result (52 tests) | failing tests and message |
|---|---|---|
samplerFilterMinmax (:6254) |
48 passed, 2 failed, 2 not run | agc_driver_graphics, agc_graphics_profile_draw: AGC graphics: guest sampler descriptor uses a min or max reduction which the device does not support |
nonSeamlessCubeMap (:6254) |
48 passed, 2 failed, 2 not run | agc_driver_graphics, agc_graphics_profile_draw: AGC graphics: non-seamless sampler table has the wrong deferred poison count |
samplerAnisotropy (:6254) |
50 passed, 2 not run | none |
samplerMirrorClampToEdge (:6254) |
50 passed, 2 not run | none |
limits.maxSamplerAnisotropy bytes (:6250) |
50 passed, 2 not run | none |
limits.maxSamplerLodBias bytes (:6251) |
50 passed, 2 not run | none |
| none (key restored, rebuilt) | 50 passed, 2 not run | none |
- With
samplerFilterMinmaxdropped, the stale verdict lets the min/max sampler through, and the run stops at theRequireincore/libs/prx/libSceAgcDriver/Graphics/src/Sampler.cpp:23. It does not reach the poison-count message of the new test. Either way the test fails. At 698042d the same mutation failed no test. - The 2 tests that did not run are the same on
mainand on every merge run (see below). - After the mutations the file was restored and the merge rebuilt.
Inferred
- The four surviving mutations show that no focused test needs
samplerAnisotropy,samplerMirrorClampToEdge,maxSamplerAnisotropyormaxSamplerLodBiasin the key.samplerTableDeviceLimitTests(Graphics.cpp:8577) andsamplerLodBiasTests(:8637) set these fields, but neither changes one between two passes over the same entry the way the new test does. - The three-pass pattern of
samplerTableMinmaxCapabilityTestswith an anisotropic or mirror-clamp S#, or with the limit changed between passes, would cover those four fields the same way.
GPU
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ctest --test-dir build -R "(sampler|image_table|^agc_driver_graphics|agc_graphics_profile_draw)" -V
| run | tests | passed | failed | not run | total |
|---|---|---|---|---|---|
main |
52 | 50 | 0 | 2 | 61.42 s |
| merge 1 / 2 / 3 | 52 | 50 | 0 | 2 | 48.95 / 52.69 / 58.55 s |
| merge, key restored after the mutations | 52 | 50 | 0 | 2 | 64.42 s |
agc_driver_graphicsandagc_graphics_profile_drawpass onmainand on all merge runs.- Not run:
agc_shader_sampler_limitsandagc_shader_nested_sampler_snapshot_retry. This is a host problem, not the PR. Windows Defender removesagc_shader_memory_tests.exeright after it links, so the post-linkobjcopystep fails and ctest finds no executable. The same happens onmain. Our earlier comment gave only theobjcopyerror; this is its cause. - Each of the 40 tests that create a Vulkan instance selected
AMD Radeon AI PRO R9700 vendor=0x1002 device=0x7551 subgroup=64. - The times are not a speed measurement.
Validation
Insert instance layer "VK_LAYER_KHRONOS_validation"appears 46 times in every log, from the 40 tests that create an instance.- No log contains
was not found but was requested by env var VK_INSTANCE_LAYERS. VUID-lines: 0 in every log, onmain, the three merge runs, the six mutations and the restored run.tools/check_conventions.py --base 99fb98ee6candtools/debt_fold.py --checkpass on the merge.
Existing runs
- Remi-Bon reported that dropping
samplerFilterMinmaxmakes the new test fail and thatagc_driver_graphicspasses with the key restored, with noVUID-lines. This run confirms both on the R9700. - Our earlier run at 698042d is the one that found that dropping
samplerFilterMinmaxfailed no test.
Host
- GPU: AMD Radeon AI PRO R9700 (gfx1201, 1002:7551), driver 32.0.31044.16, Vulkan 1.4.349
- Validation layer: Khronos validation layer 1.4.363 (LunarG SDK)
- CPU: Ryzen 9 9950X3D
- OS: Windows 11 Pro 26300
- Toolchain: WinLibs GCC 15.2, Release
- Commits: head
88cf2d43e5, merged ontomain99fb98ee6cas0c9b36c220
AI-assisted: yes
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
The changed sampler verdict cache includes the device capabilities and limits used by validation, and the regression test exercises min/max support changing across consecutive contexts.
What I ran
Reviewed head 88cf2d43e5be9e7168674e8466fbe0f65da5cc47 against the prepared diff. No build or tests were run; the test results in the PR description are author-reported.
Results
| Check | Result | Note |
|---|---|---|
| Diff and changed code | passed | Both changed files read at the pinned head |
| Build and tests | not run | Author reports 46 tests passed |
Findings
Blocking
None.
Non-blocking
None.
Not verified
No build or tests were run. Runtime behavior beyond the inspected code is not verified. The full files were excluded from the review folder for size; changed lines and relevant function context were read through the repository reader. Read: ShaderResources.cpp lines 6210–6310 and 2485–2510; Sampler.cpp lines 1–60; Graphics.cpp lines 8525–8590. Excluded by folder-size rule: the remaining contents of ShaderResources.cpp and Graphics.cpp.
To get this to a good state
Nothing is required.
samplerTableCapabilityTests runs one table entry three times per field, with the field supported, unsupported, then supported again, for min/max reduction, anisotropic filtering, the anisotropy and LOD bias limits and mirror-once clamping. Dropping any of them from the verdict key now fails a test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
Reviewed head 2207e08fe6dc70fe980804b32dc56075fcfa8973 using repo_read.py to inspect the prepared diff and targeted source ranges. No build or tests were run.
Results
| Check | Result | Note |
|---|---|---|
| Changed code review | passed | Targeted changed hunks and validation logic inspected |
| Tests and build | not run | No execution available in this review |
Negative control
Not run; no test execution was available.
Findings
Blocking
None.
Non-blocking
None.
Sources
The verdict memo key includes the sampler descriptor words, depth-compare flags, and the device capabilities and limits used by validation. Capacity-overflow entries bypass memo lookup and insertion. Changed implementation at the reviewed head
Not verified
Build and test results were not independently verified. Read the changed ranges in core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp and core/libs/prx/libSceAgcDriver/tests/Graphics.cpp, plus the sampler validation function in core/libs/prx/libSceAgcDriver/Graphics/src/Sampler.cpp. The full changed files were excluded from the review bundle and were not read in full.
To get this to a good state
Nothing is required.
|
Tested
GPU (software Vulkan): 6 GPU tests (AGC) passed twice on Mesa lavapipe (Mesa 25.2.8-0ubuntu0.24.04.5 (LLVM 20.1.2)) on a GitHub-hosted Ubuntu 24.04 runner, with the Khronos validation layer on and the shader cache off, alongside main Not covered: GPU hardware. lavapipe runs Vulkan on the CPU, so this says nothing about how real GPU drivers handle the changed paths. AI-assisted: yes (Claude Code); the runs are automated, this summary was written from their reports. |
What
ShaderResources::addSamplerTabledecodes and validates every sampler of a sampler table entry on every capture. When an entry is refused, it throws and catches an exception per sampler, every time. A shader that binds the same refused entry on each dispatch pays that cost on every dispatch.This change remembers each entry's verdict: accepted, or the refusal text. The key is the context address, the entry's guest descriptor words and its depth-compare flags. The next capture of the same entry reuses the verdict without decoding. The memo is cleared at 65536 entries. An entry over the device's sampler table capacity is never memoised.
Tested
ctest --test-dir build -R "sampler|image_table": 46/46 passed, withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationandVK_LOADER_DEBUG=layer, validation layer from Vulkan SDK 1.4.363.1. The loader log showsInsert instance layer "VK_LAYER_KHRONOS_validation"and contains noVUID-.mainvs changetools/trace_digest.pycomparison:mainalone does not reach the scene. CPU samples inaddSamplerTablewent from 654 to 163 over 45 s.Speed capture
Windows 11 (26300), AMD Radeon RX 9070, AMD proprietary driver 26.11.2 (LLPC), Ryzen 9 5950X, 32 GB. PPSA01317, Café scene, 3840x2160, validation layer not loaded. Same environment on both sides, one warm-up run then one measured run per side,
APS5_TRACE_SECONDS=0:100from the Café entry.This is not a
mainvs change capture:mainalone does not reach the scene (#7256). Both commits are local snapshots of one downstream tree (e2c5cb724bb5plus unmerged split table call work) and are not pushed. They differ only inShaderResources::addSamplerTable:0114600e6d8chas no verdict memo,d24d6e5c38d8has the memo with this PR's key.Vulkan.DispatchmsRecorder.SyncmsDriver.SplitDispatchmsOver the window,
Vulkan.Dispatch.shader_resourcesgoes from 17479 ms to 6867 ms andResources.Preparefrom 13821 ms to 3058 ms. Frame time does not improve in this scene:Recorder.Syncand GPU busy time are higher on the side with the memo. There is one run per side, so the noise is unmeasured and I do not know the cause of that rise. Both traces dropped events on queue worker 0x0, so slice-based figures in the digests are partial.tools/trace_digest.py, without
285 frames over 98460.1 ms (no summary line found)
Incomplete trace: recorded data was lost. Slice-based timings, waits and batch inventories cover retained events only; missing slices are not idle time. Summary statistics are reported separately.
Slowest frames (largest slices inside each, inclusive)
Persistent spikes (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.WorkerWait 2313.2, Driver.WorkerWait.dequeue_order 1201.5, Driver.WorkerWait.idle_and_completion_poll 1111.7, Driver.Packet 208.1, Driver.Packet.dispatch 178.7, Driver.Dispatch 178.2, Driver.SplitLookup 159.6, Driver.SplitDispatch 144.1, batch 107.4, Recorder.Sync 62.4
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
tools/trace_digest.py, with
285 frames over 98000.0 ms (no summary line found)
Incomplete trace: recorded data was lost. Slice-based timings, waits and batch inventories cover retained events only; missing slices are not idle time. Summary statistics are reported separately.
Slowest frames (largest slices inside each, inclusive)
Persistent spikes (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.WorkerWait 2379.5, Driver.WorkerWait.dequeue_order 1206.3, Driver.WorkerWait.idle_and_completion_poll 1173.1, Driver.Packet 226.9, Driver.Packet.dispatch 195.8, Driver.Dispatch 195.4, Driver.SplitLookup 176.5, Driver.SplitDispatch 161.5, batch 142.7, Recorder.Sync 101.5
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code