Skip to content

fix(agc): accept PA_CL_CLIP_CNTL UCP_CULL_ONLY_ENA without active clip planes - #26578

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
birdmarty:fix/agc-ucp-cull-only-without-clip-planes
Nov 24, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
birdmarty:fix/agc-ucp-cull-only-without-clip-planes

Conversation

@birdmarty

Copy link
Copy Markdown
Contributor

What

PA_CL_CLIP_CNTL (0x204 / MMIO 0x28810) bit 17 is UCP_CULL_ONLY_ENA (cull primitives against enabled user clip planes without clipping them, per AMD PAL gfx9_plus_merged_registers.h and Mesa gfx103.json). DecodeState and DrawRejection previously rejected bit 17 unconditionally through ClipControlMask, even when no user clip plane (UCP_ENA_0..5, bits 0..5, still rejected) and no vertex clip distance (PA_CL_VS_OUT_CNTL CLIP_DIST_ENA_0..7, bits 0..7) is enabled.

When neither UCP_ENA_0..5 nor PA_CL_VS_OUT_CNTL CLIP_DIST_ENA_0..7 is set, there are no active clip planes for UCP_CULL_ONLY_ENA to act on, so it leaves pipeline state unchanged. Draws that set UCP_CULL_ONLY_ENA alongside any UCP_ENA_0..5 bit or any PA_CL_VS_OUT_CNTL CLIP_DIST_ENA_0..7 bit still throw, since whether bit 17 also affects shader clip distances on the console is unverified.

Changes

  • core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp: add clipControlMask(const Registers& cx) that clears UCP_CULL_ONLY_ENA (bit 17) from ClipControlMask when PA_CL_VS_OUT_CNTL (0x207) has CLIP_DIST_ENA_0..7 (bits 0..7) clear, and use it in both DecodeState and DrawRejection.
  • core/libs/prx/libSceAgcDriver/tests/Graphics.cpp: verify bit 17 decodes cleanly without altering clip space, depth clamping or depth range when no clip distances are enabled (including with cull distances only), and still fails both DecodeState and DrawRejection when any CLIP_DIST_ENA_0..7 or UCP_ENA_0..5 bit is set.
  • docs/dev/debt/changes/fix-agc-ucp-cull-only-without-clip-planes.md: update the PA_CL_CLIP_CNTL debt entry in docs/dev/debt/libSceAgcDriver.md to record UCP_CULL_ONLY_ENA and the unverified interaction with shader clip distances.

Tested

Windows 11 Pro (build 26300), Intel Core i9-9900K, AMD Radeon RX 6800 (AMD driver 26.10.1, Windows driver 32.0.21045.16010, Vulkan 1.4.315), MinGW-w64 GCC 15.3.0, Release, main 441fa65119.

Focused set (agc_driver_graphics, agc_driver_unused_viewport_depth, agc_driver_depth_range_remap_draw, agc_driver_vertex_clip_cull_distances, agc_driver_vertex_clip_cull_draw, agc_driver_vertex_clip_cull_draw_no_key, agc_driver_viewport_index, agc_depth_range_remap, agc_driver_tessellation_depth_range_remap, agc_mesh_cull_store) with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (1.4.363.0) and VK_LOADER_DEBUG=layer:

main 441fa65119 this change
Passed / failed 10 / 0 10 / 0
Validation layer inserted 8 8
VUID- lines 0 0

Without the fix (origin/main's State.cpp with this branch's Graphics.cpp), agc_driver_graphics fails with a PA_CL_CLIP_CNTL flag is unsupported (register 0x204 = 0x000a0000).

Kingdom Come: Deliverance II (PPSA21704, 01.052.000):

  • What the game does: submits a triangle-list draw with PA_CL_CLIP_CNTL = 0x000a0000 (DX_CLIP_SPACE_DEF | UCP_CULL_ONLY_ENA), PA_CL_VS_OUT_CNTL = 0x00000000, and all PA_CL_UCP_0..5 zero.
  • Without this change: aborts at 13.58 s (2 presents) on Main e60b2f74ad with a PA_CL_CLIP_CNTL flag is unsupported (register 0x204 = 0x000a0000) (reproduced twice).
  • With this change: clean fix applied on Main e60b2f74ad (bb0acb0514, no diagnostics) passes the stop cleanly in 5 consecutive runs with 0 errors: boots through the CryEngine/Bink/FMOD splash, EULA, Graphics Mode selection (Performance 2560x1440), Main Menu (~44–60 FPS), New Game (Standard Mode), and into the real-time 3D opening Siege of Suchdol cutscene (~6–11 FPS, verified by GPU frame dumps).

py -3 tools/check_conventions.py --base origin/main and py -3 tools/debt_fold.py --check pass. py -3 tools/pr_overlap.py --branch fix/agc-ucp-cull-only-without-clip-planes (2,595 open PRs): all 53 mergeable PRs that share files merge cleanly with no overlap; all 13 conflicting PRs touching State.cpp (#1395, #6188, #6235, #7256, #9895, #11551, #11825, #20845, #23252, #23258, #23281, #24049, #26046) were searched by hand and none touches ClipControlMask or UCP_CULL_ONLY_ENA.

Not tested: whether UCP_CULL_ONLY_ENA affects PA_CL_VS_OUT_CNTL CLIP_DIST_ENA_0..7 on console hardware (those draws still throw), other GPUs, Linux.

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: PPSA21704 Kingdom Come: Deliverance II (PPSA21704) #26577
  • GPUs tested: AMD Radeon RX 6800 (vendor=0x1002, device=0x73bf), AMD proprietary driver 26.10.1 (Windows driver 32.0.21045.16010, Vulkan 1.4.315), Windows 11 Pro (build 26300); Khronos validation layer 1.4.363.0 on main and this change, 0 VUIDs
  • AI-assisted: yes (Antigravity)

@github-actions github-actions Bot added unblocks title Names a title ID on the Unblocks line docs agc libSceAgc* labels Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

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/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 4040 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 5925 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6188 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
PR 6235 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
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 6995 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 7002 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 7085 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 7256 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 7642 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9356 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9387 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9508 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9712 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9895 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9897 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9915 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 10193 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 11551 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 11825 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 13928 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 13929 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 15570 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 16935 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 17056 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 19620 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 20315 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 20845 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 23252 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 23258 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 23281 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 24049 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 26197 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp

@cozejarr

Copy link
Copy Markdown
Contributor

NVIDIA test run of the focused set in the description, for a second vendor next to the RX 6800 results.

  • GPU: NVIDIA GeForce RTX 4070, driver 610.88, Windows 11 Pro 26300, WinLibs GCC 15.2 (Release)
  • Khronos validation layer 1.4.335 (built from vulkan-sdk-1.4.335.0), ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer
  • main at 4d1fb21, and this branch at ac715a8 merged onto it (e5e0b034f0), in the same build tree with the test targets rebuilt for each side
  • ctest --test-dir build -V -R '^(agc_depth_range_remap|agc_driver_depth_range_remap_draw|agc_driver_graphics|agc_driver_tessellation_depth_range_remap|agc_driver_unused_viewport_depth|agc_driver_vertex_clip_cull_distances|agc_driver_vertex_clip_cull_draw|agc_driver_vertex_clip_cull_draw_no_key|agc_driver_viewport_index|agc_mesh_cull_store)$'
main this PR
passed 10 of 10 10 of 10
Insert instance layer "VK_LAYER_KHRONOS_validation" 8 8
was not found but was requested 0 0
VUID- 0 0

The 8 inserts match the count in the description.

Control: the merge with main's State.cpp and this branch's Graphics.cpp fails agc_driver_graphics with a PA_CL_CLIP_CNTL flag is unsupported (register 0x204 = 0x000a0000), as in the description. On this machine agc_driver_unused_viewport_depth fails there too with the same message. It runs the same agc_driver_graphics_tests.exe with --unused-viewport-depth, so it reaches the same new cases. agc_driver_viewport_index passes there. The control run had no VUID- lines.

AI-assisted: yes. Claude Code ran these tests on this machine and wrote this report from the logs.

@zedekvdb

Copy link
Copy Markdown
Contributor

NVIDIA run (Pascal, Windows), next to the RX 6800 in the description: the focused set passes on both sides, and this PR's Graphics.cpp change fails on main's driver as expected.

Setup: Windows 11 Pro 10.0.26300, NVIDIA Quadro P3200 (Pascal, 10de:1bbb), driver 582.42, Vulkan API 1.4.312, WinLibs GCC 15.2.0 r7, Release, main c55872d43f. VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ANYPS5_GPU="Quadro P3200", ctest -j 1 -V, 2 runs per side. Every Vulkan test selects the Quadro P3200 with the layer inserted; there are no VUID- messages.

agc_driver_graphics The other 9 tests of the focused set
main 9 of 9, 2 of 2 runs
This PR's Graphics.cpp on main's driver fails: a PA_CL_CLIP_CNTL flag is unsupported (register 0x204 = 0x000a0000)
This head (ac715a8b41) passes, 2 of 2 runs 9 of 9, 2 of 2 runs

AI-assisted: yes (Claude Code)

@oneandonlydean
oneandonlydean merged commit 9bb867e into boykopovar:main Nov 24, 2026
14 checks passed
@upipibi

upipibi commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

RTX 3070 run of ac715a8b41, merged with --no-ff onto main 5e9ad5f57b, against main alone.

Tested

  • NVIDIA GeForce RTX 3070 (driver 616.56, subgroup 32), Windows 11 Pro 26100, WinLibs GCC 15.2.0, Ninja, Release; ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation.
  • ctest -R "^agc_driver_graphics$", 3 runs each:
    • main: 1/1 passed in all 3 runs.
    • this PR: 1/1 passed in all 3 runs.
  • These tests create no Vulkan instance, so the validation layer is not loaded; 0 VUID- messages. Build: 0 failed targets.

Not tested: AMD, titles.

AI-assisted (Claude Code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* docs unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants