Repository navigation
Open
Description
Summary
Verified 4 larger GPU recompiler correctness issues during an audit of crates/xcl/src/gpu/ (on main 60599a9) 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.- While
rla()already has an#ifdef XCL_PIXELworkaround usingQuadReadLaneAt,ballot()does not. - After
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. - Direction: Under
#ifdef XCL_PIXEL, reconstruct active-quad nibbles viaQuadReadLaneAt((uint)b, 0..3)and merge across the wave with two 32-bitWaveActiveBitOrcalls.
2. TextureCubeArray view-dimension mismatch between desc::image_d3d12 and MIMG emission (crates/xcl/src/gpu/desc.rs, crates/xcl/src/gpu/recomp/emit.rs, crates/xcl/src/hle/d3d12x/real.rs)
- For
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. - Related in
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_w across 4 GiB UMA boundaries (crates/xcl/src/gpu/recomp/emit.rs)
- In
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). - Any buffer or global address crossing a 4 GiB window boundary (e.g., inside
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. - Also in
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) & missing CLAMP / OMOD modifiers (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.- Also noticed: packed
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.
Metadata
Metadata
Assignees
Labels
No labels
Activity
ivall commentedon Nov 23, 2026
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 Floating-point modes: the non-fused MAD/MAC family needsprecise, and thes_round_modeNOOPs are not free #73 (it changes codegen, not rounding); the clamp / omod gaps are worth fixing in a PR with per-instruction GPU tests.Recompiler: OMOD / CLAMP on f64 results, conversions and integer ops;…
Compute TG_SIZE: a partial last wave counts (ivall#105 "also noticed")
Pixel shaders: masks hold the helper lanes (ivall#105 item 1)
Pixel shaders: masks hold the helper lanes (xcl-dev#105 item 1)
Recompiler: wave32 src_vccz / src_execz and SDWA f16 inline constants
ivall commentedon Nov 23, 2026
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.gpu/recomp: complete remaining RDNA2 integer CLAMP=1 saturation
Recompiler: VS inputs packed into one ISG1 register are members of th…
Recompiler: handle packed ISG1 vertex inputs sharing a register (ival…
Recompiler: VS inputs packed into one ISG1 register are members of th…
Luislariosss commentedon Nov 24, 2026
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.
Recompiler: range-check UMA memory windows and propagate 64-bit carry…
Recompiler: handle packed ISG1 vertex inputs sharing a register (ival…
Pixel shaders: masks hold the helper lanes (ivall#105 item 1)
D3D12.X, Recompiler, DirectStorage: integrate PRs ivall#549, ivall#1305-
D3D12.X, Recompiler, DirectStorage: integrate PRs ivall#549, ivall#1305-
Recompiler: VS inputs packed into one ISG1 register are members of th…
Merge pull request #134 from tiagonleal/fix/ps-helper-lane-masks