fix(agc): draw each face with its own depth bias #1924
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1924"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-09T00:07:08Z.
What
decodeDepthBiasrejected a draw that rasterizes both faces when the front and back depth bias differ (depth bias differing between front and back faces). Vulkan has one depth bias per draw, and the cull mode is baked into the pipeline.Such a draw is now recorded twice in the same render pass:
DecodeStatekeeps the front values indepthBias*, puts the back values in the newbackDepthBiasConstant/backDepthBiasSlope, and setsdepthBiasPerFace. A face whose offset enable bit (PA_SU_SC_MODE_CNTL bit 11 or 12) is clear gets bias 0, which is the same as no bias.Pipelinecreates a secondVkPipelinefor that state. The first one culls back faces, the second culls front faces, anddepthBiasPerFaceis part of the pipeline key.Draw.cpprecord the draw with the first pipeline and then callContinueBackFaces(bind the second pipeline, set the back bias) and record it again. Both pipelines share one layout, so descriptor sets and push constants stay bound.The TechnicalDebt entry records the difference from hardware: the vertex stages run twice, and all front faces land before all back faces instead of in primitive order. That only matters for blending or stencil updates that depend on the order, or for a vertex shader that writes memory.
Closes #1923
Tested
Nobara 44 x86-64 (Linux 7.2), GCC 16.2, RTX 5070 Ti, driver 595.91.07. First tested on
mainf1451396; rebased ontomain00112489and retested (see the end of this section).agc_driver_graphics: the depth-bias block now decodes differing front/back bias with no culling, front-only and back-only bias, and cull-front with the back bias. Onmainit fails, because the decode throws.agc_driver_depth_bias_per_face(tests/execution/DepthBiasPerFace.cpp): a front-facing and a back-facing triangle at depth 0.5, aLESStest against a surface cleared to 0.5, opposite biases on the two faces. Only the face that is pulled closer passes, in both directions. Equal biases and front-only bias are checked too. With a single pipeline that draws both faces with the front bias, it fails (the back-facing triangle at (20, 4) is 255, expected depth-rejected).ctest -j1 --timeout 60: 494 of 495 pass. The one failure,guest_dynamic_loader, also fails here on a branch without this change.tools/check_conventions.pyandtools/check_test_registration.pypass.00112489(built withANYPS5_ENABLE_SPIRV_TOOLS=ON):agc_driver_depth_bias_per_faceandagc_driver_graphicspass,ctest -R agc_ -j1passes 279 of 280. The one failure,agc_driver_dcc_keys_first_write, fails on plainmain00112489on this GPU too.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by klosixgaming-arch on 2026-10-09T00:46:23Z.
Review: APPROVED
This is well done and I can approve it.
depthBiasPerFacein the pipeline key means you don't accidentally reuse a single-face pipeline for a per-face state.Require(!state.depthBiasPerFace || (depthBias && state.cullMode == VK_CULL_MODE_NONE))guard is exactly right — per-face only makes sense when both faces actually rasterize.ContinueBackFacesrebinds viewport/scissor/depth-bounds after the pipeline switch, which is the detail people forget when binding a secondVkPipelinemid-pass. Good.decodeDepthBiascorrectly zeroes a face's bias when its offset-enable bit (PA_SU_SC_MODE_CNTL 11/12) is clear, and the tests cover front-only, back-only, equal, and culled-face cases.APS5_REJECT_PER_FACE_DEPTH_BIASescape hatch preserves the old behaviour — nice.DepthBiasPerFace.cpp) with opposite biases and aLESStest against a 0.5 clear, in both directions. Solid.Nothing blocking. The vertex-shader-writes-memory-twice case is the one thing a pathological title could in theory observe, and you've disclosed it. Good.
Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T15:23:23Z.
Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), RTX 3060 Laptop (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head
75af5a0b, merged ontomaind70b8998in one build with 33 other AGC/shader PRs that had no Windows run.agc_driver_depth_bias_per_face,agc_driver_graphics. None of them reported skipping a case.PATHsetup.No title was run.
🤖 Addressed by Claude Code
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-10T05:17:17Z.
This conflicts with main in
Pipeline.cppandtests/Graphics.cppafter today's merges; could you rebase? Please also dropAPS5_REJECT_PER_FACE_DEPTH_BIAS(State.cpp:265) and its TechnicalDebt sentence: a switch that turns the fix off isn't wanted here. It passed testing otherwise.Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-10T05:53:00Z.
Rebased onto main
00112489and the switch is gone. New head: 75239c93.APS5_REJECT_PER_FACE_DEPTH_BIASis removed fromState.cpp, along with its sentence in the TechnicalDebt entry. A draw with different front and back bias is always drawn per face now.Pipeline.cpp: main now destroys the shader modules right aftervkCreateGraphicsPipelines. The back-face pipeline is created before that, since it uses the same modules.tests/Graphics.cpp: kept both sides. The per-face checks come first, then main's new point/line offset enable and polygon mode checks.Tested on an RTX 5070 Ti (NVIDIA 595.91.07), built with
ANYPS5_ENABLE_SPIRV_TOOLS=ON:agc_driver_depth_bias_per_faceandagc_driver_graphicspass, andctest -R agc_ -j1passes 279 of 280. The one failure,agc_driver_dcc_keys_first_write, also fails on plain main00112489on this GPU.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T07:11:29Z.
Rebased onto current
main(the only conflict was a TechnicalDebt line next to the direct memory entry; both kept). Switch removal from the previous push confirmed, noAPS5_REJECT_PER_FACE_DEPTH_BIASleft. Built and ranagc_driver_graphicsandagc_driver_depth_bias_per_faceon RADV: both pass. Merging once CI is green.