fix(shader): return 0 for 8-bit sRGB color comparison #3438

Merged
ivica00 merged 2 commits from upstream-pr/3438 into main 2026-10-11 11:43:28 +00:00
ivica00 commented 2026-10-11 10:32:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ivica00 on 2026-10-11T10:32:49Z.


What

Subnautica Below Zero (PPSA02456) stops on current main at:

presentation failed: comparison sampling of a color texture is implemented only for float, unorm and snorm formats (format 130)

Format 130 is the T# data format Format8_8_8_8Srgb. That throw is the color-comparison path for image_sample_c / image_sample_c_lz on a texture that is not R32 float or R16 unorm. The log does not print the opcode or the rest of the T# and S#.

On gfx1035, image_sample_c_lz of 8-bit sRGB (Format8Srgb, Format8_8Srgb, Format8_8_8_8Srgb) returns 0 for every compare function over references -0.5..1.5 and texel codes 0..255. This returns that 0. It does not compare the texel.

Bilinear cube comparison without DISABLE_CUBE_WRAP still throws. The same measurement shows that filter blends across faces, so a per-face clamp was the wrong model. If the format-130 shader is a bilinear cube without that bit, it still stops, and that throw matches the measurement.

8-bit UNORM also returns 0 on that hardware. This leaves the existing UNORM compare in place; that difference is recorded in TechnicalDebt.

Tested

