Repository navigation
Conversation
Only emit HLSL prelude helpers (bvh_intersect, FMT_INFO, st_bytes, dst_sel, ld_raw) and memory accessor switches (xcl_mLoad*, xcl_mStore*, atomics, xcl_loadx4) when actually referenced by the translated shader body. This trims dead code from emitted HLSL and lowers DXC compile time on shaders with single or multiple memory windows.
Owner
Author
|
Upstream PR xcl-dev#1043 was closed or merged. |
ufoptg
pushed a commit
that referenced
this pull request
Nov 27, 2026
After s_wqm the helper pixels of a quad an edge splits are in EXEC, but ballot() took masks with WaveActiveBallot alone, which leaves helper lanes out before SM 6.7: v_cndmask gave them the false value, s_and_saveexec dropped them, derivatives taken across the quad by hand were wrong along every edge, and a waterfall loop over v_readfirstlane never removed a helper lane from EXEC (ran into the loop budget). ballot_px gets each quad's four bits through quad reads and collects them with four ballots (a helper lane gets the wave's result of a ballot, but not of WaveActiveBitOr on an RTX 5070 Ti, and it holds its own copy of EXEC). Masks only read lane by lane (x64_masks liveness, now also for pixel shaders) take ballot_px_local: one ballot plus the lane's own bit. The entry EXEC stays the live lanes. HLSL of every other stage is byte-identical. Tests: gpu_ps_masks_hold_helper_lanes_on_triangle_edges (384 / 1024 pixels wrong before, 0 after, wave64 and wave32 programs), gpu_ps_helper_lanes_see_ballots_and_quads_are_lanes_4k. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ufoptg
pushed a commit
that referenced
this pull request
Nov 27, 2026
Pixel shaders: masks hold the helper lanes (#105 item 1)
ufoptg
pushed a commit
that referenced
this pull request
Nov 27, 2026
In `crates/xcl/src/gpu/dxil/lanes.rs`, `Lw::ballot` called plain `WaveActiveBallot` even in pixel shaders (`self.gfx` with `ps: Some(_)`). Under SM 6.6, `WaveActiveBallot` excludes helper lanes, whereas `Lw::rla` already uses quad reads for pixel shader helper lanes and the HLSL path uses `ballot_px` / `quad_bits` + `ballot_px_quad` (PR #134 / #105 item 1). After `s_wqm_b32`/`s_wqm_b64`, dropping helper-lane bits from compare masks corrupted `v_cndmask` / `s_and_saveexec` values read via DPP quad derivatives and caused `v_readfirstlane` waterfall loops to spin until the loop budget. Port both parts of #105 item 1 and #134 to the direct DXIL translator: - Split `Lw::ballot_ps_quad(q)` out of `Lw::ballot_ps(cond)` in `crates/xcl/src/gpu/dxil/lanes.rs`: four `WaveActiveBallot` passes spread each quad member's bit `p` from live lanes back to bit `4k + p`, preserving the wave32-in-wave64 `gfx_half` select, constant-false `(0, 0)` short-circuit, and live-lanes-only entry `EXEC` (`setup_pixel` calls `gfx_common_init` before setting `self.gfx`). Non-VOPC PS masks (such as `v_add_co_u32` carries) route through `ballot_ps` -> `ballot_ps_quad`. - In `crates/xcl/src/gpu/dxil/lower_valu.rs`, evaluate plain pixel-shader VOPC compares per quad member (`p in 0..4`) by quad-reading VGPR source operands with `QuadReadLaneAt` (leaving SGPRs such as `v_readfirstlane` results and constants wave-uniform) and feeding the 4-bit quad mask to `Lw::ballot_ps_quad`, avoiding `QuadReadAcross*` on compare predicates that crash AMD RDNA2/3/4 `amdxc64` (#134). Add CPU/DXIL-validator and CI-WARP-safe GPU draw regression tests in `lanes.rs` (384/1024 wrong pixels pre-fix on RTX 4060 -> 0/1024 post-fix for both wave64 and wave32 pixel shaders, with zero `dx.op.quadOp` in VOPC pixel shaders). Part of xcl-dev#1269 Assisted-by: Google Antigravity (Gemini 4 Neon)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prune unreferenced HLSL prelude helpers (
bvh_intersect,FMT_INFO,st_bytes,dst_sel,ld_raw) and memory accessors (xcl_loadx4,xcl_mStore*,xcl_mInterlocked*) when translating shaders.Previously,
PRELUDE_MEMand the entiremem_accessorsswitch-case ladder were emitted unconditionally, bloating the emitted HLSL and increasing DXC compile times for shaders that only perform simple loads or do not use raytracing BVH or packed buffer formatting.What is in it
crates/xcl/src/gpu/recomp/emit.rs: conditionally emit HLSL prelude helpers and memory accessors based on shader body usage.crates/xcl/src/gpu/recomp/tests.rs: addunreferenced_helpers_and_accessors_are_prunedunit test verifying that unreferenced helpers and accessors are omitted from emitted HLSL and that resulting shaders compile cleanly with DXC.Tested
cargo test --workspace -- --test-threads=4: 736 passed, 0 failed, 41 ignored.gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64unreferenced_helpers_and_accessors_are_prunedwith DXC compilation.Regression run
We have no retail title; this changes
crates/xcl/src/gpu/recomp/emit.rs, so it needs one. Could someone with a title post thexcl-smokeblocks formainand this head?main:
PR:
Not tested
AI use
Mirror of xcl-dev#1043 (auto-synced, do not edit).