fix(agc): round the color compare array layer half to even and compare NOT_EQUAL unordered (supersedes #907) #8625

Closed
oneandonlydean wants to merge 3 commits from upstream-pr/8625 into main
oneandonlydean commented 2026-10-20 18:52:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T18:52:53Z.


Supersedes #907

What

AGC colour-compare emulation (image_sample_c on a colour texture) fixes by @ThisIsAkill, rebased onto current main. The branch is #907's three commits with their authorship kept; Rujul Talekar (@Roojool) posted the resolved rebase in a #907 comment on 14 Oct, and this branch re-applies that resolution on main 86c1784b9 (the debt note and the test file conflicted again and were resolved the same way).

  • The array layer is the coordinate rounded half to even (RoundEven), where it was Floor(z + 0.5).
  • NOT_EQUAL is unordered (true when the reference or the texel is NaN); the other functions stay false for NaN.
  • TRUNC_COORD with point sampling throws.
  • Tests for 2D arrays, GREATER, NaN and the TRUNC_COORD rejection; the debt note in docs/dev/debt/shader.md is updated.

Both behaviours are the ones @adriadam10 measured on RDNA2 (gfx1035). #907 had no review blocker (adriadam10: "ready to merge from my side", 11 Oct) and the author has not replied since 7 Oct.

Tested

Linux (CachyOS, kernel 7.2.3), NVIDIA GeForce RTX 4090, driver 610.57.04, Release, GCC 16 build from this branch (main 86c1784b9 + the three commits):

  • ctest -R agc_driver_emulated_color_compare: agc_driver_emulated_color_compare and agc_driver_emulated_color_compare_srgb_decode pass (0.58 s, 0.27 s).
  • The three touched .cpp files (SpirvImageEmitter.cpp, ResourceMaterializer.cpp, EmulatedColorCompare.cpp) pass a g++ 13.5 -fsyntax-only check with the project flags (Linux CI uses GCC 13).
  • Not tested: Windows, other GPUs, a game run (no title was run for this branch), the test against main's shader (the new cases are written to fail there; not run here).

Checklist

  • Based on current main; no other open PR implements the same functions (#907 is the same change and is superseded)
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • 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: NVIDIA GeForce RTX 4090, driver 610.57.04, Linux
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4940766410 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8625). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-20T18:52:53Z. --- Supersedes #907 ### What AGC colour-compare emulation (`image_sample_c` on a colour texture) fixes by @ThisIsAkill, rebased onto current `main`. The branch is #907's three commits with their authorship kept; Rujul Talekar (@Roojool) posted the resolved rebase in a #907 comment on 14 Oct, and this branch re-applies that resolution on `main` 86c1784b9 (the debt note and the test file conflicted again and were resolved the same way). - The array layer is the coordinate rounded half to even (`RoundEven`), where it was `Floor(z + 0.5)`. - NOT_EQUAL is unordered (true when the reference or the texel is NaN); the other functions stay false for NaN. - TRUNC_COORD with point sampling throws. - Tests for 2D arrays, GREATER, NaN and the TRUNC_COORD rejection; the debt note in `docs/dev/debt/shader.md` is updated. Both behaviours are the ones @adriadam10 measured on RDNA2 (gfx1035). #907 had no review blocker (adriadam10: "ready to merge from my side", 11 Oct) and the author has not replied since 7 Oct. ### Tested Linux (CachyOS, kernel 7.2.3), NVIDIA GeForce RTX 4090, driver 610.57.04, Release, GCC 16 build from this branch (main 86c1784b9 + the three commits): - `ctest -R agc_driver_emulated_color_compare`: `agc_driver_emulated_color_compare` and `agc_driver_emulated_color_compare_srgb_decode` pass (0.58 s, 0.27 s). - The three touched `.cpp` files (`SpirvImageEmitter.cpp`, `ResourceMaterializer.cpp`, `EmulatedColorCompare.cpp`) pass a `g++ 13.5 -fsyntax-only` check with the project flags (Linux CI uses GCC 13). - Not tested: Windows, other GPUs, a game run (no title was run for this branch), the test against `main`'s shader (the new cases are written to fail there; not run here). ### Checklist - [x] Based on current `main`; no other open PR implements the same functions (#907 is the same change and is superseded) - [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) - [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: NVIDIA GeForce RTX 4090, driver 610.57.04, Linux - [x] AI-assisted: yes
MarcZX10 commented 2026-10-20 19:45:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T19:45:47Z.


I checked the overlap against the separate measurements now recorded on #7934. This PR corrects array-layer rounding, NOT_EQUAL NaN behavior, and TRUNC_COORD handling. The GFX10 format split is a distinct behavior: point comparisons return zero for every sampled floating format except codes 7 (16_UNORM) and 22 (32_FLOAT), corroborated on gfx1031 and gfx1036, with gfx1100 also reporting point and bilinear results. The candidate fix changes the format dispatch and the same regression test file touched here, so I won't publish a competing branch. Would you prefer that the format split be stacked as a follow-up to this PR, or kept as a separate PR after this lands?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6299896361 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8625#issuecomment-6299896361). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-20T19:45:47Z. --- I checked the overlap against the separate measurements now recorded on #7934. This PR corrects array-layer rounding, NOT_EQUAL NaN behavior, and TRUNC_COORD handling. The GFX10 format split is a distinct behavior: point comparisons return zero for every sampled floating format except codes 7 (16_UNORM) and 22 (32_FLOAT), corroborated on gfx1031 and gfx1036, with gfx1100 also reporting point and bilinear results. The candidate fix changes the format dispatch and the same regression test file touched here, so I won't publish a competing branch. Would you prefer that the format split be stacked as a follow-up to this PR, or kept as a separate PR after this lands?
oneandonlydean commented 2026-10-20 19:51:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T19:51:12Z.


@MarcZX10 thanks for checking the overlap and for the measurements on #7934. Please keep the format split as a separate PR. This one is queued for testing on its current branch, and stacking would mean starting that over. If you open it now, Depends on: #8625 is fine. It can go in right after this lands, and it'll need its own rebase of the shared test file.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6300029653 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8625#issuecomment-6300029653). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-20T19:51:12Z. --- @MarcZX10 thanks for checking the overlap and for the measurements on #7934. Please keep the format split as a separate PR. This one is queued for testing on its current branch, and stacking would mean starting that over. If you open it now, `Depends on: #8625` is fine. It can go in right after this lands, and it'll need its own rebase of the shared test file.
DavidAmsellem commented 2026-10-20 20:35:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DavidAmsellem on 2026-10-20T20:35:56Z.


First AMD run of this PR, on Linux with RADV. Head 8feaa79a7 merged onto main aa1b1bfce (clean merge), built in full and compared with the same main, on the same machine.

AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 (Ubuntu 24.04 base), kernel 7.0.0-38, GCC 13.3, Release.

  • agc_driver_emulated_color_compare and agc_driver_emulated_color_compare_srgb_decode: pass 3 of 3 each with ANYPS5_NO_SHADER_CACHE=1, and under the Khronos validation layer they add no VUID (the only message is VkDeviceCreateInfo-pNext-pNext, which my older 1.3.275 layer prints for every device because it doesn't know maintenance8).
  • Full suite (ANYPS5_REQUIRE_VULKAN=1 ctest -j8) at eb01b8813: 1733/1734, failing only agc_driver_guest_memory_lifetime (#7784), which fails on main too.

For #8642, which depends on this one: it doesn't merge on top of this head yet (EmulatedColorCompare.cpp and docs/dev/debt/shader.md conflict), as its description says, so I'm testing it on its own against main and will report there.

GPUs tested: AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 / kernel 7.0.0-38

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6300910000 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8625#issuecomment-6300910000). Originally posted by [DavidAmsellem](https://github.com/DavidAmsellem) on 2026-10-20T20:35:56Z. --- First AMD run of this PR, on Linux with RADV. Head `8feaa79a7` merged onto `main` `aa1b1bfce` (clean merge), built in full and compared with the same `main`, on the same machine. AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 (Ubuntu 24.04 base), kernel 7.0.0-38, GCC 13.3, Release. - `agc_driver_emulated_color_compare` and `agc_driver_emulated_color_compare_srgb_decode`: pass 3 of 3 each with `ANYPS5_NO_SHADER_CACHE=1`, and under the Khronos validation layer they add no VUID (the only message is `VkDeviceCreateInfo-pNext-pNext`, which my older 1.3.275 layer prints for every device because it doesn't know `maintenance8`). - Full suite (`ANYPS5_REQUIRE_VULKAN=1 ctest -j8`) at `eb01b8813`: **1733/1734**, failing only `agc_driver_guest_memory_lifetime` (#7784), which fails on `main` too. For #8642, which depends on this one: it doesn't merge on top of this head yet (`EmulatedColorCompare.cpp` and `docs/dev/debt/shader.md` conflict), as its description says, so I'm testing it on its own against `main` and will report there. GPUs tested: AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 / kernel 7.0.0-38 AI-assisted: yes
janzezno commented 2026-10-20 23:04:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by janzezno on 2026-10-20T23:04:30Z.


Run on AMD hardware.

Host: Arch Linux, kernel 7.2.11, AMD Radeon RX 7900 GRE (RADV NAVI31), Mesa 26.2.5, GCC 16.2.1, Release, BUILD_TESTING=ON.
main e25333e39; PR head 8feaa79a7e merged on top (clean merge).

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R 'compare|denorm|f32|f16|f64|agc_shader_memory|agc_shader_disk_cache|request_serializer|dcc|storage|pm4|indirect' -V

  • main: 137 of 137 pass. PR: 137 of 137 pass, including agc_driver_emulated_color_compare and agc_driver_emulated_color_compare_srgb_decode.
  • The same VUID- set and counts on both; none is new. The validation layer loaded in both runs.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6303754027 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8625#issuecomment-6303754027). Originally posted by [janzezno](https://github.com/janzezno) on 2026-10-20T23:04:30Z. --- Run on AMD hardware. Host: Arch Linux, kernel 7.2.11, AMD Radeon RX 7900 GRE (RADV NAVI31), Mesa 26.2.5, GCC 16.2.1, Release, `BUILD_TESTING=ON`. `main` `e25333e39`; PR head `8feaa79a7e` merged on top (clean merge). `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R 'compare|denorm|f32|f16|f64|agc_shader_memory|agc_shader_disk_cache|request_serializer|dcc|storage|pm4|indirect' -V` - `main`: 137 of 137 pass. PR: 137 of 137 pass, including `agc_driver_emulated_color_compare` and `agc_driver_emulated_color_compare_srgb_decode`. - The same `VUID-` set and counts on both; none is new. The validation layer loaded in both runs.
thuanquang commented 2026-10-21 04:39:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-21T04:39:40Z.


An AMD proprietary-driver run: RX 6700 XT (gfx1031), AMD Windows driver 32.0.21045.5002, Windows 11 26200, MinGW GCC 15.2.0 Release.

  • main 7ab4b2e56 with only this PR's EmulatedColorCompare.cpp: agc_driver_emulated_color_compare and _srgb_decode fail 3 of 3 with 2D array, point, clamp to edge: thread 2 compared to 1.000000, expected 0.000000.
  • main 7ab4b2e56 merged with this head 8feaa79a7 (clean merge): all 5 tests pass 3 of 3: those two plus agc_driver_depth_compare_copy, agc_driver_image_plane_compare_on_line and agc_driver_image_one_dimensional_compare.
  • Khronos validation layer, ctest -V on the same 5: 0 VUID- lines on main and with this PR. The layer was inserted in all 5 test processes on each side.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6308191542 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8625#issuecomment-6308191542). Originally posted by [thuanquang](https://github.com/thuanquang) on 2026-10-21T04:39:40Z. --- An AMD proprietary-driver run: RX 6700 XT (gfx1031), AMD Windows driver 32.0.21045.5002, Windows 11 26200, MinGW GCC 15.2.0 Release. - **`main` `7ab4b2e56` with only this PR's `EmulatedColorCompare.cpp`:** `agc_driver_emulated_color_compare` and `_srgb_decode` fail 3 of 3 with `2D array, point, clamp to edge: thread 2 compared to 1.000000, expected 0.000000`. - **`main` `7ab4b2e56` merged with this head `8feaa79a7` (clean merge):** all 5 tests pass 3 of 3: those two plus `agc_driver_depth_compare_copy`, `agc_driver_image_plane_compare_on_line` and `agc_driver_image_one_dimensional_compare`. - **Khronos validation layer, `ctest -V` on the same 5:** 0 `VUID-` lines on `main` and with this PR. The layer was inserted in all 5 test processes on each side.

Pull request closed

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!8625
No description provided.