Recompiler: reload::changes misses VOPC SDWA SDST writes, mimg_unorm_sample passes unclamped mip to GetDimensions, and partition.rs unsound Tier::Exact escapes #2464
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#2464
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?
@microwave805 on GitHub · 2026-11-25 19:30 UTC · original
Static audit on
main @ c7e1799found 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()missesVOPCSDWASDSTwrites, causing stale scalar reload elisioncrates/xcl/src/gpu/dxil/reload.rs:94, 121-125(contrastcrates/xcl/src/gpu/dxil/lower_valu.rs:1380-1394)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.reload::analyzemarks the second load available andlower_mem.rs:1097-1103elides it, returning stale data from the olds[4:5].reload::changes, whend.variant == Variant::Sdwa, inspectext_encoding(d): ifSD == 1, markpair(sdst, 2).2.
mimg_unorm_samplepasses unclampedleveltoGetDimensions(leaving coordinates unnormalized whenlod >= num_mips) and mismatches mip level onIMAGE_SAMPLE_C_Lcrates/xcl/src/gpu/dxil/lower_image.rs:630-665, 685-688(added in #1951)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.IMAGE_SAMPLE_C_LwithUNORM=1, line 632 queries miplevelwhile line 685 lowers tosample_cmp_level_zero(mip 0), mis-scaling coordinates by2^level.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::Exactescapes inrecomp/partition.rscrates/xcl/src/gpu/recomp/partition.rs:154-181, 247-309, 330, 378-402, 844-851EXECuniform_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).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
main @ c7e1799and issue drafting.@oni-swr on GitHub · 2026-11-25 21:25 UTC · original
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 on GitHub · 2026-11-26 13:58 UTC · original
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).