fix(shader): allow constant-zero sRGB comparisons #3532
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3532"
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 MarcZX10 on 2026-10-11T12:36:08Z.
What
Fixes #3526. On devices that cannot sample an 8-bit sRGB view, a comparison-only sRGB descriptor was rejected during
decodeImageDescriptorbefore the emulated comparison could produce its measured constant-zero result.For comparison resources, the decoded descriptor now keeps
srgbDecodedisabled so its UNORM view matches the emulated comparison runtime mode. Ordinary unsupported sRGB sampling and gathering still throw, including when a descriptor is used for both comparison and ordinary sampling. The patch preserves the existing cube-wrap restriction; #3540 covers the separate 8-bit sRGB bilinear cube case.The regression coverage and implementation from jweidenh's tested commit
5377951care included with the original commit authorship preserved.Tested
agc_shader_memory_tests,agc_driver_graphics_tests,agc_driver_emulated_color_compare_tests,agc_driver_image_srgb_load_tests, andagc_driver_runtime_images_tests.agc_shader_memory,agc_driver_graphics,agc_driver_emulated_color_compare,agc_driver_image_srgb_load,agc_driver_runtime_images, andagc_driver_emulated_color_compare_srgb_decode(forced sRGB shader decode).python3 tools/check_conventions.py --base upstream/mainandgit diff --check upstream/main...HEADpassed.Checklist
main; no other open PR implements the same behaviorImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T12:51:04Z.
I followed up on Ivica’s mode-matching observation from #3540. The comparison-only sRGB fallback now also adds matching
srgbDecoderuntime modes, so the UNORM view can passRuntimeImageModeand reach the emulated compare shader. Ordinary unsupported sRGB sampling remains rejected. The amended commit is pushed; thanks for catching the missing second half of the path.Imported from boykopovar/AnyPS5. Originally posted by jweidenh on 2026-10-11T12:53:42Z.
Update before posting: this PR has advanced to
9e8b5a21bcc597e44ac5be5fa940ee765f3a923f, adding sRGB-decode runtime modes for comparisons. The mode-matching diagnosis below describes the earlierd74f6605head. I am offering the tested patch below as an alternative implementation and regression coverage; these results do not validate the new PR head, and the patch is based ond74f6605rather than the updated branch. The runtime-mode assertion in our tests checks the alternative implementation's non-decode mode, so it would need adapting if reusing the tests with the new approach.I prepared a tested correction on top of this PR's
d74f6605178265bf3c7c7476c13b5709935b080b: commit 5377951c (patch).The remaining problem in
d74f6605, from code inspection, is that moving the exception guard alone leavesdecoded.srgbDecode = true.RuntimeImageModethen compares that against emulated comparison modes whosesrgbDecodeis false. The correction excludes comparison resources when computingdecoded.srgbDecode, and keeps the original ordinary-sampling rejection:This preserves #3438's existing zero-result semantics.
ResourceTrackerseparates comparison and ordinary sampling resources, including when they use the same descriptor.The commit includes regression coverage for all 8 compare functions × point/bilinear × R8/RG8/RGBA8 sRGB, uncached and cached; cache-hit/variant assertions across UNORM → sRGB → UNORM; all four decode masks in runtime mode selection; mixed compare/sample and compare/gather refusals; and a forced-decode CTest. It preserves the current cube-wrap restriction. #3540 changes sRGB cube behavior separately, so its tests would need reconciling if that lands first.
Validated on a locally managed Linux x64 runner: GCC 13.3, Release, Mesa 25.2.8 lavapipe (LLVM 20.1.2), SPIR-V Tools enabled. Seven focused executions passed, with zero CTest skips:
agc_shader_memoryagc_driver_graphicsagc_driver_emulated_color_compareagc_driver_image_srgb_loadagc_driver_runtime_imagesagc_driver_emulated_color_compare_srgb_decodeagc_driver_runtime_images, forced decodeThe run tested
107bfac08e0186fff51baab44e7daa17f49eb5e9on base1e8fff68. The offered commit5377951cis rebased onto your PR and has the identical Git tree,f5e4c102232e578393c440db22b94169420bcaa1; no source difference is being presented as tested. Removing only the production fix reproduced the original decode refusal in 0.39 s. Restoring it passed forced comparison (4.01 s) and image-load/refusal tests (1.45 s), with clean source restoration verified. This control reproduced main's original guard, not your PR's later mode-selection failure.Focused tests can be reproduced after a Release build with:
The logs are in private validation run 38139866682, workflow
b961f70174e688da1415ae70cc2abb7323221dc3; the results above do not rely on a publicly accessible CI link. All 11 declared submodules were initialized without modifying source; the orphan ImGui gitlink on this base was left uninitialized (now fixed upstream by #3511).agc_driver_graphicsinternally skipped two heap-mirror subcases because the runner lacks the required guest-arena/write-watch/import support. No Windows, physical-GPU, full-suite, or title-startup validation is claimed. Conventions and whitespace checks passed.AI-assisted: yes (Codex).
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T13:10:34Z.
Thanks, jweidenh. I carried your tested commit
5377951cinto #3532 as82c04e402, preserving your authorship, and addeda0e3d2098to remove the runtime-mode expansion that the comparison-only decode change no longer needs. The ordinary sRGB sample/gather rejection remains in place.I rebuilt the Release targets on current
main(a11c8f7f) with GCC 12.2 and ran the focused CTest set:agc_shader_memoryagc_driver_graphicsagc_driver_emulated_color_compareagc_driver_image_srgb_loadagc_driver_runtime_imagesagc_driver_emulated_color_compare_srgb_decodeCTest reported 6/6 passed with no test-level skips. Conventions and diff checks also pass. Hosted checks are rerunning on the updated head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T13:13:20Z.
Update: hosted checks finished on
a0e3d209. Conventions, eligibility/report, Ubuntu and Intel macOS register-context/write-watch, and all three relinker jobs pass. Full Linux/Windows jobs are skipped by the contributor workflow.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T13:27:36Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libSceAgcDriver/tests/execution/EmulatedColorCompare.cppL308-309core/libs/prx/libSceAgcDriver/CMakeLists.txtL1016core/libs/prx/libSceAgcDriver/CMakeLists.txtL1016core/libs/prx/libSceAgcDriver/CMakeLists.txtL1016Imported from boykopovar/AnyPS5. Originally posted by Zurisen on 2026-10-11T19:43:54Z.
Native Windows + NVIDIA run, the configuration #3526 was reported on:
a0e3d209merged intomain4be9c255(clean), Windows 11 Home (26200), RTX 4070 Laptop (driver 596.36), WinLibs GCC 15.2.0 r7, Release, full build,ANYPS5_REQUIRE_VULKAN=1. Like the RTX 4080 in #3526, this GPU samplesVK_FORMAT_R8_SRGBand reports no format features forVK_FORMAT_R8G8_SRGB(vulkaninfo).mainmain+ this PRagc_driver_emulated_color_compareagc_driver_emulated_color_compare_srgb_decodemain)agc_shader_memoryagc_driver_graphicsagc_driver_image_srgb_loadagc_driver_runtime_imagesWith the PR the test creates all three 8-bit sRGB textures (
format=128 vk=15,format=129 vk=16through the UNORM view,format=130 vk=43) and printsemulated color compare tests passed.