feat(agc): select occlusion counter blocks with PIXEL_PIPE_STAT_CONTROL #22465
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/22465"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by B-Howell on 2026-11-17T17:17:43Z.
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 (#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 #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 #22535.EVENT_WRITE event type 56 is not implemented.check_conventionspasses.pr_overlapreports same-line overlaps with #12568 (dumpSampleCounters), #17943 and #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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-17T18:08:01Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
97826291658959a1dcac3c01dc414f468d60ac31, basemain. No merged-preview check.repo_read.py, search and line-range reads).Results
SampleCounter.comp,SampleDumps.compread from the diff onlyFindings
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:
PIXEL_PIPE_STAT_CONTROL:github.com/boykopovar/AnyPS5@9782629165/core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp (L494-L501)github.com/boykopovar/AnyPS5@9782629165/core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp (L1211-L1214)QueueState, so the mask returns to 16 blocks:github.com/boykopovar/AnyPS5@9782629165/core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp (L1170)github.com/boykopovar/AnyPS5@9782629165/core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp (L708-L734)Not verified
sceAgcDcbResetQueuewrites, and the CUSA00900 title run. These are the author's reports and are not confirmed here.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.To get this to a good state
Nothing is required.
The optional point is listed under Non-blocking above.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-17T19:09:36Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
4a2591d5840b0d908713304a3aef0580a24b4f83, basemain. No merged-preview check.Results
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
07fffc00,0007fc00), the Bloodborne CUSA00900 run and the heap crash are not checked here.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.files.jsonlists no excluded files.To get this to a good state
Nothing is required.
Optional: the two points above.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-17T20:56:27Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
dbdd911e25e8edecfbb4e9a7b65cab3534ac933c, basemain. No merged-preview check.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.repo_read.py(7 calls, listed below).Results
Commands
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
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp: only the two changed hunks were read, not the whole file.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.PredicationByteswas replaced by a pair count. I did not readPredicationBytes, so I cannot compare the old and new read sizes.SampleCounter.compandSampleDumps.comp: not compiled. The push-constant size is checked only by the C++static_assert.check_conventionsandpr_overlap: not checked.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-17T21:54:09Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
7679aea782f801b37350caac9d90957b6e4f2d30, basemain.description.md,commits.md,manifest.json,files.jsonanddiff.patchfrom the review folder.repo_read.py:Results
diff.patchPm4.cppranges aboveFindings
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
tests/Pm4.cppdoes not compile onmainwas not checked.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.VulkanDevice.cpp, which is too large for the review folder.To get this to a good state
Nothing is required. The non-blocking points above are optional.