Repository navigation
feat(agc): select occlusion counter blocks with PIXEL_PIPE_STAT_CONTROL - #22465
Conversation
EVENT_WRITE event 56 (PIXEL_PIPE_STAT_CONTROL, index 1) now sets the per-queue mask of render-backend counter blocks that later PIXEL_PIPE_STAT_DUMP packets write and that Z-pass predication sums. The mask starts with all 16 blocks, as before. Counter IDs other than occlusion count 0, strides other than 128 bits and reserved bits throw. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@PrivacyOnion @MarcZX10 when you have time, could one of you review this? It makes |
|
Real-AMD coverage — the occlusion-counter-block selection path works across lavapipe, RDNA2 and RDNA3.
0 VUID on NAVI31. This is a driver-side counter-block/pipeline-journal path rather than an arch-divergence surface, so I didn't add GCN5 here — the RDNA pair + lavapipe cover it alongside your NVIDIA run. AI-assisted: yes |
|
@tablefrogpillow thank you, RADV on RDNA2 and RDNA3 plus lavapipe is good cover for the mask path next to the NVIDIA run. I added it to Tested. |
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
- Head reviewed:
97826291658959a1dcac3c01dc414f468d60ac31, basemain. No merged-preview check. - Read the review folder (description, commits, manifest, diff) and the head through the repository reader (
repo_read.py, search and line-range reads). - No build and no tests were run in this review; the review is by reading only.
- Author-reported runs (Windows, RADV, lavapipe, CUSA00900) are not counted as checks I ran.
Results
| Check | Result | Note |
|---|---|---|
| Build and unit tests | not run | No build in this review |
| Changed hunks read | passed | 16 of 16 listed files, by diff hunk |
| Targeted context read | passed | Pm4.cpp 700-735 and 1170-1200, VulkanDevice.cpp 3208-3228, Pm4.hpp 1-20 |
| Shader compile | not run | SampleCounter.comp, SampleDumps.comp read from the diff only |
| Author-reported GPU runs | not run | Author report, not re-run |
Findings
Blocking
None.
Non-blocking
core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp:715: when a queue's mask is 0,PredicationPassesreads no counter pair and skips every block, so the Z-pass predicate sums to zero and evaluates as "no samples" without the "never written" check. The debt note does not say what the console does here, and no test covers mask 0. Either state the intended result in the debt note, or add a test that pins it.
Sources
Commit-pinned lines at the head:
- Validation of
PIXEL_PIPE_STAT_CONTROL:AnyPS5/core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp
Lines 494 to 501 in 9782629
- Mask set on the control packet:
AnyPS5/core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp
Lines 1211 to 1214 in 9782629
- Queue reset makes a new
QueueState, so the mask returns to 16 blocks: - Z-pass predication over enabled blocks:
AnyPS5/core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp
Lines 708 to 734 in 9782629
Not verified
- PAL packet layout and the stride encoding (2 = 128 bits): the linked PAL header was not fetched.
- Console behaviour: whether predication reads disabled blocks, what
sceAgcDcbResetQueuewrites, and the CUSA00900 title run. These are the author's reports and are not confirmed here. - Test results: the GPU, CPU and validation-layer runs are author-reported and were not re-run.
- Shaders:
SampleCounter.compandSampleDumps.compwere read from the diff; they were not compiled. core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppis too large for the review folder. Only the changed lines at 3210 and 3225 were read, through the reader. The full file was not read.- Other changed files were read by hunk. Code outside the hunks and their direct callers was not read.
To get this to a good state
Nothing is required.
The optional point is listed under Non-blocking above.
|
Ran the Tested section's pattern with the Khronos validation layer on Linux and an NVIDIA GPU; the Tested section's run is on Windows. Setup: Arch Linux (kernel 7.3.4), GCC 16.2.1, Release, NVIDIA GeForce RTX 4090 (vendor
No new AI-assisted: yes (Claude Code) |
|
@domx4q thanks for the RTX 4090 Linux run on |
The console result of Z-pass predication after PIXEL_PIPE_STAT_CONTROL enables no block is unknown, so throw instead of reporting no samples. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks, @MarcZX10. Took the mask 0 point in We don't know what the console returns for Z-pass predication when Validation on the same machine (6 focused tests, 3 repeats, Khronos layer 1.4.363.1): the fix passes 6/6 with no |
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
- Head
4a2591d5840b0d908713304a3aef0580a24b4f83, basemain. No merged-preview check. - No build and no test run. Builds are not part of this review.
- Reader searches and reads at head:
python3 repo_read.py search sampleDumpBlocks core/libs/prx/libSceAgcDriver
python3 repo_read.py search ResetQueue core/libs/prx/libSceAgcDriver
python3 repo_read.py search ClearContext core/libs/prx/libSceAgcDriver
python3 repo_read.py search DumpSamples core/libs/prx
python3 repo_read.py search foldSamples core/libs/prx
python3 repo_read.py cat core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp 3207 3228
Results
| Check | Result | Note |
|---|---|---|
| Build and unit tests | not run | out of scope for this review |
| Author-reported GPU and console runs | not applicable | taken from the description, not reproduced |
| Changed lines in the 16 reviewed files | passed | read in the diff |
| Head context for changed functions | passed | limits under Not verified |
Findings
Blocking
None.
Non-blocking
docs/dev/debt/changes/claude-agc-pixel-pipe-stat-control.md:5says the block mask "returns to that on a queue reset". The mask is set only by theQueueStatedefault (core/libs/prx/libSceAgcDriver/Execution/include/QueueState.hpp:306).ClearContext, whichCLEAR_STATEand the context-state packet call (core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp:1180and:1200), does not touch the mask. A search for a queue-reset path at head found none. Either the reset lives outside this diff or the sentence is wrong. Reword it, or point to the code that resets the mask.core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp:376givesDumpSamplesa default of0xffffu, and:907does the same forfoldSamples. Every current caller passes the queue's mask, or passes target 0 where the mask is unused (Recorder.cpp:4704). A future caller that leaves the argument out would dump all 16 blocks and ignorePIXEL_PIPE_STAT_CONTROL. Consider removing the default so a missing argument fails to compile. The calls intests/Recorder.cppwould then need the mask passed.
Not verified
- No build and no test run. The GPU and console results in the description are the author's; I did not reproduce them.
- The console values (
07fffc00,0007fc00), the Bloodborne CUSA00900 run and the heap crash are not checked here. - The PAL, Mesa and shadPS4 links were not opened. No point in this review depends on them.
- Read: the diff for all 16 reviewed files. Head context:
VulkanDevice.cpplines 3207–3228 (the full file is too large for the review folder, so only the changed function was read), andPm4.cpplines 700–733 and 1172–1203 from the review folder, plus the includes ofPm4.hpp. The other changed functions (PacketExecution.cpp,PacketMemory.cpp,Recorder.cpp, both shaders,PipelinedSampleDump.cpp,tests/Pm4.cpp) were judged from their hunks, not their full surrounding text. - Excluded by rule: none.
files.jsonlists no excluded files.
To get this to a good state
Nothing is required.
Optional: the two points above.
Only the dispatch reset packet makes a new queue state, so it is the only packet that restores all 16 counter blocks. CLEAR_STATE and CONTEXT_STATE keep the PIXEL_PIPE_STAT_CONTROL selection. The debt fragment now says this instead of "returns to that on a queue reset". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks, @MarcZX10.
Validation on the same machine (six focused tests, 3 repeats, Khronos layer 1.4.363.1): the fix passes 6/6 and main |
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
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.
|
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
- Head
dbdd911e25e8edecfbb4e9a7b65cab3534ac933c, basemain. No merged-preview check. - Read all 17 changed files through
diff.patch. No changed file was read in full:VulkanDevice.cppis too large forfiles/, and only its two changed hunks were read. Excluded by rule: none. - Read the description and commits, and the review sections of the house rules.
- Checked surrounding code with
repo_read.py(7 calls, listed below). - Nothing was built or tested in this run.
Results
| Check | Result | Note |
|---|---|---|
| Diff read, 17 files | passed | Changed lines only |
| Full files read | not run | No file read in full |
| Build and ctest | not run | Not built here |
| Surrounding code | passed | Reader searches and one range read |
Commands
repo_read.py search sampleDumpBlocks
repo_read.py search SampleCounterPushBytes
repo_read.py search ClearContext core/libs/prx/libSceAgcDriver/Execution
repo_read.py cat core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp 1174 1202
Findings
Blocking
None.
Non-blocking
core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp:716: the Z-pass predication read covers every counter pair from block 0 up to the highest enabled block, not only the enabled blocks. The sum skips the disabled ones (Pm4.cpp:720), so the result holds. The PR text and the debt note say the read touches only enabled blocks, which is not what the code does. Either correct the wording or read each enabled block on its own. The wider read can also reach past an 8-pair result when a high block is enabled. I did not check the buffer size a game allocates.core/libs/prx/libSceAgcDriver/tests/Pm4.cpp:1206: the predication tests use only the 8-block mask and mask 0. No predication test uses a gap mask such as 0x8001, so a regression in the point above would pass the suite.
Not verified
- Build, ctest, and the GPU, driver and console runs in the PR body: not run here. They are author-reported only.
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp: only the two changed hunks were read, not the whole file.- The dispatch reset that restores all 16 blocks (
core/libs/prx/libSceAgcDriver/tests/Pm4.cpp:1082): the reader did not find the production path. The test asserts it, but I did not run the test. - The read size of the predication:
PredicationByteswas replaced by a pair count. I did not readPredicationBytes, so I cannot compare the old and new read sizes. - The GLSL changes in
SampleCounter.compandSampleDumps.comp: not compiled. The push-constant size is checked only by the C++static_assert. - Stride value 2 (128 bits), the PAL and Mesa layouts, and the shadPS4 links: not checked against their sources.
- The CUSA00900 run, the title crash analysis,
check_conventionsandpr_overlap: not checked.
To get this to a good state
Nothing is required.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks, @MarcZX10. Both taken in
Validation on the same machine (six focused tests, 3 repeats, Khronos layer 1.4.363.1): the fix passes 6/6 and main |
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
- Head reviewed:
7679aea782f801b37350caac9d90957b6e4f2d30, basemain. - Read
description.md,commits.md,manifest.json,files.jsonanddiff.patchfrom the review folder. - Read repository text at the head with
repo_read.py:
python3 repo_read.py search "case 0x46" core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp
python3 repo_read.py search "PredicationBytes" core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp
python3 repo_read.py search "include" core/libs/prx/libSceAgcDriver/Execution/include/Pm4.hpp
python3 repo_read.py cat core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp 280 292
python3 repo_read.py cat core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp 1196 1216
- I ran no build and no test. The test results in the description are the author's reports, not mine.
Results
| Check | Result | Note |
|---|---|---|
| Changed hunks read | passed | 16 of 16 reviewed files, from diff.patch |
| Full file text read | not run | only the Pm4.cpp ranges above |
| Build and ctest | not run | author-reported only |
| Vulkan validation | not run | author-reported only |
Findings
Blocking
None.
Non-blocking
core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp:718: Z-pass predication now makes oneGuestMemory::Readper enabled block, up to 16 small reads per predicated packet, where the old code made one bulk read. The logic reads correctly. The cost is not measured. One read of the enabled pairs would keep the old call count.core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp:376: the default0xffffurepeatsAllSampleDumpBlocksfromQueueState.hppas a literal. The same literal is the default at line 907 forfoldSamples. Using the constant would keep the value in one place, if this header can reach it.
Not verified
- Build, the six-test ctest pattern and the Khronos validation run were not run by me. The GPU results (RTX 4080 SUPER, RTX 4090, RX 7900 GRE, Ryzen 7000 iGPU, lavapipe) are the author's and the reviewers' reports.
- The claim that
tests/Pm4.cppdoes not compile onmainwas not checked. - The CUSA00900 title result, and the heap crash after the loading screen, were not checked.
- Console behaviour of
PIXEL_PIPE_STAT_CONTROL(CLEAR_STATE keeping the mask, predication on disabled blocks) cannot be checked here. The debt file says it is not measured on a console. - Full text of the changed files beyond the hunks was not read, including
VulkanDevice.cpp, which is too large for the review folder. - The event is COMMENT, not APPROVE, because no check was run and the full files were not read.
To get this to a good state
Nothing is required. The non-blocking points above are optional.
|
Thanks, @MarcZX10. I'm keeping the PR as it is for both points.
|
|
Included your original A range guard allows only the highest enabled counter pair. The same fixture fails the old bulk reader specifically at the disabled prefix and passes your enabled-pair reader; the existing result-value cases are retained. This covers the access boundary even when the backing host array is fully mapped. On Linux/RX 6650 XT/RADV 26.2.7, validation 1.4.363, current-main integration: old reader 16 pass/1 expected guard failure, updated reader 17 pass, zero skips/VUIDs. Matched builds, verbose CTest/JUnit, exact source/fixture and binary manifests, SHA-256 AI-assisted: yes. |
PacketMemory dumpSampleCounters: main's per-block mask (boykopovar#22465) skips unselected dump blocks; this branch still notes each written block as a GPU store.
Merges boykopovar#17943's head 19728b1, which merges main 711ab41 (the foldSamples resolution of boykopovar#22465); no further conflicts.
Merges boykopovar#18029's head d161c08, which carries main 711ab41 through boykopovar#17943 (19728b1). Recorder ensureOpen: keep this branch's stream/direct split. Recorder foldSamples: main's blocks parameter (boykopovar#22465) with this branch's body (batch.commands, no quiesce). RuntimeSwitches: the lower branches' entries, then this branch's two.
What
EVENT_WRITEevent type 56 (PIXEL_PIPE_STAT_CONTROL, event index 1) used to throwEVENT_WRITE event type 56 is not implemented. It now changes what later occlusion dumps do, which #1581 asked for before the event is accepted.PM4_ME_EVENT_WRITE:counter_idin bits 3-8,stridein bits 9-10 and a 16-bitinstance_enablein bits 11-26. Mesa writes the same fields at GFX11 init (ac_cmdbuf.c, sid.h).instance_enablemask, starting at all 16 blocks.PIXEL_PIPE_STAT_DUMPthen writes only the enabled blocks, on the CPU path, on the queued pipeline path and in the GPU shadersSampleCounter.compandSampleDumps.comp. AnyPS5 counts samples for the whole target, so the lowest enabled block gets the count. Z-pass predication sums, and reads, only the enabled blocks.sceAgcDcbResetQueuewrites07fffc00, which enables all 16 blocks (sceAgcDcbResetQueue writes a different packet sequence on hardware than on main #1581), so behaviour is unchanged for it. CUSA00900 writes0007fc00before each dump, which enables 8 blocks, the PS4's render backends. Before this PR its dumps wrote 16 blocks, 128 bytes past its 8-pair result.143b58aa48handles onlySoVgtStreamoutFlushandPixelPipeStatDump(8 or 16 pairs, from Neo mode) and ignores every other event. Mesa radeonsi and RADV do not emit event 56 for queries.Tested
Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0 r7, Release, RTX 4080 SUPER, driver 621.14.
tests/Pm4.cppcovers validation (each refused field), the per-queue mask and predication over 8 enabled blocks and over the gap mask0x8001.PipelinedSampleDump.cppsubmits masks0xff,0xf0and0and checks that only the enabled blocks are written and that the count lands in the first enabled block. The newagc_driver_pipelined_sample_dump_cpuentry runs that file on the CPU dump path.1adc0e2f4b9, with these tests):tests/Pm4.cppdoes not compile, andagc_driver_pipelined_sample_dumpand_drainedfail withEVENT_WRITE at DWORD 7: EVENT_WRITE event type 56 is not implemented.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer, Khronos layer 1.4.363.1,ctest --test-dir build-win -R "^(agc_driver_pm4|agc_driver_pipelined_sample_dump|agc_driver_pipelined_sample_dump_drained|agc_driver_pipelined_sample_dump_cpu|agc_sample_dumps|agc_uncounted_passes)$" -V:Insert instance layer "VK_LAYER_KHRONOS_validation", 0VUID-, no "was not found";_cpuentry), 6 inserts, 0VUID-, no "was not found".97826291658, Khronos validation 1.4.363,ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1):agc_driver_pipelined_sample_dump,_drainedand_cpupass 3/3 on a Ryzen 7000 iGPU (RADV gfx1036, RDNA2), RX 7900 GRE (RADV gfx1100, RDNA3) and lavapipe, with noVUID-on the 7900 GRE.97826291658merged onto main1adc0e2f4b, Khronos validation 1.4.363.1,ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1): the six-test pattern passes 6/6 on an RTX 4090 (620.70.06) against 5/5 on main, with noVUID-on either and no missing-layer line.4a2591d5840, MarcZX10's review): same machine and validation settings, six-test pattern--repeat until-fail:3. Fix 6/6, 96 layer inserts, 0VUID-, no missing-layer line. PR head97826291658with the new check:agc_driver_pm4fails (expected PM4 rejection), the other 5 pass, 0VUID-. Main89b0eef7ab4: 5/5 (no_cpuentry), 0VUID-.dbdd911e25e, MarcZX10's second review):tests/Pm4.cppnow checks thatCLEAR_STATEand aCONTEXT_STATEclear keep the block mask and the dispatch reset restores all 16 blocks; test only, no driver change. Same machine and validation settings, six-test pattern--repeat until-fail:3: fix 6/6, 24 layer inserts, 0VUID-, no missing-layer line. Main2e22ad2062c: 5/5 (no_cpuentry), 18 inserts, 0VUID-.7679aea782f, MarcZX10's third review): Z-pass predication now reads each enabled counter pair on its own instead of every pair up to the highest enabled block, andtests/Pm4.cppchecks the gap mask0x8001(gap blocks unwritten, samples in a disabled block ignored, samples and an unwritten pair in block 15). Same machine and validation settings, six-test pattern--repeat until-fail:3: fix 6/6, 24 layer inserts, 0VUID-, no missing-layer line. Mainbef2f1f77d4: 5/5 (no_cpuentry), 18 inserts, 0VUID-.7679aea782finside the fix(agc): restore versioned draw queue defaults on reset #22535 stack on current main): a test-only guard that allows reads of enabled counter pairs only fails the old bulk reader at the disabled prefix (16 pass, 1 expected failure) and passes this reader (17 pass), with no skips and noVUID-. The guard test lives in fix(agc): restore versioned draw queue defaults on reset #22535.EVENT_WRITE event type 56 is not implemented.check_conventionspasses.pr_overlapreports same-line overlaps with fix(agc): leave GPU-stored words out of frame capture deltas #12568 (dumpSampleCounters), perf(agc): record Vulkan draw commands on an encoder thread #17943 and perf(agc): record transfers in the encoder stream without waiting #18029 (foldSamplessignature); none of them implements this.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)