Skip to content

test(agc): write the depth-rejection plane with a draw, not a CPU fill - #28297

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
zeezey:depth-rejection-draw-clear
Dec 5, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
zeezey:depth-rejection-draw-clear

Conversation

@zeezey

@zeezey zeezey commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

What

DepthRejection in tests/execution/PackedUnorm4444PartialWrite.cpp can fail when it runs twice in one process. The change is to the test only.

Reproduction on main: call DepthRejection(*device, block, layout, color); a second time in main(). The second call can fail at its first draw (how often is under Tested):

a full write at z 0.5 that kills a checkerboard and writes depth: pixel (0, 0) holds 0xe743, expected 0x93c6 (it held 0xe743)

Cause: the case "clears" its depth plane by writing 1.0 into it with memcpy, which relies on documented driver gaps in docs/dev/debt/libSceAgcDriver.md:

  • "Depth planes in guest memory" and "Depth surfaces created over storage writes": the case's DepthTarget keeps the default depthSwizzle 0, and the driver resyncs a depth plane from guest memory only for single-sample D32_SFLOAT/D32_SFLOAT_S8_UINT with swizzle mode 24 (mirrorable() in DepthSurface.cpp). Any other plane stays in the host image only, and CPU writes to it are not read.
  • "Stale depth planes over reused guest memory": a depth surface outlives the guest memory it mirrors; the entry closes when "surfaces are retired on allocation changes".

A first call passes because a new depth surface starts at its clear depth, which the test also sets to 1.0. A second call can get its depth block at the address the first call freed, where the first call's surface is still resident with 0.5 on the checkerboard pixels that survived, so its first draw is rejected there.

Change: the case now writes 1.0 with an always-passing, depth-writing draw at z 1.0 before its draws, so its starting depth no longer depends on which surface is resident. The CPU fill is removed. The draw also writes the color block, so the case reads the block back after it, as the test does before every other CPU fill; without that read-back the fill races the draw's pending color results and the driver logs guest memory changed while GPU results were pending; keeping the CPU's blocks. DrawSetup gains the depth compare op for the new draw, with LESS as before for every other draw. Setting depthSwizzle 24 instead would move the case onto the mirrored-plane path, which is not what it tests.

What does not change: no driver code, no other test case and no test registration.

tools/pr_overlap.py stops at #7642 because it cannot fetch that pull request's head. A copy that skips the nine pull requests whose heads cannot be fetched (#7642, #9508, #10193, #13928, #13929, #14217, #14218, #24048 and #26766, none of which touches this file) finds no overlapping change. #17056, #23258, #23281 and #24049 touch this file but conflict with main, so it could not compare them; none of them changes DepthRejection or DrawSetup.

Tested

Both platforms ran with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer and ctest -V, on main 6f6f6c8e6b and the change. Every log below shows the layer inserted, no "was not found" line, 0 VUID- lines and 0 SYNC-HAZARD lines.

