Skip to content

[BUNDLE] Unknown-stride buffers: #704 on #193, stacked on #1511 - #1644

Closed
MamaLeVrai wants to merge 117 commits into
Marvisak:mainfrom
MamaLeVrai:bundle/stride-stack
Closed

MamaLeVrai wants to merge 117 commits into
Marvisak:mainfrom
MamaLeVrai:bundle/stride-stack

Conversation

@MamaLeVrai

@MamaLeVrai MamaLeVrai commented Nov 24, 2026 •

Copy link
Copy Markdown

One PR in place of 2. Unknown-stride structured buffers are one of the two compute walls left in YaBulochka's retail run on #1402 (6 shaders there) and the third reason in Impre-visible's list on #1589 (56 shaders). Two open PRs address it: #193 (a runtime stride table for structured buffers) and #704, which is stacked on it and reads such buffers through a raw view of the same bytes. #704's branch carries #193's commits, so the two are one merge. On top of the shader stack (#1319, #1402, #1492, #1504, #1511). Every head is merged unchanged onto main plus #1511, and the result is built and tested together.

For reviewers and for anyone verifying with an agent (Claude, Codex, a person): this is a [BUNDLE] PR. The re-verification commands are below, so one run covers all of it.

What is inside

PR Author Head Title
#193 n-romanovich f99b792 Shaders, GPU: add runtime stride table for structured buffers
#704 r4tedx 1f3c184 Shaders, GPU: unknown-stride buffers are read through a raw view of the same bytes (stacked on #193)

Changes made while bundling

