Repository navigation
Backlog
Description
Static audit on main @ c7e1799 found three correctness bugs in recently merged Direct DXIL / Recompiler modules (reload.rs #2207, lower_image.rs #1951, partition.rs). Part of #1269.
1. reload::changes() misses VOPC SDWA SDST writes, causing stale scalar reload elision
- Where:
crates/xcl/src/gpu/dxil/reload.rs:94, 121-125(contrastcrates/xcl/src/gpu/dxil/lower_valu.rs:1380-1394) - Root cause:
reload::changes(d)reads["SDST", "SDATA", "VDST"]only fromd.enc. ForENC_VOPCwithVariant::SdwaandSD == 1(VOPC_VOP_SDWA_SDST_ENC),SDSTlives insuper::lower::ext_encoding(d)(dword 1).lower_valu.rs:1382-1389writess[sd..=sd+1], whilereload::changesmarks onlyVCC/EXECand leavess[sd..=sd+1]unmarked. - Trigger:
s_load_dwordx4 s[12:15], s[4:5], 0x40 v_cmp_eq_u32_sdwa s[4:5], v0, v1 ; SD=1, SDST=4 overwrites s[4:5] s_load_dwordx4 s[12:15], s[4:5], 0x40
reload::analyzemarks the second load available andlower_mem.rs:1097-1103elides it, returning stale data from the olds[4:5]. - Fix: In
reload::changes, whend.variant == Variant::Sdwa, inspectext_encoding(d): ifSD == 1, markpair(sdst, 2).
2. mimg_unorm_sample passes unclamped level to GetDimensions (leaving coordinates unnormalized when lod >= num_mips) and mismatches mip level on IMAGE_SAMPLE_C_L
- Where:
crates/xcl/src/gpu/dxil/lower_image.rs:630-665, 685-688(added in dxil: emulate explicit-LOD gather4_l(_o) and support UNORM=1 non-cube sampling #1951) - Root cause:
- For explicit-LOD
UNORM=1sampling (IMAGE_SAMPLE_L,IMAGE_SAMPLE_L_O,IMAGE_SAMPLE_C_L), lines 632-640 pass unclampedlevel = ftoui(fmax(round_ne(lod), 0.0))toget_dimensions(tex.handle, Some(level))(unlikemimg_gather4_loddirectly above at lines 471-488, which clampsmip_i = umin(mip_raw, max_mip)). Per D3D12 spec,GetDimensionsreturns0whenlevel >= num_mips; line 648 clamps0to1, so line 664 dividescoords[k] / 1.0and passes raw unnormalized texel coordinates tosampleLevel. - For
IMAGE_SAMPLE_C_LwithUNORM=1, line 632 queries miplevelwhile line 685 lowers tosample_cmp_level_zero(mip 0), mis-scaling coordinates by2^level.
- For explicit-LOD
- Fix: Force
level = 0whencmp.is_some() && (has_lz || !ps); otherwise query mip 0 fornum_mipsand clamplevel = umin(level, num_mips - 1)beforeget_dimensions(tex.handle, Some(level)).
3. Unsound Tier::Exact escapes in recomp/partition.rs
- Where:
crates/xcl/src/gpu/recomp/partition.rs:154-181, 247-309, 330, 378-402, 844-851 - Root causes:
- Narrowed-
EXECuniform_mask(partition.rs:378, 382):vcmp_uniform = is_vcmp(d) && all_uniformomitsst.exec_launch &&(under narrowedEXEC,V_CMP_*writes0in inactive lanes, producing a non-uniform mask), andmask_uniformincludes|| s == EXEC || s == EXEC + 1unconditionally even when!st.exec_launch. Under narrowedEXEC,v_cmp_eq_u32 vcc, v7, v7ors_mov_b64 vcc, execsetsuniform_mask[VCC] = true; after restoringEXEC,s_cbranch_vcczis falsely classifiedTier::Exacteven though split wave32's upper half takes the wrong branch. DS_BPERMUTE_B32/DS_PERMUTE_B32(partition.rs:330, 247-309): Excluded fromis_storeand never tainted withCROSS_LANEinsource_taint(), sods_bpermute_b32 v0, v4, v5; expis classifiedTier::Exact.VOPCSDWASDST(partition.rs:154-181):uses(d)callsrdna2::sgpr_uses(d)(which ignoresext_encoding(d)), sov_cmp_gt_f32_sdwa s[10:11], v4, v5(SD=1) never setsst.mask[10..=11].S_MOVREL*(partition.rs:154-181, 336-449): Indirect SGPR indexing viaM0is unhandled (sgpr_usessees only the base register), allowing tainted SGPRs to escapeExact.or_launch(partition.rs:384): Uses.any(|&s| is_launch(s))(accepts a pair with one half clobbered) and permits-1as the other operand (s_or_b64 exec, s[10:11], -1setsexec_launch = truewhile activating non-launch lanes).
- Narrowed-
- Fix direction: Gate
vcmp_uniformonst.exec_launch, removes == EXEC || s == EXEC + 1frommask_uniform, taintDS_BPERMUTE_B32/DS_PERMUTE_B32withCROSS_LANE, conservatively taintS_MOVREL*, parse SDWASD == 1SDSTinuses(d), and require both halves of the launch pair + a lane-mask other operand inor_launch.
AI use
- Antigravity (Gemini 4 Neon): static code audit on
main @ c7e1799and issue drafting.
Metadata
Metadata
Assignees
Labels
No labels
Activity
oni-swr commentedon Nov 25, 2026
Claiming Parts 2 (mimg_unorm_sample mip clamping / IMAGE_SAMPLE_C_L mip 0) and 3 (recomp/partition.rs Tier::Exact soundness) of #2464 — leaving Part 1 (reload::changes VOPC SDWA SDST) to open PR #2479.
AI use: orchestrated with Antigravity; implementation by Claude Code (Claude Opus 5.5).
oni-swr commentedon Nov 26, 2026
Claiming Part 1 (reload::changes missing VOPC SDWA SDST writes); oni-swr has Parts 2 and 3.
Plan: mark s[SDST..+1] when the SDWA VOPC has SD=1, with a CPU unit test in reload.rs (no GPU needed).