fix(agc): include PA_SU_POLY_OFFSET_CLAMP in the initial context state #1086

Merged
Celegans12 merged 1 commit from upstream-pr/1086 into main 2026-10-08 06:06:31 +00:00
Celegans12 commented 2026-10-07 10:13:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-07T10:13:31Z.


What

decodeDepthBias needs PA_SU_POLY_OFFSET_CLAMP (context register 0x2df), but InitialContextRegisters doesn't hold it, so a depth-biased draw is skipped (missing register in context bank at DWORD 0x2df) unless the title wrote the clamp itself.

  • The initial context state, which CLEAR_STATE also restores, now holds 0x2df = 0. A clamp of 0 means no clamping, so it needs no depthBiasClamp device feature.
  • Both sources I found say 0: libSceAgc's register defaults in every version (sceAgcGetRegisterDefaults2, RegisterDefaultsData.hpp) and amdgpu's GFX10 clear-state table (clearstate_gfx10.h), which the kernel loads for CLEAR_STATE (gfx_v10_0.c).
  • PPSA26344 v1.008: the menu's depth-only draws enable bias on both faces (PA_SU_SC_MODE_CNTL 0x1a42) and write every depth bias register except the clamp, so a 900 s run skipped about 53 draws in every menu frame.

Tested

  • Windows 11, MinGW-w64 GCC 15.2.0, based on main 0d3c1eec: configure -DBUILD_TESTING=ON, full build, --target libs, ctest:
  • 387/387 tests pass (ctest --output-on-failure)
  • Same build on lavapipe (Mesa 26.2.4 llvmpipe, 8-wide subgroups, VK_DRIVER_FILES): 386/386 pass; agc_driver_flat_store is left out there because it takes several minutes on Windows llvmpipe
  • DepthBoundsBiasTests (agc_driver_graphics) now decodes a depth-biased draw after ClearContext(), which CLEAR_STATE runs, with the clamp never written, and gets clamp 0. Fails on main with the message above.
  • PPSA26344 v1.008: no DWORD 0x2df skips in a 900 s run; 29,915 before, about 53 per menu frame.
  • 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:4771157932 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1086). Originally posted by [Celegans12](https://github.com/Celegans12) on 2026-10-07T10:13:31Z. --- ### What `decodeDepthBias` needs PA_SU_POLY_OFFSET_CLAMP (context register 0x2df), but `InitialContextRegisters` doesn't hold it, so a depth-biased draw is skipped (`missing register in context bank at DWORD 0x2df`) unless the title wrote the clamp itself. - The initial context state, which CLEAR_STATE also restores, now holds 0x2df = 0. A clamp of 0 means no clamping, so it needs no `depthBiasClamp` device feature. - Both sources I found say 0: libSceAgc's register defaults in every version (`sceAgcGetRegisterDefaults2`, [RegisterDefaultsData.hpp](https://github.com/boykopovar/AnyPS5/blob/a9ec7be28726162b5af04664c98cc61f2dc4eba2/core/libs/prx/libSceAgc/Command/include/RegisterDefaultsData.hpp#L584)) and amdgpu's GFX10 clear-state table ([clearstate_gfx10.h](https://github.com/torvalds/linux/blob/602042bf29f6efde39cfb5fdd9289bf4854bc0c5/drivers/gpu/drm/amd/amdgpu/clearstate_gfx10.h#L747)), which the kernel loads for CLEAR_STATE ([gfx_v10_0.c](https://github.com/torvalds/linux/blob/602042bf29f6efde39cfb5fdd9289bf4854bc0c5/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c#L6397-L6426)). - PPSA26344 v1.008: the menu's depth-only draws enable bias on both faces (PA_SU_SC_MODE_CNTL 0x1a42) and write every depth bias register except the clamp, so a 900 s run skipped about 53 draws in every menu frame. ### Tested - Windows 11, MinGW-w64 GCC 15.2.0, based on `main` 0d3c1eec: configure `-DBUILD_TESTING=ON`, full build, `--target libs`, `ctest`: - 387/387 tests pass (`ctest --output-on-failure`) - Same build on lavapipe (Mesa 26.2.4 llvmpipe, 8-wide subgroups, `VK_DRIVER_FILES`): 386/386 pass; `agc_driver_flat_store` is left out there because it takes several minutes on Windows llvmpipe - `DepthBoundsBiasTests` (`agc_driver_graphics`) now decodes a depth-biased draw after `ClearContext()`, which CLEAR_STATE runs, with the clamp never written, and gets clamp 0. Fails on `main` with the message above. - PPSA26344 v1.008: no `DWORD 0x2df` skips in a 900 s run; 29,915 before, about 53 per menu frame. - 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
adriadam10 commented 2026-10-08 06:06:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T06:06:28Z.


Checked: 0x2df = 0 matches libSceAgc's register defaults in the repo (RegisterDefaultsData.hpp, every version); the new DepthBoundsBiasTests case fails without the QueueState.hpp change and passes with it; full ctest 415/415 on current main + PR, linux/windows CI green. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6053527302 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1086#issuecomment-6053527302). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-08T06:06:28Z. --- Checked: `0x2df = 0` matches libSceAgc's register defaults in the repo (`RegisterDefaultsData.hpp`, every version); the new `DepthBoundsBiasTests` case fails without the `QueueState.hpp` change and passes with it; full ctest 415/415 on current `main` + PR, linux/windows CI green. Merging.
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!1086
No description provided.