Skip to content

Lower the operations 0x218 programs use that were refused - #101

Open
Castyan wants to merge 50 commits into
DexNom:mainfrom
Castyan:native-0x218-ops
Open

Castyan wants to merge 50 commits into
DexNom:mainfrom
Castyan:native-0x218-ops

Conversation

@Castyan

@Castyan Castyan commented Nov 26, 2026 •

Copy link
Copy Markdown

Stacked on #98 (0x218, itself on #64 and #61). The changes to review are the 7 commits after 60ff2e8.

What

Operations the 0x218 programs use that were refused. Each has an execution test against an exact reference, with edge cases.

  • s_sext_i32_i8 / s_sext_i32_i16, v_mad_u32_u16, buffer_atomic_sub, s_absdiff_i32.
  • v_pk_fmac_f16, rounded once (the test fails without round-to-odd: 0x3e02 instead of 0x3e01).
  • v_add_nc_u32 / v_sub(rev)_nc_u32 with clamp, saturated.
  • The thread-group info SGPR (COMPUTE_PGM_RSRC2.TG_SIZE_EN): the programs read the wave count and the wave index times 64 (s_and_b32 sN, s6, 0xfc0, then v_mbcnt). These are reproduced exactly for the waves the host runs. A read that keeps the unknown bits above 11 is refused.
  • ds_append is still refused.

Results

Replay of two sets of 200 captured 0x218 descriptions on the RTX 5060: these commits were measured together with the lane-mask and address branches (88 -> 162 and 23 -> 101 for all three), with no program lost.

Checks (RTX 5060, at 9457437)

cargo clippy --workspace --all-targets --locked -- -D warnings, with and without --all-features: clean. cargo test --workspace --locked: 748 passed, 0 failed, 11 ignored.

🤖 Generated with Claude Code

Castyan and others added 30 commits November 25, 2026 19:29
…to combined-preload-pops

# Conflicts:
#	Setup-DexNomRuntime.ps1
#	apps/victory/src/play_launcher.rs
#	apps/victory/src/translate.rs
#	crates/victory-gpu/src/descriptor/host.rs
#	crates/victory-gpu/src/host.rs
#	crates/victory-gpu/src/pipeline/make.rs
#	crates/victory-hle/src/modules/d3d12x.rs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…wn lanes

Three wave64 compute shaders (a 512-thread prefix over per-wave totals) were
refused on 32-lane hosts: inside a loop only one console wave's lanes run,
v_readfirstlane copies a running sum built from scalars and LDS alone. Two
host waves cannot exchange there (no group barrier inside the loop), but every
lane holds the same sum, so each host wave's own first lane is exact.

scalar_built() finds such VGPR values (VALU results and LDS reads of them,
phis at loop headers or where every predecessor runs on all lanes; guards
allowed), and remembers which a guarded write made: those are only taken by a
read that is itself inside a branch.

Fixes 9fc111d3be79364f, 77360df21e12ea43 and 39321a95223001ed on the
RTX 5060; their pipelines are now created.

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

Compute 7f61193d2c0e5f22 was refused by CreateComputePipelineState with
E_OUTOFMEMORY on the RTX 5060 and on WARP alike, although its DXIL validates.
Bisecting the console code down to one instruction: ds_add_rtn_u32 of
(0 - x) on group-shared memory. Host compilers turn atomicrmw add of a
negation into atomicrmw sub, which DXIL has no group-shared form of, and
refuse the pipeline; ds_sub_u32 (atomicrmw sub) fails the same way.

Both are now a load and a cmpxchg loop on old - x (lds_subtract); other
atomics keep their atomicrmw. A test runs ds_add of 0 - 1 and ds_sub of
0 - 1 over 32 threads and checks LDS on the card (32 and 96).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Port of DexNom#40 (notquiteog), unchanged. A console wave64 compute
program that no other form takes off 64-lane waves is refused by a 32-lane
host and every dispatch of it is dropped; the exact wave-wide form is tried
last, only for those. VICTORY_WAVE_WIDE=0 keeps the old refusal.

On the RTX 5060 this creates 22 of the 31 compute pipelines the title's
preload left refused for requiring WaveSize(64). The 9 left: 7 run groups of
several console waves (128 to 1024 threads), which the wave-wide form does
not take, and 2 are ray-tracing BVH builder programs (28918b7150a7aad5,
caa78b8ca62bc3d6) whose waves exchange across halves.

Co-Authored-By: notquiteog <notquiteog@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
warp_a_title_buffer_in_place_shows_its_bytes_at_its_offset decommitted
half of its allocation right after dropping the buffer placed over it.
The pages of a heap opened on private memory stay locked until the
runtime has destroyed the heap, and WARP may do that a moment after the
last reference goes: under the load of the whole victory-gpu suite the
decommit was sometimes refused (ERROR_INVALID_PARAMETER) and the test
failed, or the run ended in an access violation. About 2 runs in 15
failed this way, already on a65db62.

The test now retries the decommit for two seconds at most, drops its
command queue before releasing the allocation, and checks that the
release succeeds. 40 runs of the library in a row now pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The test binary's random access violations were d3d10warp.dll's own. Every
test that asks for the software adapter gets the same device (one per
adapter in a process), and two of them compiling and running compute
shaders at once crash its shader compiler: in JITBaseVariable::OptimizeCopy
as a ComputePipelineShaderJIT is torn down, under ExecuteCommandLists of
the indirect tests' harness, or in Task_CompileShader on its own worker
threads. Every stack caught under cdb had two or more indirect::tests::warp_*
tests inside it at once. They take turns now, with the in-place tests that
open the same adapter: under cdb, 50 of 588 runs of all tests crashed
before, none of 240 after; 150 plain runs passed.

frame's tick test tries again when a busy PC wakes a wait late.

Ported from avatarmanz/VIctory-7900XTX 160d222 (its WARP turn and frame
parts; its write watch change is left out here).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…f fxceless#854)

Port of 26600c6 from fxceless/victory-fork#854 by PiloteCode ("wave64
programs in a paired form on 32-lane hosts, mesh programs over 32 KiB
linked with their pixel program, and more"). Each console wave runs as
one host wave of 32 lanes, each thread two console lanes (n and n + 32),
with every per-lane branch taken by the whole wave and EXEC as each
lane's guard. It is tried after every other form for a wave64 compute
program the host refuses (VICTORY_WAVE_PAIRS=0 turns it off).

On the 31 wave64 compute containers from the RTX 5060 preload, 29 get a
pipeline (22 before): 02384a60fda6f2d0, 1d434307d981352a,
22338086ea4c5364, 2da4beb386509b77, 3b02415f67c6b0d8, 6832a9da15c2e584
and 6b82bc7d22016cb5 now take the paired form; the other 22 are
unchanged.

Adapted to this branch:
- Kept from this branch: scalar_built() and the v_readfirstlane own-lane
  read, lds_subtract() with Module::negated() (the PR's own LDS
  subtraction loop is left out), the wave-wide last resort from
  DexNom#40 (now inside emit_forms), the POPS translation from pops.rs,
  the structured view record count / picked address / puddle texture
  size paths and scalar UINT views (moved into descriptor_data.rs next
  to the PR's unused-descriptor path, which now only runs where this
  branch refused).
- Left out: the PR's second POPS implementation (ir::without_pops_wait,
  Shader::ordered and its test), which would have run beside pops.rs.
- The ray-tracing structure builder's programs (a spilled user-data
  table, as victory-gpu classifies them) are refused by the paired form:
  forcing them onto 32-lane hosts hung NVIDIA GPUs in Marvisak#2711.
  28918b7150a7aad5 and caa78b8ca62bc3d6 stay refused.
- The new modules are classified in lib.rs; a test that expected the
  parked mask to be opaque when built alone checks only the shared build;
  the descriptor size test fills the record-count root word the runtime
  fills.

Co-Authored-By: Pilote Production <75377040+PiloteCode@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The two BVH builder programs (28918b7150a7aad5, caa78b8ca62bc3d6) were
the last wave64 compute programs refused on 32-lane hosts. They exchange
across the console wave's halves, which the per-half form got wrong and
which hung NVIDIA cards (Marvisak#2711). The paired form keeps
both halves in one host wave, so the refusal is dropped: all 31 wave64
compute containers from the RTX 5060 preload now get a pipeline.

The builder still runs only when victory-gpu allows it
(VICTORY_BVH_BUILDER=1 or VICTORY_RAY_TRACING=1) and every one of its
pipelines has a host pipeline; by default its dispatches stay dropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e method 0x218)

The title calls device method 0x218 at start for every variant of its
small compute programs (mip generation of texture arrays), handing over
a 0x60-byte description: the root signature, then (address, size) pairs
of the program's registers, its code and its resource table. Until now
the call failed with a null output and the title went without these
pipelines.

The program is now read from the description (registers, console
resource table, code without its s_code_end padding) and wrapped in a
container of its own, which is translated and cached as the title's
containers are. Descriptions that cannot be read still fail with
E_NOTIMPL and a null output. Method 0x1c8 (native graphics pipelines)
stays refused: it needs the draw's render-target formats.

The descriptor tracer also folds s_bfm_b32 and a 64-bit s_mov of a
literal (zero extended), the two instructions these programs use to
build their fixed sampler; without them the sampler's origin was lost
and the pipeline refused.

On the five 0x218 captures from the RTX 5060, all five now get a
hardware pipeline and are created by the runtime.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 0x218 commit cut the note on device method 0x1c8 down to one line
and dropped its `shortcut:` marker, which is how the repository lists
what is not implemented. It also put native_build.rs in the middle of
the sorted list of sources outside the translation, with a comment that
did not say why it is outside. The note and its marker are back, and
the entry now sits at the end of the list with the reason: native_build
only writes containers, which are hashed like any other.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Descriptions captured in game showed three misreadings in the decoder of
programs handed to device method 0x218:

