Shaders: guard conditional exports #655

Closed
Halfect wants to merge 1 commit from upstream-pr/655 into main
Halfect commented 2026-11-24 06:16:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Halfect on 2026-11-24T06:16:08Z.


What

Non-final exports under an EXEC mask now use the existing guarded-block lowering, so disabled lanes do not overwrite their previous output. The final pixel done export keeps its existing discard behavior, and mesh exports are unchanged.

Adds a synthetic pixel regression that narrows EXEC around a non-final MRT0 export. The old lowering rejects it with a conditional export; the new lowering emits DXIL that passes the validator.

Offline title measurement

Compared 25,889 matched program labels from the local shader archive with translate --validate --list --jobs 4:

  • All 8 a conditional export blockers are gone.
  • 0 DXIL-validation regressions; previously validated programs are unchanged.
  • Those eight programs then reach other pre-existing limitations (six at scalar memory reads as data, two at packed-input handling), so this is an enabling correctness fix rather than a claim of additional fully validated title programs on main.

A local compatibility run combined with #621 also removed all eight blockers with no validation regressions. This branch itself is based directly on main and does not include #621.

Checks

  • cargo test --locked -p victory-shader --lib -- --test-threads=1: 70 passed, 0 failed.
  • cargo clippy --locked -p victory-shader --lib --tests -- -D warnings: clean.
  • cargo xtask policy: 151 files ok.

Offline translation and DXIL validation only; no title executable or world run, and no shader contents or extracted data included. AI-assisted (Kimi).

