Skip to content

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

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
MichonGoddijn231849:feat/depth-bounds-bias
Oct 4, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
MichonGoddijn231849:feat/depth-bounds-bias

Conversation

@MichonGoddijn231849

@MichonGoddijn231849 MichonGoddijn231849 commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

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.

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 fix(agc): depth fast clears through the HTILE metadata #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

@oneandonlydean

Copy link
Copy Markdown
Collaborator

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 and others added 2 commits October 3, 2026 10:40
DB_DEPTH_CONTROL's DEPTH_BOUNDS_ENABLE now runs the Vulkan depth bounds
test with DB_DEPTH_BOUNDS_MIN/MAX, and PA_SU_SC_MODE_CNTL's
POLY_OFFSET_FRONT/BACK_ENABLE enable depth bias from
PA_SU_POLY_OFFSET_FRONT/BACK_SCALE/OFFSET and _CLAMP. Both are dynamic
state, so draws that differ only in their values share a pipeline.

The hardware slope scale is in 1/16 units. Depth bias with units other
than the depth format's (PA_SU_POLY_OFFSET_DB_FMT_CNTL), or that differs
between front and back faces that are both drawn, is refused. The
registers join the draw key. Depth-conditional color writes are still
refused.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ge_unrestricted

Clamping them changed the result where the stored depth is exactly 0 or 1.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@MichonGoddijn231849

Copy link
Copy Markdown
Contributor Author

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

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

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

@oneandonlydean
oneandonlydean merged commit 0623b69 into boykopovar:main Oct 4, 2026
3 checks passed
SP4C3B4R-8 pushed a commit to SP4C3B4R-8/AnyPS5 that referenced this pull request Oct 6, 2026
Takes the 13 gate-batch PRs that merged upstream (boykopovar#319 boykopovar#329 boykopovar#330 boykopovar#331 boykopovar#325
boykopovar#435 boykopovar#471 boykopovar#294 boykopovar#376 boykopovar#404 boykopovar#394 boykopovar#401 boykopovar#446) in place of astrobot's local
versions, as integ/gate-batch cab0eab had them: boykopovar#294 and boykopovar#376 in
astrobot's depth model (DepthTarget, state.depth), boykopovar#394 with the thick mip
tails, boykopovar#401 over astrobot's slab pool, boykopovar#471 keeping the settled single-lane
path. Also takes the rest of main since a818bee (boykopovar#532 boykopovar#340 boykopovar#486 boykopovar#484 boykopovar#316
boykopovar#243 boykopovar#334 boykopovar#434 boykopovar#437 boykopovar#470 boykopovar#373 boykopovar#452 boykopovar#455 and our upstreamed PRs, where
astrobot keeps its later revisions and env switches).

Resolution notes: relinker converter/matcher/tests are upstream's (boykopovar#432
decoder covers VEX RIP-relative followers); RecompileResult gains boykopovar#316's
hostSubgroupSize (set from request.target.subgroupSize); shader disk cache
format 9; boykopovar#452's scissor message; upstream's later live-stack and
memory-copy decode tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mgp3oZvembQziVNE2xARQK
@MichonGoddijn231849
MichonGoddijn231849 deleted the feat/depth-bounds-bias branch October 9, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants