Shaders: decode finds instructions in a table by dword, not a tree #2010

Open
0xkn0wh3r3 wants to merge 3 commits from upstream-pr/2012 into main
0xkn0wh3r3 commented 2026-11-25 03:03:46 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-25T03:03:46Z.


The problem

Decoding a console program into instructions was slower than it needs to be. On synthetic programs it was a large part of decoding, and decoding is about 8% of a translation (sampled).

gfx10::decode follows the control flow from offset 0 and kept every instruction it found in a BTreeMap by offset. That costs, per instruction:

  • a lookup, to stop at an instruction already found;
  • an insertion;
  • a range lookup, for the far-jump check;

plus a walk of the tree at the end to put them in order.

How it was found

A sampling profile (a helper thread suspending the translating thread every 0.5 ms and unwinding it) over a mix of synthetic compute programs (straight-line VALU, if/endif with s_and_saveexec, nested ifs, buffer stores, scalar ALU), all translated through range::build, resource::track, io::raise and lower. gfx10::decode was 8.2% of the samples inclusive, with the tree's inserts and lookups a large part of it. No title shaders were available, so the share in a real corpus may differ.

The fix

While every offset it reaches is a dword's, decode now uses a table instead of the tree (decode_aligned):

  1. It records, for each dword, the index of the instruction starting there.
  2. It keeps the instructions in a vector and sorts them by offset once at the end.
  3. The far-jump check only needs the instruction that ends exactly where the s_setpc_b64 starts. The nearest one found below it, within the longest instruction's reach (5 dwords), is the tree's answer wherever that can end there.

An offset that is no dword's (only a far jump's literal can give one) leaves the whole decode to the tree (decode_any), as before. Every result and error is the same.

Measured on an RTX 5070 Ti host (release, best of 30):

program tree (main) table
32,001 instructions (compares, saveexec, branches, VOP3, buffer stores, scalar loads) 6.1 ms 2.4 ms

This is independent of #1623 (an instruction's words kept inline): that one changes Instruction and instruction(), this one only the container decode collects into.

Testing

  • New test gfx10::tests::the_table_decodes_as_the_tree_does: decodes branches both ways, a loop, data after the end, far jumps both ways and bad code with both, and checks the table gives the tree's result. It also checks that a far jump to an unaligned offset falls back to the tree.
  • The existing decode tests (follows_branches_and_skips_data, follows_far_jumps, follows_far_jumps_backward, rejects_bad_code) now run through the table.
  • cargo test --release -p victory-shader --no-fail-fast on an RTX 5070 Ti (driver 621.24): 245 passed. The 3 failures (emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride, emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, emit::synthetic_tests::gathers_at_a_level_match_the_hardware) fail the same way on main (NVIDIA's 1,000,000-descriptor heap cap, #1835).
  • cargo clippy -p victory-shader --all-targets, with and without --features diagnostics: clean.
<!-- greyfinch-sync:Marvisak/VIctory:issue:5484358613 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2012). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-25T03:03:46Z. --- ## The problem Decoding a console program into instructions was slower than it needs to be. On synthetic programs it was a large part of decoding, and decoding is about 8% of a translation (sampled). `gfx10::decode` follows the control flow from offset 0 and kept every instruction it found in a `BTreeMap` by offset. That costs, per instruction: - a lookup, to stop at an instruction already found; - an insertion; - a range lookup, for the far-jump check; plus a walk of the tree at the end to put them in order. ### How it was found A sampling profile (a helper thread suspending the translating thread every 0.5 ms and unwinding it) over a mix of synthetic compute programs (straight-line VALU, if/endif with `s_and_saveexec`, nested ifs, buffer stores, scalar ALU), all translated through `range::build`, `resource::track`, `io::raise` and `lower`. `gfx10::decode` was 8.2% of the samples inclusive, with the tree's inserts and lookups a large part of it. No title shaders were available, so the share in a real corpus may differ. ## The fix While every offset it reaches is a dword's, `decode` now uses a table instead of the tree (`decode_aligned`): 1. It records, for each dword, the index of the instruction starting there. 2. It keeps the instructions in a vector and sorts them by offset once at the end. 3. The far-jump check only needs the instruction that ends exactly where the `s_setpc_b64` starts. The nearest one found below it, within the longest instruction's reach (5 dwords), is the tree's answer wherever that can end there. An offset that is no dword's (only a far jump's literal can give one) leaves the whole decode to the tree (`decode_any`), as before. Every result and error is the same. Measured on an RTX 5070 Ti host (release, best of 30): | program | tree (main) | table | |---|---|---| | 32,001 instructions (compares, saveexec, branches, VOP3, buffer stores, scalar loads) | 6.1 ms | 2.4 ms | This is independent of #1623 (an instruction's words kept inline): that one changes `Instruction` and `instruction()`, this one only the container `decode` collects into. ## Testing - New test `gfx10::tests::the_table_decodes_as_the_tree_does`: decodes branches both ways, a loop, data after the end, far jumps both ways and bad code with both, and checks the table gives the tree's result. It also checks that a far jump to an unaligned offset falls back to the tree. - The existing decode tests (`follows_branches_and_skips_data`, `follows_far_jumps`, `follows_far_jumps_backward`, `rejects_bad_code`) now run through the table. - `cargo test --release -p victory-shader --no-fail-fast` on an RTX 5070 Ti (driver 621.24): 245 passed. The 3 failures (`emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride`, `emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`, `emit::synthetic_tests::gathers_at_a_level_match_the_hardware`) fail the same way on `main` (NVIDIA's 1,000,000-descriptor heap cap, #1835). - `cargo clippy -p victory-shader --all-targets`, with and without `--features diagnostics`: clean.
catminou4 commented 2026-11-25 03:34:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T03:34:29Z.

Review: APPROVED


Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, cargo test -p victory-shader --locked.

145 passed / 0 failed. Decode finds instructions in a table by dword, not a tree (+1 test) — decode lookup perf/simplicity; suite green.

<!-- greyfinch-sync:Marvisak/VIctory:review:6051470108 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2012#pullrequestreview-6051470108). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T03:34:29Z. **Review:** APPROVED --- Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, `cargo test -p victory-shader --locked`. 145 passed / 0 failed. Decode finds instructions in a table by dword, not a tree (+1 test) — decode lookup perf/simplicity; suite green.
Yoshi-233 commented 2026-11-25 04:06:47 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Yoshi-233 on 2026-11-25T03:17:45Z.


I compared gfx10::decode at 940d32f and 0905347 on x86-64 Linux with synthetic, valid programs. I compared the offset, encoding, opcode, name and instruction words for every output instruction. All 42,052 entries across the four fixtures matched in order.

Median time per decode, including dropping the result (release, Rust 1.98.1, nine alternating pairs of batches pinned to the same logical CPU):

Fixture Reachable instructions Base PR
Short straight line 25 2.13 µs 1.54 µs
Long straight line 18,001 3.31 ms 1.13 ms
Short conditional skips with both paths reachable 24,001 4.92 ms 1.48 ms
Same short instruction pattern, followed by 32 KiB of unreachable padding 25 1.87 µs 2.06 µs

The long inputs were faster in all nine pairs; the padded short input was slightly slower in all nine. The last case isolates sensitivity to the supplied byte slice length while keeping the reachable instruction count fixed. I used s_mov_b32, v_mov_b32, s_nop, s_endpgm and, for the branching case, s_cbranch_scc0. These are decoder-only timings; I did not measure game loading or full translation.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7151779865 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2012#issuecomment-7151779865). Originally posted by [Yoshi-233](https://github.com/Yoshi-233) on 2026-11-25T03:17:45Z. --- I compared `gfx10::decode` at `940d32f` and `0905347` on x86-64 Linux with synthetic, valid programs. I compared the offset, encoding, opcode, name and instruction words for every output instruction. All 42,052 entries across the four fixtures matched in order. Median time per decode, including dropping the result (release, Rust 1.98.1, nine alternating pairs of batches pinned to the same logical CPU): | Fixture | Reachable instructions | Base | PR | | --- | ---: | ---: | ---: | | Short straight line | 25 | 2.13 µs | 1.54 µs | | Long straight line | 18,001 | 3.31 ms | 1.13 ms | | Short conditional skips with both paths reachable | 24,001 | 4.92 ms | 1.48 ms | | Same short instruction pattern, followed by 32 KiB of unreachable padding | 25 | 1.87 µs | 2.06 µs | The long inputs were faster in all nine pairs; the padded short input was slightly slower in all nine. The last case isolates sensitivity to the supplied byte slice length while keeping the reachable instruction count fixed. I used `s_mov_b32`, `v_mov_b32`, `s_nop`, `s_endpgm` and, for the branching case, `s_cbranch_scc0`. These are decoder-only timings; I did not measure game loading or full translation.
0xkn0wh3r3 commented 2026-11-25 08:06:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-25T07:21:17Z.


Thanks for the comparison. 42,052 instructions matching in order is a better check than the unit test.

The padded case is the per-dword table: decode_aligned makes vec![u32::MAX; code.len() / 4] up front. 32 KiB of padding is 8,192 entries to fill, about 0.2 µs, which matches 1.87 → 2.06 µs. It's linear in the slice, not in the reachable code. 023252d makes the table grow to the furthest dword reached instead, so bytes past the last instruction cost nothing (decode tests and clippy pass).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7155766868 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2012#issuecomment-7155766868). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-25T07:21:17Z. --- Thanks for the comparison. 42,052 instructions matching in order is a better check than the unit test. The padded case is the per-dword table: `decode_aligned` makes `vec![u32::MAX; code.len() / 4]` up front. 32 KiB of padding is 8,192 entries to fill, about 0.2 µs, which matches 1.87 → 2.06 µs. It's linear in the slice, not in the reachable code. 023252d makes the table grow to the furthest dword reached instead, so bytes past the last instruction cost nothing (decode tests and clippy pass).
Yoshi-233 commented 2026-11-25 08:06:40 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Yoshi-233 on 2026-11-25T07:31:11Z.


@0xkn0wh3r3 Thanks for explaining the table allocation. I retested your update at 023252d. All 42,052 decoded instructions from the four original fixtures matched both 0905347 and the PR base 940d32f, in order and field for field.

To isolate the padding cost, I used the same 25 instructions followed by zeros in a fixed-size buffer and varied only the slice length passed to gfx10::decode. These are median times per decode on x86-64 Linux, using Rust 1.98.1 in release mode, pinned to one logical CPU, with 12 rounds per revision.

Trailing padding Previous 0905347 Updated 023252d
0 KiB 1.55 µs 1.85 µs
4 KiB 1.63 µs 1.85 µs
32 KiB 2.01 µs 1.84 µs
256 KiB 4.70 µs 1.85 µs

That confirms the fix on this machine. The updated decoder stayed within 1.84–1.85 µs across all four lengths and was faster in all 12 rounds at both 32 and 256 KiB. The trade-off I measured was about 0.29 µs (+19%) for the unpadded 25-instruction case. On the original long straight-line and branching fixtures, the updated head was within 1% of the previous head. These timings cover CPU decoding only.

