feat(agc): read sampler border colours from the border colour table #6804
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6804"
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 YossiYad on 2026-10-16T12:42:48Z.
What
A sampler whose S# takes its border colour from the border colour table (
BORDER_COLOR_TYPE3) and clamps to the border on any axis (clamp modes 4 to 7) throws:#941 stopped the throw when no axis reads the border, which got PPSA21567 past its Armadillo challenges, but the table itself was still missing (#665). This implements it, following the plan @awake-devel posted there.
VK_EXT_custom_border_coloris enabled when the device hascustomBorderColorsandcustomBorderColorWithoutFormat(the S# carries no image format). Live table samplers are counted againstmaxCustomBorderColorSamplers; past it, or on a device without the extension, the sampler throws.BORDER_COLOR_PTR(S# word 3, bits 0 to 11) names a 16-byte entry atbase + ptr * 16.DecodeSamplerResourcetakes the entry's four dwords and returns them asVK_BORDER_COLOR_FLOAT_CUSTOM_EXT. Without an entry it throws as before, and a sampler paired with an integer image throws until an integer entry is measured.TA_BC_BASE_ADDR/_HI(context registers 0x20/0x21) and dispatches useTA_CS_BC_BASE_ADDR/_HI(user configuration registers 0x380/0x381), address bits 8 to 47, as Mesa's radeonsi programs them. A dispatch never falls back to the graphics pair. A sampler that reads the table with its pair never written throws, as @ThisIsAkill suggested in #665. The draw handler reads the graphics pair from the queue and passes it toVulkanDevice::Draw, so the decoded draw state, which the pipeline journal stores, does not change.SamplerTablebindings) still refuse every border mode, as before.Title. None known. PPSA21567 writes the table (entry 0 is 0.15, 0.5, 0.05, 0.0), but its only table-type sampler clamps to the edge, so after #941 it no longer reaches this path. The tests below are synthetic.
Tested
Current validation (2026-10-25): merged main
16ff208dc3and reconciled the draw-trace parameters with border-table propagation. AMD Radeon RX 7700 XT, RADV Mesa 26.2.4, Bazzite 44: focused native-FMASK, shader-memory and graphics tests pass on main (3/3); the same pattern plus both border-table execution tests passes on this branch (5/5). Both runs useANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, andctest -V. ZeroVUID-errors and no missing-layer warnings. No title or full-suite rerun for this update.Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release,
-DBUILD_TESTING=ON), based onmain66e71b63d:Full build and
cteston Intel UHD Graphics 620 (Mesa 25.2.8 ANV): 1429 of 1431 pass.agc_driver_gated_dispatch_captureand its_short_timeoutvariant failed underctest -j4(11 s instead of 5 s) and pass 3 of 3 each when run alone.agc_driver_border_color_tableandagc_driver_border_color_table_registerspass on the Intel GPU and on llvmpipe.New
agc_driver_border_color_table: a compute shader samples a 4x3 texture inside and one texel past each edge through a point clamp-to-border S# of type 3. Outside the texture it reads the named entry, another entry, the entry rewritten between two dispatches, and the table at a base moved by 256 bytes; a dispatch with no table base throws. It passes on both Intel UHD 620 (ANV) and llvmpipe, so it also runs on lavapipe in CI. ANV rounds the border colour to the texture's UNORM8 precision (0.5 reads back as 128/255), so border texels are compared within 1/255.New
agc_driver_border_color_table_registers, added after @Dextroid17 pointed out that the first test hands the base toVulkanDevicedirectly and never reaches the register reads. It submits throughsceAgcDriverSubmitDcb:TA_CS_BC_BASE_ADDRwithSET_UCONFIG_REG0x380/0x381;TA_BC_BASE_ADDRwithSET_CONTEXT_REG0x20/0x21.Each samples one texel past the texture's edge through a type 3 S#, and checks the entry's colour, that the other pair naming a different table does not change it, and that a rewritten entry takes effect with the base kept from an earlier submission. A draw after a context clear throws for the missing base. It passes 3 of 3 on the Intel UHD 620 and on llvmpipe. With either handler's register read cut, it fails with
the table base register was never written.Negative controls:
agc_driver_graphics: the table-border decode tests replace the rejection test, and new tests decode both register pairs.tools/check_conventions.py --base origin/mainpasses, andtools/pr_overlap.pyreports no overlapping pull request. Windows and macOS were not built here; the draw and dispatch register reads are covered byagc_driver_border_color_table_registers.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 jotitadev on 2026-10-16T15:30:15Z.
Review: COMMENTED
NVIDIA run, since the description covers Intel ANV and lavapipe.
Machine: NVIDIA GeForce RTX 3070, driver 595.99.02, Vulkan 1.4.329, plus lavapipe (Mesa 26.0.3, LLVM 21.1.8) on the same machine. Ubuntu 26.04 (kernel 7.0.0-38), i7-8700, GCC 15.2, Release,
BUILD_TESTING=ON. Headb376cf53bmerged ontomainbc400bede, clean merge.GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02), lavapipe (Mesa 26.0.3, LLVM 21.1.8), Ubuntu 26.04
agc_driver_border_color_tablepasses 3/3 on the RTX 3070 (0.28-0.34 s,border color table tests passed, not skipped) and 3/3 on lavapipe. So theVK_EXT_custom_border_colorpath withcustomBorderColorWithoutFormatalso works on the NVIDIA proprietary driver. The test compares border texels within 1/255; I did not check whether this driver needs that tolerance.agc_driver_graphicspasses 3/3 on both, with the new register-pair decode tests.ctest -R "^agc|shader|recompiler" -E "agc_display_buffer_dcc|agc_driver_flip|agc_driver_lds_atomics64|display|flip" -j1 --timeout 60: 616 tests. Onlyagc_driver_store_over_untrackedfails, and it fails on unchangedmainbc400bedehere too (#6347).Not checked: a red run on this machine. With only the tests on
main's sources,GuestSamplerResource.cppdoes not compile (it needsBorderColorTableIndex), so I relied on your negative controls. Also not checked: Windows, draw-path execution, titles.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-16T21:06:58Z.
Draw-path execution run. The description notes there is no draw execution test, and @jotitadev's review lists draw-path execution as not checked.
Setup: head
b376cf53bas is (based onmaineb901bcf4), Release,BUILD_TESTING=ON, CachyOS (kernel 7.2.9), i9-11900K, GCC 16.2.1, lavapipe (Mesa 26.2.4, LLVM 23.1.1, Vulkan 1.4.354). Each run used a clean environment and a fresh shader cache. Two probe programs, not committed, were built as execution tests and run as binaries. They submit real DCBs throughsceAgcDriverSubmitDcb, so the base registers go throughDriver's packet handling, not straight intoVulkanDevice.TA_BC_BASE_ADDR/_HIwithSET_CONTEXT_REG0x20/0x21, thenDRAW_INDEX_AUTOof a full-viewport triangle. The pixel shader samples the 4x3 texture at (-0.5, -0.5) through a clamp-to-border S# of type 3 and exports the result. Each case takes the most common non-zero RGBA8 value in the 1 KiB colour buffer (128 of its 256 pixels in every passing case) and compares each byte within 1. 4 runs, 0 failures in each:a sampler reads border color table entry 2, but the table base register was never written(2 runs). The driver keeps its first failure, so a no-base draw later in the same process only gets that error back and is not a separate result. The probe then exits 1 with the same error at shutdown.SET_UCONFIG_REG0x380/0x381 andDISPATCH_DIRECT(entry, 8 rewrites, base not re-sent, base moved by 256, graphics pair set elsewhere, entry 5), with and withoutAPS5_PIPELINE_DISPATCH=1, 1 run each, 0 failures in each. The type 0 to type 3 switch read the new entry with and withoutAPS5_PIPELINE_DISPATCH=1, 1 run each, on a build with two added log lines inDispatch.cpp. Those lines showedrecipeHit=0on type 3 rounds 1 to 3 (round 0, a new key, logs nothing), while type 0 rounds 1 to 5 and the type 0 dispatch after the switch loggedrecipeHit=1. WithAPS5_PIPELINE_DISPATCH=1the type 3 dispatches ran inline.borderColorTableset tostd::nulloptatDraw.cppline 20, the draw probe fails 3 of 3 with the error above. With the same change atDispatch.cppline 416, the compute probe fails 3 of 3.agc_driver_border_color_tablestill passes in both arms (1 run each). By reading, it callsVulkanDevice::Dispatchwith the table address as an argument (BorderColorTable.cppline 128), so it does not reach either register read. The probes cover that step.agc_driver_border_color_tableandagc_driver_graphicspass 3 of 3 through ctest, as the baseline for the arms above.If you want a draw execution test in this PR, I can post the probe here (284 lines, setup taken from
DrawCacheReuse.cpp).Not checked: this head merged onto current
mainbc3c0fc13, which is 156 commits pasteb901bcf4. Also not checked: a hardware GPU (lavapipe only), themaxCustomBorderColorSamplerslimit, integer-format entries, indirect draws, Windows, titles. CI's build jobs are skipped on this head.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by TheSovietWaffle on 2026-10-17T11:29:34Z.
Windows data point: head
b376cf53bas-is, Release, Windows 10 Pro 22H2 (19045), WinLibs GCC 15.2.0 r7.agc_driver_border_color_tablepasses on both devices of this host, chosen withANYPS5_GPU:1002:164e, AMD Windows driver): 3 of 3.Not checked: other tests, titles.
AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-17T11:45:16Z.
@jotitadev thanks for the NVIDIA run. Good to see
customBorderColorWithoutFormatwork on the proprietary driver as well.Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-17T13:19:25Z.
@Dextroid17 thanks, that is the step the test didn't reach. I'll add a draw and a dispatch execution test that set the base through
SET_CONTEXT_REGandSET_UCONFIG_REGand submit through the driver, so the register reads are covered in the PR itself.Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-17T13:19:26Z.
@TheSovietWaffle thanks for the Windows runs on NVIDIA and AMD.
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-17T15:09:16Z.
Review: COMMENTED
Re-run on
7f8812e96for the new register test, on NVIDIA and lavapipe.Machine: Ubuntu 26.04, i7-8700, GCC 15.2, Release,
BUILD_TESTING=ON. NVIDIA GeForce RTX 3070 (driver 595.99.02) and lavapipe (Mesa 26.0.3, LLVM 21.1.8) on the same host. Head7f8812e96merged ontomain47a266cf9(clean).ANYPS5_NO_SHADER_CACHE=1,-j1 --timeout 30.agc_driver_border_color_table_registers,agc_driver_border_color_table,agc_driver_graphics^agc(651 tests)main: 649/649)main: 649/649)Draw.cpppasses no table base (borderColorTable = std::nullopt)..._registersfails:a sampler reads border color table entry 2, but the table base register was never written;agc_driver_border_color_tablepassesDispatch.cpppasses no table base..._registersfails:compute shader ...: a sampler reads border color table entry 2, but the table base register was never written;agc_driver_border_color_tablepassesSo the new test covers the
TA_BC_BASE_ADDRandTA_CS_BC_BASE_ADDRreads on the draw and dispatch paths that @Dextroid17 pointed out. The older test does not cover them. In both broken runs the error escapes asterminate(ctest reportsSubprocess aborted), not through the test's owncatchinmain.Not run: Windows, AMD, Intel, any title.
GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02) and lavapipe (Mesa 26.0.3), Ubuntu 26.04
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-18T06:52:20Z.
@jotitadev thanks for the re-run on the register test.
Rebased onto current
main(head6aa198507,main66e71b63d). The only conflict was inVulkanDevice.cpp, wheremainaddedPresyncCountsnext toPrepareDispatch; I kept it as it is onmainand added theborderColorTableparameter. The other commits are unchanged.On the rebased head, the full build passes, and
agc_driver_border_color_tableandagc_driver_border_color_table_registerspass on Intel UHD 620 (ANV) and llvmpipe. Fullcteston the Intel GPU: 1429 of 1431; the twoagc_driver_gated_dispatch_capturetests failed under-j4and pass 3 of 3 each when run alone.Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-19T10:11:58Z.
Rebased onto current
main(head4f68fde80,main36f60df9e). The only conflict was inGraphics/include/State.hpp, wheremaindeclaredNormalizeUnusedViewportDepthat the spot where this PR declares the border colour table base; I kept both. The other commits are unchanged, and the added and removed lines match the previous head line for line.On the rebased head the full build passes, and
agc_driver_border_color_tableandagc_driver_border_color_table_registerspass 3 of 3 on the RX 7700 XT (RADV). Five other tests fail in the fullctesthere (application_heap_lazy,agc_driver_tessellation,agc_driver_bda_device,agc_driver_image_table_vouched_lookups,agc_driver_guest_memory_lifetime), and they fail the same way on plainmainon this machine.Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-19T10:15:59Z.
@adriadam10 this is rebased onto current
mainand mergeable again (head4f68fde80), with an approval from @Dextroid17 and runs on NVIDIA, AMD, Intel and lavapipe above. Ready for review when you have a moment.Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-19T13:51:33Z.
Rebased onto current
main(head78edb1495e). The only conflict was inExecution/src/Driver/Draw/Draw.cpp, wheremainnow computesQueuedDrawReadRangesand passes the reads toQueue0().Enqueue; I kept that and theborderColorTablecapture on the commit lambda together. The other commits are unchanged, and the added and removed lines match the previous head line for line.On the rebased head the full build passes, and
agc_driver_border_color_table,agc_driver_border_color_table_registersandagc_driver_image_sample_border_colorpass here (3/3 each,--repeat until-fail) on RADV.Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-19T21:17:35Z.
Rebased onto current
main(head7d1e77541,mainbf2c63f85), with two changes beyond the rebase:mainadded a second queuedcommitDrawcall for direct draws, which no longer compiled against this PR's signature. It now capturesborderColorTableand passes it on, the same as the recipe path. That is folded intofeat(agc): read table border colours when a draw builds its samplers.mainnow warns on debt entries over 1000 characters, and this PR's entry was 1438. I shortened it to 916 and put the gap first (not measured on a PS5 or seen in a title). The facts in it are the same.The other text conflict was an include in
Dispatch.cpp(kept both). Apart from those two changes, the added and removed lines match the previous head.On the rebased head the full build passes,
agc_driver_border_color_tableandagc_driver_border_color_table_registerspass 3 of 3 on RADV, andcheck_conventionshas no findings. The fullctesthas 6 failures here (application_heap_lazy,application_heap_scripting,agc_driver_tessellation,agc_driver_bda_device,agc_driver_image_table_vouched_lookups,agc_driver_guest_memory_lifetime), and all six fail the same way on plainmainon this machine.Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-20T14:35:23Z.
Rebased onto current
main(headba13cf766,main5f7e30233). The only conflict was theDrawdeclaration inVulkanDevice.hpp, wheremainaddedDrawInputsInPlace()right below it; I kept both. The added and removed lines match the previous head, and the threeDrawcall sites still passborderColorTable.On the rebased head the full build passes,
agc_driver_border_color_tableandagc_driver_border_color_table_registerspass 3 of 3 on RADV, andcheck_conventionshas no findings. The fullctesthas 5 failures here (application_heap_lazy,application_heap_scripting,agc_driver_tessellation,agc_driver_guest_memory_lifetime,agc_driver_image_array_window_past_layer_limit). The last two fail 3 of 3 on plainmainon this machine as well, and the first three are the known ones from my previous rebase.Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-21T06:54:05Z.
Merged current
maininto the branch again (head0a4de8265,main7ce3b1df3), on top of the earlier merge, so nothing was rewritten.mainadded athreadGroupparameter toDispatchIndirectanddispatch, the same functions this PR gives a trailingborderColorTable. Both are kept now,threadGroupfirst andborderColorTableafter it, and the directDispatchpasses{}for the thread group. In the debt filemainrewrote theFORCE_DEGAMMAentry next to the border colour entry; I tookmain's text and kept ours. Apart from those signatures, the PR's added and removed lines againstmainmatch the previous head.The full build passes, the three
border_colortests pass 3 of 3 on RADV, andcheck_conventionshas no findings.agc_driver_image_array_window_past_layer_limitfails here, but it fails the same way onmain7ce3b1df3(a sampled value of 107/255 where 147 is expected), so it isn't from this PR.@Dextroid17 thanks for the approval.
Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-22T05:34:41Z.
@oneandonlydean @adriadam10 ready from my side: it merges cleanly, CI is green, Dextroid17 approved it, and Dextroid17 and TheSovietWaffle both ran it.
Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-22T13:07:23Z.
Merged current
main(3ca07d086) into the branch again (head321bff9a5).mainadded anhtileClearparameter toDispatchanddispatch, in the same spot as this PR'sborderColorTable. Both are kept,htileClearfirst, and the calls that passborderColorTableby position (DispatchIndirectintodispatch, andBorderColorTable.cpp) now passstd::nulloptfor it. The full build is clean, and the three border colour tests andnative_depth_bda_clearpass 3 of 3 (the latter skips on this GPU). Across all 639 AGC tests the only failures on this machine areimage_array_window_past_layer_limitandtessellation, which fail the same way onmain.pixel_interlockfailed once in the full parallel run and then passed every rerun, alone and in parallel.Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T20:00:18Z.
Review: COMMENTED
Correction (2026-11-01): the title-ID/log demand below is not a CONTRIBUTING requirement;
Unblocks: noneis allowed. The technical points below are unaffected.1. No title reaches this on
main. The body says "Title. None known" and "Unblocks: none": PPSA21567 writes the table but its only table-type sampler clamps to the edge and no longer reaches the path after #941. The tests are synthetic. With no title ID and log line this is a new device feature (VK_EXT_custom_border_colorplumbing, register reads, sampler counting) that nothing running exercises, which is the kind of PR that gets closed.2. Draws that read the table are never cached. "A build that read an entry is never marked reusable, so the draw and dispatch resource caches never hand it to a later draw whose entry may have changed." Every draw or dispatch with a table-type border sampler therefore rebuilds its resources from scratch, each time. That may be the only exact option, but the cost is unmeasured: please say how a title using this pays it (a counter for uncached builds), or key the cache on the entry bytes as the sampler cache already does so the draw cache can be reused when the entry is unchanged.
3. Custom border sampler budget. Samplers are counted against
maxCustomBorderColorSamplersand the sampler "throws" past it. Does a sampler that is released (thefetch_subpaths inDecodeSamplerResource) always get released when a sampler-cache entry is evicted or when a build fails after the sampler was created? A leak here turns into a permanent throw after N draws, and I do not see a test that creates and drops more than the limit.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-11-08T03:10:58Z.
Review: CHANGES_REQUESTED
This no longer merges with current
main, and a mechanical rebase is not enough:git merge-treeagainstmainconflicts inVulkanDevice.hpp,VulkanDevice.cpp,Dispatch.cpp,ShaderResources.hppandShaderResources.cpp. Replaying the commits one by one also hitsDriver.hppandDraw/Draw.cpp:mainmoved the draw path intoDrawTail, with the new trace andshapeparameters onDraw/commitDraw, so whereborderColorTableis captured and passed on needs re-deciding, not just merging. The new tests go through that path, so they need rerunning after it.372c509265,0a4de8265b,321bff9a5c,9d9cd22707,132ee009f4,0853681320and the earlier ones). CONTRIBUTING asks for a linear history, so please rebase ontomaininstead of merging it again.core/libs/prx/libSceAgcDriver/tests/GuestSamplerResource.cpp:566(DecodeSamplerResource(words, false, false, true, &tableColor)expecting "integer border color from the border color table"). The production check marks that path as unimplemented, so the assertion would fail once it is implemented. Keep the positive custom-float cases and the missing-entry checks.After the rebase, rerun
agc_driver_border_color_table,agc_driver_border_color_table_registersandagc_driver_graphics. The rest was checked in earlier reviews and is unchanged.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T05:58:28Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the implementation and inspected tests support the stated border colour table behavior.
What I ran
Reviewed head
0853681320bb72964e9eea75cdbb1586d734d066. No commands or tests were run in this review; validation results in the PR description are author reported.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The full text of
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppandcore/libs/prx/libSceAgcDriver/tests/Graphics.cppwas excluded from the review folder; their relevant changed regions were inspected through the pinned reader and diff. Other full changed-file texts listed as included inmanifest.jsonwere read selectively, not exhaustively. No build, tests, CI, or physical-console behavior was independently verified. The PR description's reported test results were not rerun.To get this to a good state
Nothing is required.
Pull request closed