fix(agc): build static rasterizer discard pipelines without fragment state #23982

Merged
chitters2004 merged 4 commits from upstream-pr/23982 into main 2026-11-29 05:12:56 +00:00
chitters2004 commented 2026-11-20 00:04:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by chitters2004 on 2026-11-20T00:04:00Z.


What

A draw that discards rasterization bakes rasterizerDiscardEnable into its pipeline. Pipeline (Graphics/src/Pipeline.cpp) still built that pipeline with the draw's fragment shader stage, its colour and depth rendering attachments and the fragment dynamic states, while Pipeline::Begin begins rendering with no attachments for discard draws. Vulkan forbids this:

  • VUID-VkGraphicsPipelineCreateInfo-pStages-06894: a fragment stage in a pipeline without fragment shader state;
  • VUID-vkCmdDraw-colorAttachmentCount-06179: the pipeline declares attachments the begun rendering does not have;
  • VUID-vkCmdDraw-None-08608: the draw sets stencil reference, depth bounds and colour write masks that the pipeline did not declare dynamic;
  • VUID-VkGraphicsPipelineCreateInfo-flags-06683: a pre-rasterization library with a null set layout under a static discard.

Two draw paths reach it: SPI_SHADER_POS_FORMAT entry 0 of zero (State.cpp), and the capture pass of tessellation followed by a geometry stage (drawTessellationGeometry in Draw.cpp, the path Crimson Desert PPSA25286 uses, #6612). The capture pass copies the real draw's state, so it carries that draw's colour targets.

The libraries also had a visible effect: the pre-rasterization library key does not include the discard flag, so a normal draw with the same shaders as an earlier discard draw reused the discard library and covered no pixels (the new test shows covered 0 of 2048 pixels on main).

A pipeline that bakes rasterizer discard is now created whole, never from libraries, without a fragment stage, without rendering attachments and without the stencil reference, depth bounds and colour write mask dynamic states. Its draws no longer set them.

Tested

  • New mock test staticDiscardPipelineTests in tests/Graphics.cpp (agc_driver_graphics): a discard pipeline is not prebuilt from libraries, is created without a fragment stage, with zero rendering attachments and without those dynamic states, and its draw sets none of them.
  • New execution test tests/execution/RasterizerDiscard.cpp (agc_driver_rasterizer_discard_render_pass and agc_driver_rasterizer_discard_libraries): draws with and without discard alternately into depth and depth+stencil targets and requires 0 covered pixels with discard and all covered pixels without.
  • Fork CI on lavapipe (Linux gate with the validation layer, and Windows), on this head (based on main c3a823624f), agc_driver_graphics, agc_driver_rasterizer_discard*, agc_driver_stencil_replay*: all passed, 0 VUID lines: https://github.com/chitters2004/AnyPS5/actions/runs/44638300584
  • Negative control, the same tests on main without the Pipeline.cpp/Pipeline.hpp change (branch draft/static-discard-control): agc_driver_graphics, agc_driver_rasterizer_discard and agc_driver_rasterizer_discard_libraries fail on Linux and Windows, with 36 VUID lines (06683, 06894, 08608, 06179): https://github.com/chitters2004/AnyPS5/actions/runs/44638358466
  • Local RTX 3080 (NVIDIA 621.24, Windows 11, validation layer 1.4.335): the 3 discard execution tests pass with the fix and 0 VUIDs (plus agc_driver_graphics, passing, without the layer); on the control the execution tests report the four VUIDs above plus VUID-vkCmdDraw-dynamicRenderingUnusedAttachments-08914.
  • python -I tools/check_conventions.py passes.

Checklist

  • Based on current main (c3a823624f); no other open PR implements the same functions (this replaces our #22058, which only added the discard flag to the pre-rasterization library key and left the invalid pipelines; it will be closed in favour of this PR)
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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 3080, driver 621.24, Windows 11 (tests with the validation layer); lavapipe (fork CI Linux and Windows); AMD RX 7900 GRE, Ryzen 7800X3D iGPU and RX Vega 56 on RADV (Mesa 26.2.6, validation layer 1.4.363), run by @tablefrogpillow in the comments; no Intel run
  • AI-assisted: yes

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Corrected rasterizer-discard behavior so draws with discard enabled produce no covered pixels, including when depth or stencil testing is active.
    • Improved handling of discarded graphics pipelines to avoid unnecessary fragment processing and attachment configuration, while preserving normal rendering when discard is disabled.
  • Tests
    • Added coverage for rasterizer-discard behavior across depth-only and depth-stencil surfaces, plus pipeline configuration checks.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5405146463 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23982). Originally posted by [chitters2004](https://github.com/chitters2004) on 2026-11-20T00:04:00Z. --- ### What A draw that discards rasterization bakes `rasterizerDiscardEnable` into its pipeline. `Pipeline` (`Graphics/src/Pipeline.cpp`) still built that pipeline with the draw's fragment shader stage, its colour and depth rendering attachments and the fragment dynamic states, while `Pipeline::Begin` begins rendering with no attachments for discard draws. Vulkan forbids this: - `VUID-VkGraphicsPipelineCreateInfo-pStages-06894`: a fragment stage in a pipeline without fragment shader state; - `VUID-vkCmdDraw-colorAttachmentCount-06179`: the pipeline declares attachments the begun rendering does not have; - `VUID-vkCmdDraw-None-08608`: the draw sets stencil reference, depth bounds and colour write masks that the pipeline did not declare dynamic; - `VUID-VkGraphicsPipelineCreateInfo-flags-06683`: a pre-rasterization library with a null set layout under a static discard. Two draw paths reach it: `SPI_SHADER_POS_FORMAT` entry 0 of zero (`State.cpp`), and the capture pass of tessellation followed by a geometry stage (`drawTessellationGeometry` in `Draw.cpp`, the path Crimson Desert PPSA25286 uses, #6612). The capture pass copies the real draw's state, so it carries that draw's colour targets. The libraries also had a visible effect: the pre-rasterization library key does not include the discard flag, so a normal draw with the same shaders as an earlier discard draw reused the discard library and covered no pixels (the new test shows `covered 0 of 2048 pixels` on main). A pipeline that bakes rasterizer discard is now created whole, never from libraries, without a fragment stage, without rendering attachments and without the stencil reference, depth bounds and colour write mask dynamic states. Its draws no longer set them. ### Tested - New mock test `staticDiscardPipelineTests` in `tests/Graphics.cpp` (`agc_driver_graphics`): a discard pipeline is not prebuilt from libraries, is created without a fragment stage, with zero rendering attachments and without those dynamic states, and its draw sets none of them. - New execution test `tests/execution/RasterizerDiscard.cpp` (`agc_driver_rasterizer_discard_render_pass` and `agc_driver_rasterizer_discard_libraries`): draws with and without discard alternately into depth and depth+stencil targets and requires 0 covered pixels with discard and all covered pixels without. - Fork CI on lavapipe (Linux gate with the validation layer, and Windows), on this head (based on main c3a823624f9), `agc_driver_graphics`, `agc_driver_rasterizer_discard*`, `agc_driver_stencil_replay*`: all passed, 0 VUID lines: https://github.com/chitters2004/AnyPS5/actions/runs/44638300584 - Negative control, the same tests on main without the `Pipeline.cpp`/`Pipeline.hpp` change (branch `draft/static-discard-control`): `agc_driver_graphics`, `agc_driver_rasterizer_discard` and `agc_driver_rasterizer_discard_libraries` fail on Linux and Windows, with 36 VUID lines (06683, 06894, 08608, 06179): https://github.com/chitters2004/AnyPS5/actions/runs/44638358466 - Local RTX 3080 (NVIDIA 621.24, Windows 11, validation layer 1.4.335): the 3 discard execution tests pass with the fix and 0 VUIDs (plus `agc_driver_graphics`, passing, without the layer); on the control the execution tests report the four VUIDs above plus `VUID-vkCmdDraw-dynamicRenderingUnusedAttachments-08914`. - `python -I tools/check_conventions.py` passes. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main` (c3a823624f9); no other open PR implements the same functions (this replaces our #22058, which only added the discard flag to the pre-rasterization library key and left the invalid pipelines; it will be closed in favour of this PR) - [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) and the licence notice of code adapted from upstream (see AGENTS.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 3080, driver 621.24, Windows 11 (tests with the validation layer); lavapipe (fork CI Linux and Windows); AMD RX 7900 GRE, Ryzen 7800X3D iGPU and RX Vega 56 on RADV (Mesa 26.2.6, validation layer 1.4.363), run by @tablefrogpillow in the comments; no Intel run - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Corrected rasterizer-discard behavior so draws with discard enabled produce no covered pixels, including when depth or stencil testing is active. * Improved handling of discarded graphics pipelines to avoid unnecessary fragment processing and attachment configuration, while preserving normal rendering when discard is disabled. * **Tests** * Added coverage for rasterizer-discard behavior across depth-only and depth-stencil surfaces, plus pipeline configuration checks. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
MarcZX10 commented 2026-11-20 06:35:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T06:35:27Z.

Review: COMMENTED


Reviewed — comments

The pipeline changes address the reported static-discard mismatch; one integration detail needs clarification because the new execution-test target is not registered in the changed CMake fragment.

What I ran

  • Reviewed head 4867f6e79a0244df6c889606ef5ba423a66af491 using the pinned repository reader repo_read.py.
  • No build or tests run in this review. The CI and hardware results in the PR description are author-reported.

Results

Check Result Note
Changed code review passed Pipeline and test changes inspected
Build and tests not run No local execution performed
Reported CI not run Results supplied in the description

Findings

Blocking

None.

Non-blocking

  • core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_rasterizer_discard_tests.cmake:2 and :4 register tests that invoke agc_driver_rasterizer_discard_tests, but the changed files do not define or add that executable. The tests/execution/RasterizerDiscard.cpp source therefore depends on target registration elsewhere; clarify where that target is created or add it to the test target configuration so these CTest entries are runnable.

Not verified

  • Graphics.cpp was read only at the changed regions; its unchanged contents were not reviewed. The source file is included in the review manifest but was too large for the review folder.
  • The files.json document was not available as a reader path; changed-file inclusion status was obtained from the reader’s file listing. All other changed files listed in the manifest were read.
  • No local compilation, CTest execution, Vulkan validation run, or console run was performed. CI and hardware results listed in description.md were not independently verified.

To get this to a good state

Nothing is required. Optional: clarify or add the executable target backing the two new CTest entries.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5988504491 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23982#pullrequestreview-5988504491). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T06:35:27Z. **Review:** COMMENTED --- # Reviewed — comments The pipeline changes address the reported static-discard mismatch; one integration detail needs clarification because the new execution-test target is not registered in the changed CMake fragment. ## What I ran - Reviewed head `4867f6e79a0244df6c889606ef5ba423a66af491` using the pinned repository reader `repo_read.py`. - No build or tests run in this review. The CI and hardware results in the PR description are author-reported. ## Results | Check | Result | Note | |---|---|---| | Changed code review | passed | Pipeline and test changes inspected | | Build and tests | not run | No local execution performed | | Reported CI | not run | Results supplied in the description | ## Findings ### Blocking None. ### Non-blocking - `core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_rasterizer_discard_tests.cmake:2` and `:4` register tests that invoke `agc_driver_rasterizer_discard_tests`, but the changed files do not define or add that executable. The `tests/execution/RasterizerDiscard.cpp` source therefore depends on target registration elsewhere; clarify where that target is created or add it to the test target configuration so these CTest entries are runnable. ## Not verified - `Graphics.cpp` was read only at the changed regions; its unchanged contents were not reviewed. The source file is included in the review manifest but was too large for the review folder. - The `files.json` document was not available as a reader path; changed-file inclusion status was obtained from the reader’s file listing. All other changed files listed in the manifest were read. - No local compilation, CTest execution, Vulkan validation run, or console run was performed. CI and hardware results listed in `description.md` were not independently verified. ## To get this to a good state Nothing is required. Optional: clarify or add the executable target backing the two new CTest entries.
MarcZX10 commented 2026-11-20 21:42:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T21:42:10Z.

Review: COMMENTED


Reviewed — no blocking findings

The inspected pipeline changes and targeted tests are consistent with the stated fix; I did not run the reported CI or local checks, and the full text of some changed files was not read.

What I ran

  • Reviewed head b49dd669de1609e8dbebb56362f4c666d9b17e7b using repo_read.py to inspect the prepared diff, manifest, changed-file excerpts, and targeted repository context.
  • No build, tests, or prechecks were run in this review.

Results

Check Result Note
Diff and targeted code review passed No concrete defect found in inspected code
Build and tests not run CI and hardware results are author-reported
Full changed-file review not run Some complete file texts were not read

Findings

Blocking

None found in the inspected code.

Non-blocking

None.

Not verified

The full text of Graphics/src/Pipeline.cpp, Graphics/include/Pipeline.hpp, tests/execution/DepthFastClearHarness.hpp, and the large tests/Graphics.cpp was not read; targeted changed sections were inspected. No tests, build, or prechecks were run by me. CI and hardware results in the PR description were not independently verified. files.json was not available in the prepared bundle listing, so excluded-by-rule files could not be confirmed.

Files read: review/description.md, review/commits.md, review/manifest.json, review/diff.patch; targeted lines of Graphics/src/Pipeline.cpp, tests/Graphics.cpp, and tests/execution/DepthFastClearHarness.hpp; and the full added tests/cmake/agc_driver_rasterizer_discard_tests.cmake and tests/execution/RasterizerDiscard.cpp as shown in the diff.

Files excluded: tests/Graphics.cpp full text (too large for the review folder); excluded-by-rule files not verified.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5999783612 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23982#pullrequestreview-5999783612). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T21:42:10Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The inspected pipeline changes and targeted tests are consistent with the stated fix; I did not run the reported CI or local checks, and the full text of some changed files was not read. ## What I ran - Reviewed head `b49dd669de1609e8dbebb56362f4c666d9b17e7b` using `repo_read.py` to inspect the prepared diff, manifest, changed-file excerpts, and targeted repository context. - No build, tests, or prechecks were run in this review. ## Results | Check | Result | Note | |---|---|---| | Diff and targeted code review | passed | No concrete defect found in inspected code | | Build and tests | not run | CI and hardware results are author-reported | | Full changed-file review | not run | Some complete file texts were not read | ## Findings ### Blocking None found in the inspected code. ### Non-blocking None. ## Not verified The full text of `Graphics/src/Pipeline.cpp`, `Graphics/include/Pipeline.hpp`, `tests/execution/DepthFastClearHarness.hpp`, and the large `tests/Graphics.cpp` was not read; targeted changed sections were inspected. No tests, build, or prechecks were run by me. CI and hardware results in the PR description were not independently verified. `files.json` was not available in the prepared bundle listing, so excluded-by-rule files could not be confirmed. Files read: `review/description.md`, `review/commits.md`, `review/manifest.json`, `review/diff.patch`; targeted lines of `Graphics/src/Pipeline.cpp`, `tests/Graphics.cpp`, and `tests/execution/DepthFastClearHarness.hpp`; and the full added `tests/cmake/agc_driver_rasterizer_discard_tests.cmake` and `tests/execution/RasterizerDiscard.cpp` as shown in the diff. Files excluded: `tests/Graphics.cpp` full text (too large for the review folder); excluded-by-rule files not verified. ## To get this to a good state Nothing is required.
MarcZX10 commented 2026-11-21 02:48:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T02:48:53Z.

Review: COMMENTED


Reviewed — no blocking findings

The inspected pipeline changes address the stated static rasterizer discard issues; one changed test file was excluded from the review bundle, so approval is not justified.

What I ran

  • Read the prepared description, commits, manifest and diff for head 25485af4adc9441c294e274787fc4eb615464214.
  • Read changed pipeline implementation/header, execution harness, execution test and CMake test registration through repo_read.py.
  • No commands or tests were run. The PR description reports CI and local test results; these were not independently run here.

Results

Check Result Note
Static discard pipeline logic passed Whole pipeline, fragment stage removed, attachment metadata cleared
Execution test and registration passed Discard alternation and depth/stencil targets inspected
Full changed-file review not run Graphics.cpp was excluded as too large
Runtime checks not run Reported CI and hardware runs not repeated

Findings

Blocking

None.

Non-blocking

None.

Not verified

The changed core/libs/prx/libSceAgcDriver/tests/Graphics.cpp was not included in the prepared files because it exceeded the bundle limit. Its new test body was therefore not read. No builds, tests, validation-layer runs, or console behavior were independently verified. files.json was not available through the reader; the manifest identifies Graphics.cpp as excluded due to size. The provided diff.patch omits lockfiles, minified files, generated directories, and SVG files by preparation rule.

To get this to a good state

Review the excluded Graphics.cpp test changes and rerun the relevant checks on this head before approval.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6002366376 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23982#pullrequestreview-6002366376). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T02:48:53Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The inspected pipeline changes address the stated static rasterizer discard issues; one changed test file was excluded from the review bundle, so approval is not justified. ## What I ran - Read the prepared description, commits, manifest and diff for head `25485af4adc9441c294e274787fc4eb615464214`. - Read changed pipeline implementation/header, execution harness, execution test and CMake test registration through `repo_read.py`. - No commands or tests were run. The PR description reports CI and local test results; these were not independently run here. ## Results | Check | Result | Note | |---|---|---| | Static discard pipeline logic | passed | Whole pipeline, fragment stage removed, attachment metadata cleared | | Execution test and registration | passed | Discard alternation and depth/stencil targets inspected | | Full changed-file review | not run | `Graphics.cpp` was excluded as too large | | Runtime checks | not run | Reported CI and hardware runs not repeated | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The changed `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` was not included in the prepared files because it exceeded the bundle limit. Its new test body was therefore not read. No builds, tests, validation-layer runs, or console behavior were independently verified. `files.json` was not available through the reader; the manifest identifies `Graphics.cpp` as excluded due to size. The provided `diff.patch` omits lockfiles, minified files, generated directories, and SVG files by preparation rule. ## To get this to a good state Review the excluded `Graphics.cpp` test changes and rerun the relevant checks on this head before approval.
MarcZX10 commented 2026-11-27 20:58:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T20:58:04Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the implementation addresses the invalid static-discard pipeline state and adds regression coverage.

What I ran

Reviewed head 9429505033649a36bb6282c30b1299c4494247c2. I did not run commands or tests; repo_read.py was used to inspect the prepared diff and targeted source ranges.

Results

Check Result Note
Source review passed Pipeline changes and included tests inspected
Tests not run CI and hardware results are author-reported
Negative control not run Only author-reported results available

Findings

Blocking

None.

Non-blocking

None.

Not verified

The complete body of tests/Graphics.cpp was not read; only the changed ranges were inspected. No test execution, Vulkan validation, hardware behavior, or CI result was independently verified. The author reports successful CI and hardware runs in the PR description.

To get this to a good state

Nothing is required.

Files read: review/description.md, review/commits.md, review/manifest.json, review/diff.patch; all changed files in the manifest were inspected, with only changed ranges read for tests/Graphics.cpp. review/files.json was unavailable via the reader; the changed-file inclusion list was checked with its directory listing.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6093291766 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23982#pullrequestreview-6093291766). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-27T20:58:04Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the implementation addresses the invalid static-discard pipeline state and adds regression coverage. ## What I ran Reviewed head `9429505033649a36bb6282c30b1299c4494247c2`. I did not run commands or tests; `repo_read.py` was used to inspect the prepared diff and targeted source ranges. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | Pipeline changes and included tests inspected | | Tests | not run | CI and hardware results are author-reported | | Negative control | not run | Only author-reported results available | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The complete body of `tests/Graphics.cpp` was not read; only the changed ranges were inspected. No test execution, Vulkan validation, hardware behavior, or CI result was independently verified. The author reports successful CI and hardware runs in the PR description. ## To get this to a good state Nothing is required. Files read: `review/description.md`, `review/commits.md`, `review/manifest.json`, `review/diff.patch`; all changed files in the manifest were inspected, with only changed ranges read for `tests/Graphics.cpp`. `review/files.json` was unavailable via the reader; the changed-file inclusion list was checked with its directory listing.
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!23982
No description provided.