fix(shader): apply the output modifier only in the float modes where the hardware does #1851
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1851"
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 boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T22:02:13Z.
What
Part of #981 (FLOAT_MODE family). The output modifier (
mul:2,mul:4,div:2) was always applied to f32 results and always ignored on f16/f64 results, whatever the shader's float mode. It now followsGuestContext::floatMode(#1816).Measured on RDNA2 (gfx1035) with the HW oracle, for every combination of IEEE on/off and each of the four denormal values (
FLOAT_MODEbits 5:4 for f32, 7:6 for f16/f64):v_mul_f32 mul:2/mul:4/div:2in each of those modes. The same rule holds forv_mul_f16andv_mul_f64.SIFoldOperands: "omod is ignored by hardware if IEEE bit is enabled. omod also does not correctly handle denormals".mainalready matches the hardware (0 mismatches over 1444 rows × 3 modifiers in IEEE=0 with f32 denormals flushed).Changes:
applyF32ResultModifiersapplies omod only in those modes. A shader with no known float mode keeps the current behaviour (IEEE=0, f32 denormals flushed, the mode titles use: 0xc0 in every Astro's Playroom shader but ten).IEEE_MODE/FLOAT_MODE.Tested
Linux (CachyOS, GCC), RADV (gfx1035) and CI's lavapipe (Mesa 25.2.8).
agc_driver_f32_output_modifier: the existing table (unchanged; it matches the hardware at IEEE=0 with f32 denormals flushed, 0 mismatches) now runs with no mode and with IEEE=0/0xc0. Two new tables captured on hardware cover IEEE=0 with f32 denormals kept (ExpectedKept) and IEEE=1 (ExpectedIeee, run with 0xc0 and 0xf0; they are equal on hardware for these rows). No row of the new tables has a denormal result, so they don't depend on the driver's denormal mode.agc_driver_float16_modifiers: the existing table matches the hardware at IEEE=1 and at IEEE=0/0xc0 (checked with the oracle). It now also runs with IEEE=1, and checks that a mode with f16 output denormals flushed is refused.mainafter #697).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-08T22:07:59Z.
One result type falls between the two rules here: the f32-typed results of the f64 instructions.
float64Operationnow rejects the modifier by the f16/f64 field and then still clears it (destination.omod = 0u), sov_cvt_f32_f64 mul:2keeps its result unmodified in the titles' mode, and would throw with f16/f64 denormals flushed. Measured on RDNA2 (gfx1036, Ryzen 7950X3D iGPU) with the hardware oracle, the hardware applies it by the f32 field:v_cvt_f32_f64 v10, v[4:5] mul:2of 1.0 gives0x40000000with IEEE 0 and f32 denormals flushed (the f16/f64 field kept or flushed), and0x3f800000with IEEE 1 or with f32 denormals kept; 2.5 gives0x40a00000and0x40200000the same way. F64Rounding's column 12 is that instruction over its 32 rows: the pinned0x3f800000-style values are the IEEE 1 results, and the hardware differs from the table in 28 of the 32 rows in the titles' mode (the audit on #981,pinned-vs-hardware.txt). So the f32 results offloat64OperationwantapplyF32ResultModifiersrather than the f16/f64 rejection, and F64Rounding's column 12 the titles'-mode values. Rows and results: https://gist.github.com/SleglJan/30456e5687240f0b639a78e5477f2f91 (verify-bodies.s,verify-rows.txt,audit.json).AI-assisted: yes (Claude Code).