GPU Recompiler: PS helper lanes dropped in ballot()/WQM, TextureCubeArray mismatch, 4 GiB window carry, and DXC -Gis / CLAMP-OMOD gaps #105
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl#105
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@raylitebull on GitHub · 2026-11-23 11:15 UTC · original
Summary
Verified 4 larger GPU recompiler correctness issues during an audit of
crates/xcl/src/gpu/(onmain60599a9) that warrant dedicated PRs with thorough GPU testing (AMD + NVIDIA):1. Pixel-shader
ballot()/write_mask()drops helper lanes in WQM (crates/xcl/src/gpu/recomp/emit.rs)WaveActiveBallot(b)unconditionally returns0for helper lanes in HLSL SM 6.6.rla()already has an#ifdef XCL_PIXELworkaround usingQuadReadLaneAt,ballot()does not.s_wqm_b64 exec, exec, helper lanes haveEXEC == 1, yetv_cmp_*,v_cmpx_*,v_add_co_u32, andv_sub_co_u32clear helper-lane mask bits to0:v_cndmask_b32picks the false branch, 64-bit carries are lost on helper lanes, ands_and_saveexec_b64kills helper lanes before subsequent DPP/swizzle/implicitSample()derivatives on primitive edges.#ifdef XCL_PIXEL, reconstruct active-quad nibbles viaQuadReadLaneAt((uint)b, 0..3)and merge across the wave with two 32-bitWaveActiveBitOrcalls.2.
TextureCubeArrayview-dimension mismatch betweendesc::image_d3d12and MIMG emission (crates/xcl/src/gpu/desc.rs,crates/xcl/src/gpu/recomp/emit.rs,crates/xcl/src/hle/d3d12x/real.rs)ImageType::Cubewithdepth > 6,desc::image_d3d12creates aD3D12_SRV_DIMENSION_TEXTURECUBEARRAYSRV, butemit.rsalways castsDIM == 3(SQ_RSRC_IMG_CUBE) toTextureCube<float4>,cube_dirdiscards the array slice (floor(face / 8)), andget_resinfohardcodes depth to1u.hle/d3d12x/real.rs:dev_create_srv_x/view_shapehit fallback defaults forD3D12_SRV_DIMENSION_TEXTURECUBEARRAY(10) (hardcodingMipLevels = 1and depth6instead ofNumCubes * 6).3. Missing 64-bit carry/borrow into
xcl_wacross 4 GiB UMA boundaries (crates/xcl/src/gpu/recomp/emit.rs)smem,mubuf,buffer_atomic,mubuf_d16,flat, andflat_atomic,self.window(&hi)is computed before addingvoff/soff/imm/stride * index(unlikebvh_intersect_ray, which computesuint64_t afirst).Uma::sparse_reservespanning windows 0..2, orglobal_load_*with negative 12-bit signedOFFSETnear a window start) wraps inside the previous window instead of carrying/borrowing into the adjacent window.Mode::Geometry,IO_GS_VERTICESis only a 32-bituint xcl_vinwithoutxcl_w, so pre-fetched vertices in window 3 read from window 0.4. DXC fast-math (
-Gis) & missingCLAMP/OMODmodifiers (crates/xcl/src/gpu/recomp/dxc.rs,crates/xcl/src/gpu/recomp/emit.rs)dxc.rsdoes not pass-Gis(IEEE strictness), allowing DXC fast-math contraction/reassociation on translated float ops (and note that changing DXC flags indxc.rsshould be included in the disk cache hash so existing cached DXIL invalidates).valu64emitssaturate(double)forCLAMP=1(HLSL SM 6.6saturatehas nodoubleoverload, narrowing tofloatand losing 29 bits of precision) and ignoresm.omod;v_cvt_f32_f64andv_cvt_f16_f32ignorem.omod/m.clamp; integerCLAMP=1saturation is only handled onv_add_nc_i32/v_sub_nc_i32and dropped onv_add_nc_u32/v_sub_nc_u32/v_add3_u32/v_pk_add_u16/v_dot4_i32_i8.ISG1vertex inputs sharing a register emit duplicateXclInfield names (a{e.register}) inMode::Vertex,code32src_vccz/src_execzchecks(lo | hi) == 0in wave32 mode, SDWA passesf16 = falsetocode32, andMode::Computetg_sizeuses truncating division instead ofdiv_ceil.github-bot referenced this issue2026-11-26 04:59:09 +00:00
@ivall on GitHub · 2026-11-23 11:42 UTC · original
Thanks. Triage against current
main:ballot()– known (HANDOFF: "Ballots (v_cmp) still leave helper lanes out"). Note[WaveOpsIncludeHelperLanes](ps_6_7) was tried and hung the device ~9 s in (the entry ballot then included helper lanes forever), so a quad-read reconstruction like you suggest is the way – it needs GPU tests on primitive edges (console_compiled_derivatives_hold_on_triangle_edgesis the model).-Gis, omod / clamp gaps –-Giswas measured in #73 (it changes codegen, not rounding); the clamp / omod gaps are worth fixing in a PR with per-instruction GPU tests.@ivall on GitHub · 2026-11-23 21:14 UTC · original
Progress: the TextureCubeArray mismatch is fixed by #149 (merged). The helper-lane masks (#134) crashed the driver's compiler on RDNA4 in
gpu_wave64_ps_whole_wave_reductionsand are not merged yet; the 4 GiB window carry is #138, next in line.@Luislariosss on GitHub · 2026-11-24 01:06 UTC · original
Item 2 (TextureCubeArray mismatch) looks fixed on main at
2997c9aca, so the issue may be worth narrowing to items 1, 3 and 4.Evidence from the tree:
desc.rs:262states the intent:// always a cube array (of one cube, too): translated shaders declare TextureCubeArray.emit.rs:2165and:2272now emitTextureCubeArray<float4>forDIM == 3, and the sample form passescube_slice(face)as the array coordinate.emit.rs:5366:float cube_slice(float face) { return (float)(((uint)round(face)) / 8u); }- the console'sface + 8 * sliceencoding, so the slice is no longer discarded.emit.rs:2296:get_resinfodeclaresTextureCubeArrayand does{t}_d *= 6u, instead of hardcoding depth to 1.runner.rs:292-293createsD3D12_SRV_DIMENSION_TEXTURECUBEARRAYwithNumCubes: t.depth / 6.Item 1 is not addressed as far as I can see:
rla()has the#ifdef XCL_PIXELquad-read workaround (emit.rs:5314-5333) butballot()(:5308-5311) still returnsWaveActiveBallot(b)unchanged, so helper lanes are dropped there.I did not test any of this on a GPU beyond a full
cargo test --workspacerun on an RX 9060 XT (677 passed, 0 failed, 41 ignored), which exercises the recompiler but not a pixel shader withs_wqmon a primitive edge. Treat the above as a reading of the code, not as a measured fix.AI-assisted.