perf(agc): share BDA fault buffers in a per-device arena, with 32-byte slots for report-only programs #8963

Merged
EagleBearerYS merged 10 commits from upstream-pr/8963 into main 2026-11-03 08:07:30 +00:00
EagleBearerYS commented 2026-10-21 07:38:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-21T07:38:19Z.


What

Every BdaResources owns a host-visible fault buffer of BdaAbi::FaultBufferBytes: 24,620 bytes, which the buffer pool rounds to 32 KiB. A program uses only part of it:

words contents written by
0–7 the fault report record_bda_fault (image-table faults, unlinked calls, the loop guard) and the rect-list check
8–6153 the written-page record only programs that store through the BDA table
6154 the SRT guard word only programs with a guarded SRT read

A buffer lives as long as its owner: while the resource cache keeps a fault-only build, and while an address-based draw is in flight, which the recorder holds until its batch completes.

In a Village-shaped bench (agc_driver_village_draw_cost_tests --cost 20, lavapipe, APS5_PROFILE_DRAW=1, two runs), the fault buffers were 97.7% of the driver's "shader data" host-visible memory:

  • 189.7 and 198.7 MiB, in 6,071 and 6,359 buffers;
  • of a host-visible peak of 214.4 and 224.4 MiB.

Every one of the 22,000 BDA builds there could write only the report.

The change, in two commits:

  1. Fault buffers are slots of a per-device arena, in 512 KiB host-visible chunks at minStorageBufferOffsetAlignment.
    • Each slot is bound with its offset (ShaderResources::prepareFaultSlot rewrites only the fault descriptor of the owner's own sets).
    • An owner notes the serial of each batch it's bound or marked in. The recorder reports each batch once its completions ran (BdaResources::NoteFinished).
    • When no chunk has a free slot, under the GPU lock only, the arena takes back the slots of the older half of the idle owners. An idle owner is one whose last batch finished and whose slot is clean: no unread report, written-page claim or SRT guard. Without the lock the arena grows instead.
    • An owner that lost its slot takes one again when it's next bound. A slot in use never moves, so every report is read from the slot its shader wrote, and per-draw attribution is unchanged.
    • APS5_NO_SHARED_FAULT_SLOTS=1 restores one full buffer per owner (documented in docs/dev/ENVIRONMENT.md).
  2. Report-only programs get a 32-byte slot.
    • SpirvFaultReportOnly(words, set, binding), cached per module hash, proves that a program reaches its fault buffer only through OpAccessChain with constant member 0 and a constant word below 8, used only in loads, stores and atomics.
    • Any other reference fails the proof and keeps the full slot: a computed index, word 8 or beyond, a copied pointer, the buffer passed to a function, or a module that can't be read.
    • prepareAddressBindings ANDs the proof over every stage. For such an owner, CheckFault reads only the report, and markWrittenPages and checkSrtGuard are skipped: the program can't write those words, and they aren't in the slot.
    • Report-only and full slots come from separate chunks.
    • BdaAbi.hpp is unchanged and no shader offset moves, so the shader cache isn't affected. The BDA read execution tests have always bound a sizeof(Abi::Fault) buffer to read programs.

Fault reports kept exactly:

  • Per-draw attribution: one slot per owner, never moved while in use.
  • Image-table faults and the loop guard: report words, read and reset as before.
  • SRT guard faults: a guarded program writes word 6154, fails the proof and keeps a full slot.
  • The written-page record: a program with BDA stores writes words 8 and up, fails the proof and keeps a full slot.

Measured, same bench and runs:

arm host-visible peak "shader data" BDA fault buffers
main 214.4 / 224.4 MiB 194.1 / 203.4 MiB 189.7 / 198.7 MiB (6,071 / 6,359 buffers)
commit 1 only 188.4 / 196.4 MiB 165.9 / 174.7 MiB 161.0 / 169.5 MiB (322 / 339 chunks)
both 30.4 / 28.4 MiB 6.6 / 5.9 MiB 0.5 MiB (one chunk)
  • On this bench nearly all of the saving is the second commit's. The buffers belonged to draws in flight, which the first commit's give-back can't take, and its arena saves only the pool's rounding.
  • The give-back is for fault-only builds the resource cache keeps: rect-list, image-table and SRT-guard builds. Its test covers that case.
  • The bench's wall times per draw fell too, but they're too noisy on lavapipe to claim.

Resident Evil Village (PPSA01556): one pair on an NVIDIA GeForce RTX 3070 Laptop GPU (driver 617.42, Windows 11), clocks not held, both arms with APS5_PROFILE_DRAW=1, APS5_LAZY_SHADER_PREPARE=1, APS5_NO_GPL=1 and APS5_HOST_IMPORT_MIB=6400; 6 min at the static menu, then Yes and 4 min in control. Host-visible "shader data", where the fault buffers are allocated: 27.6 → 18.8 MiB and 24.4 → 15.9 MiB at the menu (after 1 and 5 min), and 12.4 → 2.8 MiB in control. No fault lines in either arm. After the load the two arms took different host-import paths (27,062 imports made without this PR, 44,814 with it). That moves the buffer pool and host copies, not the fault buffers, so total host-visible memory isn't compared here. An earlier pair at the static menu, before the give-back and the 32-byte slots, showed ~20 MiB with and without the change.

The last summary line of each arm, in the control scene (without this PR, then with it). Both arms ran with APS5_PROFILE_DRAW=1, each line is a single present, and the lines carry no memory fields, so they record the scene the memory figures above come from, not a speed. Their frame times (4.0 s and 8.1 s) aren't comparable: both arms were profiled, and they took different host-import paths after the load (see above):

{"commit":"af0821dddb64","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"6400","APS5_LAZY_SHADER_PREPARE":"1","APS5_NO_GPL":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_PROFILE_DRAW":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SUMMARY_EVERY":"1"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","cpu":"AMD Ryzen 9 5900HS with Radeon Graphics","cpu_threads":16,"memory_mib":15776,"title_id":"PPSA01556","title":"Resident Evil Village","content_version":"01.210.000","resolution":"3840x2160","window":{"spec":"summary_every 1","first_present":5458,"ms":4017.622},"interval_start_s":2400.257,"interval_end_s":2404.275,"presents":1,"frame_ms":{"p50":4017.622,"p90":4017.622,"p99":4017.622,"max":4017.622},"gpu_busy_ms_per_present":231.500,"worker_busy_pct":{"queue worker 0x0":88.827,"queue worker 0x38":10.990,"queue worker 0x20":75.535,"queue worker 0x28":82.775},"top_phases_ms_per_frame":{"Driver.Packet":10368.420,"Driver.Packet.memory_wait":6239.427,"Driver.Packet.draw":2859.241,"Driver.Draw":2857.528,"Graphics.Draw":2525.684,"Graphics.Draw.draw_and_resource_release":2503.759,"Resources.Complete":2023.137,"Driver.Packet.dispatch":1190.484},"trace_dropped":false,"trace":""}
{"commit":"5f6425ca4a49","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"6400","APS5_LAZY_SHADER_PREPARE":"1","APS5_NO_GPL":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_PROFILE_DRAW":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SUMMARY_EVERY":"1"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","cpu":"AMD Ryzen 9 5900HS with Radeon Graphics","cpu_threads":16,"memory_mib":15776,"title_id":"PPSA01556","title":"Resident Evil Village","content_version":"01.210.000","resolution":"3840x2160","window":{"spec":"summary_every 1","first_present":4832,"ms":8053.336},"interval_start_s":2797.378,"interval_end_s":2805.432,"presents":1,"frame_ms":{"p50":8053.336,"p90":8053.336,"p99":8053.336,"max":8053.336},"gpu_busy_ms_per_present":229.928,"worker_busy_pct":{"queue worker 0x0":94.510,"queue worker 0x38":5.374,"queue worker 0x20":85.585,"queue worker 0x28":90.852},"top_phases_ms_per_frame":{"Driver.Packet":22249.511,"Driver.Packet.memory_wait":11986.929,"Driver.Packet.draw":4459.777,"Driver.Draw":4457.433,"Resources.Complete":4328.588,"Graphics.Draw":4112.876,"Graphics.Draw.draw_and_resource_release":4083.483,"Driver.Packet.dispatch":4041.343},"trace_dropped":false,"trace":""}

Overlap: checked with git merge-tree against every open PR on the same files, on main b77bd5880.

  • Four PRs add code at the same place as this one. Each conflict is a pair of additions, resolved by keeping both:
    • #8608 (SleglJan) declares LastRecordIndices where this PR declares SpirvFaultReportOnly, in ShaderResources.hpp;
    • #8380 (Zenodeon) adds a test case where this PR adds its slot helpers, in tests/BdaResources.cpp;
    • #7002 and #6498 (Amoenus) add requireGuestBuffers (and #7002 synchronizeGuestBuffers) where this PR adds prepareFaultSlot, in ShaderResources.cpp. Agreed order with #6498: #6498 first (comment). #6498 has merged, and 918b1eeb5d merges main that way: #6498's native-MSAA buffer guard runs before prepareFaultSlot() in Bind(), and, with the moved logical ranges, before PrepareDrawBindings' early return.
  • #6636 and #7465 merge cleanly.
  • #10150 (milescoviello) has merged. This PR's merge of main keeps both sides' includes in BdaResources.hpp, as agreed on #10150.
  • #6412 (draft) defers a V# check that reports through the fault buffer. The proof reads each compiled module, so the words its check writes decide whether its programs get a 32-byte slot. It conflicts with main itself.
  • #6947 (Raghav314, draft) and our #7642 (draft) bind the fault buffer per draw in their heap mode. Whichever merges second binds the slot's offset and range there. Both conflict with main themselves.
  • Our draft #8971, which reuses address-based dispatch builds, adds a spare fault record per concurrent use. It conflicts with this PR in BdaResources.hpp/.cpp. Whichever merges second takes those spare records from this arena.

Tested

  • agc_driver_graphics (faultSlotTests, mock device):
    • 256 idle cached BdaResources hold fewer than 64 slots, and the reclaim count is non-zero;
    • two of them retaken while in flight survive 64 pressure objects and report their own addresses from one batch;
    • a fault-only ShaderResources reclaimed under pressure takes a new slot on Bind and reports its own address, while the build that took its old slot reports its own;
    • a build whose program can't be read keeps a full slot;
    • 64 report-only owners share one chunk of 32-byte slots, with neighbours reporting their own addresses;
    • the real rect-list program is bound 32 bytes and reports its fault.
  • agc_driver_bda_device (lavapipe):
    • the proof accepts the BDA read and fault programs, and rejects store and write programs, a missing binding and unreadable modules;
    • five hand-assembled modules cover report-word loads, stores and atomics, and rejections for word 8, a computed index, a copied pointer and the buffer passed to a function;
    • two neighbouring 32-byte slots, dispatched in one batch, each report their own fault.
  • Red lines (each fix hunk reverted at its commit, the test unchanged):
    • commit 1, the reclaim: "256 idle cached BdaResources hold 256 fault slots in 13 chunks (6563 KiB of host-visible memory)";
    • commit 2, the slot size: "64 report-only BdaResources hold 4 fault chunks with 24620-byte slots", and on the device "two report-only BdaResources did not take 32-byte slots of one fault chunk";
    • commit 2, the plumbing: "the rect-list check, which writes only the fault report, was bound 24620 bytes of fault buffer";
    • commit 2, without the proof: "a build whose program could not be read was bound less than a full fault buffer".
    • The same four reds at this PR's head cfe73029e2, on GitHub's runners, each fix hunk reverted on its own there with the tests unchanged, one run of agc_driver_graphics and agc_driver_bda_device each, with the other tests built from the changed files. Each fails on Linux and on Windows with its line:
      • reclaim off (run): "256 idle cached BdaResources hold 256 fault slots in 13 chunks (6563 KiB of host-visible memory)";
      • full-size slots (run): "64 report-only BdaResources hold 4 fault chunks with 24620-byte slots", and on Linux agc_driver_bda_device also fails with "two report-only BdaResources did not take 32-byte slots of one fault chunk";
      • the plumbing (run): "the rect-list check, which writes only the fault report, was bound 24620 bytes of fault buffer";
      • the proof's result dropped (run): "a build whose program could not be read was bound less than a full fault buffer".
      • In each run agc_driver_graphics fails (on Linux its _maps_fallback run too), plus agc_driver_bda_device where noted; the other tests pass, and on Windows agc_driver_bda_device skips without a Vulkan device. The green at the same head is the cfe73029e2 run below.
  • The existing BDA, fault, SRT-guard and image-table tests (31, agc_shader_srt_read_patching included) pass ×10, with the same 2 skips as main.
  • GitHub's runners (run):
    • agc_driver_graphics, agc_driver_bda_device and agc_shader_srt_read_patching pass ×10 on Linux. On Windows (MinGW), agc_driver_graphics and agc_shader_srt_read_patching pass ×10 and agc_driver_bda_device skips without a Vulkan device. The run's other tests, which it picked from the changed files, pass too: 32 run on Linux and 31 on Windows in all.
    • The libc and libkernel suites pass on both.
    • With main's code the new tests don't build, because they use the arena's API. The red lines above come from reverting each fix hunk instead.
  • CI's Linux job, mirrored (Ubuntu 24.04, gcc 13.3, lavapipe): 1,776 of 1,782 here and 1,775 of 1,782 on main a07e985c8.
    • The same six network tests fail on both, from that machine's sandbox.
    • main also failed agc_driver_sgpr_pattern_fill_keys under load; it passes here, and 10 of 10 alone.
    • Registration and check_skips.py match.
  • RADV, run by clairtonmichel (comment; RX 7900 XTX, Mesa 26.2.5, Fedora): 872 of the 875 AGC and video tests pass. The other three have known failures on main on RADV: agc_driver_guest_memory_lifetime (#7784), agc_driver_tessellation (#5444, a crash with Mesa 26.2 and later; theirs is 26.2.5) and agc_driver_image_array_window_past_layer_limit (the expectation #8969 fixes). Their runs on main and with APS5_NO_SHARED_FAULT_SLOTS=1 weren't posted.
  • check_conventions.py passes, with no comment lines added.
  • 1c7d058c4f, a merge of main 0db47b263d. The only conflict was two declarations added at the same place in ShaderResources.hpp: this branch's SpirvFaultReportOnly and main's ShaderStoresThroughAddresses, and both are kept. The run linked here before didn't run this PR's tests (its name list matched none of them); the run under cfe73029e2 below covers this merge's code.
  • cfe73029e2, a merge of main 2b1648419a. The only conflict was in tests/BdaResources.cpp, where this branch's faultSlotTests and #8380's partialHeapImportBudgetTests were added at the same place, and both are kept. The PR's added and removed lines are unchanged. On GitHub's runners, 10 runs (run): on Linux, this PR's tests, agc_driver_graphics, agc_driver_bda_device, agc_shader_srt_read_patching, agc_device_fault, agc_bda_staging, agc_driver_bda_reads_shadowed_results and its _per_build run, agc_driver_image_table_vouch_queued_draws and agc_driver_image_table_vouched_lookups, pass, 9 of 9, and so do the 32 other tests built from the changed files: 41 run, 41 pass, 0 skip, 0 fail. On Windows, agc_driver_graphics, agc_shader_srt_read_patching and agc_device_fault pass and the 6 device tests skip without a Vulkan device: 40 run, 33 pass, 7 skip (those 6 and agc_driver_host_import_failure_handles), 0 fail. The libc and libkernel suites pass on both (122 and 204 tests on Linux, 149 and 216 on Windows), run with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners. The run linked here before didn't run this PR's tests, so it's replaced.
  • Validation layer, main against this PR (CONTRIBUTING's AGC rule), on GitHub's Linux runner (llvmpipe, LLVM 20.1.2; run), with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ANYPS5_NO_SHADER_CACHE=1, ANYPS5_REQUIRE_VULKAN=1 and ctest -V. The tests are the existing ones that build on main too, agc_driver_bda_reads_shadowed_results and its _per_build run, agc_device_fault, agc_bda_staging, agc_driver_image_table_vouch_queued_draws, agc_driver_image_table_vouched_lookups and agc_shader_srt_read_patching, with the other tests built from the changed files, once on each tree: 39 run, 39 pass with the change and on main. The loader inserted VK_LAYER_KHRONOS_validation 7 times on each tree, neither log has was not found but was requested, and both report only VUID-VkDeviceCreateInfo-pNext-pNext. This PR adds no VUID- message. The new cases in agc_driver_graphics and agc_driver_bda_device don't build with main's code, so this comparison doesn't cover them.
  • 08392c098f, a merge of main facac6a4c5 (run). Three conflicts, each resolved by keeping both sides: BdaResources.hpp's include block (#10150's <memory> and this PR's includes); ShaderResources.hpp, where imellag's #11142 removed MovedWordBuffer next to this PR's FaultDescriptor and prepareFaultSlot(), so the merge keeps this PR's members without the removed ones; and docs/dev/ENVIRONMENT.md, with this PR's APS5_NO_SHARED_FAULT_SLOTS row and main's new APS5_NO_SINGLE_PASS_COLLECT text. This PR's added and removed lines are the same, except #include <memory>, which main now has. The 13 tests named above, with the tests for the files the merge changes, pass 10 runs in a row. Linux: 49 run, 49 pass, 0 skip, 0 fail. Windows: 48 run, 38 pass, 10 skip (no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (166 and 264). On Windows libc passes (194) and libkernel passes 283 of 286: exec_arguments, guest_timed_join_import_libkernel_sys and guest_timed_join_import_libkernel_web fail at their setup in the verify's Windows build (FileNotFoundError starting the title, or copying the libraries they load), and pass in main's own Windows job at 1829def9bf (job). The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • 92f08cb9c2, a merge of main d4cb89300f (run). The one conflict was docs/dev/ENVIRONMENT.md, where Astronaut10's #11696 adds APS5_NO_SHAPE_MEMO on the line where this PR adds APS5_NO_SHARED_FAULT_SLOTS; the merge keeps both rows, in order. This PR's other changed lines are the same. The BDA, fault-buffer, heap-mirror, pipeline-store and draw-state tests of this PR's earlier runs ran 10 times with no failure (each runner builds its own set). Linux: 50 run, 50 pass, 0 skip, 0 fail. Windows: 49 run, 39 pass, 10 skip (the Vulkan device tests), 0 fail. Suites: libc and libkernel pass on Linux (171 and 289). On Windows libc passes (199), and in the job's second attempt libkernel passes 309 of 312: exec_arguments, guest_timed_join_import_libkernel_sys and guest_timed_join_import_libkernel_web fail at their setup in the verify's Windows build (FileNotFoundError starting the title, or copying the libraries they load), with main's code too, and pass in main's own Windows job at 1829def9bf (job). In the first attempt, libkernel's guest_filesystem also aborted, right after it creates its test junctions: its Require(read > 0) after sceKernelOpen(".", O_DIRECTORY) failed while other suite tests removed their folders from the same directory, the Windows directory-listing race that dantdmdarealguy's #12139 fixes. This PR touches no libkernel or filesystem code, the rerun passed it, and main 04fefebe90 passes it 20 runs in a row on both runners (run). The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • 918b1eeb5d, a merge of main 1189ec3003, which brings Amoenus's #6498 (run, validation run).
    • The conflict: ShaderResources::Bind(), where #6498 adds requireGuestBuffers() and this PR adds prepareFaultSlot(). The merge keeps both, the guard first.
    • PrepareDrawBindings merged on its own: #6498's requireGuestBuffers(moved) runs before the early return, and this PR's prepareFaultSlot() after it.
    • This PR's added and removed lines are unchanged.
    • Tests, ×10: the last merge's 50 named tests and agc_driver_sample_multisample_target (#6498's cases), with the tests for the files the merge changes.
      • Linux: 53 run, 53 pass, 0 skip, 0 fail.
      • Windows: 52 run, 41 pass, 11 skip (no Vulkan device), 0 fail.
      • The libc and libkernel suites run 194 and 294 tests on Linux and 224 and 317 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 (VERIFY_VALIDATION=1 on GitHub's Linux runner, llvmpipe (LLVM 20.1.2), Mesa 25.2.8), main 1189ec3003 against this head, the same tests:
      • they pass on both arms;
      • the loader inserted VK_LAYER_KHRONOS_validation 14 times on each, and neither log has was not found;
      • both report only VUID-VkDeviceCreateInfo-pNext-pNext, so the merge adds none.
  • d958699e8b, a merge of main 6a691f69ee, which brings Celegans12's #8105 (run, validation run).
    • The one conflict: the include block of Graphics/src/Recorder.cpp, where #8105 adds DepthSurface.hpp on the line where this PR adds BdaResources.hpp. Both are kept.
    • Merged on their own: seven other files both sides change, BdaResources.hpp/.cpp, ShaderResources.hpp/.cpp, tests/BdaDevice.cpp, tests/BdaResources.cpp and docs/dev/ENVIRONMENT.md. In buildComplete, main's UploadFinish(usesBda, htileClear) sits next to this PR's faultReportOnly constructor calls, and Recorder::finish keeps this PR's BdaResources::NoteFinished.
    • This PR's added and removed lines are unchanged.
    • Tests, ×10: the 42 tests run by agc_driver_bda_device_tests and agc_driver_graphics_tests, the binaries this PR's test files build into, and every ^agc_driver_bda_ test.
      • Linux: 47 run, 47 pass, 0 skip, 0 fail.
      • Windows: 46 run, 39 pass, 7 skip (no Vulkan device), 0 fail. agc_driver_graphics_maps_fallback and agc_heap_mirror_unwatched_import are registered only off Windows.
      • 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 (VERIFY_VALIDATION=1 on GitHub's Linux runner), main 6a691f69ee against this head, the same tests:
      • they pass on both arms;
      • the loader inserted VK_LAYER_KHRONOS_validation 7 times on each, and neither log has was not found;
      • both report only VUID-VkDeviceCreateInfo-pNext-pNext, so the merge adds none.
    • On a cloud Linux machine (lavapipe): the 42 tests pass 420 of 420 runs; ctest -R '^(agc|shader)' 1,084 passed, 75 skipped, 0 failed.
  • 38f1f885ed, oneandonlydean's merge of main 88e804b0a7. The one conflict was Recorder.cpp's include block: this PR's BdaResources.hpp include and main's ReferenceStorage.hpp include, both kept. This PR's diff over main is unchanged. On GitHub's runners (run, on e03545223d, a merge of the same two commits with the same tree), agc_driver_pipeline_journal and the ^agc_driver_bda and ^agc_bda tests ran 10 times with no failure. Linux: 10 run, 10 pass, 0 skip, 0 fail. Windows: 10 run, 2 pass, 8 skip (no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (210 and 310) and on Windows (237 and 331). The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • 972242f204, oneandonlydean's merge of main a4eca2a056. The one conflict was the variable table in docs/dev/ENVIRONMENT.md, where this PR's APS5_NO_SHARED_FAULT_SLOTS row and Gonic0's APS5_NO_SHARED_GDS row from #13159 were added at the same place; the merge keeps both, in alphabetical order. This PR's diff over main is unchanged. On GitHub's runners (run, on e78abd6e7c, our merge of the same two commits with the same tree), agc_driver_pipeline_journal and the ^agc_driver_bda and ^agc_bda tests ran 10 times with no failure. Linux: 10 run, 10 pass, 0 skip, 0 fail. Windows: 10 run, 2 pass, 8 skip (no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (235 and 319) and on Windows (262 and 340). The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.

Checklist

  • Based on main 6a691f69ee (merged in d958699e8b); no other open PR implements the same 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 (none added)
  • Generic behaviour, not specific to one title
  • Depends on: #6498 has merged; #10150 has merged
  • Fixes: none
  • Related: #7047
  • Unblocks: none claimed (memory only; see the Resident Evil Village (PPSA01556) line above)
  • GPUs tested: lavapipe (a Linux machine and GitHub's Linux runner); RADV on an RX 7900 XTX (clairtonmichel's run); NVIDIA GeForce RTX 3070 Laptop GPU (driver 617.42) on Windows (the Resident Evil Village runs); Windows build and tests on GitHub's runner
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4948107370 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8963). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-21T07:38:19Z. --- ### What Every `BdaResources` owns a host-visible fault buffer of `BdaAbi::FaultBufferBytes`: 24,620 bytes, which the buffer pool rounds to 32 KiB. A program uses only part of it: | words | contents | written by | |---|---|---| | 0–7 | the fault report | `record_bda_fault` (image-table faults, unlinked calls, the loop guard) and the rect-list check | | 8–6153 | the written-page record | only programs that store through the BDA table | | 6154 | the SRT guard word | only programs with a guarded SRT read | A buffer lives as long as its owner: while the resource cache keeps a fault-only build, and while an address-based draw is in flight, which the recorder holds until its batch completes. In a Village-shaped bench (`agc_driver_village_draw_cost_tests --cost 20`, lavapipe, `APS5_PROFILE_DRAW=1`, two runs), the fault buffers were 97.7% of the driver's "shader data" host-visible memory: - 189.7 and 198.7 MiB, in 6,071 and 6,359 buffers; - of a host-visible peak of 214.4 and 224.4 MiB. Every one of the 22,000 BDA builds there could write only the report. **The change, in two commits:** 1. **Fault buffers are slots of a per-device arena**, in 512 KiB host-visible chunks at `minStorageBufferOffsetAlignment`. - Each slot is bound with its offset (`ShaderResources::prepareFaultSlot` rewrites only the fault descriptor of the owner's own sets). - An owner notes the serial of each batch it's bound or marked in. The recorder reports each batch once its completions ran (`BdaResources::NoteFinished`). - When no chunk has a free slot, under the GPU lock only, the arena takes back the slots of the older half of the idle owners. An idle owner is one whose last batch finished and whose slot is clean: no unread report, written-page claim or SRT guard. Without the lock the arena grows instead. - An owner that lost its slot takes one again when it's next bound. A slot in use never moves, so every report is read from the slot its shader wrote, and per-draw attribution is unchanged. - `APS5_NO_SHARED_FAULT_SLOTS=1` restores one full buffer per owner (documented in `docs/dev/ENVIRONMENT.md`). 2. **Report-only programs get a 32-byte slot.** - `SpirvFaultReportOnly(words, set, binding)`, cached per module hash, proves that a program reaches its fault buffer only through `OpAccessChain` with constant member 0 and a constant word below 8, used only in loads, stores and atomics. - Any other reference fails the proof and keeps the full slot: a computed index, word 8 or beyond, a copied pointer, the buffer passed to a function, or a module that can't be read. - `prepareAddressBindings` ANDs the proof over every stage. For such an owner, `CheckFault` reads only the report, and `markWrittenPages` and `checkSrtGuard` are skipped: the program can't write those words, and they aren't in the slot. - Report-only and full slots come from separate chunks. - `BdaAbi.hpp` is unchanged and no shader offset moves, so the shader cache isn't affected. The BDA read execution tests have always bound a `sizeof(Abi::Fault)` buffer to read programs. **Fault reports kept exactly:** - **Per-draw attribution:** one slot per owner, never moved while in use. - **Image-table faults and the loop guard:** report words, read and reset as before. - **SRT guard faults:** a guarded program writes word 6154, fails the proof and keeps a full slot. - **The written-page record:** a program with BDA stores writes words 8 and up, fails the proof and keeps a full slot. **Measured, same bench and runs:** | arm | host-visible peak | "shader data" | BDA fault buffers | |---|---|---|---| | main | 214.4 / 224.4 MiB | 194.1 / 203.4 MiB | 189.7 / 198.7 MiB (6,071 / 6,359 buffers) | | commit 1 only | 188.4 / 196.4 MiB | 165.9 / 174.7 MiB | 161.0 / 169.5 MiB (322 / 339 chunks) | | both | **30.4 / 28.4 MiB** | **6.6 / 5.9 MiB** | **0.5 MiB (one chunk)** | - On this bench nearly all of the saving is the second commit's. The buffers belonged to draws in flight, which the first commit's give-back can't take, and its arena saves only the pool's rounding. - The give-back is for fault-only builds the resource cache keeps: rect-list, image-table and SRT-guard builds. Its test covers that case. - The bench's wall times per draw fell too, but they're too noisy on lavapipe to claim. **Resident Evil Village (PPSA01556):** one pair on an NVIDIA GeForce RTX 3070 Laptop GPU (driver 617.42, Windows 11), clocks not held, both arms with `APS5_PROFILE_DRAW=1`, `APS5_LAZY_SHADER_PREPARE=1`, `APS5_NO_GPL=1` and `APS5_HOST_IMPORT_MIB=6400`; 6 min at the static menu, then Yes and 4 min in control. Host-visible "shader data", where the fault buffers are allocated: 27.6 → 18.8 MiB and 24.4 → 15.9 MiB at the menu (after 1 and 5 min), and 12.4 → 2.8 MiB in control. No fault lines in either arm. After the load the two arms took different host-import paths (27,062 imports made without this PR, 44,814 with it). That moves the buffer pool and host copies, not the fault buffers, so total host-visible memory isn't compared here. An earlier pair at the static menu, before the give-back and the 32-byte slots, showed ~20 MiB with and without the change. The last summary line of each arm, in the control scene (without this PR, then with it). Both arms ran with `APS5_PROFILE_DRAW=1`, each line is a single present, and the lines carry no memory fields, so they record the scene the memory figures above come from, not a speed. Their frame times (4.0 s and 8.1 s) aren't comparable: both arms were profiled, and they took different host-import paths after the load (see above): ``` {"commit":"af0821dddb64","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"6400","APS5_LAZY_SHADER_PREPARE":"1","APS5_NO_GPL":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_PROFILE_DRAW":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SUMMARY_EVERY":"1"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","cpu":"AMD Ryzen 9 5900HS with Radeon Graphics","cpu_threads":16,"memory_mib":15776,"title_id":"PPSA01556","title":"Resident Evil Village","content_version":"01.210.000","resolution":"3840x2160","window":{"spec":"summary_every 1","first_present":5458,"ms":4017.622},"interval_start_s":2400.257,"interval_end_s":2404.275,"presents":1,"frame_ms":{"p50":4017.622,"p90":4017.622,"p99":4017.622,"max":4017.622},"gpu_busy_ms_per_present":231.500,"worker_busy_pct":{"queue worker 0x0":88.827,"queue worker 0x38":10.990,"queue worker 0x20":75.535,"queue worker 0x28":82.775},"top_phases_ms_per_frame":{"Driver.Packet":10368.420,"Driver.Packet.memory_wait":6239.427,"Driver.Packet.draw":2859.241,"Driver.Draw":2857.528,"Graphics.Draw":2525.684,"Graphics.Draw.draw_and_resource_release":2503.759,"Resources.Complete":2023.137,"Driver.Packet.dispatch":1190.484},"trace_dropped":false,"trace":""} {"commit":"5f6425ca4a49","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"6400","APS5_LAZY_SHADER_PREPARE":"1","APS5_NO_GPL":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_PROFILE_DRAW":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SUMMARY_EVERY":"1"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","cpu":"AMD Ryzen 9 5900HS with Radeon Graphics","cpu_threads":16,"memory_mib":15776,"title_id":"PPSA01556","title":"Resident Evil Village","content_version":"01.210.000","resolution":"3840x2160","window":{"spec":"summary_every 1","first_present":4832,"ms":8053.336},"interval_start_s":2797.378,"interval_end_s":2805.432,"presents":1,"frame_ms":{"p50":8053.336,"p90":8053.336,"p99":8053.336,"max":8053.336},"gpu_busy_ms_per_present":229.928,"worker_busy_pct":{"queue worker 0x0":94.510,"queue worker 0x38":5.374,"queue worker 0x20":85.585,"queue worker 0x28":90.852},"top_phases_ms_per_frame":{"Driver.Packet":22249.511,"Driver.Packet.memory_wait":11986.929,"Driver.Packet.draw":4459.777,"Driver.Draw":4457.433,"Resources.Complete":4328.588,"Graphics.Draw":4112.876,"Graphics.Draw.draw_and_resource_release":4083.483,"Driver.Packet.dispatch":4041.343},"trace_dropped":false,"trace":""} ``` **Overlap:** checked with `git merge-tree` against every open PR on the same files, on `main` b77bd5880. - Four PRs add code at the same place as this one. Each conflict is a pair of additions, resolved by keeping both: - #8608 (SleglJan) declares `LastRecordIndices` where this PR declares `SpirvFaultReportOnly`, in `ShaderResources.hpp`; - #8380 (Zenodeon) adds a test case where this PR adds its slot helpers, in `tests/BdaResources.cpp`; - #7002 and #6498 (Amoenus) add `requireGuestBuffers` (and #7002 `synchronizeGuestBuffers`) where this PR adds `prepareFaultSlot`, in `ShaderResources.cpp`. Agreed order with #6498: #6498 first ([comment](https://github.com/boykopovar/AnyPS5/pull/8963#issuecomment-6440862252)). #6498 has merged, and 918b1eeb5d merges `main` that way: #6498's native-MSAA buffer guard runs before `prepareFaultSlot()` in `Bind()`, and, with the moved logical ranges, before `PrepareDrawBindings`' early return. - #6636 and #7465 merge cleanly. - #10150 (milescoviello) has merged. This PR's merge of `main` keeps both sides' includes in `BdaResources.hpp`, as agreed on #10150. - #6412 (draft) defers a V# check that reports through the fault buffer. The proof reads each compiled module, so the words its check writes decide whether its programs get a 32-byte slot. It conflicts with `main` itself. - #6947 (Raghav314, draft) and our #7642 (draft) bind the fault buffer per draw in their heap mode. Whichever merges second binds the slot's offset and range there. Both conflict with `main` themselves. - Our draft #8971, which reuses address-based dispatch builds, adds a spare fault record per concurrent use. It conflicts with this PR in `BdaResources.hpp/.cpp`. Whichever merges second takes those spare records from this arena. ### Tested - **`agc_driver_graphics`** (`faultSlotTests`, mock device): - 256 idle cached `BdaResources` hold fewer than 64 slots, and the reclaim count is non-zero; - two of them retaken while in flight survive 64 pressure objects and report their own addresses from one batch; - a fault-only `ShaderResources` reclaimed under pressure takes a new slot on `Bind` and reports its own address, while the build that took its old slot reports its own; - a build whose program can't be read keeps a full slot; - 64 report-only owners share one chunk of 32-byte slots, with neighbours reporting their own addresses; - the real rect-list program is bound 32 bytes and reports its fault. - **`agc_driver_bda_device`** (lavapipe): - the proof accepts the BDA read and fault programs, and rejects store and write programs, a missing binding and unreadable modules; - five hand-assembled modules cover report-word loads, stores and atomics, and rejections for word 8, a computed index, a copied pointer and the buffer passed to a function; - two neighbouring 32-byte slots, dispatched in one batch, each report their own fault. - **Red lines** (each fix hunk reverted at its commit, the test unchanged): - **commit 1, the reclaim:** "256 idle cached BdaResources hold 256 fault slots in 13 chunks (6563 KiB of host-visible memory)"; - **commit 2, the slot size:** "64 report-only BdaResources hold 4 fault chunks with 24620-byte slots", and on the device "two report-only BdaResources did not take 32-byte slots of one fault chunk"; - **commit 2, the plumbing:** "the rect-list check, which writes only the fault report, was bound 24620 bytes of fault buffer"; - **commit 2, without the proof:** "a build whose program could not be read was bound less than a full fault buffer". - **The same four reds at this PR's head cfe73029e2, on GitHub's runners**, each fix hunk reverted on its own there with the tests unchanged, one run of `agc_driver_graphics` and `agc_driver_bda_device` each, with the other tests built from the changed files. Each fails on Linux and on Windows with its line: - reclaim off ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40120908059)): "256 idle cached BdaResources hold 256 fault slots in 13 chunks (6563 KiB of host-visible memory)"; - full-size slots ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40120959137)): "64 report-only BdaResources hold 4 fault chunks with 24620-byte slots", and on Linux `agc_driver_bda_device` also fails with "two report-only BdaResources did not take 32-byte slots of one fault chunk"; - the plumbing ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40121019377)): "the rect-list check, which writes only the fault report, was bound 24620 bytes of fault buffer"; - the proof's result dropped ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40121087658)): "a build whose program could not be read was bound less than a full fault buffer". - In each run `agc_driver_graphics` fails (on Linux its `_maps_fallback` run too), plus `agc_driver_bda_device` where noted; the other tests pass, and on Windows `agc_driver_bda_device` skips without a Vulkan device. The green at the same head is the cfe73029e2 run below. - **The existing BDA, fault, SRT-guard and image-table tests** (31, `agc_shader_srt_read_patching` included) pass ×10, with the same 2 skips as `main`. - **GitHub's runners** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39559324160)): - `agc_driver_graphics`, `agc_driver_bda_device` and `agc_shader_srt_read_patching` pass ×10 on Linux. On Windows (MinGW), `agc_driver_graphics` and `agc_shader_srt_read_patching` pass ×10 and `agc_driver_bda_device` skips without a Vulkan device. The run's other tests, which it picked from the changed files, pass too: 32 run on Linux and 31 on Windows in all. - The libc and libkernel suites pass on both. - With `main`'s code the new tests don't build, because they use the arena's API. The red lines above come from reverting each fix hunk instead. - **CI's Linux job, mirrored** (Ubuntu 24.04, gcc 13.3, lavapipe): 1,776 of 1,782 here and 1,775 of 1,782 on `main` a07e985c8. - The same six network tests fail on both, from that machine's sandbox. - `main` also failed `agc_driver_sgpr_pattern_fill_keys` under load; it passes here, and 10 of 10 alone. - Registration and `check_skips.py` match. - **RADV, run by clairtonmichel** ([comment](https://github.com/boykopovar/AnyPS5/pull/8963#issuecomment-6311108007); RX 7900 XTX, Mesa 26.2.5, Fedora): 872 of the 875 AGC and video tests pass. The other three have known failures on `main` on RADV: `agc_driver_guest_memory_lifetime` (#7784), `agc_driver_tessellation` (#5444, a crash with Mesa 26.2 and later; theirs is 26.2.5) and `agc_driver_image_array_window_past_layer_limit` (the expectation #8969 fixes). Their runs on `main` and with `APS5_NO_SHARED_FAULT_SLOTS=1` weren't posted. - `check_conventions.py` passes, with no comment lines added. - **1c7d058c4f, a merge of `main` 0db47b263d.** The only conflict was two declarations added at the same place in `ShaderResources.hpp`: this branch's `SpirvFaultReportOnly` and `main`'s `ShaderStoresThroughAddresses`, and both are kept. The run linked here before didn't run this PR's tests (its name list matched none of them); the run under cfe73029e2 below covers this merge's code. - **cfe73029e2, a merge of `main` 2b1648419a.** The only conflict was in `tests/BdaResources.cpp`, where this branch's `faultSlotTests` and #8380's `partialHeapImportBudgetTests` were added at the same place, and both are kept. The PR's added and removed lines are unchanged. On GitHub's runners, 10 runs ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40115714460)): on Linux, this PR's tests, `agc_driver_graphics`, `agc_driver_bda_device`, `agc_shader_srt_read_patching`, `agc_device_fault`, `agc_bda_staging`, `agc_driver_bda_reads_shadowed_results` and its `_per_build` run, `agc_driver_image_table_vouch_queued_draws` and `agc_driver_image_table_vouched_lookups`, pass, 9 of 9, and so do the 32 other tests built from the changed files: 41 run, 41 pass, 0 skip, 0 fail. On Windows, `agc_driver_graphics`, `agc_shader_srt_read_patching` and `agc_device_fault` pass and the 6 device tests skip without a Vulkan device: 40 run, 33 pass, 7 skip (those 6 and `agc_driver_host_import_failure_handles`), 0 fail. The libc and libkernel suites pass on both (122 and 204 tests on Linux, 149 and 216 on Windows), run with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. The run linked here before didn't run this PR's tests, so it's replaced. - **Validation layer, `main` against this PR** (CONTRIBUTING's AGC rule), on GitHub's Linux runner (llvmpipe, LLVM 20.1.2; [run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40115779708)), with `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `ANYPS5_NO_SHADER_CACHE=1`, `ANYPS5_REQUIRE_VULKAN=1` and `ctest -V`. The tests are the existing ones that build on `main` too, `agc_driver_bda_reads_shadowed_results` and its `_per_build` run, `agc_device_fault`, `agc_bda_staging`, `agc_driver_image_table_vouch_queued_draws`, `agc_driver_image_table_vouched_lookups` and `agc_shader_srt_read_patching`, with the other tests built from the changed files, once on each tree: 39 run, 39 pass with the change and on `main`. The loader inserted `VK_LAYER_KHRONOS_validation` 7 times on each tree, neither log has `was not found but was requested`, and both report only `VUID-VkDeviceCreateInfo-pNext-pNext`. This PR adds no `VUID-` message. The new cases in `agc_driver_graphics` and `agc_driver_bda_device` don't build with `main`'s code, so this comparison doesn't cover them. - **08392c098f, a merge of `main` facac6a4c5** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40627672507)). Three conflicts, each resolved by keeping both sides: `BdaResources.hpp`'s include block (#10150's `<memory>` and this PR's includes); `ShaderResources.hpp`, where imellag's #11142 removed `MovedWordBuffer` next to this PR's `FaultDescriptor` and `prepareFaultSlot()`, so the merge keeps this PR's members without the removed ones; and `docs/dev/ENVIRONMENT.md`, with this PR's `APS5_NO_SHARED_FAULT_SLOTS` row and `main`'s new `APS5_NO_SINGLE_PASS_COLLECT` text. This PR's added and removed lines are the same, except `#include <memory>`, which `main` now has. The 13 tests named above, with the tests for the files the merge changes, pass 10 runs in a row. Linux: 49 run, 49 pass, 0 skip, 0 fail. Windows: 48 run, 38 pass, 10 skip (no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (166 and 264). On Windows libc passes (194) and libkernel passes 283 of 286: `exec_arguments`, `guest_timed_join_import_libkernel_sys` and `guest_timed_join_import_libkernel_web` fail at their setup in the verify's Windows build (`FileNotFoundError` starting the title, or copying the libraries they load), and pass in `main`'s own Windows job at 1829def9bf ([job](https://github.com/boykopovar/AnyPS5/actions/runs/40627345977/job/122615375186)). The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **92f08cb9c2, a merge of `main` d4cb89300f** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40702290761)). The one conflict was `docs/dev/ENVIRONMENT.md`, where Astronaut10's #11696 adds `APS5_NO_SHAPE_MEMO` on the line where this PR adds `APS5_NO_SHARED_FAULT_SLOTS`; the merge keeps both rows, in order. This PR's other changed lines are the same. The BDA, fault-buffer, heap-mirror, pipeline-store and draw-state tests of this PR's earlier runs ran 10 times with no failure (each runner builds its own set). Linux: 50 run, 50 pass, 0 skip, 0 fail. Windows: 49 run, 39 pass, 10 skip (the Vulkan device tests), 0 fail. Suites: libc and libkernel pass on Linux (171 and 289). On Windows libc passes (199), and in the job's second attempt libkernel passes 309 of 312: `exec_arguments`, `guest_timed_join_import_libkernel_sys` and `guest_timed_join_import_libkernel_web` fail at their setup in the verify's Windows build (`FileNotFoundError` starting the title, or copying the libraries they load), with `main`'s code too, and pass in `main`'s own Windows job at 1829def9bf ([job](https://github.com/boykopovar/AnyPS5/actions/runs/40627345977/job/122615375186)). In the first attempt, libkernel's `guest_filesystem` also aborted, right after it creates its test junctions: its `Require(read > 0)` after `sceKernelOpen(".", O_DIRECTORY)` failed while other suite tests removed their folders from the same directory, the Windows directory-listing race that dantdmdarealguy's #12139 fixes. This PR touches no libkernel or filesystem code, the rerun passed it, and `main` 04fefebe90 passes it 20 runs in a row on both runners ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40709712486)). The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **918b1eeb5d, a merge of `main` 1189ec3003**, which brings Amoenus's #6498 ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40975622266), validation [run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40975747243)). - **The conflict:** `ShaderResources::Bind()`, where #6498 adds `requireGuestBuffers()` and this PR adds `prepareFaultSlot()`. The merge keeps both, the guard first. - **`PrepareDrawBindings`** merged on its own: #6498's `requireGuestBuffers(moved)` runs before the early return, and this PR's `prepareFaultSlot()` after it. - This PR's added and removed lines are unchanged. - **Tests, ×10:** the last merge's 50 named tests and `agc_driver_sample_multisample_target` (#6498's cases), with the tests for the files the merge changes. - Linux: 53 run, 53 pass, 0 skip, 0 fail. - Windows: 52 run, 41 pass, 11 skip (no Vulkan device), 0 fail. - The libc and libkernel suites run 194 and 294 tests on Linux and 224 and 317 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** (`VERIFY_VALIDATION=1` on GitHub's Linux runner, llvmpipe (LLVM 20.1.2), Mesa 25.2.8), `main` 1189ec3003 against this head, the same tests: - they pass on both arms; - the loader inserted `VK_LAYER_KHRONOS_validation` 14 times on each, and neither log has `was not found`; - both report only `VUID-VkDeviceCreateInfo-pNext-pNext`, so the merge adds none. - **d958699e8b, a merge of `main` 6a691f69ee**, which brings Celegans12's #8105 ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/41184266260), validation [run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/41184274578)). - **The one conflict:** the include block of `Graphics/src/Recorder.cpp`, where #8105 adds `DepthSurface.hpp` on the line where this PR adds `BdaResources.hpp`. Both are kept. - **Merged on their own:** seven other files both sides change, `BdaResources.hpp/.cpp`, `ShaderResources.hpp/.cpp`, `tests/BdaDevice.cpp`, `tests/BdaResources.cpp` and `docs/dev/ENVIRONMENT.md`. In `buildComplete`, `main`'s `UploadFinish(usesBda, htileClear)` sits next to this PR's `faultReportOnly` constructor calls, and `Recorder::finish` keeps this PR's `BdaResources::NoteFinished`. - This PR's added and removed lines are unchanged. - **Tests, ×10:** the 42 tests run by `agc_driver_bda_device_tests` and `agc_driver_graphics_tests`, the binaries this PR's test files build into, and every `^agc_driver_bda_` test. - Linux: 47 run, 47 pass, 0 skip, 0 fail. - Windows: 46 run, 39 pass, 7 skip (no Vulkan device), 0 fail. `agc_driver_graphics_maps_fallback` and `agc_heap_mirror_unwatched_import` are registered only off Windows. - 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** (`VERIFY_VALIDATION=1` on GitHub's Linux runner), `main` 6a691f69ee against this head, the same tests: - they pass on both arms; - the loader inserted `VK_LAYER_KHRONOS_validation` 7 times on each, and neither log has `was not found`; - both report only `VUID-VkDeviceCreateInfo-pNext-pNext`, so the merge adds none. - **On a cloud Linux machine (lavapipe):** the 42 tests pass 420 of 420 runs; `ctest -R '^(agc|shader)'` 1,084 passed, 75 skipped, 0 failed. - **38f1f885ed, oneandonlydean's merge of `main` 88e804b0a7.** The one conflict was `Recorder.cpp`'s include block: this PR's `BdaResources.hpp` include and `main`'s `ReferenceStorage.hpp` include, both kept. This PR's diff over `main` is unchanged. On GitHub's runners ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/41417610846), on e03545223d, a merge of the same two commits with the same tree), `agc_driver_pipeline_journal` and the `^agc_driver_bda` and `^agc_bda` tests ran 10 times with no failure. Linux: 10 run, 10 pass, 0 skip, 0 fail. Windows: 10 run, 2 pass, 8 skip (no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (210 and 310) and on Windows (237 and 331). The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **972242f204, oneandonlydean's merge of `main` a4eca2a056.** The one conflict was the variable table in `docs/dev/ENVIRONMENT.md`, where this PR's `APS5_NO_SHARED_FAULT_SLOTS` row and Gonic0's `APS5_NO_SHARED_GDS` row from #13159 were added at the same place; the merge keeps both, in alphabetical order. This PR's diff over `main` is unchanged. On GitHub's runners ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/41492591512), on e78abd6e7c, our merge of the same two commits with the same tree), `agc_driver_pipeline_journal` and the `^agc_driver_bda` and `^agc_bda` tests ran 10 times with no failure. Linux: 10 run, 10 pass, 0 skip, 0 fail. Windows: 10 run, 2 pass, 8 skip (no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (235 and 319) and on Windows (262 and 340). The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. ### Checklist - [x] Based on `main` 6a691f69ee (merged in d958699e8b); no other open PR implements the same 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 (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: #6498 has merged; #10150 has merged - [x] Fixes: none - [x] Related: #7047 - [x] Unblocks: none claimed (memory only; see the Resident Evil Village (PPSA01556) line above) - [x] GPUs tested: lavapipe (a Linux machine and GitHub's Linux runner); RADV on an RX 7900 XTX (clairtonmichel's run); NVIDIA GeForce RTX 3070 Laptop GPU (driver 617.42) on Windows (the Resident Evil Village runs); Windows build and tests on GitHub's runner - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-21 07:38:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-21T07:38:34Z.


This pull request is labeled perf, so it needs the summary line of a capture on main and one with the change, from the same title, scene and machine, as the Performance report form asks. Please paste both aps5-summary.jsonl lines, attach the two traces and add the output of tools/trace_digest.py.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6310706598 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8963#issuecomment-6310706598). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-21T07:38:34Z. --- <!-- pr-labels-perf --> This pull request is labeled `perf`, so it needs the summary line of a capture on `main` and one with the change, from the same title, scene and machine, as the Performance report form asks. Please paste both `aps5-summary.jsonl` lines, attach the two traces and add the output of `tools/trace_digest.py`.
clairtonmichel commented 2026-10-21 08:02:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by clairtonmichel on 2026-10-21T08:02:31Z.


Tested on Fedora Linux (AMD Ryzen 7 9800X3D, RX 7900 XTX, Mesa/RADV).

Clean compile, and out of 875 tests in the AGC/Video suite, 872 passed successfully (99%). However, I caught 3 failures during this run that you might want to look into for this BDA/fault buffer draft:

  • 606 - agc_driver_guest_memory_lifetime (Failed)
  • 614 - agc_driver_image_array_window_past_layer_limit (Failed)
  • 848 - agc_driver_tessellation (SEGFAULT)

Great work on the host memory reduction overall! Let me know if you need any logs re-run for these specific failures.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6311108007 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8963#issuecomment-6311108007). Originally posted by [clairtonmichel](https://github.com/clairtonmichel) on 2026-10-21T08:02:31Z. --- Tested on Fedora Linux (AMD Ryzen 7 9800X3D, RX 7900 XTX, Mesa/RADV). Clean compile, and out of 875 tests in the AGC/Video suite, 872 passed successfully (99%). However, I caught 3 failures during this run that you might want to look into for this BDA/fault buffer draft: - 606 - agc_driver_guest_memory_lifetime (Failed) - 614 - agc_driver_image_array_window_past_layer_limit (Failed) - 848 - agc_driver_tessellation (SEGFAULT) Great work on the host memory reduction overall! Let me know if you need any logs re-run for these specific failures.
EagleBearerYS commented 2026-10-21 08:04:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-21T08:04:40Z.


@clairtonmichel, thanks for running it on the RX 7900 XTX. Two of the three fail on RADV without this PR too:

  • agc_driver_guest_memory_lifetime fails on main on RADV with "guest prefix unmap failed" (#7784).
  • agc_driver_tessellation segfaulted on RADV with Mesa 26.2 and later inside Mesa's nir_opt_varyings (#5444).

agc_driver_image_array_window_past_layer_limit has no report for RADV that I know of.

To tell whether any of them comes from this PR, could you post:

  • your Mesa version;
  • the output of the three tests on this PR's base, main a07e985c8f, built the same way;
  • the same three on this PR's head with APS5_NO_SHARED_FAULT_SLOTS=1, which turns the shared fault buffers off?

If a test fails the same way on main as on this PR's head, it isn't this PR. If it fails only on this PR's head with the shared buffers on, its output line is what we need.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6311145778 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8963#issuecomment-6311145778). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-21T08:04:40Z. --- @clairtonmichel, thanks for running it on the RX 7900 XTX. Two of the three fail on RADV without this PR too: - `agc_driver_guest_memory_lifetime` fails on `main` on RADV with "guest prefix unmap failed" ([#7784](https://github.com/boykopovar/AnyPS5/issues/7784)). - `agc_driver_tessellation` segfaulted on RADV with Mesa 26.2 and later inside Mesa's `nir_opt_varyings` ([#5444](https://github.com/boykopovar/AnyPS5/issues/5444)). `agc_driver_image_array_window_past_layer_limit` has no report for RADV that I know of. To tell whether any of them comes from this PR, could you post: - your Mesa version; - the output of the three tests on this PR's base, `main` a07e985c8f, built the same way; - the same three on this PR's head with `APS5_NO_SHARED_FAULT_SLOTS=1`, which turns the shared fault buffers off? If a test fails the same way on `main` as on this PR's head, it isn't this PR. If it fails only on this PR's head with the shared buffers on, its output line is what we need.
EagleBearerYS commented 2026-10-21 08:06:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-21T08:06:08Z.


@clairtonmichel, one update on the third: agc_driver_image_array_window_past_layer_limit fails on main on RADV too, in the test's expectation rather than in the driver, and #8969 fixes it. If your failing line reads "thread 7 component 0 is 107.000000/255, expected 147/255", it's that one, and it doesn't need the APS5_NO_SHARED_FAULT_SLOTS=1 run. The main run and your Mesa version still help for the other two.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6311172158 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8963#issuecomment-6311172158). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-21T08:06:08Z. --- @clairtonmichel, one update on the third: `agc_driver_image_array_window_past_layer_limit` fails on `main` on RADV too, in the test's expectation rather than in the driver, and #8969 fixes it. If your failing line reads "thread 7 component 0 is 107.000000/255, expected 147/255", it's that one, and it doesn't need the `APS5_NO_SHARED_FAULT_SLOTS=1` run. The `main` run and your Mesa version still help for the other two.
clairtonmichel commented 2026-10-21 08:16:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by clairtonmichel on 2026-10-21T08:16:05Z.


Thanks for the guidance! Here is the data from my setup (AMD Ryzen 7 9800X3D, RX 7900 XTX):

  • Mesa version: mesa-vulkan-drivers-26.2.5-1.fc45.x86_64
  • Regarding the tests: As you mentioned, agc_driver_guest_memory_lifetime and agc_driver_tessellation fail on RADV due to the known upstream issues (#7784 and #5444), and the image array window test behaves according to the known expectation mismatch (#8969).

Everything matches expected upstream behavior on RADV, confirming your shared fault buffer implementation is clean and introduces no new regressions!

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6311348689 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8963#issuecomment-6311348689). Originally posted by [clairtonmichel](https://github.com/clairtonmichel) on 2026-10-21T08:16:05Z. --- Thanks for the guidance! Here is the data from my setup (AMD Ryzen 7 9800X3D, RX 7900 XTX): - Mesa version: mesa-vulkan-drivers-26.2.5-1.fc45.x86_64 - Regarding the tests: As you mentioned, `agc_driver_guest_memory_lifetime` and `agc_driver_tessellation` fail on RADV due to the known upstream issues (#7784 and #5444), and the image array window test behaves according to the known expectation mismatch (#8969). Everything matches expected upstream behavior on RADV, confirming your shared fault buffer implementation is clean and introduces no new regressions!
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!8963
No description provided.