AGC sampler: border colour table (BORDER_COLOR_TYPE 3) not implemented #665
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 ThisIsAkill on 2026-10-05T12:49:03Z.
What fails
DecodeSamplerResource(core/libs/prx/libSceAgcDriver/Graphics/src/GuestSamplerResource.cpp) maps the sampler'sBORDER_COLOR_TYPE(S# word 3, bits 30–31) 0, 1 and 2 to Vulkan's transparent black, opaque black and opaque white. Type 3, a colour from the border colour table, throws:Seen on Astro Bot PPSA21567 (v01.018), Linux, oneandonlydean's
astrobotat4be8b3e7(the same code as onmain). It ends both Armadillo challenge levels (armadillo_challenge_1,armadillo_challenge_2), in the same compute shader each time, about 3.5–4.5 minutes in. That's 3 runs: the first run ofarmadillo_challenge_1ended earlier on an unrelated NVIDIA Xid 32, and its rerun stopped here. None of the other 80 levels I ran hit it.What's missing
BORDER_COLOR_PTR, the table index in the S#, is not decoded.Plan (I'm working on this)
Vulkan has a direct counterpart:
VK_EXT_custom_border_color. A sampler withVK_BORDER_COLOR_FLOAT_CUSTOM_EXTorVK_BORDER_COLOR_INT_CUSTOM_EXTtakes its colour fromVkSamplerCustomBorderColorCreateInfoEXT. On my RTX 3070 (NVIDIA 615.71) the extension is present, withcustomBorderColorsandcustomBorderColorWithoutFormatboth true andmaxCustomBorderColorSamplers= 4000.Rough scope:
BORDER_COLOR_PTR.SamplerCachekey: today the key is the 4 S# words, but the colour lives in memory.maxCustomBorderColorSamplers.border color tablerejection test intests/GuestSamplerResource.cppinto decode and lookup tests.Open questions before writing it
TA_BC_BASE_ADDRon GFX10-class hardware, but I haven't verified its offset or how AGC writes it. That's the next step: log it in the Armadillo run.If someone already has this, or knows the answers to these questions, please say so.
Imported from boykopovar/AnyPS5. Originally posted by NahuelGenchi on 2026-10-05T14:19:48Z.
Some of this is answered in Mesa, in case it saves a step.
The base isn't only a context register. Graphics uses TA_BC_BASE_ADDR at 0x28080 with TA_BC_BASE_ADDR_HI at 0x28084, but compute has its own pair in the uconfig space, TA_CS_BC_BASE_ADDR at 0x30E00 and TA_CS_BC_BASE_ADDR_HI at 0x30E04. Your failing shader is a compute one, so the CS pair is probably the one to log in the Armadillo run. For both pairs the low register holds the address >> 8 and the HI one the address >> 40 (src/amd/common/ac_cmdbuf.c, the compute and graphics preamble functions, and src/amd/registers/gfx103.json for the offsets).
On GFX10 BORDER_COLOR_PTR is S# word 3 bits 0 to 11 (gfx10-rsrc.json). radeonsi and radv both lay the table out as 16 bytes per entry at base + ptr * 16, holding the raw four 32 bit values. They store float or integer bits in the same slot, and radv maps both VK_BORDER_COLOR_FLOAT_CUSTOM_EXT and VK_BORDER_COLOR_INT_CUSTOM_EXT to the same TYPE 3 entry, so the entry itself doesn't say which one it is. That suggests the format of the sampled image decides how it's read, but I haven't checked that on hardware.
Imported from boykopovar/AnyPS5. Originally posted by ThisIsAkill on 2026-10-05T15:50:06Z.
@NahuelGenchi thanks, that saved a lot of searching. I logged the base registers and dumped the entry on PPSA21567 (
armadillo_challenge_2, compute shader0x5005ae200,astrobot4be8b3e7, Linux). That's 2 runs, and they agree.00007092 00fff000 05000000 c0000000: type 3 in bits 30–31, pointer 0.3e19999a 3f000000 3d4ccccd 00000000. As floats that's (0.15, 0.5, 0.05, 0.0), a plausible colour. As integers it would be around 10⁹ per channel, so this entry holds float bits.TA_BC_BASE_ADDR(context0x28080), once, to0x05059a06and0x05059a04(so the base is0x5059a0600/0x5059a0400)._HIstays 0, so the address is below 2^40. The compute pairTA_CS_BC_BASE_ADDR(0x30E00/0x30E04) is never written, through any SET_UCONFIG / LOAD_UCONFIG path the driver sees, before the compute sampler uses the table. So either the title relies on the graphics pair for compute here, or it sets the compute base some way I'm not seeing. For the implementation, I'll take the base from the graphics pair when the compute pair was never written, and throw if neither is set.I'll write it up as a PR against
mainafter that check.Imported from boykopovar/AnyPS5. Originally posted by ThisIsAkill on 2026-10-06T17:39:07Z.
One more decode on the failing sampler, and it changes what's needed for this title.
The S# that stops
armadillo_challenge_2(compute shader0x5005ae200, the same words in 2 of 2 runs onastrobot4be8b3e7) is00007092 00fff000 05000000 c0000000. Its word 0:Word 3 has BORDER_COLOR_TYPE 3 (table) and BORDER_COLOR_PTR 0.
Mode 2 is clamp to the last texel (
GuestSamplerResource.cppmaps it toVK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE), and none of the three axes uses a half-border or border mode (4 to 7). So as far as I can tell the hardware never reads a border colour for this sampler. The table type is set but unused, and the entry I dumped earlier (0.15, 0.5, 0.05, 0) doesn't matter here.For this title the smaller fix would be enough: keep throwing for BORDER_COLOR_TYPE 3 only when an axis uses one of the border modes (4 to 7), and otherwise create the sampler without a border colour. The table itself, and the question of which base register compute uses, would wait for a title that actually samples through a border mode with a table entry. Would that be acceptable, or would you rather have the table implemented in one go?
Limits: I have the S# words for Armadillo Challenge 2 only. Armadillo Challenge 1 stops at the same shader, but I didn't log its sampler.
Imported from boykopovar/AnyPS5. Originally posted by ThisIsAkill on 2026-10-06T18:50:17Z.
Opened #941 for the narrow case above. A table border colour no longer throws when no axis uses a border mode (clamp modes 4 to 7), which unblocks Armadillo Challenge 2 on PPSA21567.
It does not implement the border colour table. A sampler that names a table entry and also uses a border mode still throws, so this issue stays open for that.
Imported from boykopovar/AnyPS5. Originally posted by awake-devel on 2026-10-07T17:01:40Z.
@ThisIsAkill are you still planning the full table after #941? If not, I'd like to take it. My plan, building on your notes and @NahuelGenchi's:
VK_EXT_custom_border_color(withcustomBorderColorWithoutFormat) when the device has it. Without it, a table colour on a border mode keeps throwing.BORDER_COLOR_PTR(S# word 3, bits 0–11) and read the 16-byte entry atbase + ptr * 16when the sampler is built. Add the entry's four dwords to theSamplerCachekey, and count custom samplers againstmaxCustomBorderColorSamplers.TA_BC_BASE_ADDR/_HI(0x28080/0x28084), dispatches useTA_CS_BC_BASE_ADDR/_HI(0x30E00/0x30E04), as Mesa programs them. A dispatch that reads a table colour with the CS pair never written throws, instead of falling back to the graphics pair. PPSA21567 only shows that the title doesn't need the CS pair for a sampler that never reads the border, so I'd record that in TechnicalDebt rather than guess. If you'd rather keep the fallback you suggested, say so.tests/GuestSamplerResource.cpp, plus a driver execution test that samples outside a texture with clamp-to-border and checks the colour from the table.I can't test this on a title that samples through a table border, so the PR would be checked on the synthetic tests only (Linux, GTX 1050 Ti, NVIDIA).
Imported from boykopovar/AnyPS5. Originally posted by ThisIsAkill on 2026-10-07T17:26:07Z.
@clem-gb I'm not planning the full table now, so please go ahead.
On the base register: I'd drop the graphics-pair fallback I suggested. My only evidence for it was this title, and the decode since then shows its sampler never reads the border, so there's nothing to back it. Throwing when a dispatch reads a table colour with the CS pair never written, plus a TechnicalDebt note, matches what we actually know.
What I have that might help your tests:
TA_BC_BASE_ADDR+ 0 the title stores3e19999a 3f000000 3d4ccccd 00000000(0.15, 0.5, 0.05, 0.0 as floats). The base is0x5059a0600in one run and0x5059a0400in the other, with_HI0.00007092 00fff000 05000000 c0000000, which clamps to the edge on every axis. So PPSA21567 can't exercise a table border; the synthetic tests are all there is for now.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T08:45:57Z.
Partly addressed by #941: a table border colour (
BORDER_COLOR_TYPE3) no longer throws when no axis uses a border mode (clamp modes 4 to 7), covered inGuestSamplerResource.cpptests; still open: a sampler that names a table entry and also uses a border mode still throws (BORDER_COLOR_PTR,TA_BC_BASE_ADDRandVK_EXT_custom_border_colorare not implemented).Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-16T08:47:04Z.
@awake-devel are you still working on the border colour table from your plan above? I don't see a pull request for it yet. If you've moved on, I'd like to take it and follow your plan as written (custom border colour with
customBorderColorWithoutFormat,BORDER_COLOR_PTRand the 16-byte entry in theSamplerCachekey, the CS pair for dispatches with no fallback to the graphics pair, float entries only, and the execution test). If you're still on it, I can test your branch on a second vendor instead.Both devices on this machine support what the plan needs (Linux, Mesa 25.2.8):
customBorderColorscustomBorderColorWithoutFormatmaxCustomBorderColorSamplersSince llvmpipe has it too, the execution test would also run on lavapipe in CI.
Imported from boykopovar/AnyPS5. Originally posted by awake-devel on 2026-10-16T08:49:05Z.
Just so you know, I can't work on this for the two upcoming weeks, you can work on it if you need
Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-16T10:21:31Z.
@awake-devel thanks, I'll take it, following your plan above. I'll link the pull request here.
Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-16T12:42:55Z.
Implemented in #6804, following the plan above.