xshader: predicate guarded ALU blocks with select() and elide large-shader ISA comments #482
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/482"
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?
Imported from brcly/TuxBox. Originally posted by glovepost on 2026-11-29T14:53:02Z.
Summary
Shrink the HLSL control-flow graph emitted by
xshaderso DXC anddxil-spirvspend less time structurizing and optimizing per-lane EXEC branch diamonds:exec_groupblocks and pixel input coalescing: Splittools/shader-compiler/src/hlsl/exec_group.rsintotools/shader-compiler/src/hlsl/exec_group/{mod.rs,predicate.rs}(keeping all Rust files within the 1,200-line limit), allow pixel input reads (i.iN,i.iN.<xyzw>, andGetAttributeAtVertex(...)) inside pure ALU regions, guard bothselect_writesandpredicateagainst speculating integer/and%, and wireexec_group::predicate()afterexec_group::group()intools/shader-compiler/src/hlsl/driver/pipeline.rs. Pure guarded VGPR and SDWA writes become non-branchingselect(..., (uint)(expr), dest)statements, sharing a singlebool tb_ppredicate when a block holds multiple writes or absorbed block-local temporaries.Emitterskips per-instruction// 0xXXXX <mnemonic>comments inemitter/instruction.rsandpaired_wave64.rswhen a shader exceeds 1,500 instructions (opt-in viaTB_ISA_COMMENTS), trimming HLSL size on large shaders.float64helpers: Converttb_f64_round,tb_f64_to_i32, andtb_i32_to_f64intools/shader-compiler/src/hlsl/float64.rsfrom short-circuit?:/&&/||chains to HLSL 2021select/and/orwith& 31u-masked shifts.tools/shader-compiler/src/tests/hlsl/host_profiles.txt(TUXBOX_BLESS_PROFILES=1): only the 16-hex content hashes changed for single-lane-per-thread profiles because guarded ALU writes now emitselect(); no target profiles or wave requirements changed.tools/check_packed_integer_gpu.py:load_inputandtools/check_byte_sad_gpu.py:instrumentto match both plainvN = 0x...u;andselect()-predicatedvN = select(..., (uint)(0x...u), vN);initial literal assignments when injecting GPU check inputs.exec_lovertex shader (TuxBox-upstreamvs this branch with DXC),if (exec_lo &guards dropped from302to1, ISA comments from1,804to0, DXIL-O3br labelbranches from300to1(DXC-O3compile time0.056 s -> 0.029 s), and DXIL-O0br labelbranches from304to3, withdxvpassing. Covered by new unit tests intools/shader-compiler/src/tests/hlsl/exec_group.rsandtools/shader-compiler/src/tests/hlsl.rs, all 64 translator GPU checks (tools/check_translator_gpu.py), and all 39 scenarios across the five shader Lanes suites on both NVIDIA and AMD.Drafted with AI assistance and verified with the CPU suite and dual-GPU checks listed below.
Tested
Run the checks relevant to this change.
GPU, driver and backend:
10de:1e84), NVIDIA driver620.73.04, GE-Proton11-14 + vkd3d-proton1002:13c0), Mesa26.3.1-arch3.5(RADV RAPHAEL_MENDOCINO), GE-Proton11-14 + vkd3d-protonCommands run and their results:
Checks
CI runs the Python unit tests, the shader compiler, DXBC, and XG layout tests, and a Windows typecheck of
tuxbox-d3d12.If this pull request changes evidence JSON, regenerate the results table and the progress map and include both files:
Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-29T16:23:55Z.
Two checks of this on current
main, both cards, by running the translated programs themselves:Not covered: pixel, vertex and geometry programs, which this changes most (17,381 pixel programs in the recorded set); our tools only execute compute and mesh.