feat(agc): truncate exports into 10_11_11 unorm targets with ROUND_MODE set #23281

Open
Colewiz7 wants to merge 2 commits from upstream-pr/23281 into main
Colewiz7 commented 2026-11-18 21:43:37 +00:00 (Migrated from github.com)

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


What

A 10_11_11 UNORM color target with CB_COLOR_INFO.ROUND_MODE set is drawn with truncated exports instead of refused (truncating (ROUND_MODE) 10_11_11 unorm color targets are unsupported). It is the same change #23258 makes for 4_4_4_4: State.cpp gives the target the packing Unorm10_11_11Truncated, and its exports pack each field as floor(clamp(v, 0, 1) * max) (2047 for the 11-bit fields, 1023 for the 10-bit one), NaN to 0.

Measured on a 7800X3D iGPU (gfx1036) with a local Mesa 26.0.6 RADV patched to give COLOR_10_11_11 the UNORM number type, RB+ off and 32_ABGR exports:

export ROUND_MODE 0 ROUND_MODE 1
196,578 fields, half of them within 0.001 of a step's midpoint nearest, all truncated, all
0x3f7fffff (0.99999994) 0x7ff / 0x3ff 0x7fe / 0x3fe
NaN (any payload), -inf, -1, -0 0 0
+inf, 1, 2 0x7ff / 0x3ff 0x7ff / 0x3ff

Tested

Linux 7.3.4, GCC 16.2.1 Release, Mesa 26.2.6 RADV, main 67d3465feb. The branch carries #23206's and #23258's commits first.

  • agc_driver_packed_unorm_color_target runs its cases again on a tiled target with ROUND_MODE set, against a truncating reference. agc_graphics_profile_draw decodes the target as Unorm10_11_11Truncated instead of expecting the refusal.
  • With the truncation step removed, the new pass fails on both GPUs: a 32_ABGR export of (0, 1, 0.5) into a tiled ROUND_MODE 1 10_11_11 unorm target: pixel (0, 0) inside the scissor holds 0x803ff800, expected 0x7ffff800.
  • agc_driver_packed_unorm_color_target, agc_driver_packed_unorm4444_color_target, agc_driver_packed_float_color_target and agc_graphics_profile_draw, 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: 4/4 on both GPUs, layer 1.4.363.1 inserted, 0 VUID- lines.
  • ctest -R '^agc' (1936 tests): the failures match main's on each GPU.

Not tested: gfx1013, Windows, NVIDIA. PS4 (GCN) targets don't read ROUND_MODE, which the debt entry records.

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: #23258
  • 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:5384599871 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23281). Originally posted by [Colewiz7](https://github.com/Colewiz7) on 2026-11-18T21:43:37Z. --- ### What A 10_11_11 UNORM color target with `CB_COLOR_INFO.ROUND_MODE` set is drawn with truncated exports instead of refused (`truncating (ROUND_MODE) 10_11_11 unorm color targets are unsupported`). It is the same change #23258 makes for 4_4_4_4: `State.cpp` gives the target the packing `Unorm10_11_11Truncated`, and its exports pack each field as `floor(clamp(v, 0, 1) * max)` (2047 for the 11-bit fields, 1023 for the 10-bit one), NaN to 0. Measured on a 7800X3D iGPU (gfx1036) with a local Mesa 26.0.6 RADV patched to give `COLOR_10_11_11` the UNORM number type, RB+ off and 32_ABGR exports: | export | `ROUND_MODE` 0 | `ROUND_MODE` 1 | |---|---|---| | 196,578 fields, half of them within 0.001 of a step's midpoint | nearest, all | truncated, all | | `0x3f7fffff` (0.99999994) | `0x7ff` / `0x3ff` | `0x7fe` / `0x3fe` | | NaN (any payload), -inf, -1, -0 | 0 | 0 | | +inf, 1, 2 | `0x7ff` / `0x3ff` | `0x7ff` / `0x3ff` | ### Tested Linux 7.3.4, GCC 16.2.1 Release, Mesa 26.2.6 RADV, `main` `67d3465feb`. The branch carries #23206's and #23258's commits first. - `agc_driver_packed_unorm_color_target` runs its cases again on a tiled target with `ROUND_MODE` set, against a truncating reference. `agc_graphics_profile_draw` decodes the target as `Unorm10_11_11Truncated` instead of expecting the refusal. - With the truncation step removed, the new pass fails on both GPUs: `a 32_ABGR export of (0, 1, 0.5) into a tiled ROUND_MODE 1 10_11_11 unorm target: pixel (0, 0) inside the scissor holds 0x803ff800, expected 0x7ffff800`. - `agc_driver_packed_unorm_color_target`, `agc_driver_packed_unorm4444_color_target`, `agc_driver_packed_float_color_target` and `agc_graphics_profile_draw`, 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`: 4/4 on both GPUs, layer 1.4.363.1 inserted, 0 `VUID-` lines. - `ctest -R '^agc'` (1936 tests): the failures match `main`'s on each GPU. Not tested: gfx1013, Windows, NVIDIA. PS4 (GCN) targets don't read `ROUND_MODE`, which the debt entry records. ### 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: #23258 - [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-19 05:39:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T05:39:58Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing blocks this change; one review completeness limitation prevents a formal approval.

What I ran

Reviewed head aef630fb95d70420390000b93e5074884f939a88 through repo_read.py. No commands or tests were run; the reported GPU test results come from the PR description.

Results

Check Result Note
Code review passed Read the changed implementation and targeted call paths.
Tests not run GPU and CI results are author-reported.
File coverage not run One changed file is excluded from the prepared full-text bundle.

Findings

Blocking

None.

Non-blocking

None.

Not verified

core/libs/prx/libSceAgcDriver/tests/Graphics.cpp is marked too large for the review folder. I inspected its relevant changed test ranges through the pinned reader, but did not read the complete file. Other changed files listed as included in manifest.json were read. Hardware behavior and reported test runs were not independently verified.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5969870150 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23281#pullrequestreview-5969870150). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-19T05:39:58Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing blocks this change; one review completeness limitation prevents a formal approval. ## What I ran Reviewed head `aef630fb95d70420390000b93e5074884f939a88` through `repo_read.py`. No commands or tests were run; the reported GPU test results come from the PR description. ## Results | Check | Result | Note | |---|---|---| | Code review | passed | Read the changed implementation and targeted call paths. | | Tests | not run | GPU and CI results are author-reported. | | File coverage | not run | One changed file is excluded from the prepared full-text bundle. | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` is marked too large for the review folder. I inspected its relevant changed test ranges through the pinned reader, but did not read the complete file. Other changed files listed as included in `manifest.json` were read. Hardware behavior and reported test runs were not independently verified. ## To get this to a good state Nothing is required.
Jazeupoi commented 2026-11-19 10:54:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Jazeupoi on 2026-11-19T10:54:12Z.

Review: COMMENTED


Ran it on NVIDIA and Windows, which the description lists as not tested. #23258's 4_4_4_4 part already has NVIDIA runs on its own thread, so the new part here is the 10_11_11 one (agc_driver_packed_unorm_color_target).

Setup: Windows 11 Pro (build 26300), NVIDIA GeForce RTX 2060 (driver 621.24), WinLibs GCC 15.2.0 r7, Release. Base main cac6e5714d with #22373 (it only adds setenv for the AGC tests on Windows); "this PR" is the same tree with head aef630fb95 merged (clean; it carries #23258's commits). ctest -R "packed_(unorm|unorm4444|float)_color_target|packed_unorm4444_(multisample_)?partial_write|graphics_profile_draw" -V -j1, 3 runs each, with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, VK_LOADER_DEBUG=layer, ANYPS5_NO_SHADER_CACHE=1 and ANYPS5_REQUIRE_VULKAN=1:

result layer inserted not found lines VUID-
base 6/6, 3/3 runs 5 of 5 Vulkan tests 0 0
this PR 6/6, 3/3 runs 5 of 5 Vulkan tests 0 0

(agc_graphics_profile_draw creates no Vulkan device.)

The base runs its own versions of the tests, so as a control I built this PR's five execution tests against main's versions of the seven non-test files the PR changes. I kept Recompiler.hpp from the PR, because the tests name the new ColorExportPacking values. Four of five fail:

  • agc_driver_packed_unorm_color_target: AGC graphics: truncating (ROUND_MODE) 10_11_11 unorm color targets are unsupported
  • agc_driver_packed_unorm4444_color_target and agc_driver_packed_unorm4444_partial_write: the same for 4_4_4_4
  • agc_driver_packed_float_color_target: 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

agc_driver_packed_unorm4444_multisample_partial_write passes either way. The 10_11_11 control fails when the target is decoded, before anything is drawn. So on this GPU it shows that the test reaches the new path, not that it would catch a wrong truncated value.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5973639452 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23281#pullrequestreview-5973639452). Originally posted by [Jazeupoi](https://github.com/Jazeupoi) on 2026-11-19T10:54:12Z. **Review:** COMMENTED --- Ran it on NVIDIA and Windows, which the description lists as not tested. #23258's 4_4_4_4 part already has NVIDIA runs on its own thread, so the new part here is the 10_11_11 one (`agc_driver_packed_unorm_color_target`). **Setup:** Windows 11 Pro (build 26300), NVIDIA GeForce RTX 2060 (driver 621.24), WinLibs GCC 15.2.0 r7, Release. Base `main` `cac6e5714d` with #22373 (it only adds `setenv` for the AGC tests on Windows); "this PR" is the same tree with head `aef630fb95` merged (clean; it carries #23258's commits). `ctest -R "packed_(unorm|unorm4444|float)_color_target|packed_unorm4444_(multisample_)?partial_write|graphics_profile_draw" -V -j1`, 3 runs each, with `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `VK_LOADER_DEBUG=layer`, `ANYPS5_NO_SHADER_CACHE=1` and `ANYPS5_REQUIRE_VULKAN=1`: | | result | layer inserted | `not found` lines | `VUID-` | |---|---|---|---|---| | base | 6/6, 3/3 runs | 5 of 5 Vulkan tests | 0 | 0 | | this PR | 6/6, 3/3 runs | 5 of 5 Vulkan tests | 0 | 0 | (`agc_graphics_profile_draw` creates no Vulkan device.) The base runs its own versions of the tests, so as a control I built this PR's five execution tests against `main`'s versions of the seven non-test files the PR changes. I kept `Recompiler.hpp` from the PR, because the tests name the new `ColorExportPacking` values. Four of five fail: - `agc_driver_packed_unorm_color_target`: `AGC graphics: truncating (ROUND_MODE) 10_11_11 unorm color targets are unsupported` - `agc_driver_packed_unorm4444_color_target` and `agc_driver_packed_unorm4444_partial_write`: the same for 4_4_4_4 - `agc_driver_packed_float_color_target`: `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` `agc_driver_packed_unorm4444_multisample_partial_write` passes either way. The 10_11_11 control fails when the target is decoded, before anything is drawn. So on this GPU it shows that the test reaches the new path, not that it would catch a wrong truncated value. AI-assisted: yes (Claude Code)
MarcZX10 commented 2026-11-20 02:50:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T02:50:43Z.

Review: COMMENTED


Reviewed — no blocking findings

The inspected changes support the stated truncation behavior; no blocking defect was verified, though one changed test file was unavailable for review.

What I ran

No commands or tests were run. I inspected the prepared diff and source at head f792af8f144ad33630fdf77f1f4cc9261099c926 using the repo_read.py reader interface.

Results

Check Result Note
Source review passed Core conversion and packing inspected
Tests not run Results in the PR description are author reported

Findings

Blocking

None.

Non-blocking

None.

Not verified

core/libs/prx/libSceAgcDriver/tests/Graphics.cpp was excluded as too large for the review folder. Its changed lines were inspected, but its full text was not read. The remaining included changed files were reviewed. Tests, CI output, console behavior, and the author’s reported measurements were not independently verified.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5986793305 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23281#pullrequestreview-5986793305). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T02:50:43Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The inspected changes support the stated truncation behavior; no blocking defect was verified, though one changed test file was unavailable for review. ## What I ran No commands or tests were run. I inspected the prepared diff and source at head `f792af8f144ad33630fdf77f1f4cc9261099c926` using the `repo_read.py` reader interface. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | Core conversion and packing inspected | | Tests | not run | Results in the PR description are author reported | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` was excluded as too large for the review folder. Its changed lines were inspected, but its full text was not read. The remaining included changed files were reviewed. Tests, CI output, console behavior, and the author’s reported measurements were not independently verified. ## To get this to a good state Nothing is required.
ligmaSec commented 2026-12-03 21:59:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T21:59:17Z.

Review: COMMENTED


The current stack conflicts with main 63db72fb61 in Graphics.cpp and three shader format/serialization files. Please resolve #23258 first, then carry forward the distinct 10_11_11 packing and the existing 4_4_4_4 mode. Keep the 11-bit versus 10-bit truncation boundary checks on the rebased branch. The paired Vulkan run is pending the merge resolution.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6179341292 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23281#pullrequestreview-6179341292). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T21:59:17Z. **Review:** COMMENTED --- The current stack conflicts with `main` `63db72fb61` in `Graphics.cpp` and three shader format/serialization files. Please resolve #23258 first, then carry forward the distinct 10_11_11 packing and the existing 4_4_4_4 mode. Keep the 11-bit versus 10-bit truncation boundary checks on the rebased branch. The paired Vulkan run is pending the merge resolution. AI-assisted: yes.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/23281:upstream-pr/23281'
git switch 'upstream-pr/23281'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/23281'
git switch 'upstream-pr/23281'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/23281'
git switch 'upstream-pr/23281'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/23281'
git switch 'main'
git merge --squash 'upstream-pr/23281'
git switch 'main'
git merge --ff-only 'upstream-pr/23281'
git switch 'main'
git merge 'upstream-pr/23281'
git push origin 'main'
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!23281
No description provided.