xshader: use 3-bank ballots and double-buffered reads in page_waves #555
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/555"
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-29T23:07:21Z.
Split out from #523 per review. Adds LDS-budget-aware 3-bank
page_bitsballots and double-bufferedpage_lane_valuesreads inpage_wavessotb_page_ballotandtb_page_readdrop their pre-clear / post-read barriers when staticgroupsharedusage leaves room under the 32 KiB D3D12 limit.Changes
tools/shader-compiler/src/hlsl.rs: addgroupshared_bytesto statically size declaredgroupsharedarrays (#definebounds and expressions included, returningNoneif dynamic/unknown).tools/shader-compiler/src/hlsl/page_waves.rs: switchdeclarations(group, branchless, existing_lds)to 3-bankpage_bitsand double-bufferedpage_lane_valueswithtb_page_init(tid)initial zeroing when the existinggroupsharedfootprint fits within 32 KiB, falling back to single-buffer / legacy form otherwise.tools/shader-compiler/src/hlsl/fspx_wave.rs,driver/pipeline.rs,mesh.rs,emitter/output.rs: computeexisting_ldsand emittb_page_init(tb_wave_tid);.tools/shader-compiler/src/tests/hlsl/page_waves.rs: testgroupshared_bytesand validate roomy, 128-thread mesh, branchless, single-read, and full-LDS fallback forms with DXC + DXV.Verification
python3 tuxbox.py check --no-gpupassed 9/9 checks:host_profilesunchanged)1.9.2609.5) flags (-disable-lifetime-markers -fnew-inlining-behavior, plus-O1forcs_6_6):213/213translated shaders compiled with 0 DXC segfaults (45unsupported byxshader, identical toorigin/main).tools/stage_baseline.py cpuacross the 58 locally recordedtools/reference/stage-baseline/sample.jsonrequests (89translations):89/89compiled (0regressions),83/89byte-identical DXIL.6changed translations: HLSL bytes+0.074%(2,073,746 -> 2,075,276), DXIL bytes+0.827%(822,464 -> 829,268). (DXC wall-clock runtime rose across the83identical shaders alike during the back-to-back run, so no standalone DXC compile-time claim is made.)tuxbox.py check) and ProjectScarlett were not run against this split branch.AI-assisted: split, rebased, and tested with LLM tooling.
Imported from brcly/TuxBox. Originally posted by glovepost on 2026-11-30T00:50:21Z.
Rebased onto
main(f482572a, commit0e531c563eb4) with no functional changes fromc25f3735, and ran the changed GPU checks on NVIDIA:TUXBOX_CHECK_JOBS=2 DXC=<dxc> python3 tuxbox.py check --changed --adapter 10de:1e84 --proton <proton> --prefix <prefix> --windows-dxc <windows-dxc>10de:1e84), driver620.73.04,GE-Proton11-14Lanes and fixtures on the GPU(lanes-bindless-compute,lanes-compute-root,lanes-compute-root-recovery,lanes-raster-tables,lanes-shader-cache) andShader translator on the GPUall passed (13 passed, 0 failed, 0 not run).Evidence: TuxBox check of 0e531c563eb4, no uncommitted changes, GPU 10de:1e84: 13 passed, 0 failed, 0 not runImported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-30T01:26:54Z.
The AMD check you were missing, on
0e531c56: AMD iGPU (1002:13c0, RADV, Mesa 26.0.8, GE-Proton11-14, Linux), fullpython tuxbox.py check: 199 pass, 0 fail. A game was loading on the other card for part of it. ProjectScarlett was not run on this commit.Evidence: TuxBox check of
0e531c563e, no uncommitted changes, GPU 1002:13c0: 14 passed, 0 failed, 0 not runImported from brcly/TuxBox. Originally posted by Claudineijoseprill on 2026-11-30T03:35:41Z.
AMD discrete RDNA 1 run, on
0e531c56: Radeon RX 5700 XT (1002:731f, RADV, Mesa 25.2.8, GE-Proton11-14, Ubuntu 24.04),python tuxbox.py check --changedwith--proton,--prefixand--windows-dxc: 101 pass, 9 fail.Every gate matches a full check of unchanged
main(f482572a) on the same machine; no regressions. The 9 failures are features this card or driver lacks and fail the same onmain: 5lanes-mesh-*andtranslated-mesh(no mesh shaders),bvh64-queryandbvh32-query(no ray tracing), andpixel-interp(flatandhalffail with pipelineE_INVALIDARG; RADV doesn't exposeVK_KHR_fragment_shader_barycentricon this card).Not run: a game.
Evidence: TuxBox check of
0e531c563e, no uncommitted changes, GPU default adapter: 11 passed, 2 failed, 0 not runOne note on the new test in
src/tests/hlsl/page_waves.rs: it looks fordxcanddxvonly at$HOME/.local/binand returns early otherwise, so on machines that keep them elsewhere (e.g. onPATHfrom a distro or the devcontainer) it passes without compiling anything. Here they happen to be at that path, so it ran and passed. Resolving them fromPATH(orDXC) would keep it from silently skipping.Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-30T04:12:11Z.
Heads-up: main just landed a large cleanup (up to
e5d2e913), so this PR needs a rebase.rustfmt.toml).unwrap(), lossyascasts and undocumentedunsafeoutside tests.cargo fmt --check, rustdoc with warnings denied, and Miri on the providers' unit tests.The least painful way is to format your branch first, so the rebase only shows real changes:
Then run
python tuxbox.py check --no-gpu, which now includes the format step.If clippy flags something new:
Fromfor widening,TryFromfor narrowing, and a mask for bit fields.unwrap(): use?, orexpectwith the reason it can't fail.unsafeblock: it needs a// SAFETY:comment.CONTRIBUTING's "Code checks" section lists the commands. Thanks!