Commit Graph

4163 Commits

Author SHA1 Message Date
7557fe87f4 Keep live VA mappings when mirroring a stream pool 2026-11-27 11:28:10 +03:00
76099a22f6 d3d12: LEONIDA_ASYNC_MIN_BYTES, only large pipelines asynchronous (RT-ASYNC-LARGE-ONLY)
With LEONIDA_ASYNC_PIPELINES=1 every pipeline not built yet has its draws
and dispatches skipped, the small lighting and post programs too, so the
world phase stays black while anything compiles; with it off a submission
waits minutes for each large ray-tracing compute program.

LEONIDA_ASYNC_MIN_BYTES=<n> (with async on): a pipeline under n bytes of
SPIR-V (compute: its module; graphics: all its stages) takes the path of
async off: no record-time request, PipelineCompiles builds it at prepare,
and a compile-helper build waits for its file. One of n bytes or more stays
asynchronous. Decided once per pipeline at create (async_build). Unset, 0
or not a number: every pipeline asynchronous, as before.

Tests: async_pipeline_size_test (parsing and decision);
d3d12_m4_compute --async-small-waits (both pipelines under the threshold,
compile worker held: no job reaches it and every word matches).
Docs: runtime/README.md row, docs/d3d12_vulkan.md, docs/running.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 09:03:28 +01:00
0d61aa9be1 test: a window write-back whose copy faults on another guard's page returns (#2418)
d3d12_title_window_write_back_fault (d3d12_title_va_test --window-writeback-fault) makes the write-back's
copy fault on a page the tracker did not protect itself, the case review asked for: the ring is
write-watched, a title write makes its first page hot (writable, asked about rather than guarded), and
a geometry watch cell over the first 64 KiB, what a geometry view over the same pages arms, makes that
page read-only behind the tracker's back. The next submission's write-back faults there; the handler
reopens the cell and asks every tracker over the address, the writing one too. Without 95d25843e that
tracker took its own SRW lock again on the thread that held it and the submission never returned: a
watchdog thread ends the process with a FAIL line after 20 s. With it the submission returns and the
GPU's words, and the title's own word, are in the pages.

RTX 4070 Laptop, NVIDIA 621.40, Windows 11: passes (8 of 8 runs) with the fix; with the fix's
d3d12_vulkan_device.cpp change reverted locally it fails at the watchdog. d3d12_title_va,
d3d12_title_window_write_back and d3d12_placed_write_back pass either way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 04:32:04 +01:00
2bf19e6908 xgameruntime: LEONIDA_TRACE_XGAMESAVE logs every XGameSave call
With LEONIDA_TRACE_XGAMESAVE=1 the offline XGameSaveImpl logs one
"[rt] xgamesave:" line per XGameSave* and XGameSaveFiles* call: the call,
its handles, container and blob names, sizes and HRESULT, with the
milliseconds since the process started and the thread id. An async call
also logs when begin() schedules its job, when the work runs (and how
long it waited on the queue), when it completes and when the title
collects the result, all naming the title's XAsyncBlock. Blob contents
are never logged. Off by default: a call then pays one relaxed load.

xgameruntime_gamesave_test turns it on through a test hook, writes and
reads a blob (sync and async) and checks the lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 04:28:00 +01:00
e954dc8c16 mesh-serial-waves: a GPU fixture whose waves vote differently; no memory writes in a serial program (work in progress)
ms_w64x_wave_votes: two waves take different branches, each with its own
ballot count (and a v_readfirstlane in the second), and the triangle's
vertices come from threads 0 and 1 of the first wave and thread 64 of the
second, so ms_tri's picture needs both waves to have run their own branch
with their own votes. It passes in the side-by-side form and with
--mesh-serial-waves on an RTX 4080 (NVIDIA 621.24).

A program with a store or an atomic to memory keeps the side-by-side
form, as one with LDS does: its waves could pass each other something.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-27 11:13:58 +08:00
c842321a8f Merge origin/main into placed-defer-no-host-copy (both staged-device checks kept)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gt9hwNPurxyJ9LAfUbNiYr
2026-11-27 03:21:03 +01:00
b2cccb953a compile gate: probes from submissions only, a ring of recent leaves, and a held limit
Review of #2412 (nicoco23, ecox982745):
- A later create leaving hid the earlier one a held probe needs: last_leave_seq_ kept one leave per
  kind, so when A (there when the submission entered) and then B (entered after it) left just before
  the submission came back, B replaced A and the probe was not counted. The recent leaves are now a
  ring of 64, and any leave of the kind, of a create the submission entered beside, within 500 ms
  before it came back counts.
- Presents and idle or semaphore waits passed the gate as probes: they can take seconds on their own
  while the GPU is busy, so a slow present could mark a kind as holding, and quick ones could turn a
  kind off. SubmitTurn takes `probe` (true by default); the presents, vkQueueWaitIdle,
  vkDeviceWaitIdle and vkWaitSemaphores turns pass false. vkQueueSubmit and vkQueueBindSparse probe.
- A kind that holds submissions was waited for with no limit, so a false verdict brought back the
  unbounded gate for the rest of the run. It is now waited for up to LEONIDA_COMPILE_GATE_HELD_WAIT_MS
  (60 s; 0: no limit), after which the creates in the driver are gone past and not waited for again.
  The header comment that said a false alarm "only keeps the bounded gate" is rewritten.

Tests: submit_mutex_test gains both finish orders of A and B, B alone with A still there, a 2.1 s
present that judges nothing, and a holding kind gone past at a 400 ms held limit. All pass (MSVC,
Windows 11). The docs tests pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 02:53:48 +01:00
e5d1a14681 compile gate: a held probe needs the create beside it to have just left
A submission that stays 2 s or more in the driver turned its create kind's gate on (or back on). It
now counts only if it came back within 500 ms after a create of that kind, there when it entered,
left the driver: a submission held behind a create comes back when the create does. On the 4070
Laptop (621.40, 8 GB nearly full) a 36 s submission came back 18 s before the compute create beside
it; counted as held, it re-armed the gate, which then kept the next submission 78 s behind compute
creates. One that is slow with its creates still there is logged (the first 8) and judged nothing.

