xshader: saturate D16 integer image loads and look through half packing in type inference #159
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
library
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/omonkeyz--xbox-emulator!159
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/159/head"
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?
@GDAgent on GitHub · 2026-11-22 16:49 UTC · original
GDAgent:port/xshader-d16-integer-images→main· +269 −13 · 6 files · 1 commits · closed without mergingLibrary / area: tombox-xshader (
hlsl/mimg_d16.rs,hlsl.rs,tests/synthetic.rs,tests/exec_mem/mimg.rs,tests/exec_mem/mod.rs)Exports changed (exports.txt rows): none
Source of the behaviour: RDNA2 D16 integer image load/store semantics as modelled by Mesa RADV (
integer_dest_saturatesinac_nir_opt_16bit_tex_imageandopt_image_store_datainnir_opt_16bit_tex_image). Ported from an earlier TomBox commit (86a9899, authored by this account; MIT OR Apache-2.0); the Mesa reference is credited inTHIRD_PARTY/CREDITS.Changes:
mimg_d16::lane_to_halfso D16 integer image loads saturate each component to 16 bits (min(x, 0xffffu)forLane::Uint,asuint(clamp(asint(x), -32768, 32767)) & 0xffffuforLane::Sint) instead of truncating with& 0xffffu.Emitter::infer_tbuf_typesso D16 half-packing/unpacking operations (v_mov_b32,v_cndmask_b32,v_lshl_or_b32with shift 16, register-to-registerv_or_b32,v_and_b32with0xffff/0xffff0000, 16-bitv_lshrrev_b32/v_lshlrev_b32,v_perm_b32, etc.) are followed to the half producers/consumers rather than counted as integer evidence.uinttype comes only fromimage_atomic_*(where texel signedness is unknown).mimg_d16, synthetic half-packing inference/refusal tests intests/synthetic.rs, and 56 D3D12 execution cases intests/exec_mem/mimg.rscovering D16 UINT4 and SINT4 loads (out-of-range saturation) and stores (zero- and sign-extension) across 7 DMASK patterns.Tests (native Windows 11; not run under Proton):
cargo test --release -p tombox-xshader --lib --test opcodes --test synthetic: 117 passed, 0 failed, 2 ignored.cargo test --release -p tombox-xshader --test exec -- image_mimg(D3D12 execution on hardware): 8 passed, includingimage_mimg_d16_packs_halvesandimage_mimg_d16_integer_images(56 D16 integer cases, each rerun with runtime inputs).The full exec suite has 3 failures that also occur on plain
main:scalar_smem_loads,exec_mem::mtbuf::mtbuf_d16_store_formats,vop::basic::vop2_basic. Nothing extra fails with this change.Not verified in a title with this repo's build.
Related, not fixed here: #103 (MIMG load/store coverage).
cargo test -p tombox-xshadertests passNo game or console files and no binaries included
No fake success; unsupported D16 atomic/unknown-signedness forms fail explicitly
@omonkeyz on GitHub · 2026-11-22 17:10 UTC · original
Applied in
e239468(merged in43d17b0) with your authorship kept, thanks. I removed 17 trailing // comments because the repo allows no comment lines, and I resolved a conflict in mimg.rs against current main.Pull request closed