The release-mode victory-shader library suite also passed on 023252d (145 passed, 0 failed, 2 ignored).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7155949523 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2012#issuecomment-7155949523). Originally posted by [Yoshi-233](https://github.com/Yoshi-233) on 2026-11-25T07:31:11Z. --- @0xkn0wh3r3 Thanks for explaining the table allocation. I retested your update at `023252d`. All 42,052 decoded instructions from the four original fixtures matched both `0905347` and the PR base `940d32f`, in order and field for field. To isolate the padding cost, I used the same 25 instructions followed by zeros in a fixed-size buffer and varied only the slice length passed to `gfx10::decode`. These are median times per decode on x86-64 Linux, using Rust 1.98.1 in release mode, pinned to one logical CPU, with 12 rounds per revision. | Trailing padding | Previous `0905347` | Updated `023252d` | |---|---:|---:| | 0 KiB | 1.55 µs | 1.85 µs | | 4 KiB | 1.63 µs | 1.85 µs | | 32 KiB | 2.01 µs | 1.84 µs | | 256 KiB | 4.70 µs | 1.85 µs | That confirms the fix on this machine. The updated decoder stayed within 1.84–1.85 µs across all four lengths and was faster in all 12 rounds at both 32 and 256 KiB. The trade-off I measured was about 0.29 µs (+19%) for the unpadded 25-instruction case. On the original long straight-line and branching fixtures, the updated head was within 1% of the previous head. These timings cover CPU decoding only. The release-mode `victory-shader` library suite also passed on `023252d` (145 passed, 0 failed, 2 ignored).
Marvisak commented 2026-11-25 10:07:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T09:17:44Z.


Automated triage for the maintainers.

Merge candidate (unchanged). The push since the last triage (a759494 to 12876d1) is a rebase onto current main. The PR's diff to crates/victory-shader/src/gfx10/mod.rs is identical line for line, and it merges cleanly. The earlier reading still applies. decode_aligned keeps a per-dword index table, reserved up to 4,096 entries and grown only to the furthest dword reached, and sorts once at the end. It falls back to the BTreeMap walk (decode_any) at the first unaligned offset, and the far-jump look-back is bounded by MAX_WORDS. The independent field-by-field comparison (42,052 instructions) and the unchanged retail translate count also still apply.

CI: passing (check).

Recommending a look, not approving.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7158138030 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2012#issuecomment-7158138030). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T09:17:44Z. --- <!-- victory-triage v1 head=12876d139a0becb7a0c0b41db14ce0bd2a3239a5 verdict=merge-candidate at=2026-11-26T01:20:27Z --> Automated triage for the maintainers. **Merge candidate (unchanged).** The push since the last triage (`a759494` to `12876d1`) is a rebase onto current `main`. The PR's diff to `crates/victory-shader/src/gfx10/mod.rs` is identical line for line, and it merges cleanly. The earlier reading still applies. `decode_aligned` keeps a per-dword index table, reserved up to 4,096 entries and grown only to the furthest dword reached, and sorts once at the end. It falls back to the `BTreeMap` walk (`decode_any`) at the first unaligned offset, and the far-jump look-back is bounded by `MAX_WORDS`. The independent field-by-field comparison (42,052 instructions) and the unchanged retail translate count also still apply. CI: passing (`check`). Recommending a look, not approving. --- _Generated by [Claude Code](https://claude.ai/code)_
sinan-cmyk commented 2026-11-25 10:07:52 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T09:55:22Z.


Offline measurement on a retail dump

Result: no count change against main.