Windows 10 (19045), MinGW-w64 GCC, AMD Radeon RX 9070 XT. agc_driver_emulated_color_compare_tests prints emulated color compare tests passed. The new rows expect 0 for formats 128, 129 and 130, point and bilinear, and for format 130 every compare function 0..7. On main the same test rejects format 130. Bilinear cube comparison without DISABLE_CUBE_WRAP still rejects. tools/check_conventions.py --base upstream/main passed.

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
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • 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
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4818418370 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3438). Originally posted by [ivica00](https://github.com/ivica00) on 2026-10-11T10:32:49Z. --- ### What Subnautica Below Zero (PPSA02456) stops on current main at: `presentation failed: comparison sampling of a color texture is implemented only for float, unorm and snorm formats (format 130)` Format 130 is the T# data format `Format8_8_8_8Srgb`. That throw is the color-comparison path for `image_sample_c` / `image_sample_c_lz` on a texture that is not R32 float or R16 unorm. The log does not print the opcode or the rest of the T# and S#. On gfx1035, `image_sample_c_lz` of 8-bit sRGB (`Format8Srgb`, `Format8_8Srgb`, `Format8_8_8_8Srgb`) returns 0 for every compare function over references -0.5..1.5 and texel codes 0..255. This returns that 0. It does not compare the texel. Bilinear cube comparison without `DISABLE_CUBE_WRAP` still throws. The same measurement shows that filter blends across faces, so a per-face clamp was the wrong model. If the format-130 shader is a bilinear cube without that bit, it still stops, and that throw matches the measurement. 8-bit UNORM also returns 0 on that hardware. This leaves the existing UNORM compare in place; that difference is recorded in TechnicalDebt. ### Tested Windows 10 (19045), MinGW-w64 GCC, AMD Radeon RX 9070 XT. `agc_driver_emulated_color_compare_tests` prints `emulated color compare tests passed`. The new rows expect 0 for formats 128, 129 and 130, point and bilinear, and for format 130 every compare function 0..7. On main the same test rejects format 130. Bilinear cube comparison without `DISABLE_CUBE_WRAP` still rejects. `tools/check_conventions.py --base upstream/main` passed. ### Checklist - [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) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes
adriadam10 commented 2026-10-11 10:39:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T10:39:02Z.

Review: CHANGES_REQUESTED


Thanks for the PR. I measured both changes on the hardware oracle (gfx1035, image_sample_c_lz) and neither matches what the PR implements:

  • sRGB formats (Format8Srgb, Format8_8Srgb, Format8_8_8_8Srgb): image_sample_c on 8-bit sRGB (and 8-bit UNORM) T# returns 0 for every compare function over refs -0.5..1.5 and texel codes 0..255; only depth-capable formats (R32 float, R16 unorm) compare. Treating them with ReferenceUnorm (ResourceMaterializer.cpp:507) returns compared values where hardware returns 0, so a throw that was exact becomes a plausible-but-wrong result. The new test rows (EmulatedColorCompare.cpp:333) pin that.
  • Bilinear cube without DISABLE_CUBE_WRAP (ResourceMaterializer.cpp:552): hardware blends across cube faces here. On a 4x4 R32 float cube, 46 of 90 edge rows differ from a per-face clamp model (face 0, ref 0.1, u=3.9, v=2.5: HW 0.6016, per-face model 1.0; u=1.5, v=0.1: HW 0.3984, model 0.0). With DISABLE_CUBE_WRAP set, all 90 rows match the per-face model. So the throw is correct and removing it, together with EmulatedColorCompare.cpp:325 and the TechnicalDebt text saying cube faces are filtered separately, documents behaviour the hardware does not have.

To unblock the menu shader: if it really needs these forms, the fix is to model what hardware does (cross-face seamless filtering for the cube case; for 8-bit color formats, a constant 0 result if that is what the shader gets) with a test whose expected values come from those measurements, and to say in the description which instruction and descriptor the title uses. A log of the failing shader would help. Otherwise these paths should keep throwing.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5482980211 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3438#pullrequestreview-5482980211). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T10:39:02Z. **Review:** CHANGES_REQUESTED --- Thanks for the PR. I measured both changes on the hardware oracle (gfx1035, `image_sample_c_lz`) and neither matches what the PR implements: - **sRGB formats** (`Format8Srgb`, `Format8_8Srgb`, `Format8_8_8_8Srgb`): `image_sample_c` on 8-bit sRGB (and 8-bit UNORM) T# returns 0 for every compare function over refs -0.5..1.5 and texel codes 0..255; only depth-capable formats (R32 float, R16 unorm) compare. Treating them with `ReferenceUnorm` (`ResourceMaterializer.cpp:507`) returns compared values where hardware returns 0, so a throw that was exact becomes a plausible-but-wrong result. The new test rows (`EmulatedColorCompare.cpp:333`) pin that. - **Bilinear cube without `DISABLE_CUBE_WRAP`** (`ResourceMaterializer.cpp:552`): hardware blends across cube faces here. On a 4x4 R32 float cube, 46 of 90 edge rows differ from a per-face clamp model (face 0, ref 0.1, u=3.9, v=2.5: HW 0.6016, per-face model 1.0; u=1.5, v=0.1: HW 0.3984, model 0.0). With `DISABLE_CUBE_WRAP` set, all 90 rows match the per-face model. So the throw is correct and removing it, together with `EmulatedColorCompare.cpp:325` and the TechnicalDebt text saying cube faces are filtered separately, documents behaviour the hardware does not have. To unblock the menu shader: if it really needs these forms, the fix is to model what hardware does (cross-face seamless filtering for the cube case; for 8-bit color formats, a constant 0 result if that is what the shader gets) with a test whose expected values come from those measurements, and to say in the description which instruction and descriptor the title uses. A log of the failing shader would help. Otherwise these paths should keep throwing.
ivica00 commented 2026-10-11 10:45:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ivica00 on 2026-10-11T10:45:24Z.


The measurements are right, and the previous result was wrong. Pushed cb52ca10c.

8-bit sRGB (Format8Srgb, Format8_8Srgb, Format8_8_8_8Srgb) now returns 0 for every compare function, point and bilinear. The test expects 0, including format 130 for compare functions 0 through 7. It no longer uses the unorm clamp.

The bilinear-cube throw is back. The per-face model does not match the cross-face blend you measured, and this change does not implement seamless filtering.

The title stop on current main is presentation failed: comparison sampling of a color texture is implemented only for float, unorm and snorm formats (format 130). Format 130 is the T# data format Format8_8_8_8Srgb. That line is the color-comparison path for image_sample_c / image_sample_c_lz. The log does not print the opcode or the rest of the T# and S#. If that shader is a bilinear cube without DISABLE_CUBE_WRAP, it still throws.

The same measurement returns 0 for 8-bit UNORM. That path is unchanged, because the existing tests pin a real compare, and the difference is recorded in TechnicalDebt.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6108206009 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3438#issuecomment-6108206009). Originally posted by [ivica00](https://github.com/ivica00) on 2026-10-11T10:45:24Z. --- The measurements are right, and the previous result was wrong. Pushed cb52ca10c. 8-bit sRGB (`Format8Srgb`, `Format8_8Srgb`, `Format8_8_8_8Srgb`) now returns 0 for every compare function, point and bilinear. The test expects 0, including format 130 for compare functions 0 through 7. It no longer uses the unorm clamp. The bilinear-cube throw is back. The per-face model does not match the cross-face blend you measured, and this change does not implement seamless filtering. The title stop on current main is `presentation failed: comparison sampling of a color texture is implemented only for float, unorm and snorm formats (format 130)`. Format 130 is the T# data format `Format8_8_8_8Srgb`. That line is the color-comparison path for `image_sample_c` / `image_sample_c_lz`. The log does not print the opcode or the rest of the T# and S#. If that shader is a bilinear cube without `DISABLE_CUBE_WRAP`, it still throws. The same measurement returns 0 for 8-bit UNORM. That path is unchanged, because the existing tests pin a real compare, and the difference is recorded in TechnicalDebt.
adriadam10 commented 2026-10-11 11:43:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T11:43:25Z.

Review: APPROVED


Thanks for the update. Checked against the hardware oracle (gfx1035): 8-bit sRGB image_sample_c_lz returns 0 for every compare function, which is what the PR now implements for point and bilinear. The bilinear-cube throw is back, matching the cross-face blend measured earlier. agc_driver_emulated_color_compare passes and fails without the code changes. The 8-bit UNORM difference is recorded in TechnicalDebt. Merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5483169124 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3438#pullrequestreview-5483169124). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T11:43:25Z. **Review:** APPROVED --- Thanks for the update. Checked against the hardware oracle (gfx1035): 8-bit sRGB `image_sample_c_lz` returns 0 for every compare function, which is what the PR now implements for point and bilinear. The bilinear-cube throw is back, matching the cross-face blend measured earlier. `agc_driver_emulated_color_compare` passes and fails without the code changes. The 8-bit UNORM difference is recorded in TechnicalDebt. Merging once CI is green.
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!3438
No description provided.