Shaders: fix MIMG 3D Z texel offsets, a16 offset truncation, and cubemap sample_d LOD #353
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!353
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-353"
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?
@AscilCH on GitHub · 2026-11-24 23:49 UTC · original
AscilCH:fix/shader-mimg-3d-offset-a16-and-cube-lod→main· +438 −33 · 3 files · 1 commits · openProblem
Three MIMG sampling bugs in
crates/victory-shader/src/emit/lower.rs:a16truncates the offset word:Lower::imageread the_ooffset VGPR throughaddr_val(self, 0)(which masks to 16 bits whena16is set) instead ofaddr_u32(self, 0), destroying bits[21:16](the 3D Z offset) even though GFX10 offset words are always 32-bit.op == 60: Offset decoding capped atoffsets.min(2)(dropping Z in bits[21:16]), and folding constant offset words in-8..=7into DXIL immediate constants only ran in the pixelop == 60(sample.f32) arm — causingimage_sample_lz_o(op == 62) and computeimage_sample_oto emit non-immediate offset SSA values thatdxil.dllrejects.image_sample_dmultiplieslog2byLOG2_E(1.4427xLOD bias):Lower::imagecalledself.unary(23, texels)and multiplied bystd::f32::consts::LOG2_E, assuming DXIL unary opcode23wasln. DXIL opcode23(Log, also used byv_log_f32) is already base-2log2, so cubemap gradient samples shifted 1.4427× too high in the mip chain.Fix
addr_u32(self, 0)?, extract alloffsetsaxes ([(0, 26), (1, 18), (2, 10)]), and fold constant offset words whose fields all lie in-8..=7into immediatei32constants once in the sharedoffset_wordblock beforematch op.LOG2_Emultiply in the cubemapimage_sample_d(63 if kind == 5) path.#[cfg(test)]View::Texture3DandView::CubeMipshelpers inemit::hostand end-to-end testsmimg_3d_sample_offset_preserves_z_and_a16(coveringa16 = falseanda16 = truewith ±Z offsets) andmimg_cube_sample_d_selects_exact_log2_mip(measuring exact trilinear mip LODs0.0, 1.0, 1.5, 2.0).Verification
cargo test -p victory-shader --locked mimg_: passed (hardware D3D12 + WARP +dxil.dll)cargo xtask policy: 169 files okcargo clippy -p victory-shader --all-targets --locked -- -D warnings: cleancargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings: clean(AI-assisted; synthetic tests only, no game data.)
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.