No PR was edited. Two things on the stack:

  1. Tests at the end of emit/mod.rs: the stack and Shaders, GPU: unknown-stride buffers are read through a raw view of the same bytes (stacked on #193) #704 both add helpers and tests there; both sets are kept (a join, nothing dropped).
  2. stride_table: Shaders, GPU: add runtime stride table for structured buffers #193 adds the field to HostShader; two literals in tests that the stack adds (validate_and_create_cs_pso in emit/shader.rs and the root view test) get it, in a separate commit.

Left out, and why

Verification

Windows 11, RX 6950 XT, Rust 1.98.1 (the pinned toolchain):

Check Result
cargo clippy --workspace --all-targets --locked -- -D warnings clean
cargo clippy --workspace --all-targets --all-features --locked -- -D warnings clean
cargo test --workspace --locked 412 passed, 0 failed, 6 ignored (two runs; main: 342 passed, 6 ignored)

The title was not run, so this says nothing about in-game effect. No game data is used or committed.

Re-verify in one go

git fetch https://github.com/MamaLeVrai/VIctory.git bundle/stride-stack
git checkout FETCH_HEAD
cargo clippy --workspace --all-targets --locked -- -D warnings
cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
cargo test --workspace --locked

To confirm that no component PR moved since this was built, compare each Head above with gh pr view <n> --repo Marvisak/VIctory --json headRefOid. If one differs, the branch needs a rebuild: merge the new head in the same order.

If this lands

The component heads are in the history unchanged, so each PR's commits and authorship are kept and GitHub should mark them merged. Merging them one by one instead works too, with the exceptions noted above.

AI-assisted (Claude Code); no game data.

🤖 Generated with Claude Code

n-romanovich and others added 30 commits November 24, 2026 04:14
Pixel programs that use the I/J VGPRs as plain values (custom
interpolation, math on the weights) failed with "barycentrics read
directly". They are now channels y and z of an SV_Barycentrics input
(SM 6.1+, the emitter targets 6.6) declared with the interpolation mode
of their kind (perspective/linear, center/centroid/sample), one element
per mode (semantic index 0 and 1), with the Barycentrics shader flag and
SFI0 feature. GFX10 interpolates P0 + i (P1 - P0) + j (P2 - P0) with P0
the provoking vertex, which the host's barycentrics weight as vertex 0,
so i = y and j = z.

The VGPRs are loaded on first use as a value, so programs that only feed
them to v_interp_* declare nothing new. A console signature's own
SV_Barycentrics row (D3D name 23) is parsed and reused. Pull-model
barycentrics stay unsupported.

SV_Barycentrics is left unpacked (no row, packing location -1), like
other non-packed system values: the DXIL validator refuses it in a row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
v_interp_p1/p2 (and the f16 forms) fed with an i or j that is not the
loaded input VGPR now evaluate each half as the hardware does: P0 + i
(P1 - P0) for the first, the old dst + j (P2 - P0) for the second, with
the vertex values read by attributeAtVertex. That needs the element
declared constant, so every other interpolation of the same attribute
row is weighed from its vertices with SV_Barycentrics of its mode, and
flat reads stay loadInput of the provoking vertex. v_interp_mov of P10
and P20 reads P1 - P0 and P2 - P0 the same way when the program also
interpolates the attribute (so the hardware holds the deltas); alone it
is still refused.

The translate command's tally counts Interp::Weighted as interpolated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
image_sample_d_cl was refused by name, and behind it every program hit
a cube sample with explicit gradients, refused as "a cube sample with
... gradients". Both now translate to sampleGrad:

- A cube's gradients on GFX10 are of the face coordinates (s, t), four
  addresses rather than six, so the coordinates follow at 4. They become
  the direction's gradients through the face's linear part of
  cube_direction (u = 2s - 3, v = 2t - 3; the major axis does not move),
  in the new cube_gradient.
- `_cl`: the level-of-detail clamp follows the coordinates and is passed
  as sampleGrad's clamp.

translate --validate on shaders.rpf: vertex/pixel 12172 -> 12197
validated; both errors are gone from the list. Not yet compared against
the console's sampling at runtime.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… 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>
lower.rs: keep the PR's lazy barycentric VGPR inputs next to main's
`Reg::S(n)` arm for uninitialized SGPRs. mod.rs: the barycentric test
helper passes the structure to resource::track, which now takes it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
DXIL allows at most two SV_Barycentrics input elements, one perspective
and one linear. A program reading both perspective center and centroid
I/J as values declared two perspective elements, which the validator
refuses ("There can only be up to two input attributes of
SV_Barycentrics with different perspective interpolation mode").

The second mode of the same kind is now an Unsupported reason rather
than a second element. Reusing the first element would hand centroid
reads center weights (or the reverse), which differ on edge pixels: a
silent wrong value. Before this PR such reads were refused anyway.

Test: center + centroid values are refused; centroid alone still
translates with one element.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
The ISA's special cases in its order: a NaN numerator or denominator comes
back quieted, 0/0 and inf/inf give NaN, x/0 and inf/x a signed infinity,
0/x and x/inf a signed zero, otherwise |S0| with the quotient's sign.
Worked on the f32 values of the f16 operands, which are exact.
The ISA's "exponent of S0 all ones -> overflow" check runs before the
final |S0| case, so a NaN quotient with a finite, non-zero numerator and
denominator gives sign | infinity, as measured on gfx1036 hardware. The
zero, infinity and invalid checks still come first.
These write SCC, but their lowering gave no SCC value, so the generic
"result is not zero" stood in. The ISA sets it otherwise:

- s_min_i32/u32, s_max_i32/u32: SCC = 1 when src0 is the value chosen
  (src0 < src1 for min, src0 > src1 for max).
- s_lshl1..4_add_u32: SCC = 1 when (src0 << n) + src1 overflows 32
  bits, through bits shifted out of src0 or the add's carry.

So s_min_u32(5, 3) left SCC = 1 (3 is not zero) where the hardware
leaves 0, and s_lshl1_add_u32(1, 0xFFFFFFFE) left 0 where it leaves 1;
an s_cselect or s_cbranch_scc after them took the wrong side.
The d16 forms of the typed buffer loads return each channel as 16 bits,
two per VGPR, low half first; the decoder already sizes their data that
way. The lowering only treated `buffer_` names as d16, so a
tbuffer_load_format_d16_* went through the 32-bit path: the first VGPR
got channel x as a 32-bit value (the f32 bits of 1.0 instead of the f16
pair (1.0, 2.0)) and the other channels were dropped.

The format path now packs its channels for d16: integer formats keep
their low 16 bits, the other formats become f16 (as the MUBUF d16 path
converts them).
SDATA on s_atc_probe and s_atc_probe_buffer is a 7-bit immediate, the buffer resource is four dwords, and GLC/DLC are not operands of either.
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>
MamaLeVrai and others added 8 commits November 24, 2026 20:21
…#1504, verified together

Merges Marvisak#1145 Marvisak#343 Marvisak#1042 Marvisak#1303 Marvisak#477 on top of the stack of Marvisak#1504 (Marvisak#1319,
Marvisak#1402, Marvisak#1492, Marvisak#1504, on main ffe310e), each head unchanged, no conflicts
and no changes of mine. cargo clippy --workspace --all-targets --locked
-- -D warnings, with and without --all-features, is clean and cargo test
--workspace --locked passes (406 passed, 6 ignored; main has 342 passed,
6 ignored).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…the shader stack, joining its tests with the stack's

Marvisak#704 is stacked on Marvisak#193 (runtime stride table); its branch carries Marvisak#193's
changes. The tests at the end of emit/mod.rs conflicted with the stack's
(both add helpers and tests there); both are kept.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…stack's tests

Marvisak#193 adds `stride_table` to HostShader. The literals in validate_and_create_cs_pso
(emit/shader.rs) and the root view test (emit/root_view_tests.rs, Marvisak#1056) lack
the field; each now has it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Marvisak#1511, verified together

Merges Marvisak#704, which is stacked on Marvisak#193 and carries its runtime stride table,
on top of the stack of Marvisak#1511 (Marvisak#1319, Marvisak#1402, Marvisak#1492, Marvisak#1504, Marvisak#1511, on main
ffe310e), its head unchanged. The tests at the end of emit/mod.rs, which
both the stack and Marvisak#704 extend, are joined; two HostShader literals of the
stack's tests get Marvisak#193's `stride_table` field (a separate commit).

cargo clippy --workspace --all-targets --locked -- -D warnings, with and
without --all-features, is clean and cargo test --workspace --locked passes
(412 passed, 6 ignored, two runs; main has 342 passed, 6 ignored).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 24, 2026 20:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

…on old validators

PSV0 shared one string-table copy of a repeated semantic name (TEXCOORD0
and TEXCOORD1 pointing at the same "TEXCOORD"). DXC's PSV writer writes
one copy per element, and validators before 1.8 compare PSV0 byte for
byte, so any signature repeating a name was rejected there ("Pipeline
State Validation does not match"); 1.8 compares the strings and accepted
both. Checked against dxil.dll 1.7, 1.8 and 1.9.

Validator::version() reads IDxcVersionInfo; the compute-derivative test
skips dxil.dll validation when the validator predates 1.8, which rejects
dx.valver 1.8 outright. Translated shaders never go through dxil.dll.

Reported by @alexdeliu.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MamaLeVrai and others added 5 commits November 24, 2026 21:51
….dll is older than validator 1.8"

This reverts commit 119b763.
…tic names per element, skip on validators older than 1.8)

The author's head now does what the bundle's own commit did (a validator version query and the
skip below 1.8), and fixes the second failing test at its cause; the bundle's commit is
reverted just before this merge.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ring

The shader chain moved: Marvisak#306 is at its author's new head (e3067ae), and the bundle's own
validator commit is reverted.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…centrics

The shader chain moved: Marvisak#306 is at its author's new head (e3067ae), and the bundle's own
validator commit is reverted.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…bustness

The shader chain moved: Marvisak#306 is at its author's new head (e3067ae), and the bundle's own
validator commit is reverted.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The shader chain moved: Marvisak#306 is at its author's new head (e3067ae), and the bundle's own
validator commit is reverted.

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

Copy link
Copy Markdown
Owner

Automated triage for the maintainers. Closing because this pull request re-packages other open pull requests. Each of those is reviewed on its own, so a bundle cannot be merged.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: crates/victory-gpu/src/descriptor/host.rs, crates/victory-gpu/src/draw.rs, crates/victory-gpu/src/pipeline/host.rs, crates/victory-gpu/src/shader_cache.rs, crates/victory-shader/src/emit/bitcode.rs). It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.