I merged head 023252d5 onto main 940d32f (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 23,918 on main, 23,918 with this PR.

No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7158981812 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2012#issuecomment-7158981812). Originally posted by [sinan-cmyk](https://github.com/sinan-cmyk) on 2026-11-25T09:55:22Z. --- ### Offline measurement on a retail dump **Result: no count change against `main`.** I merged head 023252d5 onto `main` 940d32f (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 23,918 on `main`, 23,918 with this PR. No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
0xkn0wh3r3 commented 2026-11-25 19:06:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-25T18:37:10Z.


@Yoshi-233 thanks for the sweep. The +0.29 µs on the unpadded case is the table growing entry by entry: a short program reallocated it several times. a759494 reserves room for up to 4,096 entries (16 KiB) up front, without filling any, so padding past the code still costs nothing.

Median per decode for a 25-instruction program on this machine (Windows, release, 21 rounds of 20,000):

trailing padding 0905347 023252d a759494
0 KiB 2.16 µs 1.45 µs 1.32 µs
4 KiB 2.13 µs 1.45 µs 1.32 µs
32 KiB 1.77 µs 1.45 µs 1.31 µs

These timings differ from your Linux numbers for 0905347 (an allocator difference, I'd guess). Here the reserved version is the fastest at every length.

@sinan-cmyk thanks for the retail count. It's a decoder speed change, so no change in outcome is what it should show.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7171158830 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2012#issuecomment-7171158830). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-25T18:37:10Z. --- @Yoshi-233 thanks for the sweep. The +0.29 µs on the unpadded case is the table growing entry by entry: a short program reallocated it several times. a759494 reserves room for up to 4,096 entries (16 KiB) up front, without filling any, so padding past the code still costs nothing. Median per decode for a 25-instruction program on this machine (Windows, release, 21 rounds of 20,000): | trailing padding | `0905347` | `023252d` | `a759494` | |---|---:|---:|---:| | 0 KiB | 2.16 µs | 1.45 µs | 1.32 µs | | 4 KiB | 2.13 µs | 1.45 µs | 1.32 µs | | 32 KiB | 1.77 µs | 1.45 µs | 1.31 µs | These timings differ from your Linux numbers for `0905347` (an allocator difference, I'd guess). Here the reserved version is the fastest at every length. @sinan-cmyk thanks for the retail count. It's a decoder speed change, so no change in outcome is what it should show.
fuzeofficlal commented 2026-11-26 19:06:48 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T19:06:48Z.

Review: APPROVED


Verified locally merged onto origin/main (63bcca43, Windows 11 x64, Rust 1.98.1 MSVC):

  • cargo test --locked -p victory-shader --lib gfx10:: — 17 passed, 0 failed (including the_table_decodes_as_the_tree_does)
  • cargo clippy --locked -p victory-shader --all-targets -- -D warnings (default and --all-features) — 0 warnings
  • rustfmt --edition 2024 --check crates/victory-shader/src/gfx10/mod.rs — clean
  • cargo xtask policy — ok (191 files ok)

Review notes

  • Checked every encoding branch in instruction(): MAX_WORDS = 5 holds across all encodings (MIMG up to 5 words, VOP3/VOP3P up to 3, all others 1-2), so the 1..=MAX_WORDS lookback in before(end) matches BTreeMap::range(..at).next_back() for far_jump while falling back cleanly to decode_any on unaligned far-jump targets.
  • Heads-up for combining with #1623: decode_aligned reads inst.words.len() and w[0].words.len() inside gfx10/mod.rs. Once #1623 turns Instruction::words into a private [u32; 5] array, those two calls will still compile inside the module and silently return 5 instead of words().len(), so whichever PR merges second will need both updated to .words().len() (and can share Instruction::MAX_WORDS).
<!-- greyfinch-sync:Marvisak/VIctory:review:6079319235 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2012#pullrequestreview-6079319235). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T19:06:48Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (`63bcca43`, Windows 11 x64, Rust 1.98.1 MSVC): - `cargo test --locked -p victory-shader --lib gfx10::` — **17 passed, 0 failed** (including `the_table_decodes_as_the_tree_does`) - `cargo clippy --locked -p victory-shader --all-targets -- -D warnings` (default and `--all-features`) — 0 warnings - `rustfmt --edition 2024 --check crates/victory-shader/src/gfx10/mod.rs` — clean - `cargo xtask policy` — ok (`191 files ok`) ### Review notes - Checked every encoding branch in `instruction()`: `MAX_WORDS = 5` holds across all encodings (MIMG up to 5 words, VOP3/VOP3P up to 3, all others 1-2), so the `1..=MAX_WORDS` lookback in `before(end)` matches `BTreeMap::range(..at).next_back()` for `far_jump` while falling back cleanly to `decode_any` on unaligned far-jump targets. - **Heads-up for combining with #1623**: `decode_aligned` reads `inst.words.len()` and `w[0].words.len()` inside `gfx10/mod.rs`. Once #1623 turns `Instruction::words` into a private `[u32; 5]` array, those two calls will still compile inside the module and silently return `5` instead of `words().len()`, so whichever PR merges second will need both updated to `.words().len()` (and can share `Instruction::MAX_WORDS`).
Dukestar69 commented 2026-11-26 22:51:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T22:51:29Z.

Review: APPROVED


LGTM — verified on Windows against origin/main (63bcca4).

  • Table-driven GFX10 instruction decode passes all decoder tests cleanly without clippy warnings.
  • cargo test -p victory-shader --lib gfx10:: -- --test-threads=1: all passed.
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6081261360 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2012#pullrequestreview-6081261360). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T22:51:29Z. **Review:** APPROVED --- LGTM — verified on Windows against `origin/main` (`63bcca4`). - Table-driven GFX10 instruction decode passes all decoder tests cleanly without clippy warnings. - `cargo test -p victory-shader --lib gfx10:: -- --test-threads=1`: all passed. - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
neonbyte1 commented 2026-11-27 22:55:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by neonbyte1 on 2026-11-27T22:55:39Z.


A silent conflict between this PR and #1623, found while merging all triage: merge candidate PRs together on one branch (details on #3347).

  • #1623 keeps an instruction's dwords inline as words: [u32; Instruction::MAX_WORDS] plus a length, read through Instruction::words().
  • #2012 walks the decoded program with inst.words.len() (crates/victory-shader/src/gfx10/mod.rs, the next offset and the overlap check).

Each PR is correct on its own and both merge cleanly into main. Merged together, words.len() is always 5, so every instruction is walked as five dwords and the decoder refuses most programs. In the combined tree that took victory-shader's lib tests from 214 to 146 passed (335 failed). Using words() in those two places (inst.words().len(), w[0].words().len()) brings it to 344 passed / 137 failed; the remaining failures are unrelated (47 are "no SM 6.6 device" under Wine).

Whichever of the two lands second needs that two-line change. Reference commit on the integration branch: github.com/neonbyte1/VIctory@17c7845dd (merge resolution only).

Measured with CPU tests under Wine on Linux; no game data involved.

AI-assisted (Claude); measured on my machine, no game data shared.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7229731480 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2012#issuecomment-7229731480). Originally posted by [neonbyte1](https://github.com/neonbyte1) on 2026-11-27T22:55:39Z. --- A silent conflict between this PR and #1623, found while merging all `triage: merge candidate` PRs together on one branch (details on #3347). - **#1623** keeps an instruction's dwords inline as `words: [u32; Instruction::MAX_WORDS]` plus a length, read through `Instruction::words()`. - **#2012** walks the decoded program with `inst.words.len()` (`crates/victory-shader/src/gfx10/mod.rs`, the `next` offset and the overlap check). Each PR is correct on its own and both merge cleanly into `main`. Merged together, `words.len()` is always 5, so every instruction is walked as five dwords and the decoder refuses most programs. In the combined tree that took victory-shader's lib tests from 214 to 146 passed (335 failed). Using `words()` in those two places (`inst.words().len()`, `w[0].words().len()`) brings it to 344 passed / 137 failed; the remaining failures are unrelated (47 are "no SM 6.6 device" under Wine). Whichever of the two lands second needs that two-line change. Reference commit on the integration branch: https://github.com/neonbyte1/VIctory/commit/17c7845dd (merge resolution only). Measured with CPU tests under Wine on Linux; no game data involved. _AI-assisted (Claude); measured on my machine, no game data shared._
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2012:upstream-pr/2012'
git switch 'upstream-pr/2012'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2012'
git switch 'upstream-pr/2012'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2012'
git switch 'upstream-pr/2012'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2012'
git switch 'main'
git merge --squash 'upstream-pr/2012'
git switch 'main'
git merge --ff-only 'upstream-pr/2012'
git switch 'main'
git merge 'upstream-pr/2012'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!2010
No description provided.