Shaders: decode fixed 4-VGPR data and 4-SGPR rsrc for image_bvh_intersect_ray #3316
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from Marvisak/VIctory. Originally posted by mgunes1311-lab on 2026-11-26T17:18:50Z.
Coordination
Claimed in https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7197202703 (
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.
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T17:27:59Z.
Review: APPROVED
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).
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T20:24:25Z.
Review: APPROVED
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.Imported from Marvisak/VIctory. Originally posted by Jackster on 2026-11-26T22:36:58Z.
Windows 11,
63bcca4+ this PR, Radeon RX 7900 XTX:bvh_intersect_ray_uses_fixed_operands_and_omits_image_modifiersandbvh_intersect_ray_without_r128_or_dmask_bits_executes_on_gpu(filterbvh_intersect_ray): 2 passed (0.24 s).cargo clippy -p victory-shader --all-targets -- -D warnings: clean.The second one executes on the device, so the fixed 4-VGPR/4-SGPR decode is exercised by a real dispatch here. Synthetic only. AI-assisted.
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T06:06:26Z.
Independent WARP run of head
182bc1f, to go with the RX 7900 XTX run above.D3D12Core1.620.2,d3d10warp1.0.22), DXIL validation on,--features diagnostics,host.bvh_intersect_ray: 2 passed, 0 failed (1.18 s). Bothbvh_intersect_ray_uses_fixed_operands_and_omits_image_modifiersandbvh_intersect_ray_without_r128_or_dmask_bits_executes_on_gpurun; the second one dispatches on the device.cargo clippy -p victory-shader --all-targets --features host -- -D warnings: clean.Synthetic only and software WARP, so this adds the software side rather than hardware coverage; no game data.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.