Repository navigation
Shaders: lower v_bfe_u32/v_bfe_i32 to one Ubfe/Ibfe - #2954
Ingenioeren wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent test report for Setup: Windows 11 Pro 10.0.26200, Rust 1.98.1. Validator is Instruction count:
These match the PR table. With the assert left in, the parent fails on Bit extraction boundaries:
Full suite:
The same 4
They are hardware-labelled checks ("no pipeline for a wave of 32", and gather texel expectations). Lint and policy:
Overlap and limits:
This is an independent test only, not a review. Prepared with Claude Code (Claude Opus 5.5). |
Dukestar69
left a comment
There was a problem hiding this comment.
Tested merged onto origin/main (63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP, dxil.dll validator active):
cargo test -p victory-shader --lib emit::valu_tests::bfe_signed_and_unsigned_match_rdna2: 1 passed, 0 failed (RTX 5090 hardware + WARP, including the new edge cases for 5-bit offset/width masking and bit-31 boundary).cargo test -p victory-shader --lib emit::lower::tests::vector_bitfield_extract_instruction_count: 1 passed, 0 failed (19 DXIL instructions for bothv_bfe_u32andv_bfe_i32).cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.
Lowering v_bfe_u32 / v_bfe_i32 directly to DXIL tertiary.i32 Ubfe (52) / Ibfe (51) matches RDNA2's 5-bit offset/width semantics and shrinks the generated DXIL cleanly.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
fuzeofficlal
left a comment
There was a problem hiding this comment.
Reviewed and verified against main (63bcca43) on Windows 11 (RTX 5090 + WARP + dxil.dll, VICTORY_D3D12_DEBUG=1) — clean and ready to merge:
- Lowering
v_bfe_u32/v_bfe_i32(crates/victory-shader/src/emit/lower.rs:7531-7537) to a singledx.op.tertiary.i32(Ubfe52/Ibfe51, args&[w, off, a]) matches RDNA2 5-bitoff[4:0]/w[4:0]masking semantics (includingwidth == 0/32->0,offset >= 32, andoffset + width > 32sign extension from bit 31), while properly keepingself.bfe(...)for 7-bit-width scalars_bfe_{u32,i32}(lower.rs:3944). - Note on 512 KiB file-size cap: on
63bcca43,emit/lower.rsgrows to 521,372 B (+809 B, 2,916 B under524,288 B).
Local verification:
bfe_signed_and_unsigned_match_rdna2+vector_bitfield_extract_instruction_count+emit::lower::tests: 34/34 passed on both RTX 5090 and WARP (dxil.dll+DEBUG=1)emit::semantics_tests::integers_match_the_hardware: 1/1 passedcargo clippy --all-targets -- -D warnings+cargo xtask policy(192 files ok): 0 warnings
… UAV writeback - Marvisak#2952: a stream with neither a depth-stencil subobject nor a depth format defaults to disabled depth testing (apply_stream_defaults) - Marvisak#2931: feature-level query rejects count == 0 and writes 0 on UNSUPPORTED - Marvisak#2961: reject shader-visible RTV and DSV heap creation - Marvisak#2865: guard placed heaps against null and layouts against empty planes - Marvisak#2954: lower v_bfe_u32/v_bfe_i32 to one Ubfe/Ibfe - Marvisak#2948: a root UAV a shader only reads is not written back (written_root_uavs through Shader/Lowered/HostShader + cache VSH2) Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
kotekompotek
left a comment
There was a problem hiding this comment.
Verified: DXIL Ibfe(51)/Ubfe(52) already apply the 5-bit width/offset masks, so the old m31 pre-mask plus composite expansion was redundant. Opcode mapping is right (signed→51, unsigned→52) and the rewritten hardware test now discriminates arg order — e.g. (0xffffffff, off 0, width 31) expects 0x7fffffff, which a swapped (width,value) order could not produce — plus the exact instruction-count anchor (19) pins the single-op lowering.
|
Automated triage for the maintainers. Merge candidate. In One note: CI: passing ( Recommending a look, not approving. Generated by Claude Code |
|
AMD hardware run of eb73a3a. RX 6750 XT (RDNA2), driver 32.0.21045.29003, Windows 11, Rust 1.98.1, on main 63bcca4.
The whole Unit tests only, no game files. |
What
Lower
v_bfe_i32andv_bfe_u32to one DXILIbfeorUbfecall per vector instruction. Add an instruction-count regression test and extend the existing synthetic GPU test.Why
The DXIL operations use the low five bits of both width and offset and produce zero for width zero. When a field reaches or crosses bit 31, DXIL shifts the source right arithmetically for
Ibfeand logically forUbfe, which gives the same sign or zero extension as the previous lowering. The operands and results are 32-bit integers. DXIL specificationEach synthetic shader takes three runtime inputs and stores one result to a UAV. The count includes emitted setup, live instructions, and terminators. The counter is the same test-only helper as in #2893, so whichever PR lands second can drop its copy.
origin/main(63bcca4)v_bfe_i32v_bfe_u32How tested
cargo test --locked --offline -p victory-shader vector_bitfield_extract_instruction_count -- --nocapturemeasured the counts above. On main, I applied the test-only changes and recorded the baseline before adding the 19-instruction budget.cargo test --locked --offline -p victory-shader bfe_signed_and_unsigned_match_rdna2 -- --nocapturepassed on the hardware GPU and WARP on both revisions with identical expected output bits. Cases include masked offset and width, zero width, and fields ending at or crossing bit 31.cargo test --locked --offline -p victory-shaderadded one passing test on the branch, from 300 to 301. Both runs had the same two localdxil.dllvalidation failures and three ignored tests.cargo test --locked --offline -p victory-shader --test resource_trackingpassed three tests with one ignored on both revisions.cargo clippy -p victory-shader --locked --offline --all-targetspassed.cargo run -p xtask -- policy --stagedpassed for all three staged files.All shader inputs were synthesized in test code. No game files, game launch, hardware game run, or game performance benchmark.
AI assistance: prepared with OpenAI Codex under Claude Code's direction, reviewed by Ingenioeren.