Shaders: four fixes from other forks (mesh index edge flags, cube level log2, two-sampler branch, wave64 mask copies): 42 more shaders translate #1112

Open
github-bot wants to merge 4 commits from github-bot/gh-1112 into main AGit
Owner

@⁠KyleS98 on GitHub · 2026-11-25 19:56 UTC · original
KyleS98:shaders/fork-fixes → main · +133 −11 · 2 files · 4 commits · open

Four small translator fixes from other forks, brought onto main. Each is its own commit with the original author. All four are vendor-neutral.

commit from what was wrong
mesh primitive indices are 9 bits Marvisak/VIctory c0228d9 (tjthebigbearcat-hub) A GFX10 exp prim corner is a 9-bit vertex index plus an edge flag above it (bits 9, 19, 29). We read 10 bits, so a corner with its edge flag set named a vertex ≥ 512. That's past the written ones, so the triangle was culled.
cube sample with explicit gradients: log2 once, plus its _cl DexNom/VIctory 921d8d3 DXIL Log (op 23) is already base 2, and we multiplied by log2(e) again, so the level was 1.44× too coarse. The console's minimum level was also dropped: sampleLevel has no clamp, so it's now applied to the level.
a uniform branch choosing between two immediate samplers DexNom/VIctory ddb7332 Example: a root constant picks wrap or clamp. The sampler was untracked and the program didn't translate. Now it samples with both and selects by the edge taken.
a wave64 mask restored from two 32-bit scalar copies DexNom/VIctory 76749ce The restored value is the mask again.