<!-- greyfinch-sync:Marvisak/VIctory:issue:6575888531 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/655). Originally posted by [Halfect](https://github.com/Halfect) on 2026-11-24T06:16:08Z. --- ## What Non-final exports under an EXEC mask now use the existing guarded-block lowering, so disabled lanes do not overwrite their previous output. The final pixel `done` export keeps its existing `discard` behavior, and mesh exports are unchanged. Adds a synthetic pixel regression that narrows EXEC around a non-final MRT0 export. The old lowering rejects it with `a conditional export`; the new lowering emits DXIL that passes the validator. ## Offline title measurement Compared 25,889 matched program labels from the local shader archive with `translate --validate --list --jobs 4`: - All **8** `a conditional export` blockers are gone. - **0 DXIL-validation regressions**; previously validated programs are unchanged. - Those eight programs then reach other pre-existing limitations (six at scalar memory reads as data, two at packed-input handling), so this is an enabling correctness fix rather than a claim of additional fully validated title programs on main. A local compatibility run combined with #621 also removed all eight blockers with no validation regressions. This branch itself is based directly on main and does not include #621. ## Checks - `cargo test --locked -p victory-shader --lib -- --test-threads=1`: **70 passed, 0 failed**. - `cargo clippy --locked -p victory-shader --lib --tests -- -D warnings`: clean. - `cargo xtask policy`: **151 files ok**. Offline translation and DXIL validation only; no title executable or world run, and no shader contents or extracted data included. AI-assisted (Kimi).
LAKSHYA-cmd-tech commented 2026-11-24 06:54:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by LAKSHYA-cmd-tech on 2026-11-24T06:19:45Z.

Review: APPROVED


Tested on native Windows 11 with Rust 1.98.1 (x86_64-pc-windows-msvc).

  • cargo test -p victory-shader: all 70 tests passed cleanly (0 failed).
  • _conditional_pixel_export_is_guarded passed, with emitted DXIL validating cleanly via host DXIL validator.
  • cargo xtask policy: 151 files ok.
  • Verified non-final conditional exports using guarded-block lowering while preserving final pixel done discard behavior.
<!-- greyfinch-sync:Marvisak/VIctory:review:6034590386 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/655#pullrequestreview-6034590386). Originally posted by [LAKSHYA-cmd-tech](https://github.com/LAKSHYA-cmd-tech) on 2026-11-24T06:19:45Z. **Review:** APPROVED --- Tested on native Windows 11 with Rust 1.98.1 (x86_64-pc-windows-msvc). - cargo test -p victory-shader: all 70 tests passed cleanly (0 failed). - _conditional_pixel_export_is_guarded passed, with emitted DXIL validating cleanly via host DXIL validator. - cargo xtask policy: 151 files ok. - Verified non-final conditional exports using guarded-block lowering while preserving final pixel done discard behavior.
catminou4 commented 2026-11-24 10:03:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T09:37:37Z.

Review: APPROVED


Merges cleanly with main; macOS arm64, rustc 1.98.1, cargo test -p victory-shader --locked with the PR merged into main 8e79c80 → 71 passed / 0 failed / 1 ignored.

Conditional exports now lower as guarded exports instead of being refused, except the pixel stage's final done export which keeps the old kill-lane path (pixel_done is computed once and used in both places — the restructure is consistent). The new test builds a PS with a vcc-guarded exp and checks it translates (validator runs on Windows).

One coverage note: the test is pixel-stage only. The change also newly accepts guarded exports in VS/GS (previously a conditional export for any non-mesh stage) — the reasoning ("runs only for enabled lanes") holds for VS, but GS exports are per-primitive-stream and worth a second look if a title hits it; not blocking since the old behavior was a hard refusal anyway, so this strictly widens what translates.

<!-- greyfinch-sync:Marvisak/VIctory:review:6036819146 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/655#pullrequestreview-6036819146). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T09:37:37Z. **Review:** APPROVED --- Merges cleanly with main; macOS arm64, rustc 1.98.1, `cargo test -p victory-shader --locked` with the PR merged into main `8e79c80` → **71 passed / 0 failed / 1 ignored**. Conditional exports now lower as guarded exports instead of being refused, except the pixel stage's final `done` export which keeps the old kill-lane path (`pixel_done` is computed once and used in both places — the restructure is consistent). The new test builds a PS with a vcc-guarded `exp` and checks it translates (validator runs on Windows). One coverage note: the test is pixel-stage only. The change also newly accepts guarded exports in VS/GS (previously `a conditional export` for any non-mesh stage) — the reasoning ("runs only for enabled lanes") holds for VS, but GS exports are per-primitive-stream and worth a second look if a title hits it; not blocking since the old behavior was a hard refusal anyway, so this strictly widens what translates.
justr4mzi commented 2026-11-24 10:03:48 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by justr4mzi on 2026-11-24T09:38:36Z.


Independently measured PR #655 (b9c7699c) merged cleanly onto main (8e79c80) on Windows 11 with an AMD Radeon RX 6700 XT (RDNA2), Rust 1.98.1 (x86_64-pc-windows-msvc), and dxil.dll from Windows SDK 10.0.26100.0, against main (02f404e) baseline.

victory translate --validate (26,599 containers / 26,148 programs)

  • emit: a conditional export: 8 -> 0 (all 8 cleared).
  • Downstream shift matches the PR description:
    • emit: a scalar memory read as data: 604 -> 610 (+6)
    • emit: a packed input half no element holds: 166 -> 168 (+2)
  • Emitted / validated totals unchanged with 0 DXIL validation regressions:
    • VS/PS: 12,236 emitted / 12,160 validated
    • CS: 1,440 emitted / 1,417 validated
    • MS: 8,163 emitted / 8,101 validated

Build and checks

  • Clean merge onto 8e79c80 (crates/victory-shader/src/emit/lower.rs, emit/mod.rs).
  • cargo clippy -p victory-shader --lib -- -D warnings: clean.
  • cargo xtask policy: 153 files ok.
  • cargo build --release -p victory: succeeded.
  • No game data included; the title itself was not launched.

AI-assisted test execution and comparison (reviewed locally).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7127691429 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/655#issuecomment-7127691429). Originally posted by [justr4mzi](https://github.com/justr4mzi) on 2026-11-24T09:38:36Z. --- Independently measured PR #655 (`b9c7699c`) merged cleanly onto `main` (`8e79c80`) on Windows 11 with an AMD Radeon RX 6700 XT (RDNA2), Rust 1.98.1 (`x86_64-pc-windows-msvc`), and `dxil.dll` from Windows SDK `10.0.26100.0`, against `main` (`02f404e`) baseline. ### `victory translate --validate` (26,599 containers / 26,148 programs) - `emit: a conditional export`: **8 -> 0** (all 8 cleared). - Downstream shift matches the PR description: - `emit: a scalar memory read as data`: 604 -> 610 (+6) - `emit: a packed input half no element holds`: 166 -> 168 (+2) - Emitted / validated totals unchanged with **0 DXIL validation regressions**: - VS/PS: 12,236 emitted / 12,160 validated - CS: 1,440 emitted / 1,417 validated - MS: 8,163 emitted / 8,101 validated ### Build and checks - Clean merge onto `8e79c80` (`crates/victory-shader/src/emit/lower.rs`, `emit/mod.rs`). - `cargo clippy -p victory-shader --lib -- -D warnings`: clean. - `cargo xtask policy`: `153 files ok`. - `cargo build --release -p victory`: succeeded. - No game data included; the title itself was not launched. *AI-assisted test execution and comparison (reviewed locally).*
DenRakEiw commented 2026-11-24 14:04:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T14:00:19Z.

Review: APPROVED


NVIDIA cross-vendor verification — tested merged cleanly onto main (ffe310e) on Windows 11 x64 (Rust 1.98.1 MSVC) with NVIDIA GeForce RTX 5090 (Blackwell) and WARP:

  • cargo test -p victory-shader: 121 passed, 0 failed, 1 ignored (all hardware + WARP VALU/waterfall/diff tests green on RTX 5090 and WARP)
  • cargo clippy -p victory-shader --all-targets: 0 warnings
  • cargo xtask policy: ok

Matches the AMD/macOS results on NVIDIA Blackwell hardware as well. Approving.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6040560332 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/655#pullrequestreview-6040560332). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-24T14:00:19Z. **Review:** APPROVED --- NVIDIA cross-vendor verification — tested merged cleanly onto `main` (`ffe310e`) on Windows 11 x64 (Rust 1.98.1 MSVC) with **NVIDIA GeForce RTX 5090** (Blackwell) and **WARP**: - `cargo test -p victory-shader`: **121 passed, 0 failed, 1 ignored** (all hardware + WARP VALU/waterfall/diff tests green on RTX 5090 and WARP) - `cargo clippy -p victory-shader --all-targets`: **0 warnings** - `cargo xtask policy`: ok Matches the AMD/macOS results on NVIDIA Blackwell hardware as well. Approving. AI-assisted (Gemini 4 Neon).
Halfect commented 2026-11-24 14:04:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Halfect on 2026-11-24T13:23:33Z.


Rebased onto current main ffe310e and fixed the call flagged in #801: the new regression now passes the fourth resource::track argument as None (the test has no per-lane descriptors, so this keeps the old behavior). Head is now 1bd52dc.

Validation on Windows:

  • a_conditional_pixel_export_is_guarded: passed, including its Windows DXIL validation (dxil.dll 10.0.26100.0).
  • cargo check --locked -p victory-shader --tests: passed.
  • CPU-only library suite, explicitly skipping diff_tests, valu_tests, waterfall_tests, and stub_pipeline_is_created: 98 passed, 0 failed, 1 ignored.
  • cargo clippy --locked -p victory-shader --lib --tests -- -D warnings: clean.
  • cargo xtask policy: 154 files ok.

No GPU execution was used for this validation.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7132763330 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/655#issuecomment-7132763330). Originally posted by [Halfect](https://github.com/Halfect) on 2026-11-24T13:23:33Z. --- Rebased onto current main `ffe310e` and fixed the call flagged in #801: the new regression now passes the fourth `resource::track` argument as `None` (the test has no per-lane descriptors, so this keeps the old behavior). Head is now `1bd52dc`. Validation on Windows: - `a_conditional_pixel_export_is_guarded`: passed, including its Windows DXIL validation (dxil.dll 10.0.26100.0). - `cargo check --locked -p victory-shader --tests`: passed. - CPU-only library suite, explicitly skipping `diff_tests`, `valu_tests`, `waterfall_tests`, and `stub_pipeline_is_created`: **98 passed, 0 failed, 1 ignored**. - `cargo clippy --locked -p victory-shader --lib --tests -- -D warnings`: clean. - `cargo xtask policy`: **154 files ok**. No GPU execution was used for this validation.
DeerSilver commented 2026-11-24 14:05:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DeerSilver on 2026-11-24T14:04:23Z.


Re-tested head 1bd52dc merged onto main ffe310e (clean merge) on NVIDIA GeForce RTX 5060 Laptop GPU (Blackwell), driver 621.24, Windows 11 26300, Rust 1.98.1. No game files: the test suite only. Pass, with no local change: the resource::track call from #801 now builds.

  • a_conditional_pixel_export_is_guarded passes. It doesn't use the GPU, but its DXIL check did run: the Windows SDK 10.0.26100.0\x64\dxil.dll is installed here, so Validator::load found it.
  • cargo test --workspace --locked, the full workspace including the VALU and waterfall GPU groups (which ran on the RTX 5060): 343 passed, 0 failed, 6 ignored, against 342 / 6 on main.
  • cargo clippy --workspace --all-targets --locked -- -D warnings: clean.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7133795306 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/655#issuecomment-7133795306). Originally posted by [DeerSilver](https://github.com/DeerSilver) on 2026-11-24T14:04:23Z. --- Re-tested head `1bd52dc` merged onto `main` `ffe310e` (clean merge) on **NVIDIA GeForce RTX 5060 Laptop GPU** (Blackwell), driver 621.24, Windows 11 26300, Rust 1.98.1. No game files: the test suite only. **Pass**, with no local change: the `resource::track` call from #801 now builds. - `a_conditional_pixel_export_is_guarded` passes. It doesn't use the GPU, but its DXIL check did run: the Windows SDK `10.0.26100.0\x64\dxil.dll` is installed here, so `Validator::load` found it. - `cargo test --workspace --locked`, the full workspace including the VALU and waterfall GPU groups (which ran on the RTX 5060): **343 passed, 0 failed, 6 ignored**, against 342 / 6 on `main`. - `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean. AI-assisted (Claude Code).
molodayamama commented 2026-11-24 14:05:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by molodayamama on 2026-11-24T14:04:31Z.


Independent Windows check of 1bd52dcc9e4d2f863123f32a944c7ee4412c6852 (Windows 10 22H2 19045, Rust 1.98.1, MSVC x64).

  • cargo test -p victory-shader --locked --lib a_conditional_pixel_export_is_guarded -- --test-threads=1 --nocapture: 1 passed.

The synthetic pixel shader fixture verified that a conditional export is emitted with a guard. This was a lowering check without rendering.

Only source-built synthetic fixtures were used. AI-assisted verification.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7133799226 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/655#issuecomment-7133799226). Originally posted by [molodayamama](https://github.com/molodayamama) on 2026-11-24T14:04:31Z. --- Independent Windows check of `1bd52dcc9e4d2f863123f32a944c7ee4412c6852` (Windows 10 22H2 19045, Rust 1.98.1, MSVC x64). - `cargo test -p victory-shader --locked --lib a_conditional_pixel_export_is_guarded -- --test-threads=1 --nocapture`: 1 passed. The synthetic pixel shader fixture verified that a conditional export is emitted with a guard. This was a lowering check without rendering. Only source-built synthetic fixtures were used. AI-assisted verification.
Halfect commented 2026-11-24 15:03:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Halfect on 2026-11-24T14:22:10Z.


Thanks @DeerSilver and @molodayamama for the quick re-tests of 1bd52dc — good to have the full workspace suite green on the RTX 5060 and the guarded-export fixture confirmed on a second Windows setup. Nothing further from my side on this head; ready for review.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7134261387 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/655#issuecomment-7134261387). Originally posted by [Halfect](https://github.com/Halfect) on 2026-11-24T14:22:10Z. --- Thanks @DeerSilver and @molodayamama for the quick re-tests of `1bd52dc` — good to have the full workspace suite green on the RTX 5060 and the guarded-export fixture confirmed on a second Windows setup. Nothing further from my side on this head; ready for review.
fuzeofficlal commented 2026-11-24 15:04:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-24T14:31:33Z.


I ran a synthetic raster comparison on 1bd52dc. A 4×2 full-screen triangle uses complementary EXEC masks for two non-final exports to MRT0, then restores EXEC and exports to MRT1. On the Windows default hardware adapter and explicit WARP, MRT0 was red in the left two columns and green in the right two. All eight pixels in MRT1 were blue. Both images matched an independent DXC HLSL reference pixel for pixel.

In a local control with the non-final export guard removed, the shader still passed DXIL validation, but the second MRT0 export painted all eight pixels green on the hardware adapter. MRT1 still read back blue.

Test commit adds the dual-target readback to the test harness and keeps the original lowering test. victory-shader --lib passed 122 tests with one benchmark ignored. Clippy and the asset check passed.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7134518787 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/655#issuecomment-7134518787). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-24T14:31:33Z. --- I ran a synthetic raster comparison on `1bd52dc`. A 4×2 full-screen triangle uses complementary EXEC masks for two non-final exports to MRT0, then restores EXEC and exports to MRT1. On the Windows default hardware adapter and explicit WARP, MRT0 was red in the left two columns and green in the right two. All eight pixels in MRT1 were blue. Both images matched an independent DXC HLSL reference pixel for pixel. In a local control with the non-final export guard removed, the shader still passed DXIL validation, but the second MRT0 export painted all eight pixels green on the hardware adapter. MRT1 still read back blue. [Test commit](https://github.com/fuzeofficlal/VIctory/commit/7ea90bf916909a258ba7cbd3907b65fec2df7580) adds the dual-target readback to the test harness and keeps the original lowering test. `victory-shader --lib` passed 122 tests with one benchmark ignored. Clippy and the asset check passed.
Halfect commented 2026-11-24 15:04:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Halfect on 2026-11-24T14:48:05Z.


Thanks @fuzeofficlal for the raster cross-check on 1bd52dc. The result matches the intended semantics exactly: with complementary EXEC masks, the guarded non-final exports leave the disabled lanes' previous MRT0 values untouched (red/green split), and your control without the guard painting all eight pixels green confirms the guard is what carries the behavior. Pixel-for-pixel agreement with the independent DXC HLSL reference on both hardware and WARP is a strong signal.

I'll keep this branch as-is: its synthetic regression covers the lowering plus DXIL validation, and your dual-target readback harness is a useful external check on top of it. Nothing further from my side on this head; ready for review.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7134968419 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/655#issuecomment-7134968419). Originally posted by [Halfect](https://github.com/Halfect) on 2026-11-24T14:48:05Z. --- Thanks @fuzeofficlal for the raster cross-check on `1bd52dc`. The result matches the intended semantics exactly: with complementary EXEC masks, the guarded non-final exports leave the disabled lanes' previous MRT0 values untouched (red/green split), and your control without the guard painting all eight pixels green confirms the guard is what carries the behavior. Pixel-for-pixel agreement with the independent DXC HLSL reference on both hardware and WARP is a strong signal. I'll keep this branch as-is: its synthetic regression covers the lowering plus DXIL validation, and your dual-target readback harness is a useful external check on top of it. Nothing further from my side on this head; ready for review.
upstream-sync closed this pull request 2026-11-25 01:04:39 +00:00
Marvisak commented 2026-11-25 01:07:49 +00:00 (Migrated from github.com)

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


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

Main handles the title's 8 conditional exports (13091f6e: a non-done pixel export stores in every lane when the done export discards the lanes its guard leaves out; emit/lower.rs export()).

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:7148522032 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/655#issuecomment-7148522032). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:27:01Z. --- Automated triage for the maintainers. Closing because this change is already in `main`, or `main` has since replaced the code it patches. Main handles the title's 8 conditional exports (13091f6e: a non-done pixel export stores in every lane when the done export discards the lanes its guard leaves out; emit/lower.rs export()). 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!655
No description provided.