Tests: the held-probe tests release the create 100 ms before the submission comes back; a new one
checks that a slow submission with the create still there gives no held verdict.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 02:20:24 +01:00
df294dd8a1 rdna2spirv: preserve f16 denormals, NaN payloads, and bit-exact clamp in conversions (SHADER-CVT-F16-DENORM-AND-MODS)
Route v_cvt_f32_f16 through f16_in_bits so SDWA/DPP half selection, subnormals, neg/abs,
and IEEE=0 NaN sign/payload bits are preserved without raw UnpackHalf2x16 flush risk,
and clamp v_cvt_f16_f32 and v_div_fixup_f16 directly on rounded f16 bits via shared
clamp_f16_bits. Verified on RTX 3060 (driver 617.14, native + --wave64-emulate: fixed
first word 0x7FFFFFFF -> 0xFFC4A000 on cs_w32_cvt_f16_mods), 13/13 new semantic tests,
501-module semantic suite (6,385 passed, 0 failed), and 100/100 real corpus shaders
passing spirv-val.

AI-assisted: Codex gpt-6.2-sol + Antigravity gemini-4-neon.
2026-11-26 22:11:21 -03:00
59f14e13c4 device-markers: draws get marker pairs too, and the report names the draw that started and did not finish
With LEONIDA_DEVICE_MARKERS=1 every draw the replay records takes a seq from the dispatch numbering and writes the
VK_AMD_buffer_marker pair: started before its helper passes and rendering scope, finished after the scope ends (the
legacy indirect path inside the caller's scope, which the extension allows). The marker history (now 65,536 items)
keeps each draw's kind and counts, pipeline names, execute, list, command and its place among the draws to the same
targets. The loss and stall reports name the last finished item, the likely hang, the rest in flight and an idle
queue's next one not started, for draws and dispatches alike; a device-fault address is followed by the last draw
each queue started. Tests: the CPU marker test records draws and dispatches and checks the lines; the GPU marker
test writes draw markers outside and inside a dynamic-rendering scope.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 19:40:14 -05:00
cadf43276a d3d12: a title texture tracked again over the same tiles is not read again, and every fill keeps part hashes (RT-TITLE-TEXTURE-WRITE-TRACKED)
Run 60: 80 % of the looks were whole reads, 89 % of them unchanged. index_texture runs at every Map of a
slot-133 texture, at a layout found by a view and at a first naming, and each call re-tracked the texture:
its tiles were released and acquired again (so not armed) and it was named, so the next pass read it whole
although nothing had been written. Tracking again over the same tiles now changes nothing; a texture that
must be read (never filled, or known changed) is touched instead. Fills made outside the refresh (at a
slot-70 view, on the fill worker) now keep part hashes too, so the next written tile is decided by parts
rather than by a whole read. A line every 10 s counts whole reads by why: never filled, no part hashes,
one tile (its part is all of it), every tile written, no tile written.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 19:13:24 -05:00
1e05b59677 Local test merge: readers of GPU-only memory go through the frame table, twins remapped by table (b54413e87)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-26 18:58:39 -05:00
106336a48c Local test merge: LEONIDA_GPU_PROFILE, GPU time per pipeline (293fbeaca)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-26 18:56:33 -05:00
b54413e879 xmem: slot-31 copies onto a paired range make no host call; the host reads and writes those pages through the frame table (RT-MEMORY-MODEL)
Step 2 of the memory model. After step 1 the console queue's CopyPageMappingsBatchX gave a paired GPU-only page its
physical page by table, but still host-mapped the paired CPU page (the "twin") for the D3D12 layer and DirectStorage,
which read and write GPU-only memory there: one unmap plus MapViewOfFile3 per page through Wine's server. In the newest
local world run that was 47% of slot 31's pages and most of its 1.7-2.5 s of mapping per 10 s. By the log every host
remap was such a twin (pages by table minus pages by host equals the twins the title mapped itself, which are kept);
destinations with no CPU pair were none.

Now the twin is a table page too (map_table_page), and the host reaches table pages through their frames:
- src/title_frames.h: xmem's lookup (page -> its section's scratch view, held alive), its peers, monotonic bounds so
  other memory costs two loads, and for_each_part / run_end to split a range into table and host parts.
- xmem: g_table_frames under its own SRW lock (readers never wait behind g_phys_mutex), g_page_tables per physical
  page. A table page is aliased, its alias peers being its physical page's host views (note_mapping keeps them in
  step), so #1867's alias cells guard it where the title's CPU can write it. The title's unmap of a table page now
  tells its readers. transfer_physical pins and notifies table pages too.
- Readers: copy_guarded, texture_memory_readable, readable_page / readable_run_end (stream-pool extents),
  to_host_view, the ShadowPages walk and fill (a table page is read like a read-only page that is not the tracker's,
  clean while its cells are; a block with no host view anywhere is armed on its own cell), the geometry provider,
  the title buffers for vertex and index views, raw sampled surfaces, console value reads.
- Writers: kernel_writes::write and store write the frame and pin its peers; read_file reads into a bounce buffer
  first. DirectStorage goes through these.
- The slot-31 line keeps "pages N by table, M by host remap" and adds the paths behind them.

Not through the table: imports (a table page has no host pages; such buffers are shadows), GPU write-back into a
table page (left out like every aliased page; per-frame write-back is step 6), the LEONIDA_MAP_READBACK diagnostic,
the fsdraw and compute-input probes (host pages only), the batch hook's LEONIDA_SLOT31_CPU_TWIN mirror (not installed
in retail runs), and the title's own ReadFileEx/ReadFileScatter (the title has no CPU mapping there on the console).

Tests: title_frames_test (portable); xmem_test copy_page_mappings_cpu_view (no host view at either page, no host map,
reads and host writes through the frame, a write through the title's own mapping seen, remaps, kept twins, views
replaced once); d3d12_xmem_placed queue_remap_default_route (slot-133 buffers over the GPU-only pages and the twin read
them, a guarded title write through the pool's own mapping and a remap reach the GPU, no host remap).
Linux ctest (llvmpipe) 119/119; Wine suite on the iGPU against main e5a7c8942: no pass-to-fail (432 pass, the same 23
failures).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 18:52:44 -05:00
0dcf650d1c Merge remote-tracking branch 'origin/main' into fix/explicit-lod-bias-moltenvk
# Conflicts:
#	tools/rdna2spirv.py
2026-11-27 00:51:00 +01:00
293fbeacad d3d12: LEONIDA_GPU_PROFILE=1 measures the GPU time of each pipeline from timestamps
A diagnostic, off by default. Each submission on a queue whose family has
timestamp bits gets a query pool, reset once at the start of its command
buffer, and bottom-of-pipe timestamps: after the opening barrier and
bindless upload, before each run of consecutive draws or dispatches of one
pipeline, after a run that another command follows, and at the end. The
difference between two consecutive timestamps is what lies between them
added to the queue's work: a run's GPU time, or "other" when no draw or
dispatch lies between. The results are read on the fence callback once the
submission is done, never waited for, and summed by pipeline under its
stages' ShaderLibrary names (as the pass trace prints them), else its id.

Every 10 s, [rt] gpu profile lines give per frame the compute, graphics
and mesh totals, other work, per queue kind the busy time (measured as
LEONIDA_GPU_LATENCY does) against the timestamped span and the share in
draws and dispatches, and the 20 pipelines with the most GPU time (ms per
frame, share, kind, calls per frame, ms per call).

PSOs register their names with the context when the profile is on, as
they already do for the device-fault report; the device passes the
families' timestamp bits to the context. Off: one test per submission and
per command. On: about 1 us per timestamp on the Raphael iGPU, submit to
idle (vk_gpu_profile_test).

vk_gpu_profile_test runs known dispatches of two pipelines and a draw
through VulkanQueue and checks each pipeline's name, calls, runs, a time
that grows with its loop count, and that the intervals add up to the span.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 18:50:22 -05:00
14d436cf82 d3d12: views and T#s of a texture placed over a render target's memory resolve to the render target's image (RT-TITLE-TEXTURE-WRITE-TRACKED)
f7c3df172 stopped filling such a texture from the title's pages; its own image then held nothing the GPU
drew. A GPU-written texture placed at the address (render target, depth or UAV) now answers first, for
console T#s (bind_title_image) and slot-70 views (place_title_view), when the description fits: the T#'s
extent and samples, and mips and layers within the target's (TitleGpuPlacements::matches), in any format the
target's image takes a view in (its own, a castable one, or one its view list allows). Otherwise the other
texture answers as before, and the reason is counted (format; extent or samples; mips or layers) in a line
next to the refresh's.

Either order at one address: a render target placed over a texture placed first leaves that texture's
registry entry in place and drops its T# bindings, so they bind again, to the target. The ranges GPU-written
textures cover are kept by the resource (DeviceState::gpu_owned), so a texture placed later at the same
address does not take the target's range away; when the target goes, the texture at its address is filled
from memory again and its T#s find it. D3D12 views the title made of the plain resource itself still name
its own image.

Test: d3d12_existing_heap's "view over a render target" (both orders, and the target's release).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 18:50:03 -05:00
ae364461bf rdna2spirv, docs, tests: address #2239 review findings and 1080p precision check 2026-11-26 15:45:23 -08:00
edc3bd5358 Local test merge: no fill over GPU-written memory, uploads at a texture's first descriptor, written parts hashed (f7c3df172)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-26 18:43:47 -05:00
3cc0e9e5f4 Local test merge: rewritten V# halves answered by a waiting record; T#s in the title's 32-bit form wait under our address (d94b6c33b)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-26 18:41:24 -05:00
f7c3df1724 d3d12: a title texture over a render target's memory is not filled from it; textures are read at first use and by their written tiles (RT-TITLE-TEXTURE-WRITE-TRACKED)
Blocks of older frames in run 58: a texture without GPU-write flags placed over the memory of a GPU-written
one (a render target, depth or UAV texture) was filled from the title's pages there. Those pages never hold
what our GPU renders into the target's image, only what the CPU last put there, and every write mark over
them (a write-back of a GPU copy, a neighbour's write in the same tile) re-uploaded those old bytes. The
registry now keeps the CPU-view range of every GPU-written texture (DeviceState::gpu_owned), and a texture
over such a range is not watched or filled by the refresh (index_texture); one already watched stops when the
target is registered. Test: d3d12_existing_heap's "texture over a render target's memory" (fails without
this: the written 64 KiB piece shows in the texture).

Upload at first use: a title texture no descriptor names is not read, uploaded or watched. Its first
descriptor of any kind (a D3D12 view, a slot-70 view, a T# the title wrote into a console heap: all reach
Resource::note_shader_view) queues it, and the refresh before that submission reads it whole and uploads it.
A texture whose descriptors are all gone later stays on the write-driven path (nothing counts them down).

Reads by written tiles: each texture keeps a hash of its part in every 64 KiB tile (TilePieces). When some
of its tiles were written, those parts are hashed in place first; equal, and the texture is unchanged
without a whole read. The watch reports writes per 64 KiB tile (the geometry cells' fault reopens a whole
tile), so a neighbour in a written tile costs its share of that tile, not a read of all of it.

The 10 s line: textures written or new, read whole, found unchanged by their parts, uploaded, named for the
first time, not named by any descriptor (not read), ms a pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 18:41:15 -05:00
d94b6c33b2 d3d12: title-built T#s wait under the layer's texture address and bind to it; a rewritten V# whose range waits takes that answer
Two findings from one world run (every slot records line: 0 refills; fixing slots 18.2 ms a submission).

T#s: the title rebuilds T#s of the layer's textures from 32 bits. The run's unbound T#s name 0x7f0000021400 for the
layer's 0x100021400 and 0x2ef600 for 0x1002ef600 (bits 32-39 clear, 0x7f or 0 in bits 40-47): "its low 32 bits name
a texture of ours that is gone" (291-3,794 a window) and "no title memory and no texture of ours" (270-4,585, low bits
past the last address handed out: textures still to come). They were recorded under that address, while a texture's
arrival is announced at the layer's address, so no arrival ever reached them, and bind_title_image looked them up by
the exact address only. tsharp_texture_key maps such an address outside the title's memory to the layer's texture
address with the same low 32 bits (while fewer than 2^24 were handed out); the T# waits under it, and
bind_title_image takes the texture there when its shape fits (another shape stays unbound, as before).

