fix(agc): accept cull distances from tessellation evaluation shaders #13492

Merged
wrocketdev merged 1 commit from upstream-pr/13492 into main 2026-10-30 21:51:24 +00:00
wrocketdev commented 2026-10-30 16:56:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by wrocketdev on 2026-10-30T16:56:25Z.


What

ValidateShaders accepted gl_CullDistance outputs only from vertex and mesh shaders, while it accepted gl_ClipDistance from tessellation too. The recompiler already declares and stores both for a tessellation evaluation shader, and Vulkan allows both there, so any tessellated draw with a guest cull distance aborted, on any GPU, with a misleading message:

AGC graphics: vertex clip or cull distance needs shaderClipDistance or shaderCullDistance, which the device lacks (PA_CL_VS_OUT_CNTL=0x00400403)

This accepts the CullDistance built-in and capability in the tessellation evaluation stage. The device feature is still required: without shaderCullDistance the draw is refused with the same message. The tessellation control stage is unchanged, because the guest's distances are exported from the stage that writes position.

validationTests gains a tessellation pipeline whose evaluation shader writes cull distances, accepted with shaderCullDistance and refused without it. makeModule gains tessellationModel for that.

Tested

Windows 11 Pro (build 26300), Intel Core i5-12600KF, NVIDIA GeForce RTX 3060 Ti (driver 617.42), WinLibs GCC 15.2.0 r7, Release, on main ad2fbd74cd.

  • ctest -R '^agc_driver_graphics$' passes. Without the ShaderValidation.cpp change the new case fails with the message above.
  • ELDEN RING (PPSA04610) 01.017 stopped on that abort with PA_CL_VS_OUT_CNTL=0x00400403 after the title screen. With this change it reaches gameplay in the first area, no abort, no NotImplemented.
  • Rebased on main 556547da71: the four tests below pass again and tools/check_conventions.py --base upstream/main passes. tools/pr_overlap.py reports no overlap; it could not compare 23 conflicting pull requests, of which the five that touch ShaderValidation.cpp do not change this check.

ctest -R '^agc_driver_(graphics|tessellation|vertex_clip_cull_distances|vertex_clip_cull_draw)$' -V with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (Vulkan SDK 1.4.363.0) passes on main and on this change, with no missing-layer line and no VUID- line in either log; VK_LOADER_DEBUG=layer confirms the layer is inserted. None of these tests draws tessellated geometry with a cull distance, and the game was not run under the layer, so that exact path has no validation-layer coverage.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: PPSA04610 #13493
  • GPUs tested: NVIDIA GeForce RTX 3060 Ti (driver 617.42)
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5088005034 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13492). Originally posted by [wrocketdev](https://github.com/wrocketdev) on 2026-10-30T16:56:25Z. --- ### What `ValidateShaders` accepted `gl_CullDistance` outputs only from vertex and mesh shaders, while it accepted `gl_ClipDistance` from tessellation too. The recompiler already declares and stores both for a tessellation evaluation shader, and Vulkan allows both there, so any tessellated draw with a guest cull distance aborted, on any GPU, with a misleading message: `AGC graphics: vertex clip or cull distance needs shaderClipDistance or shaderCullDistance, which the device lacks (PA_CL_VS_OUT_CNTL=0x00400403)` This accepts the `CullDistance` built-in and capability in the tessellation evaluation stage. The device feature is still required: without `shaderCullDistance` the draw is refused with the same message. The tessellation control stage is unchanged, because the guest's distances are exported from the stage that writes position. `validationTests` gains a tessellation pipeline whose evaluation shader writes cull distances, accepted with `shaderCullDistance` and refused without it. `makeModule` gains `tessellationModel` for that. ### Tested Windows 11 Pro (build 26300), Intel Core i5-12600KF, NVIDIA GeForce RTX 3060 Ti (driver 617.42), WinLibs GCC 15.2.0 r7, Release, on `main` ad2fbd74cd3f. - `ctest -R '^agc_driver_graphics$'` passes. Without the `ShaderValidation.cpp` change the new case fails with the message above. - ELDEN RING (PPSA04610) 01.017 stopped on that abort with `PA_CL_VS_OUT_CNTL=0x00400403` after the title screen. With this change it reaches gameplay in the first area, no abort, no `NotImplemented`. - Rebased on `main` 556547da71: the four tests below pass again and `tools/check_conventions.py --base upstream/main` passes. `tools/pr_overlap.py` reports no overlap; it could not compare 23 conflicting pull requests, of which the five that touch `ShaderValidation.cpp` do not change this check. `ctest -R '^agc_driver_(graphics|tessellation|vertex_clip_cull_distances|vertex_clip_cull_draw)$' -V` with `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` (Vulkan SDK 1.4.363.0) passes on `main` and on this change, with no missing-layer line and no `VUID-` line in either log; `VK_LOADER_DEBUG=layer` confirms the layer is inserted. None of these tests draws tessellated geometry with a cull distance, and the game was not run under the layer, so that exact path has no validation-layer coverage. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: PPSA04610 #13493 - [x] GPUs tested: NVIDIA GeForce RTX 3060 Ti (driver 617.42) - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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!13492
No description provided.