fix(agc): set color write masks per draw through dynamic state #16572

Merged
oneandonlydean merged 3 commits from upstream-pr/16572 into main 2026-11-11 00:34:15 +00:00
oneandonlydean commented 2026-11-07 05:49:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-11-07T05:49:23Z.


What

A pipeline took the color write masks of the draw that built it into its blend attachments, so draws that differed only in their masks each built a pipeline (or a fragment output library and a linked pipeline). With two color targets whose masks differ, for example one the pixel shader does not write, the attachments differ, and the validation layer reports VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 when independentBlend is not enabled.

When the device supports VK_EXT_extended_dynamic_state3 colorWriteMask, the masks are now dynamic state. They are zero in the pipeline and left out of the pipeline and fragment output library keys. Every begin, continue, back-face and second-channel pass sets them from the draw's masked state: outputs the pixel shader lacks are masked, and the split alpha pass of an 8_8 target writes only green. Devices without the feature keep the masks in the pipeline as before, and APS5_NO_DYNAMIC_COLOR_WRITE_MASK=1 selects that path (documented in docs/dev/ENVIRONMENT.md).

The new agc_driver_color_write_mask_dynamic test draws with different masks, an unwritten second target and a split alpha target. It checks the pixels, that no pipeline is built or linked for a mask change, and the masks each recorded draw sets.

Tested

Linux 7.2.3, NVIDIA GeForce RTX 4090, driver 610.57.04, Release, BUILD_TESTING=ON, with VK_LAYER_KHRONOS_validation.

  • Full ^agc_ suite: this branch 1327/1327 passed, main d48f11ab16 1326/1326. pAttachments-00605 reports drop from 18 on main to 4. The 4 left are all in agc_driver_srgb8_color_target and come from blend state other than the masks, so they are out of scope here.
  • agc_driver_color_write_mask_dynamic on this head: passes with the dynamic path (0 validation errors) and with APS5_NO_DYNAMIC_COLOR_WRITE_MASK=1 (0 validation errors).
  • Negative controls: the test fails when the masks are not set on a continued draw, when a target the shader does not write is not masked, and when the second-channel pass mask is not set. Leaving the real masks in the pipeline is caught only by the validation count, not by the test.
  • One paired A/B against main on PPSA21564 (same machine and scene, warm-up per arm, 180 s each): no regression in fps or per-draw time; the difference is inside main's own run-to-run spread, so no speedup is claimed.
  • Not tested on Windows or on AMD.

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
  • 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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 4090, driver 610.57.04, Linux 7.2.3
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5198889483 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16572). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-11-07T05:49:23Z. --- ### What A pipeline took the color write masks of the draw that built it into its blend attachments, so draws that differed only in their masks each built a pipeline (or a fragment output library and a linked pipeline). With two color targets whose masks differ, for example one the pixel shader does not write, the attachments differ, and the validation layer reports `VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605` when `independentBlend` is not enabled. When the device supports `VK_EXT_extended_dynamic_state3` `colorWriteMask`, the masks are now dynamic state. They are zero in the pipeline and left out of the pipeline and fragment output library keys. Every begin, continue, back-face and second-channel pass sets them from the draw's masked state: outputs the pixel shader lacks are masked, and the split alpha pass of an 8_8 target writes only green. Devices without the feature keep the masks in the pipeline as before, and `APS5_NO_DYNAMIC_COLOR_WRITE_MASK=1` selects that path (documented in `docs/dev/ENVIRONMENT.md`). The new `agc_driver_color_write_mask_dynamic` test draws with different masks, an unwritten second target and a split alpha target. It checks the pixels, that no pipeline is built or linked for a mask change, and the masks each recorded draw sets. ### Tested Linux 7.2.3, NVIDIA GeForce RTX 4090, driver 610.57.04, Release, `BUILD_TESTING=ON`, with `VK_LAYER_KHRONOS_validation`. - Full `^agc_` suite: this branch 1327/1327 passed, main `d48f11ab16` 1326/1326. `pAttachments-00605` reports drop from 18 on main to 4. The 4 left are all in `agc_driver_srgb8_color_target` and come from blend state other than the masks, so they are out of scope here. - `agc_driver_color_write_mask_dynamic` on this head: passes with the dynamic path (0 validation errors) and with `APS5_NO_DYNAMIC_COLOR_WRITE_MASK=1` (0 validation errors). - Negative controls: the test fails when the masks are not set on a continued draw, when a target the shader does not write is not masked, and when the second-channel pass mask is not set. Leaving the real masks in the pipeline is caught only by the validation count, not by the test. - One paired A/B against main on PPSA21564 (same machine and scene, warm-up per arm, 180 s each): no regression in fps or per-draw time; the difference is inside main's own run-to-run spread, so no speedup is claimed. - Not tested on Windows or on AMD. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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 under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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] Fixes: none - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 4090, driver 610.57.04, Linux 7.2.3 - [x] AI-assisted: yes
gabichuuuuu commented 2026-11-07 14:41:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-07T14:41:02Z.

