feat(agc): accept linear attribute clipping in PA_CL_CLIP_CNTL #678

Merged
Celegans12 merged 1 commit from upstream-pr/678 into main 2026-10-05 18:50:17 +00:00
Celegans12 commented 2026-10-05 14:57:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-05T14:57:03Z.


What

DecodeState and the draw precheck refused PA_CL_CLIP_CNTL bit 24 (DX_LINEAR_ATTR_CLIP_ENA), so every draw that sets it was skipped with unsupported PA_CL_CLIP_CNTL flags is unsupported (register 0x204 = 0x01080000).

  • Bit 24 is now accepted next to bits 19, 26 and 27. It adds no pipeline state: clip space, depth clamping and the viewport depth range decode exactly as with the bit clear.
  • Why this is exact: Vulkan requires clipped NoPerspective outputs to vary linearly in framebuffer space (Clipping Shader Outputs), and AMD's conformant drivers set the bit on every draw: RADV (radv_cmd_buffer.c) and radeonsi (si_state.c). With the bit set the hardware clips as Vulkan does, which is how the host driver already clips the translated draw.
  • Field position: bit 24 in Mesa's GFX10.3 register database (gfx103.json). AMD's public R6xx-CIK register references list the field without a description.
  • Still rejected, with or without bit 24: user clip planes, CLIP_DISABLE, DX_RASTERIZATION_KILL, VTX_KILL_OR, VTE_VPORT_PROVOKE_DISABLE and every other bit outside 19, 24, 26 and 27.
  • TechnicalDebt (Functional): a clear bit, which main already accepted, gets the same clipping; what it changes on the console is undocumented.
  • PPSA26344 v1.008 builds the value at 0x9f741d: it clears bits 19, 24, 26 and 27 of a register template, then sets 19 and 24 (0x01080000). This register is the only skipped-draw reason its runs report.

Tested

  • Windows 11, MinGW-w64 GCC 15.2.0, based on main af92452f: configure -DBUILD_TESTING=ON, full build, --target libs, ctest:
  • 288/288 tests pass (ctest --output-on-failure)
  • agc_driver_graphics (DepthClipTests) checks PA_CL_CLIP_CNTL 0x00080000, 0, 0x0c080000 and 0x04000000 with bit 24 added. Each must decode like the value without it and pass the precheck. Every other single bit must still be rejected by DecodeState and the precheck, with and without bit 24. On main the test fails with register 0x204 = 0x01080000.
  • PPSA26344 v1.008: not yet run with this change. On main, the draws it reaches are skipped on this register.
  • Not tested: Linux (CI), console behaviour.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4746824184 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/678). Originally posted by [Celegans12](https://github.com/Celegans12) on 2026-10-05T14:57:03Z. --- ### What `DecodeState` and the draw precheck refused PA_CL_CLIP_CNTL bit 24 (`DX_LINEAR_ATTR_CLIP_ENA`), so every draw that sets it was skipped with `unsupported PA_CL_CLIP_CNTL flags is unsupported (register 0x204 = 0x01080000)`. - Bit 24 is now accepted next to bits 19, 26 and 27. It adds no pipeline state: clip space, depth clamping and the viewport depth range decode exactly as with the bit clear. - Why this is exact: Vulkan requires clipped `NoPerspective` outputs to vary linearly in framebuffer space ([Clipping Shader Outputs](https://github.com/KhronosGroup/Vulkan-Docs/blob/e4e53e4b31e13eeaee1ad99fb940aa72b2ec1b14/chapters/vertexpostproc.adoc#L1248-L1251)), and AMD's conformant drivers set the bit on every draw: RADV ([radv_cmd_buffer.c](https://gitlab.freedesktop.org/mesa/mesa/-/blob/17ca6174dcc6cb22059ac343bc29f8af7800f42e/src/amd/vulkan/radv_cmd_buffer.c#L13442-13446)) and radeonsi ([si_state.c](https://gitlab.freedesktop.org/mesa/mesa/-/blob/17ca6174dcc6cb22059ac343bc29f8af7800f42e/src/gallium/drivers/radeonsi/si_state.c#L908-912)). With the bit set the hardware clips as Vulkan does, which is how the host driver already clips the translated draw. - Field position: bit 24 in Mesa's GFX10.3 register database ([gfx103.json](https://gitlab.freedesktop.org/mesa/mesa/-/blob/17ca6174dcc6cb22059ac343bc29f8af7800f42e/src/amd/registers/gfx103.json#L13275-13282)). AMD's public R6xx-CIK register references list the field without a description. - Still rejected, with or without bit 24: user clip planes, `CLIP_DISABLE`, `DX_RASTERIZATION_KILL`, `VTX_KILL_OR`, `VTE_VPORT_PROVOKE_DISABLE` and every other bit outside 19, 24, 26 and 27. - TechnicalDebt (Functional): a clear bit, which `main` already accepted, gets the same clipping; what it changes on the console is undocumented. - PPSA26344 v1.008 builds the value at 0x9f741d: it clears bits 19, 24, 26 and 27 of a register template, then sets 19 and 24 (`0x01080000`). This register is the only skipped-draw reason its runs report. ### Tested - Windows 11, MinGW-w64 GCC 15.2.0, based on `main` af92452f: configure `-DBUILD_TESTING=ON`, full build, `--target libs`, `ctest`: - 288/288 tests pass (`ctest --output-on-failure`) - `agc_driver_graphics` (`DepthClipTests`) checks PA_CL_CLIP_CNTL `0x00080000`, `0`, `0x0c080000` and `0x04000000` with bit 24 added. Each must decode like the value without it and pass the precheck. Every other single bit must still be rejected by `DecodeState` and the precheck, with and without bit 24. On `main` the test fails with `register 0x204 = 0x01080000`. - PPSA26344 v1.008: not yet run with this change. On `main`, the draws it reaches are skipped on this register. - Not tested: Linux (CI), console behaviour. ### Checklist - [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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes
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!678
No description provided.