Shader: LDS bytes and halves, constant sample offsets, descriptor-data reasons #383

Closed
github-bot wants to merge 2 commits from gh-pr/383/head into gh-pr/383/base
Owner

@⁠xmvo on GitHub · 2026-11-24 02:49 UTC · original
xmvo:shader/more → main · +631 −30 · 5 files · 2 commits · closed without merging

Builds on #318 (its commit is the first of the two here); merge that first, or this one instead of it.

What

LDS bytes and halves. ds_read_{u,i}{8,16}, ds_write_b{8,16} and their _d16 / _d16_hi forms now lower within their dword:

  • reads load the dword, shift by the byte offset and zero- or sign-extend; d16 forms keep the VGPR's other half,
  • writes clear then set their bits with two atomics (and, then or), so lanes writing other bytes of the same dword keep theirs.

Constant sample offsets. image_sample_o, image_sample_lz_o and image_sample_l_o pass a constant offset word as the sample's immediate offsets. A computed word, or an offset outside -8..7, stops the program with its own reason. image_sample_l(_o) now reads its level after the extra words (it assumed none).

Descriptor data. A buffer descriptor read as data and by s_buffer_load is now sized from its raw SRV, as buffer-instruction uses already were. The other paths that returned "a scalar memory read as data" now each have their own reason. The title's census stopped 573 programs with that message, and this tells the causes apart.

Adds BitcodeModule::int_value (an integer constant's value).

Census buckets addressed

Reason Programs
an LDS write of bytes or halves 9
an LDS read of bytes or halves 7
image_sample_o 4
a scalar memory read as data 573 (split into specific reasons; the s_buffer_load + raw SRV case translates)

Testing

  • lds_byte_and_half_writes_keep_the_rest_of_the_dword / lds_byte_and_half_reads_extend_as_the_console (valu_tests): validated by dxil.dll and run on the hardware device. They need a one-wave group with LDS, which takes the console's wave size, and WARP can't run that, so run_cases_on lets these choose backends.
  • New image_tests module: a synthetic program loads a UAV, a 4×4 texture and a sampler from tables and samples it. Validated, then run on hardware and WARP:
    • image_sample_lz_o with a constant offset,
    • image_sample_l_o (level after the offset word),
    • image_sample_l_o with a16: coordinates in the VGPR after the offset word (the #318 layout; the old k / 2 read the offset word as u, v),
    • image_sample_d_cl (coordinates after the gradients, then the clamp).
  • cargo test -p victory-shader: 76 pass (hardware: RTX 3060). cargo clippy -p victory-shader and rustfmt clean.
  • Not yet re-run against the title's census.
**@⁠xmvo** on GitHub · 2026-11-24 02:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/383) `xmvo:shader/more` → `main` · +631 −30 · 5 files · 2 commits · closed without merging Builds on #318 (its commit is the first of the two here); merge that first, or this one instead of it. ## What **LDS bytes and halves.** `ds_read_{u,i}{8,16}`, `ds_write_b{8,16}` and their `_d16` / `_d16_hi` forms now lower within their dword: - reads load the dword, shift by the byte offset and zero- or sign-extend; d16 forms keep the VGPR's other half, - writes clear then set their bits with two atomics (`and`, then `or`), so lanes writing other bytes of the same dword keep theirs. **Constant sample offsets.** `image_sample_o`, `image_sample_lz_o` and `image_sample_l_o` pass a constant offset word as the sample's immediate offsets. A computed word, or an offset outside -8..7, stops the program with its own reason. `image_sample_l(_o)` now reads its level after the extra words (it assumed none). **Descriptor data.** A buffer descriptor read as data *and* by `s_buffer_load` is now sized from its raw SRV, as buffer-instruction uses already were. The other paths that returned "a scalar memory read as data" now each have their own reason. The title's census stopped 573 programs with that message, and this tells the causes apart. Adds `BitcodeModule::int_value` (an integer constant's value). ## Census buckets addressed | Reason | Programs | |---|---| | an LDS write of bytes or halves | 9 | | an LDS read of bytes or halves | 7 | | image_sample_o | 4 | | a scalar memory read as data | 573 (split into specific reasons; the `s_buffer_load` + raw SRV case translates) | ## Testing - `lds_byte_and_half_writes_keep_the_rest_of_the_dword` / `lds_byte_and_half_reads_extend_as_the_console` (valu_tests): validated by dxil.dll and run on the hardware device. They need a one-wave group with LDS, which takes the console's wave size, and WARP can't run that, so `run_cases_on` lets these choose backends. - New `image_tests` module: a synthetic program loads a UAV, a 4×4 texture and a sampler from tables and samples it. Validated, then run on hardware and WARP: - `image_sample_lz_o` with a constant offset, - `image_sample_l_o` (level after the offset word), - `image_sample_l_o` with **a16**: coordinates in the VGPR after the offset word (the #318 layout; the old `k / 2` read the offset word as u, v), - `image_sample_d_cl` (coordinates after the gradients, then the clamp). - `cargo test -p victory-shader`: 76 pass (hardware: RTX 3060). `cargo clippy -p victory-shader` and rustfmt clean. - Not yet re-run against the title's census.
With a16 the address VGPRs were read as one run of 16-bit pairs. The
hardware (and image_addr_dwords, which counts them) gives each extra word
(texel offsets, bias, comparison value) a whole VGPR, pads each direction
of an odd number of gradients to whole VGPRs and begins the coordinates
in a new VGPR. image_address_place now places each address that way, so
a16 biased samples translate (the bias is the f16 in its word's low half)
and a16 gathers with an offset word read their coordinates from the right
VGPR.

image_sample_d_cl lowers to sampleGrad with the clamp that follows the
coordinates.

In a census of the title's shaders these stopped 108 ("a biased image
sample with 16-bit coordinates") and 27 (image_sample_d_cl) programs.
- ds_read_{u,i}{8,16}, ds_write_b{8,16} and their _d16/_d16_hi forms
  read and write within their dword: reads shift and zero- or
  sign-extend (d16 keeps the VGPR's other half), writes clear then set
  their bits with two atomics so lanes writing other bytes of the same
  dword keep theirs.
- image_sample_o, image_sample_lz_o and image_sample_l_o pass a constant
  offset word as the sample's immediate offsets (each 6-bit offset
  within -8..7; a computed word or a wider offset stops the program with
  its own reason). image_sample_l(_o) reads its level after the extra
  words.
- A buffer descriptor read as data and by s_buffer_load is sized from
  its raw SRV. The other ways a scalar memory read as data stops now
  have their own reasons, to tell apart the 573 programs a census of
  the title stopped with "a scalar memory read as data".

Tests: LDS byte/half reads and writes run on the hardware device (one
wave with LDS takes the console's wave size, which WARP lacks); a new
image_tests module samples a 4x4 texture on hardware and WARP with
offsets, an a16 extra word, and gradients with a clamp.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:01:59 +00:00
github-bot closed this pull request 2026-11-26 04:01:59 +00:00
Author
Owner

@⁠SpaghettiMaster545 on GitHub · 2026-11-24 03:48 UTC · original

Tested with the title at b6af8b1. The branch also carries #318's commit 1d7bf9b, so this measures both together.

  • NVIDIA GeForce RTX 5070 Ti, driver 621.24 (32.0.16.2124), 32-lane waves; Ryzen 7 9800X3D; Windows 11 10.0.26100; Rust 1.98.1. Diag build of the branch merged onto main d2a4bae (clean), its own empty VICTORY_CACHE_DIR, VICTORY_KEYS into story mode, until the host GPU failure (#71, unrelated); compared program by program with a main run made the same way (#400 has the setup).
  • 5 programs that stop on main translate and run. 0 programs that ran on main stop. This run ended earlier (63 s) than the main one, so it reached fewer programs and the count is a lower bound.
  • The world hang is unchanged.

Not tested: this PR without #318, AMD GPUs, a release build, image results.

(Claude Code, Claude Opus 5.5: ran the title on both builds and compared the logs program by program.)

**@⁠SpaghettiMaster545** on GitHub · 2026-11-24 03:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/383#issuecomment-7121442572) **Tested with the title** at `b6af8b1`. The branch also carries #318's commit `1d7bf9b`, so this measures both together. - NVIDIA GeForce RTX 5070 Ti, driver 621.24 (32.0.16.2124), 32-lane waves; Ryzen 7 9800X3D; Windows 11 10.0.26100; Rust 1.98.1. Diag build of the branch merged onto `main` `d2a4bae` (clean), its own empty `VICTORY_CACHE_DIR`, `VICTORY_KEYS` into story mode, until the host GPU failure (#71, unrelated); compared program by program with a `main` run made the same way (#400 has the setup). - 5 programs that stop on `main` translate and run. 0 programs that ran on `main` stop. This run ended earlier (63 s) than the `main` one, so it reached fewer programs and the count is a lower bound. - The world hang is unchanged. **Not tested**: this PR without #318, AMD GPUs, a release build, image results. (Claude Code, Claude Opus 5.5: ran the title on both builds and compared the logs program by program.)
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-24 04:21 UTC · original

I ran the shader crate’s unit suite at head b6af8b177e46e14b0ac9e372c287a8db63c83630:

cargo test --locked -p victory-shader --lib -- --test-threads=1

Result: 76 passed, 0 failed, 0 ignored. Relevant checks include lds_byte_and_half_reads_extend_as_the_console, lds_byte_and_half_writes_keep_the_rest_of_the_dword, the image sampling offset tests, and the shader lowering/bitcode tests. These are synthetic unit checks; this run does not validate rendered image output or title behavior.

**@⁠jeremygold02** on GitHub · 2026-11-24 04:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/383#issuecomment-7121947291) I ran the shader crate’s unit suite at head `b6af8b177e46e14b0ac9e372c287a8db63c83630`: ``` cargo test --locked -p victory-shader --lib -- --test-threads=1 ``` Result: 76 passed, 0 failed, 0 ignored. Relevant checks include `lds_byte_and_half_reads_extend_as_the_console`, `lds_byte_and_half_writes_keep_the_rest_of_the_dword`, the image sampling offset tests, and the shader lowering/bitcode tests. These are synthetic unit checks; this run does not validate rendered image output or title behavior.
Author
Owner

@⁠ghost on GitHub · 2026-11-24 05:50 UTC · original

Review note on head b6af8b1: for ds_read_*_d16 / _d16_hi, crates/victory-shader/src/emit/lower.rs:2138 keeps the destination's other half by reading its old value with inst.read(Reg::V(reg)), and falls back to 0 when that is None.

On main, ir.rs effects() (the Fields::Ds arm, around line 842) adds a ds_read destination only to the written registers, and Inst::read only searches the read list. So for these reads inst.read is always None and the kept half is always zeroed: a _d16 read clears the high 16 bits, a _d16_hi read clears the low 16.

#116 fixes this in effects():

if name.starts_with("ds_read") && name.contains("_d16") {
    regs(d, &mut r)?;
}

This PR would need the same, plus a test that writes a known value to the destination first and checks the other half survives.

Read-only review, nothing built. AI-assisted (Claude Code); the claim above was checked against this head and main at d2a4bae. Context: the triage in #366.

**@⁠ghost** on GitHub · 2026-11-24 05:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/383#issuecomment-7123330971) Review note on head `b6af8b1`: for `ds_read_*_d16` / `_d16_hi`, `crates/victory-shader/src/emit/lower.rs:2138` keeps the destination's other half by reading its old value with `inst.read(Reg::V(reg))`, and falls back to 0 when that is `None`. On `main`, `ir.rs` `effects()` (the `Fields::Ds` arm, around line 842) adds a `ds_read` destination only to the written registers, and `Inst::read` only searches the read list. So for these reads `inst.read` is always `None` and the kept half is always zeroed: a `_d16` read clears the high 16 bits, a `_d16_hi` read clears the low 16. #116 fixes this in `effects()`: ```rust if name.starts_with("ds_read") && name.contains("_d16") { regs(d, &mut r)?; } ``` This PR would need the same, plus a test that writes a known value to the destination first and checks the other half survives. _Read-only review, nothing built. AI-assisted (Claude Code); the claim above was checked against this head and `main` at `d2a4bae`. Context: the triage in #366._
Author
Owner

@⁠iurysf on GitHub · 2026-11-24 07:21 UTC · original

Measured offline against main d2a4bae with victory translate --list --validate over the title's shaders.rpf + executable (26,096 programs), dxil.dll 1.9.2602.17: failures 3,733 -> 3,588 (−145), with no regressions (194 rejected by the validator, against 185). Most of the change is reclassification. "a scalar memory read as data" (573) goes to 0 here, but mostly by splitting into "descriptor address/format" (71 -> 595) rather than by translating. For comparison, #136 + #180 together take failures to 3,080 and clear both categories (details on #136).

AI-assisted.

**@⁠iurysf** on GitHub · 2026-11-24 07:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/383#issuecomment-7124901767) Measured offline against main `d2a4bae` with `victory translate --list --validate` over the title's `shaders.rpf` + executable (26,096 programs), dxil.dll 1.9.2602.17: failures 3,733 -> 3,588 (−145), with no regressions (194 rejected by the validator, against 185). Most of the change is reclassification. "a scalar memory read as data" (573) goes to 0 here, but mostly by splitting into "descriptor address/format" (71 -> 595) rather than by translating. For comparison, #136 + #180 together take failures to 3,080 and clear both categories (details on #136). AI-assisted.
Author
Owner

@⁠slint6614-dev on GitHub · 2026-11-24 07:47 UTC · original

Measured on the full retail shader pack (26,503 containers) with victory translate --validate, against main d2a4bae (emitted / validated). Windows 11, dxil.dll from SDK 10.0.26100.

VS/PS CS MS sub-dword LDS refusals (7 reads, 9 writes on main) tests
main 12272 / 12172 1693 / 1670 8191 / 8129 16 ok
#101 same 1709 / 1686 same 0 ok
#632 same 1707 / 1684 same 0, but 2 new "an LDS read into half a register" ok
#383 12361 / 12252 1720 / 1697 8220 / 8158 0 see below
  • #101 turns all 16 into validated compute programs; #632 gets 14 of them.
  • #383 (wider PR) also clears image_sample_o, image_sample_d_cl, the 108 biased 16-bit samples and the 573 "scalar memory read as data", but those mostly move to other reasons ("a descriptor's address or format read as data" 71 → 595, "an image address" 2 → 27), and the signature mismatches go 21 → 29 (input) and 25 → 26 (output).
  • #383: cargo test -p victory-shader --release crashed with STATUS_ACCESS_VIOLATION in 2 of 6 parallel runs (0 of 6 on main; --test-threads=1 always passes, 76 tests). Possibly a race in one of the new tests.
**@⁠slint6614-dev** on GitHub · 2026-11-24 07:47 UTC · [original](https://github.com/Marvisak/VIctory/pull/383#issuecomment-7125372650) Measured on the full retail shader pack (26,503 containers) with `victory translate --validate`, against main d2a4bae (emitted / validated). Windows 11, dxil.dll from SDK 10.0.26100. | | VS/PS | CS | MS | sub-dword LDS refusals (7 reads, 9 writes on main) | tests | |---|---|---|---|---|---| | main | 12272 / 12172 | 1693 / 1670 | 8191 / 8129 | 16 | ok | | #101 | same | 1709 / 1686 | same | 0 | ok | | #632 | same | 1707 / 1684 | same | 0, but 2 new "an LDS read into half a register" | ok | | #383 | 12361 / 12252 | 1720 / 1697 | 8220 / 8158 | 0 | see below | - #101 turns all 16 into validated compute programs; #632 gets 14 of them. - #383 (wider PR) also clears `image_sample_o`, `image_sample_d_cl`, the 108 biased 16-bit samples and the 573 "scalar memory read as data", but those mostly move to other reasons ("a descriptor's address or format read as data" 71 → 595, "an image address" 2 → 27), and the signature mismatches go 21 → 29 (input) and 25 → 26 (output). - #383: `cargo test -p victory-shader --release` crashed with `STATUS_ACCESS_VIOLATION` in 2 of 6 parallel runs (0 of 6 on main; `--test-threads=1` always passes, 76 tests). Possibly a race in one of the new tests.
Author
Owner

@⁠adamdotpy on GitHub · 2026-11-24 15:55 UTC · original

Reviewed b6af8b1. Two things first, then what I found in each part.

It no longer applies to main. The branch is based on d2a4bae; git merge-tree against ffe310e conflicts in crates/victory-shader/src/emit/lower.rs and .../valu_tests.rs, which is why the PR reads as dirty. @⁠SpaghettiMaster545's title test merged onto d2a4bae cleanly, so the conflict came in with the commits after that; a rebase is needed before anyone can judge the merge or re-run a census.

Run here (Windows 11, Rust 1.98.1): cargo test -p victory-shader — 76 passed, 0 failed, matching @⁠jeremygold02.

_d16 / _d16_hi kept half: the source is the wrong one, and this test cannot see it

@⁠TrashTalker3460 is right that the kept half is unreliable, but the mechanism is worth stating precisely, because it explains why lds_byte_and_half_reads_extend_as_the_console passes on hardware:

  • ir.rs's effects() puts a ds destination only in the write list, and chains data into the read list (Fields::Ds, addr.iter().chain(data)).
  • So inst.read(Reg::V(vdst)) returns something only because the encoding's data0 field is parsed as an operand and names that register. In the test ds(op, 0, 5, 0, offset) has data0 = 0, i.e. v0, and vdst is also v0, preloaded with the LDS content — so the "kept" half happens to be the value the test expects. In a title shader whose data0 names another register (hardware ignores that field on a read), the kept half comes from that register instead.
  • The robust source is the destination register's previous SSA definition, not an operand of this instruction. If #116 does that, it fixes both _d16 and _d16_hi.

A test that would catch it: same program, but vdst = 2 with the address in v5 and data0 naming a third register (or 0 while vdst != 0), so the kept half can only come from v2's own previous value.

LDS bytes and halves

The part I expected to be wrong is right. hole = mask << shift, keep = ~hole, value masked into hole: mask and value are disjoint per write, so the and then or pair commutes and lanes writing different bytes of one dword cannot lose each other's bits. Two notes:

  • A lane reading that dword between the two atomics sees the hole zeroed. The console program has the same race unlocked, but "two atomics" reads as if the pair were atomic; a sentence saying it is not would stop someone relying on it.
  • The byte-3 half shortcut is documented; the read at byte 3 (the high half coming from the next dword) is where this differs from hardware, so it is the case to name in the shortcut comment.

image_address_place

per = grads / 2 is safe only because the caller computes grads = 2 * spatial, so it is never 1. Nothing in the function says that, and the comment right above talks about odd gradient counts being padded — a debug_assert!(per > 0 || grads == 0) or a sentence would keep the next edit from dividing by zero inside the translator rather than failing a shader.

Descriptor data — three PRs, one case

Your Fields::Smem arm is the same fix as #953 (a buffer descriptor also read by s_buffer_load becomes a raw SRV, (11 | u, 0)), reached independently, and the reason split around it is what #1083 does. Whichever lands first, the other two rebase:

  • if #953 goes in first, this keeps the reclassification (Fields::Flat, the other arms) and drops the Fields::Smem translation;
  • @⁠iurysf's census says the split accounts for most of the change here anyway ("descriptor address/format" 71 → 595 rather than new translations), so the two PRs are complementary once one carries the arm.

One shared open question: both use (11 | u, 0) regardless of used.stride, so getDimensions().x on that raw view is bytes/4 while a console structured descriptor's dword 2 is bytes/stride — 4× at stride 16, and it is the record count. I raised it on #953; if it turns out to matter, it matters identically here.

**@⁠adamdotpy** on GitHub · 2026-11-24 15:55 UTC · [original](https://github.com/Marvisak/VIctory/pull/383#issuecomment-7136829679) Reviewed `b6af8b1`. Two things first, then what I found in each part. **It no longer applies to `main`.** The branch is based on `d2a4bae`; `git merge-tree` against `ffe310e` conflicts in `crates/victory-shader/src/emit/lower.rs` and `.../valu_tests.rs`, which is why the PR reads as `dirty`. @⁠SpaghettiMaster545's title test merged onto `d2a4bae` cleanly, so the conflict came in with the commits after that; a rebase is needed before anyone can judge the merge or re-run a census. **Run here** (Windows 11, Rust 1.98.1): `cargo test -p victory-shader` — 76 passed, 0 failed, matching @⁠jeremygold02. ### `_d16` / `_d16_hi` kept half: the source is the wrong one, and this test cannot see it @⁠TrashTalker3460 is right that the kept half is unreliable, but the mechanism is worth stating precisely, because it explains why `lds_byte_and_half_reads_extend_as_the_console` passes on hardware: - `ir.rs`'s `effects()` puts a `ds` destination only in the write list, and chains `data` into the read list (`Fields::Ds`, `addr.iter().chain(data)`). - So `inst.read(Reg::V(vdst))` returns something only because the *encoding's* `data0` field is parsed as an operand and names that register. In the test `ds(op, 0, 5, 0, offset)` has `data0 = 0`, i.e. v0, and `vdst` is also v0, preloaded with the LDS content — so the "kept" half happens to be the value the test expects. In a title shader whose `data0` names another register (hardware ignores that field on a read), the kept half comes from that register instead. - The robust source is the destination register's previous SSA definition, not an operand of this instruction. If #116 does that, it fixes both `_d16` and `_d16_hi`. A test that would catch it: same program, but `vdst = 2` with the address in `v5` and `data0` naming a third register (or 0 while `vdst != 0`), so the kept half can only come from v2's own previous value. ### LDS bytes and halves The part I expected to be wrong is right. `hole = mask << shift`, `keep = ~hole`, value masked into `hole`: mask and value are disjoint per write, so the `and` then `or` pair commutes and lanes writing different bytes of one dword cannot lose each other's bits. Two notes: - A lane reading that dword *between* the two atomics sees the hole zeroed. The console program has the same race unlocked, but "two atomics" reads as if the pair were atomic; a sentence saying it is not would stop someone relying on it. - The byte-3 half shortcut is documented; the read at byte 3 (the high half coming from the next dword) is where this differs from hardware, so it is the case to name in the shortcut comment. ### `image_address_place` `per = grads / 2` is safe only because the caller computes `grads = 2 * spatial`, so it is never 1. Nothing in the function says that, and the comment right above talks about odd gradient counts being padded — a `debug_assert!(per > 0 || grads == 0)` or a sentence would keep the next edit from dividing by zero inside the translator rather than failing a shader. ### Descriptor data — three PRs, one case Your `Fields::Smem` arm is the same fix as #953 (a buffer descriptor also read by `s_buffer_load` becomes a raw SRV, `(11 | u, 0)`), reached independently, and the reason split around it is what #1083 does. Whichever lands first, the other two rebase: - if #953 goes in first, this keeps the reclassification (`Fields::Flat`, the other arms) and drops the `Fields::Smem` translation; - @⁠iurysf's census says the split accounts for most of the change here anyway ("descriptor address/format" 71 → 595 rather than new translations), so the two PRs are complementary once one carries the arm. One shared open question: both use `(11 | u, 0)` regardless of `used.stride`, so `getDimensions().x` on that raw view is bytes/4 while a console structured descriptor's dword 2 is bytes/stride — 4× at stride 16, and it is the record count. I raised it on #953; if it turns out to matter, it matters identically here.
Author
Owner

@⁠adamdotpy on GitHub · 2026-11-24 15:58 UTC · original

For the LDS half of this PR, #571 is the better implementation of the same ground: it handles the halfword at byte 3 by straddling into the next dword (64-bit shift on read, 64-bit mask/data on write, past-the-end clamped with reads seeing 0), where this PR documents the straddle as a shortcut that loses the spilling byte. I would land #571 for LDS and rebase this one to keep only the image_sample_o and descriptor-data work, which nothing else covers.

Both PRs share the same question about the _d16 kept half — the destination register is read via inst.read(Reg::V(dst)) while ir.rs::effects() only declares dst as written, and the tests cannot see it because vdst and the data field coincide. I left the details with an experiment on #571. One fix upstream would close both.

**@⁠adamdotpy** on GitHub · 2026-11-24 15:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/383#issuecomment-7136909413) For the LDS half of this PR, #571 is the better implementation of the same ground: it handles the halfword at byte 3 by straddling into the next dword (64-bit shift on read, 64-bit mask/data on write, past-the-end clamped with reads seeing 0), where this PR documents the straddle as a shortcut that loses the spilling byte. I would land #571 for LDS and rebase this one to keep only the `image_sample_o` and descriptor-data work, which nothing else covers. Both PRs share the same question about the `_d16` kept half — the destination register is read via `inst.read(Reg::V(dst))` while `ir.rs::effects()` only declares `dst` as written, and the tests cannot see it because `vdst` and the data field coincide. I left the details with an experiment on #571. One fix upstream would close both.
Author
Owner

@⁠pablogonz12 on GitHub · 2026-11-24 16:20 UTC · original

I ran the CI clippy on head b6af8b1 (the branch has no checks): cargo xwin clippy --workspace --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings fails on two points, both the first error in their crate:

  • crates/victory-shader/src/emit/valu_tests.rs:757: type_complexity on the [(u8, u16, fn(u32) -> u32); 6] table in lds_byte_and_half_reads_extend_as_the_console — a type alias (or #[allow(clippy::type_complexity)]) clears it.
  • crates/victory-gpu/src/host.rs:267: undocumented_unsafe_blocks, which is not from this PR: current main has since added a // SAFETY: comment above that raw.cast::<IDXGIAdapter1>() line, so rebasing on main fixes it.
    Also, when this meets current main: image_tests.rs needs emit(..., Target::ANY) and raw_view_tests.rs needs the extra lanes argument of resource::track (I hit both in my tree).
    No game data, just the two compiler messages.
**@⁠pablogonz12** on GitHub · 2026-11-24 16:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/383#issuecomment-7137518212) I ran the CI clippy on head b6af8b1 (the branch has no checks): `cargo xwin clippy --workspace --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings` fails on two points, both the first error in their crate: - `crates/victory-shader/src/emit/valu_tests.rs:757`: `type_complexity` on the `[(u8, u16, fn(u32) -> u32); 6]` table in `lds_byte_and_half_reads_extend_as_the_console` — a `type` alias (or `#[allow(clippy::type_complexity)]`) clears it. - `crates/victory-gpu/src/host.rs:267`: `undocumented_unsafe_blocks`, which is not from this PR: current main has since added a `// SAFETY:` comment above that `raw.cast::<IDXGIAdapter1>()` line, so rebasing on main fixes it. Also, when this meets current main: `image_tests.rs` needs `emit(..., Target::ANY)` and `raw_view_tests.rs` needs the extra `lanes` argument of `resource::track` (I hit both in my tree). No game data, just the two compiler messages.
Author
Owner

@⁠adamdotpy on GitHub · 2026-11-24 16:29 UTC · original

Reproduced the flaky release-test crash on b6af8b1, and found the cause. Windows 11, Rust 1.98.1, the branch's release test binary run 6 times with default (parallel) threads:

run 1 exit=139 (segfault)     run 4 exit=139 (segfault)
runs 2, 3, 5, 6 exit=0, "test result: ok"

That is 2 of 6, same as your report, and --test-threads=1 passes every time. So it is a parallel-run race, not a broken assertion.

The cause is that this branch's base predates the GPU-test serialization. Current main's valu_tests.rs has:

/// … two GPU tests at once on WARP can end the test process with an
/// access violation. Other GPU test modules take this lock too.
pub(super) static ONE_AT_A_TIME: std::sync::Mutex<()> = …

and run_cases takes it before touching a device. Your merge base's valu_tests.rs has no ONE_AT_A_TIME at all (git show <merge-base>:…valu_tests.rs | grep -c ONE_AT_A_TIME → 0), and the new run_cases_on in this branch — called from the two new LDS tests and from image_tests.rs — creates Host::new and dispatches without taking any lock. Two of those on the same device (hardware or WARP) at once is precisely the access violation main's comment names. I could not make the LDS tests alone crash in 10 parallel runs, so the full suite's contention is what tips it over; the missing lock is still the defect.

The fix is one line after the rebase: have run_cases_on take ONE_AT_A_TIME like run_cases does on current main (it will be in scope after rebasing, since it is pub(super) in the same module). Until then, --test-threads=1 is the honest way to run it, as you found.

On @⁠pablogonz12's two clippy points: the type_complexity on the [(u8, u16, fn(u32) -> u32); 6] table at valu_tests.rs:757 is yours — an alias or #[allow] clears it. The undocumented_unsafe_blocks at host.rs:267 is a rebase artifact, confirmed: current main has the // SAFETY: EnumWarpAdapter returns a DXGI adapter… comment on exactly that raw.cast::<IDXGIAdapter1>() line, so merging main in clears it. Your other two notes (the Target::ANY and lanes signature changes) are the same class — they come from meeting current main, not from this diff.

Nothing changed on your branch from me; this is evidence only. The shader-side substance (LDS sub-dword handling, sample offsets, descriptor-data reasons) I reviewed earlier still stands, and the #571 comparison note from before is unchanged: for the LDS half, #571 is the stronger implementation.

**@⁠adamdotpy** on GitHub · 2026-11-24 16:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/383#issuecomment-7137754530) Reproduced the flaky release-test crash on `b6af8b1`, and found the cause. Windows 11, Rust 1.98.1, the branch's release test binary run 6 times with default (parallel) threads: ``` run 1 exit=139 (segfault) run 4 exit=139 (segfault) runs 2, 3, 5, 6 exit=0, "test result: ok" ``` That is 2 of 6, same as your report, and `--test-threads=1` passes every time. So it is a parallel-run race, not a broken assertion. **The cause is that this branch's base predates the GPU-test serialization.** Current `main`'s `valu_tests.rs` has: ```rust /// … two GPU tests at once on WARP can end the test process with an /// access violation. Other GPU test modules take this lock too. pub(super) static ONE_AT_A_TIME: std::sync::Mutex<()> = … ``` and `run_cases` takes it before touching a device. Your merge base's `valu_tests.rs` has no `ONE_AT_A_TIME` at all (`git show <merge-base>:…valu_tests.rs | grep -c ONE_AT_A_TIME` → 0), and the new `run_cases_on` in this branch — called from the two new LDS tests and from `image_tests.rs` — creates `Host::new` and dispatches without taking any lock. Two of those on the same device (hardware or WARP) at once is precisely the access violation `main`'s comment names. I could not make the LDS tests alone crash in 10 parallel runs, so the full suite's contention is what tips it over; the missing lock is still the defect. **The fix is one line after the rebase:** have `run_cases_on` take `ONE_AT_A_TIME` like `run_cases` does on current main (it will be in scope after rebasing, since it is `pub(super)` in the same module). Until then, `--test-threads=1` is the honest way to run it, as you found. On @⁠pablogonz12's two clippy points: the `type_complexity` on the `[(u8, u16, fn(u32) -> u32); 6]` table at `valu_tests.rs:757` is yours — an alias or `#[allow]` clears it. The `undocumented_unsafe_blocks` at `host.rs:267` is a rebase artifact, confirmed: current `main` has the `// SAFETY: EnumWarpAdapter returns a DXGI adapter…` comment on exactly that `raw.cast::<IDXGIAdapter1>()` line, so merging `main` in clears it. Your other two notes (the `Target::ANY` and `lanes` signature changes) are the same class — they come from meeting current `main`, not from this diff. Nothing changed on your branch from me; this is evidence only. The shader-side substance (LDS sub-dword handling, sample offsets, descriptor-data reasons) I reviewed earlier still stands, and the #571 comparison note from before is unchanged: for the LDS half, #571 is the stronger implementation.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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!383
No description provided.