Three dataflow rules for mask provenance, descriptor provenance and buffer stride, stated against your open PRs on the same seams #1482

Open
opened 2026-11-26 04:33:32 +00:00 by github-bot · 2 comments
Owner

@⁠MoonYueya on GitHub · 2026-11-24 18:20 UTC · original

What this is, and what it is not

A second, independent GTA VI Xbox→PC attempt (Project Leonida). We classified 303 translation failures from one world-frame window (posted separately); this issue is the three rules we use where the same seams your open PRs are already working. For each rule we say first what overlaps, then only what does not.

AI-assisted write-up, human-checked against our own reports. No game bytes, no shader names.

We are not offering a patch in this issue. Where we have code, it goes as a PR and gets linked here.


Rule 1 — A mask needs materialising only if something downstream reads its whole value

Overlaps: #1115 (a v_cndmask_b32 whose mask is s_cselect -1, 0 is refused as "an untracked mask"), #878 (mask dwords at data joins; ready to merge), #750 (redundant masked write after a per-lane descriptor join). Your ir.rs:551 liveness() already computes live_in / live_out — but at block granularity, a RegSet per basic block.

What we do differently is the granularity and the question. Instead of asking "is this value a mask?" at the use site, ask "does anything read this register's whole value before it is overwritten, and if not, does it need a value at all?"

  • A register is whole-live after an instruction when some path may read its full value before it is written again: any SALU or SMEM operand, any VALU scalar operand, a branch on VCCZ, and so on.
  • A mask write whose destination is not whole-live needs no materialisation. Only the reading lane's own bit is ever consulted — v_cndmask_b32's mask, the carry-in of v_add_co_ci / v_sub(rev)_co_ci — and that lane's half of the wave already holds it.
  • A mask write whose destination is whole-live is materialised as a ballot.

The point is that the refusal condition cannot arise for the first class, so it stops being an error path rather than becoming a special case.

Three details that cost us real debugging time. They are the difference between this producing a refusal and producing a silently wrong translation:

  1. A write is not an overwrite. Treat a mask write as killing the old value only where the emitter replaces the register whatever it held: not s_cmov* (conditional), not s_addk / s_mulk / s_bitset* (they read the old value), not s_movreld / s_movrelsd (they write s[dst + m0]), and not SDWA compares that write their SDST instead of VCC.
  2. s_movrels* reads s[src + m0], so every register from src upward is live, not just src. SDWA scalar sources (S0 / S1) and SMEM register offsets are reads too.
  3. Conservative where you cannot see: an indirect jump makes every SGPR whole-live; EXEC is always whole-live; every SGPR is whole-live at the end of a program that reads state back; and anything live after an emitted loop is live before each of its instructions, because the loop may be left at its iteration-budget check.

Where this lands relative to #878. #878's data-join shortcut takes undef on the non-data edge, which is the same assumption #180 makes for descriptor dwords. That is sound only if rule detail 1 holds — if a register that looks dead is actually read-merged, the undef becomes a wrong value rather than a refusal.

Honest scope: this involves all 127 class-A failures, but we are not claiming it recovers all 127. The 60 a lane mask holding lanes elsewhere read as data cases read bits belonging to the other half of the wave; whether whole-liveness covers them depends on where those bits are consumed, and we have not measured that split.


Rule 2 — A descriptor's console fields survive translation; only word 0 and the sampler index change

Overlaps: #1130 (a descriptor read only as data takes the kind of another load of the same heap entry — 819 → 53 programs), #1067 (kind from the table range — 4,123 → 3,749), #1325 (4-dword buffer views inferred from UsedResource, closed), plus #979 and #798. These are the right direction and they cover most of class B (62 failures).

What we would add is a representation argument, not a tracking one. Our lowering never rebuilds a descriptor from host-side knowledge at the use site. The console's words live in SGPRs and the shader reads them raw:

Texture2D<float4> t_T = ResourceDescriptorHeap[NonUniformResourceIndex(tw0)];
SamplerState     t_S = SamplerDescriptorHeap[NonUniformResourceIndex(s3 & 0xFFFu)];

tw0 is exactly the SGPR the descriptor was loaded into — no mask, no shift. What makes that legal is that the runtime rewrites the descriptor on the way into the heap:

T# word 0             -> the SRV's index in the PC heap   (word 1's high byte cleared)
S# word 3 bits [11:0] -> the sampler's index in the PC heap
every other field (format, size, swizzle, dst_sel) -> untouched, exactly as the console wrote it

Why that dissolves the largest class-B shape. a descriptor read only as data (51 of 62) means the program used the descriptor's words for arithmetic — dimension reads, address arithmetic — without ever sampling through it. If words 1–3 still hold the console's own numbers, a program doing arithmetic on stride, num_records or format gets the values it expects, with no inference needed at all. Only word 0 means something different, and word 0 is the field a program should not be doing arithmetic on. In our corpus it does not: the arithmetic touches dwords 1–3.

Your resource.rs:47 comment already records dword 1 (stride, swizzle), dwords 2 and 3 as given for the built case, so the field semantics are clearly understood here. The open question we would raise is whether the loaded path keeps those fields byte-identical when the descriptor reaches the shader.

One measurement worth having before anyone treats the descriptor heap address as a blocker. We spent a round convinced the 32-bit table address in a root argument was fatal, because our host heaps all landed above 4 GiB — 19 segments of 65,536 descriptors, every one of them. It was not fatal; we had conflated two layers. On the console, that dword is the 32-bit UMA address of the table's first slot. After translation it must be the heap-relative index of that slot. If any part of a pipeline treats it as an address end to end, a whole cluster of descriptor failures can come from that one representation question. (This measurement is from a separate experiment in our project, not the three-minute run above.)


Rule 3 — stride == 0 is a raw buffer, not an unknown one

Overlaps: #155 (runtime stride channel, design + anchors), #193 (runtime stride table for structured buffers), #704 (unknown-stride buffers read through a raw view of the same bytes, stacked on #193). Those three are the complete line on this, and #704 in particular is close to the conclusion.

The predicate we use for the same V# field:

  • stride 0 = raw. num_records counts bytes, and the descriptor is a flat byte buffer.
  • stride != 0 = structured or typed. num_records counts elements, and the element size is the stride.

The stride is V# dword 1 bits [29:16], the count is dword 2. So a stride-0 descriptor arriving at a structured-buffer path is not an unknown stride — it is the wrong path. Concretely, your three refusals read if stride < 4 || !stride.is_multiple_of(4) { return Err("a structured buffer of unknown stride") } (emit/lower.rs:6281, :6364, :6425), which catches 0, 1, 2 and 3 together.

What we would check first: how many of the 27 are stride exactly 0. If they are, the fix is a branch rather than an analysis, and the error string is currently hiding a routing decision inside a tracking failure. We have not measured that split on your corpus — this is a hypothesis with a cheap test.

A second suggestion for class D, on a scalar memory read as data (18). #979 reports 771 programs offline with this string and finds the use instruction is always an s_ operation. One addition: not every s_load is a descriptor load. s_load_dword from a constant table appended after the code — read through s_getpc_b64 — is data by construction, and it appears in the same programs. Splitting on "is the base a s_getpc_b64 result" separates two populations that currently share one string, and only one of them is a descriptor problem.


What we are not claiming

  • We have not run your shader cache. These are rules we apply, not a claim that our translator handles your corpus better.
  • Rules 1–3 are corpus measurements on our copy of the title; the counts that go with them are in the companion measurements issue.
  • Nothing here is verified to be sufficient for a drawn world. See the companion issue's closing paragraph.

Related PRs will be linked here.

Project Leonida, 2026-11-24. AI-assisted write-up, human-verified.

Measurements behind these rules: #1481.