I left out the integer-target blend part of ddb7332 (that's #715) and the tests of c0228d9.

Tested on an RTX 3090 Ti, --console series-s. The tree was d510ee4 plus this branch, plus #798 and #1081 so the S profile renders the world. Warm cache, from boot into the prologue cell:

  • Translation warm-up: shaders that don't translate went from 286 to 244.
  • Cell frame time: 112–123 ms both ways (8.1–8.9 fps with upstream's frame-rate switches on), so no cost.
  • The picture in the cell is unchanged by this PR as far as I can tell (see the correction below).
  • Still there either way: the noisy face of the woman in the pink shirt, and blocky patches on the cell's right-hand wall.
  • cargo test -p victory-shader: 217 passed.

Correction (same day): I first wrote here that Lucia's hair went from pale orange-blond to dark brown with this PR. That was wrong. Over 17 runs the hair colour follows something else:

  • It was dark brown in exactly the four runs that came first after a shader-cache warm-up, when about 1,900 pipelines are compiled during loading and draws are dropped while they are being made.
  • It was blond in every other run, with and without these commits.

So some pass that normally runs is skipped in those first runs and changes the hair. I'm looking for which one; it has nothing to do with this PR. The count of shaders that translate (286 → 244 that do not) is from the warm-up itself and stands.

AI-assisted (Claude Code; opened with Claude Opus 5.5, corrected with Claude Fable 5.2); runs and grabs on my machine; no game data.

**@⁠KyleS98** on GitHub · 2026-11-25 19:56 UTC · [original](https://github.com/fxceless/victory-fork/pull/1112) `KyleS98:shaders/fork-fixes` → `main` · +133 −11 · 2 files · 4 commits · open Four small translator fixes from other forks, brought onto main. Each is its own commit with the original author. All four are vendor-neutral. | commit | from | what was wrong | |---|---|---| | mesh primitive indices are 9 bits | Marvisak/VIctory c0228d9 (tjthebigbearcat-hub) | A GFX10 `exp prim` corner is a 9-bit vertex index plus an edge flag above it (bits 9, 19, 29). We read 10 bits, so a corner with its edge flag set named a vertex ≥ 512. That's past the written ones, so the triangle was culled. | | cube sample with explicit gradients: log2 once, plus its `_cl` | DexNom/VIctory 921d8d3 | DXIL `Log` (op 23) is already base 2, and we multiplied by log2(e) again, so the level was 1.44× too coarse. The console's minimum level was also dropped: `sampleLevel` has no clamp, so it's now applied to the level. | | a uniform branch choosing between two immediate samplers | DexNom/VIctory ddb7332 | Example: a root constant picks wrap or clamp. The sampler was untracked and the program didn't translate. Now it samples with both and selects by the edge taken. | | a wave64 mask restored from two 32-bit scalar copies | DexNom/VIctory 76749ce | The restored value is the mask again. | I left out the integer-target blend part of ddb7332 (that's #715) and the tests of c0228d9. **Tested** on an RTX 3090 Ti, `--console series-s`. The tree was `d510ee4` plus this branch, plus #798 and #1081 so the S profile renders the world. Warm cache, from boot into the prologue cell: - Translation warm-up: shaders that don't translate went from **286 to 244**. - Cell frame time: 112–123 ms both ways (8.1–8.9 fps with upstream's frame-rate switches on), so no cost. - The picture in the cell is unchanged by this PR as far as I can tell (see the correction below). - Still there either way: the noisy face of the woman in the pink shirt, and blocky patches on the cell's right-hand wall. - `cargo test -p victory-shader`: 217 passed. **Correction (same day):** I first wrote here that Lucia's hair went from pale orange-blond to dark brown with this PR. That was wrong. Over 17 runs the hair colour follows something else: - It was dark brown in exactly the four runs that came first after a shader-cache warm-up, when about 1,900 pipelines are compiled during loading and draws are dropped while they are being made. - It was blond in every other run, with and without these commits. So some pass that normally runs is skipped in those first runs and changes the hair. I'm looking for which one; it has nothing to do with this PR. The count of shaders that translate (286 → 244 that do not) is from the warm-up itself and stands. AI-assisted (Claude Code; opened with Claude Opus 5.5, corrected with Claude Fable 5.2); runs and grabs on my machine; no game data.
A GFX10 primitive export holds three corners of ten bits: a 9-bit vertex
index and its edge flag (bits 9, 19 and 29). The index was read with all
ten bits, so a corner with its edge flag set named a vertex at 512 or
past it, beyond the written ones, and the primitive was culled.

From Marvisak/VIctory c0228d9 by tjthebigbearcat-hub (the index mask;
its tests were not carried over), as also carried by DexNom/VIctory.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
DXIL's Log (op 23) is already base 2; it was multiplied by log2(e) once
more, so the level such a sample picked was 1.44 times too coarse. The
console's minimum level (`_cl`) was also dropped: sampleLevel has no
clamp operand, so it is applied to the level.

From DexNom/VIctory 921d8d3 (the cube level hunk).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A sampler descriptor built from constants on two edges of a branch (a root
constant choosing wrap or clamp) was an untracked sampler, and the program
did not translate. Each immediate sampler is a static binding of its own:
the image is sampled with both and the result taken from the edge the
console's sampler came from. 42 more of the title's shaders translate
(286 -> 244 that do not).

From DexNom/VIctory ddb7332 (the translator part; its integer-target blend
part is fxceless/victory-fork#715).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
From DexNom/VIctory 76749ce ("Recover voxel visibility shader when a
wave64 mask is restored from scalar copies").

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:57:41 +00:00
Author
Owner

@⁠Ym1r1710 on GitHub · 2026-11-25 20:32 UTC · original

Tried this on an RTX 5080 (Series X profile, not S), on top of current main plus a few open PRs. Warm cache after the first run retranslated. In the cell scene at world+400 and +800 the picture looks the same as before as far as I can see: hair, faces and walls unchanged, nothing new broken. Frame time 104 ms vs 97 ms on the run before without it, but that's inside the 10 ms or so my runs wander by, so I wouldn't read anything into it. So no visible win on S-less X profile here, no regression either. Keeping it.

**@⁠Ym1r1710** on GitHub · 2026-11-25 20:32 UTC · [original](https://github.com/fxceless/victory-fork/pull/1112#issuecomment-7173827476) Tried this on an RTX 5080 (Series X profile, not S), on top of current main plus a few open PRs. Warm cache after the first run retranslated. In the cell scene at world+400 and +800 the picture looks the same as before as far as I can see: hair, faces and walls unchanged, nothing new broken. Frame time 104 ms vs 97 ms on the run before without it, but that's inside the 10 ms or so my runs wander by, so I wouldn't read anything into it. So no visible win on S-less X profile here, no regression either. Keeping it.
Author
Owner

@⁠HLVM04 on GitHub · 2026-11-25 20:34 UTC · original

A Series S data point from an RTX 5070 Ti (Ryzen 7 9800X3D, Windows 11 build 26200) where the hair did not change.

I cherry-picked the four commits onto our own Series S stack (an older fork main plus several open PRs, #798 among them, and some local changes). The median frame in the first gameplay scene was 74 ms, about where our runs without them sit, and I saw no visible regression.

The main character's hair still renders pale blond on this card with the four commits in. Since this is the same profile as your 3090 Ti test, the hair fix may depend on something else in your tree, or on timing. On our stack her skin and hair colour already varied between runs before this PR (lit or black, dark or blond), so this is weak evidence either way. I didn't count untranslated shaders before and after.

**@⁠HLVM04** on GitHub · 2026-11-25 20:34 UTC · [original](https://github.com/fxceless/victory-fork/pull/1112#issuecomment-7173871429) A Series S data point from an RTX 5070 Ti (Ryzen 7 9800X3D, Windows 11 build 26200) where the hair did not change. I cherry-picked the four commits onto our own Series S stack (an older fork main plus several open PRs, #798 among them, and some local changes). The median frame in the first gameplay scene was 74 ms, about where our runs without them sit, and I saw no visible regression. The main character's hair still renders pale blond on this card with the four commits in. Since this is the same profile as your 3090 Ti test, the hair fix may depend on something else in your tree, or on timing. On our stack her skin and hair colour already varied between runs before this PR (lit or black, dark or blond), so this is weak evidence either way. I didn't count untranslated shaders before and after.
Author
Owner

@⁠grosterr on GitHub · 2026-11-25 22:40 UTC · original

A data point from an RTX 3060 12 GB, and one test that fails when this meets #770.

Machine: RTX 3060 12 GB, Ryzen 7 5700X, 32 GB, Windows 11, Series X profile.
Tree: the #770 stack (d034ac1) + main 9c184b3 + #1057, this PR (4bc83a6), #1044, #1101 and #1014. Branch: grosterr/victory-fork rtx3060.

One test fails after the merge. ir::tests::a_mask_parked_in_lanes_another_scalar_shares_comes_back_whole_with_shared_slots (from #854, carried in #770) passes on the stack and on the stack + main + #1057, and fails once this PR is in:

panicked at crates\victory-shader\src\ir.rs:2183:9:
two scalars make an opaque mask

Both #854 and the last commit here fix PS_VoxelizeVisiblity, in two ways. #854 brings the parked mask back as a pair through with_shared_slots. With this PR, Lanes::move_source follows the two s_mov_b32 copies back to that pair, so even without shared slots EXEC comes out as the compare's lanes. The test had recorded the old limit ("built as it is, the mask comes back as two scalars, which the structurisation cannot see into"). The new answer is the right one, so only the expectation has to change:

assert!(!opaque(&alone), "two scalar copies of the pair are the compare's mask");

It is in 6a53386, together with the doc comment above the test. After it, victory-shader has 245 passed and 0 failed. Whoever merges this and #770 second will meet it.

In the game (10 minutes, prologue cell block and corridor, 11 switches): 179 ms a frame at 5,564 draws, against 174 ms at 4,944 draws on the same tree with main d510ee4 and without these four PRs. That is the same within noise. Hair, faces, sunlight through the window and the corridor looked as before. Lucia's hair was dark both before and after, so on this tree the hair change cannot be seen either way. No errors in the log.

Warm-up count: translate --warm all with VICTORY_HOST_WAVE=32: 232 of 25,985 do not translate, the same number as before this PR. On top of #854's paired wave64 form, the 42 shaders this PR adds over main seem to translate already. I did not compare which 232 they are.

**@⁠grosterr** on GitHub · 2026-11-25 22:40 UTC · [original](https://github.com/fxceless/victory-fork/pull/1112#issuecomment-7176650181) A data point from an RTX 3060 12 GB, and one test that fails when this meets #770. **Machine:** RTX 3060 12 GB, Ryzen 7 5700X, 32 GB, Windows 11, Series X profile. **Tree:** the #770 stack (`d034ac1`) + main `9c184b3` + #1057, this PR (`4bc83a6`), #1044, #1101 and #1014. Branch: [`grosterr/victory-fork` `rtx3060`](https://github.com/grosterr/victory-fork/tree/rtx3060). **One test fails after the merge.** `ir::tests::a_mask_parked_in_lanes_another_scalar_shares_comes_back_whole_with_shared_slots` (from #854, carried in #770) passes on the stack and on the stack + main + #1057, and fails once this PR is in: ``` panicked at crates\victory-shader\src\ir.rs:2183:9: two scalars make an opaque mask ``` Both #854 and the last commit here fix `PS_VoxelizeVisiblity`, in two ways. #854 brings the parked mask back as a pair through `with_shared_slots`. With this PR, `Lanes::move_source` follows the two `s_mov_b32` copies back to that pair, so even without shared slots EXEC comes out as the compare's lanes. The test had recorded the old limit ("built as it is, the mask comes back as two scalars, which the structurisation cannot see into"). The new answer is the right one, so only the expectation has to change: ```rust assert!(!opaque(&alone), "two scalar copies of the pair are the compare's mask"); ``` It is in [`6a53386`](https://github.com/grosterr/victory-fork/commit/6a53386), together with the doc comment above the test. After it, `victory-shader` has 245 passed and 0 failed. Whoever merges this and #770 second will meet it. **In the game (10 minutes, prologue cell block and corridor, 11 switches):** 179 ms a frame at 5,564 draws, against 174 ms at 4,944 draws on the same tree with main `d510ee4` and without these four PRs. That is the same within noise. Hair, faces, sunlight through the window and the corridor looked as before. Lucia's hair was dark both before and after, so on this tree the hair change cannot be seen either way. No errors in the log. **Warm-up count:** `translate --warm all` with `VICTORY_HOST_WAVE=32`: 232 of 25,985 do not translate, the same number as before this PR. On top of #854's paired wave64 form, the 42 shaders this PR adds over main seem to translate already. I did not compare which 232 they are.
Author
Owner

@⁠KyleS98 on GitHub · 2026-11-26 01:25 UTC · original

Thanks for the three reports.

  • @⁠HLVM04 and @⁠Ym1r1710: your "hair did not change" matches the correction I've since put in the description. Across 17 runs here the hair colour followed whether pipelines were still compiling during loading, not these commits. So the claim this PR makes is only the translation count and "nothing broken", which is what you both saw.
  • @⁠grosterr: agreed on the test. With the last commit here Lanes::move_source follows the two scalar copies back to the pair, so a_mask_parked_in_lanes_another_scalar_shares_comes_back_whole_with_shared_slots should expect a non-opaque mask, as in your 6a53386. Whichever of this and #770 merges second should take that one-line change. I'm happy to add it here if the maintainer prefers this PR to carry it. Also useful: on top of #854 the count doesn't move (232 both ways), so the 42 shaders are the ones #854's paired form already recovers.

AI-assisted (Claude Code, Claude Fable 5.2).

**@⁠KyleS98** on GitHub · 2026-11-26 01:25 UTC · [original](https://github.com/fxceless/victory-fork/pull/1112#issuecomment-7179754769) Thanks for the three reports. - @⁠HLVM04 and @⁠Ym1r1710: your "hair did not change" matches the correction I've since put in the description. Across 17 runs here the hair colour followed whether pipelines were still compiling during loading, not these commits. So the claim this PR makes is only the translation count and "nothing broken", which is what you both saw. - @⁠grosterr: agreed on the test. With the last commit here `Lanes::move_source` follows the two scalar copies back to the pair, so `a_mask_parked_in_lanes_another_scalar_shares_comes_back_whole_with_shared_slots` should expect a non-opaque mask, as in your `6a53386`. Whichever of this and #770 merges second should take that one-line change. I'm happy to add it here if the maintainer prefers this PR to carry it. Also useful: on top of #854 the count doesn't move (232 both ways), so the 42 shaders are the ones #854's paired form already recovers. AI-assisted (Claude Code, Claude Fable 5.2).
This pull request has changes conflicting with the target branch.
  • crates/victory-shader/src/structure.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1112/head:github-bot/gh-1112'
git switch 'github-bot/gh-1112'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1112'
git switch 'github-bot/gh-1112'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1112'
git switch 'github-bot/gh-1112'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1112'
git switch 'main'
git merge --squash 'github-bot/gh-1112'
git switch 'main'
git merge --ff-only 'github-bot/gh-1112'
git switch 'main'
git merge 'github-bot/gh-1112'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.