fix(agc): accept additional color comparison image forms #2092

Merged
authurtabo-byte merged 5 commits from upstream-pr/2092 into main 2026-10-10 08:13:30 +00:00
authurtabo-byte commented 2026-10-09 08:11:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by authurtabo-byte on 2026-10-09T08:11:30Z.


What

Accept the existing cube-to-2D-array runtime mode for color comparison, and classify 8-bit sRGB formats with the existing UNORM reference clamp. MiniGolf (PPSA03647) uses an sRGB cube comparison descriptor that previously had no matching prepared mode.

Anisotropic point/bilinear encodings 2/3 remain rejected. The previous revision incorrectly treated them as ordinary point/bilinear filtering; this revision restores main's guard rather than weakening the rejection test reported by rmz-24.

No new comparison instruction lowering is introduced. Cube coordinates use the existing CubeAxis/CubeLayer conversion in SpirvImageEmitter.cpp. sRGB texels use Vulkan's image-format decode before comparison; the GPU regression uses the standard sRGB transfer function as its reference. Console reference-clamping behavior and cube-edge filtering remain unmeasured and are explicitly recorded in TechnicalDebt.

Tested

Rebased onto main 0df342c6 (PR head 9cc55a13). Resolved the TechnicalDebt.md conflict by retaining both main's ancillary-word entry and this change's color-comparison entry. git range-diff confirms the executable code changes are unchanged by this rebase. The focused tests below were rebuilt from this PR checkout, separately from the MiniGolf integration branch. Windows, MinGW-w64 GCC 15.2.0, Release, NVIDIA RTX 3050 6GB Laptop GPU, SPIRV-Tools disabled.

  • agc_shader_memory: passes, with an assertion that the captured cube descriptor selects a cube emulated-comparison mode.
  • agc_driver_emulated_color_compare: passes, including new sRGB point/bilinear result checks and rejection of both anisotropic filter encodings. Existing address, border, offset, cache and reduction cases remain enabled.
  • agc_driver_guarded_null_pointer: passes on the rebased main.
  • python -I tools/check_conventions.py --base 0df342c6 --head 9cc55a13: passes.

The earlier MiniGolf integration accepted anisotropic filtering incorrectly; that run is not evidence that anisotropic sampling works. Linux, validation layers and PS5 hardware equivalence were not tested locally.

