Shaders: support clamped image sample variants and include cubemap kinds in spatial count #1255

Closed
github-bot wants to merge 1 commit from gh-pr/1255/head into gh-pr/1255/base
Owner

@⁠AdamRchd on GitHub · 2026-11-24 16:49 UTC · original
AdamRchd:fix/clamped-image-samples → main · +114 −22 · 1 files · 1 commits · closed without merging

What

In crates/victory-shader/src/emit/lower.rs, image sample lowering now supports clamped image sample variants (image_sample_cl, image_sample_b_cl, image_sample_d_cl, and image_sample_c_cl in pixel shaders), passes the converted clamp argument instead of a dummy float, matches image_sample_b* when locating the initial address operand, and includes cubemap resource kinds (5..=7) in the spatial coordinate register count (spatial).

Test

  • Added clamped_image_samples_lower_and_validate in crates/victory-shader/src/emit/lower.rs covering image_sample_cl, image_sample_b_cl, and image_sample_d_cl lowering and DXIL Validator checks.
  • cargo test -p victory-shader clamped_image_samples_lower_and_validate: passed.
  • cargo test --workspace: passed (121 passed, 1 ignored in victory-shader; all workspace tests passed).
  • cargo xtask policy: 154 files ok.
  • cargo run --release -p victory -- translate --validate: 26148 of 26148 programs translated (12167 VS/PS, 1417 CS, and 8152 MS DXIL modules validated) with no _cl lowering errors.

No game files were included in the repository.

**@⁠AdamRchd** on GitHub · 2026-11-24 16:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/1255) `AdamRchd:fix/clamped-image-samples` → `main` · +114 −22 · 1 files · 1 commits · closed without merging ## What In `crates/victory-shader/src/emit/lower.rs`, image sample lowering now supports clamped image sample variants (`image_sample_cl`, `image_sample_b_cl`, `image_sample_d_cl`, and `image_sample_c_cl` in pixel shaders), passes the converted clamp argument instead of a dummy float, matches `image_sample_b*` when locating the initial address operand, and includes cubemap resource kinds (`5..=7`) in the spatial coordinate register count (`spatial`). ## Test - Added `clamped_image_samples_lower_and_validate` in `crates/victory-shader/src/emit/lower.rs` covering `image_sample_cl`, `image_sample_b_cl`, and `image_sample_d_cl` lowering and DXIL `Validator` checks. - `cargo test -p victory-shader clamped_image_samples_lower_and_validate`: passed. - `cargo test --workspace`: passed (`121 passed, 1 ignored` in `victory-shader`; all workspace tests passed). - `cargo xtask policy`: `154 files ok`. - `cargo run --release -p victory -- translate --validate`: `26148` of `26148` programs translated (`12167` VS/PS, `1417` CS, and `8152` MS DXIL modules validated) with no `_cl` lowering errors. No game files were included in the repository.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:25:14 +00:00
github-bot closed this pull request 2026-11-26 04:25:14 +00:00
Author
Owner

@⁠pablogonz12 on GitHub · 2026-11-24 17:03 UTC · original

Setup: Linux, RX 9070 XT, RADV (Mesa 26.3.1), dxil-spirv master, spirv-val 1.3. Your head folded onto a base of origin/main ffe310e plus #1017 — main's host build is broken without it (E0425 host_resource in victory-gpu), so the base is that pair. Ran the four-stage offline check (translate, dxil-spirv, spirv-val, RADV pipeline) over 768 programs: the 751-program world dump plus a 52-program BVH capture, 35 duplicate containers skipped.

translate valid SPIR-V RADV pipeline
base 666 / 768 656 656
your head 666 / 768 656 656

No program gained or lost and the failure table is identical to the base, reason for reason: nothing in this capture reaches the class you lower, so this is a no-regression result only (same 10 SPIR-V validation failures as the base).

Not tested: in-game.

**@⁠pablogonz12** on GitHub · 2026-11-24 17:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/1255#issuecomment-7138615722) Setup: Linux, RX 9070 XT, RADV (Mesa 26.3.1), dxil-spirv master, spirv-val 1.3. Your head folded onto a base of origin/main `ffe310e` plus #1017 — main's host build is broken without it (`E0425 host_resource` in `victory-gpu`), so the base is that pair. Ran the four-stage offline check (translate, dxil-spirv, spirv-val, RADV pipeline) over 768 programs: the 751-program world dump plus a 52-program BVH capture, 35 duplicate containers skipped. | | translate | valid SPIR-V | RADV pipeline | |---|---|---|---| | base | 666 / 768 | 656 | 656 | | your head | 666 / 768 | 656 | 656 | No program gained or lost and the failure table is identical to the base, reason for reason: nothing in this capture reaches the class you lower, so this is a no-regression result only (same 10 SPIR-V validation failures as the base). Not tested: in-game.
Author
Owner

@⁠AdamRchd on GitHub · 2026-11-24 17:15 UTC · original

Thanks for running the RADV check and confirming there are no regressions. Agreed—this capture doesn't hit _cl or cubemap spatial counts, so the unit test and victory translate --validate cover the change here.

**@⁠AdamRchd** on GitHub · 2026-11-24 17:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/1255#issuecomment-7138932020) Thanks for running the RADV check and confirming there are no regressions. Agreed—this capture doesn't hit `_cl` or cubemap spatial counts, so the unit test and `victory translate --validate` cover the change here.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:35 UTC · original

Automated triage for the maintainers. Closing because this change is already in main, or main has since replaced the code it patches.

image_sample_d_cl is in main and the other _cl forms occur in no title program. Its cube change is wrong: it takes DXIL kinds 5..=7 as 'cubemap kinds' (6 and 7 are 1D/2D arrays) and passes a cube's two face-space gradients as two components of a direction gradient to sampleGrad. Also reformats unrelated tests.

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

**@⁠Marvisak** on GitHub · 2026-11-25 00:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/1255#issuecomment-7148674327) Automated triage for the maintainers. Closing because this change is already in `main`, or `main` has since replaced the code it patches. image_sample_d_cl is in main and the other _cl forms occur in no title program. Its cube change is wrong: it takes DXIL kinds 5..=7 as 'cubemap kinds' (6 and 7 are 1D/2D arrays) and passes a cube's two face-space gradients as two components of a direction gradient to sampleGrad. Also reformats unrelated tests. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

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!1255
No description provided.