Skip to content

feat(agc): accept conservative Z export in DB_SHADER_CONTROL - #752

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
Celegans12:feat/agc-conservative-z-export
Oct 5, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
Celegans12:feat/agc-conservative-z-export

Conversation

@Celegans12

Copy link
Copy Markdown
Contributor

What

A nonzero DB_SHADER_CONTROL.CONSERVATIVE_Z_EXPORT (bits 13-14) was rejected by DecodeState and the draw precheck (depth export, shader coverage or ordered fragment execution) and by DecodePixelStageInfo (AGC graphics: DB_SHADER_CONTROL.CONSERVATIVE_Z_EXPORT is unsupported).

Tested

  • Windows 11, MinGW-w64 GCC 15.2.0, based on main 681f83e: configure -DBUILD_TESTING=ON, full build, --target libs, ctest:
  • 316/316 tests pass (ctest --output-on-failure)
  • New conservativeZExportTests in agc_driver_graphics: with a shader that exports POS_Z as MRTZ, DB_SHADER_CONTROL 0x21, 0x2021, 0x4021 and 0x2020 give DepthReplacing, plus DepthLess, plus DepthGreater, and no depth mode, also after a serializer round trip, with distinct cache keys; DecodeState and the precheck accept 0x2020 and 0x4020; 0x6021 throws; ValidateShaders accepts DepthLess and DepthGreater and still rejects DepthUnchanged. On main it fails with the DecodePixelStageInfo message above.
  • PPSA26344 v1.008, offline over all 10,504 extracted pixel shaders with the driver's DecodePixelStageInfo: only 37a91497897c68dd changes. It now decodes, and its SPIR-V gains OpExecutionMode DepthLess and passes spirv-val. The other 10,503 give the same result and SPIR-V size. Not yet run in game.
  • Not tested: PPSA21564 and Dreaming Sarah (expect a PPSA21564 gate), 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

@github-actions

github-actions Bot commented Oct 5, 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
#375 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp L371
#423 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp L371
#448 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp L371
core/shader/recompiler/CacheKey.hpp L142
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp L680, L704
core/shader/recompiler/Optimization/include/Optimization/ShaderStageInputInfo.hpp L185
core/shader/recompiler/Translation/src/ShaderInputInfoBuilder.cpp L139

DecodeState, the draw precheck and DecodePixelStageInfo rejected every
nonzero CONSERVATIVE_Z_EXPORT (DB_SHADER_CONTROL bits 13-14).
EXPORT_LESS_THAN_Z (1) and EXPORT_GREATER_THAN_Z (2) promise that the
exported Z stays on one side of the interpolated Z. The value now
reaches the recompiler as a pixel stage field, and a pixel shader that
writes FragDepth declares DepthLess or DepthGreater next to
DepthReplacing, the SPIR-V modes RADV maps to these values. Vulkan lets
those modes only add a depth test of the interpolated Z before shading,
so a shader that keeps the promise renders the same. The reserved value
3 still throws.

The field is part of the recompile cache key, the draw key and the
serialized request (version 7), and ValidateShaders accepts both modes.
@Celegans12
Celegans12 force-pushed the feat/agc-conservative-z-export branch from 0cc7f28 to 4a67b14 Compare October 5, 2026 22:35
@github-actions github-actions Bot added shader core/shader docs agc libSceAgc* labels Oct 5, 2026
@oneandonlydean
oneandonlydean merged commit 1438d99 into boykopovar:main Oct 5, 2026
3 checks passed
@Celegans12
Celegans12 deleted the feat/agc-conservative-z-export branch October 5, 2026 23:51
MichonGoddijn231849 added a commit to MichonGoddijn231849/AnyPS5-fork that referenced this pull request Oct 6, 2026
boykopovar#752 took version 7 for the pixel stage's conservative Z export, so a version 7 request
written without this change has no PA_CL_VS_OUT_CNTL word: the field moves to version 8.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
MichonGoddijn231849 added a commit to MichonGoddijn231849/AnyPS5-fork that referenced this pull request Oct 7, 2026
boykopovar#752 took version 7 for the pixel stage's conservative Z export, so a version 7 request
written without this change has no PA_CL_VS_OUT_CNTL word: the field moves to version 8.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
alfalfa-star pushed a commit to alfalfa-star/AnyOrbitr that referenced this pull request Oct 7, 2026
boykopovar#752 took version 7 for the pixel stage's conservative Z export, so a version 7 request
written without this change has no PA_CL_VS_OUT_CNTL word: the field moves to version 8.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
MichonGoddijn231849 added a commit to MichonGoddijn231849/AnyPS5-fork that referenced this pull request Oct 7, 2026
boykopovar#752 took version 7 for the pixel stage's conservative Z export, so a version 7 request
written without this change has no PA_CL_VS_OUT_CNTL word: the field moves to version 8.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
MichonGoddijn231849 added a commit to MichonGoddijn231849/AnyPS5-fork that referenced this pull request Oct 8, 2026
boykopovar#752 took version 7 for the pixel stage's conservative Z export, so a version 7 request
written without this change has no PA_CL_VS_OUT_CNTL word: the field moves to version 8.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* docs shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants