feat(agc): blend into an unclamped normalized color target in the pixel shader #11684

Merged
oneandonlydean merged 12 commits from upstream-pr/11684 into main 2026-10-29 07:48:48 +00:00
oneandonlydean commented 2026-10-27 02:41:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-27T02:41:57Z.


What

A draw that enabled color blending into an unclamped normalized color target (UNORM/SNORM with the unclamped blend mode) used to be refused with "blending unclamped normalized color is not implemented". The draw's blend is now done in the pixel shader, on a float storage view of the target, inside the pixel-interlock section, and clamped to the format's range ([0, 1] or [-1, 1]) only at the end.

  • The pixel request carries a blended normalized-target merge (factors, operations, write mask, signedness); TargetMerge/TargetBlend add their fields to the cache key, the snapshot hash, the draw lookup and the request serializer only when blending is enabled, so keys, hashes and serialized bytes of every other draw are identical (the blend flag is bit 16 of the old merge mask word, which an older reader rejects instead of misreading).
  • Same-draw overdraw is in primitive order (the interlock), masked channels keep the destination, SRC_ALPHA_SATURATE, MIN and MAX follow Vulkan.
  • Refused with a message, as before: multisampled, packed, reversed or alternate-order targets, dual-source blending, a signed blend that skips a component, and a device without fragmentShaderPixelInterlock.

agc_driver_unclamped_normalized_blend is the new execution test: it blends 14 UNORM and 4 SNORM draws against a float oracle (with channels outside the write mask required to be exact), two same-draw overdraws of 16 layers each, the request bytes, the cache key and the masks, and the refusal without pixel interlock. docs/dev/debt/libSceAgcDriver.md records the path.

Tested

  • Linux, Intel i9-14900KF, NVIDIA GeForce RTX 4090 (driver 610.57.04), on main 0bad0fc46a: build of the eight test executables of the bar, rc 0; ctest -R '^(agc_driver_unclamped_normalized_blend|agc_driver_graphics|agc_shader_memory|request_serializer|agc_shader_disk_cache|agc_pipeline_journal|agc_driver_pipeline_journal|agc_driver_packed_unorm4444_partial_write|agc_driver_packed_unorm4444_multisample_partial_write|public_headers)': 77 of 77 passed. agc_driver_unclamped_normalized_blend prints "14 UNORM draws, 4 SNORM draws, 2 same-draw overdraws of 16 layers, 1 refusal without pixel interlock"; with VK_LAYER_KHRONOS_validation it reports no validation error, only Undefined-Value-ShaderOutputNotConsumed-DynamicRendering warnings (the attachment is unbound or masked).
  • Replay of 440 recorded request dumps, main against an earlier revision of this branch (before the rebase onto the current main), in both modes: stdout and the 222 SPIR-V modules are byte-identical except the shader-disk-cache source-version line, which changes on every recompiler commit.
  • A bring-up run of a title that uses this path (400 s per arm, RTX 4090, main against this branch, driver cache on): no regression (0 Xid and 0 validation errors; this branch 14.26 fps and 19.7 GB peak memory, main 14.33 fps and 19.0 GB; run on an earlier revision of the branch based on an older main). The blend itself is not observable in that scene (all frames are black on main too), so this shows no regression, not the fix.
  • A short two-scene gate against main (earlier revision, older main): every check passed except one visual check at +20 s (43.8 against a limit of 40); the frames differ by about 0.7 s of timing (camera and animation phase) with the same geometry, colours and fades, and no corruption, so it was accepted as timing noise. That scene has no blended UI or fade either.
  • Not run: Windows, macOS, AMD or Intel GPUs, a title scene that shows the blend.
  • Not a performance change.

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 under Silent stubs in their library's technical debt file (none added)
  • 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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 4090, driver 610.57.04, Linux
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5027757514 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11684). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-27T02:41:57Z. --- ### What A draw that enabled color blending into an unclamped normalized color target (UNORM/SNORM with the unclamped blend mode) used to be refused with "blending unclamped normalized color is not implemented". The draw's blend is now done in the pixel shader, on a float storage view of the target, inside the pixel-interlock section, and clamped to the format's range (`[0, 1]` or `[-1, 1]`) only at the end. - The pixel request carries a blended normalized-target merge (factors, operations, write mask, signedness); `TargetMerge`/`TargetBlend` add their fields to the cache key, the snapshot hash, the draw lookup and the request serializer only when blending is enabled, so keys, hashes and serialized bytes of every other draw are identical (the blend flag is bit 16 of the old merge mask word, which an older reader rejects instead of misreading). - Same-draw overdraw is in primitive order (the interlock), masked channels keep the destination, `SRC_ALPHA_SATURATE`, `MIN` and `MAX` follow Vulkan. - Refused with a message, as before: multisampled, packed, reversed or alternate-order targets, dual-source blending, a signed blend that skips a component, and a device without `fragmentShaderPixelInterlock`. `agc_driver_unclamped_normalized_blend` is the new execution test: it blends 14 UNORM and 4 SNORM draws against a float oracle (with channels outside the write mask required to be exact), two same-draw overdraws of 16 layers each, the request bytes, the cache key and the masks, and the refusal without pixel interlock. `docs/dev/debt/libSceAgcDriver.md` records the path. ### Tested - Linux, Intel i9-14900KF, NVIDIA GeForce RTX 4090 (driver 610.57.04), on main `0bad0fc46a`: build of the eight test executables of the bar, rc 0; `ctest -R '^(agc_driver_unclamped_normalized_blend|agc_driver_graphics|agc_shader_memory|request_serializer|agc_shader_disk_cache|agc_pipeline_journal|agc_driver_pipeline_journal|agc_driver_packed_unorm4444_partial_write|agc_driver_packed_unorm4444_multisample_partial_write|public_headers)'`: 77 of 77 passed. `agc_driver_unclamped_normalized_blend` prints "14 UNORM draws, 4 SNORM draws, 2 same-draw overdraws of 16 layers, 1 refusal without pixel interlock"; with `VK_LAYER_KHRONOS_validation` it reports no validation error, only `Undefined-Value-ShaderOutputNotConsumed-DynamicRendering` warnings (the attachment is unbound or masked). - Replay of 440 recorded request dumps, main against an earlier revision of this branch (before the rebase onto the current main), in both modes: stdout and the 222 SPIR-V modules are byte-identical except the shader-disk-cache source-version line, which changes on every recompiler commit. - A bring-up run of a title that uses this path (400 s per arm, RTX 4090, main against this branch, driver cache on): no regression (0 Xid and 0 validation errors; this branch 14.26 fps and 19.7 GB peak memory, main 14.33 fps and 19.0 GB; run on an earlier revision of the branch based on an older main). The blend itself is not observable in that scene (all frames are black on main too), so this shows no regression, not the fix. - A short two-scene gate against main (earlier revision, older main): every check passed except one visual check at +20 s (43.8 against a limit of 40); the frames differ by about 0.7 s of timing (camera and animation phase) with the same geometry, colours and fades, and no corruption, so it was accepted as timing noise. That scene has no blended UI or fade either. - Not run: Windows, macOS, AMD or Intel GPUs, a title scene that shows the blend. - Not a performance change. ### 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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's technical debt file (none added) - [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 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 4090, driver 610.57.04, Linux - [x] AI-assisted: yes
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!11684
No description provided.