Skip to content

feat(agc): resolve table samplers through device image keys - #13928

Open
Celegans12 wants to merge 150 commits into
boykopovar:mainfrom
Celegans12:feat/agc-device-table-samplers
Open

Celegans12 wants to merge 150 commits into
boykopovar:mainfrom
Celegans12:feat/agc-device-table-samplers

Conversation

@Celegans12

@Celegans12 Celegans12 commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

What

Stacked on #10193; please review the sampler-table changes and merge resolution.

Resolve ordinary table S# values through per-use device image keys containing all four raw sampler words. Preserve correlated and separate T#/S# indices; retain sampler owners and generations through recorder completion. Mixed consumers keep their existing CPU path.

Unsupported sampler keys produce explicit faults without CPU fallback. Keep at most 64 diagnostic details of 512 bytes and one suppression record per table; retry and capacity behavior remain separate. Device image ABI 4 is unchanged. The combined sampler shader-cache layout uses format 76 and invalidates older entries.

Continues Celegans12's local work with fable-void's interface/key/hash/ring credit preserved. Runtime-only S# addresses are in #13929; #12904 validates ordinary samplers and #12980 specializes direct-image minimum LOD. The combined-stack scan reports 65 other shared-line or export overlaps, including #13929 and the request/cache-format branches; 139 conflicting branches could not be compared. Reconcile shared changes as those PRs land.

Tested

Based on main 096c455 plus #10193; merges cleanly with 9090972. Windows 11 / MinGW-w64 GCC 15.2.0, Release with -DBUILD_TESTING=ON and SPIR-V Tools: 27 focused serializer, shader, image-table, sampler and heap cases passed three times on NVIDIA RTX 3080 Laptop / 610.62 with validation 1.4.363. Two additional refusal-limit and retry cases passed three times. No VUIDs or skips. GPU tests include filtering, LOD bias, poison and recovery.

Ubuntu 24.04 WSL / Mesa 25.2.8 llvmpipe / LLVM 20.1.2, validation 1.4.363: 14 cases passed three times and 15 heap-dependent cases skipped. No VUIDs. Userfaultfd write protection was unavailable, so the same-texture sampler-refresh subcase did not run. The earlier native Linux sampler-owner release failure remains unverified.

Not tested: macOS, native Linux descriptor-heap execution, titles/FPS or console behavior. The parent title-scale cache-growth report remains unresolved.

Checklist

  • Based on current main; 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
  • Generic behaviour, not specific to one title
  • Depends on: feat(agc): serve lane-keyed, pointer and runtime image-table columns #10193
  • Fixes: none
  • Unblocks: PPSA26344 Ghost of Yōtei (PPSA26344) #675
  • GPUs tested: NVIDIA RTX 3080 Laptop, 610.62, Windows 11; Mesa 25.2.8 llvmpipe / LLVM 20.1.2, Ubuntu 24.04 WSL
  • AI-assisted: yes

Raghav314 and others added 30 commits October 25, 2026 02:33
Co-authored-by: Yunus Shaikh <75296019+EagleBearerYS@users.noreply.github.com>
…pair

Load a released resource plan instead of treating the stage as planless, and on the first mixed retry drop reused per-draw stages so they rebuild in GPU mode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…them per use

A GPU-mode stage's shader data, flattened SRT and image table map reuse the ring span written for the same words while the batch still holds its chunk, so a repeated draw or dispatch points at the table already in the heap. [gpu-heap] reports ring spans written and kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…and slots are unchanged

writeHeapStage skips validating, patching and copying the shader data words when the guest words and user data match the previous write, the stage's slots are current and the span is still held. APS5_VERIFY_GPU_HEAP recomputes the words and fails if they would differ.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ap under APS5_PIPELINE_STATS

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n the heap

Ring spans stay held while their chunk was not re-entered: a kept span
reopens its chunk for the batch, and the ring skips chunks a batch still
reads from. The [gpu-heap] line counts expired spans.

Image detiles in heap mode push the tiled buffer address and index a
storage view slot that the texture releases when it is destroyed, so they
bind no descriptor set.

[rescache] gains the fast/full revalidate time split and why storage
keys fail the fast proof.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A storage owner the sweep drops last can be a StorageTexture whose
release frees its view slots through the heap; dropping it under the
heap mutex deadlocked. The sweep now hands such owners out and they are
released once the locks are gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s on the heap

A storage image whose keys moved since its upload (a fast clear over a
surface uploaded uncompressed) no longer sends the revalidation to the
full walk: the image's own refresh applies the clear and the fast proof
runs again, as for foreign pending images. The refresh proof tests get
their own ctest entry and cover the path.

CMASK clears in heap mode push the CMASK and error buffer addresses and
index the target's view slot instead of binding a descriptor set. The
heap registry mutex outlives static destruction, so a storage image
released at exit can still free its view slots.

The heap draw test replays the first texture draw after another texture
churned the slots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The memo keys mix every user data word, so a title whose user data moves
each frame fills its 16384 keys within seconds; clearing it then sent
every heap stage of the next frame through a full walk and materialize at
once (20 ms frames every few seconds in Minecraft Dungeons II). A full
memo now becomes the previous generation, and a hit there moves the entry
back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… too

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A relocated copy of a cached draw dropped ring, ringAttributes, ringFlat
and ringBindings, so a heap stage hitting it ran without per-draw heap
words and drew with the donor's template data (Hades II black flicker).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
buildRingWords cleared the stored ShaderData words, so a ring hit fell
back to the template's words past the user-data prefix; it now copies the
current user words over the stored ones.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rotating the two-generation memo destroyed the whole previous generation
(up to 16384 keys of captures and words) on the draw thread, a 16-20 ms
heap_direct stall every few seconds in MC D2. Each insert now frees two
old entries, so the old generation is empty before the next rotation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…PIPELINE_STATS

Per-call time of the draw stage's preparation, heap stage call, walk memo, walk, materialize and finish on
the queue worker, and of the resource template find and build, slot mapping, stage data and buffer
address writes on the committer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cost line

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…its key

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An indirect dispatch with USE_THREAD_DIMENSIONS stores its thread limit in
the ShaderData words at record time, which heap stages keep in a ring span,
so these dispatches were kept off the heap. The limit now goes into the
dispatch's ring span: the stage takes a fresh span before its data is
written and drops it afterwards, so a kept span that other dispatches read
never changes. The ring takes transfer writes for the copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ces too small for its slots

The sampler heap held 256 samplers, an eighth of what D3D12 allows, so
scenes with many samplers swept it early. It now holds 2048, which fits
NVIDIA's sampler heap beside its embedded sampler range. A device whose
resource or sampler heap cannot hold the slots no longer enables the heap
and takes the per-draw path, instead of failing at the first heap use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…es the per-draw path

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…and buffer back in classic descriptor mode

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tor heap

agc_driver_heap_draw_sample_heap, _nogpl_heap, _full_heap and
_full_heap_pipelined, and agc_driver_pipeline_journal_gpu_heap set
APS5_GPU_HEAP and then require the heap to take the draw's stages, to
refuse a capped heap or to put a compute stage in GPU mode. On a device
where DescriptorHeapEnabled() stays false (no VK_EXT_descriptor_heap, or
one without maintenance5, room for the heap's slots or enough push data)
none of that can happen, and they failed instead of skipping. They now
exit 77 with a "skipped, the device lacks VK_EXT_descriptor_heap, ..."
line there, and run as before on a device with the heap.

(cherry picked from commit 0a01340)
A run with APS5_GPU_HEAP recorded its pipelines in the same journal as a
run without it, so each mode replayed the other's records: those failed
at the pipeline layout check, and they took places in the replay limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the descriptor heap on, buffers are reached through buffer
addresses, which have no Coherent buffer array and no 64-bit view. GLC
loads and stores became plain 32-bit accesses, so a compute shader that
polls a queue slot another workgroup writes never saw the write and the
GPU hung (RoboCop: Rogue City at the splash, Xid 109).

GLC dword accesses through a buffer address are now device-scope atomic
loads and stores, and GLC two-dword accesses use one 64-bit atomic as the
storage-buffer path does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r cache invalidation

A program with GLC or DLC accesses that invalidates the vector caches
reads the whole guest buffer array as Coherent on the storage-buffer
path, so its loads without GLC see other work-groups' writes after the
invalidation. Through buffer addresses those loads and stores stayed
plain. They are now device-scope atomic loads and stores in such
programs, as GLC accesses already are.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Dec 2, 2026

@ligmaSec ligmaSec left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trial merge onto c1601e56d5 conflicts throughout the device table, recorder, and shader resource stack. For the sampler-specific delta, retain correlated and independent T#/S# indexing and verify that the sampler owner survives a recorded batch after table replacement. A single-frame sample can pass while a slot or generation is reused too soon. Please rerun device-table and fallback cases together on the resolved stack.

AI-assisted: yes.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* build docs needs rebase Conflicts with main, rebase needed shader core/shader unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.