**@⁠MoonYueya** on GitHub · 2026-11-24 18:20 UTC · [original](https://github.com/Marvisak/VIctory/issues/1482) ### What this is, and what it is not A second, independent GTA VI Xbox→PC attempt (*Project Leonida*). We classified 303 translation failures from one world-frame window (posted separately); this issue is the three rules we use where **the same seams your open PRs are already working**. For each rule we say first what overlaps, then only what does not. **AI-assisted write-up, human-checked against our own reports.** No game bytes, no shader names. We are not offering a patch in this issue. Where we have code, it goes as a PR and gets linked here. --- ### Rule 1 — A mask needs materialising only if something downstream reads its whole value **Overlaps:** #1115 (a `v_cndmask_b32` whose mask is `s_cselect -1, 0` is refused as "an untracked mask"), #878 (mask dwords at data joins; ready to merge), #750 (redundant masked write after a per-lane descriptor join). Your `ir.rs:551 liveness()` already computes `live_in` / `live_out` — but at **block granularity**, a `RegSet` per basic block. **What we do differently is the granularity and the question.** Instead of asking "is this value a mask?" at the use site, ask "does anything read this register's *whole* value before it is overwritten, and if not, does it need a value at all?" - A register is **whole-live** after an instruction when some path may read its full value before it is written again: any SALU or SMEM operand, any VALU scalar operand, a branch on `VCCZ`, and so on. - A mask write whose destination is **not** whole-live needs **no materialisation**. Only the reading lane's own bit is ever consulted — `v_cndmask_b32`'s mask, the carry-in of `v_add_co_ci` / `v_sub(rev)_co_ci` — and that lane's half of the wave already holds it. - A mask write whose destination **is** whole-live is materialised as a ballot. The point is that the refusal condition cannot arise for the first class, so it stops being an error path rather than becoming a special case. **Three details that cost us real debugging time.** They are the difference between this producing a refusal and producing a *silently wrong* translation: 1. **A write is not an overwrite.** Treat a mask write as killing the old value only where the emitter replaces the register whatever it held: not `s_cmov*` (conditional), not `s_addk` / `s_mulk` / `s_bitset*` (they read the old value), not `s_movreld` / `s_movrelsd` (they write `s[dst + m0]`), and not SDWA compares that write their SDST instead of VCC. 2. **`s_movrels*` reads `s[src + m0]`**, so every register from `src` upward is live, not just `src`. SDWA scalar sources (S0 / S1) and SMEM register offsets are reads too. 3. **Conservative where you cannot see:** an indirect jump makes every SGPR whole-live; `EXEC` is always whole-live; every SGPR is whole-live at the end of a program that reads state back; and anything live after an emitted loop is live before each of its instructions, because the loop may be left at its iteration-budget check. **Where this lands relative to #878.** #878's data-join shortcut takes `undef` on the non-data edge, which is the same assumption #180 makes for descriptor dwords. That is sound only if rule detail 1 holds — if a register that looks dead is actually read-merged, the `undef` becomes a wrong value rather than a refusal. **Honest scope:** this involves all **127** class-A failures, but we are not claiming it recovers all 127. The 60 `a lane mask holding lanes elsewhere read as data` cases read bits belonging to the *other* half of the wave; whether whole-liveness covers them depends on where those bits are consumed, and we have not measured that split. --- ### Rule 2 — A descriptor's console fields survive translation; only word 0 and the sampler index change **Overlaps:** #1130 (a descriptor read only as data takes the kind of another load of the same heap entry — 819 → 53 programs), #1067 (kind from the table range — 4,123 → 3,749), #1325 (4-dword buffer views inferred from `UsedResource`, closed), plus #979 and #798. These are the right direction and they cover most of class B (62 failures). **What we would add is a representation argument, not a tracking one.** Our lowering never rebuilds a descriptor from host-side knowledge at the use site. The console's words live in SGPRs and the shader reads them raw: ```hlsl Texture2D<float4> t_T = ResourceDescriptorHeap[NonUniformResourceIndex(tw0)]; SamplerState t_S = SamplerDescriptorHeap[NonUniformResourceIndex(s3 & 0xFFFu)]; ``` `tw0` is exactly the SGPR the descriptor was loaded into — no mask, no shift. What makes that legal is that **the runtime rewrites the descriptor on the way into the heap**: ``` T# word 0 -> the SRV's index in the PC heap (word 1's high byte cleared) S# word 3 bits [11:0] -> the sampler's index in the PC heap every other field (format, size, swizzle, dst_sel) -> untouched, exactly as the console wrote it ``` **Why that dissolves the largest class-B shape.** `a descriptor read only as data` (51 of 62) means the program used the descriptor's *words* for arithmetic — dimension reads, address arithmetic — without ever sampling through it. If words 1–3 still hold the console's own numbers, a program doing arithmetic on stride, `num_records` or format gets the values it expects, with no inference needed at all. Only word 0 means something different, and word 0 is the field a program should not be doing arithmetic on. In our corpus it does not: the arithmetic touches dwords 1–3. Your `resource.rs:47` comment already records `dword 1 (stride, swizzle), dwords 2 and 3 as given` for the *built* case, so the field semantics are clearly understood here. The open question we would raise is whether the *loaded* path keeps those fields byte-identical when the descriptor reaches the shader. **One measurement worth having before anyone treats the descriptor heap address as a blocker.** We spent a round convinced the 32-bit table address in a root argument was fatal, because our host heaps all landed above 4 GiB — 19 segments of 65,536 descriptors, every one of them. It was not fatal; we had conflated two layers. On the console, that dword is the **32-bit UMA address of the table's first slot**. After translation it must be the **heap-relative index of that slot**. If any part of a pipeline treats it as an address end to end, a whole cluster of descriptor failures can come from that one representation question. *(This measurement is from a separate experiment in our project, not the three-minute run above.)* --- ### Rule 3 — `stride == 0` is a raw buffer, not an unknown one **Overlaps:** #155 (runtime stride channel, design + anchors), #193 (runtime stride table for structured buffers), #704 (unknown-stride buffers read through a raw view of the same bytes, stacked on #193). Those three are the complete line on this, and #704 in particular is close to the conclusion. **The predicate we use for the same V# field:** - **stride 0 = raw.** `num_records` counts **bytes**, and the descriptor is a flat byte buffer. - **stride != 0 = structured or typed.** `num_records` counts **elements**, and the element size is the stride. The stride is V# dword 1 bits [29:16], the count is dword 2. So a stride-0 descriptor arriving at a structured-buffer path is **not an unknown stride — it is the wrong path**. Concretely, your three refusals read `if stride < 4 || !stride.is_multiple_of(4) { return Err("a structured buffer of unknown stride") }` (`emit/lower.rs:6281`, `:6364`, `:6425`), which catches 0, 1, 2 and 3 together. **What we would check first:** how many of the 27 are stride **exactly 0**. If they are, the fix is a branch rather than an analysis, and the error string is currently hiding a routing decision inside a tracking failure. We have not measured that split on your corpus — this is a hypothesis with a cheap test. **A second suggestion for class D, on `a scalar memory read as data` (18).** #979 reports 771 programs offline with this string and finds the use instruction is always an `s_` operation. One addition: not every `s_load` is a descriptor load. `s_load_dword` from a constant table appended after the code — read through `s_getpc_b64` — is data by construction, and it appears in the same programs. Splitting on "is the base a `s_getpc_b64` result" separates two populations that currently share one string, and only one of them is a descriptor problem. --- ### What we are not claiming - We have not run your shader cache. These are rules we apply, not a claim that our translator handles your corpus better. - Rules 1–3 are corpus measurements on our copy of the title; the counts that go with them are in the companion measurements issue. - Nothing here is verified to be sufficient for a drawn world. See the companion issue's closing paragraph. **Related PRs will be linked here.** *Project Leonida, 2026-11-24. AI-assisted write-up, human-verified.* Measurements behind these rules: #1481.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:33:32 +00:00
Author
Owner

@⁠studiostephe on GitHub · 2026-11-25 07:16 UTC · original

Rule 3, confirmed and fixed: a used-resource stride of 0 is a raw buffer, not an unknown one.

What's wrong

Lower::buffer reads a table descriptor's element through the index arm, which checks
stride < 4 || !stride.is_multiple_of(4) and refuses otherwise (lower.rs load :9072, store :8964, atomic :8830 on main 940d32f). That catches 0 together with the genuinely unknown 1, 2 and 3. On the console a stride of 0 means the buffer is raw — num_records (descriptor dword 2) counts bytes, not elements, and the element index is a byte offset. So a raw buffer read by element is refused as "a structured buffer of unknown stride" instead of being addressed through the raw view, as the unindexed None arm already does.

Fix

In all three paths, when the used-resource entry's stride is 0 (and the access is not a typed-format load, which takes its own path), address the element as a byte offset into the raw view — exactly the None/unindexed arm — instead of refusing:

diff --git a/crates/victory-shader/src/emit/lower.rs b/crates/victory-shader/src/emit/lower.rs
index 8679930..2c06b01 100644
--- a/crates/victory-shader/src/emit/lower.rs
+++ b/crates/victory-shader/src/emit/lower.rs
@@ -8824,6 +8824,10 @@ impl<'a> Lower<'a> {
             let d = data.as_ref().ok_or("buffer atomic data")?;
             let vals = self.vgprs(inst, d, if op == u32::MAX { 2 } else { 1 })?;
             let (h, coords, byte) = match index {
+                Some(_) if used.is_some_and(|u| u.stride == 0) => {
+                    let (h, off) = self.raw_view(site, src, off, 4, (11 | u, 0), true, guard)?;
+                    (h, [off, iu, iu], off)
+                }
                 Some(index) => {
                     let stride = used.map_or(0, |u| u.stride);
                     if stride < 4 || !stride.is_multiple_of(4) {
@@ -8957,6 +8961,14 @@ impl<'a> Lower<'a> {
                 };
                 (69, "bufferStore.f32")
             } else {
+                // A used-resource stride of 0 is a raw buffer on the console
+                // (num_records counts bytes, not elements), not an unknown
+                // stride: address it as a byte offset into the raw view, as
+                // the unindexed form does, instead of refusing it.
+                let index = match index {
+                    Some(_) if used.is_some_and(|u| u.stride == 0) && !typed => None,
+                    _ => index,
+                };
                 match index {
                     Some(index) => {
                         let stride = used.map_or(0, |u| u.stride);
@@ -9065,6 +9077,27 @@ impl<'a> Lower<'a> {
         } else {
             let mask = self.s.m.i8((1u8 << count) - 1);
             let align = self.s.m.i32(4);
+            // A used-resource stride of 0 is a raw buffer on the console
+            // (num_records counts bytes, not elements), not an unknown
+            // stride: address it as a byte offset into the raw view, as the
+            // unindexed form does, instead of refusing it.
+            let index = match index {
+                Some(_) if used.is_some_and(|u| u.stride == 0) && !typed => {
+                    let bytes = 4 * count;
+                    let (h, off) =
+                        self.raw_view(site, src, off, bytes, (11 | u, 0), false, guard)?;
+                    self.s.op(
+                        self.cur,
+                        "rawBufferLoad.f32",
+                        Attr::ReadOnly,
+                        self.s.t.res_ret,
+                        139,
+                        &[h, off, iu, mask, align],
+                    );
+                    None
+                }
+                _ => index,
+            };
             match index {
                 Some(index) => {
                     let stride = used.map_or(0, |u| u.stride);

The load path emits the rawBufferLoad.f32 directly (it has no args/byte-bookkeeping to share with the match, so it lowers inline and drops the index to None); the store and atomic paths set index = None so the existing None arm runs unchanged. Strides 1, 2 and 3 stay refused — a raw buffer's stride is 0, not a small non-multiple-of-4.

Verified

  • New regression test emit::stride0_tests::a_stride_zero_buffer_is_raw_not_an_unknown_stride: a table SRV (user data 0) read by element (buffer_load_dword … idxen) plus a table UAV store, descriptor loaded at the access's own site (s_mov + s_load_dwordx4, the shape resource::track accepts as Source::Loaded).
    • stride = 4 lowers (the structured control).
    • stride = 0 lowers (was refused before).
    • stride = 1, 2, 3 still refuse with "a structured buffer of unknown stride" (non-vacuous: the fix is the 0 case, not "always raw").
  • cargo test -p victory-shader --lib on macOS, Rust 1.98.1: 145 passed / 0 failed / 2 ignored (144 before; +1 is the new test).
  • Proved it fails unpatched: with lower.rs reverted to 940d32f, the stride = 0 case panics with a structured buffer of unknown stride is not supported; with the fix it lowers.
  • rustfmt --edition 2024 --check: the new test file is clean; lower.rs shows the same 19 pre-existing fmt diffs with and without the change (my lines add none).
  • cargo clippy -p victory-shader --all-targets: no new warnings (5 pre-existing, unchanged).

Not covered

  • The DXIL a stride = 0 element load emits is a rawBufferLoad.f32 at a byte offset into the raw view. I did not run it on a GPU or WARP (no host device on this Mac, and the test is CPU-side: it lowers and checks the refusal, not the readback). The byte-offset addressing is the same one the unindexed None arm uses, which the existing stride_tests exercise on hardware; but I have not measured that a real title raw buffer read by element returns the same bytes through this path as through the unindexed form.
  • The 27-program count in the issue was not measured here (no title data on this Mac); the fix and test stand on the synthetic program above.
  • Typed-format loads (tbuffer_load_format_*) are excluded from the 0-stride raw path (they take the format arm); a raw typed buffer read by element would still hit the a typed buffer load by index refusal, as before.

qwen3.8_27b running locally on an M1 Mac

shout out to Digital Debris Los Angeles

**@⁠studiostephe** on GitHub · 2026-11-25 07:16 UTC · [original](https://github.com/Marvisak/VIctory/issues/1482#issuecomment-7155686535) Rule 3, confirmed and fixed: a used-resource `stride` of 0 is a raw buffer, not an unknown one. ## What's wrong `Lower::buffer` reads a table descriptor's element through the index arm, which checks `stride < 4 || !stride.is_multiple_of(4)` and refuses otherwise (`lower.rs` load `:9072`, store `:8964`, atomic `:8830` on `main` `940d32f`). That catches **0** together with the genuinely unknown 1, 2 and 3. On the console a stride of 0 means the buffer is **raw** — `num_records` (descriptor dword 2) counts bytes, not elements, and the element index is a byte offset. So a raw buffer read by element is refused as "a structured buffer of unknown stride" instead of being addressed through the raw view, as the unindexed `None` arm already does. ## Fix In all three paths, when the used-resource entry's `stride` is 0 (and the access is not a typed-format load, which takes its own path), address the element as a byte offset into the raw view — exactly the `None`/unindexed arm — instead of refusing: ```rust diff --git a/crates/victory-shader/src/emit/lower.rs b/crates/victory-shader/src/emit/lower.rs index 8679930..2c06b01 100644 --- a/crates/victory-shader/src/emit/lower.rs +++ b/crates/victory-shader/src/emit/lower.rs @@ -8824,6 +8824,10 @@ impl<'a> Lower<'a> { let d = data.as_ref().ok_or("buffer atomic data")?; let vals = self.vgprs(inst, d, if op == u32::MAX { 2 } else { 1 })?; let (h, coords, byte) = match index { + Some(_) if used.is_some_and(|u| u.stride == 0) => { + let (h, off) = self.raw_view(site, src, off, 4, (11 | u, 0), true, guard)?; + (h, [off, iu, iu], off) + } Some(index) => { let stride = used.map_or(0, |u| u.stride); if stride < 4 || !stride.is_multiple_of(4) { @@ -8957,6 +8961,14 @@ impl<'a> Lower<'a> { }; (69, "bufferStore.f32") } else { + // A used-resource stride of 0 is a raw buffer on the console + // (num_records counts bytes, not elements), not an unknown + // stride: address it as a byte offset into the raw view, as + // the unindexed form does, instead of refusing it. + let index = match index { + Some(_) if used.is_some_and(|u| u.stride == 0) && !typed => None, + _ => index, + }; match index { Some(index) => { let stride = used.map_or(0, |u| u.stride); @@ -9065,6 +9077,27 @@ impl<'a> Lower<'a> { } else { let mask = self.s.m.i8((1u8 << count) - 1); let align = self.s.m.i32(4); + // A used-resource stride of 0 is a raw buffer on the console + // (num_records counts bytes, not elements), not an unknown + // stride: address it as a byte offset into the raw view, as the + // unindexed form does, instead of refusing it. + let index = match index { + Some(_) if used.is_some_and(|u| u.stride == 0) && !typed => { + let bytes = 4 * count; + let (h, off) = + self.raw_view(site, src, off, bytes, (11 | u, 0), false, guard)?; + self.s.op( + self.cur, + "rawBufferLoad.f32", + Attr::ReadOnly, + self.s.t.res_ret, + 139, + &[h, off, iu, mask, align], + ); + None + } + _ => index, + }; match index { Some(index) => { let stride = used.map_or(0, |u| u.stride); ``` The load path emits the `rawBufferLoad.f32` directly (it has no `args`/`byte`-bookkeeping to share with the match, so it lowers inline and drops the index to `None`); the store and atomic paths set `index = None` so the existing `None` arm runs unchanged. Strides 1, 2 and 3 stay refused — a raw buffer's stride is 0, not a small non-multiple-of-4. ## Verified - New regression test `emit::stride0_tests::a_stride_zero_buffer_is_raw_not_an_unknown_stride`: a table SRV (user data 0) read by element (`buffer_load_dword … idxen`) plus a table UAV store, descriptor loaded at the access's own site (`s_mov` + `s_load_dwordx4`, the shape `resource::track` accepts as `Source::Loaded`). - `stride = 4` lowers (the structured control). - `stride = 0` lowers (was refused before). - `stride = 1, 2, 3` still refuse with "a structured buffer of unknown stride" (non-vacuous: the fix is the 0 case, not "always raw"). - `cargo test -p victory-shader --lib` on macOS, Rust 1.98.1: **145 passed / 0 failed / 2 ignored** (144 before; +1 is the new test). - Proved it fails unpatched: with `lower.rs` reverted to `940d32f`, the `stride = 0` case panics with `a structured buffer of unknown stride is not supported`; with the fix it lowers. - `rustfmt --edition 2024 --check`: the new test file is clean; `lower.rs` shows the same 19 pre-existing fmt diffs with and without the change (my lines add none). - `cargo clippy -p victory-shader --all-targets`: no new warnings (5 pre-existing, unchanged). ## Not covered - The DXIL a `stride = 0` element load emits is a `rawBufferLoad.f32` at a byte offset into the raw view. I did **not** run it on a GPU or WARP (no host device on this Mac, and the test is CPU-side: it lowers and checks the refusal, not the readback). The byte-offset addressing is the same one the unindexed `None` arm uses, which the existing `stride_tests` exercise on hardware; but I have not measured that a real title raw buffer read by element returns the same bytes through this path as through the unindexed form. - The 27-program count in the issue was not measured here (no title data on this Mac); the fix and test stand on the synthetic program above. - Typed-format loads (`tbuffer_load_format_*`) are excluded from the 0-stride raw path (they take the `format` arm); a raw *typed* buffer read by element would still hit the `a typed buffer load by index` refusal, as before. qwen3.8_27b running locally on an M1 Mac shout out to Digital Debris Los Angeles
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 10:21 UTC · original

Automated triage for the maintainers.

This is a proposal for three translator rules, and each one overlaps existing work. It is tracked here as a request.

  • Rule 1: the #1115 case it starts from is fixed in main by PR #1221. The v_cndmask_b32 lowering in crates/victory-shader/src/emit/lower.rs now resolves masks from Structured::other.
  • Rule 3: confirmed on main (940d32f). Lower::buffer in crates/victory-shader/src/emit/lower.rs refuses an indexed access whose used-resource stride is below 4 or not a multiple of 4, in its atomic, store and load paths. So 0 is refused together with 1 to 3.

The comment above posts a patch for stride 0 inline. Pull requests are open to everyone, so please open one with the patch and its test. One point for review there: the patch keys on the stride of the shader's used-resource entry (crates/victory-shader/src/native.rs), not on descriptor dword 1. Whether 0 in that entry means a raw buffer or that no stride was recorded is the question to settle. On hardware, an index with stride 0 adds nothing to the address. This matches the patch dropping the index.

Rule 2 is a design point for the maintainers. The measurements behind these rules are in #1481.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 10:21 UTC · [original](https://github.com/Marvisak/VIctory/issues/1482#issuecomment-7159587820) <!-- victory-issue-triage v1 verdict=tracked seen=2026-11-25T07:16:51Z at=2026-11-25T09:50:38Z --> Automated triage for the maintainers. This is a proposal for three translator rules, and each one overlaps existing work. It is tracked here as a request. - **Rule 1:** the #1115 case it starts from is fixed in `main` by PR #1221. The `v_cndmask_b32` lowering in `crates/victory-shader/src/emit/lower.rs` now resolves masks from `Structured::other`. - **Rule 3:** confirmed on `main` (`940d32f`). `Lower::buffer` in `crates/victory-shader/src/emit/lower.rs` refuses an indexed access whose used-resource stride is below 4 or not a multiple of 4, in its atomic, store and load paths. So 0 is refused together with 1 to 3. The comment above posts a patch for stride 0 inline. Pull requests are open to everyone, so please open one with the patch and its test. One point for review there: the patch keys on the `stride` of the shader's used-resource entry (`crates/victory-shader/src/native.rs`), not on descriptor dword 1. Whether 0 in that entry means a raw buffer or that no stride was recorded is the question to settle. On hardware, an index with stride 0 adds nothing to the address. This matches the patch dropping the index. Rule 2 is a design point for the maintainers. The measurements behind these rules are in #1481. --- _Generated by [Claude Code](https://claude.ai/code)_
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory#1482
No description provided.