feat(agc): look up table images at run time through a device image table on the GPU heap (APS5_GPU_PATH) #7642

Open
EagleBearerYS wants to merge 175 commits from upstream-pr/7642 into main
EagleBearerYS commented 2026-10-18 19:16:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-18T19:16:54Z.


Stacked on #9508 (Raghav314's GPU descriptor heap on VK_EXT_descriptor_heap), so it merges after #9508. This head merges #9508's fbab1c1619 (in 67420fb18b), which carries main 87448b3c91. #9508's newer 73c5187825 (constant samplers embedded in GPU heap pipelines) isn't merged here yet. The device path is opt-in behind APS5_GPU_PATH=1, on top of #9508's APS5_GPU_HEAP=1; with either unset, nothing changes.

What

Shaders that load a T# from an image table at a key they compute (bindless tables, V#-addressed T# arrays) can only be bound today if the CPU snapshots and resolves every table record for every draw: the CPU table path. With large tables that's most of a draw's cost. On a Village-shaped lavapipe bench (a 32,768-record V# table, 256 textures, 850 indirect draws per frame), the CPU table path spends 14.7–16.5 ms per draw in descriptors alone, and runs out of memory within 30 s. Lavapipe's 256-byte descriptors make that larger than a GPU driver would, so the title measurement under Pending is the number that counts.

With APS5_GPU_HEAP=1 APS5_GPU_PATH=1, such a T# is looked up on the GPU instead.

  • The recompiler emits, for each device-table image read in a GPU-mode stage, a lookup in a device-side hashed key table. The key is the T#'s words, the image interface and the sampler class. A hit gives the image's slot in #9508's GPU descriptor heap (BindlessHeap::TextureSlot), and the shader samples through that slot.
  • A miss or a null T# reads zeros and appends one record per distinct key per batch to the batch's miss ring.
  • After the batch, the driver resolves each missed key with the CPU table path's own checks, takes a heap slot, and inserts the entry before the next batch.
  • First use reads the texels. Before a draw stage or dispatch is recorded, the driver evaluates which T#s its device-table reads will select for its user data (ExpectedDeviceImages) and inserts those keys first. A per-thread memo keeps that at about 4 µs per draw in steady state on the bench.
  • Fallbacks:
    • a program the table can't serve is recompiled with device tables off and takes #9508's CPU-resolved image-table map from then on. That covers a miss-ring overflow in 3 batches in a row, a full table, no heap slot, and an incomplete expectation;
    • a draw outside the recorder (a synchronous draw) uses its programs' CPU table variants for that draw only.
  • Freshness: entries follow the write watch, GPU writes and the texture cache. Entries over host-imported memory, which isn't watched, are proved unchanged by a content compare instead of being looked up again every frame.
  • The table's header is written when the table is created (447b798239). The key table is device-local memory that nothing cleared, and its header reached the GPU only through the first upload, so a GPU-mode program that ran before that batch read whatever the memory held as the bucket mask and probed outside the table. The table is now cleared and its header written in one batch when it's created.
  • #9508's heap: this uses its GPU-mode stages, set-1 heap arrays, BindlessHeap::TextureSlot and its NearlyFull margin as they are. The table takes no slot while NearlyFull holds and reserves none. Each entry holds its texture, and each Prepare marks the live entries' slots used in the heap's epoch (92c6dab397), so #9508's idle-slot eviction doesn't take a slot the table serves. The table drops every key whose SlotGeneration moved, after the last point in Prepare that can submit and before it uploads.
  • The ABI change (bbb446f55d, on its own so it can be reviewed alone): four words just before map[HeaderElementBase] in the heap table map, the bucket buffer's device address and the open batch's miss-ring chunk address. They're all zero when no device table is attached, so maps without a table behave as now. ImageTableAbi::Version goes 2 → 3, and every heap map carries the trailer, which adds 16 bytes per stage map. A column served by the device table writes no per-element slot parts. Raghav314 agreed to the trailer and the version bump (reply).
  • Switches:
    • APS5_GPU_PATH=1 turns it on. Without APS5_GPU_HEAP=1 and a device with VK_EXT_descriptor_heap, it stays off and says why;
    • APS5_NO_DEVICE_IMAGE_EXPECT=1 leaves first uses to the miss ring;
    • counters are in the [device-images] lines under APS5_PROFILE_DRAW=1.

Credit:

  • fable-void: the device image table and the expected images come from his wip/new-gpu-path.
  • Raghav314: this builds on #9508's GPU descriptor heap. The one change to its heap table map is the trailer commit above. He reviewed it (reply): the trailer and version 3, the CPU map as the fallback for programs the device table can't serve, and a per-class sampler specialization constant while the classes stay few.

