Skip to content

Integrate the native C++ shader translator and resource binding updates - #3039

Merged
R0Y00 merged 35 commits into
mainfrom
cpp-migration
Nov 27, 2026
Merged

R0Y00 merged 35 commits into
mainfrom
cpp-migration

Conversation

@R0Y00

@R0Y00 R0Y00 commented Nov 27, 2026

Copy link
Copy Markdown
Owner

Change

Integrate the published C++ shader migration branch into main. The direct compute translator gains packed integer conversions, bit alignment and bit-field operations, and preservation of the high destination half for binary16 arithmetic. The resource path handles a byte-address descriptor selected through the GPU heap. The offline compiler resolves, caches and watches RTV variants. Implementation and fixture history are in #2986, #2989, #2996, #2998, #3003, #3020 and #3025.

Verification

Head under review is b8f49259. Integration checks on the merge result are pending. On x64 Windows with the documented development prerequisites, run:

cmake --preset dev
cmake --build --preset dev
ctest --preset dev --no-tests=error -R '^native_direct_container$' --output-on-failure
ctest --preset dev --no-tests=error --output-on-failure

Record the tested merge commit, build configuration, failures and capability skips. For GPU results include adapter, driver, backend and debug-layer status. Compare the existing main paths and the new translator on identical inputs with independent caches. Report any previously accepted request that now fails, changes bindings or produces different output.

Review

Please check the shared decode, binding and cache interfaces, preservation of existing runtime behavior, and explicit diagnostics for unsupported forms. Corpus coverage is a regression measurement. Further instruction coverage can land independently. Keep the PR in draft pending integration results and review.

AI-assisted integration PR.

R0Y00 and others added 30 commits November 27, 2026 02:49
…#2914)

* shader: draw a per-vertex VCC across a vertex-stage join (Refs #2906)

A source-built gfx1013 vertex stage writes VCC in each arm of a branch
chosen by a runtime root word and consumes the joined mask with a
CNDMASK. The translated stage is drawn on WARP and hardware and compared
with a per-vertex CPU model. Two program mutations are the negative
controls.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>

* shader: add a per-vertex masked-arm case to the VCC join draw (Refs #2906)

One compare writes VCC and splits the vertices between THEN and ELSE
under saved EXEC. A CNDMASK reads the same VCC after EXEC is restored.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>

* docs: move the vertex VCC join note to its own topic file (Refs #2906)

New notes go in docs/experiments/<topic>.md. The note now states that
the per-vertex arms lower to selects in one block.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>

---------

Co-authored-by: Claude Mythos 5.2 <noreply@anthropic.com>
* xmem: split slot 31 placeholders when the OS hides the placeholder bit

The region query reports placeholders with Flags bit 0x100 on Windows. Wine leaves
it 0, so alias_placeholders refused every split or coalesce and queue slot 31
batches failed with ERROR_INVALID_ADDRESS whenever a run was not exactly one
placeholder. Probe once: if the bit is missing and VirtualFree with
MEM_PRESERVE_PLACEHOLDER refuses a plain reservation and leaves it whole, offer
any reserved region to the split. A plain one then fails the split instead of
being released. Where the bit is reported nothing changes.

* tests: slot 31 split inside an XMem reservation, with a committed-target control

xmem_placeholder_split maps two pool pages into the middle of an XMem reservation
through X2WMapPageBatch and checks the bytes, a write through the destination and
the reserved neighbours. A batch onto a committed page in the same reservation must
fail and keep its bytes. xmem_placeholder_split_control disables the fallback and
passes only when the split step fails; it skips where the OS reports the
placeholder bit.

* docs: placeholder fallback for slot 31 splits under Wine

* xmem: copy DirectStorage destinations under the mapping mutex

Add x2w_xmem_copy_to_destination. It checks that the whole destination
capacity is committed and writable, and copies the data, both under
memory.mutex. A run break (unmapping a page of a shared run and mapping
its other pages again) also runs under that mutex, so it can neither
make the check see a transient reservation nor start during the copy.

Lazily mapped pages of both ranges are committed before the mutex is
taken. A fault under the mutex is passed on: the lazy commit handler now
skips mapping threads, as retry_remapped_page already did.

The region walk moves from XCRDAPI's destination_writable to
x2w_local::committed_writable, so both DLLs share one implementation.

* startup: copy DirectStorage data through x2w_xmem_copy_to_destination

A plain-memory destination is now checked and written by xmem.dll under
its mapping mutex when the export is there. Before, the VirtualQuery
pre-check could run while an XMem run break had the destination's page
unmapped for a moment, and refuse a destination that was mapped before
and after. Without xmem.dll the check and the copy run in XCRDAPI as
before.

A copy that faults on its source now fails the request ("copy faulted
(source not readable)") instead of raising in the stand-in.

* tests: DirectStorage copy during an XMem run break

startup_dstorage_break_window holds an unmap of page 5 of an 8-page run
in the window where the run is apart (the xmem test-controls build's
X2W_XMEM_TEST_HOLD_WINDOW), checks that page 2 reads MEM_RESERVE there,
and submits a memory-source request into page 2. The request must not
complete within the 1000 ms hold, then complete with S_OK with every
byte in place after the release. It also covers a request with no break
and a read-only destination refused on the xmem path.

startup_dstorage_break_window_control builds XCRDAPI with the export
lookup's name changed, so it judges the destination with its own
VirtualQuery inside the window. It must report "refused while the run
was broken".

* xmem: split an owned placeholder before mapping a page into it

A map into the middle of a larger placeholder always fails first, so every
single-page XMemMapPhysicalPages call made two MapViewOfFile3 attempts. Under
Wine each attempt is a server round trip whose cost grows with the view count.
Split first when the target is not an exact placeholder; fall back to the
map-first path if the split or the map fails. X2W_XMEM_TEST_MAP_FIRST=1 keeps
the old order for tests. x2w_xmem_map_counts reports the attempts.

* xmem: answer non-faulting readers outside run breaks

With X2W_XMEM_SHARED_VIEWS=1, unmapping a page inside a run unmaps the whole run and maps its other pages
again. A touch of those pages in between is retried by the fault handler, but a region query or a kernel copy
does not fault: it reads the pages as reserved, or fails.

x2w_xmem_stable_call(fn, context) runs fn when no break begins or ends around it, else again under the mapping
mutex. XMemVirtualQuery, and through x2w_local::outside_run_breaks the stand-ins' x2w_local::writable,
measure_placed_buffer (slot 133) and snapshot_samplers, now answer that way. Without shared views no break
begins, so fn runs once as before.

xmem_run_break_readers holds a break open with the test-controls build and checks that each reader waits for
it and then sees the page committed; its control build runs the stand-in readers directly and they answer
inside the window.

* xmem: answer the main module's VirtualQueryEx outside run breaks

The title queries its own pages through its VirtualQueryEx import. With X2W_XMEM_SHARED_VIEWS=1 xmem.dll now
points that import at a wrapper that runs the query through x2w_xmem_stable_call, so a page of a run that is
being taken apart is not reported as reserved. The module is pinned only when an import was changed (the pin
is undone with the import if it is refused), so a main module without the import can still unload the shim
before its first mapping call.

xmem_run_break_readers checks the wrapped import of its own executable inside a held break.

* xmem: retry a fault in the break after the one the handler saw end

retry_remapped_page names the break a fault belongs to as seen | 1. When the
handler reads the generation after the break has ended (even), that names the
next break, so a fault on the same page in that next break is not retried and
the access violation ends the process. Name the break that just ended instead:
(seen - 1) | 1.

Back-to-back breaks over one page made this show up: with a reader on page 20
and page 21 toggled, the hold-ignored child of xmem_page_runs_check.py crashed
in 6 of 6 runs once map calls also open a break, and passed 6 of 6 with this.

Test build: X2W_XMEM_TEST_HOLD_RETRY=<name> holds the handler before it reads
the break. xmem_run_break_readers gets a case that faults in break A, is held
until A ends, and faults on the same page in break B. The
xmem_run_break_readers_next_break_control test runs it without the hold.

* xmem: run readers once without shared views, and write their answers after a break

Without X2W_XMEM_SHARED_VIEWS, every unmap still counts in the break generation
(begin_break is not gated on the switch), so x2w_xmem_stable_call made
default-mode readers wait for memory.mutex. Each page has a view of its own
there, and no break takes a page away from a reader, so stable_call now runs fn
directly until shared views are on. The comment, and the message of "xmem:
answer non-faulting readers outside run breaks", saying no break begins without
the switch were wrong.

XMemVirtualQuery and the VirtualQueryEx import wrapper answered into the
caller's buffer inside stable_call. On its mutex path the lazy-commit handler
passes faults on, so a buffer in an uncommitted mapped slot was not committed
there. Both now answer into a local copy and write it out after the call.
A refused pin of the VirtualQueryEx wrapper is logged with its error and the
restore count. measure_placed_buffer keeps the query count of a pass that ran
again. The docs describe stable_call and the load-time read of the switch.

"xmem: answer the main module's VirtualQueryEx outside run breaks" said the
title queries its own pages through VirtualQueryEx. An import scan shows only
that the executable under test imports it. How often it is called was not
measured.

Checks in xmem_run_break_readers: a break that begins while fn runs makes it run
again under the mutex (pins the after-check); default mode answers inside an
unmap (xmem_run_break_readers_default); lazy commit with the output in an
uncommitted slot (xmem_run_break_readers_lazy); the reader's 300 ms now count
from its start.

* xmem: join a page mapped on its own call to the view before it

Start-up maps nearly every page with a call of its own (45595 of 45602 runs
had one page), and under Wine each map costs more the more views the process
has. With X2W_XMEM_SHARED_VIEWS=1, a mapping call whose pages form one run now
joins the recorded run that ends at its address. It joins only when its first
page is the next slot of the section behind that run's last page, and both lie
in one reservation of the shim.

The new pages' range is split to a placeholder of its own, the run is unmapped
inside a break (begin_break, as for an unmap), the two placeholders are joined,
and one view is mapped over both. A refused step before the unmap changes
nothing. After it, the run is mapped again as it was (map_recorded) and the
new pages get a view of their own. If the run cannot be restored, its pages are
forgotten and the call fails, as in an unmap. Default mode is unchanged.

Test build: X2W_XMEM_TEST_NO_MERGE=1 turns the merge off; X2W_XMEM_TEST_FAULT
stages 4 (joined map) and 5 (joining the placeholders) refuse a step.

xmem_cross_call_merge covers 32 single-page calls -> one view, an unmap in
the middle, slots in reverse order (32 views), a reader held in the window,
both refused steps, and two reservations. xmem_cross_call_merge_control
keeps the old one-view-per-call layout under NO_MERGE.
xmem_cross_call_merge_deployed shows the deployed shim ignores that switch.
xmem_cross_call_merge_default covers default mode.

xmem_page_runs_check.py expected "Mapping the page again does not join the
pieces: three views". The page now joins the lower piece (two views). The
three-view layout stays asserted by xmem_cross_call_merge_control.
xmem_page_runs_device_check maps the upper view first and the single pages in
reverse slot order, so its view boundaries stay.

* xmem: stop a joined run at 64 pages

An unmap inside a run takes the whole run apart and maps its other pages
again, and a cross-call merge does the same to the run it joins. Nothing
bounded the joined run, so after loading every title unmap inside a run of
thousands of pages cost one long break: 46-72 ms each in a gate run under Wine,
with readers waiting 63 s in all and presents at 2.4/s.

merge_with_previous now leaves a page on its own when the joined run would be
longer than max_merged_run_pages (64); the next pages join that one. The test
build's X2W_XMEM_TEST_MERGE_CAP replaces the cap for a timing mode.

Measured under Wine with every byte of the run written (xmem_cross_call_merge_check
timing, median of 5): an unmap inside a run of 64 pages takes 0.28 ms, of 512
pages 2.1 ms, of 4096 pages 13 ms; joining a page to a run of 63 takes 1.5 ms,
about what a page mapped on its own costs (1.4 ms). The fixture process has a
few views, the title process tens of thousands.

xmem_cross_call_merge gets a capped case: 192 single-page calls make three
views of 64 pages, and an unmap held in its window in the middle one takes
apart 64 pages while the outer two stay mapped. The control, deployed and
default modes now print their pass line at the end of main, only with no
failed check.

* xmem: retry a fault from any of the last 64 breaks, not only the last

begin_break replaced the recorded ranges, so retry_remapped_page saw only the
last break. A handler that ran after a later break on another run had begun
found its address outside those ranges and passed the fault on. Joins made that
the normal case: one permissive XMemMapPhysicalPages call joins the CPU run and
then its GPU mirror run under one memory.mutex hold, and each map call opens a
break of its own.

RemapWindow now keeps the ranges of the last 64 breaks with their id (the odd
generation). The handler names the newest break whose ranges hold the address,
so a fault in a later break of the same page is still retried once more.

xmem_run_break_readers_two_runs faults in break A on run 1 and holds the
handler until break B on a disjoint run 2 is held open. xmem_run_break_readers_mirror
does the same across the CPU join and the GPU mirror join of one call
(X2W_XMEM_PERMISSIVE, X2W_XMEM_GPU_MIRROR). With one kept break both end the
process with an access violation (exit 5). The RemapWindow and hold_window
comments now also name the merge.

* xmem: run title ReadFile/WriteFile again after a run break refused the buffer

Inside a run break a kernel copy into or out of a page of the run fails at
once, with no fault to retry. Measured under Wine with the break held open
(xmem_run_break_readers ReadFile_import/WriteFile_import, before this change):
ReadFile fails with ERROR_NOACCESS and leaves the file position at 0,
WriteFile fails with ERROR_INVALID_USER_BUFFER.

With X2W_XMEM_SHARED_VIEWS=1 at load, the main module's ReadFile and WriteFile
imports go through a wrapper. A synchronous call that fails with one of those
errors while a break was in progress, or began or ended around it, and whose
buffer lies in a run, waits for memory.mutex and runs again, at most 4 times in
all. Other failures return at once as before: a read into a reserved page in
no run fails at once (io_outside_runs). With lazy commit the ReadFile wrapper
calls read_file_committed inside (lazy_read_file). Overlapped I/O, a call that
a break cuts short after part of the copy, and I/O from other modules stay
uncovered.

* xmem: write back only what XMemVirtualQuery's query writes, and pass lines at the end

XMemVirtualQuery copied all 64 bytes of the caller's buffer before the query and
wrote all 64 back after it. era_query writes 49 (the MBI and the tail byte at
0x30), so bytes 49-63 were read and rewritten where they never were before, and
a buffer of 49-63 bytes that ends at a page end could fault. The caller's buffer
is no longer read; on success tail_offset + 1 bytes go back, on failure none.

xmem_run_break_readers_default prints its pass line at the end of main, only
with no failed check, so a crash after the cases does not read as a pass.
xmem_page_runs_device_check prints a check_failed line before the map-order
returns, which were silent and looked like a refused device.

* xmem: say the run cap bounds joined runs only, and test the break ring's edge

The cap of 64 pages (max_merged_run_pages) is checked only where a page joins
the run before it (merge_with_previous). A run mapped by one call (map_run in
map_pages_locked) is not capped, and neither are the survivors map_recorded maps
again after an unmap inside such a run. Both are as long as before the cap; a
single large call is the title's own choice and was not the regression. The
comment above the cap and docs/startup-runtime.md said the cap bounds every
later break of a run; they now say it bounds the runs that joining builds, and
name the two uncapped paths.

xmem_run_break_readers_ring_edge holds a fault in break A before its handler
reads the breaks, ends A, then makes 63 or 64 later breaks (map and unmap a
lone page). After 63, A is still recorded and the fault is retried; after 64,
A's slot (RemapWindow::kept) holds the newest break and the fault is passed
on, which the reader's own __except catches.

* tests: map single-page XMem views from high to low

* tests: preserve the XMem linear buffer view boundary

---------

Co-authored-by: JohnConnorNPC <128232619+JohnConnorNPC@users.noreply.github.com>
Co-authored-by: Codex <codex@openai.com>
* shader: lower v_pack_b32_f16 in the direct C++ DXIL path

Lower VOP3 0x311 with integer operations only: pick the half of each
source with op_sel, clear the sign for abs, then toggle it for neg, and
place source 0 low and source 1 high. Signed zeros and NaN payloads keep
their exact bits, and the destination may overlap a source.

Refuse clamp, omod, a destination or third-source op_sel bit, abs/neg on
the third source, inline constants and literals with a named diagnostic.

native_pack_b32_f16_check.py evaluates the emitted IR against the model
of the Python translator (issue repro, overlap, SGPR input, all op_sel,
abs and neg forms, wrong-order controls) and has a compute readback mode
for a GPU run.

Fixes #2909

* tests: keep pack_b32_f16 readback groups from overlapping

Each workgroup stores 66 words (64 modifier forms, the SGPR case and
the overlap case) but groups were 64 words apart, so group 0's last
two results shared words with group 1's first two and the final value
depended on which group wrote last.

Space the groups 128 words (512 bytes) apart: s_lshl by 9 instead of 8.
The expected buffer is built from per-group offsets that are asserted
disjoint and inside the 2064-word buffer, so every group's SGPR and
overlap results are compared with no write-order assumption.

* docs: add the v_pack_b32_f16 direct lowering experiment note

Record the lowering semantics, the refused modifier forms, the Linux IR
verification and the Windows result from the review of #2917. The GPU
readback has no run yet because native_store_replay --direct crashes
with 0xC0000005 (#2915).

* tests: tie the pack_b32_f16 readback shift to its stride
#2931)

This reverts commit ee76dfa. Those are the 17 XMem commits of #2911, which
is still under review against main, plus two fixture changes. Keeping them
off cpp-migration keeps the branch to the native compiler work. When #2911
lands on main, merging main into cpp-migration brings in the reviewed
version.

Every file #2918 touched is restored to its state at cd752a8. The later
#2917 touches none of them.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…ve_request (#2928)

The check feeds 0xffffffff to compile_dxil and expected "unsupported
instruction". The word is not a gfx1013 encoding, so the decoder now
refuses it first with "unknown gfx1013 instruction format at byte N".
The refusal and the missing .cso are still asserted; the expected
message is now the one the compiler prints (Refs #2915).

AI-assisted.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…2932)

AMD's user-mode DXIL compiler (`amdxc64.dll` `8.18.10.0514`, driver
`32.0.32029.2010` on Radeon RX 9070 XT) queries
`llvm::Module::getNamedMetadata("llvm.ident")` and dereferences the returned
`NamedMDNode*` (`[rcx + 0x40]`) without a null check during
`CreateComputePipelineState` and `CreateGraphicsPipelineState`. `dxc.exe`
always emits `!llvm.ident`, while `IDxcValidator::Validate` treats it as
optional, so direct DXIL containers from `DxilModule` passed validation, WARP,
and NVIDIA while crashing all seven direct-DXIL `_hardware` tests with
`0xC0000005` on RDNA 4.

- `src/dxil_module.h`: emit `!llvm.ident = !{!<id>}` (`!{!"x2w"}`) in
  `DxilModule::finish_compute`, covering `cs`, `vs`, `gs`, and `ps`.
- `src/gfx1013_pixel.cpp`: emit `!llvm.ident = !{!0}` (`!{!"x2w"}`) in
  `x2w::direct_gfx1013_constant_pixel`.
- `tests/native_dxil_llvm_ident_check.py`,
  `tests/cmake/native_dxil_llvm_ident.cmake`: check `!llvm.ident` across
  `gfx1013-container-cs`, `gfx1013-container-vs`, `gfx1013-container-ps`,
  `gfx1013-container-rect` (`vs`, `gs`, `ps`), and `gfx1013-direct-constant-ps`
  with stripped-`!llvm.ident` negative controls, and draw both direct pixel
  paths on WARP and hardware with mutated-output negative controls.
- `docs/experiments/native-dxil-llvm-ident.md`: record the A/B isolation and
  RX 9070 XT + WARP verification results.

Refs #2915

AI-assisted.
…2939)

The runtime (d3d12_draw.inl) and gfx2hlsl.py key shader requests with
x2w-startup-shader-28 and -28cs, but read_graphics_request and
read_compute_request still hashed with -14 and -14cs, so compile_dxil
refused every request the current runtime publishes as a key mismatch.
The two fixtures that publish requests for compile_dxil move to the same
tags.


Claude-Session: https://claude.ai/code/session_01Sir6Mr49SZWax95VApRPvz

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…2937)

The direct compute decoder accepted DPP16 pattern values 0-255 only for
graphics. Compute now accepts them too, and lower_dpp() (formerly
mirror()) reads the source with waveReadLaneAt from lane
(lane & ~3) | ((pattern >> 2 * (lane & 3)) & 3). The handling of a
disabled source lane (BOUND_CTRL, fetch-inactive), the operand-modifier
rules and the two-source ALU limit are the row mirror's. A thread count
that is not a multiple of four is refused. Row shifts, rotates,
broadcasts, row_share and row_xmask stay refused in compute.

AI-assisted.
* shader: restore LDS replay compilation through the compute request loader

* shader: track the result register of returning LDS atomics

---------

Co-authored-by: Codex <codex@openai.com>
…xel draws (#2946)

An s_cbranch_execz after s_wqm exec, sM is skipped only when EXEC is zero
in the whole guest wave. For the bounded form where sM comes from the
filtered coverage or the whole-quad EXEC, the region writes only scalars
and the branch lands on the exact coverage restore, lower the condition
as WaveActiveAnyTrue of the modelled EXEC bit OR-ed across the quad with
QuadReadAcrossX/Y/Diagonal, as decided on #2907. Quad reads see helper
lanes, so a quad whose bits sit only on helpers or on pixels that did not
survive still votes. The vote is over the desktop wave, under the packing
contract of #2835 and #2854.

The fixture measures the desktop quads, helpers and waves of each draw
and checks eight cases against that layout, with quad-local, no-OR and
survivor-only votes as negative controls. On an adapter with no wave
holding two quads the hardware entry exits 77; the WARP entry runs
everything a 4-lane wave can decide and names the one control it cannot.
An IR entry checks that the vote is emitted before any conditional
branch. Hardware register access inside the region is refused by name.
…mpute path (#2940) (#2950)

The direct compute path lowered v_readfirstlane_b32 only. v_readlane_b32
now reads the selected lane with waveReadLaneAt, taking the half from
the lane index for a split guest wave64. v_writelane_b32 writes its
scalar source to the selected lane only and ignores guest EXEC. The lane
is a constant or an SGPR, masked to the wave width. A lane that may have
no host thread is refused, and v_readlane_b32 joins the multi-wave64
convergence guard.

Lane reads may write vcc_lo and vcc_hi in direct compute. In wave32,
VCC is s106 only and s107 is ordinary scalar data, which wave32 programs
use when they spill and refill the VCC pair; a 64-bit read of VCC reads
s106:s107. In wave64 s107 stays the high half of VCC. The graphics and
HLSL paths still refuse both.

AI-assisted.
…bit shifts (#2951) (#2952)

v_lshrrev_b64 and v_lshlrev_b64 accepted only a VGPR pair or the inline
0 as the shifted value. They now also take a nonzero inline integer,
sign-extended to 64 bits, a 32-bit literal, zero-extended, and an even
SGPR pair, the rules gfx2hlsl.py applies through i64_words. Inline
floats stay refused.

AI-assisted.
… compile_dxil (#2955)

Align compile_dxil --requests and the native request reader with the startup shader cache contract (#2933):

- Parse ASCII req_<key>.psin stream descriptions (psin1 <key> ena=0x... addr=0x...), enforce key matching and non-contradictory SPI_PS_INPUT_ENA / SPI_PS_INPUT_ADDR masks, fold b'psin1' + pack('<II', ena, addr) into the graphics FNV-1a key, and honour SPI_PS_INPUT_ENA alongside SPI_PS_INPUT_ADDR in raw pixel entry lowering.
- Strip the req_ prefix in compile_dxil --requests outputs (<key>.vs.cso / <key>.ps.cso, <key>.gs.cso for rectangle batches, and <key>.cs.cso for compute), stage graphics bytecode before publishing, withdraw stale manifests before rewriting or on refusal, record <key>.psdep for .psin pairs, and atomically publish <key>.txt last for runtime-bindable stages.
- Open frontend and DXIL cache entries with FILE_SHARE_DELETE during cache lookups so concurrent --jobs workers sharing a stage do not fail when MoveFileExW replaces an identical cache entry.
- Add native_startup_request_cache_check.py (.psin draws, end-to-end d3d12_xs graphics draw and slot-67 compute dispatch without manual renaming, revision-literal pinning, and mismatched-key / stale-.psin refusal controls).

Closes #2933

AI-assisted.
…+ compute path (#2957) (#2959)

The direct compute path lowered the bitwise 64-bit SALU ops and refused
the other _b64 ones. s_bfm_b64 now builds its 64-bit mask from six-bit
width and offset fields with SCC unchanged. s_cselect_b64 selects both
words by SCC, and s_not_b64 inverts both words and sets SCC from the
64-bit result. Constants extend to 64 bits as pair_high does. The
destination is an even SGPR pair, or vcc for s_cselect_b64 and
s_not_b64; exec stays refused.

AI-assisted.
* runtime: translate slot 67 compute requests in the stand-in (Refs #2934)

With X2W_NATIVE_SHADERS naming the directory of dxcompiler.dll and
dxil.dll, the first Dispatch of a slot 67 pipeline reads the request the
stand-in published, runs the C++ compute frontend and the DXIL compiler
in-process, and fills the ComputeTranslation that a published <key>.txt
fills. The existing dispatch path then binds the table buffers.

Accepted: root constants, a raw table buffer loaded per lane and a raw
table buffer stored to. Every other view kind, a sampler, an adapter
without 32-lane waves and whatever the frontend refuses are logged by
reason and left to a published translation.

run.ps1 -Render -NativeShaders <dir> sets the switch.
startup_compute_dispatch_native_{warp,hardware} dispatches a source-built
program from an empty cache and compares all 320 output words with the
CPU reference; an unsupported program is refused with the output
untouched.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>

* docs: record the in-process compute dispatch results (Refs #2934)

Route, program and controls, commands, the results on the RTX 4090 and
on WARP (capability skip: no 32-lane waves) for a58e08f, and the
limits of what was run.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>

* docs: record the GPU-check package run for the compute dispatch note (Refs #2934)

tools/package-gpu-check.ps1 at 89a7531: the extracted package passes its
WARP run, 11 tests and 68 of 68 recorded shader cases; bvh_wave64_warp
reports a capability skip (no 64-lane waves).

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>

---------

Co-authored-by: Claude Mythos 5.2 <noreply@anthropic.com>
)

VOP2 and VOP3 v_add_f16, v_sub_f16, v_subrev_f16 and v_mul_f16 in the
direct compute path widen the low half, operate in f32, and round with
the same integer conversion as v_cvt_f16_f32. The high half of the
result is zero. SDWA, DPP, clamp, omod, a high-half op_sel, and a
non-default f16 rounding or denormal mode are refused by name.

Fixes #2945

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
…e path (#2966)

The direct compute frontend refused every FLAT-encoded instruction. It
now decodes global_load_dword in the saddr form and lowers it when
SADDR is the unadvanced root address of a root SRV, the binding the
scalar root loads already use: a raw buffer load at
zext(VADDR) + sext(OFFSET), guarded to [0, 2^32) so a wrapped byte
offset reads zero, with the low address bits dropped like
buffer_load_dword in this path.

The off form, the FLAT and scratch segments, other opcodes, the lds
form, non-root or replaced pointers and unaligned immediate offsets
stay refused by name.

tests/native_global_load_check.py checks eleven refusals and the
module's loads and guards, and dispatches offsets 0, 16 and -8, a
VADDR near 2^32 and an unaligned VADDR against a root SRV, with
offset-dropped and guard-dropped references as controls.

Refs #2962. AI-assisted.

Co-authored-by: legacy-code-archaeologist <359844974+legacy-code-archaeologist@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…t C++ compute path (#2965) (#2967)

A loaded structured-buffer descriptor is often turned into a raw byte
window before a buffer store: word 1 & 0xc000ffff clears the stride,
word 2 is multiplied by the clamped stride, and word 3 | 0x30000000
sets OOB_SELECT to 3. Loads already accepted that form through
byte_window_srv; a buffer_store_raw through raw_buffer_uav now accepts
it too and binds the unmodified descriptor as before, so the manifest
and runtime are unchanged. Buffer atomics keep the strict check. The OR
on word 3 is also accepted on a plain loaded word, as gfx2hlsl.py does
for stores. The stride proof and descriptor identity checks are
unchanged.

AI-assisted.
image_io refused the comparison gather. It now lowers image_gather4_c_lz
(MIMG opcode 79) on 2D and 2D-array images with dmask 0x1 to DXIL
textureGatherCmp: channel 0, the reference (the first address dword) as
compare value, the constant comparison sampler under the existing field
checks, and the base-level sampler fix that image_gather4_lz uses.
Other dmasks, cube and 3D images, and the implicit-LOD, _c_l and _c_b
forms stay refused.

tests/native_gather_compare_check.py traces the module's operands to
their registers, checks seven refusals with an image_sample_c_lz
control, and creates the graphics pipeline of
native_graphics_comparison_pso_warp with the gather on WARP.

Refs #2969. AI-assisted.

Co-authored-by: legacy-code-archaeologist <359844974+legacy-code-archaeologist@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…direct compute (#2963) (#2973)

The direct compute path lowered the plain binary16 add, sub, subrev and
mul (#2964) and refused their SDWA forms. The SDWA forms now read the
WORD_0 or WORD_1 half of each VGPR source (DWORD reads the low half),
apply abs/neg, compute through the same binary32 path and round once to
binary16 with packed_half_rne, then place the half with dst_sel WORD_0
or WORD_1 and UNUSED_PAD or UNUSED_PRESERVE, as gfx2hlsl.py sdwa_half()
does. Byte selections, sext, SGPR or constant sources, dst_sel DWORD,
UNUSED_SEXT, clamp and omod stay refused, as do the min/max SDWA forms.

AI-assisted.
…ts (#2972)

* test: a native DXIL module reads a GPU-selected descriptor heap slot (ResourceDescriptorHeap probe)

Adds DxilModule::heap_handle (dx.op.createHandleFromHeap, opcode 218, annotated with the view class) and a probe that
compiles the same selection shader as DXC HLSL and as the native module, creates the pipeline with the heap-indexed root
flag, and dispatches it twice with different selector words: each readback must be the data of the selected slot and the
UAV guard word must stay intact. The adapter needs shader model 6.6 and resource binding tier 3, else the test skips.

* feat: the direct compute lowering reads a GPU-selected descriptor heap slot as a raw buffer SRV

A buffer load through a descriptor loaded from the whole resource heap at a GPU-computed index used to be refused
(whole-heap buffer access needs a matching descriptor at the GPU-selected index). The direct DXIL lowering now emits
ResourceDescriptorHeap[slot] (createHandleFromHeap, annotated as a raw buffer) and records a heap_buffer_srv binding with
no table register; the pipeline then creates its root signature with the heap-indexed flag and sets the heap on the list.
Adds the view-type classification header (native_global_srv.h) that the dispatch guard will use; no guard yet.

* fix: the probe module ends with ret void

* test: the probe writes both shader containers and the check prints how they differ

* test: skip the heap-handle probe on adapters without 32-lane waves

The native module declares WaveSize=32 (the guest wave). WARP offers only
4-lane waves, so CreateComputePipelineState refuses the native shader and
native_heap_handle_probe_warp failed with "pipeline state of the native
shader". Return 77 when the adapter cannot run 32-lane waves, as
native_store_replay and native_recording_check already do.

AI-assisted.

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

* native: capture and replay view types for GPU-selected global SRV slots

The direct compute translation takes a view contract for a GPU-selected
descriptor heap slot (HeapViewContract none / raw_buffer / other). A heap
descriptor load is translated only with raw_buffer; without a contract the
existing refusal stays. Constant heap indices, immediate offsets, scalar
buffer loads from the heap base and stride reads of a selected slot are
refused. Heap-reading modules set shader flag 0x40000000, which the
validator requires.

compile_dxil gfx1013-container-cs reads an optional req_<key>.views
(native_global_srv.h, format version 2 with buffer sizes), refuses a
selection whose slot holds another view type before publishing a .cso, and
reports the captured selection.

native_global_srv_heap_replay records a dispatch that selects its slot from
GPU data (selector read back before recording, guard before Dispatch,
NativeRecording + NativeDispatchStates) and replays the compile_dxil output
on a heap rebuilt from the captured view types, with negative controls on
both paths.

Fixes #2908. AI-assisted.

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

---------

Co-authored-by: c1 <c1@x.invalid>
Co-authored-by: tedin7 <110300616+tedin7@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The direct compute frontend refused v_sad_u8, v_sad_hi_u8, v_sad_u16,
v_sad_u32 and v_msad_u8. They now sum unsigned absolute differences of
four bytes, two halfwords or one dword, add S2 and wrap modulo 2^32, as
gfx2hlsl.py's SAD helpers and tools/pixel_aot.py do. v_msad_u8 skips a
byte whose S1 byte is zero; v_sad_hi_u8 shifts the byte sum left by 16.
Source and output modifiers stay refused like the other integer VOP3
forms.

tests/native_sad_check.py dispatches per-lane operands with zero S1
bytes and S0 bytes on both sides against a CPU reference, refuses the
clamp form, and checks that signed, unmasked, unshifted and S2-dropped
references differ.

Refs #2987. AI-assisted.

Co-authored-by: legacy-code-archaeologist <359844974+legacy-code-archaeologist@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…te path (#2994)

The direct compute frontend lowered the logical 64-bit shifts and
v_mad_u32_u24 but refused their signed counterparts. v_ashrrev_i64 now
uses the shifted-value rules of the logical shifts with an arithmetic
ashr i64, and sign-extends a 32-bit literal as gfx2hlsl.py's
i64_words(signed=True) does. v_mad_i32_i24 is
sext(S0[23:0]) * sext(S1[23:0]) + S2 modulo 2^32.

tests/native_signed_forms_check.py reuses the native_shift64 program
for six sources and six amounts and adds a multiply-add dispatch with
bit 23 set and nonzero upper bits. Its controls check the modules and
that zero-extended-literal, logical, unsigned and unmasked references
differ.

Refs #2991. AI-assisted.

Co-authored-by: legacy-code-archaeologist <359844974+legacy-code-archaeologist@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…ests (#2989)

* shader: resolve and cache RTV variant requests in compile_dxil --requests (Refs #2980)

gfx1013-container-pair --requests now also takes each req_<key>.rtv. The
reader checks the "rtv1 <base key> <format> ..." text as
tools/startup/gfx2hlsl.py request_source does (256 bytes, decimal, one
to eight formats, FNV-1a of the text is the key in the name) and reads
the base parts it names, checked against the base key. A key with both
markers is one request, the variant.

The ordered formats type the pixel stage's color targets: u32 or i32 for
the integer formats, f32 otherwise. The two three-channel 32-bit integer
formats are refused by name when the pixel stage exports to their
target, as in gfx2hlsl.py. A container whose own output signature says
otherwise is refused. The target types are part of the pair cache key,
the manifest accepts an integer target only for the variant that asked
for it, and the request is the manifest's last line, which the runtime
matches. A variant without a runtime manifest is refused. A base request
adds nothing to its key and takes the same path as before.

native_rtv_variant_controls compiles a base and four variants cold and
warm with four workers and checks thirteen refusals, a withdrawn stale
directory and a signature conflict. native_rtv_variant_{warp,hardware}
draws three variants through the stand-in and reads the target back.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

* docs: record the RTV variant request results (Refs #2980)

What changed, the pair, formats and expected values, the controls, the
results on the RTX 4090 and on WARP for be9a070, the baseline, a
mutation control, the regression runs and the limits.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

* docs: record the Release build results for the RTV variant requests (Refs #2980)

The release preset at be9a070 on the same machine: the three tests on both adapters, twelve repeated control runs and the regression set.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
…rect C++ compute path (#2986)

The direct compute frontend refused these three VOP3 bit operations.
They now follow the gfx2hlsl.py VOP3 table: v_alignbit_b32 returns
bits [k + 31 : k] of {S0, S1} with k = S2[4:0], v_alignbyte_b32 the
same with k = 8 * S2[1:0], both returning S1 for k = 0, and v_bfm_b32
is ((1 << S0[4:0]) - 1) << S1[4:0] like s_bfm_b32. The zero case is a
select, so the masked shift in the other arm stays in range.

tests/native_align_bfm_check.py dispatches every shift 0 to 31 and
every byte count, repeated with bit 5 set, against a CPU reference,
and its controls check that the zero-shift, exchanged-source and
unmasked references differ.

Refs #2985. AI-assisted.

Co-authored-by: legacy-code-archaeologist <359844974+legacy-code-archaeologist@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
… compute path (#2996)

The direct compute frontend refused the two saturating 16-bit packs.
They now follow gfx2hlsl.py's VOP3 table: v_cvt_pk_u16_u32 packs
min(S0, 0xffff) and min(S1, 0xffff), v_cvt_pk_i16_i32 the signed
sources clamped to [-32768, 32767], S0 in the low half. A nonzero
unused SRC2 field and op_sel are refused.

tests/native_cvt_pk16_check.py converts eight operand pairs across both
bounds of both forms in a dispatch against a CPU reference; its
controls refuse the SRC2 and op_sel forms and check that truncating
and unsigned-bound references differ.

Refs #2995. AI-assisted.

Co-authored-by: legacy-code-archaeologist <359844974+legacy-code-archaeologist@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The direct compute frontend refused v_cvt_pk_u8_f32. It now computes
(S2 & ~(0xff << 8 * S1[1:0])) | (flt32_to_uint8(S0) << 8 * S1[1:0])
with the conversion gfx2hlsl.py measured on RDNA 2: an integer test
(bits - 1) < 0x7f800000 for positive values, DXIL FMin with 255.0,
Round_ne and fptoui, so NaN, zeros and negatives give 0 and +inf 255.

tests/native_cvt_pk_u8_check.py dispatches ties, the saturation bound,
infinities, a NaN, a subnormal and all byte selects against a CPU
reference that agrees with tools/rdna_cvt_pk_u8.py's measured model.
Its controls check the module for one FMin and one Round_ne per case
and that half-up, truncating and negative-passing references differ.

Refs #2997. AI-assisted.

Co-authored-by: legacy-code-archaeologist <359844974+legacy-code-archaeologist@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…refusals (#3003)

* tooling: support .rtv variant requests in compile_dxil --watch and --refusals

* tooling: document pre-sorted invariant on dedupe_graphics_markers
…or (#3025)

Recognize the byte-address descriptor rewrite under the captured raw-buffer view contract. Exercise both selected slots in synthetic capture and offline replay, and refuse rewrites that cannot preserve the selected view.

Refs #3023.
…and mul (#3020)

The non-SDWA forms of v_add_f16, v_sub_f16, v_subrev_f16 and v_mul_f16
zeroed the destination's high half. LLVM's
GCNSubtarget::zeroesHigh16BitsOfDest lists exactly these four ops with
"On gfx10, all 16-bit instructions preserve the high bits", the direct
path's v_cvt_f16_f32 already keeps it, and #669 measured the same for
the 16-bit integer ops on RDNA 2 silicon. The result now goes to D[15:0]
and D[31:16] keeps its value. SDWA forms are unchanged.

tests/native_f16_alu_check.py already preset every destination's high
half to 0xabcd. Its model, IR interpreter and readback now require that
high half kept, and the mutant it rejects is a zeroed high half instead
of a kept one.

Refs #669. AI-assisted (Claude Code); reviewed and run locally.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Preserve native and offline startup cache handling for revision 29 and archived revision 28 requests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.