feat(agc): implement image and sampler tables indexed at runtime offsets #757
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/757"
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 Celegans12 on 2026-10-05T21:11:40Z.
What
Image and sampler descriptors that
s_buffer_loadreads at runtimekey * stride + addendoffsets fail planning (GetImageResource dword 0 is not a valid runtime value). This snapshots such tables per invocation and selects the entry in the shader; table contents stay out of shader, pipeline and disk-cache keys.ANISO_OVERRIDEpairings, and a T# whose surface has no mapped byte.(key << n) & maskkeys (@tibzejoker's fix) keep the whole table. Records are read in runs (@SleglJan'sShaderMemory::readWords).docs/dev/ARCHITECTURE.md; runtime ABI 12, disk format 32 (stored plans carry table columns); limits indocs/dev/debt.#758 adds tables loaded through 64-bit pointers. Table FMASK entries still fault. #5461 and #5472 also change the disk format, and #5620 extends the bindless-table path this replaces. #5550's T# that is both queried and sampled is one column here (its test is ported), as is #5188's T# read at a user-data offset, whose test now checks the record each key selects. #4783's key reservation and #5408's key-miss trace count the image shapes this adds to content keys.
Tested
Based on
main066b58fa. Windows 11 (MinGW-w64 GCC 15.2.0) and Linux: configure -DBUILD_TESTING=ON, full build, --target libs, ctest.log_macrosalso fails onmainhere.main84b01f9c: 1171/1173;agc_driver_bc_block_copyandagc_driver_depth_compare_copyalso fail onmainthere.agc_driver_image_table,_cache,_reuse,_cache_bounds(new: both bounds),agc_driver_bindless_images,agc_shader_bindless(new: shared keyed columns, masked offsets, #5550's queried and sampled T#),agc_driver_key_missandagc_driver_graphics(new: table words and shapes in content keys) andagc_shader_disk_cache(plans with table columns and key domains round trip) pass on both. The table tests don't build onmain;_cache_boundsfails without the two bounds.Not tested: native RADV, Linux with write tracking, console behaviour.
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 oneandonlydean on 2026-10-05T22:56:49Z.
Thanks for this. The Linux job fails in the new
agc_driver_image_tabletest on all three of #757, #758 and #759 (run 37374351259):I don't think the table path is at fault here. The check just before it, that record 4 gives the same words as a direct binding of the same T# and S#, passed in that run, so the direct binding returns 0x00000001 on lavapipe too. Record 4 pairs
LinearWrapwith a 32_UINT image, andrequiresPointSamplerforces point filtering only for the signed integer class (and conversions and depth), so an unsigned integer image reaches Vulkan with a linear filter. R32_UINT has noSAMPLED_IMAGE_FILTER_LINEARsupport, so the result is undefined: NVIDIA happens to return the point sample, lavapipe doesn't.Either of these should make it pass everywhere:
requiresPointSampler(and in the table entries' point-filtered S# copy), so both paths give the point sample on every driver; orThe first also fixes direct bindings on lavapipe, so I'd prefer it, but it's your call. The other rows pass, and Windows is green.
Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-06T00:20:09Z.
Thanks, that was it. I went with the first option. #757, #758 and #759 are force-pushed onto
maincb33f858.requiresPointSamplernow covers the Uint class like Sint. The table paths (an S# column of a table entry, and a direct T# with a table S#) use the same rule, so every integer view reaches Vulkan with the point-filtered copy. This also changesmain's direct binding path for Uint images, as the description now says.agc_driver_image_table, because NVIDIA and the Intel iGPU here return the centre texel even with a linear sampler. The check asserts that word 2 of the sampler bound for the direct Uint +LinearWrappair, and of each table entry's integer copy, is the point word (0x01000000, not 0x00500000).Windows: ctest 335/335 (#757), 335/335 (#758) and 336/336 (#759).
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-06T01:12:44Z.
Thanks. The Uint rule now covers direct bindings, table entries and both mixed pairings (direct S# with a table image, table S# with a direct image), and the sampler-word checks don't depend on the driver.
Two things:
mainafter #668 landed (comparison sampling of color textures):IrMetadata/Resources.hpp,ResourceMaterializer.cpp,ShaderDiskCache.cppandSpirvImageEmitter.cpp. It needs one more rebase.ResourceMaterializer.cpp:907) could therefore throw where main didn't. That seems unlikely to matter, but it may be worth a few words in the TechnicalDebt line.Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-06T02:51:15Z.
Rebased the chain onto
mainfe98276f, over #668. Windows: ctest 342/342 (#757), 342/342 (#758) and 343/343 (#759); #757 alone also passes with-DANYPS5_ENABLE_SPIRV_TOOLS=ON.agc_driver_emulated_color_comparepasses as merged. The four conflicts were textual, andemulatedCompareis encoded next totableView.FormatVersionstays 5, since #668 leftmainat 4.agc_shader_memoryhas rows for each case.ShaderInfo::MaxSamplersone slot sooner than onmain.agc_driver_flat_store. It needs about 6 minutes on Windows llvmpipe, which is past the 240 s limit, and it passes when given the time.Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-06T03:09:57Z.
Correction to the lavapipe note above. Under identical load, with main's and this chain's test binaries running side by side on Mesa 26.2.4 llvmpipe, this chain is about 45% slower in both slow tests:
agc_driver_global_vcc_base: 94 s on main, 137 s here.agc_driver_flat_store: 259 s on main, 365 s here.NVIDIA shows no difference, and neither test uses image tables, so this is a per-dispatch or per-compile cost that #757 adds everywhere. It is not the environment. I'm tracking it down and will fix it on this branch before asking for another look.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-06T03:27:17Z.
Thanks for the rebase. I went through the range-diff against the previous heads: the #668 merge keeps
emulatedComparenext to the table view,FormatVersion5 still invalidates the cache, and the new record-time errors only fire where a compare-sampled color texture meets a table (table S#, or a color entry inside a table), with R32 float and R16 unorm entries still comparing natively. Failing there is better than the silent NEVER/point/wrap sampler. The sampler-slot TechnicalDebt line covers the second point.Thanks also for the lavapipe correction. It matches CI: #758's Linux job (run 37406080556) timed out in
agc_driver_flat_storeat 120 s, whilemaintook 66 s for that test on its last run. I'll wait for the fix before running the chain in PPSA21564, since a per-dispatch or per-compile cost would show up in its frame rate too.Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-06T04:44:12Z.
Fixed and force-pushed. #757, #758 and #759 are on
main109a3281; the #685 rename inDispatch.cppwas the only conflict.Cause:
RecordBdaFaultcomputed the two fault-address words (OpUConvertof the address, and of the address shifted right by 32) before claiming the fault slot withOpAtomicCompareExchange, instead of inside thewonblock as onmain.agc_driver_global_vcc_base.GALLIVM_PERF=noptboth versions take the same time.Fix: both
RecordBdaFaultandRecordBdaFaultWordsnow claim the slot first and compute the words inside thewonblock. Callers ofRecordBdaFaultemitmain's SPIR-V again: the wave32 module ofagc_driver_global_vcc_baseis byte-identical tomain's.agc_shader_memorygains a host-only check that the claim comes before any address conversion.Side by side on llvmpipe (Mesa 26.2.4, same load):
mainagc_driver_global_vcc_baseagc_driver_flat_storeTests: Windows ctest 354/354 (#757), 354/354 (#758) and 355/355 (#759), and the same on lavapipe.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-06T05:33:59Z.
Thanks for tracking that down. The range-diff against the previous heads only moves the fault-word conversions into the
wonblock (through theRecordFaulttemplate), addsverifyFaultSlotClaimedFirst, and keeps the #685 rename inDispatch.cpp; #758 is unchanged. CI agrees with your numbers:agc_driver_flat_storetook 67.5 s (#757), 74.4 s (#758) and 78.4 s (#759) on the new heads, against 88.2 s onmain109a3281's own run, andagc_driver_global_vcc_base27.6 to 30.5 s against 32.1 s.I'll run the chain through PPSA21564 next (cold and warm shader cache) and report back here.
Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-06T09:49:26Z.
Rebased the chain onto
main88ca57d7after #800 (TechnicalDebt.md context only). The code patches are identical to the previous heads 12198763 / 50de2e5e / 06645dd8, so a PPSA21564 run on those still applies. Windows ctest: 359 / 359 / 360.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-07T06:37:38Z.
@boykopovar @oneandonlydean this one needs the maintainer's call before anyone merges it.
runtimeDescriptorArray/descriptorBindingPartiallyBound. It also removes #5's bindless slots and changes the disk cache format. #639 is reworking the same thing ("image/sampler optimization remain incomplete") in the same files:ResourceMaterializer.cpp,DescriptorBindingBuilder.cpp,SpirvDescriptors.hpp,ShaderDiskCache.cpp,BindlessImages.cpp.main's direct binding for Uint images (point-sampler copy, like Sint), and #639 moves that same rule.maina9ec7be28, build +libs+ ctest pass 385/385 on Linux (RADV).Question for @boykopovar: should this land before #639 (and #639 adopt its table ABI), or wait and be redone on top of #639's runtime descriptors? #758, #759 and #920 are stacked on it.
Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-07T06:43:45Z.
Thanks for checking it on RADV, and for raising the ordering question. That's the right call to leave to @boykopovar.
Either order works for me. If #757 lands first, I'm happy to help #639 take over the table ABI. If #639 goes first, I'll redo #757, #758, #759 and #920 on top of its runtime descriptors rather than keep a parallel path. For context, these tables are what let PPSA26344's title load run: the Tiled Decals shaders and the other table-indexed shaders there dispatch only through them today, and #920 adds the
image_loadreads the menu packs use.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-07T11:40:36Z.
Review: CHANGES_REQUESTED
The new head (c3ba8653) fails its own test on Linux, independent of the ordering question above:
agc_shader_memorydies with a Bus error in CI (run 37611726687); Windows passes.main0d3c1eec): SIGSEGV inverifyImageTableReduction. The stack isRecompile→ its error path (recompileReporting) →RequestSerializer::Serialize, which reads through an invalid pointer. So one of theRecompilecalls in that test throws, and serializing the request for the message then crashes. Either the throw is unexpected, or it is theexpectFailurecase and the request holds a span thatSerializecan't read (context.memoryregions or the shader code). Both need fixing.agc_driver_image_table,agc_driver_image_table_cache,agc_shader_disk_cache) pass here.Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-07T15:57:19Z.
Thanks for reproducing it and pointing at
verifyImageTableReduction, that was exactly it. The crash was a bug in the test, not in the recompiler: it assignedmemory.Regions(), a temporary vector, to the request'scontext.memoryspan. When the expected-failureRecompilethrew,recompileReportingserialized the request through that dangling span, and on glibc the freed memory gives a non-canonical pointer, hence the bus error. The test now keeps the regions in a local vector that outlives the call.I've pushed 586892646, rebased on current main. Linux and Windows CI both pass, and so do #758, #759 and #920 on top of it. The rebase also brought in #866's sRGB loads (8_SRGB / 8_8_SRGB table entries are poisoned as a format conversion rather than sampled without the decode), #1043's shared fault function, and #1066's per-stage limits for the table bindings. The shader cache format is now 8.
Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-07T22:50:18Z.
@adriadam10 this is rebased onto current
main(39fafc45a, with #285, #903 and #940 in), and the Linux job passes now. The bus error from your review was the test's danglingcontext.memoryspan I described above. When you have a moment, could you take another look?Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-08T23:33:56Z.
Title evidence — this PR clears the wall a real title hits.
PPSA26344 (Ghost of Yōtei, 01.008): decrypted
eboot.binrelinked, staged runtime layout (libs/refreshed from the rebuild,app0/pointing at the dump's resources), RTX 3080 Ti on Linux.main(f1451396)mainGetImageResource dword 0 is not a valid runtime value; chain: ReadConstBuffer@pc=0x590(GetBufferResource(ReadConst(GetSrtResource, Immediate)…), IMul32(ReadConstBuffer@pc=0x258(… ShiftLeftLogical32(Phi(…) …), IAdd32(Phi(…)))…))With this PR the title gets through shader preparation — 53 shaders compiled (17.4 MiB written to the disk cache) — and dies at the next wall, which is a different one and already tracked as #1817:
So this PR removes the first of two consecutive walls; it is not blocked by #1817.
Merge note for the rebase: only
Optimization/src/ResourceMaterializer.cppconflicted (main's PCK2/PCK4 packed-image handling landed after this PR's base). I resolved it as main's packed logic and error text plus the sentinel this PR'sResources.hppuses —base.tableView != NoTableView; main's older name for the same field,indirectRoot/ImageResource::NoIndirectImage, does not exist after the merge, so the guards have to stay in thetableViewspelling.Raw logs kept (before / after). Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-08T23:35:23Z.
Thanks for running it on Yōtei. It's good to see the
GetImageResourcewall gone on Linux too, and your merge note matches what we saw. Heads-up: following boykopovar's guidance after #639, I'm reworking this PR on #639's runtime descriptors. It will keep compilation at registration and per-invocation data out of the cache key, and it absorbs #920'simage_loadsupport. The rework will replace this head soon, and I'll mention it here when it's up, in case you want to rerun.Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-09T02:31:23Z.
@adriadam10 I've reworked this on top of #639's runtime descriptors, following boykopovar's guidance, so it looks quite different from the version you reviewed. Instead of adding a parallel mechanism, it turns the bindless path into the general case: any T# or S# that
s_buffer_loadreads atkey * stride + addendbecomes a table column, and the old r256 table atkey * 32is simply stride 32. Each entry takes its mode from the artifact's own runtime mode list, the same per-entry modes #639 uses. The shader reads the mode, swizzle and element from a small map buffer, and the entries bind through one variable-count array whose layout size is a device constant.Shaders still compile at registration, and nothing per invocation goes into the plan, specialization, pipeline or disk-cache keys. A 3-entry and a 3,000-entry table share one variant, specialization and SPIR-V.
image_loadworks through tables too, because #920 is folded in here, so #920 can be closed. Anything that can't be exact faults when an active lane uses it, never at registration.Could you take another look when you have time?
Details
mainf1451396. Runtime ABI 11, disk cache format 22.main: 1,209 programs that throw at registration there now register, 404 more requests compile, and none regressed.PlanBuilder::Collectwalks iteratively now, because deep chains overflowed its stack onmaintoo.agc_shader_bindless,agc_driver_image_table,agc_driver_image_table_cache,agc_driver_image_table_reuseandagc_driver_bindless_images. The new ones don't build onmain.CacheableResultconditions.Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-09T12:18:51Z.
A second, independent implementation reaches the same conclusion for this exact title, which is worth having on record here.
sharpemu/sharpemu#926 ("Ghost of Yōtei: rendering up to the gamma screen and difficulty menu") boots PPSA26344 to gameplay, and its first shader item describes the mechanism this PR implements:
That is the same shape as the fix here: the image/sampler tables live at runtime offsets and must be read through the descriptor table rather than from a fixed location. Arriving at it independently, from the same game, on a different codebase (C#/Vulkan), is decent evidence that this is the title's actual blocker and not an artefact of one emulator's design.
For completenes, the measured effect on AnyPS5 side, from my earlier comment: on
mainthe title dies atGetImageResource dword 0 is not a valid runtime valueat presentation; with this PR merged ontomainit compiles 53 shaders (17.4 MiB disk cache) instead, and the next wall is #1817'ss_swappc_b64one. Their list also names the failures that come after ours ("Shared-memory phase synchronisation in multi-block shaders", "guest LDS size passed to SPIR-V"), which matches what this project still has open.Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T19:09:15Z.
#759 is merged now, so this conflicts with main. Could you rebase it onto current main? A full build can run once it merges cleanly.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-10T08:06:02Z.
This conflicts with main again after today's merges (#2133 and #2229 among them, 7 files); please rebase.
Also, on main
b7bb2684ecplus 4854d588 (Linux, RTX 4090) the newagc_driver_image_table_reusefails, with-j4and alone:Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T08:10:10Z.
Review: CHANGES_REQUESTED
Following up on @oneandonlydean's request, this still needs work before it can land:
main(checked with a merge onto currentupstream/main):DepthSurface.cpp,tests/ShaderMemory.cpp,ResourceMaterializer.cpp,ShaderDiskCache.cpp/.hpp,SpirvImageEmitter.cppanddocs/dev/TechnicalDebt.md. Please rebase; theResourceMaterializer/disk cache ones need your judgement on the table layout and format version.agc_driver_image_table_reusefails where write tracking works, as Dean reported on an RTX 4090:a CPU write collected after earlier entries of its 64 KiB block, then two dispatches: 2 reused and 1 resolved tables, expected 1 and 2. It fails the same way for us on Linux with RADV, so it is not driver-specific. Either the expected counts or the reuse logic is wrong.agc_driver_bindless_images(modified by this PR) fails on RADV withvkAllocateDescriptorSets: Vulkan result -12(pool exhausted). Please check how the descriptor pool is sized for the variable-count image/sampler arrays.Please say which hosts you ran them on after the fix (one with write tracking, and RADV or NVIDIA). I'll do the full pass once these are green.
Imported from boykopovar/AnyPS5. Originally posted by ponhei9502 on 2026-10-10T09:35:21Z.
A real-title data point for this PR, in case it helps as a test case once it is rebased.
Title / setup: Demon's Souls (PPSA01341), Linux x86-64 (CachyOS), NVIDIA RTX 3080 10 GB. Tree:
mainatddcb251aplus a few local Linux fixes, none in the recompiler's resource tracking.Failure on main: three pixel programs (0x248a6e000, 0x248a7ad00, 0x248a7e800) fail planning with
So the T# is loaded from an SRT buffer at
base + (FindILsb(lane mask) << shift) + imm, with the mask walked bit by bit in a loop — the "descriptor read at a runtimekey * stride + addendoffset" shape this PR describes, with the key coming from a lane-mask bit scan.Where it surfaces: not at a draw. The title calls
sceAgcCreateInterpolantMapping, which goesDriver::ResolveShaderAbi->PrepareRegistered->PrepareShaderWithDiagnostics, and the exception leaves on the guest thread, so the process terminates (no[videoout] presentation failedline). IfResolveShaderAbiswallows it, the next failure isprepared shader artifact is missing for the requested static ABIat the first draw using the program.Reproduction (about 6 minutes on a warm shader cache):
+ds_enableDebugStartMenu=trueinPackageCmdLineArgs.txt, then Cross on "Walk Through" and Cross on "(0-1) Nexus"; it dies as the loading fog starts. The same error also ends a normal new game at character creation.Happy to run this route against the branch after the rebase and report what the fault buffer says for these programs. (Found with an automated test loop; the details above were checked against the logs and a host-side stack trace.)
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-10T10:58:41Z.
Thank you — that is a useful data point, and it lands on the path this PR generalizes: three pixel programs failing planning with
GetImageResource dword 0 is not a valid runtime value, with a chain running through a runtime-computed address (SelectU32/DppUpdateU32lanes feedingLoadAddressU32), is the case where the descriptor is only known per invocation.Worth knowing before you retest:
mainhas moved under this PR, but not in the file this depends on —ResourceTracker.cppis unchanged sinceddcb251a. The descriptor-web split (#1274, SRTPhileaves) and the 2D/3D binding reads landed beforeddcb251a, so they are already in the tree you tested. The PR does conflict withmainright now — nine files, includingDepthSurface.cppandtests/ShaderMemory.cpp— so a rebase comes first.If it still fails at the PR head, the detail that would settle it is whether those three programs' resource index is an SRT slot fixed at compile time or a runtime value, since that is the split this PR makes.
Imported from boykopovar/AnyPS5. Originally posted by tv7 on 2026-10-10T13:20:10Z.
Tested on Windows with Marvel's Wolverine (PPSA03671). This PR removes the title's stop at its first presentation.
Setup: Windows 11 Pro (10.0.26200), RTX 3070, GCC 15.2.0 UCRT (WinLibs), Release.
mainb69270dd9+ #1940 (b7e32b364) + the fixes from #2747 and #2748, plus local placeholders (log, return 0) for two unnamed imports (GTfJ64qFCPwAcm,zBsgF0q8DIMPad). Then this PR (d03a55d6c) merged on top: no conflicts.Without this PR: 17 registered shaders are deferred with
GetImageResource dword 0 is not a valid runtime value, and the first presentation ends the title:With this PR: no
GetImageResourcefailures at all (0 of the 17), and the compute shader above is prepared. The title gets further and stops on a different, later error:That is a pixel shader at
0x11d015f100. The message and stage match #2621 (a registered shader drawn under a context its registration did not prepare), but I haven't checked that the cause is the same here.Tested and written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-10T17:41:15Z.
I am cross-testing this and #758 against 007 First Light (PPSA11386), coordinating on #2523. I have fetched exact heads 9e5fcf29 / c38d9ccd, now cleanly based on main
57f96fd2, and am building an isolated Windows / NVIDIA candidate. The local 18,960-key request and original export stay on this machine; no title data will be uploaded.I had a narrower dense sampled-table WIP before seeing these updates (https://github.com/Scramblrrrr/AnyPS5/tree/codex/first-light-wide-integration), but it retains static 16-slot expansion and does not solve all hidden static capacity failures. I am testing your broader runtime implementation before extending that overlap. I will report exact heads, configuration, focused tests, and the next game stop on #2523.
AI-assisted cross-test (Codex).
Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-10T19:06:42Z.
@Celegans12 Tested #757 (9e5fcf29) and #758 (c38d9ccd) with RetroArch's Dolphin core (homebrew RetroArch, PPSA99169) in ubershader mode (
dolphin_shader_compilation_mode = 2), running the GameCube 240p Test Suite. On Windows 11, NVIDIA RTX 5070 Ti, MinGW-w64 GCC 15.2.Without them: planning stops at
That is, a T# read through a user-data pointer at an offset of key * stride, where the key is a bitfield of a constant-buffer value (the ubershader takes its texture slot from a uniform).
One gap in sampler tables: with both PRs, every draw then stops at
from
addSamplerTable→SamplerCache::Get→DecodeSamplerResource→Sampler::Sampler. The entry decodes to a LOD bias of 28.26; the device limit (maxSamplerLodBias) is 15 here.addSamplerTable's first pass rejects entries one by one inside itstry(opaque-black border, non-seamless cube,ANISO_OVERRIDE). The device-limit checks are in theSamplerconstructor, which runs in the second pass, outside it. So an entry with an out-of-range bias passes validation and then fails the whole draw, instead of becoming a per-entry rejection that faults only when a lane selects it.Samplerconstructor checks (anisotropy support and ratio, unnormalized coordinates with comparison) probably belong in the first pass for the same reason. I only hit the LOD bias one.Caveats:
main: this is my integration branch, amainfrom 2026-10-07 plus my open PRs, #423 and local changes. RetroArch can't run the Dolphin core onmainalone yet.ValidateShaders/Inspectparameter lists (next to #423's clip/cull flags; I kept yourruntimeDescriptorArrayposition), theShaderDiskCachesizes and format version (took yours), and itsShaderDiskCache.cpptest. That test comparesbufferRead, which my older base doesn't have, so I dropped that one comparison locally. #758 applied cleanly on top.agc_driver_graphics,shader_disk_cache,shader_memoryand the clip/cull tests pass on that branch.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-10T19:40:02Z.
Review: COMMENTED
Following @TheAggie's run — the sampler wall it exposes is diagnosable from the code, so here is what the numbers mean.
The guest LOD bias is a 14-bit signed fixed-point 6.8 field:
toSignedLodBiassign-extends the 14 bits and divides by 256 (Graphics/src/GuestSamplerResource.cpp:50, field extracted at:80), and the decoder test builds its fixtures from the same encoding (tests/GuestSamplerResource.cpp:54). So a reported bias of 28.26 is a raw value near 7236 — inside the field's own range, and decoded as designed.That splits the next step in two, and the difference matters:
key * stride) is exactly the place where a descriptor read from the wrong offset shows up as a plausible-looking number sitting in the wrong field. The cheap way to settle it: log the four raw S# dwords at the point of refusal and check they parse as a sampler descriptor at all — border colour, filters and min/max LOD sane. If they do not, the fix belongs in the descriptor lookup, not in the limit check.maxSamplerLodBias(15 on this device), andGraphics/src/Sampler.cpp:12refuses rather than silently changing the result. Clamping would draw something, but it would deviate from what the guest asked for without saying so — so that choice wants either a TechnicalDebt entry naming this title and this log line, or a decision from the maintainers.Nothing here is a reason to hold #757 or #758: the wall is downstream of them, and their leaving planning is what exposes it.
Two limits on this: I cannot reproduce the run — no AMD hardware here (lavapipe only) and no Dolphin/RetroArch setup — and I have not found an issue covering this sampler wall. The closest existing work is merged #934 (LOD biases in colour-comparison sampling), which handles LOD biases on a different path and does not cover this refusal — so if point 1 turns out to be a misread, it is worth its own report with the title and log line.
Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by EdouardSence on 2026-10-10T20:00:05Z.
Tested with Ghost of Yōtei (PPSA26344) on RADV. This PR (through #758) gets past the analysis stop in #2715, then the same shader stops on a RADV descriptor allocation that looks fixable here.
Setup: CachyOS (kernel 7.2.9), RX 9070 XT (RDNA4), RADV / Mesa 26.2.4, Release, headless gamescope with scripted input. Main
4a747c487+ #1940 (operand 235) + #758 (which contains this PR's9e5fcf29a) + Pipodi's44a80d4f(relocated header copies, #1837).Before (main + #1940 +
44a80d4f): about 26 s in,compute shader 0x80003aa700: GetImageResource dword 0 is not a valid runtime value(#2715).With #757/#758: that analysis stop is gone. About 25 s in, the same shader stops on:
A local print (not pushed) in
DescriptorCache::Allocateand before it:So the 1024-sampler table pushes the set onto the dedicated, exactly-sized pool. The image table binding (
b260,VARIABLE_DESCRIPTOR_COUNT, max 262144) is allocated with a variable count of 0, because this dispatch's table has no elements.RADV does not shrink the set for a variable count of 0. In
radv_descriptor_set_create(Mesa main,src/amd/vulkan/radv_descriptor_set.c):A count of 0 takes
layout->size, the size with all 262144 image descriptors, which the exactly-sized pool can't hold.What I measured, one change at a time on the dedicated path:
VK_ERROR_OUT_OF_POOL_MEMORYFREE_DESCRIPTOR_SET_BITVK_ERROR_FRAGMENTED_POOLmax(1, n)and sampled-image pool size +1, nothing elseWith the last one the title goes on to the next shader,
0x8000265d00:unnormalized guest sampler is used with a texel offset, which is not implemented, which is what #822 targets. #822 conflicts with #758 inPipelineSpecialization.hppandResources.hpp, so I did not stack it.So a small change here would avoid the RADV case: when the table has no elements, allocate the variable binding with a count of 1 and size the pool for it (one more sampled image). The same applies to the non-cached path that calls
CreateSetPoolwith the samevariableCount. I haven't checked other drivers' handling of a 0 count; on NVIDIA this path may never fail.Tested and written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by ponhei9502 on 2026-10-10T20:25:05Z.
Follow-up to my comment above, as promised: I ran the Demon's Souls (PPSA01341) debug-menu route against this branch after the rebase.
Tree:
main3cb317fc+ this PR at 9e5fcf29 + #425 at d6088bed, plus local Linux fixes outside the recompiler's resource tracking. Linux x86-64, RTX 3080, NVIDIA 615.78.08, Release,ANYPS5_ENABLE_SPIRV_TOOLS=OFF. Cold shader cache, one run.Result: the same three pixel programs still fail planning with the same text, so this shape is not covered yet:
Counts for one run up to the level load: 97 failed preparations across the three programs (0x848a6e000: 39, 0x848a7e800: 38, 0x848a7ad00: 20), all through
sceAgcCreateInterpolantMapping->Driver::ResolveShaderAbi/ResolveGraphicsAbi.What differs from the cases in the description, as far as I can read the chain: the table key is not a value read from a buffer but
FindILsb32of a lane mask that is built withReadLaneand consumed one bit per loop iteration (thePhi/BitwiseXor32(1 << bit)pair), and the heap offset is(key << shift) + immediate. Onmainbefore this PR (yesterday, not reached in today's run because it stops earlier now) a further program failed the same way atpc=0x00000288withPhi(Immediate, IAdd32(Phi(...)))as the key, i.e. a plain loop counter; I have not re-tested that one on this branch.I can capture whatever helps (the shader bytes, the SRT buffer contents at dispatch, a trace option) and re-run on request.
Pointer, in case it is useful (added later): SharpEmu handles this exact shape as a finite selector.
src/SharpEmu.ShaderCompiler/Resources/ResourceTracker.DenseImages.cs(TryCreateWaveIndexedImageSelector, comment above it) describes it as "post-process kernels select a descriptor per active bit in a scalar mask: mask -> s_ff1 -> v_mov -> (bit * stride + table) -> global_load -> v_readfirstlane -> key << 5 -> s_load_dwordx8", and resolves the key set on the host from the mask and the index table (mask offset, index data offset, index stride), withWaveMaskSelectorBounds.csproving the mask's range. Demon's Souls is one of the titles it was written for. GPL-2.0-or-later.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-10T21:42:29Z.
Review: COMMENTED
Following @EdouardSence's report — the path he instrumented is in
ShaderResources.cpp, and both halves of the mismatch are visible there.descriptorCount, withVARIABLE_DESCRIPTOR_COUNT_BIT: line 1489 (context.imageTableCapacity, 262144 in his dump).tableDescriptors = min(tableElements, imageTableCapacity)and line 1528plannedSampledImages + tableDescriptors.variableCount.value_or(0u)— line 1543, and line 2814 on the path he saw: a table with no elements passes a variable count of 0.dedicatedpool from his "dedicated alloc failed" line (it is created at 2824): when a set does not fit a shared pool, it gets its own, sized exactly as above.So the request is a variable binding of length 0 with a pool sized for 0, while RADV charges the layout's full size for that request. The request itself is legal:
VkDescriptorSetVariableDescriptorCountAllocateInfosays "If descriptorSetCount is zero or this structure is not included in the pNext chain, then the variable lengths are considered to be zero" — a zero length is a defined state, and the spec does not forbid an implementation charging the layout's size for it. That is why it only bites on RADV: nothing here is invalid, and the pool is simply what runs out.Two ways to close it, and his experiment already chose between them:
max(1, variableCount)and add the matching +1 to the pool — his last row: allocates, and costs one descriptor.The second is the one I would argue for: the declared capacity is an upper bound, not a demand, and a fix that depends on the driver shrinking the set for a zero count is the fragile one. His table shows the zero count is precisely the case that costs the full layout on RADV.
Whether Mesa's choice is worth a report on its own is a separate question — the request is legal either way, and this side can stop paying for it in one line.
Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T22:14:21Z.
Review: CHANGES_REQUESTED
The head now merges cleanly with
main. Two test problems remain:agc_driver_bindless_imagesfails on RADV (merged onto currentmain, Linux):vkAllocateDescriptorSets: Vulkan result -12. This PR modifies that test, and the description says the pool failure is unresolved. @EdouardSence's report on an RX 9070 XT points at the table binding declaringimageTableCapacitydescriptors withVARIABLE_DESCRIPTOR_COUNTwhile the pool is sized from the actual elements (ShaderResources.cpp). Please fix it here or drop the test change, so the test is green on RADV.agc_driver_image_table_reusefails on @oneandonlydean's RTX 4090 (2 reused and 1 resolved tables, expected 1 and 2, alone and with-j4). It passes here on RADV with write tracking, so please check whether your current head still fails on NVIDIA and make the expectation not depend on the driver.Please re-run both on the new head and post the result.
Imported from boykopovar/AnyPS5. Originally posted by Tamalero on 2026-10-11T08:06:33Z.
Tested #757 + #758 on Marvel's Guardians of the Galaxy (PPSA01748), the second title I reported on #2715. They fix its stop: the three shaders that compute the T# index from a loop counter now prepare, including the one the title dispatches (
pc=0x588), so that abort is gone. The run now ends at about the same time on something unrelated (CB metadata pass with depth or stencil work, an AGC check), so the PRs did their part.Details
Setup: CachyOS (Linux 7.2), RTX 4090 (NVIDIA 615.78), GCC, Release.
mainf5c0fe00plus my local integration patches. The ones Guardians needs to start are PlayGo chunk ids #3238, null indirect base #3239, sysmodule ids #3240/#2541 and offlinesceNpGetUserIdByAccountId#2852; the others are for Ratchet (#3158, #3283). 9e5fcf29 and c38d9ccd are cherry-picked on top.Rebasing onto current
main: both commits conflict, all small:ResourcePlan.hpp,ResourceTracker.cpp(members) andRecompiler.cpp: both sides added fields or code. I kept both, and keptmain's+ snapshot.nullRootReadsinpoisonedSrtReads.ResourceMaterializer.cpp:EvaluateRuntimeSourcesnow takes&snapshot.nullRootReads. InTryRuntimeImageModeI kept yourreject(reason, …)structure and passedmain's newer detailed incompatibility message (formats, modes, T# words) as the detail.ResourceTracker.cpp:mainalready has a newerMemoryIndexBelongsTo(with them_memoryUsersindex), so I kept that and added onlyScalarAddressMemory. The memberm_indirectImageshad to go, since #757 replacesIndirectImagePlan.The PR's tests pass on that tree:
agc_driver_image_table,_image_table_cache,_image_table_reuse,agc_driver_runtime_images,agc_driver_bindless_images,agc_shader_bindless,agc_shader_memory.Guardians, before → after:
main+ local fixesGetImageResource dword 0 is not a valid runtime valuepc=0x588,0x5d4,0x974)0x588is dispatched and abortsImageRead(pc=0x4378,0x4380×2)pc=0x588CB metadata pass with depth or stencil workThe new stop is
DecodeColorMetadataPass(State.cpp) requiringDB_DEPTH_CONTROL & 0xfandDB_RENDER_CONTROL & 0xfto be zero for an eliminate-fast-clear / DCC-decompress pass. That is unrelated to this PR. I have since fixed it and three later stops locally (an always-pass depth test in that pass,D16_UNORM_S8_UINTon NVIDIA, #2975, andBLEND_BYPASS). With those plus these two PRs, Guardians gets past its loading screen into its first UI screen.Tested and written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by tibzejoker on 2026-10-11T13:13:21Z.
Data point from GTA V (PPSA04264): it is another title with the #2715 pattern. Windows 11, RTX 4090. This is a replay-only check with
agc_shader_replay, not a game run.Compute shader
0x25b40aa00(wave64, 8x8x1) loads its T# from a buffer at a computed index.main(2220effbe), it stops in resource analysis:I can't do an in-game run on this PR for now: the branch is about 1000 commits behind
mainand GTA needs several other branches to get that far. I'll report back once it is rebased if that helps. The request file is available if you want it.Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-11T13:39:21Z.
I've prepared the rebase and the empty-table fix: one physical descriptor plus pool space, including draw snapshots, while the guest table stays empty. Sampler constraints are checked before Vulkan allocation without clamping bias or weakening the OS-specific reuse counts; unsupported border pairings fail conservatively. This still doesn't establish whether the reported sampler address was correct.
The parent passes all 16 focused tests and the three no-pipeline-library controls per platform, with all five CPU regressions failing before the fixes and passing afterward. Counted reuse ran on Windows; Linux omits it and two per-wave cases. Windows default Recorder passes with four watch-dependent omissions.
The full #758 stack merged with main still has failed CI. Exact main repeats all four Windows failures, plus Linux's R8 sRGB comparison and default Recorder depth-proof failures; later Recorder checks remain unrun.
Full merged results
NVIDIA/Windows: 830 passed, four failed, five expected skips; skip-policy check passed. Lavapipe/Linux: 804 passed, four failed, 33 skipped; the skip-policy check rejected missing
agc_write_trackingcoverage. No unexpected native-fatal markers were hidden in passing tests. These are failure results, not a full-suite pass.Could you rerun
agc_driver_bindless_imageson RADV to confirm the allocation fix on the affected driver?Imported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-11T13:54:00Z.
@Celegans12 A cost measurement of this path with a large table, from 007 First Light (PPSA11386) on Linux.
Setup. RTX 3080, NVIDIA 615.71.09, Release, SPIRV-Tools off, warm shader and pipeline caches,
APS5_PROFILE_DRAW=1. The stack is57f96fd2with #757/#758 at their previous heads (9e5fcf29 / c38d9ccd) plus 41 other commits: other open PRs and local patches, identical in both runs.TableSnapshotteris unchanged in your rebased heads.The cost. 007's image table has 18,960 entries.
TableSnapshotterreads it one dword at a time on every capture, about 190k word reads per snapshot. In steady state that's 3.3 ms per snapshot and 4.5 s of every 10 s on the draw thread, about half of the queue-0 draw-packet time.A follow-up, which I'll open against main once #757/#758 are merged. I'm not suggesting it for this PR. It's SleglJan/AnyPS5
perf/image-table-snapshot-reuse(f9c2003d, on 1ff81c24):ShaderMemory::readWords.Regions()andtables.rangescome out the same.Result. Two runs on that stack, differing only by this change. Values cover twenty 10 s windows in steady state: packet counts are means, times are medians. Frames per minute come from the window title:
DRAW_INDEX_OFFSET_2packets per 10 sThe after run ended at about 289 s on
vkAllocateMemory storage texture: Vulkan result -2, a separate issue (#3256).Tests. The change adds two checks to
agc_shader_memory_tests, which run inagc_shader_memoryandagc_shader_bindless:On f9c2003d, all 384 agc/shader/recompiler/spirv test targets pass on the RTX 3080.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by tv7 on 2026-10-11T14:29:29Z.
@Celegans12 A device-memory data point for the image table path, from Marvel's Wolverine (PPSA03671) on Windows.
Setup. RTX 3070 (8 GB), Windows 11, GCC 15.2.0 UCRT, Release. Main
a11c8f7f7+ this PR ate904eb18c+ #3588 (APR) + #3633 (array color views) + #3336 (unexported pixel inputs) + placeholders for 2 unresolved imports.What happens. One of the title's tables is its whole bindless texture heap (2,493 entries, counted in an earlier run on an older head).
resolveImageTablescreates or looks up a texture for every entry belowimageTableCapacityfor that one dispatch, and keeps them all alive for it. On 8 GB that alone exceeds device memory: the first presentation stops withcompute shader 0x11d032b100: AGC graphics: vkAllocateMemory texture: Vulkan result -2, preceded by many[textures] ... keeps the snapshot path: vkAllocateMemory storage texture: Vulkan result -2.Check. Same build, with
context.imageTableCapacityclamped to 150 by a local env var (so entries past 150 take the existing capacity fault): no out-of-memory, and the title runs 10 minutes without an error. I also tried each other memory change I had locally (kept-bytes accounting of new storage images, retiring signaled batches inBoundKeptBytes,APS5_HOST_IMPORT_MIB=9216); none of them changes the outcome on current main, only the table size does.So a table whose entries add up to more than the texture budget fails on 8 GB cards. A byte budget for the textures one table materializes (faulting the rest like the capacity limit does), or creating entries only when a shader reads them, would avoid it. Your call whether that belongs here or in a follow-up; I can test either on this title.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by EdouardSence on 2026-10-11T14:48:27Z.
@Celegans12 @adriadam10, on the
agc_driver_bindless_imagesfailure on RADV: this is the change that makes it pass here (RX 9070 XT, Mesa 26.2.4 RADV, Linux). I tested it onmaina11c8f7fwith #758 merged, conflicts resolved as @Tamalero describes.RADV's
radv_descriptor_set_createsizes a set whose variable descriptor count is 0 at the layout binding's fulldescriptorCount. That isimageTableCapacityhere, while the pool is sized from the table's actual elements, so a table with no elements getsVK_ERROR_OUT_OF_POOL_MEMORY(-1000069000). Allocating at least one element keeps the variable count and the pool size consistent:(in
ShaderResources.cpp, wheretableDescriptorsfeeds both the pool size andvariableCount)agc_driver_bindless_imagesfails withvkAllocateDescriptorSets: Vulkan result -1000069000.agc_driver_graphicsstops ona chained update-after-bind pool lost the variable image count. Its expectation (maxSets == 1024andFREE_DESCRIPTOR_SET_BITon the chained pool) predatesmain's current descriptor pool scheme, so it needs updating for the rebase rather than a code change.I can't check
agc_driver_image_table_reuseon NVIDIA. It passes here on RADV.Tested and written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T21:23:01Z.
Checked the new head e904eb18 merged onto current
main(Linux, RADV, libSceAgc + libSceAgcDriver scope): 409/409 ctest pass, includingagc_driver_bindless_images(thevkAllocateDescriptorSets -12is gone) andagc_driver_image_table_reuse(write tracking works here). The new tests need the PR'sImageTableAbi.hpp, so they can't be run againstmainfor a negative check.Not covered by us:
agc_driver_image_table_reusefailed on your RTX 4090 at the previous head ("2 reused and 1 resolved tables, expected 1 and 2"). Could you rerun it on this head? If it still fails, that is the blocker.resolveImageTablescreating textures for every entry belowimageTableCapacity). @Celegans12, please answer whether this head changes either.Otherwise the real-title reports in the thread show the planning wall cleared.
Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-11T22:31:28Z.
Test on Demon's Souls (PPSA01342 v1.005, US), Windows, RTX 3060 (NVIDIA 591.86), MinGW-w64 GCC 15.2.0, Release. This covers the material-selected table that fisherjoey reported on #1184 for PPSA01341.
Tree:
maina11c8f7f7+ #3871 + #425 + #2904 (needed to get this far) + this PR ate904eb18c. One textual conflict with #425 inShaderResources::noteReusable; I kept #425'sRefreshedPerUse()early return and this PR'sImageTableMapexclusion on the next line.Without this PR, right after the brightness calibration screen:
With it, that stop is gone. The voice/subtitle settings screen and the opening cinematic render, with no table-related errors in the log; I watched the cinematic for several minutes. This was the first run of the build, so every shader was recompiled (about 6,350); I saw no descriptor allocation failures on NVIDIA with 12 GB.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-11T23:12:24Z.
Reran on the RTX 4090 (NVIDIA 610.57.04, Linux) at e904eb18, built on its own base:
agc_driver_image_table_reusepasses 5 of 5, andagc_driver_bindless_imagespasses.ctest -R "agc|shader"is 375/381; the six failures (agc_driver_bda_device,agc_driver_flat_apertures_0/2/3/4/5) are the same six at the merge-base0f863c10.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-11T23:13:20Z.
Conflicts with main again in
VulkanDevice.cpp,ShaderResources.cppandtests/Graphics.cpp; please rebase.Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-12T06:49:15Z.
I rebased this and #758 onto current
main. The only real change is around #3717:mainnow enables the same three descriptor-indexing features for its replay devices, so this PR usesmain's fields and layout-flag path instead of its own, which also feeds the pipeline capture. One table test now passes the update-after-bind flag itself to match that. The PR also gained coverage for table keys that come from a loop counter and from a set-bit loop (s_ff1/s_bitset0), the shapes Yōtei's terrain domain programs use; both fail with image tables switched off.Two earlier points I couldn't confirm here: @adriadam10's RADV pool failure in
agc_driver_bindless_images(the one-descriptor reservation for empty tables is meant to fix it, but I have no RADV device), andagc_driver_image_table_reusewith write tracking on Linux (WSL has no write watch). If either of you can run those, that would settle them.Checks
log_macrosalso fails onmain.main2ccbd376: 937/938 pass;agc_driver_depth_compare_copyalso fails onmain.Imported from boykopovar/AnyPS5. Originally posted by Mouhand-Kaddo on 2026-10-12T09:34:47Z.
Tested this head (
753c29396e4d0c790c6faae216f94fcdc5eda5ca) together with child #758 (cad61e9a744474d98b25ee2f2f35de864f31441d) on current mainc36fd0a0eb57c01866befd370c88329ca42df759, Linux RX 6900 XT / RADV Mesa 26.2.4. This is a locally ported combined stack, not standalone validation of this PR head.Nine of ten focused table/resource/cache/graphics/optimizer checks pass.
agc_driver_image_tablecrashes at its first graphics-table draw, after the negative compute tests. A debugger-only experiment proves a current-main integration gap: the fragment shader references shared ImageTable set 0, whilePipelineLibrary.cppretains only set 1 for the fragment graphics pipeline library. Retaining both sets makes the entire test pass. The corresponding fragment-library cache key must also account for set 0.The 17 Demon's Souls descriptor captures remain red because the pointer-table matcher rejects descriptors assembled from two adjacent four-dword loads. I posted the exact PCs, offset values, U32 wrapping concern, and separate GPL diagnosis on #758. No game/menu success is claimed, and no validation or fault assertions were disabled.
Testing performed with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by Mouhand-Kaddo on 2026-10-12T12:20:50Z.
Linux follow-up for the tested head
753c29396e4d0c790c6faae216f94fcdc5eda5ca. Demon's Souls (PPSA01342) reached the main menu, with New Game and Settings visible in a native emulator frame and interaction confirmed by the user. Selecting New Game then produced a black screen; gameplay is not validated.This was a combined integration stack: public-main snapshot
c36fd0a0eb57c01866befd370c88329ca42df759, ported #757/#758, #4288, #3991, #4402, the descriptor-layout fix now in #4456, and a local split-descriptor-load correction. It is not an isolated success claim for this PR. The final menu run used GDB to investigate an earlierbuffer descriptor uses an unsupported typeabort. That earlier failure remains undiagnosed.The table support still needed a local correction for eight-word image descriptors formed by two four-word raw-address loads. That follow-up remains separate from your implementation.
Reproduction detail: the title run temporarily raised Linux
udmabufsize_limit_mbfrom 64 to 2048 because larger GPU imports failed at the default limit. The user restored 64 afterward and readback confirmed it. Default shader optimization remained enabled. RX 6900 XT/RADV was receiving GPU work; CPU shader compilation was a major startup bottleneck. Game assets were accessed through an enforced read-only view of the Windows gaming drive, without copying the game or changing its inputs. Disposable test caches have now been removed. AI-assisted testing/report.Imported from boykopovar/AnyPS5. Originally posted by tibzejoker on 2026-10-12T14:58:29Z.
Windows data for head
753c2939with GTA V (PPSA04264), Windows 11, RTX 4090, WinLibs GCC 15.2.0, Release.I took this commit onto my GTA test tree (main
325e0a8bdplus a few open PRs: #425, #290, #637, #448, #423 and #2802). It conflicted only in theValidateShaders/Inspectparameter lists, against #423's clip/cull distance flags. Same Story run before and after:0x25b456800bindless image table has 65536 entries (0 materials), limit 160x25b458e000x25b45a200GetImageResource dword 0 is not a valid runtime valueThe prologue renders as before, and no other dispatch fails in order.
The remaining failure reads its T# through two constant buffer loads. The descriptor dword is
ReadConstBuffer@0x13b8(V# from the SRT, offset), whereoffsetis derived fromReadConstBuffer@0x135c(another V# from the SRT, ReadFirstLane(SelectU32(Phi …))). The index is a loop-carried, wave-uniform value that is itself loaded from memory, so it is probably outside what this PR covers. I'm noting it here only so the GTA case is on record. I can send the.reqif it helps.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-12T20:32:58Z.
@Celegans12 A finding from 007 First Light (PPSA11386) on a stack that carries this PR (e904eb18;
MatchKeyDomainandNarroware identical at 753c29396), and a patch on the current head.What we saw. We replayed 216 recorded shader requests from the game. No table in the 21 table-using shaders (95 traced tables) was narrowed: each one walked its whole domain (18,960 or 18,944 records) and bound every distinct entry. Per shader binding that is 335–339 elements in most shaders and 3,116–3,281 in the largest. Each bound element is a texture the driver looks up or creates for that draw or dispatch.
Cause.
MatchKeyDomainonly recognises keys read V#-relative (ReadConstBuffer). A key read through the SRT (ReadConst: a scalar load at an immediate offset that the SRT plan folds into a flat slot, from a user-data pointer or a V#) gets no key domain, so the snapshot keeps the whole domain. Across the 1,533 matcher calls in those 216 requests, these key shapes were rejected:ShiftRightLogical32ReadFirstLaneBitwiseAnd32PhiIAdd32ReadConstSelectU323 V#-relative reads matched.
Patch: SleglJan/AnyPS5
fix/757-key-domainat 0a7d5dad7, one commit on 753c29396 (5 files, +95/−22).valuekey domain, used only when no V# or address read at a runtime offset is left in the key (noReadConstBufferorLoadAddressU32): user data, SRT reads, constants and arithmetic on them. The key then carries a one-dword descriptor source, and the snapshot evaluates it at dispatch time and narrows to that record.ShaderMemorycaseverifyImageTableSrtKey: a key read through the SRT pointer narrows the snapshot to that record. Recompiled with a different key value, only the snapshot codes change; the SPIR-V and the disk-cache key stay the same. On 753c29396 it fails with "image table SRT key: a key read through the SRT has no key domain".TechnicalDebt.md: a key that is neither a V#-relative scalar read nor a value the SRT walker evaluates from user data, SRT reads and constants alone still binds the whole domain. Examples: a shifted or masked runtime-offset V# read, a per-lane value made uniform byv_readfirstlane, or a loop-carried phi.Effect, measured on our game stack with the first revision of this change, before the V#/address check. Your replay tool can't read our stack's request dumps, so the patch's own effect is covered by its test. The 14 tables whose key is read through the SRT narrow to 1–2 bound elements; record 0 always stays. The other tables are unchanged. We're working on those next: phi leaves and shift/mask/add transforms of V# reads, and a bounded scan for keys taken from raw buffers.
Tested on Linux with lavapipe and SPIRV-Tools ON, from a clean tree:
agc_shader_memory,agc_shader_bindless,agc_driver_image_table,agc_driver_image_table_reuse,agc_driver_image_table_cache,agc_shader_disk_cache.agc_shader_bindlessfails as above.tools/check_conventions.pypasses against the PR head.The change keeps your narrowing design and adds a domain for keys the current matcher doesn't cover. Fold the commit into this PR or have it as a follow-up on top, whichever you prefer. #758 and #4475 build on the same
MatchKeyDomain/Narrow, so they'd pick it up too.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by tv7 on 2026-10-12T20:39:22Z.
Rebase handoff: rebased onto current
main(44ab0c39e), authorship unchanged (one commit,8945fe208).Main's registration-module series (
765ea6a10,4d0b5c789,d7e0f27d6,e9def903f) touched the same code, so the conflicts were more than textual:table != NoTablewhere main testedindirectRoot). The oldindirectRoot/indirectResources/TableImageIndexpaths are gone, as in this PR.tableBindings[2]andtableElements[2], aTableStage::set, and aBinding::setthatsetOfhonours. Pool sizes and the variable descriptor count are per set too, in the draw build and in draw snapshots.DescribeSetLayouts: describes the same table bindings and binding flags as the draw build: sampler table asSAMPLERxsamplerTableCapacitypartially bound, and the image table per set, partially bound with a variable count. So prebuilt libraries' set layouts match the draw's.ShaderValidationkeeps main's per-stage set check and passesruntimeDescriptorArray.PreparedDescriptorBindinghas bothinactiveandtableSamplerMasks. A table sampler's filter element also honoursinactive. The Linux-onlyShaderDiskCachesize asserts now readCompiledShaderArtifact200 andRecompileResult384 (both sides' growth added; I can't build on Linux here, so please check). The 17 TechnicalDebt entries moved todocs/dev/debt/libSceAgcDriver.md(6) anddocs/dev/debt/shader.md(11) after342a8c459.Verified on Windows 11, RTX 3070, GCC 15.2.0 UCRT, Release:
tools/check_conventions.py --base origin/mainpasses3e0e01f35) plus #3633, #3846 and #4702, withAPS5_VERIFY_SET_LAYOUTS=1: no set layout mismatch. It runs until a separate stop: a pixel shader that exports the stencil reference now needsVK_EXT_shader_stencil_export, which this NVIDIA device lacks (22d662eda). Like my earlier runs, this one caps the table at 150 images locally, because the full 2493-entry table runs out of VRAM on 8 GB (see my earlier comment).To pick it up:
Head is
8945fe208.Imported from boykopovar/AnyPS5. Originally posted by Mouhand-Kaddo on 2026-10-12T21:23:01Z.
Retest on Linux using updated #4456 head
4f5f6d671cdb0ffd3a9c43eedbdf03e433e80ebeas the integration base. Its six focused PR checks pass three times each; the previous null-shader-module mock failure is reproduced on its parent and fixed on this head.The title support stack remains #757/#758/#4288/#3991/#4402 plus the local grouped split-load correction. Five integration shader/graphics checks pass. Demon's Souls PPSA01342 rendered language/display settings and the online/offline prompt, then aborted with exit 134:
This run did not verify main menu. The earlier c36-based integration did reach it. I have not isolated which rebased-stack change causes the descriptor failure, so this is not a regression attribution to this PR. No memory guard/OOM event stopped the run. One brief debugger snapshot was taken during startup, then detached.
The temporary Linux udmabuf limit was again 2048 MiB for the title run and is now verified back at 64. Assets were read directly through an enforced read-only view of the Windows gaming drive, without copying the game. Original input hashes and timestamps are unchanged. AI-assisted testing/report.
Imported from boykopovar/AnyPS5. Originally posted by tibzejoker on 2026-10-12T21:25:05Z.
GTA V (PPSA04264) numbers for the table cost @SleglJan and @tv7 describe. Windows 11, RTX 4090, 64 GB RAM. Base: main
2a5eca11cplus the open PRs GTA needs. #757 is tv7'srebase/757(8945fe208). Story prologue, same scene each time. FPS is frames counted over 120 s.fix/757-key-domain(0a7d5dad7)0x25b456800,0x25b458e00), and RAM levels off rather than growing.0x25b45a200, which I posted earlier. Its T# index is loaded from a second constant buffer.perf/image-table-snapshot-reuse(f9c2003df). It needs #758's 64-bit pointer tables (TableColumn::address,ScalarAddressDword), and this tree doesn't have #758.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by Tamalero on 2026-10-12T23:17:25Z.
Marvel's Guardians of the Galaxy (PPSA01748) on tv7's
rebase/757, with #758 on top: two findings about table materialization, alongside the table cost @SleglJan and @tibzejoker measured. One of them comes with a fix that took the title from 0.4 to about 4 FPS.1. Garbage table slots get snapshotted every frame. Two elements of the title's table (226 and 255) hold a repeating byte pattern, not a T#. They decode to base
0x2dd20158000, 11125×6107, 65 layers, format 2: about 4.4 GB, far outside mapped guest memory. The table path builds that texture at every table use:ReadTextureSurfacefills a 4.2 GB vector, it's uploaded, the cache refuses it for size, and the next frame does it again. That costs about 1.9 million minor faults per 5 s, a 4 GB host and driver mapping churning each frame, and the whole desktop stutters. The title never samples those slots.Locally I poison an element whose memory isn't mapped. In the resolve loop, after
DescribeSurface, ifGuestMemory::Accessible(base, guestBytes)is false, the element is rejected like a decode failure. Results:Every T# I saw with
MIN_LOD_WARNorMIP_STATS_CNT_ENset was one of these garbage slots, so the "texture streaming feedback is not reported" warning is a side effect of decoding them.2. Table reuse never hits for this title, and can't with an exact-match key. A performance trace at about 4 FPS shows frames of about 210 ms (p50), with the GPU busy about 43 ms. About one table is resolved per frame, and that resolve costs about 25 ms in
capture_resourcesplus about 20 ms inmaterialize. I traced the reuse misses step by step:The
TableStatekey changes between every pair of lookups. The collect epoch and the allocation generation both change each time, because the title allocates constantly.Every table has unfit entries. Each one has about 36 entries that are views of storage images, plus a few with no write-watch generation, and any single unfit entry disqualifies the whole table.
Relaxing both still gives 0 hits. I relaxed both locally, as an experiment only:
TableCurrent, I runCollectWritesover the table's ranges beforeUnchangedSinceAll. Without that,agc_driver_image_table_reusecorrectly catches stale texels.With that, tables are kept, but no lookup ever matches. The title builds a different table every frame: 214, 239, 243, 268, 328 and 345 entries in consecutive frames.
This looks like the whole-domain walk @SleglJan describes. Table sizes that change from frame to frame fit a table that isn't narrowed, so
fix/757-key-domainmay be the real fix here. I haven't tested it on this title yet. If narrowing doesn't cover Guardians' key shapes, the per-element cost is what's left, at about 150 µs per entry. A per-element memo keyed on the descriptor words and validated per range would help more than whole-table reuse. Finding 1 applies either way: a narrowed table can still land on a garbage slot.Details and logs
Setup: Linux (CachyOS), RTX 4090 (NVIDIA 615.78), GCC 16, Release. Main
84659e16d, plus tv7's rebase of this PR (8945fe208), plus #758 (cad61e9a7), plus local fixes the title needs to reach its first UI:BLEND_BYPASS;sceNpGetUserIdByAccountIdoffline.The title relinked with
--to-intel.#758 is needed for this title. Without it, the run aborts after about 97 s on
GetImageResource dword 0 is not a valid runtime value(pc0x588, the loop-counter shape). With it, pcs0x588,0x5d4and0x974compile. Pcs0x4378and0x4380(the waterfall/ImageRead shape) still fail at registration but are not dispatched.Cherry-picking #758 onto the rebase conflicts in two places:
ShaderDiskCachesize asserts, which become Artifact 200, Invocation 200, Result 408 (#758 adds one vector to each of the last two);docs/dev/TechnicalDebt.md.Slot 226/255 descriptor words:
Trace summary (
APS5_TRACE_SECONDS=150:20, 93 presents):Reuse miss breakdown (local counters, per 5 s at the same screen):
Tested and written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by Tamalero on 2026-10-12T23:33:12Z.
Follow-up for @SleglJan: I tried
fix/757-key-domain(0a7d5dad7, cherry-picked onto the stack above) on Guardians of the Galaxy (PPSA01748). It doesn't narrow this title's tables: they still bind 257–342 entries per frame, the same as without it. The relevant tests pass on the combined stack, includingagc_shader_memorywith the new SRT-key case.The reason is the key shape. I logged every table key that ends up with no domain. All 12 in this title are the same loop-carried index:
So the shader walks the table in a loop and samples each entry up to a bound. No key domain can narrow that to one record, because the shader may really read every entry below the bound. A domain bounded by the loop limit would still leave hundreds of entries here. For this title the remaining cost is per bound entry, at about 150 µs each, roughly 45 ms per frame at about 300 entries.
FPS on the same screen, no shader cache in either run:
The difference may just be the uncached runs; I haven't separated it out.
Details
The diagnostic is local: it prints
IrOpcodeNameof the key and its first arguments whenMatchKeyDomainreturns no domain inTryMakeTableColumn. The twoVoidoperands it printed are the loop's initial value and step, which aren't instructions.These are the same shaders whose index chain shows up in the
GetImageResource dword 0failures this title had before #757 and #758: a loop-carriedPhi/IAdd32shifted left.Tested and written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-13T00:12:12Z.
Rebase check, read-only. I did not touch this branch.
State. The PR head
753c29396conflicts withmain(1c5e62878). tv7'srebase/757(8945fe208, one commit on44ab0c39e) is 147 commits behindmainnow, and merging it intomainconflicts in three files:core/shader/recompiler/Optimization/src/ResourceTracker.cpp, inRun():mainnow sets upm_blockSourcesandm_blockImagesthere, and the PR replacesPlanIndirectImages()withPlanTableColumns().core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp, innoteReusable():mainadded aRefreshedPerUse()texture check, and the PR changed the line after it to skipImageTableMapallocations.core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp, the test list and the test definitions.How I resolved them (scratch merge of
8945fe208into1c5e62878, not pushed):ResourceTracker.cpp: keptmain's block-index setup and calledPlanTableColumns().ShaderResources.cpp: kept both,main'sRefreshedPerUse()check and the PR'sImageTableMapexemption.ShaderMemory.cpp: keptverifyGuardedDescriptorSourcesand the PR'sverifyImageTableKeys,verifyImageTablesandverifyImageTableRegistration. I droppedmain'sverifyBindlessTable, because it exercises the indirect-image path this PR removes.Results. GCC 16.2.1, Release, Linux, lavapipe.
agc_driver_image_table_tests,agc_driver_image_table_cache_tests,agc_driver_image_table_reuse_tests,agc_driver_bindless_images_testsandagc_shader_memory_testsall exit 0.tools/check_conventions.py --base upstream/mainpasses.Not tested: native RADV, the full suite, and any title. A lavapipe pass says nothing about adriadam10's RADV
vkAllocateDescriptorSets-12 (reviews of 10 Oct). He reported it gone at the earlier heade904eb18, but this head,753c29396, has not been run on RADV.Question for the author: should
main'sverifyBindlessTablebe ported to the table design? I dropped it only because it depends on the removed path, and I can't judge the coverage it gave.Imported from boykopovar/AnyPS5. Originally posted by Tamalero on 2026-10-13T01:18:03Z.
@Celegans12 Why the remaining Guardians of the Galaxy (PPSA01748) shaders (pcs
0x4378/0x4380) don't become a table column, reproduced offline withagc_shader_replayon the stack above (#757 + #758):The T# is loaded in two halves through the same pointer, but the two offsets are computed separately. Dwords 0–3 come from the load at
0x4378and dwords 4–7 from the load at0x4380. Both use the sameGetAddressResource(ReadConst(SRT), ReadConst(SRT))pointer. The second half's +16 is folded into its offset before theReadFirstLane, instead of being an immediate:So
TryMakeTableColumnstops at the per-dword check: dword 4 reads immediate offset0x0where it expectsfirst + 16 = 0x10. Even with that relaxed,EquivalentValue(offset, read->Argument(1))can't hold, because the two offset values only agree at run time. Of the 111 image handles in the shader, this is the only one that gets this far; the rest are not table loads.The index itself is a light-list walk:
FindILsb32over a mask from anImageRead, made uniform withReadFirstLane. So a key domain can't narrow it, and the column has to take the whole range behind the pointer.Two possible ways to accept it, if this shape is in scope for #757/#758:
offset4 == offset0 + 16by walking both expressions together throughReadFirstLane/SelectU32/Phi, with theIAdd32(…, 16)on the dword-4 side.Ratchet & Clank: Rift Apart (PPSA01474, see #4706) stops at a related shape: compute shader
0x116bb65f00, a T# through a pointer that is itself read from a V# (ReadConstBuffer@0x1aa8) at aReadFirstLanewaterfall index, at pc0x6340. I haven't traced that one yet; its request isn't in the log.Would you like us to take on some of this? I work with Claude Code on this machine, and either part is something we could try:
It would be a commit on top of your branch or a follow-up PR, whichever you prefer. I'd rather not start without your view on which approach fits #757's design. I can also run any branch you push on both titles and report back.
How it was traced
A local diagnostic in
TryMakeTableColumnnames whichreturn falseeachGetImageResourcehandle takes:It then prints both dwords' handle and offset IR, which is where the two expressions above come from. The request replays with
agc_shader_replay(4824 code words, 14 user data, wave64, 4×4×4 threads). It's game code, so I'm not attaching it.Tested and written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-13T02:00:31Z.
Measurement on Ghost of Yotei (PPSA26344), llvmpipe (LLVM 23.1.1) through lavapipe, no AMD hardware, so no RADV claim.
Stack.
mainat510a2188cplus tv7'srebase/757(8945fe208), merged locally as4702369de. It hits the same three conflicting files as in my rebase check above (that check was against1c5e62878, this run against510a2188c).Result on this title. On
mainalone the run aborts at compute shader0x80003aa700(the record-table shader from #2715). That one failure appears in 3 log lines: the registration warning,presentation failed, andwhat():. With #757 stacked,0x80003aa700appears in 0 log lines, and the run stops at a different shader. Thepresentation failedline reads:The chain starts with
LoadAddressU32on aGetAddressResourcepointer, which is the shape #758 handles.This is one stop on one device. The title does not reach gameplay, and I am not claiming it does.
Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-13T02:27:38Z.
@adriadam10, sorry for leaving your question from Sunday open. Short answer: the old head changed neither cost report, and this one changes both, though only partly for keys that can't be narrowed. I've rebased onto
main37dd4830and pushed the changes as one commit.Here's what changed for each report:
ShaderMemory::readWords(that reader is Jan's, from hisperf/image-table-snapshot-reuse), and the per-record lookups use a hash instead of an ordered map. Offline, an 18,960-record table now takes 1.6 ms per capture instead of 4.2 ms on my machine, including the page fetches. Jan's per-thread memo would cut it further, so I've left that for his follow-up, as he planned.imageTableCapacity". The driver only builds textures for the entries the snapshot holds. So the real lever is narrowing, and I've folded in Jan'sfix/757-key-domain: a key the SRT walker can evaluate now narrows the table to the selected record. It's in this commit with credit in the message. That still doesn't help @Tamalero's Guardians tables. Their keys are loop counters (Phi(init, IAdd(Phi, step))), so the shader really can reach every entry below the loop bound. @tv7, your 2,493-entry heap on 8 GB will still run out of device memory if its key is one of the shapes that can't be narrowed. A texture byte budget would turn that into a fault whenever the shader selects an entry past the budget. I'd rather not decide that policy inside this PR. Would a separate issue for it work for you?agc_driver_image_tablenow requires the fault for such an entry. With the fix reverted, that check fails.@tibzejoker, your GTA numbers (1.22 → 0.65 → 0.77 FPS) were measured before both changes. If you get a chance, a rerun on this head would show how much is left.
The rebase itself follows @tv7's
rebase/757: per-set table bindings, so a fragment table sits in the fragment set when pipeline libraries split it. That should also cover the set-0 crash @Mouhand-Kaddo found on RADV. For the rest of the rebase I used @Dextroid17's conflict notes. On his question: I didn't portverifyBindlessTable. Its two modes, keys from material records and the whole table, are whatverifyImageTableKeysandverifyImageTablescover now withTableMaterialCodeandTableWholeCode.@oneandonlydean, thanks for rerunning the reuse test. Could you run
agc_driver_image_table_reuseandagc_driver_image_tableonce more on the 4090? And @adriadam10, could you runagc_driver_bindless_imageson RADV again? Both changed since your runs.Details
DepthSurface.cppconflict withmain.log_macrosfails onmaintoo.main0c3dc9ca: 1,006/1,007 pass;agc_driver_depth_compare_copyfails onmaintoo.ShaderMemoryper capture, median of 60. Before: 4.2 ms. After: 1.6 ms, or 1.0 ms with the pages already fetched. Of the remaining time, about 0.7 ms is the per-record descriptor lookup.agc_shader_bindlesscompares run reads with word reads. That includes a run across a page and a record cut by an unmapped page, with identical snapshots and captured regions. It also includes Jan's SRT-key case, which fails with his tracker change reverted.maintook 28 since my last push. Runtime ABI 12.Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-13T03:47:42Z.
I reviewed the overlap with #4757, #757 and #758. #4757 fixes a reproduced CPU memo hash collision by retaining an owned ResourceSnapshot and checking exact Matches at both lookups. Your image-table snapshots own their vectors and provide nested default equality, so retaining ResourceSnapshot::operator== would automatically include the new tables, including #758's readRanges.
I propose landing #4757 first, then rebasing #757/#758 while retaining that equality and the collision regression alongside the image-table checks. I have not tested the combined branches. Would you agree to this order? If agreed, #4757 would keep Depends on: none, and the following PRs would declare #4757 as a dependency.
AI-assisted: yes. — Codex
Imported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-13T04:27:58Z.
@Celegans12 thanks for folding the SRT key domain into
f99f5ecdc. @tibzejoker @Tamalero thanks for testing it. Two problems with it turned up on 007 since I posted it, and both are fixed on our stack. The first is now inf99f5ecdctoo; a one-commit fix on top of it follows.TableColumn's defaultedoperator==). Once accesses get domains, accesses with different key expressions over the same table become separate columns, image resources and snapshot columns.f99f5ecdc, which has no memo of the snapshot walk yet. It matters for the per-thread memo follow-up you left for me. The whole-snapshot memo skips keyed columns, and the column memo is keyed on the pre-walk record states, which change with every key value, so neither hits. On our stack the fix walks the whole domain as before and applies the narrowing afterwards as a mask over the output codes. That will go into the memo follow-up.@Tamalero your loop-carried
Phi/IAdd32keys get no domain from the patch, as you found. It only changes such a shader if another access in it does get a domain, and then problem 1 applies. I can't tell from here whether that's behind your 2.5–3.8 vs 3.5–6 FPS. On the unmapped slots: across two of our 007 runs (~142k texture creations) no such surface reached creation (the largest was 6400x4096), so it's not a lever there, but the rejection is harmless for us.Patch: SleglJan/AnyPS5
fix/757-key-domain-v2at 92bdcdbfa, one commit onf99f5ecdc(4 files, +144/−32).Narrowmarks the union of all domains' records and keeps record 0.ShaderMemorycases underagc_shader_bindless:v_readfirstlaneof a per-lane buffer load leave the column whole, checked in both orders.keyDomainfield, the union case's planning check fails there: two images are planned for the two keyed reads.agc_driver_depth_compare_copyfails onmaintoo. Conventions pass againstf99f5ecdc.f99f5ecdc: our 007 request dumps don't load on that head.@tibzejoker if you rerun GTA on
f99f5ecdc, this commit on top would show whether split columns cost anything there.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by tibzejoker on 2026-10-13T04:51:56Z.
@Celegans12 GTA V (PPSA04264) rerun on
f99f5ecdc. Windows 11, RTX 4090, 64 GB RAM. Story prologue, same scene as my earlier numbers, FPS from frames counted over t=30..120 s.The base is now main
37dd48308plus the open PRs GTA needs, so I measured with and without #757 on that same base:f99f5ecdcf99f5ecdc+ SleglJan'sfix/757-key-domain-v2(92bdcdbfa)fix/757-key-domain0x25b456800,0x25b458e00) still dispatch with #757. Without it they fail and are skipped, so the "without" row does less GPU work than the "with" row.0x25b45a200:GetImageResource dword 0 is not a valid runtime value; chain: ReadConstBuffer@.... Its T# index comes from a second constant buffer.Two things outside this PR were needed to get this far on current main, for anyone stacking on it:
buffer descriptor has reserved bits set. Main up toe55b881f0is fine, and reverting #4410 alone fixes it. I'll write it up separately.889e5d436) refuses a 2D-array/cube depth storage view that GTA uses (compute0x242d4a200), so I reverted that commit locally.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by tibzejoker on 2026-10-13T07:50:18Z.
@Celegans12 the last in-order failure in GTA V (PPSA04264) with this PR, and a one-commit fix on top of
f99f5ecdc, in case it fits #757.Shape. Compute shader
0x25b45a200reads its T# withs_buffer_loadfrom a V# at(key << 5) & mask. The key itself is aReadConstBufferfrom a second V# at av_readfirstlaneindex. Onlykey * stride (+ addend)offsets are matched as a table column, so it stops onf99f5ecdcwith:Patch: tibzejoker/AnyPS5
fix/757-masked-table-offsetat 2a2f96385, one commit onf99f5ecdc(3 files, +58/−3).TryMakeTableColumnalso acceptsBitwiseAnd32(ShiftLeftLogical32|IMul32(key, 2^n), imm): the shift is the stride, the addend is 0.docs/dev/debt/shader.mdsays so.ShaderMemorycaseverifyImageTableMaskedOffset. It runsTableMaterialCodewith ans_and_b32after the shift, and keys that carry bits above the mask. It checks the column (stride 32, no key domain) and that the whole table is bound. Onf99f5ecdcit fails with the sameGetImageResource dword 0error.Tested on Windows 11, RTX 4090, GCC 15.2.0 UCRT, Release:
agc_shader_memory,agc_shader_bindless,agc_driver_image_table,agc_driver_image_table_cache,agc_driver_image_table_reuseandagc_driver_bindless_imagespass.tools/check_conventions.py --base f99f5ecdcpasses.agc_shader_replay, GTA's request now passes resource analysis. It then stops atSrtWalker::EvaluateDescriptorSources, because replay has no guest memory.37dd48308plusf99f5ecdcand the other open PRs it needs), with this commit0x25b45a200dispatches. For the first time the Story prologue runs with no failing dispatch at all: our local skip-on-error hack never fired in 150 s, and the rendering is correct. Binding the whole domain costs FPS: 0.56 against 0.66-0.78 when the shader was skipped, at the same 36-37 GB RAM.Fold it in or take it as a follow-up, whichever you prefer.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T08:43:01Z.
Review: CHANGES_REQUESTED
Checked
f99f5ecdcmerged onto currentmain(Linux, RADV, libSceAgc + libSceAgcDriver scope): 493/494 ctest.agc_driver_image_table,_cache,_reuse,agc_driver_bindless_images,agc_driver_graphicsand the shader memory/disk cache tests pass. The one failure,agc_driver_tessellation, is a SIGSEGV insidelibvulkan_radeonfromLinkPipelineFromLibraries; it also shows up on an unrelated PR here, so I'm not blaming this one. The new tests can't be run againstmain(they needImageTableAbi.hpp), so no negative check from our side.Before this can land:
docs/dev/ARCHITECTURE.mdneeds the change: runtime image/sampler tables, the map buffer, snapshots per invocation and the new disk format. The PR touches the descriptor flow and the cache but only editsdocs/dev/debt.Phi(init, IAdd32(Phi, step)), 257-342 bound entries per frame). Please say what you expect to bound this to, or narrow those cases, with a before/after on the same tree.TableColumnequality including the domain) and @tibzejoker's one-commit fix for the(key << 5) & maskshape are not in this head; fold them in or say why not.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T13:10:35Z.
Review: CHANGES_REQUESTED
8ca1d7acd is a rebase onto
main0f2683cb(conflicts only); none of the points from the last review are addressed yet, and they still apply:docs/dev/ARCHITECTURE.mdstill describes the descriptor flow without the runtime image/sampler tables, the map buffer, per-invocation snapshots and the new disk format. Add it under the section that covers runtime descriptors.Phi(init, IAdd32(Phi, step))) binding 257-342 entries per frame. Please say what you expect to bound this to, or narrow those cases, with a before/after on the same tree.TableColumnkey-domain follow-up and @tibzejoker's fix for the(key << 5) & maskshape are not in this head; fold them in or say why not.Merge needs the full Build dispatched on the final head (linux/windows are skipped on PRs).
Imported from boykopovar/AnyPS5. Originally posted by tibzejoker on 2026-10-13T13:19:39Z.
@Celegans12 the
(key << n) & maskfix applies cleanly on 8ca1d7acd: tibzejoker/AnyPS5fix/757-masked-table-offset-8ca1, one commitf1a8500f3on your head (3 files, +58/−3, same change as 2a2f96385).On Windows 11, RTX 4090, GCC 15.2.0, Release:
agc_shader_memory,agc_shader_bindless,agc_driver_image_table,agc_driver_image_table_cache,agc_driver_image_table_reuseandagc_driver_bindless_imagespass.ResourceTracker.cppchange,agc_shader_bindlessfails on the newverifyImageTableMaskedOffsetcase.tools/check_conventions.py --base 8ca1d7acdpasses.Cherry-pick it if you want to fold it in.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by tv7 on 2026-10-13T17:13:48Z.
@Celegans12 @tibzejoker Marvel's Wolverine (PPSA03671) on 8ca1d7acd + tibzejoker's
f1a8500f3, for the masked-offset question in the last review. Windows 11, RTX 3070, GCC 15.2.0, Release. Base: #757's head (main0f2683cb) plus #4702, #5304 and local placeholders for three unknown imports. Not current main, which #757 conflicts with.The title still stops at the same place as without
f1a8500f3:Shape. It is the other order of the
(key << n) & maskcase: the mask comes first, the shift after.s47is itself ans_buffer_load_dwordat 0x94ec from a V# read from the SRT, at an offset loaded at 0xa14 and shifted left by 4. The T# then reaches the image instruction through nested Phis (the fetch sits in a loop with branches), so this may also be one of the loop-carried keys from the cost discussion, not only a new offset shape.agc_shader_replay shader_11d1418800.reqreproduces it offline on this tree (resource analysis failed: GetImageResource dword 0 ...). The dump holds the title's shader code, so I have not attached it; the instructions above are the relevant part, and I can run a candidate fix against it.🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by tibzejoker on 2026-10-13T17:19:04Z.
@tv7 thanks. I don't think the offset is what stops it there.
f1a8500f3.(key & 0xffff) << 5isMatchScale'sShiftLeftLogical32(x, 5), withkey = BitwiseAnd32(...): an affinekey * 32column.f1a8500f3only adds the other order,(key << n) & mask, where the mask is applied after the scale.Phi(Phi(ReadConstBuffer@0x9878 ...), Phi(...)), so the T# that reaches the image instruction merges loads from different arms or iterations.SplitDescriptorPhisonly splits a descriptor Phi when every predecessor gives an incoming value and the arms are equivalent. It also searches 8 levels at most (phiSearchDepth). A loop-carried T# (Phi(init, load)in the loop header) falls outside both conditions.APS5_DUMP_IR=11d1418800on that replay should show whether thes_buffer_load_dwordx8at 0x9878 ever becomes a table handle before the Phi. Is the header Phi's other incoming value the same load from a previous iteration, or a different T#?AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by tv7 on 2026-10-13T19:22:33Z.
@tibzejoker thanks, that was it.
APS5_DUMP_IR=11d1418800on the replay (same tree, 8ca1d7acd +f1a8500f3), IR aftersrt:The failing
GetImageResource %99754(block$309, pc 0xc818..0xcc38) gets every dword through two nested loop-header Phis, and both are loop-invariant. The other incoming value is the Phi itself, not a different T#:Dropping the self-references, all eight dwords (
%69710..%69717) resolve to that one load, so the T# is fetched once before the loop and carried through it unchanged. The other image accesses in this shader with a Phi in dword 0 have the same shape (Phi(x, self)in$248/$251). So it looks like a case for removing trivialPhi(x, self)beforeSplitDescriptorPhis/ the table match, not one that needs per-iteration snapshots.🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-14T02:24:40Z.
@adriadam10, this head goes through your four points from yesterday. I've rebased onto
mainee9037d8, which has #4883, so the disk format is now 31 here and 32 on #758. The runtime ABI stays 12, and neither PR touches the request serializer.docs/dev/ARCHITECTURE.mdhas a new "Runtime image and sampler tables" section under Graphics, next to the registration-module bullets that describe the other runtime descriptors. It covers how a column is planned and narrowed, the per-invocation snapshot, the map buffer layout, poisoning, driver-side reuse and what the disk cache stores. Rebasing onto #4883 also needed a real change: its stored front-end plans carried the old indirect-image fields, so the plan encoder now writes each table column with its key domains, andagc_shader_disk_cacheround-trips plans with keyed and whole columns.Both fixes from the thread are folded in, credited in the commit message. @tibzejoker's
(key << n) & maskchange is in, with one line adapted so a masked read marks the shared column whole. @SleglJan'sTableColumnfollow-up is in too: one column per heap access shape, narrowed to the union of its keys, and kept whole as soon as one read has no key domain. Both of their tests are inagc_shader_bindless. @Tamalero's unmapped-slot rejection was already in the last head.On cost, I can't run GTA V or Guardians, so here's what I can say and measure. A table whose key the SRT walker can evaluate binds the records its keys select plus record 0. A loop-carried, lane-reduced or masked key binds every record the heap V# covers, capped at 65,536. Inside one invocation the shader can read any of those records, so binding fewer would mean faulting on reads that are valid. A loop-limit bound would only help when the limit is something we can evaluate and is smaller than the V#. In Guardians the table changes size every frame with the list (214-345 entries in @Tamalero's trace), so I expect the two to be the same there. I haven't seen a title where they differ.
For a before/after on the same tree, I took a 65,536-record heap with 4,096 distinct T#s (GTA's table size) and timed the CPU side of one invocation, with and without the two fold-ins. A whole table costs about 7.1 ms to snapshot plus 0.4 ms to build the map, and binds all 4,096 images. A keyed table costs 0.2-0.3 ms. Before the fold-ins, two SRT keys into one heap made two table images and two snapshots; now they make one (0.58 → 0.32 ms). The masked shape went from a refused dispatch to a whole table, which matches what @tibzejoker saw: GTA has no failing dispatch, but runs at 0.56 FPS instead of 0.66-0.78 with that shader skipped. His 1.33 FPS baseline also skipped the two 65,536-entry table dispatches, so it isn't the same amount of work.
I also replayed Yōtei's captured requests with both trees. 64 of them plan tables, 137 columns in all, and every one is whole in both: their keys are waterfall
v_readlane/v_readfirstlaneindices and loop counters. So for these titles the cost is per bound entry, and I don't think narrowing is what will bring it down. What will is not redoing that work every frame. @SleglJan's snapshot reuse (3.3 → 0.3 ms per snapshot on 007) needs #758, so it can follow once both land. For the driver side, @Tamalero's per-element memo keyed by the descriptor words would fit Guardians, where whole-table reuse never hits. My CPU numbers don't include the driver's texture lookup per element, and at the ~150 µs per entry he measured, that's the larger part.On order: #4883 is merged and this is rebased onto it, so 31/32 are final unless
maintakes another format first. #5461 and #5472 also bump to 31, so whichever of us lands later renumbers. #4757 doesn't change any format or ABI number, and the only textual overlap is two adjacent lines inResourcePlan.hpp. SinceImageTableSnapshotalready compares by value, its snapshot equality covers the tables automatically. I'd suggest #4757 goes first since it's small and fixes a correctness bug, and I'll rebase this onto it. @Ondra97, does that work for you? A maintainer still needs to dispatch the full Build on this head.Details
log_macrosfails onmaintoo. Linux (upstream's job in WSL, lavapipe), merged withmain016db923: 1,093/1,095 pass;agc_driver_bc_block_copyandagc_driver_depth_compare_copyfail onmain016db923too.agc_driver_image_table,_cache,_reuse,agc_driver_bindless_images,agc_driver_runtime_images,agc_shader_bindless,agc_shader_memory,agc_shader_disk_cache,agc_driver_graphics,agc_shader_device_profile: 10/10.agc_shader_disk_cache's plan-switch check usedAPS5_TRACE_BINDLESS, which only the removed indirect path read, so it now usesAPS5_TRACE_IMAGE_TABLE.CaptureResourcesthroughShaderMemoryplusRecompile(request, capture)for the sixTableRequestshaders, 65,536 records of 32 bytes and 4,096 distinct T#s, median of 10 after 2 warm-ups, RTX 3080 Laptop machine, CPU only.v_readfirstlanelane key(key << 5) & 0x1fffe0GetImageResource dword 0)main's request reader; 428 plan, and the 2 failures are #758's pointer tables. 64 plan tables, 137 columns, all whole on both trees. Key shapes per shader:ReadLane(SelectU32)38, loopPhi20,ReadFirstLane(SelectU32)8,ReadLane(Phi)3,UMin32(ReadLane)1, and 2 whose material-V# keys share a column with an unkeyed read.Imported from boykopovar/AnyPS5. Originally posted by tibzejoker on 2026-10-14T02:51:04Z.
@Celegans12 GTA V (PPSA04264) on this head, b26df6aaa. Windows 11, RTX 4090, MinGW-w64 GCC 15.2.0, Release, write watch on.
Base:
main71c71f50bplus the open PRs GTA needs to reach Story: #5596 (#637's port), #4878, fdfawef324's #448 port, #1186 and #1189. I ran the same tree with and without this PR, one Story run each. "Skipped" is our local hack that logs a dispatch whose shader can't be compiled and skips it instead of aborting.So the folded-in masked-offset change works on this head, and GTA has no failing dispatch with it. The FPS gap is the same as on our older stack (0.56 against 0.66-0.78). As you said, it isn't the same work, since the run without #757 skips those three dispatches.
Two things that may be worth a look:
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-14T05:11:04Z.
@tibzejoker, thanks for the before/after numbers. I chased the growth with a driver-level test, and it wasn't a snapshot kept per invocation. Two caches in the driver are capped by entry count only, and with this PR their table entries became several MB each. The new head 4dcf657a20 caps both by size.
The resource cache keys a built dispatch on its descriptors, and that key includes the table's T# list and map. So when a few records change every frame, each frame adds a new ~5 MB object that keeps its 4,096 textures alive, and the old ones are never hit again. The cap was 1,024 entries, so roughly 5 GB plus those textures. The dispatch cache keys on user data, and each entry stores the captured table words (2 MiB for 65,536 records) plus the compiled result. When the SRT pointer moves between frames, every frame adds an entry, and that cache was only capped at 8,192 keys. Your ~1 GB/min at 0.66 FPS is about 8 MB per table dispatch with three table shaders, which is the same order as these two together. Now the resource cache keeps at most 65,536 table elements and the dispatch cache at most 256 MiB of captured words, evicting the least recently used (
APS5_RESOURCE_CACHE_TABLE_ELEMENTSandAPS5_DISPATCH_CACHE_BYTESoverride them). In my test both stay flat over 300 dispatches. With the same table every dispatch, nothing grew before either.The jump when Story starts is a different thing, and this head doesn't change it. I checked that nothing runs per record that should run per distinct T#: the 65,536 records are read once to build the map, and exactly 4,096 elements and 4,096 textures come out of it. All of them are created in that first dispatch, so that's the stall. On top of the GPU copy, the texture cache keeps a CPU copy of each sampled texture's guest bytes for its change check, so a 4,096-texture table costs about its texture size again in RAM. My guess is that this is most of your 10 GB, but I haven't measured it with GTA-sized textures. That copy is bounded by the sampled-texture budget, which comes from VRAM, not by RAM, so it's a separate follow-up. The draw cache has the same count-only cap. Fragment-stage tables could grow it the same way, but nothing has shown that yet, so I've left it for a follow-up if a title does.
Could you rerun Story on 4dcf657a20 with
APS5_PROFILE_DRAW=1and post the[dispatch-cache]and[rescache]lines plus RAM at 180 s? Those lines show which of the two caches GTA was filling.@adriadam10, the ordering question is settled: #4757 was closed (oneandonlydean found no title reaches it), so #757 goes first and #758 stays stacked on it. The disk formats stay 31 here and 32 on #758, and the runtime ABI stays 12. #5461 and #5472 also take 31, so whichever of us lands later renumbers. For Ghost of Yōtei this pair is the difference between no frame and the loading screen. I ran plain
main75690a11tonight, and the game aborts 31 s in, before its first frame, on the compute shader 0x80003aa700 (GetImageResource dword 0, its texture comes from a runtime table). With #757/#758 and the rest of our stack it renders the logos, intro and title and runs 50 minutes into the loading screen without a crash. Could you re-review this head? A maintainer also needs to dispatch the full Build on it.Details
mainee9037d8, and both merge cleanly withmain90d0cb48.log_macrosfails onmaintoo. Linux (upstream's job in WSL, lavapipe), merged withmain90d0cb48: 1,110/1,112 pass;agc_driver_bc_block_copyandagc_driver_depth_compare_copyfail onmaintoo. #757 alone, Linux job merged withmain75690a11: the 10 targeted tests pass.agc_driver_image_table,_cache,_cache_bounds,_reuse,agc_driver_bindless_images,agc_driver_runtime_images,agc_shader_bindless,agc_shader_memory,agc_shader_disk_cache,agc_driver_graphics: 10/10.agc_driver_image_table_cache_bounds:APS5_RESOURCE_CACHE_ENTRIES=4orAPS5_DISPATCH_CACHE_ENTRIES=16on the old head also stopped the growth in the matching case, which confirms which cache each case fills.Texturecreations, 2.2-2.4 s. Private memory +1.34 GB for 64 MiB of texels, or +0.68 GB withAPS5_SYNC_TEXTURE_UPLOAD=1, so about half of it is uploads held by the open batch (the recorder submits every 512 MiB of kept bytes).Imported from boykopovar/AnyPS5. Originally posted by tibzejoker on 2026-10-14T05:59:27Z.
@Celegans12 Story on 4dcf657a2 with
APS5_PROFILE_DRAW=1, the same stack as my last post (mainee9037d85plus #5596, #4878, the #448 port, #1186 and #1189). Windows 11, RTX 4090.There were no failing dispatches in 180 s. The frame rate is about 0.6 FPS, with or without the profile switch.
RAM (private bytes):
The jump at the start is still there, as you expected. After it, RAM rises about 1 GB a minute, close to b26df6aaa (39 → 43 GB over the same 150 s). So capping these two caches did not change the slope for GTA.
Last lines at 180 s:
As far as I can read them:
So the remaining growth is likely somewhere else, possibly the CPU copies of sampled textures you mentioned.
The first try on this head crashed 15 s into Story, in
[RAGE] HDD Streamerat eboot 0x28aacee. The run above used the identical build and did not crash, so I take that crash to be intermittent and not caused by this PR. I am checking it separately.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T06:18:50Z.
On b26df6aaa tibzejoker sees process RAM jump by ~10 GB when Story starts (with a 15-20 s stall) and then keep rising by about 1 GB a minute, while it stays flat without this PR. Does anything keep the per-invocation snapshots of the whole tables alive past their batch? Please find where it goes and bound it, or show that it levels off.
Imported from boykopovar/AnyPS5. Originally posted by Tamalero on 2026-10-14T07:21:21Z.
@Celegans12, Guardians of the Galaxy (PPSA01748) on the current heads, since you can't run it:
maind8888df9b+ #7585595a163c0(which carries this PR's4dcf657a20), and nothing else except one NpManager stub.Progress. On older
mainwith this PR alone, the title aborted after about 97 s onGetImageResource(shader stage 5, pc 0x588). With both PRs it no longer aborts. It gets past the loading screen to its first UI screen at about 11 FPS. That screen draws only a dark background, a red rule and two corner marks, so its text and images are missing. That is about where my old local stack got, but now with no local table changes.Memory, since that's the open question here: RSS stays flat at 11.6 GiB over a minute on that screen, and was about 10 GiB three minutes in, while shaders were still compiling. I don't see the ~1 GB/min growth reported for GTA V, though this title doesn't get far yet.
What still doesn't plan (21 shaders at registration):
s_swappc_b64to a computed target (pcs 0x6a8, 0xa98, 0xbc4): #4706's territoryGetImageResource dword 0 is not a valid runtime valueat pc 0x4378 / 0x4380The three at 0x4378/0x4380 are the shape I'd flag for this PR or #758:
The T# is loaded through a pointer from the SRT, at
key << n. The key is areadfirstlaneof a value that comes from anImageRead: a per-pixel material id read from a texture, then made wave-uniform. So it's a uniform runtime key into a pointer-reached table, but the key's set of values isn't in a buffer the planner can enumerate.FYI, for whoever sequences these: #5089 (waterfall loops over per-lane T#s) doesn't cover this. Tried alone on
main, these chains have noReadLanecopy and are unchanged. It also conflicts with this PR and #758 inResourceTracker.cpp(12 hunks), so the two can't be stacked locally as they are.Details
--to-intel, and the shader cache was rebuilt (format change onmain).sceNpGetUserIdByAccountIdreturns USER_NOT_FOUND offline, sincemain's version still throws.Tested and written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-14T08:55:03Z.
Resident Evil Village (PPSA01556) numbers with this PR, from a Windows run to the title (RTX 3070 Laptop, driver 617.42), in case they help.
Setup: our Village stack,
mainf74ec639cplus this PR at b26df6aaa (ResourceMaterializer.cppis the same at 4dcf657a2) and other open PRs and local experiments of ours, with #5596 reverted and the address-space cache off (APS5_NO_ADDRESS_SPACE_CACHE=1, for an unrelated stop). Of those, only a local change that drops branch conditions the CPU walk can never evaluate touches resource plans.Narrow()traced were over the scan cap, for example:[image-table] (10 s): 408 snapshots, 408 tables, 13369344 keys, structural poison: none, narrowing 0 applied / 408 skipped, 1850.3 ms, about 4.5 ms per snapshot. Other windows there: 235 snapshots in 1,158 ms, 396 in 1,925 ms, 141 in 975 ms. How many snapshots a window takes may depend on the address-space cache being off; the cost per snapshot shouldn't.Two directions that might help, if useful:
ResourceMaterializer::Materializetakes the snapshot anew on every call (TableSnapshotter(...).Run()), so an unchanged heap is read and decoded again each time. Reusing a column's records while its heap range is unwritten would avoid most of those 4.5 ms per snapshot, with or without narrowing. The snapshot already records that range intables.ranges.Imported from boykopovar/AnyPS5. Originally posted by tibzejoker on 2026-10-14T09:00:13Z.
For EagleBearerYS's first direction, here is what GTA V shows on 4dcf657a2 (
maind8888df9bplus this PR, #448's port, #1186 and #1189). I sampled queue worker 0 every millisecond over 150 s of Story (APS5_SAMPLE_WORKER, 8,967 samples, symbolized withnm). Worker 0 is GTA's critical path; the full profile is in #5694.ShaderResources::resolveImageTables→GuestMemory::EqualsCommitted(memcmp): 7.1 % of worker 0.ResourceMaterializer::ResolveImageTables, its own time: 3.4 %.TableSnapshotter::Column: 0.5 %.So in GTA, about 11 % of the critical thread goes to re-reading and comparing tables. The tables are GTA's 65,536-record heaps with 4,096 distinct T#s, and they change rarely. Reusing a column's records while
tables.rangesis unwritten, as suggested, should remove most of that.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-14T09:18:11Z.
Thanks for running these heads on three more titles. It's good to see Guardians of the Galaxy get past its loading screen with memory flat at 11.6 GiB, and GTA with no failing dispatch.
What all three runs agree on is where the time goes now: re-reading tables that rarely change. In Village, each snapshot costs about 4.5 ms because narrowing never applies to its 32 MiB key buffer, and in GTA about 11% of the critical worker goes to re-reading and comparing the 65,536-record heaps (7.1% in
EqualsCommittedalone). @SleglJan already has the start of this inperf/image-table-snapshot-reuse(f9c2003df): it keeps a column's plan and descriptor lookups while its words are unchanged. That still reads and compares the words on every capture, which is the part tibzejoker's profile shows as the larger cost. So I'd add what @EagleBearerYS suggests on top of it: skip the read itself while the column's range intables.rangeshas no write since the last snapshot.@SleglJan, you said you'd open this after #757/#758 merge. Would you rather open it now, stacked on #758, or should I fold it in here with your authorship and add the unwritten-range skip? I'm fine either way. I'd just like the cost numbers in this thread to have an answer that lands soon.
@Tamalero, the three shaders at 0x4378/0x4380 are a new shape: a pointer table keyed by a material id read from a texture and made wave-uniform. The planner can't enumerate those keys from a buffer, so they'd need either the whole pointer-reached table or a runtime bound. I'll look at it as a follow-up rather than grow this PR. Could you attach one of their requests?
@adriadam10, none of this changes the four points from your last review, which I answered this morning. The snapshot reuse is a follow-up for the cost, not a correctness issue. This head is still waiting for your re-review and for the full Build.
Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-14T10:35:04Z.
I've rebased this onto
mainc654b199(head e7faf20683): #4806's mapped SPIR-V took disk format 31, so this PR now uses 32 and #758 uses 33, and #5347's depth-surface rework only moved where a new surface bumps the table-reuse serial. The one change in meaning is #5188's new test: with this PR, a T# read from a constant buffer at a user-data offset becomes a one-column table instead of an ordinary image, so I changed its check to read the record each key selects from the table snapshot. Both heads pass the full Windows NVIDIA suite and upstream's Linux job apart from the tests that also fail onmain. @EagleBearerYS, does that still cover what you needed for the Village mesh program?Details
mainis at 11). Both merge cleanly withmain3e577eda.log_macrosalso fails onmain. Upstream's Linux job in WSL (lavapipe), merged withmain23e93c05, passes 1,123/1,125, andagc_driver_bc_block_copyandagc_driver_depth_compare_copyalso fail onmainthere.agc_driver_image_table,_cache,_cache_bounds,_reuse,agc_driver_bindless_images,agc_driver_runtime_images,agc_shader_bindless,agc_shader_memory,agc_shader_disk_cache,agc_driver_graphics,agc_driver_buffer_descriptor_runtime. The same 11 pass in the Linux job merged withmain3e577eda.verifyUniformTableImage(#5188) now checks that the T# is planned as a table column with a 48-byte stride, and that the captures withs2 = 2ands2 = 1read the T#s of records 2 and 1 through the table.Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-14T10:45:41Z.
Yes for what the test was there for: that the program plans, and that each capture reads the T# of the record the user data selects. Your version checks both through the table (one column at a 48-byte stride, records 2 and 1). I haven't replayed Village's dumped mesh program on e7faf20683 yet. I'll add the result here when I have it.
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-14T12:07:39Z.
A follow-up on the replay I mentioned: it didn't get as far as the recompiler. Village's dumped mesh program (shader 0x2086a1e500, stage 7) is from 2026-10-13, request format version 20, and
agc_shader_replaybuilt at e7faf20683 stops loading it withRequestSerializer: truncated data. This PR doesn't changeRequestSerializer.cpp, somainreads it the same way. The dump was written by our local Village stack at the time, so it may not matchmain's reader.The driver only writes these dumps when preparation fails, and with #5188 merged this program prepares, so a fresh dump won't come on its own. Short of a Village run through its PSO cache build on this head, your updated
verifyUniformTableImageis what covers it.Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-14T15:14:26Z.
I've rebased this onto
main066b58faagain, and the new head isd9e47d1e98. The textual conflicts came from #5550, #5249 and #5408, but only #5550 changed what the code means. It taught the old bindless-table path to accept a T# that several image operations share, which happens when one table entry is both queried and sampled. This PR replaces that path.TryMakeTableColumnnever required the T#'s reads to have a single user, so each copy of the T# plans the same column, and the reads become planning-only once every user is a planned column. I ported milescoviello's test intoverifyImageTables: the shader must plan one column holding one image, and the map must select the right record for each key. To check that the test really guards the case, I added a single-user check back intoTryMakeTableColumnin a scratch build. The test then failed with the error from #5550 (GetImageResource dword 0 is not a valid runtime value).Two other merges were clean as text but broke on the content-key words this PR adds, an image shape per table element. #4783 reserves each key's exact size, and
agc_driver_graphicscaught the missing words. #5408's key-miss trace parses keys word by word, so every real key would have come out unlabelled. Both now count the shapes, and the trace counts table words as image and sampler words. Their tests cover this. #5249's in-place sparse heaps merged cleanly, and its two tests pass on this head.Disk format stays 32 here and 33 in #758, and the runtime ABI stays 12 (
mainis still at 31 and 11). With #758 on top, Windows NVIDIA passes 1,188 of 1,189 tests, and upstream's Linux job merged withmain84b01f9cpasses 1,171 of 1,173. The failures are the onesmainhas as well.@adriadam10 @oneandonlydean, could you take another look and start the full Build while the head is clean?
mainmoves fast, and these shader files conflicted again within a day.Details
ShaderResources.hppandtests/Graphics.cpp: kept both sides (#5408'sContentKeyComponentnext toImageTableReuseCounts, and the alpha-to-coverage switches next to the image-table ones).ResourceTracker.cpp: kept this PR'sTryMakeTableColumnand dropped #5550'susedOnlyAsImagetogether with the path it extended.tests/ShaderMemory.cpp: ported #5550's query test to the table-column model.LoadSampledImageDescriptorwith the slot argument this PR removed. It now loads the resource's descriptor like every other caller.ContentKeyreserves1 + imageShapes.size()more words per binding.ResourceContentKeyTestsnow gives the images shapes and checks that changing the last shape changes the key. Before the fix it failed with "content key reserved a different word count than it serialized".LabelShaderKeyreads the shape list and labelsImageTable/SamplerTablewords as image/sampler.agc_driver_key_missgained image-table word, shape and sampler-table word cases.CutRegionscheck, and a set holding both is reused only when both proofs pass.agc_sparse_run_importandagc_sparse_run_import_copiedpass.agc_driver_image_table,_cache,_cache_bounds,_reuse,agc_driver_bindless_images,agc_driver_runtime_images,agc_shader_bindless,agc_shader_memory,agc_shader_disk_cache,agc_driver_graphics,agc_driver_buffer_descriptor_runtime,agc_driver_key_miss,agc_sparse_run_import,_copied,agc_driver_image_store_array_through_volume,agc_driver_image_address_dimension, and both alpha-to-coverage state tests. The same 18 pass in the Linux job on #758 merged withmain84b01f9c.agc_shader_disk_cachetimed out once in the parallel pass. It passed alone, and then ten times in a row under-j 8alongside the other table tests.main84b01f9c.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T15:28:00Z.
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.
main)core/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hppL22-23, L25-27core/shader/recompiler/Optimization/src/ResourceMaterializer.cppL29-30, L446-447, L1026-1027, L1042, L1048-1056core/shader/recompiler/Optimization/include/Optimization/SrtWalker.hppL34core/shader/recompiler/ShaderDiskCache.cppL87-89core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ResourcePlan.hppL13core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/Resources.hppL59-61core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppL416-427core/shader/recompiler/Optimization/src/ResourceMaterializer.cppL195-197, L586-587core/shader/recompiler/ShaderDiskCache.cppL141-142core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppL170core/shader/recompiler/ShaderDiskCache.cppL141-142core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppL170core/shader/recompiler/Optimization/src/ResourceMaterializer.cppL1037-1038core/shader/recompiler/ShaderDiskCache.cppL141-142core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppL1080-1101core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppL12, L683-684core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppL12, L682-684core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppL12, L682-684core/shader/recompiler/Optimization/include/Optimization/SrtWalker.hppL34core/shader/recompiler/ShaderDiskCache.cppL87-89core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppL1358core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ControlFlowInfo.hppL22-37core/shader/recompiler/Optimization/src/ResourceMaterializer.cppL317-338, L380-399core/shader/recompiler/Optimization/src/ResourceTracker.cppL433-463, L485, L498, L540-547, L557-585core/shader/recompiler/ShaderDiskCache.cppL110-111, L150, L967-975, L1106, L1109-1118core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hppL127core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppL703core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cppL154, L330-331, L597, L618core/libs/prx/libSceAgcDriver/tests/Graphics.cppL26core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppL1358core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ControlFlowInfo.hppL22-37core/shader/recompiler/Optimization/src/ResourceMaterializer.cppL317-338, L344-369, L380-399core/shader/recompiler/Optimization/src/ResourceTracker.cppL433-463, L485, L498, L540-547, L557-585core/shader/recompiler/ShaderDiskCache.cppL110-111, L150, L967-975, L1106, L1109-1118core/shader/recompiler/ShaderDiskCache.cppL86-89core/shader/recompiler/Optimization/src/ResourceMaterializer.cppL220Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T15:34:48Z.
Review: APPROVED
Re-review of
d9e47d1e98(#757) with #758's34525fdf7aon top, merged ontomain84b01f9cd(clean merge). Linux, RADV,-DANYPS5_ENABLE_SPIRV_TOOLS=ON, libSceAgc + libSceAgcDriver scope: 572/573 ctest.agc_driver_image_table,_cache,_cache_bounds,_reuse,agc_driver_bindless_images,agc_shader_bindless,agc_shader_memory,agc_shader_disk_cache,agc_driver_graphics,agc_driver_key_miss,agc_sparse_run_importand_copiedpass. Inagc_driver_image_tablethe poisoned entries (outside the snapshot, not an image, unmapped surface, sRGB decode, table written by its dispatch) each reach the host as a thrownimage table:fault. Only the per-wave wave32 case is skipped, since RADV's subgroup is 64.agc_driver_tessellation(SIGSEGV), fails the same way onmain84b01f9cdbuilt alone, so it isn't this PR.All four points from my last review are addressed: the ARCHITECTURE.md section, both fold-ins (with their tests in
agc_shader_bindless), the order (#4757 closed, #4883 rebased on) and the final numbers (disk format 32/33, runtime ABI 12). Selected poison entries throw throughBdaResources::CheckFault, so nothing thatmainrefused now returns a plausible value, and every unbound case has a debt line.On @oneandonlydean's memory question: tibzejoker's 4dcf657a2 run shows both caches sitting at their new caps (dispatch cache ~254 MiB, resource cache 1,024 entries, only 20 table T# misses per 10 s). The ~1 GB/min that remains in GTA isn't in the structures this PR adds, and Guardians stays flat at 11.6 GiB. The CPU copies of sampled textures are bounded by the VRAM-derived budget, which is a follow-up that isn't specific to tables. The snapshot cost (Village 4.5 ms, GTA ~11 % of worker 0) is a performance follow-up (SleglJan's snapshot reuse plus the unwritten-range skip), not a correctness issue.
Approving both. #758 goes in after #757. The full Build (Windows) is dispatched on the final heads before the merge.
Imported from boykopovar/AnyPS5. Originally posted by Tamalero on 2026-10-14T19:10:07Z.
@Celegans12, Guardians of the Galaxy (PPSA01748) on
mainbebff8b0e, which has this PR, #758 and #4475 merged. The only local change is one NpManager stub.Better than before. All the menu text now renders, which it didn't on the older heads. The title goes through the language, brightness and adjustments screens, plays its intro video, and starts loading the first level.
It still stops during that load, on a shape I'd separate from the 0x4378/0x4380 one you described:
The key is a
readfirstlaneof an interpolated attribute (a flat per-primitive id). It indexes a constant buffer that holds a pointer. That pointer leads to a second pointer, which leads to the T#. So it's two pointer hops, where #758 covers one. Yesterday's run, on the older heads, stopped on a second pixel shader with exactly the same chain at different pcs (0x3b9421600, pc 0x144 / 0x118 / 0x94). The 0x4378/0x4380 shaders (key from anImageRead) still show up as unplanned at registration but haven't been the stop.On the request: I'd rather not attach it. The serialized request carries the title's shader binary, and I keep game code off public threads. If you open a follow-up for either shape, I can run it on this title the same day and post the result, or paste more of AnyPS5's own planner output from the log.
Details
--to-intelagainst this build; fresh shader cache (format change).s_swappc_b64to a computed target (#4706's territory), and 3 are the 0x4378/0x4380 shape. Plus 11 notices of "unsupported registered shader type 8".Tested and written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-14T23:05:18Z.
@Celegans12, Village numbers for the snapshot-reuse follow-up. Resident Evil Village (PPSA01556) on
maine34c47921, which has this PR, plus the commits Village needs on this PC, on an RTX 3070 Laptop (driver 617.42) under Windows 11. The extra commits are #5703, #5851, #5815, #1186 and #3864, plus local workarounds for shader preparation, sample counts and sample locations.From one run from boot to first control with
APS5_PROFILE_DRAW=1, where the queue-0 worker is 100% busy throughout:[image-table]time per 10 sEach table has 32,768 keys. In a Tracy capture of the title with local zones, the draw stage's capture, which reads each column's records, is 55% of the worker's own time, about 100k words read per capture.
resolveImageTablestakes another 15%, 2.9 ms per draw. Both of those numbers come from profiled runs.Without any profiling (only
APS5_TRACE_SECONDS), a trace of the load into the first 3D scene hasShader.DrawStageat 171 ms of the 332 ms per frame that queue 0's draw packets take.So keeping a column while its words are unchanged, and skipping its read while
tables.rangeshas no write since the last snapshot, would reach a large share of the worker's time in this title.I can test SleglJan's
perf/image-table-snapshot-reuse, or the follow-up PR when it's up, on Village and post the same numbers before and after.