Review: COMMENTED


A Windows NVIDIA run, the cell the description lists as not tested, on Turing.

Setup: Windows 11 x64, NVIDIA laptop GPU (Turing), driver 610, WinLibs GCC 15.2.0 r7 UCRT, Release, every AGC execution test built. Head ac4ac99bb2 merged onto main 4e44ed59b2 (clean merge), with main 4e44ed59b2 from the same build directory as the control. ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1, Selected GPU was the NVIDIA GPU. No validation layer on this machine.

  • agc_driver_color_write_mask_dynamic passes in 9 of 9 runs and takes the full dynamic path: color write mask tests passed (dynamic write mask, pipeline libraries, recorded draws). So this driver exposes extendedDynamicState3ColorWriteMask.
  • With APS5_NO_DYNAMIC_COLOR_WRITE_MASK=1 it passes on the baked path: (write mask in the pipeline, pipeline libraries, no recorded draws).
  • agc_driver_pipeline_journal, agc_pipeline_journal, _long_paths and _extended_paths pass 4 of 4 on main and 5 of 5 with this PR.
  • agc_driver_recorder passes 4 of 4 on main and 9 of 10 with this PR. The one failure was a 30 s timeout. In the five extra runs, two took about 17 s instead of 2 s, and color_write_mask_dynamic in the same runs took 15 s instead of 0.6 s. main showed the same kind of stall once (15 s), so I read it as this machine stalling rather than the change.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5812899168 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16572#pullrequestreview-5812899168). Originally posted by [gabichuuuuu](https://github.com/gabichuuuuu) on 2026-11-07T14:41:02Z. **Review:** COMMENTED --- A Windows NVIDIA run, the cell the description lists as not tested, on Turing. **Setup:** Windows 11 x64, NVIDIA laptop GPU (Turing), driver 610, WinLibs GCC 15.2.0 r7 UCRT, Release, every AGC execution test built. Head `ac4ac99bb2` merged onto `main` `4e44ed59b2` (clean merge), with `main` `4e44ed59b2` from the same build directory as the control. `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1`, `Selected GPU` was the NVIDIA GPU. No validation layer on this machine. - `agc_driver_color_write_mask_dynamic` passes in 9 of 9 runs and takes the full dynamic path: `color write mask tests passed (dynamic write mask, pipeline libraries, recorded draws)`. So this driver exposes `extendedDynamicState3ColorWriteMask`. - With `APS5_NO_DYNAMIC_COLOR_WRITE_MASK=1` it passes on the baked path: `(write mask in the pipeline, pipeline libraries, no recorded draws)`. - `agc_driver_pipeline_journal`, `agc_pipeline_journal`, `_long_paths` and `_extended_paths` pass 4 of 4 on `main` and 5 of 5 with this PR. - `agc_driver_recorder` passes 4 of 4 on `main` and 9 of 10 with this PR. The one failure was a 30 s timeout. In the five extra runs, two took about 17 s instead of 2 s, and `color_write_mask_dynamic` in the same runs took 15 s instead of 0.6 s. `main` showed the same kind of stall once (15 s), so I read it as this machine stalling rather than the change. 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!16572
No description provided.