Pending

  • Pinned slots near a full heap (Raghav314, reply): each entry holds its texture, so a table with many entries can keep #9508's image slots close to full. If a title shows that, the table releases its textures and relies on slot generations alone. Since 92c6dab397 the table also marks its live slots used each heap epoch, so they leave only through the table's own budget eviction, not #9508's idle eviction.
  • Resident Evil Village (PPSA01556)'s title menu on an RTX 3070, with #8926's fix for the title's intro, switches on against off:
    • On 594b34659a (the same commits on #9508's earlier head 1b09774f07), with APS5_GPU_HEAP=1 APS5_GPU_PATH=1 the Vulkan device was lost in 3 of 3 runs before the title menu stood. With neither switch, the menu stood in both runs.
    • On a later diagnostic build, with this PR's commits and its header fix on #9508's 75edb2c8e1 (whose image slots were still per kind) and two heap fixes #9508 has since taken, no run lost the device, but memory grew faster with the switches on. At the static menu, from menu + 1 min to + 10 min, single runs: 594 MB/min with neither switch, 1,022 with APS5_GPU_HEAP=1 alone, and 1,096 with both. So APS5_GPU_PATH adds about 70 MB/min, within run-to-run spread. Both runs with both switches stopped at the 2.5 GB commit floor; the run with APS5_GPU_HEAP=1 alone reached menu + 12 min without stopping. A later run on #9508's 5645b5be5b with two heap counters on top (counts) found the heap's holds flat from 2 minutes after the menu appeared: 1,907 slots, 1,490 textures (667 MiB) and 49 storage images (526 MiB), none held only by the heap. Memory still grew 1,149 MB/min. So the growth comes with APS5_GPU_HEAP=1 but isn't the heap's holds; its cause is pending a comparison of where the memory goes with the heap on and off.
    • The on-side measurements wait on that, and the PR stays in draft. The same split on #9508's current head, whose image slots are one shared pool, is pending.
  • Per-draw cost. On a Village-shaped harness (lavapipe, 320×180) the device path was about 155 µs of driver CPU per draw. The goal is about 80–90 µs. Most of the rest is per-draw capture, specialization and keying for draws whose result is already known.

Limitations

  • Hull, domain and local stages keep the CPU table path.
  • A direct VulkanDevice::Draw outside the driver with device-table results isn't served, so agc_driver_image_table's graphics part fails with the switch on. Only tests and tools draw that way.
  • agc_driver_bindless_images asserts CPU table behaviour, so it fails with the switch on.
  • Mesh stages read device tables, but haven't run on lavapipe, whose LLVM can't compile recompiled NGG mesh modules.
  • Without host imports (Linux without /dev/udmabuf), a draw copies its V# table and rebuilds its resources every draw.

Tested

  • NVIDIA GeForce RTX 3070 Laptop GPU at edc61087bc (driver 617.42, Windows 11, WinLibs GCC 15.2.0, Release, ANYPS5_REQUIRE_VULKAN=1; GPU clocks weren't held, pass/fail only). #9508's heap is live there: every run logs "Vulkan descriptor heap: GPU-mode draws and dispatches bind from VK_EXT_descriptor_heap".

    • agc_driver_device_image_table_heap, which checks that #9508's sweep keeps the slots the table holds, and agc_driver_device_image_path_gpu_path pass 5 runs in a row. agc_driver_device_image_table, agc_driver_device_image_path and agc_driver_device_image_path_without_heap pass 3.
    • At commit 4 alone (827d6d1af6), agc_driver_device_image_table_heap and agc_driver_device_image_table pass 5 runs in a row.
    • An earlier build of commit 4 crashed in the NVIDIA driver at the heap test's teardown: the test kept a graphics context alive past device.reset(), so its buffer pool freed memory on a destroyed device. The test now scopes that context, and the product code is unchanged.
  • Linux (lavapipe, CI's flags), per commit: each of the 8 commits builds, registers with nothing new left unrun, and passes ctest -R 'table_trailer|device_image' 5 runs in a row. lavapipe has no VK_EXT_descriptor_heap, so the two GPU-heap tests skip 77 there with "the device lacks VK_EXT_descriptor_heap…".

  • Eight reds, each with the code under test broken and the named test kept:

    what broken how ctest red message
    trailer layout element base placed before the trailer agc_shader_table_trailer "the element base does not follow the four trailer words"
    trailer layout bucket and ring words swapped agc_shader_table_trailer "the bucket address words are wrong"
    slot invalidation after a sweep generation check off agc_driver_device_image_table "a key whose heap slot was swept leaves the table (0 swept, 5 left)"
    freshness OwnWriteSerial dropped agc_driver_device_image_table "a store the driver made in the same collect epoch refreshes the entry it covers (0 refreshed)"
    freshness unwatched rule off agc_driver_device_image_table "a new collect epoch over unwatched entries whose bytes still match looks none of them up again (64 checked)"
    ring addressing ring address read from the bucket words agc_shader_device_image_tables "the lookup does not read the bucket and ring addresses from the four trailer words before the element base"
    expected images a lane-read key counted complete agc_shader_device_image_tables "the pre-pass called a key read from a lane complete"
    APS5_GPU_PATH refusal ignores APS5_GPU_HEAP agc_driver_device_image_table "the device image path stays off without APS5_GPU_HEAP and says so"
  • CI's Linux job, mirrored, on the head before the teardown fix (66b470c3cf, which differs from this head only in that test): 1,919 of 1,930.

    • 7 of the 11 failures are #9508's own lavapipe failures at its head 23b2a3fc2d: five heap tests that need the extension, and the two agc_driver_image_table_atomics tests.
    • 3 are the machine's IPv6 tests.
    • 1 is agc_driver_pipelined_fill_gpu_heap, a #9508 test none of these commits touch, under the run's load. It passes 10 of 10 alone.
    • The 92 skips are #9508's 90 plus the two GPU-heap tests. check_skips.py flags only guest_sce_net, as on every branch on that machine.
  • agc_driver_pipelined_fill_gpu_heap under load: a #9508 test, run on cloud Linux machines with lavapipe, its ctest environment and 6 concurrent loops, at the rebase 9e843c1a9e on #9508's 5547aa11ef.

    • The failure: it fails now and then, on #9508 alone and with this PR, always with "AGC graphics: a satisfied WAIT_REG_MEM skipped an overlapping queued write".
    • First batches: 8 of 350 runs with this PR against 1 of 350 without. That's 5/100 against 0/100 in separate ctest batches, and 3/250 against 1/250 interleaved.
    • Interleaved, both orders: 7 of 720 against 3 of 720 (Fisher's exact two-sided p = 0.34). On a second machine, 10 of 360 against 9 of 360.
    • With #9697's test fix (9587c4467b, now on main) cherry-picked onto both trees, both pass 360 of 360. So it's a race in the test, which #9697 fixes, and this PR doesn't change its rate.
  • MinGW (x86_64-w64-mingw32-g++-posix, -fsyntax-only -Wall -Wextra) on the 27 changed sources, against the same files at 23b2a3fc2d: no new diagnostics.

  • GitHub's runners at 67c1aea6b8, this PR's 9 commits on #9508's head 5645b5be5b (run):

    • The restack: #9508 moved from b175572c8f to 5645b5be5b, whose image slots are one shared pool. git range-diff against the previous head 4e3a10de4e shows 7 commits unchanged. Commit 1 takes #9508's FormatVersion 49 as its base and keeps #9508's new slot sentence in docs/dev/ARCHITECTURE.md with this PR's trailer line. Commit 4 calls #9508's SlotGeneration(slot), since its slots became one shared pool: in the table's heap slots and in its heap test, three lines.
    • The tests: the five agc_driver_device_image_* tests, agc_device_image_keys and the shader tests built from the changed files, 10 runs in a row. Linux: 24 run, 22 pass, 2 skip (agc_driver_device_image_path_gpu_path and agc_driver_device_image_table_heap, which need VK_EXT_descriptor_heap), 0 fail. Windows: 26 run, 21 pass, 5 skip (the five agc_driver_device_image_* tests; the runner has no Vulkan device), 0 fail.
    • Per commit, 3 runs in a row each: commit 1 (run) on Linux 18 run, 18 pass, and on Windows 20 run, 19 pass, 1 skip (agc_driver_image_table_vouched_lookups). Commit 4 (run) on Linux 21 run, 20 pass, 1 skip, and on Windows 23 run, 20 pass, 3 skip. Commit 6 (run) on Linux 22 run, 21 pass, 1 skip, and on Windows 24 run, 21 pass, 3 skip. None failed. The skips are the GPU-heap test on Linux, and on Windows the Vulkan tests.
    • The suites: libc and libkernel pass on both (143 and 206 tests on Linux, 170 and 222 on Windows), run with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
    • #9508's arm doesn't build with the new tests, which need this PR's code, so there's no before arm.
  • Validation, #9508's 5645b5be5b against 67c1aea6b8 (CONTRIBUTING's AGC rule), on one GitHub Linux runner (run), with VK_LAYER_KHRONOS_validation, ANYPS5_NO_SHADER_CACHE=1, ANYPS5_REQUIRE_VULKAN=1 and ctest -V on llvmpipe: the loader inserted the layer 2 times on #9508's tree and 9 times with this PR, neither log has was not found, and both report only VUID-VkDeviceCreateInfo-pNext-pNext, so this PR adds no VUID- message.

  • GitHub's runners at 594b34659a, this PR's 8 commits rebased onto #9508's head 1b09774f07 (run):

    • The rebase: #9508 moved onto a newer main and gained one commit, 1b09774f07 ("keep GPU heap pipelines in their own journal"). Its other 36 commits carry over: 34 unchanged, and 2 adjusted where main changed the same pipeline-library lines.
    • git range-diff against the previous head 0aaf2b962b: 6 commits unchanged, and 2 whose only changes are context lines from main. Those are a GuestMemory.cpp hunk header, after main split MarkWritten, and an include line in ResourceMaterializer.cpp. Against the rebase the load runs below used (9e843c1a9e, on #9508's 5547aa11ef), all 8 are unchanged.
    • The tests: the five agc_driver_device_image_* tests, agc_device_image_keys and the shader tests built from the changed files pass 10 runs in a row on Linux, with the two GPU-heap tests skipping there. On Windows they build and pass, with 5 Vulkan tests skipping.
    • The suites: libc and libkernel pass on Linux (117, 198). On Windows, libkernel's guest_raise_in_system_call failed in the job's first attempt, and the job's second attempt passed both suites (144, 208). That test also timed out twice on main's own Windows Build today (run, run), and this PR changes nothing in libkernel.
    • The libc and libkernel suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
    • #9508's arm doesn't build with the new tests, which need this PR's code, so there's no before arm.
  • Validation, #9508 against this head (CONTRIBUTING's AGC rule), on one GitHub Linux runner (run):

    • Setup: VK_LAYER_KHRONOS_validation, ANYPS5_NO_SHADER_CACHE=1, ANYPS5_REQUIRE_VULKAN=1 and ctest -V, on llvmpipe.
    • The tests: #9508's tree ran agc_driver_image_table_vouched_lookups and the shader tests it has; this head ran those and this PR's tests.
    • The layer: the loader inserted it 2 times on #9508's tree and 9 times with this PR, and neither log has was not found.
    • The messages: both logs report only VUID-VkDeviceCreateInfo-pNext-pNext, so this PR adds no VUID- message.
  • Earlier heads on GitHub's runners:

    • GitHub's runners at 0aaf2b962b, on #9508's head f85d0b3285 (run). This head is edc61087bc's 8 commits replayed unchanged (git range-diff: all 8 =). The five agc_driver_device_image_* tests and the shader tests built from the changed files pass 10 runs in a row on Linux, with the two GPU-heap tests skipping there. On Windows they build and pass, with the Vulkan tests skipping. The libkernel suite passes on both and libc's on Windows. On Linux libc's one failure is precise_wait, a timing test this PR doesn't touch, which also failed with main's implementation in another run today (run).
    • At edc61087bc, on #9508's earlier head 23b2a3fc2d (run), the same tests passed the same way, with the libc and libkernel suites passing on both.
  • On #6947 (the previous base, up to 05502ba6a5): the CI Linux mirror with the switch unset changed no test's status, ^(agc|shader|recompiler) with it on passed 749 of 751 (the two test limitations above), the device image harness passed in 8 configurations with a red per case, and the fork's full Windows build passed 1,572 tests.

  • Astro's Playroom (PPSA01325), by @fma-rc (comment), on the previous head (05502ba6a5, on #6947), as the no-change check: Linux, RTX 5080 (driver 615.78.08), one run each into the first level, with and without APS5_GPU_PATH=1. No program in that scene read an image table this path serves, the 12 captured frames of each run show the same scenes with no black or missing textures, and one round each within 10% is not a speedup, as they read it.

  • Not tested: the watched-import half of agc_storage_clear_hand_over. On lavapipe it runs the unwatched hand-over, which passes 10 of 10 on #9508 and with this PR, then skips the watched case, since lavapipe's host imports are compared rather than write-watched.

  • check_conventions.py passes at 594b34659a against 1b09774f07, with no comment lines added. It passed at 0aaf2b962b against f85d0b3285, and at 66b470c3cf against 23b2a3fc2d and against main.

  • 88ad9e88d8, a merge of main 2b1ae87c69, which brings milescoviello's #12039 (run).

    • The conflict: two neighbouring size asserts in ShaderDiskCache.cpp. #12039 grows IrValue to 144 bytes, and this PR's IrResourcePlan is 752. Each side changed only its own struct, so the merge keeps both values, and the build compiles both asserts. The merge commit's message says so.
    • The field counts (ShaderInfo 25, ImageResource 47, DeviceImageUse 4) stay this PR's; no struct gained fields from both sides. FormatVersion stays 62. This PR's own diff is unchanged.
    • ×10: the device image key, table and path tests, agc_shader_device_image_tables and every ^agc_driver_bda_ test.
      • Linux: 154 run, 144 pass, 10 skip, 0 fail.
      • Windows: 171 run, 70 pass, 101 skip (no Vulkan device), 0 fail.
      • The libc and libkernel suites run 199 and 307 tests on Linux and 226 and 329 on Windows, with 0 failed. The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
    • On a cloud Linux machine (lavapipe): the tests of the 36 executables built from the changed test files pass 10 of 10, 236 tests, with 31 GPU-heap tests skipped (lavapipe has no VK_EXT_descriptor_heap). ctest -R '^(agc|shader)': 1,246 passed, 0 failed, 98 skipped.
  • 0f3e74aa41: 6407d568ba, a merge of #9508's head dd7120c648, and a heap-slot test fix on top.

    • The merge brings #9508's 28c310dc06 (out-of-range GPU heap address loads keep returning zero), 68c1327a6a (the image table store test skips without the GPU heap), 9263a4bdce (the GPU heap is gated on the descriptor heap extension's revision, not the driver's Vulkan version) and its two merges of main, the last of 6a691f69ee.
      • Three conflicts, each resolved by keeping both sides: docs/dev/ENVIRONMENT.md's rows, now APS5_GPU_HEAP, APS5_GPU_HEAP_EXCLUDE and APS5_GPU_PATH in name order; the WIN32 PATH set_tests_properties list in CMakeLists.txt; and VulkanDevice::Target(), which takes both assignments.
      • ShaderResources.cpp merged on its own and keeps #9508's resolution of #8105, so a build with an HTILE mask clear is never reusable, address-space reuse included.
      • This PR's own changed lines are the same, except the WIN32 PATH line, which now also lists #9508's two tests.
    • 0f3e74aa41 sets APS5_HEAP_SLOT_CAP with APS5_GPU_HEAP in BindlessHeapSlots.cpp, before the test opens its device. With APS5_GPU_PATH=1 the device creates the device image table at open, and that builds the device's heap. BindlessHeap reads the cap once, in its constructor, so the heap kept its full slot count and none of the test's refusals at 1 or 8 slots happened.
      • The red/green ran on an NVIDIA GeForce RTX 3070 Laptop GPU (driver 617.42, Windows 11, WinLibs GCC 15.2.0, Release, ANYPS5_REQUIRE_VULKAN=1; GPU clocks weren't held, pass/fail only). #9508's heap is live there: every run logs "Vulkan descriptor heap: GPU-mode draws and dispatches bind from VK_EXT_descriptor_heap".
      • With APS5_GPU_HEAP=1 APS5_GPU_PATH=1, the six agc_driver_heap_slots* tests fail 6 of 6 with the test file before this commit, for example "bindless heap slot reuse tests failed: one free slot of eight refuses the heap". With it, they pass 3 runs of 3.
      • Without the switches, they pass with and without it.
      • The five agc_driver_device_image_* tests, agc_driver_device_image_table_heap and agc_driver_device_image_path_gpu_path included, pass 3 runs of 3 with the switches and without them.
    • ×10 on GitHub's runners (run): the 38 tests built from this PR's test files (device image keys, table and path, and the shader disk-cache, memory and table tests), and every ^agc_driver_heap_slots and ^agc_driver_image_table test.
      • Linux: 55 run, 46 pass, 9 skip, 0 fail.
      • Windows: 56 run, 33 pass, 23 skip (no Vulkan device), 0 fail.
      • The libc and libkernel suites run 199 and 308 tests on Linux and 226 and 330 on Windows, with 0 failed. The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
    • ^agc|^shader once (run):
      • Linux: 1,275 run, 1,175 pass, 99 skip, 1 fail. agc_driver_pipeline_journal timed out at 120 s, the cold-compile timeout #13858's sweep also hit. Alone ×5 (run) it passes 5 of 5 on Linux: 83.60 s for the first run, and 6.10 to 6.14 s for each after.
      • Windows: 1,310 run, 377 pass, 933 skip (no Vulkan device), 0 fail.
    • Validation: #9508's dd7120c648 against this head, on GitHub's Linux runner (llvmpipe), with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation and the runner's layer 1.3.275 (run). It ran agc_driver_depth_clear_hle twice, with the tests the verify adds for the files this head changes over #9508: 25 tests.
      • They pass on both arms.
      • The loader inserted the layer 3 times on #9508 and 5 times with this head, and neither log has was not found.
      • Both report only VUID-VkDeviceCreateInfo-pNext-pNext, VUID-vkCmdCopyImage-srcImage-01548 and VUID-vkCmdCopyImage-srcImage-01551, so this head adds none.
      • On the RTX 3070 above, agc_driver_depth_clear_hle also passes 30 runs of 30 under layer 1.4.363, with no validation message.
    • On a cloud Linux machine (lavapipe), at 6407d568ba:
      • the 38 tests ×10: 36 pass 10 of 10, and 2 skip (no VK_EXT_descriptor_heap);
      • ^agc_driver_heap_slots|^agc_driver_image_table: 12 pass, 7 skip;
      • ctest -R '^(agc|shader)' without GALLIUM_OVERRIDE_CPU_CAPS=avx: 1,176 passed, 99 skipped, 0 failed.
      • With that override, 20 tests crash with SIGILL or fail on that machine, whose CPU lacks the GFNI instruction llvmpipe emits there. The 17 of them that exist on a tree without this PR or #9508 fail the same way there.
  • 22cead42b2: 525408ab29, a merge of main 5fb1747fa7, then a merge of #9508's 0ab5f157a8.

    • 525408ab29: one conflict, at the end of ShaderResources.cpp, where JJenkx's #13648 adds SampledTexturesCleared() and this PR adds LookupDeviceTableTexture and DeviceTableTextureCurrent. Both are kept, with no other edit.
      • #13648's GPU-cleared textures compose with the device table. A cleared entry's DCC keys make DeviceTableTextureCurrent return false, so the table looks it up again, as it did for every DCC-keyed entry before.
      • A cleared texture's views and layout (SHADER_READ_ONLY_OPTIMAL) are those of an uploaded one.
    • 22cead42b2 takes #9508's aa86660b4c ("free retired depth surfaces that only GPU heap slots sample") and its merge of main, which brings chitters2004's #13667. #9508's own resolution of #13667's new PrebuildStageLibrary argument comes with it unchanged. Clean.
    • This PR's own changed lines are the same, by the sorted +/- lines over #9508 and main.
    • ×10 on GitHub's runners (run): the 38 tests built from this PR's test files, every ^agc_driver_heap_slots and ^agc_driver_image_table test, agc_driver_sampled_clear_keys and agc_driver_depth_clear_hle.
      • Linux: 57 run, 48 pass, 9 skip, 0 fail.
      • Windows: 58 run, 33 pass, 25 skip (no Vulkan device), 0 fail.
      • The libc and libkernel suites run 199 and 308 tests on Linux and 226 and 330 on Windows, with 0 failed. The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
    • Validation: #9508's 0ab5f157a8 against this head, the same tests, on GitHub's Linux runner with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (layer 1.3.275) (run).
      • Both arms report only VUID-VkDeviceCreateInfo-pNext-pNext, VUID-vkCmdCopyImage-srcImage-01548 and VUID-vkCmdCopyImage-srcImage-01551, so this head adds none. The loader inserted the layer 28 times on #9508 and 35 times with this head.
      • On both arms, agc_driver_image_table fails its ctest check for validation messages. Its FAIL_REGULAR_EXPRESSION matches the VUID-VkDeviceCreateInfo-pNext-pNext line that layer 1.3.275 logs for VkPhysicalDeviceMaintenance8FeaturesKHR in the device's feature chain. Both the check and that feature chain are main's.
    • On a cloud Linux machine (lavapipe), at 525408ab29:
      • this PR's 57 tests ×10: 48 pass, 9 skip (no VK_EXT_descriptor_heap, or no uint storage view);
      • agc_driver_sampled_clear_keys passes 10 of 10;
      • ^(agc|shader): 1,278 run, 1,178 pass, 99 skip, 1 fail. The failure is agc_driver_idle_store_yields, from #13621, which failed 14 of 30 runs on main 5fb1747fa7 alone there.
  • 06eba99c50: every field the device image interface's duplicate check compares is in its id, for @mrfelek's Death Stranding 2 (PPSA02015) stop on #10193 (comment): device image interface: two image interfaces share the id.

    • The gap: RegisterDeviceImageInterface compares entries with ImageResource's defaulted operator==, but mixImageInterface didn't mix five of its fields, and deviceInterfaceImage didn't clear them. Two device-table images, or mode lists, that differed only in one of those fields got one id, and the second registration threw.
    • The fix, in ResourceMaterializer.cpp, decides each field by whether the interface depends on it:
      • mixed into the id:
        • dimensionQueryOnly and sampledOnly: inspectImageDescriptor reads both on the stored interface image when DeviceImageTable::lookupKey picks a mode through TryRuntimeImageMode;
        • targetMerge: it changes the modes and the SPIR-V declarations.
      • cleared in the registry's copy:
        • adjustedSample: it only decides which modes RuntimeImageModes adds, and the modes are already part of the id;
        • optionalDescriptor: only the per-draw snapshot reads it, on the program's own copy.
      • The registry exists only for deviceTable images, so nothing else changes.
    • The shader cache needs no format bump. The id is stored in the SPIR-V and in the cached result. But an entry is loaded only when its FormatVersion and SourceVersion() both match (ShaderDiskCache.cpp 1478 and 1491), and its directory and key are named after SourceVersion() (1514, 1950-1951). SourceVersion() is a SHA-256 over the recompiler's sources (ShaderCacheVersion.cmake), ResourceMaterializer.cpp included. So no entry with an old id can be read, and the layout is unchanged.
    • The test: agc_driver_device_image_table's interface case now registers, for each of the five fields, an image that differs from the base only in that field.
      • The three mixed fields get their own id, and the two cleared ones share the base's.
      • A mode that differs only in sampledOnly gets its own id.
      • Red: on 22cead42b2 the case stops at "device image interface: two image interfaces share the id 0xa1ad8eab5dcb3e9d".
    • #9183 (fma-rc) adds ImageResource::volumeGather. Whichever of #9183 and this PR merges second gives it a mixed-or-cleared call, with a test case.
    • ×10 on GitHub's runners, against #9508's 0ab5f157a8 (run): the same set as above.
      • Linux: 57 run, 48 pass, 9 skip, 0 fail.
      • Windows: 58 run, 33 pass, 25 skip (no Vulkan device), 0 fail.
      • The libc and libkernel suites run 199 and 308 tests on Linux and 226 and 330 on Windows, with 0 failed. The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
    • Validation: #9508's 0ab5f157a8 against this head, the same tests, on GitHub's Linux runner (layer 1.3.275) (run).
      • Both arms report only VUID-VkDeviceCreateInfo-pNext-pNext, VUID-vkCmdCopyImage-srcImage-01548 and VUID-vkCmdCopyImage-srcImage-01551, so this head adds none.
      • The loader inserted the layer 28 times on #9508 and 35 times with this head. agc_driver_image_table fails its validation-message check on both arms, as above. The only "was not found" in either log is that check's own regex, echoed in its failure line.
    • On a cloud Linux machine (lavapipe):
      • this PR's 57 tests ×10: 48 pass, 9 skip;
      • ^(agc|shader): 1,279 run, 1,180 pass, 99 skip, 0 fail. A first run had 6 failures: five frame-capture tests stopping on that machine's full disk ("less than 4 GiB free on the capture volume"), and agc_driver_idle_store_yields, main's flaky test. All 6 passed alone, and the rerun after freeing space is the one above.
  • 715097ee91: b5065a1fe9 and 715097ee91, merges of #9508's 31f5d0e8dd and 09cc865e29, which bring Raghav314's commits since 0ab5f157a8 and #9508's merges of main, with #12862's test split.

    • b5065a1fe9 keeps both sides, with two edits for what #9508 changed:
      • the heap retention test no longer calls the heap sweep #9508 removed;
      • DeviceImageTable::HeapSlots passes texture.get() to #9508's TextureSlot(Texture*) (dd83293174). That's the change milescoviello named in their Ghost of Tsushima run on #10193 (below).
      • docs/dev/ARCHITECTURE.md's APS5_GPU_HEAP bullet keeps #9508's sentences and this PR's trailer words.
    • 715097ee91:
      • CMakeLists.txt is resolved with tools/agc_test_split.py resolve, which moves this PR's registrations into tests/cmake/. #9508 already registers the _gpu_heap variants through agc_add_gpu_heap_test().
      • The other conflicts keep both sides:
        • ShaderDiskCache.cpp: #9508's 866bd70c70 drops the second userDataRegisterReads, and this PR's two lists follow imageTableFaults in both directions;
        • Dispatch.cpp and DrawCapture.cpp;
        • ShaderResources.cpp's includes;
        • tests/BindlessHeapSlots.cpp: #9508's helpers, with both settings made before the device opens;
        • the Windows PATH line in agc_shader_memory_tests.cmake.
      • #9508's 0f4b636d04 and 675e23803d rename what this PR's lines call (LoadTableMap, TableHeap(), TableMapAddressed(), context.localDevice, graphicsContext()), so this PR's lines follow.
    • #13774 (BufferSpecializationFields) comes in through #9508's own merge of main, which adds it to the binding-plan key and the snapshot hash. This PR's Recompiler.cpp lines don't touch those functions.
    • The count: with -DBUILD_TESTING=ON, ctest -N gives 3,227 tests: #9508's 3,219 plus this PR's 8, each listed once, with all 22 _gpu_heap variants.
    • The trailer read is reached only through LoadTableMap's TableMapAddressed() branch, never the table-map buffer branch. agc_shader_device_image_tables compiles and validates it. The GPU tests that run it, agc_driver_device_image_table_heap and agc_driver_device_image_path_gpu_path, skip on lavapipe, which has no VK_EXT_descriptor_heap.
    • ×10 (run): this PR's set, with ^agc_driver_heap_slots and ^agc_driver_image_table.
      • Linux: 61 run, 46 pass, 15 skip, 0 fail. The 15 need VK_EXT_descriptor_heap.
      • Windows: 60 run, 32 pass, 28 skip (no Vulkan device), 0 fail.
      • The libc and libkernel suites run 199 and 308 tests on Linux and 226 and 330 on Windows, with 0 failed. The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
    • Validation: main 31034785f8 against this head, the same tests, on GitHub's Linux runner (run).
      • Both arms report only VUID-VkDeviceCreateInfo-pNext-pNext, VUID-vkCmdCopyImage-srcImage-01548 and VUID-vkCmdCopyImage-srcImage-01551, so this head adds none.
      • The loader inserted the layer 11 times on main and 35 times with this head. agc_driver_image_table fails its validation-message check on both arms, as above.
    • On a cloud Linux machine (lavapipe):
      • the full build passes;
      • this PR's set ×10: 60 run, 45 pass, 15 skip, 0 fail;
      • the 366 tests of the files #9508 changed since 31f5d0e8dd, ×10: 328 pass, 38 skip, 0 fail;
      • ^(agc|shader): 1,292 run, 1,121 pass, 171 skip, 0 fail. The skips rise from 104 at b5065a1fe9 because #9508's 09cc865e29 makes its GPU heap variants skip, instead of passing on the per-draw path, when the device has no descriptor heap (95 of the 171).
    • Title runs on #10193, which stacks on this PR. Celegans12's #10193, #13928 and #13929 each depend on the one before. Both runs are of combined stacks with other open PRs and local changes, not of this PR alone:
      • Death Stranding 2: On the Beach (PPSA02015), in mrfelek's run (comment), with APS5_GPU_HEAP=1 APS5_GPU_PATH=1. On the CPU table path it creates ~17,000 sampled textures and spends ~85 ms per draw, until memory runs out. On the GPU path it creates 800 sampled textures, at ~2.8-15 ms per draw, until the interface id stop that 06eba99c50 fixes. With 06eba99c50 merged into the same stack, mrfelek reports the id stop gone in 2 of 2 runs (comment); the next limit there is 20 programs on the CPU table path and host memory.
      • Ghost of Tsushima (PPSA02225, 02.024.000), in milescoviello's run (comment), on #10193's 8403a9b05c with APS5_GPU_HEAP=1 APS5_GPU_PATH=1 APS5_KEEP_UNEXPECTED_DEVICE_IMAGES=1, an RTX 4070 Ti, Linux.
        • With #9533, #9717 and #9742, a local guest-buffer change and APS5_NO_HEAP_DATA_UNIFORM=1, the 20-minute session runs to the end. Its interface id clash at 101 s is the one 06eba99c50 fixes.
        • Its tables stay on the CPU table path (722-810 per 10 s). The run's author guesses sampler tables are why, which this PR leaves for a follow-up, and hasn't confirmed it.
  • 67420fb18b: 7e88d62913 and 67420fb18b, merges of #9508's de1bbf1af3 and fbab1c1619, with 92c6dab397, a fix for the device image table's eviction window, between them.

    • 7e88d62913 brings Raghav314's commits since 09cc865e29 and #9508's merges of main. Among the commits:
      • a6ecdf81e4: heap stages' root and shader data are pushed like vkd3d's root signature;
      • 36caa8b0fe: idle GPU heap image slots are evicted;
      • 097833507b: an evicted slot counts as free only once a submission covers it;
      • de1bbf1af3: a batch is submitted early once it holds half the descriptor ring.
      • The conflicts: 14 files, each resolved by keeping both sides. Two needed a call:
        • RecompileImpl builds the result as a value, sets deviceImagePlan, then makes it shared_ptr<const>;
        • ResourceMaterializer's !deviceTable guard goes on #9508's new fill(...) call.
      • This PR adds no uses of the API #9508's root items replace, so its own lines needed no port.
    • 92c6dab397, fix(agc): keep device image table slots from retiring while a batch still reads them.
      • The window: with #9508's eviction, DeviceImageTable::Prepare swept its keys (retainSlots) and uploaded, then took a miss-ring chunk with chunkFor(recorder, true), which can Sync and submit.
        • At that submission the heap could evict a live table slot under that batch's serial.
        • Once that batch completed, the slot could be reused and rewritten while the next batch still read the key through it.
        • The table never touched its slots after inserting them, so the heap saw them as idle.
      • The fix, in two parts:
        • Prepare now sweeps again and uploads once, after chunkFor, so nothing that can submit sits between the last sweep and the upload. That also covers a flush inside resolve's texture lookup. Expect never uploads, so it needs no change.
        • A new Slots::touch member, mapped to BindlessHeap::TouchSlots, marks every live entry's slot used once per heap epoch. #9508's evictLocked takes only slots with use + 2 <= epoch, so it no longer takes one the table serves.
      • Tests, in the same commit and run by agc_driver_device_image_table:
        • SweptWhileWaitingForAChunk holds all 16 miss-ring chunks and moves a live key's slot inside chunkFor's wait. On the merge without the fix it fails with "a prepare serves no key whose heap slot moved while it waited for a miss-ring chunk (slot 2, 0 swept)", and with the fix it passes.
        • LiveSlotsTouched checks the touch once per epoch.
    • 67420fb18b merges fbab1c1619, Dean's merge of main 87448b3c91 into #9508. Three conflicts, each resolved by keeping both sides:
      • tests/ShaderMemory.cpp: the --device-image-tables and --table-trailer dispatch, then main's --registered-view-churn;
      • IrMetadata/Resources.hpp: NoSampler and DeviceImageUse, then main's AppliesLodBiasInShader;
      • PipelineSpecialization.hpp: main's SamplerLodBiasBase 57728 and SamplerLodBiasShaderThreshold, then DeviceSamplerClassBase 58368.
    • What stays the same:
      • This PR's own changes over #9508 match line for line: git diff de1bbf1af3 92c6dab397 and git diff fbab1c1619 67420fb18b both give 59 files, +4,252/-30.
      • FormatVersion stays 62.
      • The 3rdparty/SDL2 move and the new 3rdparty/sqlite are main's, through #9508.
    • Spec IDs:
      • On main, the bases from 57344 to 57791 are contiguous. The device sampler classes take 58368 to 58431, after 576 unused IDs.
      • The class index is at most 63, because info.samplers stops at ShaderInfo::MaxSamplers (ResourceTracker.cpp:2461-2464).
      • #10489 moves the FMASK format and volume gather bases to 58048 and 58176. Its last range ends at 58303, so the two PRs don't overlap either.
    • LOD bias: a device-path sampler is always a direct sampler, because a device-table image read through a sampler table fails to compile (SpirvImageEmitter.cpp:2371).
      • It takes main's shader-side bias (AppliesLodBiasInShader, SamplerLodBiasBase plus the sampler index).
      • Its host sampler's bias is 0 past the threshold, as for a direct image.
    • ×10 (run): this PR's set, with ^agc_shader_memory, ^agc_shader_registered_view_churn, ^agc_driver_image_sample_lod_bias, ^agc_shader_sampler_limits and ^agc_shader_disk_cache.
      • Linux: 35 run, 20 pass, 15 skip, 0 fail. The 15 need VK_EXT_descriptor_heap. agc_driver_device_image_table passes 10 of 10.
      • Windows: 37 run, 12 pass, 25 skip (no Vulkan device), 0 fail.
      • The libc and libkernel suites run 323 and 338 tests on Linux and 354 and 365 on Windows, with 0 failed. The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
    • Validation: main 87448b3c91 against this head, the same tests, on GitHub's Linux runner (run).
      • main's arm ran 15 tests and this head's arm 36, all passing, with 15 skipped on this head.
      • Both arms report only VUID-VkDeviceCreateInfo-pNext-pNext, so this head adds none.
      • The loader inserted the layer 7 times on main and 27 times with this head, and neither log has was not found.
      • Windows: no before/after comparison (the runner has no Vulkan device, and the harness's before-build didn't complete). This PR's own build passed 38 tests, with 25 skipped.
    • On a cloud Linux machine (lavapipe):
      • At 92c6dab397:
        • this PR's set ×10: 28 tests, 13 pass, 15 skip, 0 fail;
        • the 109 tests that #9508's commits since 09cc865e29 change, ×10: 83 pass, 26 skip, 0 fail;
        • ^(agc|shader): 1,482 run, 1,289 pass, 193 skip, 0 fail.
      • At 67420fb18b:
        • this PR's set ×10: 13 pass, 15 skip, 0 fail;
        • the merge's 33 touched tests ×10: all pass;
        • ^(agc|shader): 1,494 run, 1,301 pass, 193 skip, 0 fail. 106 of the skips need VK_EXT_descriptor_heap.
    • Not tested: the fix on a device with the heap extension. agc_driver_device_image_table_heap and agc_driver_device_image_path_gpu_path need VK_EXT_descriptor_heap, which lavapipe and GitHub's runners lack, and the RTX 3070 above wasn't rerun at this head.

Checklist

  • Based on current main through #9508 (Raghav314, fbab1c1619, which this head merges); #9508's image tables are CPU-resolved into heap slots, and fable-void's branch is not an open PR. #7223, #7395 and #7550 extend the CPU table path in the same recompiler files (ResourceMaterializer.cpp, ResourceTracker.cpp); they compose with this. No other open PR implements these functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: #9508 (Raghav314); #10807 (milescoviello) and #10359 (valenciana-nc) go before this PR (merge order only; their overlaps are with #9508's lines this PR is stacked on); #10507 (orezraey) goes after this PR (merge order only, on #10507)
  • Unblocks: PPSA01556 #5169 (per-draw binding cost at Resident Evil Village's title menu; not measured yet, see Pending)
  • GPUs tested: NVIDIA GeForce RTX 3070 Laptop GPU (driver 617.42), Windows 11; lavapipe (Mesa 25.2.8, LLVM 20.1.2), Ubuntu 24.04; GitHub's Windows runner (no Vulkan device); NVIDIA GeForce RTX 5080 (615.78.08), Linux, in fma-rc's run on the previous head; NVIDIA GeForce RTX 4070 Ti (615.71.09), Linux, in milescoviello's Ghost of Tsushima run on #10193, which stacks on this PR
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4912049639 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7642). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-18T19:16:54Z. --- > Stacked on #9508 (Raghav314's GPU descriptor heap on `VK_EXT_descriptor_heap`), so it merges after #9508. This head merges #9508's fbab1c1619 (in 67420fb18b), which carries `main` 87448b3c91. #9508's newer 73c5187825 (constant samplers embedded in GPU heap pipelines) isn't merged here yet. The device path is opt-in behind `APS5_GPU_PATH=1`, on top of #9508's `APS5_GPU_HEAP=1`; with either unset, nothing changes. ### What Shaders that load a T# from an image table at a key they compute (bindless tables, V#-addressed T# arrays) can only be bound today if the CPU snapshots and resolves every table record for every draw: the CPU table path. With large tables that's most of a draw's cost. On a Village-shaped lavapipe bench (a 32,768-record V# table, 256 textures, 850 indirect draws per frame), the CPU table path spends 14.7–16.5 ms per draw in `descriptors` alone, and runs out of memory within 30 s. Lavapipe's 256-byte descriptors make that larger than a GPU driver would, so the title measurement under Pending is the number that counts. With `APS5_GPU_HEAP=1 APS5_GPU_PATH=1`, such a T# is looked up on the GPU instead. - **The recompiler** emits, for each device-table image read in a GPU-mode stage, a lookup in a device-side hashed key table. The key is the T#'s words, the image interface and the sampler class. A hit gives the image's slot in #9508's GPU descriptor heap (`BindlessHeap::TextureSlot`), and the shader samples through that slot. - **A miss or a null T# reads zeros** and appends one record per distinct key per batch to the batch's miss ring. - **After the batch,** the driver resolves each missed key with the CPU table path's own checks, takes a heap slot, and inserts the entry before the next batch. - **First use reads the texels.** Before a draw stage or dispatch is recorded, the driver evaluates which T#s its device-table reads will select for its user data (`ExpectedDeviceImages`) and inserts those keys first. A per-thread memo keeps that at about 4 µs per draw in steady state on the bench. - **Fallbacks:** - a program the table can't serve is recompiled with device tables off and takes #9508's CPU-resolved image-table map from then on. That covers a miss-ring overflow in 3 batches in a row, a full table, no heap slot, and an incomplete expectation; - a draw outside the recorder (a synchronous draw) uses its programs' CPU table variants for that draw only. - **Freshness:** entries follow the write watch, GPU writes and the texture cache. Entries over host-imported memory, which isn't watched, are proved unchanged by a content compare instead of being looked up again every frame. - **The table's header is written when the table is created** ([447b798239](https://github.com/EagleBearerYS/AnyPS5/commit/447b798239)). The key table is device-local memory that nothing cleared, and its header reached the GPU only through the first upload, so a GPU-mode program that ran before that batch read whatever the memory held as the bucket mask and probed outside the table. The table is now cleared and its header written in one batch when it's created. - **#9508's heap:** this uses its GPU-mode stages, set-1 heap arrays, `BindlessHeap::TextureSlot` and its `NearlyFull` margin as they are. The table takes no slot while `NearlyFull` holds and reserves none. Each entry holds its texture, and each `Prepare` marks the live entries' slots used in the heap's epoch ([92c6dab397](https://github.com/EagleBearerYS/AnyPS5/commit/92c6dab397)), so #9508's idle-slot eviction doesn't take a slot the table serves. The table drops every key whose `SlotGeneration` moved, after the last point in `Prepare` that can submit and before it uploads. - **The ABI change** ([bbb446f55d](https://github.com/EagleBearerYS/AnyPS5/commit/bbb446f55d), on its own so it can be reviewed alone): four words just before `map[HeaderElementBase]` in the heap table map, the bucket buffer's device address and the open batch's miss-ring chunk address. They're all zero when no device table is attached, so maps without a table behave as now. `ImageTableAbi::Version` goes 2 → 3, and every heap map carries the trailer, which adds 16 bytes per stage map. A column served by the device table writes no per-element slot parts. Raghav314 agreed to the trailer and the version bump ([reply](https://github.com/boykopovar/AnyPS5/pull/9508#issuecomment-6339210878)). - **Switches:** - `APS5_GPU_PATH=1` turns it on. Without `APS5_GPU_HEAP=1` and a device with `VK_EXT_descriptor_heap`, it stays off and says why; - `APS5_NO_DEVICE_IMAGE_EXPECT=1` leaves first uses to the miss ring; - counters are in the `[device-images]` lines under `APS5_PROFILE_DRAW=1`. **Credit:** - **fable-void:** the device image table and the expected images come from his `wip/new-gpu-path`. - His key table commit (d48d173c93) is here under his authorship. - The commits that adapt his work (3aa9bc59c2, bdea78a4d9, 85b3d403d9, aef54d98b3 and 8cf949d971) name his commits in their bodies. - **Raghav314:** this builds on #9508's GPU descriptor heap. The one change to its heap table map is the trailer commit above. He reviewed it ([reply](https://github.com/boykopovar/AnyPS5/pull/9508#issuecomment-6339210878)): the trailer and version 3, the CPU map as the fallback for programs the device table can't serve, and a per-class sampler specialization constant while the classes stay few. ### Pending - **Pinned slots near a full heap** (Raghav314, [reply](https://github.com/boykopovar/AnyPS5/pull/9508#issuecomment-6339210878)): each entry holds its texture, so a table with many entries can keep #9508's image slots close to full. If a title shows that, the table releases its textures and relies on slot generations alone. Since 92c6dab397 the table also marks its live slots used each heap epoch, so they leave only through the table's own budget eviction, not #9508's idle eviction. - **Resident Evil Village (PPSA01556)'s title menu** on an RTX 3070, with #8926's fix for the title's intro, switches on against off: - **On 594b34659a** (the same commits on #9508's earlier head 1b09774f07), with `APS5_GPU_HEAP=1 APS5_GPU_PATH=1` the Vulkan device was lost in 3 of 3 runs before the title menu stood. With neither switch, the menu stood in both runs. - **On a later diagnostic build**, with this PR's commits and its header fix on #9508's 75edb2c8e1 (whose image slots were still per kind) and two heap fixes #9508 has since taken, no run lost the device, but memory grew faster with the switches on. At the static menu, from menu + 1 min to + 10 min, single runs: 594 MB/min with neither switch, 1,022 with `APS5_GPU_HEAP=1` alone, and 1,096 with both. So `APS5_GPU_PATH` adds about 70 MB/min, within run-to-run spread. Both runs with both switches stopped at the 2.5 GB commit floor; the run with `APS5_GPU_HEAP=1` alone reached menu + 12 min without stopping. A later run on #9508's 5645b5be5b with two heap counters on top ([counts](https://github.com/boykopovar/AnyPS5/pull/9508#issuecomment-6392294482)) found the heap's holds flat from 2 minutes after the menu appeared: 1,907 slots, 1,490 textures (667 MiB) and 49 storage images (526 MiB), none held only by the heap. Memory still grew 1,149 MB/min. So the growth comes with `APS5_GPU_HEAP=1` but isn't the heap's holds; its cause is pending a comparison of where the memory goes with the heap on and off. - The on-side measurements wait on that, and the PR stays in draft. The same split on #9508's current head, whose image slots are one shared pool, is pending. - **Per-draw cost.** On a Village-shaped harness (lavapipe, 320×180) the device path was about 155 µs of driver CPU per draw. The goal is about 80–90 µs. Most of the rest is per-draw capture, specialization and keying for draws whose result is already known. ### Limitations - Hull, domain and local stages keep the CPU table path. - A direct `VulkanDevice::Draw` outside the driver with device-table results isn't served, so `agc_driver_image_table`'s graphics part fails with the switch on. Only tests and tools draw that way. - `agc_driver_bindless_images` asserts CPU table behaviour, so it fails with the switch on. - Mesh stages read device tables, but haven't run on lavapipe, whose LLVM can't compile recompiled NGG mesh modules. - Without host imports (Linux without `/dev/udmabuf`), a draw copies its V# table and rebuilds its resources every draw. ### Tested - **NVIDIA GeForce RTX 3070 Laptop GPU** at edc61087bc (driver 617.42, Windows 11, WinLibs GCC 15.2.0, Release, `ANYPS5_REQUIRE_VULKAN=1`; GPU clocks weren't held, pass/fail only). #9508's heap is live there: every run logs "Vulkan descriptor heap: GPU-mode draws and dispatches bind from VK_EXT_descriptor_heap". - `agc_driver_device_image_table_heap`, which checks that #9508's sweep keeps the slots the table holds, and `agc_driver_device_image_path_gpu_path` pass 5 runs in a row. `agc_driver_device_image_table`, `agc_driver_device_image_path` and `agc_driver_device_image_path_without_heap` pass 3. - At commit 4 alone (827d6d1af6), `agc_driver_device_image_table_heap` and `agc_driver_device_image_table` pass 5 runs in a row. - An earlier build of commit 4 crashed in the NVIDIA driver at the heap test's teardown: the test kept a graphics context alive past `device.reset()`, so its buffer pool freed memory on a destroyed device. The test now scopes that context, and the product code is unchanged. - **Linux (lavapipe, CI's flags), per commit:** each of the 8 commits builds, registers with nothing new left unrun, and passes `ctest -R 'table_trailer|device_image'` 5 runs in a row. lavapipe has no `VK_EXT_descriptor_heap`, so the two GPU-heap tests skip 77 there with "the device lacks VK_EXT_descriptor_heap…". - **Eight reds,** each with the code under test broken and the named test kept: | what | broken how | ctest | red message | | - | - | - | - | | trailer layout | element base placed before the trailer | `agc_shader_table_trailer` | "the element base does not follow the four trailer words" | | trailer layout | bucket and ring words swapped | `agc_shader_table_trailer` | "the bucket address words are wrong" | | slot invalidation after a sweep | generation check off | `agc_driver_device_image_table` | "a key whose heap slot was swept leaves the table (0 swept, 5 left)" | | freshness | `OwnWriteSerial` dropped | `agc_driver_device_image_table` | "a store the driver made in the same collect epoch refreshes the entry it covers (0 refreshed)" | | freshness | unwatched rule off | `agc_driver_device_image_table` | "a new collect epoch over unwatched entries whose bytes still match looks none of them up again (64 checked)" | | ring addressing | ring address read from the bucket words | `agc_shader_device_image_tables` | "the lookup does not read the bucket and ring addresses from the four trailer words before the element base" | | expected images | a lane-read key counted complete | `agc_shader_device_image_tables` | "the pre-pass called a key read from a lane complete" | | `APS5_GPU_PATH` | refusal ignores `APS5_GPU_HEAP` | `agc_driver_device_image_table` | "the device image path stays off without APS5_GPU_HEAP and says so" | - **CI's Linux job, mirrored,** on the head before the teardown fix (66b470c3cf, which differs from this head only in that test): 1,919 of 1,930. - 7 of the 11 failures are #9508's own lavapipe failures at its head 23b2a3fc2d: five heap tests that need the extension, and the two `agc_driver_image_table_atomics` tests. - 3 are the machine's IPv6 tests. - 1 is `agc_driver_pipelined_fill_gpu_heap`, a #9508 test none of these commits touch, under the run's load. It passes 10 of 10 alone. - The 92 skips are #9508's 90 plus the two GPU-heap tests. `check_skips.py` flags only `guest_sce_net`, as on every branch on that machine. - **`agc_driver_pipelined_fill_gpu_heap` under load:** a #9508 test, run on cloud Linux machines with lavapipe, its ctest environment and 6 concurrent loops, at the rebase 9e843c1a9e on #9508's 5547aa11ef. - **The failure:** it fails now and then, on #9508 alone and with this PR, always with "AGC graphics: a satisfied WAIT_REG_MEM skipped an overlapping queued write". - **First batches:** 8 of 350 runs with this PR against 1 of 350 without. That's 5/100 against 0/100 in separate ctest batches, and 3/250 against 1/250 interleaved. - **Interleaved, both orders:** 7 of 720 against 3 of 720 (Fisher's exact two-sided p = 0.34). On a second machine, 10 of 360 against 9 of 360. - **With #9697's test fix** (9587c4467b, now on `main`) cherry-picked onto both trees, both pass 360 of 360. So it's a race in the test, which #9697 fixes, and this PR doesn't change its rate. - **MinGW** (`x86_64-w64-mingw32-g++-posix`, `-fsyntax-only -Wall -Wextra`) on the 27 changed sources, against the same files at 23b2a3fc2d: no new diagnostics. - **GitHub's runners** at 67c1aea6b8, this PR's 9 commits on #9508's head 5645b5be5b ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40146603361)): - **The restack:** #9508 moved from b175572c8f to 5645b5be5b, whose image slots are one shared pool. `git range-diff` against the previous head 4e3a10de4e shows 7 commits unchanged. Commit 1 takes #9508's `FormatVersion` 49 as its base and keeps #9508's new slot sentence in `docs/dev/ARCHITECTURE.md` with this PR's trailer line. Commit 4 calls #9508's `SlotGeneration(slot)`, since its slots became one shared pool: in the table's heap slots and in its heap test, three lines. - **The tests:** the five `agc_driver_device_image_*` tests, `agc_device_image_keys` and the shader tests built from the changed files, 10 runs in a row. Linux: 24 run, 22 pass, 2 skip (`agc_driver_device_image_path_gpu_path` and `agc_driver_device_image_table_heap`, which need `VK_EXT_descriptor_heap`), 0 fail. Windows: 26 run, 21 pass, 5 skip (the five `agc_driver_device_image_*` tests; the runner has no Vulkan device), 0 fail. - **Per commit,** 3 runs in a row each: commit 1 ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40141549943)) on Linux 18 run, 18 pass, and on Windows 20 run, 19 pass, 1 skip (`agc_driver_image_table_vouched_lookups`). Commit 4 ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40146711382)) on Linux 21 run, 20 pass, 1 skip, and on Windows 23 run, 20 pass, 3 skip. Commit 6 ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40146782488)) on Linux 22 run, 21 pass, 1 skip, and on Windows 24 run, 21 pass, 3 skip. None failed. The skips are the GPU-heap test on Linux, and on Windows the Vulkan tests. - **The suites:** libc and libkernel pass on both (143 and 206 tests on Linux, 170 and 222 on Windows), run with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - #9508's arm doesn't build with the new tests, which need this PR's code, so there's no before arm. - **Validation, #9508's 5645b5be5b against 67c1aea6b8** (CONTRIBUTING's AGC rule), on one GitHub Linux runner ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40146651257)), with `VK_LAYER_KHRONOS_validation`, `ANYPS5_NO_SHADER_CACHE=1`, `ANYPS5_REQUIRE_VULKAN=1` and `ctest -V` on llvmpipe: the loader inserted the layer 2 times on #9508's tree and 9 times with this PR, neither log has `was not found`, and both report only `VUID-VkDeviceCreateInfo-pNext-pNext`, so this PR adds no `VUID-` message. - **GitHub's runners** at 594b34659a, this PR's 8 commits rebased onto #9508's head 1b09774f07 ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39873871057)): - **The rebase:** #9508 moved onto a newer `main` and gained one commit, 1b09774f07 ("keep GPU heap pipelines in their own journal"). Its other 36 commits carry over: 34 unchanged, and 2 adjusted where `main` changed the same pipeline-library lines. - **`git range-diff` against the previous head 0aaf2b962b:** 6 commits unchanged, and 2 whose only changes are context lines from `main`. Those are a `GuestMemory.cpp` hunk header, after `main` split `MarkWritten`, and an include line in `ResourceMaterializer.cpp`. Against the rebase the load runs below used (9e843c1a9e, on #9508's 5547aa11ef), all 8 are unchanged. - **The tests:** the five `agc_driver_device_image_*` tests, `agc_device_image_keys` and the shader tests built from the changed files pass 10 runs in a row on Linux, with the two GPU-heap tests skipping there. On Windows they build and pass, with 5 Vulkan tests skipping. - **The suites:** libc and libkernel pass on Linux (117, 198). On Windows, libkernel's `guest_raise_in_system_call` failed in the job's first attempt, and the job's second attempt passed both suites (144, 208). That test also timed out twice on `main`'s own Windows Build today ([run](https://github.com/boykopovar/AnyPS5/actions/runs/39859731775), [run](https://github.com/boykopovar/AnyPS5/actions/runs/39861406807)), and this PR changes nothing in libkernel. - The libc and libkernel suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - #9508's arm doesn't build with the new tests, which need this PR's code, so there's no before arm. - **Validation, #9508 against this head** (CONTRIBUTING's AGC rule), on one GitHub Linux runner ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39873911284)): - **Setup:** `VK_LAYER_KHRONOS_validation`, `ANYPS5_NO_SHADER_CACHE=1`, `ANYPS5_REQUIRE_VULKAN=1` and `ctest -V`, on llvmpipe. - **The tests:** #9508's tree ran `agc_driver_image_table_vouched_lookups` and the shader tests it has; this head ran those and this PR's tests. - **The layer:** the loader inserted it 2 times on #9508's tree and 9 times with this PR, and neither log has `was not found`. - **The messages:** both logs report only `VUID-VkDeviceCreateInfo-pNext-pNext`, so this PR adds no `VUID-` message. - **Earlier heads on GitHub's runners:** - **GitHub's runners** at 0aaf2b962b, on #9508's head f85d0b3285 ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39769111591)). This head is edc61087bc's 8 commits replayed unchanged (`git range-diff`: all 8 `=`). The five `agc_driver_device_image_*` tests and the shader tests built from the changed files pass 10 runs in a row on Linux, with the two GPU-heap tests skipping there. On Windows they build and pass, with the Vulkan tests skipping. The libkernel suite passes on both and libc's on Windows. On Linux libc's one failure is `precise_wait`, a timing test this PR doesn't touch, which also failed with `main`'s implementation in another run today ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39760376179)). - At edc61087bc, on #9508's earlier head 23b2a3fc2d ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39749273577)), the same tests passed the same way, with the libc and libkernel suites passing on both. - **On #6947** (the previous base, up to 05502ba6a5): the CI Linux mirror with the switch unset changed no test's status, `^(agc|shader|recompiler)` with it on passed 749 of 751 (the two test limitations above), the device image harness passed in 8 configurations with a red per case, and the fork's full Windows build passed 1,572 tests. - **Astro's Playroom (PPSA01325), by @fma-rc** ([comment](https://github.com/boykopovar/AnyPS5/pull/7642#issuecomment-6269227272)), on the previous head (05502ba6a5, on #6947), as the no-change check: Linux, RTX 5080 (driver 615.78.08), one run each into the first level, with and without `APS5_GPU_PATH=1`. No program in that scene read an image table this path serves, the 12 captured frames of each run show the same scenes with no black or missing textures, and one round each within 10% is not a speedup, as they read it. - **Not tested:** the watched-import half of `agc_storage_clear_hand_over`. On lavapipe it runs the unwatched hand-over, which passes 10 of 10 on #9508 and with this PR, then skips the watched case, since lavapipe's host imports are compared rather than write-watched. - `check_conventions.py` passes at 594b34659a against 1b09774f07, with no comment lines added. It passed at 0aaf2b962b against f85d0b3285, and at 66b470c3cf against 23b2a3fc2d and against `main`. - **88ad9e88d8, a merge of `main` 2b1ae87c69**, which brings milescoviello's #12039 ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/41121705785)). - **The conflict:** two neighbouring size asserts in `ShaderDiskCache.cpp`. #12039 grows `IrValue` to 144 bytes, and this PR's `IrResourcePlan` is 752. Each side changed only its own struct, so the merge keeps both values, and the build compiles both asserts. The merge commit's message says so. - **The field counts** (`ShaderInfo` 25, `ImageResource` 47, `DeviceImageUse` 4) stay this PR's; no struct gained fields from both sides. `FormatVersion` stays 62. This PR's own diff is unchanged. - **×10:** the device image key, table and path tests, `agc_shader_device_image_tables` and every `^agc_driver_bda_` test. - Linux: 154 run, 144 pass, 10 skip, 0 fail. - Windows: 171 run, 70 pass, 101 skip (no Vulkan device), 0 fail. - The libc and libkernel suites run 199 and 307 tests on Linux and 226 and 329 on Windows, with 0 failed. The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **On a cloud Linux machine (lavapipe):** the tests of the 36 executables built from the changed test files pass 10 of 10, 236 tests, with 31 GPU-heap tests skipped (lavapipe has no `VK_EXT_descriptor_heap`). `ctest -R '^(agc|shader)'`: 1,246 passed, 0 failed, 98 skipped. - **0f3e74aa41: 6407d568ba, a merge of #9508's head dd7120c648, and a heap-slot test fix on top.** - **The merge** brings #9508's 28c310dc06 (out-of-range GPU heap address loads keep returning zero), 68c1327a6a (the image table store test skips without the GPU heap), 9263a4bdce (the GPU heap is gated on the descriptor heap extension's revision, not the driver's Vulkan version) and its two merges of `main`, the last of 6a691f69ee. - Three conflicts, each resolved by keeping both sides: `docs/dev/ENVIRONMENT.md`'s rows, now `APS5_GPU_HEAP`, `APS5_GPU_HEAP_EXCLUDE` and `APS5_GPU_PATH` in name order; the WIN32 PATH `set_tests_properties` list in `CMakeLists.txt`; and `VulkanDevice::Target()`, which takes both assignments. - `ShaderResources.cpp` merged on its own and keeps #9508's resolution of #8105, so a build with an HTILE mask clear is never reusable, address-space reuse included. - This PR's own changed lines are the same, except the WIN32 PATH line, which now also lists #9508's two tests. - **0f3e74aa41** sets `APS5_HEAP_SLOT_CAP` with `APS5_GPU_HEAP` in `BindlessHeapSlots.cpp`, before the test opens its device. With `APS5_GPU_PATH=1` the device creates the device image table at open, and that builds the device's heap. `BindlessHeap` reads the cap once, in its constructor, so the heap kept its full slot count and none of the test's refusals at 1 or 8 slots happened. - **The red/green** ran on an NVIDIA GeForce RTX 3070 Laptop GPU (driver 617.42, Windows 11, WinLibs GCC 15.2.0, Release, `ANYPS5_REQUIRE_VULKAN=1`; GPU clocks weren't held, pass/fail only). #9508's heap is live there: every run logs "Vulkan descriptor heap: GPU-mode draws and dispatches bind from VK_EXT_descriptor_heap". - **With `APS5_GPU_HEAP=1 APS5_GPU_PATH=1`,** the six `agc_driver_heap_slots*` tests fail 6 of 6 with the test file before this commit, for example "bindless heap slot reuse tests failed: one free slot of eight refuses the heap". With it, they pass 3 runs of 3. - **Without the switches,** they pass with and without it. - **The five `agc_driver_device_image_*` tests,** `agc_driver_device_image_table_heap` and `agc_driver_device_image_path_gpu_path` included, pass 3 runs of 3 with the switches and without them. - **×10 on GitHub's runners** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/41191330423)): the 38 tests built from this PR's test files (device image keys, table and path, and the shader disk-cache, memory and table tests), and every `^agc_driver_heap_slots` and `^agc_driver_image_table` test. - Linux: 55 run, 46 pass, 9 skip, 0 fail. - Windows: 56 run, 33 pass, 23 skip (no Vulkan device), 0 fail. - The libc and libkernel suites run 199 and 308 tests on Linux and 226 and 330 on Windows, with 0 failed. The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **`^agc|^shader` once** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/41191338651)): - Linux: 1,275 run, 1,175 pass, 99 skip, 1 fail. `agc_driver_pipeline_journal` timed out at 120 s, the cold-compile timeout #13858's sweep also hit. Alone ×5 ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/41197275470)) it passes 5 of 5 on Linux: 83.60 s for the first run, and 6.10 to 6.14 s for each after. - Windows: 1,310 run, 377 pass, 933 skip (no Vulkan device), 0 fail. - **Validation:** #9508's dd7120c648 against this head, on GitHub's Linux runner (llvmpipe), with `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` and the runner's layer 1.3.275 ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/41195295365)). It ran `agc_driver_depth_clear_hle` twice, with the tests the verify adds for the files this head changes over #9508: 25 tests. - They pass on both arms. - The loader inserted the layer 3 times on #9508 and 5 times with this head, and neither log has `was not found`. - Both report only `VUID-VkDeviceCreateInfo-pNext-pNext`, `VUID-vkCmdCopyImage-srcImage-01548` and `VUID-vkCmdCopyImage-srcImage-01551`, so this head adds none. - On the RTX 3070 above, `agc_driver_depth_clear_hle` also passes 30 runs of 30 under layer 1.4.363, with no validation message. - **On a cloud Linux machine (lavapipe),** at 6407d568ba: - the 38 tests ×10: 36 pass 10 of 10, and 2 skip (no `VK_EXT_descriptor_heap`); - `^agc_driver_heap_slots|^agc_driver_image_table`: 12 pass, 7 skip; - `ctest -R '^(agc|shader)'` without `GALLIUM_OVERRIDE_CPU_CAPS=avx`: 1,176 passed, 99 skipped, 0 failed. - With that override, 20 tests crash with SIGILL or fail on that machine, whose CPU lacks the GFNI instruction llvmpipe emits there. The 17 of them that exist on a tree without this PR or #9508 fail the same way there. - **22cead42b2: 525408ab29, a merge of `main` 5fb1747fa7, then a merge of #9508's 0ab5f157a8.** - **525408ab29:** one conflict, at the end of `ShaderResources.cpp`, where JJenkx's #13648 adds `SampledTexturesCleared()` and this PR adds `LookupDeviceTableTexture` and `DeviceTableTextureCurrent`. Both are kept, with no other edit. - #13648's GPU-cleared textures compose with the device table. A cleared entry's DCC keys make `DeviceTableTextureCurrent` return false, so the table looks it up again, as it did for every DCC-keyed entry before. - A cleared texture's views and layout (`SHADER_READ_ONLY_OPTIMAL`) are those of an uploaded one. - **22cead42b2** takes #9508's aa86660b4c ("free retired depth surfaces that only GPU heap slots sample") and its merge of `main`, which brings chitters2004's #13667. #9508's own resolution of #13667's new `PrebuildStageLibrary` argument comes with it unchanged. Clean. - This PR's own changed lines are the same, by the sorted `+`/`-` lines over #9508 and `main`. - **×10 on GitHub's runners** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/41201719018)): the 38 tests built from this PR's test files, every `^agc_driver_heap_slots` and `^agc_driver_image_table` test, `agc_driver_sampled_clear_keys` and `agc_driver_depth_clear_hle`. - Linux: 57 run, 48 pass, 9 skip, 0 fail. - Windows: 58 run, 33 pass, 25 skip (no Vulkan device), 0 fail. - The libc and libkernel suites run 199 and 308 tests on Linux and 226 and 330 on Windows, with 0 failed. The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **Validation:** #9508's 0ab5f157a8 against this head, the same tests, on GitHub's Linux runner with `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` (layer 1.3.275) ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/41201725908)). - Both arms report only `VUID-VkDeviceCreateInfo-pNext-pNext`, `VUID-vkCmdCopyImage-srcImage-01548` and `VUID-vkCmdCopyImage-srcImage-01551`, so this head adds none. The loader inserted the layer 28 times on #9508 and 35 times with this head. - On both arms, `agc_driver_image_table` fails its ctest check for validation messages. Its `FAIL_REGULAR_EXPRESSION` matches the `VUID-VkDeviceCreateInfo-pNext-pNext` line that layer 1.3.275 logs for `VkPhysicalDeviceMaintenance8FeaturesKHR` in the device's feature chain. Both the check and that feature chain are `main`'s. - **On a cloud Linux machine (lavapipe),** at 525408ab29: - this PR's 57 tests ×10: 48 pass, 9 skip (no `VK_EXT_descriptor_heap`, or no uint storage view); - `agc_driver_sampled_clear_keys` passes 10 of 10; - `^(agc|shader)`: 1,278 run, 1,178 pass, 99 skip, 1 fail. The failure is `agc_driver_idle_store_yields`, from #13621, which failed 14 of 30 runs on `main` 5fb1747fa7 alone there. - **06eba99c50: every field the device image interface's duplicate check compares is in its id**, for @mrfelek's Death Stranding 2 (PPSA02015) stop on #10193 ([comment](https://github.com/boykopovar/AnyPS5/pull/10193#issuecomment-6545720023)): `device image interface: two image interfaces share the id`. - **The gap:** `RegisterDeviceImageInterface` compares entries with `ImageResource`'s defaulted `operator==`, but `mixImageInterface` didn't mix five of its fields, and `deviceInterfaceImage` didn't clear them. Two device-table images, or mode lists, that differed only in one of those fields got one id, and the second registration threw. - **The fix,** in `ResourceMaterializer.cpp`, decides each field by whether the interface depends on it: - **mixed into the id:** - `dimensionQueryOnly` and `sampledOnly`: `inspectImageDescriptor` reads both on the stored interface image when `DeviceImageTable::lookupKey` picks a mode through `TryRuntimeImageMode`; - `targetMerge`: it changes the modes and the SPIR-V declarations. - **cleared in the registry's copy:** - `adjustedSample`: it only decides which modes `RuntimeImageModes` adds, and the modes are already part of the id; - `optionalDescriptor`: only the per-draw snapshot reads it, on the program's own copy. - The registry exists only for `deviceTable` images, so nothing else changes. - **The shader cache needs no format bump.** The id is stored in the SPIR-V and in the cached result. But an entry is loaded only when its `FormatVersion` and `SourceVersion()` both match (`ShaderDiskCache.cpp` 1478 and 1491), and its directory and key are named after `SourceVersion()` (1514, 1950-1951). `SourceVersion()` is a SHA-256 over the recompiler's sources (`ShaderCacheVersion.cmake`), `ResourceMaterializer.cpp` included. So no entry with an old id can be read, and the layout is unchanged. - **The test:** `agc_driver_device_image_table`'s interface case now registers, for each of the five fields, an image that differs from the base only in that field. - The three mixed fields get their own id, and the two cleared ones share the base's. - A mode that differs only in `sampledOnly` gets its own id. - **Red:** on 22cead42b2 the case stops at "device image interface: two image interfaces share the id 0xa1ad8eab5dcb3e9d". - **#9183** (fma-rc) adds `ImageResource::volumeGather`. Whichever of #9183 and this PR merges second gives it a mixed-or-cleared call, with a test case. - **×10 on GitHub's runners,** against #9508's 0ab5f157a8 ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/41221060744)): the same set as above. - Linux: 57 run, 48 pass, 9 skip, 0 fail. - Windows: 58 run, 33 pass, 25 skip (no Vulkan device), 0 fail. - The libc and libkernel suites run 199 and 308 tests on Linux and 226 and 330 on Windows, with 0 failed. The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **Validation:** #9508's 0ab5f157a8 against this head, the same tests, on GitHub's Linux runner (layer 1.3.275) ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/41221068403)). - Both arms report only `VUID-VkDeviceCreateInfo-pNext-pNext`, `VUID-vkCmdCopyImage-srcImage-01548` and `VUID-vkCmdCopyImage-srcImage-01551`, so this head adds none. - The loader inserted the layer 28 times on #9508 and 35 times with this head. `agc_driver_image_table` fails its validation-message check on both arms, as above. The only "was not found" in either log is that check's own regex, echoed in its failure line. - **On a cloud Linux machine (lavapipe):** - this PR's 57 tests ×10: 48 pass, 9 skip; - `^(agc|shader)`: 1,279 run, 1,180 pass, 99 skip, 0 fail. A first run had 6 failures: five frame-capture tests stopping on that machine's full disk ("less than 4 GiB free on the capture volume"), and `agc_driver_idle_store_yields`, `main`'s flaky test. All 6 passed alone, and the rerun after freeing space is the one above. - **715097ee91: b5065a1fe9 and 715097ee91, merges of #9508's 31f5d0e8dd and 09cc865e29**, which bring Raghav314's commits since 0ab5f157a8 and #9508's merges of `main`, with #12862's test split. - **b5065a1fe9** keeps both sides, with two edits for what #9508 changed: - the heap retention test no longer calls the heap sweep #9508 removed; - `DeviceImageTable::HeapSlots` passes `texture.get()` to #9508's `TextureSlot(Texture*)` (dd83293174). That's the change milescoviello named in their Ghost of Tsushima run on #10193 (below). - `docs/dev/ARCHITECTURE.md`'s `APS5_GPU_HEAP` bullet keeps #9508's sentences and this PR's trailer words. - **715097ee91:** - `CMakeLists.txt` is resolved with `tools/agc_test_split.py resolve`, which moves this PR's registrations into `tests/cmake/`. #9508 already registers the `_gpu_heap` variants through `agc_add_gpu_heap_test()`. - **The other conflicts keep both sides:** - `ShaderDiskCache.cpp`: #9508's 866bd70c70 drops the second `userDataRegisterReads`, and this PR's two lists follow `imageTableFaults` in both directions; - `Dispatch.cpp` and `DrawCapture.cpp`; - `ShaderResources.cpp`'s includes; - `tests/BindlessHeapSlots.cpp`: #9508's helpers, with both settings made before the device opens; - the Windows `PATH` line in `agc_shader_memory_tests.cmake`. - #9508's 0f4b636d04 and 675e23803d rename what this PR's lines call (`LoadTableMap`, `TableHeap()`, `TableMapAddressed()`, `context.localDevice`, `graphicsContext()`), so this PR's lines follow. - **#13774** (`BufferSpecializationFields`) comes in through #9508's own merge of `main`, which adds it to the binding-plan key and the snapshot hash. This PR's `Recompiler.cpp` lines don't touch those functions. - **The count:** with `-DBUILD_TESTING=ON`, `ctest -N` gives 3,227 tests: #9508's 3,219 plus this PR's 8, each listed once, with all 22 `_gpu_heap` variants. - **The trailer read** is reached only through `LoadTableMap`'s `TableMapAddressed()` branch, never the table-map buffer branch. `agc_shader_device_image_tables` compiles and validates it. The GPU tests that run it, `agc_driver_device_image_table_heap` and `agc_driver_device_image_path_gpu_path`, skip on lavapipe, which has no `VK_EXT_descriptor_heap`. - **×10** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/41269060896)): this PR's set, with `^agc_driver_heap_slots` and `^agc_driver_image_table`. - Linux: 61 run, 46 pass, 15 skip, 0 fail. The 15 need `VK_EXT_descriptor_heap`. - Windows: 60 run, 32 pass, 28 skip (no Vulkan device), 0 fail. - The libc and libkernel suites run 199 and 308 tests on Linux and 226 and 330 on Windows, with 0 failed. The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **Validation:** `main` 31034785f8 against this head, the same tests, on GitHub's Linux runner ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/41269067311)). - Both arms report only `VUID-VkDeviceCreateInfo-pNext-pNext`, `VUID-vkCmdCopyImage-srcImage-01548` and `VUID-vkCmdCopyImage-srcImage-01551`, so this head adds none. - The loader inserted the layer 11 times on `main` and 35 times with this head. `agc_driver_image_table` fails its validation-message check on both arms, as above. - **On a cloud Linux machine (lavapipe):** - the full build passes; - this PR's set ×10: 60 run, 45 pass, 15 skip, 0 fail; - the 366 tests of the files #9508 changed since 31f5d0e8dd, ×10: 328 pass, 38 skip, 0 fail; - `^(agc|shader)`: 1,292 run, 1,121 pass, 171 skip, 0 fail. The skips rise from 104 at b5065a1fe9 because #9508's 09cc865e29 makes its GPU heap variants skip, instead of passing on the per-draw path, when the device has no descriptor heap (95 of the 171). - **Title runs on #10193, which stacks on this PR.** Celegans12's #10193, #13928 and #13929 each depend on the one before. Both runs are of combined stacks with other open PRs and local changes, not of this PR alone: - **Death Stranding 2: On the Beach (PPSA02015),** in mrfelek's run ([comment](https://github.com/boykopovar/AnyPS5/pull/10193#issuecomment-6545720023)), with `APS5_GPU_HEAP=1 APS5_GPU_PATH=1`. On the CPU table path it creates ~17,000 sampled textures and spends ~85 ms per draw, until memory runs out. On the GPU path it creates 800 sampled textures, at ~2.8-15 ms per draw, until the interface id stop that 06eba99c50 fixes. With 06eba99c50 merged into the same stack, mrfelek reports the id stop gone in 2 of 2 runs ([comment](https://github.com/boykopovar/AnyPS5/pull/10193#issuecomment-6548519711)); the next limit there is 20 programs on the CPU table path and host memory. - **Ghost of Tsushima (PPSA02225, 02.024.000),** in milescoviello's run ([comment](https://github.com/boykopovar/AnyPS5/pull/10193#issuecomment-6548433318)), on #10193's 8403a9b05c with `APS5_GPU_HEAP=1 APS5_GPU_PATH=1 APS5_KEEP_UNEXPECTED_DEVICE_IMAGES=1`, an RTX 4070 Ti, Linux. - With #9533, #9717 and #9742, a local guest-buffer change and `APS5_NO_HEAP_DATA_UNIFORM=1`, the 20-minute session runs to the end. Its interface id clash at 101 s is the one 06eba99c50 fixes. - Its tables stay on the CPU table path (722-810 per 10 s). The run's author guesses sampler tables are why, which this PR leaves for a follow-up, and hasn't confirmed it. - **67420fb18b: 7e88d62913 and 67420fb18b, merges of #9508's de1bbf1af3 and fbab1c1619, with 92c6dab397, a fix for the device image table's eviction window, between them.** - **7e88d62913** brings Raghav314's commits since 09cc865e29 and #9508's merges of `main`. Among the commits: - a6ecdf81e4: heap stages' root and shader data are pushed like vkd3d's root signature; - 36caa8b0fe: idle GPU heap image slots are evicted; - 097833507b: an evicted slot counts as free only once a submission covers it; - de1bbf1af3: a batch is submitted early once it holds half the descriptor ring. - **The conflicts:** 14 files, each resolved by keeping both sides. Two needed a call: - `RecompileImpl` builds the result as a value, sets `deviceImagePlan`, then makes it `shared_ptr<const>`; - `ResourceMaterializer`'s `!deviceTable` guard goes on #9508's new `fill(...)` call. - This PR adds no uses of the API #9508's root items replace, so its own lines needed no port. - **92c6dab397**, `fix(agc): keep device image table slots from retiring while a batch still reads them`. - **The window:** with #9508's eviction, `DeviceImageTable::Prepare` swept its keys (`retainSlots`) and uploaded, then took a miss-ring chunk with `chunkFor(recorder, true)`, which can `Sync` and submit. - At that submission the heap could evict a live table slot under that batch's serial. - Once that batch completed, the slot could be reused and rewritten while the next batch still read the key through it. - The table never touched its slots after inserting them, so the heap saw them as idle. - **The fix, in two parts:** - `Prepare` now sweeps again and uploads once, after `chunkFor`, so nothing that can submit sits between the last sweep and the upload. That also covers a flush inside `resolve`'s texture lookup. `Expect` never uploads, so it needs no change. - A new `Slots::touch` member, mapped to `BindlessHeap::TouchSlots`, marks every live entry's slot used once per heap epoch. #9508's `evictLocked` takes only slots with `use + 2 <= epoch`, so it no longer takes one the table serves. - **Tests,** in the same commit and run by `agc_driver_device_image_table`: - `SweptWhileWaitingForAChunk` holds all 16 miss-ring chunks and moves a live key's slot inside `chunkFor`'s wait. On the merge without the fix it fails with "a prepare serves no key whose heap slot moved while it waited for a miss-ring chunk (slot 2, 0 swept)", and with the fix it passes. - `LiveSlotsTouched` checks the touch once per epoch. - **67420fb18b** merges fbab1c1619, Dean's merge of `main` 87448b3c91 into #9508. Three conflicts, each resolved by keeping both sides: - `tests/ShaderMemory.cpp`: the `--device-image-tables` and `--table-trailer` dispatch, then `main`'s `--registered-view-churn`; - `IrMetadata/Resources.hpp`: `NoSampler` and `DeviceImageUse`, then `main`'s `AppliesLodBiasInShader`; - `PipelineSpecialization.hpp`: `main`'s `SamplerLodBiasBase` 57728 and `SamplerLodBiasShaderThreshold`, then `DeviceSamplerClassBase` 58368. - **What stays the same:** - This PR's own changes over #9508 match line for line: `git diff de1bbf1af3 92c6dab397` and `git diff fbab1c1619 67420fb18b` both give 59 files, +4,252/-30. - `FormatVersion` stays 62. - The `3rdparty/SDL2` move and the new `3rdparty/sqlite` are `main`'s, through #9508. - **Spec IDs:** - On `main`, the bases from 57344 to 57791 are contiguous. The device sampler classes take 58368 to 58431, after 576 unused IDs. - The class index is at most 63, because `info.samplers` stops at `ShaderInfo::MaxSamplers` (`ResourceTracker.cpp:2461-2464`). - #10489 moves the FMASK format and volume gather bases to 58048 and 58176. Its last range ends at 58303, so the two PRs don't overlap either. - **LOD bias:** a device-path sampler is always a direct sampler, because a device-table image read through a sampler table fails to compile (`SpirvImageEmitter.cpp:2371`). - It takes `main`'s shader-side bias (`AppliesLodBiasInShader`, `SamplerLodBiasBase` plus the sampler index). - Its host sampler's bias is 0 past the threshold, as for a direct image. - **×10** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/42172049666)): this PR's set, with `^agc_shader_memory`, `^agc_shader_registered_view_churn`, `^agc_driver_image_sample_lod_bias`, `^agc_shader_sampler_limits` and `^agc_shader_disk_cache`. - Linux: 35 run, 20 pass, 15 skip, 0 fail. The 15 need `VK_EXT_descriptor_heap`. `agc_driver_device_image_table` passes 10 of 10. - Windows: 37 run, 12 pass, 25 skip (no Vulkan device), 0 fail. - The libc and libkernel suites run 323 and 338 tests on Linux and 354 and 365 on Windows, with 0 failed. The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **Validation:** `main` 87448b3c91 against this head, the same tests, on GitHub's Linux runner ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/42172921354)). - `main`'s arm ran 15 tests and this head's arm 36, all passing, with 15 skipped on this head. - Both arms report only `VUID-VkDeviceCreateInfo-pNext-pNext`, so this head adds none. - The loader inserted the layer 7 times on `main` and 27 times with this head, and neither log has `was not found`. - Windows: no before/after comparison (the runner has no Vulkan device, and the harness's before-build didn't complete). This PR's own build passed 38 tests, with 25 skipped. - **On a cloud Linux machine (lavapipe):** - **At 92c6dab397:** - this PR's set ×10: 28 tests, 13 pass, 15 skip, 0 fail; - the 109 tests that #9508's commits since 09cc865e29 change, ×10: 83 pass, 26 skip, 0 fail; - `^(agc|shader)`: 1,482 run, 1,289 pass, 193 skip, 0 fail. - **At 67420fb18b:** - this PR's set ×10: 13 pass, 15 skip, 0 fail; - the merge's 33 touched tests ×10: all pass; - `^(agc|shader)`: 1,494 run, 1,301 pass, 193 skip, 0 fail. 106 of the skips need `VK_EXT_descriptor_heap`. - **Not tested:** the fix on a device with the heap extension. `agc_driver_device_image_table_heap` and `agc_driver_device_image_path_gpu_path` need `VK_EXT_descriptor_heap`, which lavapipe and GitHub's runners lack, and the RTX 3070 above wasn't rerun at this head. ### Checklist - [x] Based on current `main` through #9508 (Raghav314, fbab1c1619, which this head merges); #9508's image tables are CPU-resolved into heap slots, and fable-void's branch is not an open PR. #7223, #7395 and #7550 extend the CPU table path in the same recompiler files (`ResourceMaterializer.cpp`, `ResourceTracker.cpp`); they compose with this. No other open PR implements these functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: #9508 (Raghav314); #10807 (milescoviello) and #10359 (valenciana-nc) go before this PR (merge order only; their overlaps are with #9508's lines this PR is stacked on); #10507 (orezraey) goes after this PR (merge order only, on #10507) - [x] Unblocks: PPSA01556 #5169 (per-draw binding cost at Resident Evil Village's title menu; not measured yet, see Pending) - [x] GPUs tested: NVIDIA GeForce RTX 3070 Laptop GPU (driver 617.42), Windows 11; lavapipe (Mesa 25.2.8, LLVM 20.1.2), Ubuntu 24.04; GitHub's Windows runner (no Vulkan device); NVIDIA GeForce RTX 5080 (615.78.08), Linux, in fma-rc's run on the previous head; NVIDIA GeForce RTX 4070 Ti (615.71.09), Linux, in milescoviello's Ghost of Tsushima run on #10193, which stacks on this PR - [x] AI-assisted: yes
blawesom commented 2026-10-19 07:29:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-19T07:29:40Z.


Rebase handoff for the 82-commit GPU-path series — the full series is rebased onto main (cc5b79868, authorship unchanged). This is a deep architectural reconciliation; the resolutions:

  • the draw finisher merge: main's const-correct writesPrograms/writablePrograms form with your tail/finisher threading, tail.programs synced after setMeshIndexBuffer so mesh words reach the finisher
  • the serializer collisions: FormatVersion bumped 40→44 (one per format-affecting change in the series — reviewers may prefer a single final value); DescriptorBinding 656, ShaderInvocation 312, RecompileResult pinned to probe-derived merged sizes
  • ShaderRegistry's convertedSamples flag promoted into linkedSource (mutable copy only when linked code or converted samples exist) — the most semantic rewrite, worth a reviewer's eye
  • the key-source headers (HostThread.hpp, AtomicSharedPtr.hpp) added to the recompiler's cache key with the shader_cache_runtime_sources test fixture generalized to create them
  • three build repairs on the subagent's draft (a missing RecompileImpl forward declaration, a duplicated GuardRead, a stale read.bytes spelling)

Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, AMD RX 9070 XT / RADV): builds; conventions pass; full suite green apart from the four known main regressions (#5444 Mesa, #7584 BDA, #7766 image-table vouch, #7784 guest-memory lifetime — all bisected today), none from this PR.

To pick it up:

git fetch https://github.com/blawesom/AnyPS5 rebase/7642
git checkout <your branch>
git merge --ff-only FETCH_HEAD
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6262041719 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7642#issuecomment-6262041719). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-19T07:29:40Z. --- **Rebase handoff for the 82-commit GPU-path series** — the full series is rebased onto `main` (`cc5b79868`, authorship unchanged). This is a deep architectural reconciliation; the resolutions: - the draw finisher merge: `main`'s const-correct `writesPrograms`/`writablePrograms` form with your `tail`/finisher threading, `tail.programs` synced after `setMeshIndexBuffer` so mesh words reach the finisher - the serializer collisions: `FormatVersion` bumped 40→44 (one per format-affecting change in the series — reviewers may prefer a single final value); `DescriptorBinding` 656, `ShaderInvocation` 312, `RecompileResult` pinned to probe-derived merged sizes - `ShaderRegistry`'s `convertedSamples` flag promoted into `linkedSource` (mutable copy only when linked code or converted samples exist) — the most semantic rewrite, worth a reviewer's eye - the key-source headers (`HostThread.hpp`, `AtomicSharedPtr.hpp`) added to the recompiler's cache key with the `shader_cache_runtime_sources` test fixture generalized to create them - three build repairs on the subagent's draft (a missing `RecompileImpl` forward declaration, a duplicated `GuardRead`, a stale `read.bytes` spelling) Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, `BUILD_TESTING=ON`, AMD RX 9070 XT / RADV): builds; conventions pass; **full suite green apart from the four known `main` regressions** (#5444 Mesa, #7584 BDA, #7766 image-table vouch, #7784 guest-memory lifetime — all bisected today), none from this PR. **To pick it up:** ``` git fetch https://github.com/blawesom/AnyPS5 rebase/7642 git checkout <your branch> git merge --ff-only FETCH_HEAD ```
fma-rc commented 2026-10-19 14:09:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-19T14:09:40Z.


@EagleBearerYS here's Astro's Playroom (PPSA01325) on this head (05502ba6a5), Linux, RTX 5080 (driver 615.78.08), one run each into the first level with Cross pressed, and a 10 s trace window in the same gameplay scene. Both runs had APS5_PROFILE_DRAW=1; one added APS5_GPU_PATH=1.

With the switch on, the log has no [device-images] line at all in 190 s: no 10-second counters, no "takes the CPU table path" line and no "stays off on this device" line. So the device image table logged no activity on this title, and I can't attribute anything below to the lookup itself.

The 12 captured frames of each run show the same intro and gameplay scene, with no black or missing textures in either. The trace window had 135 frames with the switch and 124 without. The GPU ran at P0 for most of both runs, median graphics clock 2812 MHz in each. That's one round each, and the two are within 10%, so I wouldn't read the gap as a speedup.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6269227272 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7642#issuecomment-6269227272). Originally posted by [fma-rc](https://github.com/fma-rc) on 2026-10-19T14:09:40Z. --- @EagleBearerYS here's Astro's Playroom (PPSA01325) on this head (05502ba6a5), Linux, RTX 5080 (driver 615.78.08), one run each into the first level with Cross pressed, and a 10 s trace window in the same gameplay scene. Both runs had `APS5_PROFILE_DRAW=1`; one added `APS5_GPU_PATH=1`. With the switch on, the log has no `[device-images]` line at all in 190 s: no 10-second counters, no "takes the CPU table path" line and no "stays off on this device" line. So the device image table logged no activity on this title, and I can't attribute anything below to the lookup itself. The 12 captured frames of each run show the same intro and gameplay scene, with no black or missing textures in either. The trace window had 135 frames with the switch and 124 without. The GPU ran at P0 for most of both runs, median graphics clock 2812 MHz in each. That's one round each, and the two are within 10%, so I wouldn't read the gap as a speedup.
EagleBearerYS commented 2026-10-21 02:39:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-21T02:39:28Z.


@fma-rc Thanks for the Astro's Playroom (PPSA01325) run. No [device-images] line means no program in that scene reads an image table the path serves. The 10-second counters print only once a device image table exists, and the per-program line prints for each program recompiled with device tables. The "stays off on this device" line didn't print either, so the switch was on and the device supports the path. That makes your pair the no-change check: the same frames, and frame counts within noise, as you read them, on a title whose shaders don't use the bindless image tables this moves onto the GPU heap. I'll add it to Tested as that.

@blawesom Thanks for rebasing the series and for the notes. We won't take the rebased copy into this PR. It carries the 31 commits of Raghav314's #6947, which this draft is stacked on, and rebasing those is his call on his PR. This PR follows #6947 when it moves, with a merge of main of its own if needed. Your resolution notes (the finisher threading, convertedSamples moving into linkedSource, and the key-source headers) are a useful reference for that merge. If we use one, the commit credits you. On the format numbers, one FormatVersion step per format change is what we do too, but main has moved since, so the values will change again.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6306636123 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7642#issuecomment-6306636123). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-21T02:39:28Z. --- @fma-rc Thanks for the Astro's Playroom (PPSA01325) run. No `[device-images]` line means no program in that scene reads an image table the path serves. The 10-second counters print only once a device image table exists, and the per-program line prints for each program recompiled with device tables. The "stays off on this device" line didn't print either, so the switch was on and the device supports the path. That makes your pair the no-change check: the same frames, and frame counts within noise, as you read them, on a title whose shaders don't use the bindless image tables this moves onto the GPU heap. I'll add it to Tested as that. @blawesom Thanks for rebasing the series and for the notes. We won't take the rebased copy into this PR. It carries the 31 commits of Raghav314's #6947, which this draft is stacked on, and rebasing those is his call on his PR. This PR follows #6947 when it moves, with a merge of main of its own if needed. Your resolution notes (the finisher threading, `convertedSamples` moving into `linkedSource`, and the key-source headers) are a useful reference for that merge. If we use one, the commit credits you. On the format numbers, one FormatVersion step per format change is what we do too, but main has moved since, so the values will change again.
adriadam10 commented 2026-10-23 13:46:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-23T13:46:49Z.

Review: CHANGES_REQUESTED


Reviewed the 8 commits on top of #9508; it can't land before that one does.

  • The title measurement (Resident Evil Village, switches on vs off) is still under Pending, and the per-draw goal (~155 µs measured vs 80–90 µs) isn't met. The only numbers are from lavapipe, which the body itself says overstates the CPU path. Please post the title run (share of draws on the device path, CPU per draw, GPU time per frame, images) on this head before merge.
  • A draw whose expected T#s can't be evaluated before it is recorded is still recorded and samples zeros for that batch (docs/dev/debt/libSceAgcDriver.md, new line). fma-rc's Death Stranding 2 run shows five programs doing this during loading. Please say how often it happens on a real title and whether it is visible (a missing frame of texture), or record the draw again through the CPU map.
  • Memory: entries hold their texture, so a full table pins up to its capacity of host textures. State the bound and peak RSS with the table full, before/after, on a large workload; the "Pinned slots near a full heap" item is currently only a plan.
  • ShaderDiskCache::FormatVersion is 49 here, main is 45 and #7223 takes 46. Re-pick it when #9508 and #7223 land.
  • Conflicts with main come from #9508; rebase once it merges.

Everything else checked (trailer ABI v3 layout and its tests, docs and debt updates, no added code comments, conventions) looks fine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5629125577 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7642#pullrequestreview-5629125577). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-23T13:46:49Z. **Review:** CHANGES_REQUESTED --- Reviewed the 8 commits on top of #9508; it can't land before that one does. - The title measurement (Resident Evil Village, switches on vs off) is still under Pending, and the per-draw goal (~155 µs measured vs 80–90 µs) isn't met. The only numbers are from lavapipe, which the body itself says overstates the CPU path. Please post the title run (share of draws on the device path, CPU per draw, GPU time per frame, images) on this head before merge. - A draw whose expected T#s can't be evaluated before it is recorded is still recorded and samples zeros for that batch (`docs/dev/debt/libSceAgcDriver.md`, new line). fma-rc's Death Stranding 2 run shows five programs doing this during loading. Please say how often it happens on a real title and whether it is visible (a missing frame of texture), or record the draw again through the CPU map. - Memory: entries hold their texture, so a full table pins up to its capacity of host textures. State the bound and peak RSS with the table full, before/after, on a large workload; the "Pinned slots near a full heap" item is currently only a plan. - `ShaderDiskCache::FormatVersion` is 49 here, `main` is 45 and #7223 takes 46. Re-pick it when #9508 and #7223 land. - Conflicts with `main` come from #9508; rebase once it merges. Everything else checked (trailer ABI v3 layout and its tests, docs and debt updates, no added code comments, conventions) looks fine.
jotitadev commented 2026-10-31 04:11:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-31T04:11:08Z.

Review: COMMENTED


Linux NVIDIA run of head 88ad9e88d8. As far as I can tell from the thread, it's the first Linux test run with the descriptor heap live: lavapipe skips the GPU-heap tests, and the 3070 runs in the body are Windows.

Setup: Ubuntu 26.04, GCC 15.2, Release. RTX 3070 with NVIDIA 595.99.02 and lavapipe (Mesa 26.0.3), one at a time via VK_DRIVER_FILES. The head is merged --no-ff onto main 539c3425f8 with no conflicts. ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1, ctest -j1. This head carries #9508 at 82f76ffa75, so the heap turns on with this driver (GPU-mode draws and dispatches bind from VK_EXT_descriptor_heap).

  • Build: all (size asserts and field counts) builds with no new warnings. public_headers passes 65/65.
  • Heap and device-image tests, no layer, 3070: all 115 tests matching heap|device_image pass 115/115 in 3 of 3 runs.
    • That includes agc_driver_device_image_table_heap and agc_driver_device_image_path_gpu_path with the heap live.
    • In both batches, the path test prints GPU-mode compute stages 10, ... expected 10, inserted 10 / 0, miss records 0, fallbacks 0.
  • The 267 tests of the executables built from the changed test files, layer 1.4.341, 3 runs per device:
    • lavapipe: 267/267 each run.
    • 3070: this PR's own tests pass every run (agc_shader_table_trailer, agc_shader_device_image_tables, agc_device_image_keys, and the five agc_driver_device_image_*), with no VUID- from them.
    • 3070 failures: 9, 13 and 11 *_gpu_heap / heap_* tests segfault, a different subset each run. The heap VUIDs (11236, 11228, maintenance4-08602) also appear. That's #9508's base at 82f76ffa75 under this layer, which I reported on #9508. #9508's newer head turns the heap off under layers older than 1.4.363.
  • Layer 1.3.275 (the NVIDIA CI's), 3070: 36 of 267 fail, including device_image_table_heap and device_image_path_gpu_path (SEGFAULT). The layer doesn't know the extension. Once this branch restacks on #9508's current head, these tests will skip on that machine, because #9508's current head keeps the heap off on 595.99.02, which reports Vulkan 1.4.329.
  • ^agc, no layer: 1221/1221 on the 3070 and 1221/1221 on lavapipe.
  • ^agc with the switches set for the whole run, 3070:
    • APS5_GPU_HEAP=1 alone: 14 fail, none of them this PR's tests. Four are the ones #9508 fixed in dfe95cc969: tessellation_depth_range_remap, prepared_graphics and both lazy_resolved_abi. Four are multisample tests that also fail on #9508's ec6c2f384f once its driver check is relaxed locally so the heap goes live.
    • APS5_GPU_HEAP=1 APS5_GPU_PATH=1: 23 fail. The 9 extra failures are this PR's:
      • three are bindless_images (plain, _gpu_heap, _heap), as the Limitations section says;
      • the other six are the agc_driver_heap_slots* tests, which pass without APS5_GPU_PATH. In that run they fail with a full heap refuses another owner's view, one free slot of eight refuses the heap, storage owners that leave one free slot of eight refuse the heap and views that leave one free slot of eight refuse the heap.
      • So with the path on, the heap's slot accounting no longer matches what those tests assume. It could be a test assumption, like the four #9508 fixed, or the table taking slots the tests don't expect. I haven't looked further.
  • Red: the new tests include the PR's new headers (DeviceImageTable.hpp and others), so they can't run on main. Instead I broke the code under test: the table entry no longer holds its texture (entry = {nullptr, ...} in DeviceImageTable::lookupKey). agc_driver_device_image_table_heap then fails with the heap slot holds the entry's texture, and agc_driver_device_image_table and agc_driver_device_image_path_gpu_path fail too. With the code restored, all pass.

GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02, Linux), lavapipe (Mesa 26.0.3).

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5721150049 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7642#pullrequestreview-5721150049). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-31T04:11:08Z. **Review:** COMMENTED --- Linux NVIDIA run of head `88ad9e88d8`. As far as I can tell from the thread, it's the first Linux test run with the descriptor heap live: lavapipe skips the GPU-heap tests, and the 3070 runs in the body are Windows. Setup: Ubuntu 26.04, GCC 15.2, Release. RTX 3070 with NVIDIA 595.99.02 and lavapipe (Mesa 26.0.3), one at a time via `VK_DRIVER_FILES`. The head is merged `--no-ff` onto `main` `539c3425f8` with no conflicts. `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1`, `ctest -j1`. This head carries #9508 at `82f76ffa75`, so the heap turns on with this driver (`GPU-mode draws and dispatches bind from VK_EXT_descriptor_heap`). - **Build:** `all` (size asserts and field counts) builds with no new warnings. `public_headers` passes 65/65. - **Heap and device-image tests, no layer, 3070:** all 115 tests matching `heap|device_image` pass 115/115 in 3 of 3 runs. - That includes `agc_driver_device_image_table_heap` and `agc_driver_device_image_path_gpu_path` with the heap live. - In both batches, the path test prints `GPU-mode compute stages 10, ... expected 10, inserted 10 / 0, miss records 0, fallbacks 0`. - **The 267 tests of the executables built from the changed test files, layer 1.4.341, 3 runs per device:** - lavapipe: 267/267 each run. - 3070: this PR's own tests pass every run (`agc_shader_table_trailer`, `agc_shader_device_image_tables`, `agc_device_image_keys`, and the five `agc_driver_device_image_*`), with no `VUID-` from them. - 3070 failures: 9, 13 and 11 `*_gpu_heap` / `heap_*` tests segfault, a different subset each run. The heap VUIDs (`11236`, `11228`, `maintenance4-08602`) also appear. That's #9508's base at `82f76ffa75` under this layer, which I reported on #9508. #9508's newer head turns the heap off under layers older than 1.4.363. - **Layer 1.3.275 (the NVIDIA CI's), 3070:** 36 of 267 fail, including `device_image_table_heap` and `device_image_path_gpu_path` (SEGFAULT). The layer doesn't know the extension. Once this branch restacks on #9508's current head, these tests will skip on that machine, because #9508's current head keeps the heap off on 595.99.02, which reports Vulkan 1.4.329. - **`^agc`, no layer:** 1221/1221 on the 3070 and 1221/1221 on lavapipe. - **`^agc` with the switches set for the whole run, 3070:** - `APS5_GPU_HEAP=1` alone: 14 fail, none of them this PR's tests. Four are the ones #9508 fixed in dfe95cc969: `tessellation_depth_range_remap`, `prepared_graphics` and both `lazy_resolved_abi`. Four are multisample tests that also fail on #9508's `ec6c2f384f` once its driver check is relaxed locally so the heap goes live. - `APS5_GPU_HEAP=1 APS5_GPU_PATH=1`: 23 fail. The 9 extra failures are this PR's: - three are `bindless_images` (plain, `_gpu_heap`, `_heap`), as the Limitations section says; - the other six are the `agc_driver_heap_slots*` tests, which pass without `APS5_GPU_PATH`. In that run they fail with `a full heap refuses another owner's view`, `one free slot of eight refuses the heap`, `storage owners that leave one free slot of eight refuse the heap` and `views that leave one free slot of eight refuse the heap`. - So with the path on, the heap's slot accounting no longer matches what those tests assume. It could be a test assumption, like the four #9508 fixed, or the table taking slots the tests don't expect. I haven't looked further. - **Red:** the new tests include the PR's new headers (`DeviceImageTable.hpp` and others), so they can't run on `main`. Instead I broke the code under test: the table entry no longer holds its texture (`entry = {nullptr, ...}` in `DeviceImageTable::lookupKey`). `agc_driver_device_image_table_heap` then fails with `the heap slot holds the entry's texture`, and `agc_driver_device_image_table` and `agc_driver_device_image_path_gpu_path` fail too. With the code restored, all pass. GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02, Linux), lavapipe (Mesa 26.0.3). Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
MarcZX10 commented 2026-11-23 02:40:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T02:40:24Z.

Review: COMMENTED


Reviewed — comments

Changes are required before merge: the author must complete a broad review of the changed code and resolve any issues found.

What I ran

Reviewed the prepared diff for head 2eb37516af1e94aa481a1c34f8cead9cdab7ef90 and inspected selected diff sections. No tests or builds were run. Repository source reads through repo_read.py were not available in this session.

Results

Check Result Note
Diff inspection passed Prepared patch inspected selectively
Tests and build not run No commands executed
Source review not run Head source not read

Findings

Blocking

None verified.

Non-blocking

No code finding is offered because the relevant repository source was not verified.

Not verified

The review is incomplete: no repository source at the pinned head was read, and no tests or builds were run. I inspected description.md, manifest.json, and selected portions of diff.patch; I did not inspect commits.md or files.json. Most changed files listed in the manifest were not read, and some changed files were excluded from the review bundle because they were too large or unsupported. The stated behavior and test claims in the description remain unverified.

To get this to a good state

Complete a source-level review of the changed files at the pinned head and run the relevant checks before making a merge decision.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6015979569 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7642#pullrequestreview-6015979569). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-23T02:40:24Z. **Review:** COMMENTED --- # Reviewed — comments Changes are required before merge: the author must complete a broad review of the changed code and resolve any issues found. ## What I ran Reviewed the prepared diff for head `2eb37516af1e94aa481a1c34f8cead9cdab7ef90` and inspected selected diff sections. No tests or builds were run. Repository source reads through `repo_read.py` were not available in this session. ## Results | Check | Result | Note | |---|---|---| | Diff inspection | passed | Prepared patch inspected selectively | | Tests and build | not run | No commands executed | | Source review | not run | Head source not read | ## Findings ### Blocking None verified. ### Non-blocking No code finding is offered because the relevant repository source was not verified. ## Not verified The review is incomplete: no repository source at the pinned head was read, and no tests or builds were run. I inspected `description.md`, `manifest.json`, and selected portions of `diff.patch`; I did not inspect `commits.md` or `files.json`. Most changed files listed in the manifest were not read, and some changed files were excluded from the review bundle because they were too large or unsupported. The stated behavior and test claims in the description remain unverified. ## To get this to a good state Complete a source-level review of the changed files at the pinned head and run the relevant checks before making a merge decision.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/7642:upstream-pr/7642'
git switch 'upstream-pr/7642'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/7642'
git switch 'upstream-pr/7642'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/7642'
git switch 'upstream-pr/7642'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/7642'
git switch 'main'
git merge --squash 'upstream-pr/7642'
git switch 'main'
git merge --ff-only 'upstream-pr/7642'
git switch 'main'
git merge 'upstream-pr/7642'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!7642
No description provided.