perf(shader): fold idempotent Saturate, FMax, and FMin calls (#312) #314
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: launcher
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
run report
security: hold
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs gpu test
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Androtim--MiniVI!314
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-314"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@RUIZ-Enrique-25002136 on GitHub · 2026-12-02 09:01 UTC · original
RUIZ-Enrique-25002136:perf/shader-fold-clamp-minmax→main· +113 −0 · 1 files · 1 commits · openSummary
Implements bit-exact algebraic folding for idempotent
Saturate,FMax, andFMinDXIL intrinsic calls incrates/victory-shader/src/emit/bitcode/opt.rs::Module::simplify.Fixes #312
Refs #276
AI-Ready Context & Change Map
For downstream coding/review agents, here is the exact scope, rewrite rule set, and verification summary of this PR:
crates/victory-shader/src/emit/bitcode/opt.rs—Module::simplify(Op::Callarm,opt.rs:693-726)args[0]viaself.int_k(...)and handles:dx.op.unary.f32opcode7(Saturate):Saturate(Saturate(y)) -> Saturate(y)(Some(*x)when*xis itselfdx.op.unary.f32(7, _)).Saturatealready maps every finite/infinite/NaN input into[+0.0, 1.0].dx.op.binary.f32opcodes35(FMax) and36(FMin):op(a, a) -> a. Under DXILFMax/FMinsemantics, a NaN is returned only if both inputs are NaN, so(a, a)always producesabit-for-bit (preserving-0.0and NaN payloads).op(op(x, y), z) -> op(x, y)andop(z, op(x, y)) -> op(x, y)wheneverz == x || z == yand both calls share the same opcode (35 == 35or36 == 36). Preserves DXIL NaN propagation in all 4 finite/one-NaN/both-NaN cases; cross-opcode nests likeFMax(FMin(x, y), y)are intentionally not absorbed.REUSE+drop_dead()inModule::optimisealready deduplicate identical inner calls and remove dead producers oncesimplifyreturns the existingV.crates/victory-shader/src/emit/bitcode/opt.rs— Unit Testidempotent_saturate_and_minmax_calls_fold(opt.rs:2261-2332) testingSaturate(Saturate(x)),FMax(x, x),FMin(y, y),FMax(FMax(x, y), y),FMin(x, FMin(x, y)), and negative caseFMax(FMin(x, y), y), plusModule::write()round-trip.Rig Specs Tested On
x86_64-pc-windows-msvcfull workspace clippy and live GPU frame-time benchmarks deferred to GitHub Actions (windows-latest) / maintainer runRun Settings & Profile
victory-shaderbitcode optimizer changes on top oforigin/main(c7d3102)VICTORY_*Overrides: N/AMeasurements & Verification
cargo clippy --workspace --all-targets --locked -- -D warnings(requiresx86_64-pc-windows-msvc; verified on GitHub Actionswindows-latestCI)cargo clippy --workspace --all-targets --all-features --locked -- -D warnings(requiresx86_64-pc-windows-msvc; verified on GitHub Actionswindows-latestCI)cargo clippy --locked -p victory-shader --lib -- -D warnings-> 0 warnings, exit 0cargo test --locked -p victory-shader -- --test-threads=1-> 253 passed, 0 failed, 2 ignored (includingidempotent_saturate_and_minmax_calls_foldandevery_pass_leaves_what_random_programs_store)cargo test --locked -p xtask-> 8 passed, 0 failedcargo xtask policy->asset policy: 321 files ok@Androtim on GitHub · 2026-12-02 09:03 UTC · original · edited 2026-12-03 12:02 UTC
Automated triage for the maintainers (not an approval).
Verdict:
needs-rebase· CI (check):passingThis PR no longer merges cleanly into
main.To change the verdict: Rebase onto current
mainand resolve conflicts; CI and triage will run again automatically.Generated with Antigravity CLI (
agy).github-bot referenced this pull request2026-12-02 09:10:27 +00:00
github-bot referenced this pull request2026-12-02 10:08:30 +00:00
@Androtim on GitHub · 2026-12-03 11:12 UTC · original
Gate 3 Live Windows D3D12 Cold-Cache GPU Verification — PASS
Tested combined PR #311 + PR #314 on Windows 11 + NVIDIA RTX 4060 Ti 8 GB (
1440pDLSS Quality, fresh cold shader cache):14/14victory-shader::emit::bitcode::opt::testspassing (idempotent_saturate_and_minmax_calls_fold+ differential suite).DRAWS 9904,DROPPED 172,0 being made, peak dedicated VRAM5476 / 6613 MiB).Note: Once PR #311 merges, PR #314 only has a trivial adjacent unit-test line conflict at the bottom of
crates/victory-shader/src/emit/bitcode/opt.rs(zero production-code overlap). Ready to merge!@Androtim on GitHub · 2026-12-03 11:33 UTC · original
PR
#311has merged (8780a119), leaving the expected adjacent unit-test conflict incrates/victory-shader/src/emit/bitcode/opt.rs. Gate 3 cold-cache GPU verification already passed — once rebased ontomainwith green CI, ready to auto-merge immediately.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.Merge
Merge the changes and update on Forgejo.