Skip to content

DXIL: fix compact SGPR liveness for RMW/CMOV SALU and Wave32 masks - #2604

Closed
real-alponzo wants to merge 195 commits into
xcl-dev:amd-devfrom
real-alponzo:amd-dev/fix-compact-sgpr-liveness
Closed

real-alponzo wants to merge 195 commits into
xcl-dev:amd-devfrom
real-alponzo:amd-dev/fix-compact-sgpr-liveness

Conversation

@real-alponzo

@real-alponzo real-alponzo commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Fixes two SGPR liveness bugs in amd-dev's compact DXIL micro-block emitter (crates/xcl/src/gpu/dxil/compact.rs):

  1. Conditional-write and RMW SALU ops dropped from use / killed in def: inst_sreg_scc_use_def only treated S_CMOVK_I32 as a conditional write. In rdna2_spec.rs, S_CMOV_B32, S_CMOV_B64, S_ADDK_I32, S_MULK_I32, S_BITSET0_B32/B64, and S_BITSET1_B32/B64 declare SDST with input: false, output: true, so predecessor micro-blocks could elide storing SDST to its alloca slot and feed stale/zero data into the successor.
  2. Wave32 64-bit VALU mask writers over-killed s[v + 1]: VALU mask writers (V_CMP_*, V_ADD_CO_*, etc.) declare size: 64 in rdna2_spec.rs, but in Wave32 (!wave64) they only write the low SGPR and leave s[v + 1] intact.

What is in it

  • Thread lw.wave64 into compute_live_out and inst_sreg_scc_use_def in crates/xcl/src/gpu/dxil/compact.rs.
  • Treat all S_CMOV* as conditional writes (add SDST to u, omit from def) and S_ADDK_I32 / S_MULK_I32 / S_BITSET{0,1}_B{32,64} as read-modify-write (add SDST to both u and def).
  • Clamp def width to 1 SGPR for non-S_* 64-bit mask outputs when !wave64.
  • Add unit test cmov_and_rmw_salu_read_sdst_and_wave32_valu_keeps_hi_sgpr in compact::liveness_tests.

Tested

  • Hardware: Intel Core i9-9900K, 32 GB RAM, AMD Radeon RX 6800 (16337 MiB VRAM, RDNA2, driver 32.0.21045.29003), Windows 11 Pro build 26300, rustc 1.100.0, DXC 1.9.2602.17.
  • cargo test -p xcl --lib gpu::dxil::compact: 12 passed, 0 failed, 0 ignored, 0 skipped.

Not tested

  • NVIDIA or Intel GPUs, wave32-only hardware, or Linux/Wine.

Regression run

xcl-smoke v1
commit: e1d84b7d9153f86a97d2ec5d209d196046fc0bea
gpu: AMD Radeon RX 6800
title: 6ca5cab7
seconds: 60
exit: 0x0
frames shown: 1499 (PresentX 1499)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13951 MB
xcl-smoke v1
commit: 6a0bb5b4f294b0729771ed457af1f96c01f5c06b
gpu: AMD Radeon RX 6800
title: 6ca5cab7
seconds: 60
exit: 0x0
frames shown: 1540 (PresentX 1540)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14734 MB
xcl-smoke v1
commit: 281d8f0c73b9024a00609b5974e44accfa17c659
gpu: AMD Radeon RX 6800
title: 6ca5cab7
seconds: 60
exit: 0x0
frames shown: 1520 (PresentX 1520)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14742 MB

AI use

  • Antigravity (Gemini 4 Neon): audited amd-dev compact.rs liveness, implemented the fix and unit test, ran the tests and paired scripts/smoke.ps1 runs, and drafted this PR description.

isaacwingate and others added 30 commits November 25, 2026 07:22
pso_async means a graphics pipeline still being built to go on with its
stand-in, which draws nothing, while a worker builds it; only compute
pipelines are waited for (a skipped dispatch would leave its outputs
unwritten). But graphics_bound and ExecuteIndirect called resolve_wait,
which waits for the build - and builds it on the title's thread when no
worker has started it. With lazy pipelines that is every graphics
pipeline's first draw.

On an NVIDIA GPU the retail title of #505 had its threads held 1 - 5 s
per draw in the driver's compiler as its world loaded: 25 graphics binds,
33.2 s in all within 25 s (counted with #899's log), and its hang
watchdog ended the run. A test report on #889 (RTX 4080) found a title
thread held in bind::execute_indirect -> resolve_wait at the abort.

Draws and ExecuteIndirect now take their pipeline with resolve_for_bind:
a graphics one still being built goes to the workers and the draw uses
its stand-in (ExecuteIndirect skips, as it already did for a pending
one); a compute one is waited for as before. With this, the same world
load logged no graphics wait.

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

On the console a physical page mapped at several addresses is one page. XCL
keeps a page at one address at a time and copies it when the title maps it
elsewhere (`move_away`), so the other addresses go stale; a retail title maps
its streamed pages into a pool, into the CPU view of a 24 GB reservation and
into that reservation's GPU view (#1031).

`kernelx::sections` is the base for real aliasing: a block of physical pages
is one pagefile-backed SEC_RESERVE section, and a page is mapped as a view of
its 64 KiB slice into a placeholder (MapViewOfFile3 with
MEM_REPLACE_PLACEHOLDER). Every view of a slice is the same memory and a page
takes commit once, when it is committed through any view. Unmapping leaves a
placeholder for the next view. Ordinary reserved memory (write-watched if
asked) can replace part of a placeholder and go back to one.

Nothing calls it yet. Measured in a standalone program on Windows 11 26200
over 200 000 pages: map 2.2 us, unmap 2.75 us, commit 0.9 us a page.
GetWriteWatch refuses a range that holds a view (error 87), and one call
cannot span two neighbouring reservations either.
The upload of title memory to video memory (`d3d12x::sparse`) and the
textures kept in step with title memory learn what the CPU wrote from the
write watch, and a view of a section (`kernelx::sections`) cannot be
write-watched: GetWriteWatch refuses any range that holds one.

`kernelx::guards` keeps the views of a physical page read-only. The first
write through any of them faults; a vectored handler makes that view
writable, notes the page and lets the write go on. `take_dirty` hands over
the pages of every view of each page written – a write through one view is
a write to all of them – and guards those views again before their bytes are
read, so a later write is caught again and an earlier one is in what is read.

Kernel calls do not fault into the handler, they fail: `lazy::ensure`, which
XCL already calls before a kernel call or its own code writes title memory,
opens the guards there first and counts the write. A view committed by the
lazy handler is writable and counts as written. Both take no lock until a
view has been watched.

Nothing watches a view yet.
… fault

A guarded view of a physical page (`kernelx::guards`) is read-only until it
is written. Code of XCL's own that writes there faults into the guard and
goes on, but a kernel call does not fault: ReadFile into such a view fails.
`lazy::ensure` opened the views first, yet the submit thread's `take_dirty`
could guard them again before the write – between DirectStorage's check of
its destination and the copy, or before the kernel wrote a ReadFile buffer.

`guards::open` now returns `Opened`, which keeps its views writable until it
is dropped; `take_dirty` uploads a pinned view but does not guard it again,
and the end of the write counts as a write. `lazy::ensure` returns it and its
callers hold it across their write: the routed ReadFile for a synchronous
read, and the destination checks of DirectStorage and the CPU-side
bottom-of-pipe writes. An overlapped ReadFile writes after the call returns:
its views stay open until its OVERLAPPED is no longer STATUS_PENDING, which
`take_dirty` reads without faulting (the title may free it once done). A
retail title reads 271 MB that way into the CPU view of its 24 GB
reservation 8.5 s after start.

`guards::written` counts a page as written through all its views when XCL
writes it by page number.

Nothing watches a view yet, so nothing changes without views.
…s mapped at

Without it XCL keeps a physical page at one address at a time and copies it
when the title maps it elsewhere; the console shows the page at every
address it is mapped at. A retail title maps its streamed pages into a pool,
into the CPU view of a 24 GB reservation and into that reservation's GPU
view (#1031).

With `XCL_PAGE_ALIAS=1` (`kernelx::alias`):
- a block of physical pages is a section (`kernelx::sections`) with a view
  of its own, through which XCL reads and writes pages by number
  (DirectStorage); the title never maps a page there;
- the title's reservations of 64 KiB pages with no commit (its CPU view, GPU
  view and pool) are placeholders, and a page mapped there is a view of its
  slice, guarded (`kernelx::guards`) so that a write through one view is
  uploaded at all of them; `title_textures` adds those pages to what the
  write watch found;
- a page mapped anywhere else (a placeholder region the title made in a
  sparse window) is moved there and back with its bytes, as before.

Pages are committed on first use as before (`kernelx::lazy`); whether a page
is committed is a bit per page: asking Windows walked the rest of a fresh
block, and a title mapping 100 000 new pages one at a time took 20 s longer
to its first frame.

Measured in a traced run of a retail title: 3 blocks (11 360, 2 960 and
99 776 pages), 131 072 map calls in 150 s, nearly all single pages into its
plain reservations, none at a page's home, no commit inside them.
…GPU-view page shows

Queue method #31 (#29 of the older layout) maps pages of the title's
memory into GPU views; it was a stub. Its batches are now decoded and
checked against the batch count and the pool, and each 64 KiB page of
a GPU view records the pool page it was given and the physical page the
title had mapped there (kernelx::mirrors). A bad call records nothing;
releasing a view drops its pages.

XCL keeps a physical page's data where it was mapped last, and the
title maps most streamed pages into the CPU view behind the GPU view
too, so `mapped_source` answers where that page is now (`page_now`),
else the pool page itself. Each title mapping is remembered per address
(Away::title), written once the page is in place and forgotten when the
reservation goes; a page freed while its allocation lives is no longer
looked for (Away::freed).

Nothing reads the record yet: textures are unchanged; the queue logs its
counts. (#1031)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`mirrors::decode_batches` checks and decodes one call of the queue's
CopyPageMappingsBatchX into (GPU-view page, pool page or unmapped) pairs;
`apply_batches` records them as before. No change in behaviour: the next
commit maps the decoded pages for real when physical pages alias.
The queue's CopyPageMappingsBatchX maps pool pages into GPU views; on the
console a GPU-view page then shows the physical page mapped at its pool page
at the time of the call. #1055 decodes the calls and keeps a record of them;
with physical pages aliasing (`kernelx::alias`) the GPU view is a reservation
of views, so the decoded mappings are made for real: each GPU-view page
becomes a view of the physical page mapped at its pool page now, or is
unmapped (kind 2, or nothing mapped at the pool page). Textures in the GPU
view then read the page at their own address (`title_textures` prefers an
address with a physical page mapped), and a write through any view of the
page is uploaded at all of them.

Without the switch nothing changes: the call is recorded as in #1055.
Each chained dispatch made a scratch buffer for all its groups and kept it until the allocator's reset. A retail title's 176 split programs need 187 KB a group (median), 3 GB for 960x540 pixels in groups of 8x4. At most XCL_SPLIT_SCRATCH_MB (256) of groups now run at once, each piece adding the slab's origin to the group ids, and the chains recorded on one list share the buffer.
In a pixel shader EXEC holds helper lanes (s_wqm), and on a primitive's
edge the first lane of EXEC is often one. v_readfirstlane read that lane.
An RDNA2 driver (RX 6700 XT, 32.0.21045) gives 0 for everything a helper
lane holds once a WaveReadLaneAt ran inside a loop, quad reads included.
A loop whose state the console's compiler carries in a vector register
(v_mov v, s ... v_readfirstlane s, v) then read 0 back on each pass and
ran to the loop budget: a retail title's volumetric light pass took
seconds per draw at its world start and Windows reset the GPU (#675).

v_readfirstlane now reads the first lane of EXEC that is live
(ballot(true), per half in the wave32-in-64 form) when EXEC has one, and
the first lane of EXEC as before when it has none. The value is the same:
the console's compiler reads the first lane of a value equal in every
lane, or of a lane it then removes from EXEC (a waterfall loop).

The new GPU test draws that title's list-loop shape on two triangles
sharing a diagonal. Without the change, on the RX 6700 XT, 69 of 1024
pixels run the loop 65 536 times (the budget) with wrong results; with
it, none, and at most 16 passes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
raylitebull and others added 9 commits November 26, 2026 01:03
sparse::State::queue is a D3D12_COMMAND_LIST_TYPE_DIRECT queue, but
take_readback_job created its pooled allocator and command list as
D3D12_COMMAND_LIST_TYPE_COPY. Submitting a COPY command list to a
DIRECT queue immediately triggers DXGI_ERROR_INVALID_CALL (0x887a0001).

Create ReadbackJob allocators/lists as D3D12_COMMAND_LIST_TYPE_DIRECT
matching State::queue, and skip returning/resetting a ReadbackJob if its
fence wait times out so an in-flight allocator is never reused early.

Assisted-by: Antigravity (Gemini 4 Neon High)
…sync

Implement indirect Draw/DrawIndexed safety caps (#408) and eliminate
per-draw CPU lock contention and heap allocations across command-list
recording and descriptor lookups (#395):

- Indirect draw caps (device_x.rs, bind.rs): track Draw/DrawIndexed
  command signatures in DRAW_SIGS (RwLock) and guard indirect draw
  argument buffers via hoisted PRELUDE_DRAW_GUARD_* (or inline
  GUARD_DRAW_ARGS_* when prelude hoisting is blocked), zeroing any
  record with verts == 0, instances == 0, verts >= 2^23 (8,388,608),
  or verts * instances > 2^26 (67,108,864) using overflow-safe u32
  arithmetic. Opt-out via XCL_INDIRECT_DRAW_GUARD=0 or
  XCL_INDIRECT_GUARD=0. Indirect dispatch guards already enforce
  <= 2^22 total groups with X > 65,535 folding into Y.
- Lock contention & per-stage bind cache (bind.rs, list_x.rs):
  - Shard bind::STATES across 64 Mutex shards and switch command
    signature tables (ROOT_SIGNATURES, DISPATCH_SIGNATURES,
    DISPATCH_ONLY, DISPATCH_MESH_SIGS, DRAW_SIGS) and list_x::MIRRORS
    to RwLock so parallel recording threads do not serialize.
  - Zero-allocation stack [u32; KERNEL_SGPRS] io builders (fill_io_gfx,
    fill_io_compute, fill_io_two_pass), zero-allocation little-endian
    Set*Root32BitConstants, reusable dummy_table_p when all root args
    fit inline, and idempotent Set*RootSignature preserving io_cache
    and Vec capacity.
  - Cache per-list heaps_ensured, lazily cached vram_io_dev, and
    pso_abi_cache (skipping repeated pso_async/real/list_x/GLOBAL
    lookups on consecutive draws with the same PSO).
  - Fix list_x::skip_redundant_pso_bind so bind_abi re-binding an
    already-active resolved PC PSO hits the cache instead of
    re-emitting SetPipelineState + DRED markers on every async PSO.
- Reusable dirty-page bitset & descriptor lookup (list_x.rs,
  console_heap.rs, real.rs):
  - Replace per-draw Vec<bool> in list_x::copy_written with a reusable
    thread-local Vec<u64> bitset and word-wise run scanning.
  - Keep console_heap::HEAPS sorted for O(log N) partition_point
    lookups, add single-lock slot_pair for copy_console_slots,
    zero-refcount global_*_heap_raw accessors, and smallest_failed
    allocation short-circuiting on full shared heaps.

Assisted-by: Antigravity (Gemini 4 Neon High)
Break any active 256-slot InlineGuardBatch on graphics draws
(DrawInstanced, DrawIndexedInstanced, DispatchMesh, graphics
ExecuteIndirect) and mark prelude_blocked + close inline_guard on
Enhanced/UAV barriers (uav_barrier_x and UAV resource_barrier_x) so
memory-writing graphics shaders never race with a pre-draw indirect
guard batch or hoisted prelude (#424). Also gate test-only indirect
draw limit constants with #[cfg(test)] for zero warnings.

Assisted-by: Antigravity (Gemini 4 Neon High)
Complete Win11 scheduling hardening in kernelx/host/real:
- Export guest SetThreadPriority in kernelx.rs and floor guest priorities
  below THREAD_PRIORITY_BELOW_NORMAL (IDLE / LOWEST) to BELOW_NORMAL
  unless XCL_PRIORITY=0, preventing Windows 11 hybrid E-core starvation
  of title streaming/background threads while leaving internal XCL
  pso_async workers (calling win32 directly) untouched.
- Add winmm timeBeginPeriod(1) alongside NtSetTimerResolution(finest, 1)
  in kernelx::fine_timer(), and add idempotent restore_fine_timer() called
  on normal exit (host.rs) and forced/timed exit (real::end_title) so both
  timer-resolution requests are cleanly released on shutdown.
- Add unit tests covering priority flooring (pure + live guest hook) and
  idempotent timer-resolution restoration.

Assisted-by: Antigravity (Gemini 4 Neon High)
…ze deferred submits

Give graphics and compute pipelines independent 12 s per-frame wait windows (XCL_PSO_FRAME_BUDGET_MS, default 12000 ms; 0 = skip immediately, off = disabled). Builds run on prioritized wanted xcl-pso-* workers so title threads always wake when a frame's window expires; once spent, remaining unready draws or dispatches for that kind return the stand-in for the current frame and retry with a fresh window on the next frame instead of stalling PresentX into title render watchdogs or dropping fast cold graphics draws permanently. Also mark deferred submits wanted immediately in need_by_submit so DXC/big-compile gates and preload workers prioritize them right away.

Assisted-by: Antigravity (Gemini 4 Neon High)
…ure caches (#2578)

Adapt two cache-safe stability fixes cleanly onto origin/amd-dev (bf02341):
- #2577 (real.rs, shaders.rs): record the chosen adapter's PCI vendor ID
  in driver_cache::note_vendor() and disable on-disk .pso driver blobs on
  AMD (0x1002) unless XCL_PSO_DISK_CACHE=1, avoiding device removals from
  stale 954-byte driver cache stubs written before a crash/kill (#2512).
  Adds driver_cache::tests::blobs_are_kept_on_disk_unless_they_are_references.
- #2578 (title_textures.rs): return all retired resource pointers from
  Table::retire_range() so retire_overlapping() evicts LAST_CONTENT and
  STREAM_RECHECK for every retired texture (not only placed unmap targets).

Assisted-by: Antigravity (Gemini 4 Neon High)
…access (#2582)

Fix #2582 (0xc0000005 CPU write AV inside sparse UMA windows on buffers
backed by OutsideBufferTable / sparse::alloc_vram_only):
- place_at_title_address stored alloc_vram_only's uncommitted sparse VA
  (holes = 0xFFFF, MEM_RESERVE only) in UMA_BUFFERS, so GetGPUVirtualAddress
  and Map handed that uncommitted VA back to the title. When the title later
  CPU-wrote through it (e.g. clearing a 128x0x5c0 table), Windows raised
  0xc0000005.
- Mark alloc_vram_only 64 KiB pages with kernelx::lazy::mark (0 upfront CPU
  commit, GPU-only buffers keep holes = 0xFFFF and never clobber UAV writes)
  and unmark + MEM_DECOMMIT them cleanly in free_vram_only.
- When the title first CPU-touches a page, kernelx::lazy::commit commits it
  and queues it via sparse::note_lazy_commit (without locking sparse::STATE
  inside the VEH); before_execute, readback_now, readback_after_execute, and
  decommit_range drain LAZY_COMMITS to clear entry.holes without touching
  to_zero so only CPU-written 4 KiB pages upload to VRAM.
- In real::res_map, call kernelx::lazy::ensure(p, bytes) before readback_now
  so Map() on a lazy sparse buffer commits pages before VRAM->CPU copy.
- Add regression test lazy_commit_clears_vram_only_holes_without_clobbering_to_zero.

Assisted-by: Antigravity (Gemini 4 Neon High)
…ts, and keep split whole builds async

Eliminate the remaining multi-second stalls observed past the 12 s per-frame pipeline wait window on cold/warm world frames:
- Track in-flight wall-clock waits (`active_waiters` / `active_since`) in `pso_async::FrameWaitBudget` so staggered concurrent title threads share one hard wall-clock ceiling per kind per frame instead of each getting a fresh 12 s window (applied to both `FRAME_BUDGET_GFX`/`FRAME_BUDGET_CS` and `FRAME_WAIT`).
- Skip deferring pending compute dispatches to submit in `list_x::defer` when `XCL_PSO_WAIT_MS` is set (#2581), when the current frame's compute wait window is already spent, or once 16 deferred segments have already been allocated on the current frame (prevents 512+ deferred segments and command-allocator/RAM churn).
- Never compile `Chain::whole()` synchronously on a title/submit thread inside `dispatch_chain::dispatch` when scratch allocation fails under memory pressure or missing backing allocator: kick off `start_whole_async()` and return an error so the dispatch is skipped cleanly until the background whole build finishes, matching `whole_nonblocking`.

Assisted-by: Antigravity (Gemini 4 Neon High)
inst_sreg_scc_use_def now treats all S_CMOV* as conditional writes and
S_ADDK_I32/S_MULK_I32/S_BITSET* as read-modify-write on SDST, and clamps
Wave32 VALU 64-bit mask defs to 1 SGPR so live s[v+1] slots are not killed.

Assisted-by: Antigravity (Gemini 4 Neon)
@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), head merged with current main:

  • cargo test -p xcl --lib: the parallel run aborts (0xc0000409) and the --test-threads=1 rerun finishes with 10 real failures (1528 passed / 10 failed / 27 ignored):
gpu::dxil::kernel::dispatch_chain_native_wave64_builds_whole
gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier
gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu            (f32 rounding wave32: 0x3f800000 vs 0x3f7fffff)
hle::d3d12x::bind::tests::two_pass_binds_set_the_shared_view_heap
hle::d3d12x::list_x::tests::a_dispatch_with_a_pipeline_still_building_waits_at_the_submit
hle::d3d12x::list_x::tests::a_put_off_dispatch_runs_at_the_submit_when_its_build_outlasts_the_wait_budget
hle::d3d12x::list_x::tests::bitset_runs_emit_exact_contiguous_page_ranges   ((0,130) vs (0,128))
hle::d3d12x::real::big_compile_tests::giant_driver_compiles_have_their_own_lane
hle::d3d12x::title_textures::tests::title_bytes_are_used_in_place_when_all_are_readable
hle::kernelx::tests::physical_home_without_sparse_windows_uses_coherent_window

Note the branch carries ~19 commits on top of main (stacked work incl. the frame-wait-window, sparse lazy-commit and texture-cache changes), so the failures may belong to an earlier layer rather than the compact-SGPR fix itself — but the merged head does not pass as it stands.

— Devin

@DarkPanda69

Copy link
Copy Markdown

NVIDIA wave32-only run (listed as untested), plus an RX 9070 XT: the new test passes on both, and nothing else changes against amd-dev in the direct-DXIL GPU suite.

Head 281d8f0 applied on amd-dev b5c0275, debug, Windows 11 Pro 26200, XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu:: --test-threads=4 on amd-dev and with the PR, card chosen with XCL_ADAPTER:

amd-dev this PR
RTX 3060 (Ampere, 32-lane waves only, 32.0.16.1088) 748 passed, 4 failed, 20 SKIPPED 749 passed, 4 failed, 20 SKIPPED
RX 9070 XT (RDNA4, 32.0.32029.2010) 746 passed, 6 failed, 4 SKIPPED 747 passed, 6 failed, 4 SKIPPED

On both cards, the only result change is the new cmov_and_rmw_salu_read_sdst_and_wave32_valu_keeps_hi_sgpr (ok), with no new skips. All the failures are the same on amd-dev without this PR:

Not tested: Intel, Linux / Wine, a title.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

@oni-swr

oni-swr commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

merge-check
base: 7c795f5 (amd-dev)
head: 281d8f0
merge: clean (merge commit 122c5a106d31fb6d65058063dede600782750ac6, compact.rs auto-merged)
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> merge: 1803 passed, 17 failed, 48 ignored, 4 tests printed SKIPPED. Base (same machine, same command): 1802 passed, 18 failed, 48 ignored, 4 SKIPPED. The only differences are the PR's new test (passes) and hle::d3d12x::list_x::tests::the_mirror_sync_copies_only_the_pages_the_title_wrote, which failed on the base and passed on the merge (unrelated to compact.rs). The other 17 failures are the same on the base and on the merge (e.g. gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1, gpu::dxil::kernel::dispatch_chain_native_wave64_builds_whole, e2e test_title_, offline_pipeline_is_reused_by_a_second_process): baseline failures, not caused by the PR.
review: read the whole diff (+66/-9, compact.rs only). none found. S_CMOV* now read and keep their destination, S_ADDK_I32 / S_MULK_I32 / S_BITSET{0,1}B{32,64} read it and write it, and a Wave32 non-S op with a 64-bit SGPR output kills only the low SGPR; compute_live_out / plan pass lw.wave64. Every change makes liveness more conservative (more uses, fewer or equal defs) except the Wave32 narrowing, which matches Wave32 hardware semantics. Remaining sources: a Wave32 S
op with a 64-bit output still counts both SGPRs as written (unchanged). The new test covers CMOV/RMW/Wave32 V_CMP but runs only the decoder-level use/def masks, no shader output.
performance: none by default at run time: the change is plan-time liveness analysis on u128 masks. More live registers can only keep a few more SGPRs alive in compacted programs; not measured.
verdict: safe to merge
hardware / tool and model: AMD Radeon RX 7800 XT (RDNA3), driver 32.0.31035.1003, Windows 11 Pro build 26200, Rust 1.100.0 MSVC, debug build; tool and model: Claude Code (Claude Sonnet 5.5)

@thehollowedone

thehollowedone commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Releasing my merge-check claim: current amd-dev 7c795f5 already contains this PR's patch as a523305. The stable patch ID of a523305 and head 281d8f0 is the same: 66fdab5b2e7e6ba2f98b9664209e5b6789ddabbf. A local git merge --no-commit --no-ff of the head into that base completed cleanly with zero file changes; a523305 is an ancestor of the base.

This PR can be closed as already applied on amd-dev. I did not run the build or suite for this no-op merge. AI use: Codex (GPT-6.2 Sol) compared the exact commits and trial merge.

@throny

throny commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

merge-check claim
head: 281d8f0

@throny

throny commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

merge-check
base: 7c795f5 (amd-dev)
head: 281d8f0
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> nothing to compare: the merge changes no file. (The run of this identical-to-base tree ended early with 0xc0000409 in the library test binary. On this NVIDIA card the amd-dev suite is noisy: the base alone gives 1804 passed, 16 failed, 48 ignored, two tests (list_x the_mirror_sync_copies_only_the_pages_the_title_wrote, present compositor_releases_root_sig_and_rejects_invalid_planes) fail in some runs and not in others, and in 2 of 5 runs today the library test binary ended with 0xc0000409, one of them a tree identical to the base.)
review: the whole change is already on amd-dev: commit a523305 (same subject) is an ancestor of 7c795f5, the PR's diff reverses cleanly on the branch, and a trial merge changes nothing. The test it adds is on the branch already, so an earlier count of it as a new passing test was the branch's own test.
performance: none.
verdict: not yet: nothing to merge; already in amd-dev through a523305, so this PR can be closed.
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read). An NVIDIA card: it says nothing about AMD driver behaviour, so a check from an AMD tester is the one that counts for that.

Prime1997 pushed a commit that referenced this pull request Nov 29, 2026
… stores

The compact form lowers each class of identical blocks once, but a block
only joins a class when everything in it matches, and every class stores
all SGPRs and SCC it wrote back to their slots. In large console
programs the same buffer / SMEM / image access sits in many blocks with
different ALU around it, so its long lowering was emitted once per block.
On large programs (64 blocks or more):

- a memory instruction that occurs more than once becomes a micro-block
  of its own, lowered once for all its occurrences; pure no-ops
  (s_nop, s_waitcnt*, s_clause, ...) are left out, and the empty jump
  blocks that leaves are bypassed;
- blocks that differ only in one 32-bit literal, or only in where an
  s_getpc_b64 sits, share a class and read the literal / block PC from a
  packed table, when that saves at least 64 classes;
- the successor field can index a pool of distinct taken targets
  (fallthrough = 0) when that is smaller than inline block numbers or
  offset pairs; the table limit rises from 12288 to 32768 words;
- a backward liveness over s0..s105 and SCC gives each class the union
  of its blocks' live-out sets, and a class stores only what is live;
  the same liveness strips far-jump veneers (s_getpc_b64 + s_add_u32 +
  s_addc_u32 feeding a resolved s_setpc_b64) whose registers and SCC are
  dead at the target. Kernel-mode programs (the tests' ABI) keep every
  register live at the end.

The use / def sets are conservative: s_movrel* reads every SGPR,
conditional and read-modify-write SALU (s_cmov*, s_addk, s_mulk,
s_bitset*) read their destination and s_cmov* does not kill it, and a
wave32 VALU mask write defines only its low SGPR (from 33d1222, open as
#2604). New here: SDWA sources with their S0 / S1 bit set are SGPR uses,
as Lw::sources reads them; the ported code missed S1, so a v_add_nc_u32
sdwa reading s20 through VSRC1 left s20 dead and its store out.

The micro-blocks and the liveness are one commit: on an RTX 5070 Ti the
micro-blocks alone make the retail title's largest compute program
(95cc13288a27a96e) one the driver refuses (E_OUTOFMEMORY); with the
liveness it builds, and goes from 804 KB to 258 KB of DXIL.

Ported from the compact-form and liveness parts of amd-dev's f089a9d
(raylitebull, cherry-picked there from 46aecbf, Assisted-by:
Antigravity (Gemini 4 Neon High)) and 33d1222 (Alp Pesen,
Assisted-by: Antigravity (Gemini 4 Neon)).

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

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head 281d8f0

Only the top commit (281d8f0) belongs to this PR. The other 211 commits (+34k lines) come from a fork branch that is also the base of #2605 and several other open PRs.
The change in that commit is already on main, identically, in 16f2f5c (merged with #3263): inst_sreg_scc_use_def(d, wave64) with cond_write = starts_with("S_CMOV"), the rmw_dst list, the wave32 def_n clamp, and the same cmov_and_rmw_salu... test.
Recommendation: close (superseded by main commit 16f2f5c).

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

@throny

throny commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Closing as superseded: this change is already on amd-dev (33d1222). From Foniass's rechecked close list on #1607, checked again by script just now. If something here is still missing, say so and reopen it, or ask and I will.

AI use: Claude Code (Claude Opus 5.5).

@throny throny added the duplicate This issue or pull request already exists label Dec 1, 2026
@throny throny closed this Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duplicate This issue or pull request already exists

Projects

None yet

Development

Successfully merging this pull request may close these issues.