feat(agc): depth bounds test and depth bias #376

Merged
MichonGoddijn231849 merged 2 commits from upstream-pr/376 into main 2026-10-04 09:55:58 +00:00
MichonGoddijn231849 commented 2026-10-02 16:15:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-02T16:15:48Z.


What

  • Depth bounds: DB_DEPTH_CONTROL's DEPTH_BOUNDS_ENABLE runs the Vulkan depth bounds test with DB_DEPTH_BOUNDS_MIN/MAX (0x008/0x009). Without a depth surface it is still refused. Bounds outside [0, 1] are refused unless VK_EXT_depth_range_unrestricted is available, because clamping them would change the result at a stored depth of exactly 0 or 1.
  • Depth bias: PA_SU_SC_MODE_CNTL's POLY_OFFSET_FRONT/BACK_ENABLE enable Vulkan depth bias:
    • constant factor = PA_SU_POLY_OFFSET_FRONT/BACK_OFFSET;
    • slope = _SCALE / 16 (the hardware scale is in 1/16 units);
    • clamp = PA_SU_POLY_OFFSET_CLAMP.
  • Refused depth bias:
    • bias whose PA_SU_POLY_OFFSET_DB_FMT_CNTL units differ from the depth format's. A context that never writes the register is taken to use the format's units;
    • front and back bias that differ while both faces are drawn.
  • Pipelines: both are dynamic state, so draws that differ only in bounds or bias values share a pipeline.
  • Draw key: the registers join it.
  • Still refused: depth-conditional color writes (DB_DEPTH_CONTROL bits 30/31).
  • Device: depthBounds and depthBiasClamp are enabled when the device has them.

GTA V draws its deferred light volumes with the depth bounds test, and its shadow maps with depth bias. Both had been refused, so the scene got no point or spot lights and no shadows.

Tested

Windows 11 Pro, AMD Ryzen 5 7600, NVIDIA GeForce RTX 5080 (driver 32.0.16.1074), 32 GB DDR5-5600, MinGW-w64 GCC 15.2.0.

  • GTA V (PPSA04264), with #374: the light volumes and shadow-map draws are no longer rejected, and the Prologue's interior lights show.
  • Dreaming Sarah (PPSA02929): the title menu, its text and the first scene render as on main.
  • Demon's Souls (PPSA01342), with #231 and #232: it reaches the main menu.
  • ctest: all tests pass. New cases cover the decode of bounds and bias, and out-of-range bounds being refused without VK_EXT_depth_range_unrestricted and accepted with it.

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
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none (touches the same DrawKeyRegisters line as #374; whichever lands second takes both ranges)
  • AI-assisted: yes. Written with Claude (Anthropic) under my direction; I reviewed and tested it.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4718737583 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/376). Originally posted by [MichonGoddijn231849](https://github.com/MichonGoddijn231849) on 2026-10-02T16:15:48Z. --- ### What - **Depth bounds:** `DB_DEPTH_CONTROL`'s `DEPTH_BOUNDS_ENABLE` runs the Vulkan depth bounds test with `DB_DEPTH_BOUNDS_MIN/MAX` (`0x008`/`0x009`). Without a depth surface it is still refused. Bounds outside [0, 1] are refused unless `VK_EXT_depth_range_unrestricted` is available, because clamping them would change the result at a stored depth of exactly 0 or 1. - **Depth bias:** `PA_SU_SC_MODE_CNTL`'s `POLY_OFFSET_FRONT/BACK_ENABLE` enable Vulkan depth bias: - constant factor = `PA_SU_POLY_OFFSET_FRONT/BACK_OFFSET`; - slope = `_SCALE` / 16 (the hardware scale is in 1/16 units); - clamp = `PA_SU_POLY_OFFSET_CLAMP`. - **Refused depth bias:** - bias whose `PA_SU_POLY_OFFSET_DB_FMT_CNTL` units differ from the depth format's. A context that never writes the register is taken to use the format's units; - front and back bias that differ while both faces are drawn. - **Pipelines:** both are dynamic state, so draws that differ only in bounds or bias values share a pipeline. - **Draw key:** the registers join it. - **Still refused:** depth-conditional color writes (`DB_DEPTH_CONTROL` bits 30/31). - **Device:** `depthBounds` and `depthBiasClamp` are enabled when the device has them. GTA V draws its deferred light volumes with the depth bounds test, and its shadow maps with depth bias. Both had been refused, so the scene got no point or spot lights and no shadows. ### Tested Windows 11 Pro, AMD Ryzen 5 7600, NVIDIA GeForce RTX 5080 (driver 32.0.16.1074), 32 GB DDR5-5600, MinGW-w64 GCC 15.2.0. - GTA V (PPSA04264), with #374: the light volumes and shadow-map draws are no longer rejected, and the Prologue's interior lights show. - Dreaming Sarah (PPSA02929): the title menu, its text and the first scene render as on `main`. - Demon's Souls (PPSA01342), with #231 and #232: it reaches the main menu. - `ctest`: all tests pass. New cases cover the decode of bounds and bias, and out-of-range bounds being refused without `VK_EXT_depth_range_unrestricted` and accepted with it. ### 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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none (touches the same `DrawKeyRegisters` line as #374; whichever lands second takes both ranges) - [x] AI-assisted: yes. Written with Claude (Anthropic) under my direction; I reviewed and tested it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
oneandonlydean commented 2026-10-03 06:28:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-03T06:28:26Z.


One exactness note: without VK_EXT_depth_range_unrestricted, out-of-range depth bounds are clamped to [0, 1]. That changes the result where the stored depth is exactly 0 or 1. For example, with DB_DEPTH_BOUNDS_MIN above 1 the hardware rejects every pixel, but after the clamp a pixel at depth 1 passes. Refusing bounds outside [0, 1] when the extension is missing would keep it exact; that's what my integration branch does.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5966361830 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/376#issuecomment-5966361830). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-03T06:28:26Z. --- One exactness note: without VK_EXT_depth_range_unrestricted, out-of-range depth bounds are clamped to [0, 1]. That changes the result where the stored depth is exactly 0 or 1. For example, with DB_DEPTH_BOUNDS_MIN above 1 the hardware rejects every pixel, but after the clamp a pixel at depth 1 passes. Refusing bounds outside [0, 1] when the extension is missing would keep it exact; that's what my integration branch does.
MichonGoddijn231849 commented 2026-10-03 08:43:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-03T08:43:10Z.


Agreed, thanks. Pushed: bounds outside [0, 1] are now refused when VK_EXT_depth_range_unrestricted is missing instead of clamped, with a test, and the branch is rebased onto main.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5967287369 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/376#issuecomment-5967287369). Originally posted by [MichonGoddijn231849](https://github.com/MichonGoddijn231849) on 2026-10-03T08:43:10Z. --- Agreed, thanks. Pushed: bounds outside [0, 1] are now refused when `VK_EXT_depth_range_unrestricted` is missing instead of clamped, with a test, and the branch is rebased onto `main`.
github-actions[bot] commented 2026-10-03 11:40:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-03T11:40:30Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#453 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp L705-707
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5968808164 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/376#issuecomment-5968808164). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-03T11:40:30Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #453 | `core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp` [L705-707](https://github.com/boykopovar/AnyPS5/blob/13cbbfa7f749d6c38e41bde6f5afebd7d30b993b/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp#L705-L707) | | |
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!376
No description provided.