Skip to content

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

Merged
oneandonlydean merged 4 commits into
boykopovar:mainfrom
chitters2004:fix/static-discard-pipelines
Nov 29, 2026
Merged

oneandonlydean merged 4 commits into
boykopovar:mainfrom
chitters2004:fix/static-discard-pipelines

Conversation

@chitters2004

@chitters2004 chitters2004 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

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 c3a8236), 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 (c3a8236); no other open PR implements the same functions (this replaces our fix(agc): key the pre-rasterization library by rasterizer discard #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.

…state

A draw that discards rasterization (SPI_SHADER_POS_FORMAT entry 0 of zero,
or the tessellation capture pass of a tessellation plus geometry draw)
baked rasterizerDiscardEnable into a pipeline that still carried the
draw's fragment shader, colour and depth attachments and fragment dynamic
states, and into pipeline libraries whose pre-rasterization part cannot
take null set layouts under a static discard. Vulkan forbids a fragment
stage when the pipeline has no fragment shader state
(VUID-VkGraphicsPipelineCreateInfo-pStages-06894), the begun rendering had
no attachments while the pipeline declared them
(VUID-vkCmdDraw-colorAttachmentCount-06179), and the draw set stencil
reference, depth bounds and colour write masks the pipeline did not make
dynamic (VUID-vkCmdDraw-None-08608).

A pipeline that bakes rasterizer discard is now created whole, without a
fragment stage, rendering attachments or those dynamic states, and its
draws no longer set them. It is no longer built from pipeline libraries.
@tablefrogpillow

Copy link
Copy Markdown
Contributor

AMD datapoint, since the PR has no AMD run. I ran the new agc_driver_rasterizer_discard_tests binary on RADV for this head (4867f6e79a). The control is the same build with Graphics/src/Pipeline.cpp and Graphics/include/Pipeline.hpp reverted to the merge base c3a823624f9.

Environment: Mesa 26.2.6 RADV, Khronos validation layer 1.4.363, ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_LOADER_DEBUG=layer. Each log shows Insert instance layer "VK_LAYER_KHRONOS_validation" and no was not found. I ran the binary directly with each ctest environment: APS5_NO_GPL=1 (_render_pass) and the default (_libraries). Each cell is 3 runs, and the result was the same every time.

GPU PR, _render_pass PR, _libraries control, _render_pass control, _libraries
RX 7900 GRE (NAVI31, gfx1100) pass, 0 VUID pass, 0 VUID exit 0, but logs 06894 + 08608 fail covered 0 of 2048 pixels; logs 06683 + 08608 + 06179
Ryzen 7800X3D iGPU (RAPHAEL, gfx1036) pass, 0 VUID pass, 0 VUID exit 0, but logs 06894 + 08608 fail covered 0 of 2048 pixels; logs 06683 + 08608 + 06179
RX Vega 56 (VEGA10, gfx900) pass, 0 VUID pass, 0 VUID exit 0, but logs 06894 + 08608 fail covered 0 of 2048 pixels; logs 06683 + 08608 + 06179

The PR head also passes on Vega without the validation layer, once in each mode.

On RADV the control's _render_pass (no-GPL) case exits 0. ctest would show it as Passed, and the only sign of the bug in that mode is the 06894/08608 validation errors. The library-reuse effect (covered 0 of 2048) appears on all three AMD generations.

@chitters2004

Copy link
Copy Markdown
Contributor Author

Thank you @tablefrogpillow, that is the AMD coverage this PR was missing, on three generations.

The _render_pass result matches our CI control: on main it also passes on lavapipe (Linux and Windows, https://github.com/chitters2004/AnyPS5/actions/runs/44638358466). Without pipeline libraries the bug draws nothing wrong; the discard pipeline is only invalid (fragment stage, attachments and dynamic states it must not have), so the execution test can only see it through the validation layer. The case that fails on main without a layer is the mock test agc_driver_graphics (staticDiscardPipelineTests), which checks the created pipeline directly: no fragment stage, no rendering attachments, none of those dynamic states.

I've added your runs to the tested GPUs in the description.

AI-assisted: yes

@github-actions github-actions Bot added build agc libSceAgc* labels Nov 20, 2026

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 20, 2026
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

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.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 20519 core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp L723
PR 27734 core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp L1026-1027

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 1395 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 4040 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 5609 core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
PR 5925 core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6235 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6280 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6481 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6808 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 7256 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 7275 core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
PR 7642 core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 8246 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9335 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9356 core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9387 core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9508 core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9712 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9895 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/libs/prx/libSceAgcDriver/tests/execution/DepthFastClearHarness.hpp
PR 9897 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9915 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 10193 core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 10351 core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 11551 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 11825 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 13928 core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 13929 core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 14032 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 14473 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 14944 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 15343 core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp
PR 15570 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 17056 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 17611 core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 19821 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 20010 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 20153 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 20728 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 20845 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 21960 core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 22424 core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
PR 23252 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 23258 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 23281 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 23553 core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp
PR 23818 core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 24049 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 24083 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 24327 core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/libs/prx/libSceAgcDriver/tests/execution/DepthFastClearHarness.hpp
PR 24781 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 25534 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 25557 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 26084 core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 26197 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 26630 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 26706 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 27698 core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 28142 core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp

@janzezno

Copy link
Copy Markdown
Contributor

@chitters2004 #24305 (gates the interlock pipeline workarounds on RADV from Mesa 26.3.1) touches two of the lines you change in Graphics/src/Pipeline.cpp:

  • in the libraryKeys early return, FragmentInterlock(shaders) becomes AvoidsInterlockEpilog(context, shaders), and you add state.rasterizerDiscard;
  • in the dynamicColorWriteMask initialiser of the Pipeline constructor, !FragmentInterlock(shaders) becomes !AvoidsInterlockEpilog(context, shaders), and you add && !state.rasterizerDiscard.

Both conflicts are textual and resolve by keeping both conditions. I'd suggest yours goes first since it was opened first, and I'll rebase onto it. Does that work for you? I'll record the order in both PR bodies.

@chitters2004

Copy link
Copy Markdown
Contributor Author

@janzezno that works for me, thanks for checking. Keeping both conditions in both places is the right resolution.

@MarcZX10 on the test target: agc_driver_rasterizer_discard_tests comes from the execution-test glob in core/libs/prx/libSceAgcDriver/CMakeLists.txt:713-724, which builds one agc_driver_<name>_tests executable per tests/execution/*.cpp, so tests/execution/RasterizerDiscard.cpp defines it. The fragment in tests/cmake/ only registers its CTest entries, like the other execution-test fragments.

AI-assisted: yes

# Conflicts:
#	core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
#	core/libs/prx/libSceAgcDriver/tests/execution/DepthFastClearHarness.hpp

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 20, 2026
# Conflicts:
#	core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@throny

throny commented Nov 22, 2026

Copy link
Copy Markdown

GPU test run: ✅ no new failures or validation errors on Windows / NVIDIA

Basis: built and ran · this PR's head 25485af4ad merged onto main 851212fb98 · Windows 11 Pro 26300, RTX 4080 (10de:2704, driver 610.88, subgroup 32), WinLibs GCC 15.2.0 r7, Release

Checked

  • The agc_* tests tools/select_tests.py selects for this change: 2058 of 2059 passed, run with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer (Khronos validation layer, nightly 1.4.369, newer than the 1.4.335 minimum).
  • The loader logged Insert instance layer "VK_LAYER_KHRONOS_validation" 1893 times and never was not found but was requested by env var VK_INSTANCE_LAYERS.
  • 0 VUID- messages, the same as a full agc_* run of main 851212fb98 on this machine with the same settings.
  • The failure is agc_driver_store_over_untracked, which also fails intermittently on main here (agc_driver_store_over_untracked is flaky on Windows: the second-store case sometimes finds no saved guest bytes #22670), not this change.
  • New in this PR, passing on NVIDIA: agc_driver_rasterizer_discard, agc_driver_rasterizer_discard_libraries, agc_driver_rasterizer_discard_render_pass.

Findings: none from this run; this is a GPU run, not a code review.

AI-assisted test run (Claude Code) · head 25485af4ad · base main 851212fb98

@Helldiverr

Copy link
Copy Markdown
Contributor

Verdict: on an AMD R9700 under Windows, the six focused tests pass 3 of 3 on the merge, with 0 VUID-. With main's Pipeline.cpp and Pipeline.hpp, three of them fail 3 of 3: a draw after a discard draw covers 0 pixels, and each run logs 36 VUID- lines.

Code. I read the diff at 25485af4ad.

  • Library and pipeline state. A state with rasterizerDiscard now never takes the library path (core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp:435). In the constructor's init list (line 555), depthBounds and dynamicColorWriteMask are now off for such a state, and staticDiscard is set.
  • Discard pipelines. These drop the dynamic stencil reference (line 732) and the fragment stage (line 826), and get a rendering info with no attachments (lines 844 to 850). Their draws no longer set the stencil reference (line 1069).
  • Tests.
    • staticDiscardPipelineTests (core/libs/prx/libSceAgcDriver/tests/Graphics.cpp:10108) checks the created pipeline against a mock.
    • core/libs/prx/libSceAgcDriver/tests/execution/RasterizerDiscard.cpp:33 alternates discard and normal draws, into a depth target and a depth+stencil target.
  • Test registration. The execution source is registered three times: agc_driver_rasterizer_discard, the default registration of every tests/execution source, which runs with libraries on; _libraries, also with libraries on; and _render_pass, with APS5_NO_GPL=1.
  • Conventions. The description names a title (Crimson Desert) only as the path that reaches this code. The code has no title-specific values. I found no code comments and no made-up success. Debt files are untouched.
  • Checks. On the merge, tools/check_conventions.py --base 26508fa3f9 passes and tools/debt_fold.py --check exits 0.

Existing runs.

  • The author: RTX 3080 on Windows, and lavapipe on fork CI.
  • tablefrogpillow: RX 7900 GRE, gfx1036 and Vega 56 on Linux (RADV).
  • throny: RTX 4080 on Windows.

None used AMD's Windows driver.

Negative control. On the merge I restored main's Graphics/src/Pipeline.cpp and Graphics/include/Pipeline.hpp, kept the PR's tests, rebuilt, and ran the six tests 3 times. Results were the same in every run:

  • agc_driver_rasterizer_discard and agc_driver_rasterizer_discard_libraries failed with a draw without rasterizer discard covered 0 of 2048 pixels. This is the library reuse the description reports, now seen on AMD's driver.
  • agc_driver_graphics (CPU) failed with a pipeline that bakes rasterizer discard was built from pipeline libraries.
  • agc_driver_rasterizer_discard_render_pass passed, but logged 20 VUID- lines: 8 × VUID-VkGraphicsPipelineCreateInfo-pStages-06894 and 12 × VUID-vkCmdDraw-None-08608.
  • The two library tests each logged 2 × VUID-VkGraphicsPipelineCreateInfo-flags-06683, 4 × VUID-vkCmdDraw-None-08608 and 2 × VUID-vkCmdDraw-colorAttachmentCount-06179.
  • That totals 36 VUID- lines per run, the same four IDs and count as the author's lavapipe control.
  • agc_driver_stencil_replay and agc_driver_tessellation_geometry passed with 0 VUID-.

I then restored the PR's files.

GPU. Command, for main and for each head run:
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ctest --test-dir build -R "^agc_driver_(graphics|rasterizer_discard|rasterizer_discard_render_pass|rasterizer_discard_libraries|stencil_replay|tessellation_geometry)$" -V

test main head 1 head 2 head 3
agc_driver_stencil_replay Passed 0.64 s Passed 1.50 s Passed 0.63 s Passed 0.62 s
agc_driver_tessellation_geometry Passed 0.50 s Passed 1.60 s Passed 0.49 s Passed 0.48 s
agc_driver_graphics (CPU) Passed 11.24 s Passed 11.45 s Passed 11.14 s Passed 11.09 s
agc_driver_rasterizer_discard not on main Passed 1.00 s Passed 0.24 s Passed 0.25 s
agc_driver_rasterizer_discard_render_pass not on main Passed 0.99 s Passed 0.25 s Passed 0.25 s
agc_driver_rasterizer_discard_libraries not on main Passed 0.24 s Passed 0.24 s Passed 0.22 s

Validation. Every head and control log shows the loader inserting VK_LAYER_KHRONOS_validation 6 times: once per GPU test, and twice in agc_driver_tessellation_geometry. The main log shows 3, because the three discard tests do not exist there. No log contains was not found but was requested by env var VK_INSTANCE_LAYERS. The main and head logs have 0 VUID- lines. The control logs have the 36 listed above. Every log has 0 SYNC-HAZARD lines.

Speed evidence. None in the PR, and none is claimed. I did not measure speed.

  • GPU: AMD Radeon AI PRO R9700 (gfx1201, 1002:7551), driver 32.0.31044.16, Vulkan 1.4.349
  • Validation layer: Khronos 1.4.363 (LunarG SDK)
  • CPU: Ryzen 9 9950X3D
  • OS: Windows 11 Pro 26300
  • Toolchain: WinLibs GCC 15.2, Release
  • Commits measured: main 26508fa; head 25485af4ad, merged onto main as c3f708bac8

AI-assisted: yes

@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: Rasterizer-Discard Pipeline Support

Layer / File(s) Summary
Configure rasterizer-discard pipelines
core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp, core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
Pipeline construction avoids pipeline-library use, removes fragment stages and attachment metadata, and omits selected dynamic states when rasterizer discard is enabled.
Verify whole-pipeline construction
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
The mock records pipeline stage, attachment, and dynamic-state metadata. Tests check whole-pipeline construction and the absence of fragment-state commands.
Exercise rasterizer-discard draws
core/libs/prx/libSceAgcDriver/tests/execution/DepthFastClearHarness.hpp, core/libs/prx/libSceAgcDriver/tests/execution/RasterizerDiscard.cpp, core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_rasterizer_discard_tests.cmake
The execution harness accepts a rasterizer-discard option. Vulkan tests check coverage for discarded and non-discarded depth and depth-stencil draws. CMake registers the tests.

Suggested reviewers: janzezno, eaglebearerys

Change: Bug fix

Merge Risk: Minimal · up to 94295

This change builds rasterizer-discard pipelines without fragment state and without pipeline-library reuse. That prevents invalid pipeline state and the case where a later normal draw covers no pixels. No blocking issues were found, and reported tests pass on several GPUs.

Security architecture risk: Minimal · up to 94295

The change prevents a discard draw from affecting later draws that use the same shaders. It uses the existing discard setting, adds no public interface, and does not change how saved pipeline recipes are read.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — Discard no longer propagates through the shared pipeline-library path to ordinary draws. The full pipeline cache already distinguishes discard from ordinary draws and compares key bytes before reuse.

Trust Boundaries and Controls

  • inferred — The inspected selector changes how an existing draw reaches Vulkan pipeline creation; it does not grant the draw a new capability or bypass a security control. Whole-pipeline creation uses the existing device, layout, and pipeline-cache locking path.

Resilience and Maintainability Implications

  • observed — Discard prebuild returns without publishing a library. If whole-pipeline construction throws, the constructor releases the Vulkan objects it owns and rethrows before insertion. Concurrent builders recheck the key under the store mutex before publishing a completed pipeline.
Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

Cppcheck (2.22.0)

Cppcheck (2.22.0) exceeded its 180-second time budget. Findings from completed work are retained; remaining checks are incomplete.

core/libs/prx/libSceAgcDriver/tests/Graphics.cpp

Cppcheck interrupted; analysis of this file is incomplete

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d40219c3-ad1d-43b6-8b97-dab2e018a85c
Commits

Reviewing files that changed from the base of the PR and between ea49f32 and 9429505.

Files selected for processing: 6

  • core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp
  • core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
  • core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
  • core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_rasterizer_discard_tests.cmake
  • core/libs/prx/libSceAgcDriver/tests/execution/DepthFastClearHarness.hpp
  • core/libs/prx/libSceAgcDriver/tests/execution/RasterizerDiscard.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@oneandonlydean
oneandonlydean merged commit d42e183 into boykopovar:main Nov 29, 2026
15 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants