Shaders: skip redundant heap clamps on host memory/consts, clear stale DOUBLES flag, fix v_permlane and wave32 f64 sum (#505) #598

Open
orazal12 wants to merge 1 commit from upstream-pr/598 into main
orazal12 commented 2026-11-25 02:49:54 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by orazal12 on 2026-11-25T02:49:54Z.


Addresses DXIL regressions introduced between 2119b0e and a803c87 (Refs #505):

  • Skip redundant VIEW_LIMIT clamps on host-owned memory & in-bounds constants: Lower::memory() now uses heap_handle_unclamped for host-owned SLOT_MEMORY indices, and heap_handle skips emitting dx.op.binary.i32 UMin for compile-time constants already within bounds. Dynamic title-controlled heap indices and out-of-bounds constants still clamp.
  • Clear stale flags::DOUBLES after dead-code elimination: tracks TypeDef::Double in Usage::doubles and clears flags::DOUBLES in Shader::finish() when opt::DEAD removes all double ops.
  • Include v_permlane* in console_lanes: adds || n.starts_with(v_permlane) in lower.rs so v_permlane16_b32/v_permlanex16_b32 shaders emit WaveSize metadata and don't trip debug_assert!(self.console_lanes).
  • Fix active_f64_sum wave32 exchange guard: matches shape() (!self.local && self.exchange.as_ref().is_some_and(|e| !e.1)) so small groups / local waves on 32-lane GPUs don't emit invalid LDS exchange barriers.

Verification:

  • cargo test -p victory-shader --offline: 218 passed, 0 failed (4 new unit tests validating with dxil.dll)
  • cargo test -p xtask --offline: 4 passed (asset policy check ok)
  • cargo clippy -p victory-shader --all-targets --offline -- -D warnings: 0 warnings
<!-- greyfinch-sync:fxceless/victory-fork:issue:6596066118 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/598). Originally posted by [orazal12](https://github.com/orazal12) on 2026-11-25T02:49:54Z. --- Addresses DXIL regressions introduced between `2119b0e` and `a803c87` (Refs #505): - **Skip redundant `VIEW_LIMIT` clamps on host-owned memory & in-bounds constants**: `Lower::memory()` now uses `heap_handle_unclamped` for host-owned `SLOT_MEMORY` indices, and `heap_handle` skips emitting `dx.op.binary.i32` UMin for compile-time constants already within bounds. Dynamic title-controlled heap indices and out-of-bounds constants still clamp. - **Clear stale `flags::DOUBLES` after dead-code elimination**: tracks `TypeDef::Double` in `Usage::doubles` and clears `flags::DOUBLES` in `Shader::finish()` when `opt::DEAD` removes all double ops. - **Include `v_permlane*` in `console_lanes`**: adds `|| n.starts_with(v_permlane)` in `lower.rs` so `v_permlane16_b32`/`v_permlanex16_b32` shaders emit `WaveSize` metadata and don't trip `debug_assert!(self.console_lanes)`. - **Fix `active_f64_sum` wave32 exchange guard**: matches `shape()` (`!self.local && self.exchange.as_ref().is_some_and(|e| !e.1)`) so small groups / local waves on 32-lane GPUs don't emit invalid LDS exchange barriers. **Verification:** - `cargo test -p victory-shader --offline`: 218 passed, 0 failed (4 new unit tests validating with `dxil.dll`) - `cargo test -p xtask --offline`: 4 passed (asset policy check ok) - `cargo clippy -p victory-shader --all-targets --offline -- -D warnings`: 0 warnings
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/598:upstream-pr/598'
git switch 'upstream-pr/598'

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/598'
git switch 'upstream-pr/598'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/598'
git switch 'upstream-pr/598'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/598'
git switch 'main'
git merge --squash 'upstream-pr/598'
git switch 'main'
git merge --ff-only 'upstream-pr/598'
git switch 'main'
git merge 'upstream-pr/598'
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
fxceless/victory-fork!598
No description provided.