Checklist

  • Based on current main; no other open PR implements the same fix
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; anisotropy remains refused
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source: none added
  • Generic behaviour, not specific to one title
  • Depends on: none; #907 independently reviews other color-comparison semantics
  • AI-assisted: yes, Codex
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4797845983 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2092). Originally posted by [authurtabo-byte](https://github.com/authurtabo-byte) on 2026-10-09T08:11:30Z. --- ### What Accept the existing cube-to-2D-array runtime mode for color comparison, and classify 8-bit sRGB formats with the existing UNORM reference clamp. MiniGolf (PPSA03647) uses an sRGB cube comparison descriptor that previously had no matching prepared mode. Anisotropic point/bilinear encodings 2/3 remain rejected. The previous revision incorrectly treated them as ordinary point/bilinear filtering; this revision restores main's guard rather than weakening the rejection test reported by rmz-24. No new comparison instruction lowering is introduced. Cube coordinates use the existing `CubeAxis`/`CubeLayer` conversion in `SpirvImageEmitter.cpp`. sRGB texels use Vulkan's image-format decode before comparison; the GPU regression uses the standard sRGB transfer function as its reference. Console reference-clamping behavior and cube-edge filtering remain unmeasured and are explicitly recorded in TechnicalDebt. ### Tested Rebased onto main `0df342c6` (PR head `9cc55a13`). Resolved the `TechnicalDebt.md` conflict by retaining both main's ancillary-word entry and this change's color-comparison entry. `git range-diff` confirms the executable code changes are unchanged by this rebase. The focused tests below were rebuilt from this PR checkout, separately from the MiniGolf integration branch. Windows, MinGW-w64 GCC 15.2.0, Release, NVIDIA RTX 3050 6GB Laptop GPU, SPIRV-Tools disabled. - `agc_shader_memory`: passes, with an assertion that the captured cube descriptor selects a cube emulated-comparison mode. - `agc_driver_emulated_color_compare`: passes, including new sRGB point/bilinear result checks and rejection of both anisotropic filter encodings. Existing address, border, offset, cache and reduction cases remain enabled. - `agc_driver_guarded_null_pointer`: passes on the rebased main. - `python -I tools/check_conventions.py --base 0df342c6 --head 9cc55a13`: passes. The earlier MiniGolf integration accepted anisotropic filtering incorrectly; that run is not evidence that anisotropic sampling works. Linux, validation layers and PS5 hardware equivalence were not tested locally. ### Checklist - [x] Based on current `main`; no other open PR implements the same fix - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw; anisotropy remains refused - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source: none added - [x] Generic behaviour, not specific to one title - [x] Depends on: none; #907 independently reviews other color-comparison semantics - [x] AI-assisted: yes, Codex
rmz-24 commented 2026-10-09 13:21:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rmz-24 on 2026-10-09T13:21:12Z.


214f75a5 cherry-picked onto current main d70b8998 breaks an existing test: agc_driver_emulated_color_compare fails 3 of 3 runs with this change and passes on main (Windows 11, RTX 5060 Ti, MinGW-w64 GCC 15.2.0 r7, Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON; full ctest otherwise 509/510):

AGC graphics: expected rejection: point or bilinear

The case is tests/execution/EmulatedColorCompare.cpp:257, Reject(*device, Format8888UNorm, {ClampEdge, FilterAnisoBilinear}, "point or bilinear"). With this change an anisotropic-bilinear color comparison is accepted where the test expects the ResourceMaterializer filter rejection. It doesn't look Windows-specific, since it's a recompiler decision. If accepting that form is intended, the test needs updating along with the semantics source for it; otherwise the new path should keep rejecting anisotropic filters.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6081733279 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2092#issuecomment-6081733279). Originally posted by [rmz-24](https://github.com/rmz-24) on 2026-10-09T13:21:12Z. --- 214f75a5 cherry-picked onto current `main` d70b8998 breaks an existing test: `agc_driver_emulated_color_compare` fails 3 of 3 runs with this change and passes on `main` (Windows 11, RTX 5060 Ti, MinGW-w64 GCC 15.2.0 r7, Release, `-DANYPS5_ENABLE_SPIRV_TOOLS=ON`; full ctest otherwise 509/510): ``` AGC graphics: expected rejection: point or bilinear ``` The case is `tests/execution/EmulatedColorCompare.cpp:257`, `Reject(*device, Format8888UNorm, {ClampEdge, FilterAnisoBilinear}, "point or bilinear")`. With this change an anisotropic-bilinear color comparison is accepted where the test expects the `ResourceMaterializer` filter rejection. It doesn't look Windows-specific, since it's a recompiler decision. If accepting that form is intended, the test needs updating along with the semantics source for it; otherwise the new path should keep rejecting anisotropic filters. AI-assisted: yes
authurtabo-byte commented 2026-10-09 20:31:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by authurtabo-byte on 2026-10-09T20:31:01Z.


Thanks for catching that. The branch head has been updated to \2e2ec5d4:

  • Retains rejection of anisotropic filter combinations (\FilterAnisoPoint, \FilterAnisoBilinear) so \ResourceMaterializer\ behaves as expected.
  • Retains both upstream guarded-null-pointer tests and adds cube-comparison regression coverage.
  • All execution tests (\gc_driver_emulated_color_compare, \gc_driver_guarded_null_pointer, \gc_shader_memory) now pass cleanly.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6088754467 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2092#issuecomment-6088754467). Originally posted by [authurtabo-byte](https://github.com/authurtabo-byte) on 2026-10-09T20:31:01Z. --- Thanks for catching that. The branch head has been updated to \2e2ec5d4\: - Retains rejection of anisotropic filter combinations (\FilterAnisoPoint\, \FilterAnisoBilinear\) so \ResourceMaterializer\ behaves as expected. - Retains both upstream guarded-null-pointer tests and adds cube-comparison regression coverage. - All execution tests (\gc_driver_emulated_color_compare\, \gc_driver_guarded_null_pointer\, \gc_shader_memory\) now pass cleanly.
adriadam10 commented 2026-10-10 05:59:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T05:59:25Z.

Review: CHANGES_REQUESTED


Thanks for restoring the anisotropic rejection. I measured both new forms on RDNA2 hardware (gfx1035, image_sample_c_lz, IEEE=0), and they don't match what the hardware returns:

  • sRGB (ResourceMaterializer.cpp:507, test at EmulatedColorCompare.cpp:150). On 8_8_8_8_SRGB (and 8_SRGB, 8_8_8_8_UNORM, 8_UNORM, 16_FLOAT), image_sample_c_lz returns 0 for every compare function, ALWAYS included, with point and bilinear filtering. Plain image_sample_lz on the same T# reads the expected decoded texels. Only depth-capable formats (32_FLOAT, 16_UNORM) give a real comparison, and emulatedCompareState already sends exactly those to the native path. So "decode, then compare against a UNORM-clamped reference" is not what the GPU does for these formats. The expected values in the test come from the sRGB transfer function, not from hardware, which is why they pass. Please keep these formats throwing. If you want to model them, the measured result is a constant 0, but that is a separate change (see the note below).
  • Cube (ResourceMaterializer.cpp:531, :696). On 32_FLOAT, face = layer and s/t in [1,2] match the cube-to-array conversion: all 192 point rows and all 54 in-face bilinear rows agree. With the default sampler (word0 bit 28 DISABLE_CUBE_WRAP = 0), bilinear footprints that reach a face edge filter across into the neighbouring face. 46 of 90 edge rows differ from the per-face clamp that the emulation uses, and with bit 28 set all 90 match. Point sampling at the edges matches too. Please throw for bilinear cube comparison unless that bit is set (or model seamless filtering), and add an execution test on a cube view. The current cube test (ShaderMemory.cpp:2138) only checks which mode gets selected.
  • The TechnicalDebt line (docs/dev/TechnicalDebt.md:45) should then describe what is actually accepted.

Note: the UNORM color-comparison emulation already on main has the same mismatch with these measurements (the hardware returns 0 and the emulation compares). That will be raised separately and is not for this PR to fix. Measurements were taken on gfx1035, not on PS5's gfx1013; both are RDNA2.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5477879151 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2092#pullrequestreview-5477879151). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T05:59:25Z. **Review:** CHANGES_REQUESTED --- Thanks for restoring the anisotropic rejection. I measured both new forms on RDNA2 hardware (gfx1035, `image_sample_c_lz`, IEEE=0), and they don't match what the hardware returns: - **sRGB (`ResourceMaterializer.cpp:507`, test at `EmulatedColorCompare.cpp:150`).** On 8_8_8_8_SRGB (and 8_SRGB, 8_8_8_8_UNORM, 8_UNORM, 16_FLOAT), `image_sample_c_lz` returns 0 for every compare function, ALWAYS included, with point and bilinear filtering. Plain `image_sample_lz` on the same T# reads the expected decoded texels. Only depth-capable formats (32_FLOAT, 16_UNORM) give a real comparison, and `emulatedCompareState` already sends exactly those to the native path. So "decode, then compare against a UNORM-clamped reference" is not what the GPU does for these formats. The expected values in the test come from the sRGB transfer function, not from hardware, which is why they pass. Please keep these formats throwing. If you want to model them, the measured result is a constant 0, but that is a separate change (see the note below). - **Cube (`ResourceMaterializer.cpp:531`, `:696`).** On 32_FLOAT, face = layer and s/t in [1,2] match the cube-to-array conversion: all 192 point rows and all 54 in-face bilinear rows agree. With the default sampler (word0 bit 28 `DISABLE_CUBE_WRAP` = 0), bilinear footprints that reach a face edge filter across into the neighbouring face. 46 of 90 edge rows differ from the per-face clamp that the emulation uses, and with bit 28 set all 90 match. Point sampling at the edges matches too. Please throw for bilinear cube comparison unless that bit is set (or model seamless filtering), and add an execution test on a cube view. The current cube test (`ShaderMemory.cpp:2138`) only checks which mode gets selected. - The TechnicalDebt line (`docs/dev/TechnicalDebt.md:45`) should then describe what is actually accepted. Note: the UNORM color-comparison emulation already on `main` has the same mismatch with these measurements (the hardware returns 0 and the emulation compares). That will be raised separately and is not for this PR to fix. Measurements were taken on gfx1035, not on PS5's gfx1013; both are RDNA2.
adriadam10 commented 2026-10-10 08:13:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T08:13:28Z.

Review: APPROVED


Checked on the PR merged onto current main: agc_shader_memory and agc_driver_emulated_color_compare pass, the AgcDriver/Agc ctest scope is green (333/333), and both tests fail without the ResourceMaterializer.cpp change. sRGB and anisotropic forms are rejected again, bilinear cube comparison requires DISABLE_CUBE_WRAP (matches my gfx1035 measurements: 90/90 edge rows), and the cube execution test covers it. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5478282202 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2092#pullrequestreview-5478282202). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T08:13:28Z. **Review:** APPROVED --- Checked on the PR merged onto current main: `agc_shader_memory` and `agc_driver_emulated_color_compare` pass, the AgcDriver/Agc ctest scope is green (333/333), and both tests fail without the `ResourceMaterializer.cpp` change. sRGB and anisotropic forms are rejected again, bilinear cube comparison requires `DISABLE_CUBE_WRAP` (matches my gfx1035 measurements: 90/90 edge rows), and the cube execution test covers it. Merging.
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!2092
No description provided.