Shaders: decode fixed 4-VGPR data and 4-SGPR rsrc for image_bvh_intersect_ray #3316
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!3316
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3316"
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?
@mgunes1311-lab on GitHub · 2026-11-26 17:18 UTC · original
mgunes1311-lab:shader-bvh-mimg-operands→main· +274 −28 · 2 files · 1 commits · openCoordination
Claimed in #1633 (
Shaders: decode fixed 4-VGPR data and 4-SGPR resource operands and SP3 formatting for image_bvh_intersect_ray). CheckedSTATUS.md,CLAIMS.md, andforge/main— zero conflict with open PRs orforge/mainhunks incrates/victory-shader/src/gfx10/{fields,sp3}.rs.Problem
Per the AMD RDNA2 ISA manual (Chapter 11, MIMG
image_bvh_intersect_ray0xe6andimage_bvh64_intersect_ray0xe7) and LLVM'sMIMG_IntersectRaydefinition:v[dst:dst+3]) and read a 4-SGPR (128-bit,s[rsrc:rsrc+3]) BVH resource descriptor regardless of rawdmask,r128,d16,tfe, orlwebits in the MIMG header. PreviouslyEncoding::Mimgsizeddatafromdmask.count_ones().max(1)(withd16/tfe/lwe) andrsrcas 8 SGPRs wheneverr128 == 0, breaking descriptor tracking and result sizing ifr128ordmaskbits are cleared.vdst, vaddr, srsrcplus cache flags anda16, omitting image-only modifiers (dmask:,dim:SQ_RSRC_IMG_*,r128,unorm,d16,tfe,lwe).Fix
gfx10::fields(Encoding::Mimg), forcedatato 4 VGPRs (ignoringd16,tfe,lwe) andrsrcto 4 SGPRs whenevername.starts_with("image_bvh").gfx10::sp3(Fields::Image), emit only cache flags anda16after the operands forimage_bvh*.Verification
gfx10::sp3::tests::bvh_intersect_ray_uses_fixed_operands_and_omits_image_modifierstesting SP3 disassembly ofimage_bvh_intersect_ray(standard +dlc glc a16) and NSAimage_bvh64_intersect_ray, plus operand decoding withdmask=0, r128=0, d16=1, tfe=1, lwe=1.gfx10::sp3::tests::bvh_intersect_ray_without_r128_or_dmask_bits_executes_on_gpucompiling and dispatching a synthetic compute shader withimage_bvh_intersect_rayencoded withdmask=0, r128=0(ands16clobbered) on both hardware D3D12 and WARP, verifying DXIL validation and GPU ray-box hit output.cargo test -p victory-shader --all-features --locked bvh_intersect_ray,cargo clippy --workspace --all-targets --all-features --locked -- -D warnings, andcargo xtask policyon Windows 11 (x86_64-pc-windows-msvc).AI-assisted contribution (Google Antigravity); all code, DXIL validation, and D3D12/WARP GPU tests were locally executed and verified.
@Dukestar69 on GitHub · 2026-11-26 17:27 UTC · original · approved these changes
Reviewed the diff and verified locally on Windows 11 x64:
image_bvh*with fixed 4-VGPRdata(ignoringdmask/d16/tfe/lwe) and 4-SGPRrsrc(ignoringr128) plus matching SP3 formatting accurately reflects the RDNA2 ISA encoding.cargo test -p victory-shader --lib gfx10:: -- --test-threads=1: 17 passed, 0 failed (includingbvh_intersect_ray_uses_fixed_operands_and_omits_image_modifiers).cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@fuzeofficlal on GitHub · 2026-11-26 20:24 UTC · original · approved these changes
LGTM on decoding and SP3 formatting for
image_bvh_intersect_ray/image_bvh64_intersect_ray.Verified
crates/victory-shader/src/gfx10/fields.rs(Encoding::Mimg):image_bvh*forces 4-VGPRdata(ignoringdmask/d16/tfe/lwe) and 4-SGPRrsrc(ignoringr128), matching RDNA2 ISA operand widths and existingimage_addr_dwordscounts (11/8and12/9).crates/victory-shader/src/gfx10/sp3.rs: omits image-only modifiers while keeping cache flags anda16; both standard and NSA disassembly fixtures match.cargo run --locked -p xtask -- policy:191 files okcargo clippy --locked -p victory-shader --all-targets -- -D warnings(default &--all-features): cleanVICTORY_WARP=0(RTX 5090):gfx10::18 passed, 0 failed;emit::bvh_tests::14 passed, 0 failed;gfx10:: ir:: structure:: resource:: io::79 passed, 0 failed, 1 ignoredVICTORY_WARP=1:bvh_intersect_ray2 passed, 0 failed;emit::bvh_tests::14 passed, 0 failed (includingdxil.dllvalidation inbvh_intersect_ray_without_r128_or_dmask_bits_executes_on_gpu)Minor non-blocking nits
rustfmt --edition 2024reports formatting diffs in touched hunks atcrates/victory-shader/src/gfx10/fields.rs:381andcrates/victory-shader/src/gfx10/sp3.rs:975,995,1093,1158.crates/victory-shader/src/gfx10/sp3.rs:1020: the comment saysClobber s16..s19, though onlys16is written (0xDEAD_BEEF), andresource.rs:1349already rejects non-4-dword descriptors before readings16.emit/lower.rs:8390still rejects*tfe || *lwebefore reachingself.bvh(8394), which is harmless for valid shaders since AMD requires those bits to be zero.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.