Windows 11, NVIDIA GeForce RTX 4090 (driver 621.24), validation layer 1.4.363:

  • agc_driver_packed_unorm4444_partial_write: 20 of 20 runs passed with the change and 20 of 20 on main, at most 1.45 s. Neither logs guest memory changed while GPU results were pending.
  • DepthRejection called twice in one process: on main 0 of 20 runs passed, all 20 with the message above; with the change 20 of 20 passed. ("Main" here is the change's build with PackedUnorm4444PartialWrite.cpp put back to its main contents, restored afterwards and its hash checked.)
  • Area set depth|partial_write|4444|interlock|occlusion|sample|stencil, 256 tests, -j 8: 252 passed and 4 were skipped, none failed, with the change and on main alike.
  • Complete suite, -j 8 --timeout 300, 7467 tests (2379 agc_): with the change 7428 passed, 2 failed and 37 were skipped (agc_: 2351, 1, 27); on main 7429 passed, 1 failed and 37 were skipped (agc_: 2352, 0, 27). windows_write_watch failed on both ("cannot restore full resident run protection"). agc_driver_pm4_stall_prompt_lock failed only with the change ("a video output registration waited for the driver lock while the stall prompt was open"); run alone, it passed 5 of 5 times with the change and 5 of 5 on main (it opens no Vulkan device, so these logs have no layer lines), and its executable, agc_driver_pm4_tests, does not build from PackedUnorm4444PartialWrite.cpp. The run with the change overlapped other work on this PC; the main run did not. Every other test has the same result on both. The 4444 test logs no pending-results warning in either run.
  • tools/vulkan_validation_gate.py with main 6f6f6c8e6b as baseline and the change as candidate, targets agc_driver_packed_unorm4444_partial_write_tests and libs, --tests '^agc_driver_packed_unorm4444_partial_write$' --gpu NVIDIA --repeat 20: status complete, exit code 0, no problems and no new diagnostics. All 20 iterations returned 0 on each side. The only message either side counts is Undefined-Value-ShaderOutputNotConsumed-DynamicRendering, 200 times in the baseline's 20 runs and 200 times in the change's. The test took 0.60 to 1.34 s per run on the baseline and 0.60 to 1.30 s with the change.
  • Rebased onto main 1f27e2abfa before opening. The two commits since 6f6f6c8e6b bring feat(agc): keep page digests instead of copies of sampled snapshots outside the write watch #28258, which touches neither PackedUnorm4444PartialWrite.cpp, DepthSurface.cpp nor the test registration. On 1f27e2abfa: agc_driver_packed_unorm4444_partial_write passed 20 of 20 runs; DepthRejection called twice passed 20 of 20 with the change and 0 of 20 with main's file, all 20 with the message above; the area set, now 257 tests, had 253 passed, 4 skipped and none failed. No VUID-, SYNC-HAZARD or pending-results line.

Linux, lavapipe (llvmpipe, Mesa 25.2.8, LLVM 20.1.2) in an Ubuntu 24.04 container, validation layer 1.4.335, GALLIUM_OVERRIDE_CPU_CAPS=avx. userfaultfd fails with EPERM in this container, so there is no guest write watch and the tests that need it fail here on main as well. "Main" is the same build with PackedUnorm4444PartialWrite.cpp put back to its main contents (restored afterwards and its hash checked):

  • agc_driver_packed_unorm4444_partial_write: 20 of 20 runs passed with the change and 20 of 20 on main, at most 0.82 s. Neither logs guest memory changed while GPU results were pending.
  • DepthRejection called twice in one process: on main 10 of 20 runs passed and 10 failed with the message above; with the change 20 of 20 passed.
  • Area set depth|partial_write|4444|interlock|occlusion|sample|stencil, 250 tests, -j 6: 157 passed, 63 failed and 30 were skipped, with the change and on main alike; every test has the same result on both.
  • Complete suite, -j 6 --timeout 120, 7352 tests (2329 agc_): 6812 passed, 219 failed and 321 were skipped, with the change and on main alike (agc_: 1878, 209, 242); every test has the same result on both, and the 4444 test logs no pending-results warning in either.

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 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 4090, driver 621.24, Windows 11; lavapipe (llvmpipe, Mesa 25.2.8, LLVM 20.1.2), Linux
  • AI-assisted: yes.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Updated depth-rejection test coverage to verify color output when depth comparison is set to always.

The 4_4_4_4 partial write test's depth-rejection case filled its D32
depth plane (swizzle mode 0) with 1.0 on the CPU. That relies on two
documented driver gaps: the driver keeps such a plane in its host image
only and does not read CPU writes to it ("Depth planes in guest memory",
"Depth surfaces created over storage writes"), and a depth surface
outlives the guest memory it mirrors ("Stale depth planes over reused
guest memory", which closes when surfaces are retired on allocation
changes). A first call passes because a new depth surface starts at
DB_DEPTH_CLEAR, which the test also sets to 1.0. A second call in one
process can get its depth block at the address the first call freed,
where the first call's surface is still resident with 0.5 on the
checkerboard pixels that survived, and its first draw is then rejected
there ("pixel (0, 0) holds 0xe743, expected 0x93c6").

The case now writes 1.0 with an always-passing, depth-writing draw at
z 1.0 before its draws, so its starting depth no longer depends on which
surface is resident, and reads the color block back after that draw, as
the test does before every other fill, so the CPU fill does not race
the draw's pending color results. The draw setup takes the depth compare
op for it. A depthSwizzle of 24 would move the case onto the
mirrored-plane path, which is not what it tests.

Tested with the validation layer on an RTX 4090 (Windows 11) and on
lavapipe: agc_driver_packed_unorm4444_partial_write passes on main and
with the change, and neither logs the driver's pending-results warning;
with the case called twice in one process it fails on main and passes
with the change. The depth, partial write, 4444, interlock, occlusion,
sample and stencil tests give every test the same result on main and
with the change. In the complete suite every test also has the same
result on both, apart from agc_driver_pm4_stall_prompt_lock, which
failed once with the change and passes 5 of 5 when run alone on both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NAAUzVZz5igZcosJFfZ3kV
@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: Depth comparison test

Layer / File(s) Summary
Configure and exercise depth comparison
core/libs/prx/libSceAgcDriver/tests/execution/PackedUnorm4444PartialWrite.cpp
DrawSetup defaults depthCompare to VK_COMPARE_OP_LESS, and depth-enabled draws use that field. DepthRejection first draws with a full mask at depth 1.0 using VK_COMPARE_OP_ALWAYS, then reads the target. The function no longer clears the depth buffer or explicitly initializes the color target.

Suggested reviewers: jab-dev, marczx10

Change: Other

Merge Risk: Minimal · up to c105d

This updates a driver test so it no longer depends on a reused depth surface or races pending GPU results. It does not touch production code, so the risk of merging is minimal.

Security architecture risk: Minimal · up to c105d

The change initializes depth through a draw in one execution test. It preserves the comparison used by the existing test draws and does not change the driver’s public interface or production behavior.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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: 8773ef20-230a-4261-a425-15c11567f3dd
Commits

Reviewing files that changed from the base of the PR and between 1f27e2a and c105de8.

Files selected for processing: 1

  • core/libs/prx/libSceAgcDriver/tests/execution/PackedUnorm4444PartialWrite.cpp

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

@JJenkx

JJenkx commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Windows at this head (c105de86e060): agc_driver_packed_unorm4444_partial_write passes, 3/3 runs. This is the CTest of the executable that compiles the changed PackedUnorm4444PartialWrite.cpp.

Setup:

  • Windows 11 22621, Ryzen 9 5950X, MinGW-w64 GCC 15.2 UCRT r7, Release.
  • The exact PR head was built (not merged into main).
  • 3 runs through the shared FIFO.

The added test lines have no platform guard.

AI-assisted: yes.

@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

The change at head c105de86e060254b55fd13176021ad77e9bd2793 is limited to the depth rejection test and its initialization draw appears consistent with the intended test behavior.

What I ran

Read the prepared description, commit summary, manifest, diff, and the changed file ranges relevant to DrawSetup, ReadBack, and DepthRejection. No tests were run in this review. The description's test runs are author-reported.

Results

Check Result Note
Patch review passed One test file changed
Tests run by reviewer not run Author-reported results only

Findings

Blocking

None.

Non-blocking

None.

Not verified

The remainder of the changed file and repository context outside the targeted ranges were not read. The author-reported Windows and Linux test runs were not independently verified. files.json was not available through the reader, so excluded-file status was not verified; the manifest lists one reviewed file, whose relevant ranges were read.

To get this to a good state

Nothing is required.

@github-actions

github-actions Bot commented Nov 29, 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 29119 core/libs/prx/libSceAgcDriver/tests/execution/PackedUnorm4444PartialWrite.cpp L147, L264
PR 29120 core/libs/prx/libSceAgcDriver/tests/execution/PackedUnorm4444PartialWrite.cpp L147, L264
PR 29123 core/libs/prx/libSceAgcDriver/tests/execution/PackedUnorm4444PartialWrite.cpp L147, L264

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 17056 core/libs/prx/libSceAgcDriver/tests/execution/PackedUnorm4444PartialWrite.cpp
PR 23258 core/libs/prx/libSceAgcDriver/tests/execution/PackedUnorm4444PartialWrite.cpp
PR 23281 core/libs/prx/libSceAgcDriver/tests/execution/PackedUnorm4444PartialWrite.cpp
PR 24049 core/libs/prx/libSceAgcDriver/tests/execution/PackedUnorm4444PartialWrite.cpp

@ycbuzi

ycbuzi commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Tested c105de86e0 merged into main, with the whole ctest suite on each machine below. Nothing fails that does not also fail on main on the same machine.

  • Windows Server 2022 (GitHub-hosted runner), full build, WinLibs GCC 15.2.0: 99% tests passed, 2 tests failed out of 7462; 99% tests passed, 2 tests failed out of 7462. 2 of the failing tests fail on main too. run
  • Windows Server 2025 (GitHub-hosted runner), full build, WinLibs GCC 15.2.0: 100% tests passed, 0 tests failed out of 7462; 100% tests passed, 0 tests failed out of 7462. run

GPU: 4 GPU tests (AGC) passed twice on a GTX 1650 SUPER (Windows 11, Vulkan required, validation layer on, shader cache off), with this pull request merged into main e3249c53cb. No Vulkan validation message appears that main does not also produce on the same GPU.

AI-assisted: yes (Claude Code); the runs are automated, this summary was written from their reports.

@Plyxen Plyxen 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.

I read the diff at c105de86e0. Windows 11, GCC 15.2, merged into main at 6c6b29320fe together with other open PRs (so not an isolated build), with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 and VK_LAYER_KHRONOS_validation on an RTX 5080 (621.24) and a Radeon iGPU (26.11.2).

  • agc_driver_packed_unorm4444_partial_write: pass on both GPUs. The loader log shows the layer inserted and no "was not found" line, and neither run has a VUID- or SYNC-HAZARD line.
  • No control: it is a test change. The depth-rejected draws still run ("a depth-rejected merge" is in the summary line on both GPUs).

Not checked: the driver on which the CPU fill failed.

AI-assisted: yes (Claude Code)

@ligmaSec ligmaSec left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The changed packed-unorm fixture builds. It loaded validation layer 1.4.369 on both main and the patched tree, then skipped on both because lavapipe lacks fragmentShaderPixelInterlock. The paired GCN scalar-buffer control passed with Vulkan required and shader cache disabled. Neither log contains a missing-layer diagnostic or a VUID- entry. The draw-seeded depth rejection case still needs a device with pixel interlock.

AI-assisted: yes.

@oneandonlydean
oneandonlydean merged commit 13c1e8a into boykopovar:main Dec 5, 2026
17 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants