Skip to content

Test upstream unknown-stride shader support on D3D12 - #2

Draft
yourmomsbasement wants to merge 13 commits into
mainfrom
integration/shader-unknown-stride
Draft

yourmomsbasement wants to merge 13 commits into
mainfrom
integration/shader-unknown-stride

Conversation

@yourmomsbasement

@yourmomsbasement yourmomsbasement commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

This draft brings in Marvisak#704 at 1f3c184, including its runtime stride-table dependency Marvisak#193. It preserves the upstream commit history and targets the fork’s main directly.

The stack gives shaders whose structured-buffer stride is unknown at translation time a raw view of the same bytes. It handles descriptor slots selected per lane and keeps alias lifetime tied to descriptor retirement.

The trial integration passed git diff --check and a Windows MSVC workspace cross-check with blake3/pure on Linux. The fork’s Windows CI run passed both Clippy steps and cargo test --workspace --locked. The focused WARP run passed all five tests: three shader readbacks, one raw descriptor-view readback, and one descriptor-retirement test. The verification branch was based on this exact head and required a Shader Model 6.6 WARP device so a skipped dispatch could not pass. Hardware GPU readbacks are pending a Windows GPU machine.

D3D12 test plan

On Windows with a Shader Model 6.6 GPU, run these with the normal hardware adapter and both WARP environment variables unset:

cargo test -p victory-shader --lib --locked unknown_stride -- --test-threads=1
cargo test -p victory-gpu --lib --locked raw_view_tests -- --test-threads=1

Record the adapter, driver, which tests actually dispatched, and any D3D12 debug-layer messages. If running a title comparison, use the same settings on main and this branch and record unknown-stride refusals, dropped dispatches, and any device removal.

n-romanovich and others added 13 commits November 24, 2026 04:14
… names

A buffer read whose element stride is not known at translation takes a
raw handle and a byte offset from the runtime stride table. The handle
was of the slot the title's view is in, and a raw handle over a
structured or typed view is undefined in D3D12: for the load of
[index 2, offset 4] an RTX 5070 reads dword 21 of a structured view of
12 bytes (dword 7 asked for) and dword 36 of one of 16 bytes or a typed
RGBA32F one (dword 9 asked for), where a Radeon and WARP read the bytes
asked for. No handle of another kind is right everywhere either: with a
structured handle whose declared stride differs from the view's, the RTX
5070 addresses by the view's stride and the Radeon and WARP by the
declared one.

The table's entry per slot is now a StrideEntry of two dwords: the
stride, and the heap slot holding a raw view of the bytes the slot's
view reads (none: the slot's own view is raw), with the bytes from that
raw view's start to the view's first byte (raw views start on 16 bytes
on the host). The shader reads, stores and runs atomics through a raw
handle of the slot named, so the handle's kind always matches the view.
RawWindow gives the host the raw view for a byte range.

The GPU side writes the new entries without raw slots yet, which reads
as before.

The test binds raw, structured (12, 16, 20 bytes) and typed (RGBA32F,
R32_UINT) views, as shader views for the load and as unordered access
views for the store and the atomics, with their raw views beside them,
on the hardware adapter and WARP; a second one takes the descriptor
from a join of two loads.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The programs that read a buffer without a known stride pick its heap
slot at run time, so the runtime stride table has to be looked up by the
slot the shader computes, and the view in it can differ from one thread
group to the next.

A new test loads the heap slot from a buffer per thread group (a scalar
load whose offset is the loaded value), with a structured view of 12
bytes in one slot and one of 16 bytes in the other: the four lanes of
each group read the bytes of the view their group chose, in one dispatch
and again with the choice swapped. A lane reading past the three
elements of the first view reads zero, not the buffer's next bytes.

The test host's raw views now cover a window of the buffer (as
RawWindow gives the host for a view's elements) rather than all of it,
which is what ends the read there; the view kinds test takes its raw
views and entries from the same function, with views starting 4 and 12
bytes into their raw views.

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

A shader that reads a buffer without knowing its stride takes a raw
handle of the slot the runtime stride table names. The host heap now
makes that slot: when it makes a structured or typed buffer view (for a
shader or for unordered access), it also makes a raw view of the same
bytes of the same host copy in a pool of 65,536 slots after the dynamic
ones, and writes the slot, the stride and the bytes from the raw view's
start to the view's first byte (raw views start on 16 bytes) into the
slot's entry. A raw view keeps its own slot. The raw view ends with the
view's last element, so reads past it give zeros.

The entry and the raw view are written wherever the slot's descriptor
is (tables made for a draw, title slots a draw reads through a table,
slots made null), so they are as current as the descriptor; a slot made
again reuses its raw view slot, and one made null, raw or constant, or
a dynamic slot given back, returns it to the pool. Views the host
cannot make raw (starting off a dword of the copy, or with the pool
full) point at a null raw view and are logged once.

The test makes placed structured, typed and raw views in a host heap
and runs the translated program of victory-shader's run-time slot test
on it: each thread group reads the bytes of the view in the slot it
chose, zeros past the view's end, and the new view's bytes after the
slots are made again.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
main moved under Marvisak#193 and this branch. One conflict, in
HostHeap::new (descriptor/host.rs): Marvisak#336 tries the heap with DYNAMIC
dynamic slots, then with MIN_DYNAMIC, then capped, and records the range it
got in `dynamic`; this branch puts ALIASES raw-view slots after the dynamic
ones. Both kept: each attempt asks for the alias slots too, the capped
count leaves room for them, the lease bitmap has `extra` entries as on
main, and `alias_base` stays `count + extra`. A merge rather than a rebase
so Marvisak#193's commits keep their ids.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…clamps, and non-multiple-of-4 stride refusal
main now has CI (clippy with -D warnings, then the workspace's tests). No
conflict; both of CI's clippy commands are clean on the result.

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

Marvisak#193 moved: buffer views are clamped to what is left of the host copy, a
shader that reads the stride table without a host view heap is not run,
and a known stride that is no multiple of four is refused. Conflicts were
with main, not with this branch's change: `bind` already returns whether
the draw may run (Marvisak#336), with its doc comment and the dropped counter, and
main already renamed the second test module in host.rs. main's side kept
in all three; Marvisak#193's `return false` in the stride-table branch is in.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The three tests in emit/mod.rs that dispatch through `hosts()` ran
without `valu_tests::ONE_AT_A_TIME`, so with WARP they could dispatch
at the same time as another module's GPU test. Two GPU tests at once on
WARP can end the test process with an access violation; that is how
the shader test process died with 0xc0000005 on CI for 505d5b1.

Locally, `VICTORY_WARP=1 cargo test -p victory-shader --lib` at the
default thread count crashed 2 of 4 runs without this change, and
passed 6 of 6 with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

4 participants