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

Closed
AdamRchd wants to merge 1 commit from upstream-pr/1255 into main
AdamRchd commented 2026-11-24 16:49:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by AdamRchd on 2026-11-24T16:49:31Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6586903043 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1255). Originally posted by [AdamRchd](https://github.com/AdamRchd) on 2026-11-24T16:49:31Z. --- ## 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.
DenRakEiw commented 2026-11-24 17:04:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T16:56:54Z.

Review: APPROVED


Tested merged cleanly onto main (ffe310e) on Windows 11 x64 (Rust 1.98.1 MSVC):

  • cargo test -p victory-shader emit::lower: 12 passed, 0 failed (including clamped_image_samples_lower_and_validate)
  • cargo clippy -p victory-shader --all-targets: 0 warnings
  • cargo xtask policy: ok

Clean lowering and validation for clamped image sample variants and cubemap spatial counts. Approving.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6043699116 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1255#pullrequestreview-6043699116). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-24T16:56:54Z. **Review:** APPROVED --- Tested merged cleanly onto `main` (`ffe310e`) on Windows 11 x64 (Rust 1.98.1 MSVC): - `cargo test -p victory-shader emit::lower`: **12 passed, 0 failed** (including `clamped_image_samples_lower_and_validate`) - `cargo clippy -p victory-shader --all-targets`: **0 warnings** - `cargo xtask policy`: ok Clean lowering and validation for clamped image sample variants and cubemap spatial counts. Approving. AI-assisted (Gemini 4 Neon).
pablogonz12 commented 2026-11-24 17:04:48 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by pablogonz12 on 2026-11-24T17:03:21Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7138615722 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1255#issuecomment-7138615722). Originally posted by [pablogonz12](https://github.com/pablogonz12) on 2026-11-24T17:03:21Z. --- 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.
AdamRchd commented 2026-11-24 18:05:36 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by AdamRchd on 2026-11-24T17:15:49Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7138932020 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1255#issuecomment-7138932020). Originally posted by [AdamRchd](https://github.com/AdamRchd) on 2026-11-24T17:15:49Z. --- 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.
upstream-sync closed this pull request 2026-11-25 01:06:02 +00:00
Marvisak commented 2026-11-25 01:08:06 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:35:40Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148674327 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1255#issuecomment-7148674327). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:35:40Z. --- 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

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