V#s: about 2,100 rewritten V# halves a submission, 70% resolving to nothing at about 9 us each (the alias table,
the backings, the geometry copies and the title memory walked again, VirtualQuery included), 63% with words seen
before. A waiting record is fixed again by every change that could let it resolve, so while one waits its answer
stands: a rewritten half whose exact range another half of the heap waits for takes that answer
(ConsoleHeapSlotRecords::waiting_answer, one hash lookup; a half that asks for a geometry copy only from one that did,
and not after geometry room was freed since the refresh). To keep answers current, the submission's changes are
applied before the rewritten slots, and the changes noted during the pass (a window a fix made, a buffer another
thread released) are applied to the heap before an answer is taken (sync_slot_changes). The records keep a third
list per range for waiting halves that asked for a geometry copy. The slot records line counts the answered halves.

Tests: d3d12_tsharp_refill_test also writes the texture's T# in the title's two 32-bit forms before the texture exists
and expects both bound at the first submission after it appears, and gone with it. d3d12_unbound_tsharp_rules_test:
the 0x7f form with the texture's shape binds (it expected "no texture"). console_heap_slot_records_test: in the 400
random rounds half the writes take a waiting answer after applying the changes noted so far, and each answer must be
what resolving at that moment gives (a copy that skips applying them fails); the rounds still equal a full
re-resolution. Linux ctest 115/115.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 18:40:43 -05:00
6f5086f2f8 Merge remote-tracking branch 'origin/main' into fix/rdna2spirv-f16-interp-computed-ij 2026-11-26 15:24:47 -08:00
f7b2497303 compile gate: a verdict per kind of create, re-armed by a held submission, and the creates in the driver on a device loss
On NVIDIA 621.40 every probe beside a compute create came back in 0-12 ms,
but a run whose gate those probes had turned off lost the device 9 s later
with a submission held 7.8 s beside a mesh pipeline create, and with the
gate off a vkQueueSubmit sat 54 s in the driver beside a 56 s mesh create
before the device was lost. Graphics creates never passed the gate.

- Graphics creates (mesh included) now pass the gate (PipelineState::build
  through DriverTurn), and CompileTurn carries the create's kind, name,
  trigger and size. The adaptive gate keeps a verdict per kind; a probe
  counts for each kind that had a create in the driver from before the
  submission entered until it came back, a held one against all of them.
- A kind that is off is still timed: a submission that stays 2 s or more
  beside one of its creates turns that kind back on for the rest of the run.
- No submission goes ahead, at the limit or the probe budget, while a create
  of a kind that holds submissions is in the driver, and such creates are
  waited for even if one went past them before the verdict.
- A create never waits behind the submission of the thread that holds the
  submit lock.
- VulkanContext::mark_device_lost logs the creates in the driver (kind,
  program, size, thread, how long, whether submissions wait for them) and
  each kind's gate.

Tested: submit_mutex (new gate_per_kind case; held-verdict cases adjusted;
also under LEONIDA_COMPILE_GATE=1 and =0), MSVC, Windows 11.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 00:19:05 +01:00
fe1980cd88 Local test merge: slot record visits bounded per addition and per submission (67863b3df)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-26 18:08:43 -05:00
67863b3df8 d3d12: slot records: an addition finds the waiting V#s whose base it holds; a record is looked at once an index a submission
One world run with the merged index showed 60,000-135,000 records looked at per submission for 1,300-2,600 slots
fixed again and 130-210 changes. Two causes in ConsoleHeapSlotRecords::touched:

- An addition (an alias range, title memory, a backing) visited every waiting record whose range overlapped it.
  Waiting V#s with large spans (data words that read as V#s of up to 4 GiB into title memory) were visited by every
  addition anywhere inside their span, at nearly every submission, and fixed again to no effect. A V# resolves only
  through an alias range, backing, copy or title memory that holds its base (or a backing that holds its refused
  target), so an addition now visits the waiting records whose range starts inside it; the groups with waiting
  records are kept by start a second time for this, so only those are walked. TitleVaAliases tells title memory as
  the merged range it is now part of (a V# whose base lies in the older part may fit only now), and nothing for a
  commit inside a range it already has.
- A record named by several changes of one submission was looked at once per change. Each group's two lists now
  carry the touched() call that last visited them, so a record is looked at once an index a call at most.

Test: 5,000 waiting halves of 4 GiB; 200 additions inside their spans that hold no base look at none (the previous
index looked at all of them 200 times and fails), one that holds 10 bases looks at those 10; 200 removals over the
same 5,000 resolved halves look at each once. The 400 random rounds against a full re-resolution still pass (slots
fixed again there 81,005 -> 75,919, looked at 133,506 -> 97,952); a copy whose removals skip waiting records fails.
Linux ctest 115/115.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 18:05:08 -05:00
4559529701 Local test merge: texture watch arms uncommitted pages, pinned tiles wait for the write (9aed60a22)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-26 18:01:52 -05:00
9aed60a222 d3d12: title texture tiles over memory not committed yet are armed, and a kernel write in progress is waited out, not read (RT-TITLE-TEXTURE-WRITE-TRACKED)
Run 57 showed 99.9 % of the arms refused, 60,637 tiles not armed and about 8,700 textures looked at per pass
(60-68 ms a pass). The refusals were this watch's own: a tile with any page not committed was refused, so
every streamed texture registered before its memory arrived was named and its arming retried at every pass,
and a texture never filled because its memory was not readable was named again at every pass too.

Now pages not committed are left as they are: xmem's commit or mapping bumps the tile's cell, and the mapping
change makes the textures over it probe their memory again. A texture whose memory is not readable is not
named again until then, except one the title mapped (its pages may be committed under the Map pointer). A tile
pinned for a kernel write is busy: the texture is not read (which uploaded half-written textures at every pass
until the write ended) and is read once the pin is gone. Only a tile whose guard cannot be set is read at every
pass. The log line counts busy looks and arms apart from refusals.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 18:00:13 -05:00
41b46f0dcf Local test merge: descriptor refill on the exact-range index (83d9eee2b)
runtime/README.md: the console-heap rows come from the refill branch, the shadow rows from #1867.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-26 17:47:00 -05:00
83d9eee2bb Merge branch 'descriptor-refill' into slot-records-merged
The T# records, the room lists and the texture and room changes of descriptor-refill now live in the exact-range
index of slot-records-index. src/console_heap_slot_records.h: a third index, by T# address (the exact range
[address, address + 1)), of the same groups with a settled and a waiting list; a texture gone visits exactly the
T#s recorded for its address, a texture added the waiting ones. The records waiting for room (V# halves refused a
geometry copy, T#s refused for a full bindless array) are kept in a list per kind with each record's place, so a
record leaves it in O(1) and room made visits only the records waiting for it. Interface as descriptor-refill
has it (states, set_texture, base, textures, textures_waiting); device code, README rows and both sides' docs kept.
32 bytes a half.

Tests: console_heap_slot_records_test, both sides' cases (60,010-slot release; 300,000 slots in 74 blocks, a
40-byte release looks at 3; 400 random rounds against a full re-resolution; a texture registered looks at the 10 of
60,015 waiting on its address; room changes touch only the records waiting for room); a copy that skips settled
lists on a removal fails. Linux ctest 115/115.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 17:42:43 -05:00
6f5e2ddc29 Local test merge: texture refresh by write tracking, uploads wait on the GPU (8c579b7d4)
runtime/README.md: the sparse arena changed the LEONIDA_IMPORT_BELOW_ARENA row and the texture work removed the LEONIDA_ORDER_TEXTURE_UPLOADS row next to it; the arena's row is kept and the removed row stays removed.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-26 17:38:24 -05:00
04e60ec7cb Local test merge: value waits held until met (458a2805d)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-26 17:37:55 -05:00
458a2805df d3d12_xs: hold console value waits until met; release only when nothing else can make progress
A list value wait (wait32/wait64) that is not met at submission holds its queue until memory meets it. The fixed
200 ms timeout, LEONIDA_VALUE_WAIT_TIMEOUT_MS and the 4 ms demotions are removed (in Linux world runs 14-63 gates a
run timed out with the writer's value not there yet).

A held gate goes without its value only when nothing else can make progress (releaser idle, no title
ExecuteCommandLists in progress, nothing of the pump's running on the GPU; work the layer holds behind a wait is not
running, asked through the new rt::d3d12::fence_signal_submitted), and then only: in a cycle (at once), at a present
queued behind it (VIctory-Belobug-AMD's rule, queue/behind.rs step, queue.rs release_held), or when the title has made
no queue call for 2 s; every gate goes at device loss. src/list_value_progress.h (portable) replaces
list_value_wait_budget.h. Each release is logged with gate, queue, wait and reason; released waits met later are
counted. stop() drops gates it leaves shut so they no longer hold their queues.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 17:37:42 -05:00
9807c5ec24 d3d12: console heap T#s wait on their texture's address and are fixed when it appears; no T# retries
A title-written T# that found no texture went on a retry list that every submission tried again, round robin, for
500 us (LEONIDA_CONSOLE_RETRY_US). World runs had up to ~35,000 waiting, 200-550 retried per submission, and every
retry counted again as a T# "naming no texture" (1.56 million in 27 log windows of one run). A bound T# whose texture
went never came back unless the title rewrote its slot.

The per-slot records of RT-VSHARP-SLOT-RECORDS now hold T#s too (src/console_heap_slot_records.h): the exact base
address and bound / waiting / waiting for room, with an index by that address. Texture changes go on the same change
list: note_image_address, a GPU placement added and a streamed texture published (texture_added), forget_image and a
placement removed (texture_gone), freed bindless entries (texture_room), each also at the other view of pool memory.
The next submission fixes exactly the T#s naming the address. A V# refused a geometry copy for lack of room is fixed
again when geometry copies are freed (geometry_room, GeometryViews::free_generation), closing the gap A1 left.

"No texture at the T# address" is counted in "unbound T#s by reason" by what the address is: title memory, a texture
of ours that is gone, low 32 bits naming one of ours (same shape / other shape / gone), or none. The slot records
line gives T#s recorded, waiting, fixes left waiting and refills.

Removed: retry_console_slots. LEONIDA_CONSOLE_RETRY_US applies only to the opt-in GPU heap pass now; slots deferred
by LEONIDA_CONSOLE_FIX_US are fixed first at the next submission (fix_deferred_slots).

Tests: console_heap_slot_records_test (T# and room cases), new d3d12_tsharp_refill_test (the last of 60,001 waiting
T#s samples its texture at the first submission after it appears; its T# leaves the hash table when it goes),
d3d12_unbound_tsharp_rules_test (address classes). Linux ctest 115/115 (llvmpipe); Wine suite (clang-cl, iGPU RADV)
425 pass / 24 fail, against test/three-fixes 425/23: d3d12_tsharp_refill new and passing, xmem (known flake) the
only pass->fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 17:36:24 -05:00
3c3c502902 Local test merge: #1867 finished, aliased shadow pages guarded (4f364c857)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-26 17:35:12 -05:00
a3404f5a41 compile gate: probe once the waits of the last 10 s add up to 2.5 s, whatever the watchdog does (LEONIDA_COMPILE_GATE_PROBE_MS)
The adaptive gate never probed in two runs because no single wait reached
the 15 s limit: on NVIDIA 621.40, 80 waits of 3-7 s back to back (90 s in
all) kept the title's main loop from reporting for 30 s and its watchdog
ended the run; on an RTX 4060 with the watchdog kept kicked the limit was
0, so nothing could probe, and 459 waits of up to 2.9 s took 155 s by
t=202 s.

Until a verdict is in, a submission now also goes ahead once the waits at
the gate in the last 10 s, its own included, add up to
LEONIDA_COMPILE_GATE_PROBE_MS (2500 ms). A budget over a window rather
than a shorter per-wait limit, because it also counts many short waits and
a single wait reaches it as soon as a 2.5 s limit would; before the
verdict the gate stops the queues for at most about a quarter of any 10 s.
On a driver that holds submissions (630.20) the first probe enters after
2.5 s instead of 15 s and loses the device if the create stays 10 s more;
the held verdict (still 2 s, inside those 10 s) ends the early probes and
leaves only the per-wait limit, so that is one probe per run.

The limit and the budget no longer depend on the title's watchdog. Only
LEONIDA_COMPILE_GATE_WAIT_MS=0 (the budget then defaults to 0) or
LEONIDA_COMPILE_GATE=1 (no limit by default, never probes) waits however
long the creates take.

Tested: submit_mutex (new gate_probe_budget case; also under
LEONIDA_COMPILE_GATE=1 and =0, with the watchdog variables set, and with
LEONIDA_COMPILE_GATE_WAIT_MS=0), MSVC, Windows 11.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 23:34:54 +01:00
fb1260d91d Local test merge: sparse arena with signed V# offsets (9d46dd647)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-26 17:34:49 -05:00
2c443ff1ec Local test merge: remaps by table update (8f606046f)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-26 17:34:44 -05:00
8f606046f4 xmem: slot-31 page copies onto a paired GPU-only range are table updates, not host remaps (RT-MEMORY-MODEL)
The console queue's CopyPageMappingsBatchX goes through xmem's range callback in a retail run. It host-mapped every
destination page of a paired GPU-only range twice: the GPU-only page and its CPU twin. Each map is a VirtualQuery, a
placeholder split and a MapViewOfFile3/UnmapViewOfFile2, which are wineserver round trips under Wine. All of it ran on
the render thread under g_phys_mutex, which DirectStorage's page transfers take too. A local world run spent 3.9-6.0 s
mapping per 10-12 s.

Nothing on the host reads a GPU-only address of a paired range:
- the D3D12 layer, DirectStorage and the texture refresh read the CPU twin (title_gpu_views::to_cpu);
- the runtime reads a page by number through its section's scratch view (host_page);
- the title's CPU never touches the range (PAGE_NOACCESS on the console).

So such a page now gets its physical page in g_mapped and g_table_pages alone, with no host view, as the console edits
GPU page tables only. The twin is mapped as before, and so is a destination with no CPU pair: an independent-pages
range (LEONIDA_SLOT31_RUNS), whose pages are read where they are.
- A view the title mapped there itself is unmapped once when a copy lands on it.
- unmap_range_locked drops table pages in its range, so the title's own unmap or release clears them.
- A table page is not one of its physical page's host addresses (no note_mapping, no alias peer). It can be neither
  written nor guarded on the host, so a twin plus a GPU-only page is no longer "aliased" for the slot-133 shadows and
  the geometry watch.
- A table update raises title_memory_map::changed and geometry_writes::notify(replaced) for the GPU-only address, as
  a host remap did. A remap changes bytes, not what a V# resolves to, so the slot-record change list is not involved.
- The periodic slot-31 line gains "pages N by table, M by host remap" (slot31_mapping_counts).

Tests (Wine):
- xmem_test, test_copy_page_mappings_cpu_view: no host view on the GPU-only range; one host remap per page, not two;
  a copy from a GPU-only page finds what its table entry holds; a page the title mapped there is replaced by a table
  entry; the title's unmap clears the table.
- d3d12_xmem_placed, queue_remap_default_route: it read the GPU-only pages directly (the old behaviour). It now reads
  them through a slot-31 copy and checks that they have no host view.

Wine suite on the iGPU: 425 pass / 23 fail, the same as main e5a7c8942, nothing changed. Linux ctest on llvmpipe:
115/115.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 17:33:58 -05:00
134a1d17ff d3d12: console heap slot records index exact ranges; a change looks only at the slots it overlaps (RT-SLOT-RECORDS-EXACT-INDEX)
The records' two indexes kept each V# half in a bucket per power-of-two span class and 64 KiB-or-larger block,
and a change visited every entry of every bucket it reached, plus resolved halves for an addition that only
re-fixes waiting ones: 82,000-472,000 slots looked at per submission for 2-15 changes and 1,450-3,150 slots
fixed in the busiest world windows of one run, 4.4-13.4 ms a submission.

Now each index holds the halves by their exact range: halves naming the same range share a group with a resolved
and a waiting list, each half keeping its place in its list (a move or a removal is O(1), no stale entries, an
empty group goes). Groups are ordered by start per power-of-two class of their length; a query searches each
class in use once and walks the groups starting less than one class length before the change. A change looks at
exactly the halves whose range overlaps it (an addition: the waiting ones only); the groups compared besides are
those that start within one class length before it and end before it, one comparison each and no slot. 20 bytes
a half (was 24), plus a group per distinct range. Interface and device code unchanged.

Test: 300,000 slots of 16 bytes packed into 74 blocks of 64 KiB; a 40-byte release looks at the 3 it overlaps
(the bucketed index looked at the whole block and fails), by source it also finds a 1 MiB range starting two
blocks earlier, a moved slot leaves nothing behind, and an addition over all of them looks at the 1,000 waiting.
The 400 random rounds against a full re-resolution still pass (entries looked at 792,825 -> 133,506 for the same
81,005 slots fixed); copies that skip large ranges or the waiting lists on a removal fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 17:33:42 -05:00
2e16339cd0 d3d12: the title texture refresh looks only at textures whose pages were written, not at every texture's bytes (RT-TITLE-TEXTURE-WRITE-TRACKED)
Before every submission (at most every 16 ms, and not at all when a view held the registry), the refresh hashed
every mapped or stale texture and a round robin of the rest (sampled, a full hash every sixth pass), within
byte and time budgets that could split the planes of one video frame over passes.

Now each title texture filled from memory is watched through the geometry watch's cells: its 64 KiB tiles, at
its CPU view and every other address xmem maps them at, are armed read-only; a write faults once per tile, and
the fault, a mapping change or a kernel write's opening queues the tile (geometry_writes::WriteQueue, new). The
refresh, at every submission and with the registry waited for, takes that queue and reads only the textures over
the written tiles (TitleTextureWatch, src/title_texture_watch.h), arming them again before the read; a texture
nobody wrote costs nothing. A tile that cannot be armed (not committed, pinned, no fault handler) names its
textures at every pass: the one fallback. A fill whose full hash equals the last one uploads nothing. A slot-70
view no longer hashes its texture: it fills only one never filled or known changed.

Removed with the hash pass: LEONIDA_TITLE_TEXTURE_PERIOD_MS, _CHECK_KB, _FILL_MB, _FILL_MS,
LEONIDA_TEXTURE_HASH_BUDGET_US, LEONIDA_TEXTURE_SWEEP_BUDGET_US, LEONIDA_TITLE_EVERY_BUDGET_US,
LEONIDA_TITLE_VIEW_REFRESH_MS and the async mode LEONIDA_TEXTURE_REFRESH_ASYNC (its worker pass, first-use
fills, mapped list and range index). A line every 10 s counts passes, textures looked at, uploaded, unchanged,
written tiles and arms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 17:25:15 -05:00
5a984952b4 d3d12: title texture uploads wait for earlier work on the GPU, never on the CPU, and are never skipped (RT-TITLE-UPLOAD-GPU-ORDER)
A title texture upload waited on the CPU, with the submit lock held, for all work submitted on every queue, at
most 250 ms, and skipped the write when that work was not done. World frames take longer, so changed textures
(the planes of a video frame among them) arrived late or out of step, and the submitting thread stalled up to
250 ms per upload (the 200-277 ms maxima of the textures phase in world runs).

The staged transfer now waits for that work on the GPU: write_staged_title_image hands it every queue timeline
value submitted so far. Every such value is already submitted, and console waits whose signal is not submitted
live in QueueHolds, so the GPU wait cannot deadlock. The upload slots are reused once their transfer is done
(looked up, not waited for), and new ones are made while all are in flight. Every title fill goes through this
upload, so the host-copy path for title textures (write_host_texture, its bounded wait and
LEONIDA_ORDER_TEXTURE_UPLOADS) goes. As before, the transfer is submitted on the primary queue before the
submission whose before_execute runs the refresh, and the other queues wait for it on the GPU, so that
submission's draws sample the new texels.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 17:22:16 -05:00
b882b245fb compile gate: adaptive by default, off once submissions come back quickly with a create in the driver
With the bounded wait, the three submissions that went ahead on NVIDIA
621.40 came back from the driver in 11, 1 and 0 ms with the create still
there, but consecutive long creates made submissions wait the full 15 s
again and the title's watchdog still ended the run.

Every submission that enters the driver next to a create the gate went
past at the limit is now a probe. Two that come back in under 250 ms, at
least 1 s apart, with that create still in the driver turn the gate off for
the rest of the run; one that stays 2 s or more keeps it on. Both verdicts
are logged once. Two probes a second apart, because on 630.20 back-to-back
creates take and release the driver's lock and one submission could slip
in between; the second costs no extra wait. LEONIDA_COMPILE_GATE=1 gates
always without probing (and compute builds keep holding the submit lock),
=0 has no gate. The README row now says what =1 does again.

Tested: submit_mutex (new gate_adapts case; also under
LEONIDA_COMPILE_GATE=1 and =0), MSVC, Windows 11.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 23:13:26 +01:00
62be3fa189 compile gate: a submission waits at most 15 s for creates in the driver, then goes ahead (LEONIDA_COMPILE_GATE_WAIT_MS)
The gate keeps vkQueueSubmit out of the driver while a pipeline create is
in it (on NVIDIA 630.20 a submission that entered during a long compute
create waited 10 s in the driver and lost the device). The waiter holds the
submit lock, so every queue stops behind it: on an RTX 4070 Laptop (NVIDIA
621.40) one compute create stayed in the driver for over 54 s during the
story load and the title's 30 s hang watchdog ended the process.

A submission now goes ahead after LEONIDA_COMPILE_GATE_WAIT_MS (15 s by
default; 0: no limit). The creates in the driver then hold no later
submission back; creates that enter afterwards are waited for again. On
630.20 that only gives up creates over 25 s (15 s here plus the driver's
10 s), which the watchdog ends anyway. With the watchdog kept kicked
(LEONIDA_TITLE_WATCHDOG=0 and LEONIDA_TITLE_WATCHDOG_KICK) the default stays
no limit. The log names each submission that goes ahead and how long it then
spent in the driver. The README row, which still described the gate as
opt-in, now says it is on by default.

Tested: submit_mutex (new gate_wait_limit case), MSVC, Windows 11.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 23:07:38 +01:00
9d46dd6475 d3d12: V# bases as signed offsets when every module sign-extends them; a sparse arena only then (RT-MEMORY-MODEL)
RADV puts sparse buffers 64 TiB above ordinary ones, so with the sparse arena of the previous commit every geometry
copy and title-window block lay below heap_base and TitleBufferWindows::allocate refused it (it accepted only a
positive offset below 2^47). Shaders translated since 2026-11-24 sign-extend a V#'s 48-bit base and say so in their
index entry (vsharp_base_sign_extended), and RADV hands out every address from one 2^47 half of the 48-bit space, so
any block is within reach of heap_base as a signed offset.

- shader_library.h: VsharpBaseCensus counts the marker over every loaded module; signed only when all have it.
- The device reads V# bases signed when the census says so (or with LEONIDA_IMPORT_BELOW_ARENA=1, as before). The
  import refusal still follows that setting alone. One line logs the census.
- create_arena: the arena is sparse only with signed offsets; otherwise one allocation, and one line says why.
- TitleBufferWindows::shader_reachable replaces the positive-only check. The first failure of each Vulkan call while
  making a block, and the first block refused for its address, are logged.
- rebase_title_vsharp sign-extends a base it already rewrote below heap_base.
- device_arena_memory (for tests); cs_user_data.comp reads V# bases sign-extended, as translated shaders do.

Tests: d3d12_title_va_game_device and d3d12_geometry_views_game_device (d3d12_title_va_test --game-device: the
device the game makes, with the arena's bind queue); geometry_views_test (shader_reachable at the measured RADV
addresses and the range edges); shader_library_test (the census). Wine suite on the iGPU: 429 pass / 23 fail against
425 / 23 on main 8bc59a74c, nothing pass to fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 17:03:39 -05:00
4f364c857b test: an alias added after the shadow's cells were armed is guarded too (RT-SHADOW-ALIAS-GUARD)
check_aliased_guard covers the addresses known when the cells are first armed.
This covers the later case: the page is guarded at A and B, then reported at C
as well, with the cells' mapping moved at every address as xmem's note_mapping
does once the peers are updated. The next submission must ask for the other
addresses again and guard C, so a write through C faults and is copied at the
submission after it. Without the re-ask in ShadowPages::update_aliased, C stays
writable and the write through it is never copied.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 16:58:49 -05:00
df92abca8e Merge main e5a7c8942 into shadow-aliased-guard (#1867)
One conflict, runtime/README.md: this branch rewrote the LEONIDA_SHADOW_ALIAS_MS
row, main (#2163) added the LEONIDA_SHADOW_KEEP row after it. Both rows kept;
the keep row's "aliased" now reads "aliased while they can't be guarded at every
address", since aliased pages are no longer copied without a sign of a write.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 16:55:04 -05:00
011d446c32 Merge pull request #2408 from aslan2142/dispatch-width-counters
indirect clamp: count dispatch records by width and log them (RT-INDIRECT-DISPATCH-COUNTERS)
2026-11-26 22:45:14 +01:00
9da604f3f5 d3d12: the GPU address arena binds its memory in 2 MiB blocks as allocations need it (RT-MEMORY-BREAKDOWN-AND-SPARSE-ARENA)
The arena was one allocation of its whole size, made at start: with LEONIDA_ARENA_MB=4095 a world run used about
0.8 GB of it (peak end about 1 GB) and held 4 GiB of Resizable BAR memory. Where the device can, the arena is now a
sparse buffer: LEONIDA_ARENA_MB bounds the address range, and memory is bound as it is used.

- src/arena_backing.h (new): the backing units. A unit is one VkDeviceMemory, mapped once, bound over whole 2 MiB
  blocks. An allocation no larger than a block stays inside one block; a larger one takes whole blocks of its own
  (the free-block map's keep-out, footprint and alignment). A unit is bound before the first allocation in it is
  handed out, and when its last allocation is released it is pending with the release's retire ticket; it is unbound
  and freed only once completed_retire_ticket() has reached that ticket. An allocation in a pending block revives it.
- The CPU reaches the arena through one accessor, DeviceState::arena_host(offset, bytes): one table read, null with a
  rate-limited line for a range without memory. Callers that name an offset they do not hold (write_arena_value,
  read_arena, the fsdraw probe) use ArenaBacking::with_host under its shared lock; copy_destination and
  known_view_heap use offset_of. arena.mapped is gone, so every former `arena.mapped + offset` was converted.
- Binds go to a queue nothing else uses (pick_arena_bind_queue: RADV's sparse-only family, or a sparse family with
  a queue to spare) and are waited for there, so a bind never sits behind a submission that waits for a fence the
  CPU signals later. The device asks for that queue at creation.
- Unbinding is safe because: arena_release records submitted_retire_ticket() + 1 (as defer_destroy), so the
  submission being recorded is covered too; reclaim_arena() runs at the start of ExecuteCommandLists, reads
  completed_retire_ticket() before taking the arena lock, and unbinds only units whose ticket has completed; the
  table entries are cleared under the exclusive lock before the memory is freed. An unbound range reads as zero
  (residencyNonResidentStrict is required), never a fault.
- A D3D12 heap in the arena lends its unit's memory (at the heap's place in the unit) to reserved resources' tiles;
  Heap::offset() keeps the arena VA.
- Without sparse buffers, strict residency, a sparse address space as large as the arena, or a queue to spare
  (llvmpipe), one allocation backs the whole arena as before, through the same accessors. No new setting.
- The arena line at release gains `GPU address arena: bound N MiB now (peak P, U units of 2 MiB blocks, sparse)`;
  the mem-probe breakdown's arena `bound` is the bound bytes.

Tests: arena_backing_test (CPU, fake driver): placement never crosses a unit, binds shared per block, unbinding
waits for the ticket, revival, a random workload whose bound bytes equal the blocks live allocations touch, bind
failure, the one-allocation arena, the bind queue choice. arena_sparse_gpu_test (a real device, 77 without sparse
binding): a 256 MiB arena with 40 MiB allocated has 44 MiB bound; CPU writes are what the GPU reads; released blocks
stay bound while a submission that reads them is in flight and are unbound (reading zero) once it completes; a bind
made while the work queue is blocked completes. Both are new (fail to build on main).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 16:44:41 -05:00
359ba968d5 indirect clamp: count dispatch records by width and log them (RT-INDIRECT-DISPATCH-COUNTERS)
#2230 bounds a dispatch record by the device's maxComputeWorkGroupCount instead of 65 535. Nothing said how wide
the title's dispatches are, nor when a device's own limit still cuts one (llvmpipe allows 65 535 in x; RADV 2^32 - 1),
which its review asked for. The title's tile passes ask for 67 440 groups in x at 2560x1440 (found in the
VIctory-Belobug-AMD fork of VIctory, crates/victory-gpu/src/indirect.rs; no code of it is used).

- indirect_clamp.comp: stats words 12-15 count dispatch records that run wider than 65 535 groups in x, the widest
  x that runs, those cut at the device's limits (and still running), and all of them.
- vulkan_indirect_clamp.h: the counters, read with the others (16 words a slot, words 8-15 zeroed before the pass),
  and a line every 10 s while dispatch records are clamped: `indirect clamp dispatch: N records, W wider than 65535
  groups in x, widest x X, C cut at the device's limits (x x y x z)`.
- indirect_clamp_spv.h regenerated from the .comp as its header says (glslangValidator 16.6.0).
- docs/d3d12_vulkan.md section 4.7: the device's bound per dimension (it still said 65 535), the line, and the test.

Tests: indirect_clamp_test's cases 6b and 6c check the counters (70 000 x 1 x 1: wider than 65 535 where the device
runs it, cut at its limit and counted where not). tests/test_indirect_clamp_telemetry.py checks the new atomics.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 16:43:28 -05:00