d3d12_xs: eager blendclamp leaves R32G32B32A32_FLOAT targets alone #320

Closed
github-bot wants to merge 1 commit from gh-pr/320/head into gh-pr/320/base
Owner

@⁠enderrr9 on GitHub · 2026-11-23 18:19 UTC · original
enderrr9:d3d12xs-blendclamp-fp32 → main · +42 −4 · 3 files · 1 commits · closed without merging

Fixes the BLOCKERS.md entry "eager blendclamp also clamps R32G32B32A32_FLOAT (fmt 2) to +-65504 ... looks unintended".

Bug

blendclamp::small_float() listed DXGI format 2 (R32G32B32A32_FLOAT) next to the fp16 formats. So with TOMBOX_BLEND_CLAMP in eager mode, every blended fp32 target was clamped to ±65504, the fp16 range. ps mode (shader_xlat::export_kind) already leaves format 2 alone, and ps_clamp_kinds_only_change_the_small_float_formats pins that.

Fix

small_float now lists 10/34/54 (fp16) and 26 (R11G11B10), the same formats ps mode clamps. It's a one-line change.

Test

New: blendclamp_hw::warp_blendclamp_leaves_fp32_targets_above_the_fp16_range. It's a WARP test, #[ignore]d like the other blendclamp GPU tests: cargo test -p d3d12_xs --lib warp_blendclamp -- --ignored. It makes three additive draws (40000, 40000, 1) on an R32G32B32A32_FLOAT target:

run result
raw control 80001.0 everywhere
eager, before 65504.0 (0x477fe000), with clamp passes run
eager, after 80001.0, no clamp passes

bpp() and channels() in the test kit learn the 16-byte format.

The existing warp_blendclamp_lazy_matches_eager_for_an_additive_chain_that_overflows_to_inf and warp_ps_clamp_matches_eager_blendclamp_for_shader_inf_and_nan still pass.

cargo test -p d3d12_xs --lib: 666 passed, 2 failed. Both failures are unrelated to this change:

  • fixed_result_dxgix_exports_match_every_console_d3d12_xs needs a console d3d12_xs.dll under D:\xbox-pc-port\games;
  • one_megabyte_detiles_on_one_thread_in_a_few_ms is a timing test that took 26 ms on this laptop in a debug build.

pr_gate.py: 3 files, 0 problems.

🤖 Generated with Claude Code

**@⁠enderrr9** on GitHub · 2026-11-23 18:19 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/320) `enderrr9:d3d12xs-blendclamp-fp32` → `main` · +42 −4 · 3 files · 1 commits · closed without merging Fixes the BLOCKERS.md entry "eager blendclamp also clamps R32G32B32A32_FLOAT (fmt 2) to +-65504 ... looks unintended". ## Bug `blendclamp::small_float()` listed DXGI format 2 (`R32G32B32A32_FLOAT`) next to the fp16 formats. So with `TOMBOX_BLEND_CLAMP` in eager mode, every blended fp32 target was clamped to ±65504, the fp16 range. ps mode (`shader_xlat::export_kind`) already leaves format 2 alone, and `ps_clamp_kinds_only_change_the_small_float_formats` pins that. ## Fix `small_float` now lists 10/34/54 (fp16) and 26 (R11G11B10), the same formats ps mode clamps. It's a one-line change. ## Test New: `blendclamp_hw::warp_blendclamp_leaves_fp32_targets_above_the_fp16_range`. It's a WARP test, `#[ignore]`d like the other blendclamp GPU tests: `cargo test -p d3d12_xs --lib warp_blendclamp -- --ignored`. It makes three additive draws (40000, 40000, 1) on an `R32G32B32A32_FLOAT` target: | run | result | |---|---| | raw control | 80001.0 everywhere | | eager, before | **65504.0** (`0x477fe000`), with clamp passes run | | eager, after | 80001.0, no clamp passes | `bpp()` and `channels()` in the test kit learn the 16-byte format. The existing `warp_blendclamp_lazy_matches_eager_for_an_additive_chain_that_overflows_to_inf` and `warp_ps_clamp_matches_eager_blendclamp_for_shader_inf_and_nan` still pass. `cargo test -p d3d12_xs --lib`: 666 passed, 2 failed. Both failures are unrelated to this change: - `fixed_result_dxgix_exports_match_every_console_d3d12_xs` needs a console `d3d12_xs.dll` under `D:\xbox-pc-port\games`; - `one_megabyte_detiles_on_one_thread_in_a_few_ms` is a timing test that took 26 ms on this laptop in a debug build. `pr_gate.py`: 3 files, 0 problems. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
small_float() listed DXGI format 2 (R32G32B32A32_FLOAT) next to the fp16
formats, so the eager clamp passes clamped every blended fp32 target to
+-65504. That is the fp16 range, not the fp32 one. ps mode
(shader_xlat::export_kind) already leaves format 2 alone, and BLOCKERS.md
flagged the eager behaviour as looking unintended.

small_float now lists 10/34/54 (fp16) and 26 (R11G11B10), the same
formats ps mode clamps.

Test: blendclamp_hw::warp_blendclamp_leaves_fp32_targets_above_the_fp16_range
(WARP, ignored by default like the other blendclamp GPU tests). Three
additive draws of 40000, 40000 and 1 on an R32G32B32A32_FLOAT target:
- raw control: 80001.0 everywhere;
- eager before this change: 65504.0 (0x477fe000), with clamp passes run;
- eager after: 80001.0, and no clamp passes.
The existing warp_blendclamp_lazy_matches_eager... and
warp_ps_clamp_matches_eager... tests still pass.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:18:39 +00:00
github-bot closed this pull request 2026-11-26 06:18:39 +00:00
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-25 13:49 UTC · original

Applied on main in 92c998d (cherry-picked onto the current history with your authorship kept; comment lines stripped per CONTRIBUTING). Thank you.

**@⁠omonkeyz** on GitHub · 2026-11-25 13:49 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/320#issuecomment-7164346406) Applied on main in 92c998d (cherry-picked onto the current history with your authorship kept; comment lines stripped per CONTRIBUTING). Thank you.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.