Repository navigation
Shaders: decode 16-bit integer inline float constants as f32 bits - #1295
WALID1618Y wants to merge 1 commit into
Conversation
|
Independent verification of \6cf80f2\ on Windows 11 / AMD Radeon RX 9060 XT (RDNA4, \gfx1200) / Rust 1.98.1 MSVC:
Code audit looks solid: splitting \half_src(inst, k, float)\ matches \packed_src\ so 16-bit integer ops read raw f32 bits of inline float constants \240..=248\ while 16-bit float ops preserve f16 bits (including \�_cvt_f16_u16/\�_cvt_f16_i16\ and \�_cmp_*_u16/i16). AI-assisted; synthetic tests only, no game files. |
|
Reviewed at head 1. The claim is right and the change is complete at every call site. On RDNA2, a non-packed 16-bit integer VOP3 op reads the selected half of the inline constant's f32 bit pattern, while 16-bit float ops (and packed VOP3P ops via 2. Red/green proven here. The PR's 3. Hardware evidence on this machine. 4. Checks: 5. Behavior note, not a defect: this changes what previously-translating shaders compute when a 16-bit integer op consumes an inline float constant — before, they silently used the f16 bits. That is precisely the bug being fixed (the f16 and f32 halves disagree, e.g. 0x3118 vs 0xF983), and the packed-op path is untouched, so VOP3P shaders are unaffected. Nothing found that would block this. |
…tants as f32 bits
…tants as f32 bits
|
Automated triage for the maintainers. Needs rebase. This pull request conflicts with Generated by Claude Code |
In
crates/victory-shader/src/emit/lower.rs,half_srcunconditionally decoded GFX10 inline float constants (240..=248) viaf16_operandfor all non-packed 16-bit instructions. On RDNA2 (GFX10), inline float constants use FP16 bit patterns only for 16-bit floating-point operands; 16-bit integer instructions (u16/i16/b16, includingv_add_nc_u16,v_cvt_f16_u16/i16, andv_cmp_*_u16/i16) interpret those encodings as 32-bit FP32 bit patterns and select the low or high 16-bit half viaop_sel(the non-packed counterpart to #637 forpacked_src, per LLVM's GFX10 encoding table).Change
float: boolparameter toLower::half_src, mirroringLower::packed_srcfrom Shaders: decode GFX10 packed inline constants by operand type #637:float = true(f16_operand) for FP16 sources:half_fsrc,cvt_norm16, andv_cmp_class_f16.float = false(operand) for 16-bit integer sources:v_cvt_f16_u16/v_cvt_f16_i16, 16-bit integer VALU ops (v_add_nc_u16,v_sub_nc_u16,v_mul_lo_u16, shifts, min/max), andv_cmp_*_u16/v_cmp_*_i16.half_int_ops_decode_inline_float_constants_as_f32_bitsincrates/victory-shader/src/emit/valu_tests.rs.op_selmain(ffe310e)v_add_nc_u16(+ 0)248(1/(2π)),op_sel:[0,0]0x000031180x0000f983v_add_nc_u16(+ 0)248(1/(2π)),op_sel:[1,0]0x000000000x00003e22v_add_nc_u16(+ 5)242(1.0),op_sel:[0,0]0x00003c050x00000005v_add_nc_u16(+ 5)242(1.0),op_sel:[1,0]0x000000050x00003f85v_cvt_f16_u16242(1.0),op_sel:[0]0x000073800x00000000v_cmp_eq_u16(== 0xf983/== 0x3118)248(1/(2π))0/11/0v_add_f16(control,+ 0)248(1/(2π)),op_sel:[0,0]0x000031180x00003118Verification
1.98.1,dxil.dllvalidation enabled (VICTORY_DXIL), NVIDIA GeForce RTX 3050 (driver32.0.16.2124) + Microsoft WARP (10.0.26100.9818). Synthetic tests only; I did not run the game.main(ffe310e), the new test fails on hardware withv_add_nc_u16 low half of inline 248: got 0x00003118, want 0x0000f983.cargo test -p victory-shader --locked(withdxil.dll): 121 passed, 0 failed, 1 ignored (4 differential tests skip without the console compiler)cargo clippy --workspace --all-targets --locked -- -D warnings: cleancargo clippy --workspace --all-targets --all-features --locked -- -D warnings: cleancargo xtask policy:154 files okNote: open PR #926 also edits
half_src(to ignoreop_selon 16-bit compares); if merged first, rebasing is a one-line signature merge.AI-assisted; all builds, DXIL validations, and GPU dispatches were executed locally.