fix(agc): match the measured CB conversion of 11_11_10 float color targets #23206

Merged
Colewiz7 merged 1 commit from upstream-pr/23206 into main 2026-11-29 10:13:18 +00:00
Colewiz7 commented 2026-11-18 20:16:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Colewiz7 on 2026-11-18T20:16:12Z.


What

Two changes to 11_11_10 float color targets, both from one measurement of the CB on RDNA2:

  • A target with CB_COLOR_INFO.ROUND_MODE clear decodes like one with it set. The refusal rounding (ROUND_MODE 0) 11_11_10 float color targets are unsupported (a518a90ad6) assumed the bit makes the CB round. It doesn't.
  • The packed export writes 0x3f0 (10-bit field) or 0x7e0 (11-bit field) for every NaN. PackExport used to keep the top payload bits, as F32BitsToSmallFloatRtz does for image stores, which this PR leaves unchanged.

Measured on a 7800X3D iGPU (gfx1036) with a local Mesa 26.0.6 RADV patched to force COLOR_11_11_10, RB+ off (gfx1013 has none) and 32_ABGR exports:

export ROUND_MODE 0 ROUND_MODE 1
65,536 random floats per channel, 2^-20 to 2^16 truncated, all truncated, all
65024 to 1e10 0x3df / 0x7bf same
+inf 0x3e0 / 0x7c0 same
-inf, -1, -0, 1e-30 0 same
NaN 0x7f800001, 0x7fa00000, 0x7fe00000, 0x7fffffff, 0xff800001 and 4 more 0x3f0 / 0x7e0 same

The same NaNs drawn into an R32_SFLOAT target come back unchanged, so the CB is what rewrites them. SIMPLE_FLOAT and BLEND_BYPASS change nothing. On a 4_4_4_4 UNORM target in the same setup ROUND_MODE 0 rounds and 1 truncates, so the bit itself works. The resolve of this format, measured with the same probe, is in #11362.

Tested

Linux 7.3.4, GCC 16.2.1 Release, Mesa 26.2.6 RADV, main 533edafcac.

  • agc_driver_packed_float_color_target gains two NaN payload cases and a ROUND_MODE 0 pass. agc_graphics_profile_draw now decodes the ROUND_MODE 0 target instead of expecting the refusal.
  • With main's sources both fail on both GPUs: a 32_ABGR export of (nan, nan, nan) into a tiled 11_11_10 float target: pixel (0, 0) inside the scissor holds 0xfa1f07ff, expected 0xfc1f83f0, and rounding (ROUND_MODE 0) 11_11_10 float color targets are unsupported.
  • Those two and agc_driver_packed_float_blend, run with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer and ctest -V: 3/3 on both GPUs, layer 1.4.363.1 inserted, 0 VUID- lines on this PR and on main f15df3256c.
  • ctest -R '^agc' (1936 tests): the failures match main's exactly on each GPU.

Not tested: gfx1013, Windows, NVIDIA, and NaN through a blend or partial write, which goes through the same PackExport.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: AMD Radeon RX 7900 XT (RADV NAVI31) and AMD Ryzen 7 7800X3D iGPU (RADV RAPHAEL_MENDOCINO), Mesa 26.2.6, Linux 7.3.4
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5383372085 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23206). Originally posted by [Colewiz7](https://github.com/Colewiz7) on 2026-11-18T20:16:12Z. --- ### What Two changes to 11_11_10 float color targets, both from one measurement of the CB on RDNA2: - A target with `CB_COLOR_INFO.ROUND_MODE` clear decodes like one with it set. The refusal `rounding (ROUND_MODE 0) 11_11_10 float color targets are unsupported` (a518a90ad6) assumed the bit makes the CB round. It doesn't. - The packed export writes `0x3f0` (10-bit field) or `0x7e0` (11-bit field) for every NaN. `PackExport` used to keep the top payload bits, as `F32BitsToSmallFloatRtz` does for image stores, which this PR leaves unchanged. Measured on a 7800X3D iGPU (gfx1036) with a local Mesa 26.0.6 RADV patched to force `COLOR_11_11_10`, RB+ off (gfx1013 has none) and 32_ABGR exports: | export | `ROUND_MODE` 0 | `ROUND_MODE` 1 | |---|---|---| | 65,536 random floats per channel, 2^-20 to 2^16 | truncated, all | truncated, all | | 65024 to 1e10 | `0x3df` / `0x7bf` | same | | +inf | `0x3e0` / `0x7c0` | same | | -inf, -1, -0, 1e-30 | 0 | same | | NaN `0x7f800001`, `0x7fa00000`, `0x7fe00000`, `0x7fffffff`, `0xff800001` and 4 more | `0x3f0` / `0x7e0` | same | The same NaNs drawn into an `R32_SFLOAT` target come back unchanged, so the CB is what rewrites them. `SIMPLE_FLOAT` and `BLEND_BYPASS` change nothing. On a 4_4_4_4 UNORM target in the same setup `ROUND_MODE` 0 rounds and 1 truncates, so the bit itself works. The resolve of this format, measured with the same probe, is in #11362. ### Tested Linux 7.3.4, GCC 16.2.1 Release, Mesa 26.2.6 RADV, `main` `533edafcac`. - `agc_driver_packed_float_color_target` gains two NaN payload cases and a `ROUND_MODE` 0 pass. `agc_graphics_profile_draw` now decodes the `ROUND_MODE` 0 target instead of expecting the refusal. - With `main`'s sources both fail on both GPUs: `a 32_ABGR export of (nan, nan, nan) into a tiled 11_11_10 float target: pixel (0, 0) inside the scissor holds 0xfa1f07ff, expected 0xfc1f83f0`, and `rounding (ROUND_MODE 0) 11_11_10 float color targets are unsupported`. - Those two and `agc_driver_packed_float_blend`, run with `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer` and `ctest -V`: 3/3 on both GPUs, layer 1.4.363.1 inserted, 0 `VUID-` lines on this PR and on `main` `f15df3256c`. - `ctest -R '^agc'` (1936 tests): the failures match `main`'s exactly on each GPU. Not tested: gfx1013, Windows, NVIDIA, and NaN through a blend or partial write, which goes through the same `PackExport`. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: AMD Radeon RX 7900 XT (RADV NAVI31) and AMD Ryzen 7 7800X3D iGPU (RADV RAPHAEL_MENDOCINO), Mesa 26.2.6, Linux 7.3.4 - [x] AI-assisted: yes
MarcZX10 commented 2026-11-18 21:02:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-18T21:02:37Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the implementation and added test cases are consistent with the stated measured behavior.

What I ran

Reviewed head 5bdd418f61a2f809ddb5272ccc5aa099ccbc41fc against the prepared diff. I did not run programmatic checks. The author reports running GPU tests and the agc suite; those results were not independently verified.

Results

Check Result Note
Diff and changed code passed Reviewed all changed lines
Tests not run Author-reported results only

Findings

Blocking

None.

Non-blocking

None.

Not verified

I read core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp, core/libs/prx/libSceAgcDriver/tests/Graphics.cpp, core/libs/prx/libSceAgcDriver/tests/execution/PackedFloatColorTarget.cpp, core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp, and docs/dev/debt/changes/agc-11-11-10-float-cb-conversion.md. The included changed lines and targeted context were inspected. files.json was not available from the reader; the manifest/listing identify core/libs/prx/libSceAgcDriver/tests/Graphics.cpp as excluded from the review folder, so I read its changed hunk through the pinned reader. GPU behavior, other vendors and platforms, and the reported test runs were not independently verified. No negative control was run.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5965107600 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23206#pullrequestreview-5965107600). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-18T21:02:37Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the implementation and added test cases are consistent with the stated measured behavior. ## What I ran Reviewed head `5bdd418f61a2f809ddb5272ccc5aa099ccbc41fc` against the prepared diff. I did not run programmatic checks. The author reports running GPU tests and the `agc` suite; those results were not independently verified. ## Results | Check | Result | Note | |---|---|---| | Diff and changed code | passed | Reviewed all changed lines | | Tests | not run | Author-reported results only | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified I read `core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp`, `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`, `core/libs/prx/libSceAgcDriver/tests/execution/PackedFloatColorTarget.cpp`, `core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp`, and `docs/dev/debt/changes/agc-11-11-10-float-cb-conversion.md`. The included changed lines and targeted context were inspected. `files.json` was not available from the reader; the manifest/listing identify `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` as excluded from the review folder, so I read its changed hunk through the pinned reader. GPU behavior, other vendors and platforms, and the reported test runs were not independently verified. No negative control was run. ## To get this to a good state Nothing is required.
MarcZX10 commented 2026-11-20 04:39:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T04:39:09Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the author’s measurements and the inspected implementation support the stated behavior.

What I ran

Reviewed head 8b49658de9df5881f6e599ddd3ef55258e99fdbd using repo_read.py. No commands or tests were run.

Results

Check Result Note
Change review passed Inspected all changed files
Tests not run Results in the PR description are author reported

Findings

Blocking

None.

Non-blocking

None.

Not verified

Did not run tests or independently verify the reported GPU measurements. The PR reports testing on two AMD GPUs; gfx1013, Windows, NVIDIA, and NaN through blending or partial writes were not tested by the author. Read: State.cpp, Graphics.cpp (changed lines), PackedFloatColorTarget.cpp, SpirvModuleEmitter.cpp, and agc-11-11-10-float-cb-conversion.md. No changed files were excluded from review; Graphics.cpp was read at its changed lines only. files.json was not available as a review-folder document.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5987572500 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23206#pullrequestreview-5987572500). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T04:39:09Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the author’s measurements and the inspected implementation support the stated behavior. ## What I ran Reviewed head `8b49658de9df5881f6e599ddd3ef55258e99fdbd` using `repo_read.py`. No commands or tests were run. ## Results | Check | Result | Note | |---|---|---| | Change review | passed | Inspected all changed files | | Tests | not run | Results in the PR description are author reported | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified Did not run tests or independently verify the reported GPU measurements. The PR reports testing on two AMD GPUs; gfx1013, Windows, NVIDIA, and NaN through blending or partial writes were not tested by the author. Read: `State.cpp`, `Graphics.cpp` (changed lines), `PackedFloatColorTarget.cpp`, `SpirvModuleEmitter.cpp`, and `agc-11-11-10-float-cb-conversion.md`. No changed files were excluded from review; `Graphics.cpp` was read at its changed lines only. `files.json` was not available as a review-folder document. ## To get this to a good state Nothing is required.
malekaifa commented 2026-11-24 19:30:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by malekaifa on 2026-11-24T19:30:37Z.

Review: APPROVED


Reviewed exact head 8b49658de9df5881f6e599ddd3ef55258e99fdbd.

The production delta is narrowly scoped and matches the measured CB behavior. Removing the ROUND_MODE 0 refusal is backed by the same truncating conversion on both bit values, while the shader-side NaN canonicalization is restricted to Format10_11_11Float color exports: the unsigned-NaN test uses abs(bits) > 0x7f800000, so positive and negative NaNs both select the canonical field, and (0x1f << mantissaBits) | (1 << (mantissaBits - 1)) produces the measured 0x3f0 10-bit and 0x7e0 11-bit encodings. Image-store conversion remains unchanged.

The regression covers multiple NaN payload/sign patterns and the formerly rejected ROUND_MODE 0 path. Independent AMD evidence exists on Linux/RADV and Windows/LLPC, including an old-production negative control for the NaN result; the focused packed-float tests pass on the exact head, and all hosted exact-head checks are terminal/successful (with the unrelated matrix jobs intentionally skipped). MarcZX10 also approved this exact head.

No blocking finding from me.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6045958528 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23206#pullrequestreview-6045958528). Originally posted by [malekaifa](https://github.com/malekaifa) on 2026-11-24T19:30:37Z. **Review:** APPROVED --- Reviewed exact head `8b49658de9df5881f6e599ddd3ef55258e99fdbd`. The production delta is narrowly scoped and matches the measured CB behavior. Removing the `ROUND_MODE 0` refusal is backed by the same truncating conversion on both bit values, while the shader-side NaN canonicalization is restricted to `Format10_11_11Float` color exports: the unsigned-NaN test uses `abs(bits) > 0x7f800000`, so positive and negative NaNs both select the canonical field, and `(0x1f << mantissaBits) | (1 << (mantissaBits - 1))` produces the measured `0x3f0` 10-bit and `0x7e0` 11-bit encodings. Image-store conversion remains unchanged. The regression covers multiple NaN payload/sign patterns and the formerly rejected ROUND_MODE 0 path. Independent AMD evidence exists on Linux/RADV and Windows/LLPC, including an old-production negative control for the NaN result; the focused packed-float tests pass on the exact head, and all hosted exact-head checks are terminal/successful (with the unrelated matrix jobs intentionally skipped). MarcZX10 also approved this exact head. No blocking finding from me. AI-assisted: yes
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!23206
No description provided.