- The user-data dword and the stride were swapped. The byte in the
  packed word is the user-data dword: every entry of root slot k names
  dword 4 + k, inside the program's COMPUTE_PGM_RSRC2 user-SGPR count.
  The u32 before it is the stride (0x10 or 0x20 for structured buffer
  SRVs, 4 for images, as in the title's own containers). With the swap,
  the CBV of every accepted mip-generation program named user-data
  dword 0 instead of the table in dword 4. A root parameter that names
  user data the program does not have is now refused.
- The header count is not always that of the 0x41 entries (11 for 12
  seen), so the entries are told apart by their tag.
- Root type 0 is root constants, read as values from the user SGPRs
  (`v_mul_f32 v7, s5, v7`). They are now a root parameter of size/4
  SGPRs, with no used resource.
- The thread-group depth is the low half of its word; the high half
  holds something else (0x10 seen with 32 x 1 x 1 groups).

In game, 0x218 now makes over 2048 pipelines and turns down 32 to 63
descriptions (before: about 512 made, over 1024 turned down). Of eight
descriptions captured in game, all now decode and four reach a hardware
pipeline; the four others stop at translator limits (a descriptor
changed after loading, an address with two computed terms). The five
earlier captures still pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A description the decoder turns down used to be logged with a count
only, and one whose blocks could not be read was not logged at all.
The warning now gives the reason (which block, or the decoder's error)
and the description's twelve words.

With VICTORY_DUMP_NATIVE=<folder>, a description turned down is saved
there with the blocks it names, four of each reason and 200 in all, as
slot218-<n>-desc-<address>.bin and slot218-<n>-dNN-<address>-<size>.bin
with the reason beside them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Root type 1 in a console resource table is a root descriptor: a 64-bit
buffer address in two user SGPRs. The title's programs that use one (a
root SRV t1 in user data 7 and 8, the next slot at 9) build a buffer
descriptor around s7:s8 and load through it, so it becomes a root
parameter of two SGPRs and a used resource, as the title's containers
give one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The flags' bit 5, which says 32 lanes in the title's containers, is
clear in every description captured from device method 0x218, so every
such program was taken as 64 lanes. The ones whose depth word has 0x10
in its high half are 32-lane programs: they move exec_lo alone, keep
scalars in vcc_hi and use VGPRs up to the 32-lane count of
COMPUTE_PGM_RSRC1 exactly (v143 of 18 granules in slot218-m005, v127
of 16 in m008, v40 of 6 in m007, beyond the 64-lane count). The others
move the whole exec and stay within the 64-lane count (v23 of 6 in
m002, v31 of 8 in run1-m004).

As 64 lanes, a v_cmp writing s[15:16] overwrote the first dword of a
descriptor in s[16:19] (m008 at 0x2f8, "a descriptor changed after
loading"), and the VGPR count was half the program's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Castyan and others added 20 commits November 26, 2026 20:28
The 0x218 programs read structured buffers by byte through a descriptor
the code rewrites after loading it: the stride cleared in dword 1
(s_and_b32 by 0xc000ffff), the record count in dword 2 multiplied by
the stride (s_mul_i32 by s_max_u32 of s_bfe_u32 of dword 1, 14 bits at
16, and 1), OOB_SELECT raw in dword 3 (s_or_b32 of 0x30000000, after
an s_and_b32 by 0xcfffffff). The tracker refused it as "a descriptor
changed after loading".

The memory and its size in bytes are the loaded descriptor's, and the
host's buffer views are raw already, so the tracker now takes the
rewritten descriptor as the load's. An access that reads it by index
or format is refused: with stride 0 the index adds nothing, where the
load's descriptor would scale it.

slot218-m005, m006 and m008 now get past these descriptors; with m007
they stop at "an address with two computed terms": a descriptor loaded
from s[10:11] plus s9 << 5, user SGPRs the resource table names no root
parameter for (a heap and its index, as far as the code shows).

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

The resource table of a 0x218 description names only some of the user
SGPRs a program reads: slot218-m007 loads a descriptor from s[10:11]
plus s9 << 5, where the table has entries for user-data dwords 4 to 6
alone. Word 0 of the description is the root signature, one of ours,
which keeps its serialized form; what s7 to s10 hold is in it.

With VICTORY_DUMP_NATIVE, every saved description now has that
serialized form beside it, as slot218-<n>-root.bin, and a description
whose program decodes but does not translate is saved too, its reason
being the translator's ("translation: GFX10 code at ..."). Such
descriptions were not saved before, so no capture showed what the
translator turns down. Root signatures are told from other objects by
their function table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The resource table of a 0x218 description names only some of the user
SGPRs a program reads (slot218-m007: entries for user-data dwords 4 to
6, a descriptor loaded from s[10:11] plus s9 << 5), and the translator
refused what it could not trace. The decoder now reads the root
signature the description names (an RTS0 part, alone or in a
container) and adds the parameters the table leaves out.

Every captured table places the parameters from user-data dword 4 on,
in order, a table taking one dword, root constants their count and a
root CBV two (slot 0 at 4 even when unnamed; a root CBV at 7 and 8, the
constants after it at 9), so the others are placed the same way and
only those. Nothing is guessed: the program is refused, with the reason,
when the table places a parameter elsewhere, when a parameter is cut by
the end of the program's user SGPRs, when user SGPRs are left past the
parameters (where a directly indexed heap would be: no capture places
one), for a root SRV or UAV (no table places one) and when the
signature cannot be read. Without a signature the table's layout is
used alone, as before.

The captures hold no root signature yet, so they replay as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The two merged branches disagreed on root SRVs: the resource table
decoder reads one (root type 1, kind SRV, a 64-bit address in user data
7 and 8 that the program builds a buffer descriptor around), while the
root signature reader refused every root SRV as one no capture places.
In game, where a signature comes with every description, a program the
table describes in full would then have been turned down.

A root SRV in the signature is now a root descriptor of two dwords, as
a root CBV, and is taken when the table places it itself. One the
signature names and the table leaves out is still refused, as is every
root UAV: what they are read as is not known.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
73d8513 refused every 0x218 program with user SGPRs left past its root
parameters, where a directly indexed heap would be. A game run with
ed45fe9 captured 200 descriptions with their root signatures: 196 end
their parameters exactly at their user-SGPR count, and the 4 with one
more have CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED in their signature but never
read that SGPR. The refusal only cost pipelines: over 1024 descriptions
were turned down in that run, against 32 to 63 before 73d8513.

Those SGPRs are now left unnamed. A program that reads one is still
refused, by the translator ("a hardware SGPR input"), so nothing is
placed there by guess. All 200 captured descriptions now decode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9eac44a read the root constants entry's byte as their size in bytes.
Against the 200 root signatures captured with their descriptions, that
byte is 4 whatever the count: 1, 2, 3 or 4 constants in the signature
(30 descriptions with 4, 6 with 2, 2 with 1, 1 with 3, all with byte 4).
Programs with more than one constant read SGPRs nothing named and were
refused ("a hardware SGPR input"), 35 of the 200 captures.

The table alone now gives the first constant, and the signature gives
the count of those it names, refused if they run past the program's
user SGPRs. Of the 200 captures, the hardware SGPR refusals are gone
and 11 reach a hardware pipeline (2 before).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 0x218 programs read SCC as a number through operand 253, src_scc:
s_mov_b32 sN, src_scc (283 times in the 37 captures refused for it),
s_add_u32, s_and_b32, s_or_b32, s_mul_i32, s_sub_i32, and VALU
v_mov_b32, v_add_nc_u32 or v_lshl_add_u32. The IR already records the
read of SCC for that operand, but the lowering refused it as "a special
operand (vccz, execz, scc, lds_direct)".

It is now the SCC bit, 0 or 1. A test runs s_mov_b32, s_add_u32 and
v_mov_b32 of src_scc after s_cmp_lg_u32 on the card and on WARP. Of the
200 descriptions captured in game, the special operand refusals are
gone and 17 reach a hardware pipeline (11 before).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Four scalar operations the 0x218 programs use were refused by name:
s_pack_ll_b32_b16 (7 of the 200 captures), s_pack_hh_b32_b16 (4),
s_bitreplicate_b64_b32 (6) and s_bfm_b64 (1). s_pack_lh_b32_b16 comes
with the other two packs.

- s_pack_ll/lh/hh: the low or high half of src0 in the low half, the
  low or high half of src1 in the high half.
- s_bfm_b64: src0[5:0] ones shifted up by src1[5:0], in 64 bits.
- s_bitreplicate_b64_b32: each bit i of src0 in bits 2i and 2i + 1.

None of them writes SCC. A test runs each on the card and on WARP and
reads both halves of the 64-bit ones. Of the 200 captures, those
refusals are gone and 24 reach a hardware pipeline (17 before).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Port of fxceless/victory-fork#146 (67f7ff0) by davi713albano-coder.

image_store packs the channels its dmask enables into consecutive VGPRs
(16-bit halves with d16), in channel order, and writes 0 to the others.
DXIL's typed textureStore writes all four channels, and the host format
drops those past its width, so the disabled ones are written as 0.0.
A store with dmask 0 writes nothing.

Before, only dmask 0xF was taken, and the 0x218 programs' partial
stores were refused ("an image store of some channels", 60 of the 200
descriptions captured in game). Of those 200, 64 now reach a hardware
pipeline (24 before).

The channel order and the zeroed channels follow AMD's MIMG description
as the PR and other RDNA2 translators read it; the test checks this
lowering (10 masks, sparse and d16 ones included) on the host, not the
console's hardware. Adapted here: the test's HostShader takes the two
fields this tree adds.

Co-Authored-By: Castyan <120135015+Castyan@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
buffer_store_format_x, _xy, _xyz and _d16_x by index were refused ("a
typed buffer store of some channels or at an offset", 19 of the 200
descriptions captured in game: 14 d16_x, 3 x, 2 xy, none at an offset).
They now write the channels they give first and 0 to the others, as
image_store writes the channels its dmask leaves out: a typed UAV store
writes all four channels and the host format drops those past its
width. A store at an offset is still refused, with its own message.

A test stores 1 to 4 channels and d16_x by index into a typed RGBA16F
buffer on the card and on WARP and reads all four back. Of the 200
captures, 78 now reach a hardware pipeline (64 before).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
v_ldexp_f32 (src0 * 2^src1, src1 a signed integer) was refused by name
in 10 of the 200 descriptions captured in game. It is now three
multiplies by powers of two that each have a normal float form
(exponents -126 to 127), the exponent first clamped to -378..381: that
covers every exponent that can take a float to or from zero, a denormal
or infinity, and each product is exact until the last, which rounds as
a single ldexp would.

A test runs it on the card and on WARP against f64 references, past
both ends of the range (a result below the normal range may be flushed
to zero). Of the 200 captures, 88 now reach a hardware pipeline (78
before).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The second game run's captures (200 descriptions with their signatures,
including those that do not translate) show where a directly indexed
heap goes. Every program with CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED in its
signature has one user SGPR more than its root parameters take (61),
every one with both heap flags two (43), and no other program has any.
The first is the view heap: those programs add an offset to it, load a
buffer descriptor there (s_load_dwordx4) and read its stride. They were
refused as "an address with two computed terms" or "an address not from
a root parameter".

The view heap is now a ResourceHeap parameter in the dword past the
root parameters, then the sampler heap a SamplerHeap one, when the
program's user SGPRs are exactly that many more; otherwise they stay
unnamed, as before. The translator already reads descriptors from a
ResourceHeap parameter at an index it computes.

Of those 200 captures, the "two computed terms" refusals are gone; the
programs now stop further on, mostly at "an address with an untracked
high half" (44). The 200 earlier captures replay as before (88 reach a
hardware pipeline).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 0x218 programs that read their view heap add an index to the
heap's dword and make the high half with the carry of that sum read as
a number: s_add_u32 s40, s10, s18 then s_add_u32 s41, 0, src_scc. The
tracker took a carry into the high half only as s_addc_u32 x, 0, and
refused these as "an address with an untracked high half" (44 of the
second run's 200 captures).

s_add_u32 of x and src_scc is now x plus the carry, as s_addc_u32 x, 0
is (the same shortcut: offsets below 4 GB). A test tracks such a heap
address. Of the second run's 200 captures, 23 now reach a hardware
pipeline (5 before); the first run's 200 replay as before (88).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two 0x218 programs (one in each captured run) read a signed 16-bit
field out of a scalar with s_sext_i32_i16, which was refused by name.
s_sext_i32_i16 and s_sext_i32_i8 are now the low word or byte of the
source shifted to the top and arithmetically back down; like the
console's, they leave SCC alone (the IR already counted them among
the instructions that do not write it).

A test runs both on the card and on WARP against Rust's sign
extensions (0x7F, 0x80, 0x7FFF, 0x8000, 0xFFFF and bits above the
field) and checks that SCC set by an earlier compare comes through.
Replay: dump-218 24/200 (23 before), dump-218-run4 89/200 (88 before);
no program that reached a hardware pipeline stops reaching it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Seven 0x218 programs of dump-218 (m168-m174) index their arrays with
v_mad_u32_u16, which was refused by name. It is now S0[15:0] *
S1[15:0] + S2, the halves zero-extended and the sum wrapping at 32
bits, with op_sel bits 0 and 1 taking a register's high half instead.
The 66 uses in the 400 captures are of that form: a register, a
literal or an inline integer as src0, a register's either half as
src1, 0 or a full dword as src2. Kept refused: op_sel bits 2-3, op_sel
on a constant, an inline float as a 16-bit source, and (as for every
integer result) clamp.

A test runs it on the card and on WARP against the computation in
Rust, with all four op_sel combinations, a literal, inline integers
and SGPR or VGPR addends, on halves with the top bit set, 0xFFFF *
0xFFFF plus 0xFFFFFFFF, and inputs whose other half differs.

Replay: dump-218 26/200 (24 before: m171 and m173 now reach a hardware
pipeline; m168-m170, m172 and m174 stop further on, at "a first-lane
read where not every lane runs"), dump-218-run4 89/200 (unchanged); no
program that reached a hardware pipeline stops reaching it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Three 0x218 programs of each captured run (m005, m006, m100 and m008,
m010, m062) accumulate packed halves with v_pk_fmac_f16, which was
refused as a packed 16-bit operation. Each half of the destination is
now S0 * S1 + D of the same halves, fused and rounded once to the
nearest even f16, denormals kept. The product of two f16s is exact in
f32 and so is the error of the f32 sum (TwoSum); that sum rounded to
odd and then to f16 (f16_nearest) is the single rounding. Kept
refused: an inline constant, a literal whose halves differ, SDWA and
DPP.

A test runs it on the card and on WARP against an exact integer
reference: midpoints a double rounding gets wrong, denormals, overflow
and the tie to infinity, signed zeros, infinities and NaN, random
halves, and a literal as the programs use it. Without the round-to-odd
step the card gives 0x3e02 for fma(0x3e00, 0x3c01, 0x8001), where the
test wants 0x3e01.

Replay: dump-218 28/200 (26 before: m005 and m006 now reach a hardware
pipeline, m100 stops further on at a lane mask), dump-218-run4 91/200
(89 before: m008 and m010 reach one, m062 stops at the same lane
mask); no program that reached a hardware pipeline stops reaching it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fourteen 0x218 programs of each captured run enable the thread-group
info SGPR (COMPUTE_PGM_RSRC2.TG_SIZE_EN) and read it one way only:
s_and_b32 with 0xfc0, the wave's index in the group times 64, as the
base of v_mbcnt_lo/hi(-1, ...), which makes the thread's flat index in
the group. The SGPR is now the group's wave count in bits 0-5 and the
wave's index in bits 6-11 (where ACO reads num_subgroups and
subgroup_id). The index is that of the console wave holding the thread
whose ids the program gets: its flat id, as thread_id relabels it in
every host form (paired, two host waves per console wave, host waves
of the console's width; the host's own ids without console lanes),
over the console wave size. Lane numbers are that flat id's low bits,
so index * 64 + lane is the console's flat index. What the console
holds above bit 11 is not known, so only reads that mask it off
(s_and_b32 with a mask below 0x1000) are lowered; any other read, or
the value going into a join, is still refused.

A test runs the programs' form on the card in the paired form, as two
host waves of 32, as a console wave32 program with a partial last wave
and without lane operations, and checks every thread's index, wave
count and low 12 bits against the console's; with the index taken over
32 lanes it fails (thread 32: 0x60 for 0x20). Another checks that a
whole read and a mask with bit 12 are refused.

Replay: dump-218 38/200 (28 before: m001-m004, m019, m021, m025, m026,
m028, m029 now reach a hardware pipeline; m020, m022, m065, m066 stop
further on, at lane masks), dump-218-run4 101/200 (91 before: the same
ten programs as m001-m004, m031, m036, m038, m039, m041, m042; m032,
m035, m044, m045 stop at lane masks); no program that reached a
hardware pipeline stops reaching it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two 0x218 programs of dump-218 (m185 at 0x13c, m188 at 0x154) take
what is left of a count with v_sub_nc_u32 ... clamp, which was refused
as an integer output modifier. On these three unsigned 32-bit
operations the clamp bit saturates the result: 2^32 - 1 when the sum
passes the top, 0 when the difference goes below 0. Kept refused:
omod, clamp with SDWA or DPP, and clamp on every other integer
operation. The wave-operation simulation already takes a clamped
operation for an unknown value.

A test runs all three on the card and on WARP with and without clamp
over pairs of edge values (0, 1, 2, 2^31 - 1, 2^31, 2^32 - 2, 2^32 - 1
and another) against Rust's saturating and wrapping arithmetic; without
the saturation it fails (1 + 0xffffffff).

Replay: dump-218 40/200 (38 before: m185 and m188 now reach a hardware
pipeline), dump-218-run4 101/200 (unchanged); no program that reached
a hardware pipeline stops reaching it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Three 0x218 programs (m178 and m183 of dump-218, m132 of
dump-218-run4) refused as "a first-lane read where not every lane
runs" are that only in the form with two host waves per console wave,
which cannot read the console's first lane inside a lane branch. The
paired form, which can, stopped at their buffer_atomic_sub. It is now
DXIL's atomic add of the negated data: the same dword modulo 2^32, and
with glc the same dword from before.

A test runs three subtractions from one dword on the card and on WARP,
the last with glc, over pairs of edge values (0, 1, 7, 2^31,
2^32 - 1) against 0 - a - b in Rust; lowered as an add it fails.

Replay: dump-218 40/200, dump-218-run4 101/200 (both unchanged: the
paired form of the three programs now stops at "a descriptor's
address or format read as data"); no program that reached a hardware
pipeline stops reaching it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two 0x218 programs of dump-218 (m077, m079) negate SCC with
s_absdiff_i32 sN, src_scc, 1, which was refused. The result is now
|src0 - src1| as the ISA's pseudocode computes it on 32 bits: the
difference wraps, and its absolute value too, so i32::MIN (as a
difference or as an overflow such as 0x7fffffff - -1) stays i32::MIN.
SCC is the result != 0, as for s_abs_i32, whose lowering it shares.

A test runs it on the card and WARP against the wrapping reference in
Rust, with 0 - 0, both orders, i32::MIN on either side, overflowing
differences and their SCC; without the change it is refused.

Replay: dump-218 103/200, dump-218-run4 165/200, as before: m077 and
m079 now stop further on, at the SCC of s_and_b64 vcc, exec (the any
lane of a mask) read as data by this s_absdiff_i32 ("a lane mask read
as data"); no program that reached a hardware pipeline stops reaching
it.

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

Copy link
Copy Markdown

At the exact PR head tested:

At 9457437, the stock packed FP16 FMA test passed on physical RTX 5070 and WARP with 768 additional finite sign, denormal, cancellation and overflow triples checked against the integer reference. This tests packed FMA only; the other opcodes and title captures were not independently verified.

Verification was AI-assisted with GPT-6.2 Astra.

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.

3 participants