tombox-xshader: f32 omod only acts with IEEE 0 and f32 output denormals flushed (measured on RDNA2); fres() applies it under MODE 0xf0 #386

Open
opened 2026-11-26 06:21:05 +00:00 by github-bot · 0 comments
Owner

@⁠SchmashinPrunes on GitHub · 2026-11-25 17:34 UTC · original

Library / area: tombox-xshader, f32 VOP3 output modifiers (fres in hlsl.rs) and the assumed initial MODE (mode::MODE_DEFAULT = 0xf0, PGM_RSRC1_AT empty).

@⁠omonkeyz, this needs a decision from you, so it's an issue rather than a PR.

Measurement

I ran the ISA sweep's f32 omod cases on RDNA2 silicon as raw kernels: a gfx1036 iGPU, Ryzen 5 9600X, ROCm/HIP. That's RDNA2, not gfx1013. The ops were v_add/sub/subrev/mul/mul_legacy/min/max_f32 with mul:2, mul:4 and div:2, about 580 finite cases each, under every FP_DENORM f32 setting and both IEEE values:

f32 FP_DENORM (MODE[5:4]) IEEE omod
3 (keep in, keep out) 0 ignored, 586/586
2 (flush in, keep out) 0 ignored
1 (keep in, flush out) 0 applied, 586/586
0 (flush both) 0 applied
3 1 ignored
0 1 ignored

All seven ops show the same pattern. f32 omod acts only when IEEE = 0 and f32 output denormals are flushed ((MODE & 0x220) == 0). It's the same rule #363 measured for f16, and the same condition LLVM uses before folding an omod (SIFoldOperands: IEEE off and FP32 denormals flushed).

Why this is a decision

  • fres() applies f32 omod unconditionally. Under the translator's assumed MODE 0xf0 (f32 denormals kept), the hardware would ignore it. Gating it like f16 (hres_mode, & 0x280) would be correct for that MODE.
  • But PGM_RSRC1_AT is empty, so every title shader runs with MODE_DEFAULT = 0xf0. Gating f32 omod correctly under that MODE switches off every f32 omod in every title.
  • A compiler only emits omod when it takes effect. So a console shader that uses f32 omod almost certainly runs with f32 output denormals flushed and IEEE 0. In other words, the assumed 0xf0 is probably wrong for those shaders, at least for f32.

Options I can see:

  1. Gate f32 omod on MODE like f16, and fix the default. For example, take f32 output flush as the default (MODE 0xc0 or similar) until PGM_RSRC1 is located. That changes how f32 denormals are treated in every title shader, so it needs your corpus runs.
  2. Gate on MODE only when MODE is known (PGM_RSRC1 located, or the shader writes MODE with s_setreg), and keep applying omod otherwise, with an unknowns note as the f16 path has.
  3. Infer it per shader: a shader whose code uses f32 omod is assumed to run with f32 output denormals flushed.

I can implement whichever you prefer. The silicon data and the sweep cases are ready for an exec test either way.

The other silicon mismatches (VOP3 op_sel on promoted ops, v_cube* denormals, v_sat_pk_u8_i16) are in PR #385.

🤖 Generated with Claude Code

**@⁠SchmashinPrunes** on GitHub · 2026-11-25 17:34 UTC · [original](https://github.com/omonkeyz/xbox-emulator/issues/386) **Library / area:** tombox-xshader, f32 VOP3 output modifiers (`fres` in `hlsl.rs`) and the assumed initial MODE (`mode::MODE_DEFAULT = 0xf0`, `PGM_RSRC1_AT` empty). @⁠omonkeyz, this needs a decision from you, so it's an issue rather than a PR. ### Measurement I ran the ISA sweep's f32 omod cases on RDNA2 silicon as raw kernels: a gfx1036 iGPU, Ryzen 5 9600X, ROCm/HIP. That's RDNA2, not gfx1013. The ops were `v_add/sub/subrev/mul/mul_legacy/min/max_f32` with `mul:2`, `mul:4` and `div:2`, about 580 finite cases each, under every FP_DENORM f32 setting and both IEEE values: | f32 FP_DENORM (MODE[5:4]) | IEEE | omod | |---|---|---| | 3 (keep in, keep out) | 0 | ignored, 586/586 | | 2 (flush in, keep out) | 0 | ignored | | 1 (keep in, flush out) | 0 | **applied**, 586/586 | | 0 (flush both) | 0 | **applied** | | 3 | 1 | ignored | | 0 | 1 | ignored | All seven ops show the same pattern. **f32 omod acts only when IEEE = 0 and f32 output denormals are flushed** (`(MODE & 0x220) == 0`). It's the same rule #363 measured for f16, and the same condition LLVM uses before folding an omod (`SIFoldOperands`: IEEE off and FP32 denormals flushed). ### Why this is a decision - `fres()` applies f32 omod unconditionally. Under the translator's assumed MODE `0xf0` (f32 denormals kept), the hardware would ignore it. Gating it like f16 (`hres_mode`, `& 0x280`) would be correct for that MODE. - But `PGM_RSRC1_AT` is empty, so every title shader runs with `MODE_DEFAULT = 0xf0`. Gating f32 omod correctly under that MODE switches off every f32 omod in every title. - A compiler only emits omod when it takes effect. So a console shader that uses f32 omod almost certainly runs with f32 output denormals flushed and IEEE 0. In other words, the assumed `0xf0` is probably wrong for those shaders, at least for f32. Options I can see: 1. **Gate f32 omod on MODE like f16, and fix the default.** For example, take f32 output flush as the default (MODE `0xc0` or similar) until PGM_RSRC1 is located. That changes how f32 denormals are treated in every title shader, so it needs your corpus runs. 2. **Gate on MODE only when MODE is known** (PGM_RSRC1 located, or the shader writes MODE with `s_setreg`), and keep applying omod otherwise, with an `unknowns` note as the f16 path has. 3. **Infer it per shader:** a shader whose code uses f32 omod is assumed to run with f32 output denormals flushed. I can implement whichever you prefer. The silicon data and the sweep cases are ready for an exec test either way. The other silicon mismatches (VOP3 op_sel on promoted ops, `v_cube*` denormals, `v_sat_pk_u8_i16`) are in PR #385. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:21:05 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.