fix(shader): decode the scalar aperture sources 235-238 instead of failing the shader #1940
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1940"
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 Dextroid17 on 2026-10-09T01:28:15Z.
What
DecodeRdnaScalarSourcethrowsunsupported scalar source operand codefor scalar source codes 235 to 238, which fails the whole shader. Those codes have names —src_shared_base,src_shared_limit,src_private_base,src_private_limit, per LLVM'sSIRegisterInfo.td(lines 266-269) — so this decodes them to their own operand kinds and names, and makes a read of one refuse with a message that names the source instead of falling into the generic invalid-operand path.readScalarCodealso gained explicit refusal cases: itsdefaultanswered 0, which for an aperture base would be a silently wrong address rather than a refusal.What is deliberately not modelled: the value. The wave's shared and private aperture bases and limits are unknown here, so a shader that reads one refuses (and, with #1836's deferral, is left unprepared) instead of being handed a plausible address. A shader that only carries the value into an address — the shape that motivated this — prepares normally.
Tested
aperture_sourcestest: the four codes decode to their four kinds, and an instruction whosesource0is 235 decodes with that kind. It fails onmain(the decode throws) and passes here.ctestdecoder/image/scalar/control-flow subset on lavapipe (the CI device): 62/62 passed.eboot.binrelinked, staged runtime layout, RTX 3080 Ti, Linux. With #757 + #1836 applied it aborted about 13 minutes in withunsupported scalar source operand code 235 at program counter 856(reported as #1920); with this change it runs about 24 minutes and 897 shaders without reaching that call, and the one shader that does read an aperture source is deferred with the named refusal instead of terminating the process.Not verified: the value the console gives these operands (that is what "not modelled" means), and any title whose shaders read rather than carry them.
Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T15:23:31Z.
Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), RTX 3060 Laptop (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head
b0c4d944, merged ontomaind70b8998in one build with 33 other AGC/shader PRs that had no Windows run.aperture_sources. None of them reported skipping a case.PATHsetup.No title was run.
🤖 Addressed by Claude Code
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-09T19:58:14Z.
Thank you for this — a native Windows run is exactly the evidence this PR could not produce for itself, and folding 33 AGC/shader PRs into one build is more useful than running yours alone.
On the one failure you attribute here: I do not think it is #2257's registration. Its two new modes are added to the same
foreach(preparedMode ...)list as the existing ones, and the Windows PATH line sits inside that loop:so
agc_driver_prepared_shaders_deferred_undecodablegets the same modification as..._indirectand the rest. Your later run at5b8316ffon #2257 went the other way — all sevenagc_driver_prepared_shaders*pass — and you note a local fix for #2193's Windows build in that same run. That reads like a missing DLL from #2193 rather than a registration gap in #2257.If you can still see the 15:23 failure, could you say which binary it reported as missing, or re-run on #2257's current head from a clean shell? If it does turn out to be the registration I will fix it here, but I would rather correct the cause than the attribution.
aperture_sourcesreporting no skipped cases is the part I wanted most, so thank you also for saying explicitly that no title was run.Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by tv7 on 2026-10-10T00:38:47Z.
Tested on Windows with a second title that hits the same failure as #1920.
Setup: Windows 11 Pro (10.0.26200), RTX 3070, GCC 15.2.0 UCRT (WinLibs), Release. This PR (b0c4d944a) merged onto main
54f28f2d3, together with other open PRs this title needs to get this far (#1836, #1893, #1709, #1837, and #1339 before it merged). Title: Marvel's Wolverine (PPSA03671).Without this PR: the title aborts while preparing shaders with
unsupported scalar source operand code 235 at program counter 816(src_shared_base), after about 800 shaders.With this PR: that abort is gone. The title runs for the whole 300 s test window without crashing, with the window and swapchain up and about 1,400 shaders compiled.
aperture_sourcesand the rest of ctest (521/521) pass on this host with the same merge.Limits: one title, one run. I have not checked whether the shaders that read the aperture registers render correctly, or whether frames are presented after the swapchain is created. The remaining log lines are shaders deferred at registration for other known reasons (data-dependent
s_swappc_b64, registered type 8).Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T05:58:19Z.
Review: CHANGES_REQUESTED
Checked the decode, the translation refusals and the build:
aperture_sourcespasses here and needs the change to compile. Thanks also to @popcoder565 and @tv7 for the Windows runs. Two things to fix:core/libs/tests/ApertureSources.cpp:28-33:CheckRefusesTranslationonly checks the decoded kind. The refusal of a read is what the PR promises and replaces the old silent0default, but nothing pins it. Translate an instruction that reads source 235..238 (seecore/libs/tests/ScalarSwappc.cppfor how to build and translate one) and assert that it throws with the source named, for both thereadScalarCodeand thereadRawU32paths.core/libs/prx/libSceAgcDriver/CMakeLists.txt:1024-1030: the new test block is not indented like the surrounding ones.Once these are in, this is ready from my side.
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-10T10:58:40Z.
Both points are addressed, and the branch is rebased onto
a29ef592— the PR went fromCONFLICTINGtoMERGEABLE. The only conflict was theTechnicalDebt.mdentry, resolved by keeping both lines (the newVertexBufferReadSizeentry and this one).1. The refusal is now pinned by a test that translates, not just a decode check.
core/libs/tests/ApertureSources.cppbuildss_mov_b32 s0, <source>for each of 235 to 238, translates it throughTranslationContext, and asserts the refusal names the source it refused. Both refusals now name it —readRawU32throughRdnaOperandToString(operand),readScalarCodethrough the same mapping — so a bare "not modelled" can no longer be told apart from a decode gap.Two negative controls, each against a rebuilt binary, then restored:
ctest -R "aperture|scalar_swappc|shader_memory|scalar_call"→ 6/6 pass.tools/check_conventions.pypasses;tools/check_test_registration.pyreports "none new".2. The CMake block is indented like its neighbours (4 spaces at statement level, 8 inside
if(WIN32), 12 for the continuedPATHline). While fixing that I also found my earlier revision had de-indented the following pre-existingadd_test_executable(scalar_call_tests …)line to column 0; that is restored, so the diff is now a pure insertion rather than an insertion plus a moved line.One thing I could not test, and would rather flag than paper over: the
readScalarCodehalf of the refusal is defensive — no decoded instruction reaches it. Every caller traces to a register number:getResourceDword(index, dword)is called withmemory.resource/memory.sampler, each derived frominst.sourceX.reg / 4uon a decoded SGPR (≤ 105), so the buffer and sampler paths top out at26 * 4 + 3 = 107and the image path (8 dwords) at26 * 4 + 7 = 111;getScalarAddressResource(base)takesbase≤ 106 and readsbaseandbase + 1, topping out at 107; and the last caller reads a terminator'sindirectSelectorCode, which is never assigned anywhere in the tree — it is default-initialised toInvalidControlFlowIdand guarded by!= InvalidControlFlowId, so that branch is dead. The only other writers ofresource/samplerare the memory patches inResourceTracker.cpp, which carry collection ids, and a literal1uinInstructionTranslator.cpp; neither can reach 235. Since the method is private, a translation test cannot construct a code of 235 to 238 for it.I have left the guard in place, because it refuses instead of silently returning
0— the behaviour this PR is about. If you would rather not carry an unreachable branch, say so and I will drop it; if you want it pinned, I can add the seam.Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-10T11:25:02Z.
Measurement on a real title, in case it helps this land.
PPSA26344 (Ghost of Yōtei, 01.008) gets further with this change than without it.
Without it — current
main, Linux x86-64, lavapipe, running the title's own directory (yotei-header.log):With it — this branch rebased on
a29ef592, same device, same run directory (yotei-main.log):2393x1346, 3 images),So this change moves the title past the wall #1920 names, which is why
unsupported scalar source operand code 235no longer appears.One detail worth having, because it is easy to assume the opposite: the new aperture refusal does still fire in these runs — each log records
the scalar aperture source src_shared_base is not modelled— but it is not fatal. Registration skips that shader and the run carries on to the header refusal below, instead of ending here.A follow-up build that also names the fields of that refusal (
yotei-both.log) shows what the title replaces:Three qualifications, so the numbers are not read for more than they are: the runs are not a controlled A/B on a single tree — the later one reused a warm shader cache (1264 hits, no misses) while the first was fully cold; reaching a swapchain is not a correct frame; and the wall the title stops at next is another open question rather than a pass.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T22:26:48Z.
Review: APPROVED
Re-checked after the rebase:
aperture_sourcesnow translatess_mov_b32from sources 235..238 and pins that the refusal names the source; with theOperandAccess.cpprefusals reverted the test fails, and without the change it does not compile.agc_driver_flat_aperturesand the scoped ctest are green, CI is green, and the Windows runs by @popcoder565 and @tv7 cover the platform. Merging.