fix(shader): return 0 for 8-bit sRGB color comparison #3438
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3438"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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 forimage_sample_c/image_sample_c_lzon 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_lzof 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_WRAPstill 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_testsprintsemulated 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 withoutDISABLE_CUBE_WRAPstill rejects.tools/check_conventions.py --base upstream/mainpassed.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)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:Format8Srgb,Format8_8Srgb,Format8_8_8_8Srgb):image_sample_con 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 withReferenceUnorm(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.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). WithDISABLE_CUBE_WRAPset, all 90 rows match the per-face model. So the throw is correct and removing it, together withEmulatedColorCompare.cpp:325and 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.
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 formatFormat8_8_8_8Srgb. That line is the color-comparison path forimage_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 withoutDISABLE_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.
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_lzreturns 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_comparepasses and fails without the code changes. The 8-bit UNORM difference is recorded in TechnicalDebt. Merging once CI is green.