AGC: draws with different front and back depth bias are rejected #1923

Closed
opened 2026-10-09 00:07:06 +00:00 by fisherjoey · 0 comments
fisherjoey commented 2026-10-09 00:07:06 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-09T00:07:06Z.


Summary

decodeDepthBias (core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp:250 on main f1451396) throws depth bias differing between front and back faces when a draw rasterizes both faces (no culling in PA_SU_SC_MODE_CNTL) and the front and back bias differ: the enable bits 11/12, or PA_SU_POLY_OFFSET_FRONT_SCALE/OFFSET (0x2e0/0x2e1) against BACK_SCALE/OFFSET (0x2e2/0x2e3). The draw is skipped, and after the first time it is skipped at precheck.

Vulkan has one depth bias per draw, and the pipeline (Pipeline.cpp:215) bakes in the cull mode. When one face is culled, the decoder already takes the other face's values, so only the no-culling case is missing.

Impact on Demon's Souls (PPSA01341 v1.07)

The tutorial level's shadow casters use this state: PA_SU_SC_MODE_CNTL 0x01001a48 (no culling, both offsets enabled), front slope -17.6 against back slope -480000, constant -30000 on both. Depth only (CB0 = COLOR_INVALID), into the shadow depth at 0x2a4700000. About 4.3k draws per 10 s are skipped ([gpu] skipped draw again: ... depth bias differing between front and back faces). #1086 (0x2df) and #1346 (format-0 colour slots) took care of the other rejections of these shadow draws, so this is the one left.

Fix

Branch: https://github.com/fisherjoey/AnyPS5/tree/fix/depth-bias-per-face

  • DecodeState keeps the front values in depthBias* and puts the back values in the new backDepthBias* with depthBiasPerFace set. A face that has its enable bit clear gets bias 0.
  • Pipeline builds a second VkPipeline for such a state. The first culls back faces and the second culls front faces. Draw records the draw once with each, setting the matching bias through the dynamic depth bias state. Descriptor sets and push constants stay bound, because both pipelines share one layout.
  • APS5_REJECT_PER_FACE_DEPTH_BIAS=1 brings back the old rejection.
  • TechnicalDebt entry: the vertex stages run twice, and all front faces land before all back faces. That matters only for blending or stencil updates that depend on primitive order.

Tests: agc_driver_graphics decodes the per-face cases (fails on main, where the decode throws), and the new GPU test agc_driver_depth_bias_per_face draws a front-facing and a back-facing triangle with opposite biases against a depth test, and only one of them may pass. A build that draws both faces with the front bias fails it.

Found on Linux 7.2 (Nobara 44), GCC 16, RTX 5070 Ti (595.91.07).

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5770690678 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/1923). Originally posted by [fisherjoey](https://github.com/fisherjoey) on 2026-10-09T00:07:06Z. --- ### Summary `decodeDepthBias` (`core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp:250` on `main` f1451396) throws `depth bias differing between front and back faces` when a draw rasterizes both faces (no culling in PA_SU_SC_MODE_CNTL) and the front and back bias differ: the enable bits 11/12, or PA_SU_POLY_OFFSET_FRONT_SCALE/OFFSET (0x2e0/0x2e1) against BACK_SCALE/OFFSET (0x2e2/0x2e3). The draw is skipped, and after the first time it is skipped at precheck. Vulkan has one depth bias per draw, and the pipeline (`Pipeline.cpp:215`) bakes in the cull mode. When one face is culled, the decoder already takes the other face's values, so only the no-culling case is missing. ### Impact on Demon's Souls (PPSA01341 v1.07) The tutorial level's shadow casters use this state: `PA_SU_SC_MODE_CNTL` 0x01001a48 (no culling, both offsets enabled), front slope -17.6 against back slope -480000, constant -30000 on both. Depth only (CB0 = COLOR_INVALID), into the shadow depth at 0x2a4700000. About 4.3k draws per 10 s are skipped (`[gpu] skipped draw again: ... depth bias differing between front and back faces`). #1086 (0x2df) and #1346 (format-0 colour slots) took care of the other rejections of these shadow draws, so this is the one left. ### Fix Branch: https://github.com/fisherjoey/AnyPS5/tree/fix/depth-bias-per-face - `DecodeState` keeps the front values in `depthBias*` and puts the back values in the new `backDepthBias*` with `depthBiasPerFace` set. A face that has its enable bit clear gets bias 0. - `Pipeline` builds a second `VkPipeline` for such a state. The first culls back faces and the second culls front faces. `Draw` records the draw once with each, setting the matching bias through the dynamic depth bias state. Descriptor sets and push constants stay bound, because both pipelines share one layout. - `APS5_REJECT_PER_FACE_DEPTH_BIAS=1` brings back the old rejection. - TechnicalDebt entry: the vertex stages run twice, and all front faces land before all back faces. That matters only for blending or stencil updates that depend on primitive order. Tests: `agc_driver_graphics` decodes the per-face cases (fails on `main`, where the decode throws), and the new GPU test `agc_driver_depth_bias_per_face` draws a front-facing and a back-facing triangle with opposite biases against a depth test, and only one of them may pass. A build that draws both faces with the front bias fails it. Found on Linux 7.2 (Nobara 44), GCC 16, RTX 5070 Ti (595.91.07). AI-assisted: yes.
Sign in to join this conversation.
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#1923
No description provided.