fix(agc): fragment SampleId, Layer, FragDepth and SampleMask interfaces #375
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/375"
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 MichonGoddijn231849 on 2026-10-02T16:15:39Z.
What
The recompiler emits the following, but the SPIR-V validator refused them, so the draws were skipped:
DepthReplacingexecution mode (Z export);int[1]oruint[1]array. Array interface types are now spelledelem[N]by the validator.The validator now accepts them, together with the Geometry and SampleRateShading capabilities those inputs need in fragment shaders. They are accepted only when the device enabled
geometryShaderandsampleRateShading(#295 adds those enables), so a device without them refuses the draw. Vertex stages still refuse those capabilities.GTA V's lighting, decal and particle shaders use these interfaces. The log showed
unsupported device capability 2/35,unsupported fragment built-in,unsupported SPIR-V interface typeandunsupported fragment execution mode.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.
main.ctest: all tests pass. New validation cases cover a fragment shader with SampleId, Layer, FragDepth and SampleMask, a SampleMask of the wrong length, and a vertex shader refusing SampleRateShading.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 repositorymainwith #305, whose HelperInvocation input is kept in the same fragment built-in check🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T05:43:28Z.
The validator side looks right to me, and the new cases are good. One dependency is missing: the body says the device already enables
geometryShaderandsampleRateShading, but on main VulkanDevice.cpp doesn't set either. Only #295 adds them. With this PR alone, a fragment module with Geometry or SampleRateShading passes validation and is created without those features enabled, which the Vulkan spec doesn't allow. Also, main's recompiler still emits ShaderLayer for a fragment Layer input (SpirvModuleSetup.cpp), and #295 is what switches it to Geometry.Could you add
Depends on #295, or move the two device enables into this PR? Ideally Geometry and SampleRateShading would only be accepted when the device enabled them, so a device withoutgeometryShaderrefuses the draw.Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-04T08:48:53Z.
Thanks, you're right: the description was wrong about
main, and only #295 enables those features. I've done both:Depends on #295and rebased this branch onto #295.a40eb82a: the validator now accepts Geometry and SampleRateShading in a fragment shader only when the device enabledgeometryShaderandsampleRateShading. The flags come from the context, where #295's enables now record them. A device without them refuses the draw. The test checks acceptance with both enabled, and the refusal of each capability when its feature is missing.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T09:52:03Z.
Thanks, both done. The validator now accepts Geometry and SampleRateShading in a fragment shader only when the device enabled
geometryShaderandsampleRateShading, and the test checks the refusal of each. Merged with current main it builds and passes the full ctest here. Ready to merge from my side right after #295, once both have been through a PPSA21564 run on my integration branch.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-06T05:34:07Z.
This conflicts with main now in
ShaderValidation.cpp, on the fragment execution-mode check. #752 (conservative Z export) addedExecutionModeDepthLessandExecutionModeDepthGreaterto the sameRequire(...)line where this PR addsExecutionModeDepthReplacing. Accepting all of them (OriginUpperLeft, EarlyFragmentTests, DepthReplacing, DepthLess, DepthGreater) resolves it. #423 and #448 carry this commit and hit the same line.Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-06T15:39:14Z.
Rebased onto current
main(now cc1ed88c). TheShaderValidation.cppline accepts all five fragment modes as you suggested: OriginUpperLeft, EarlyFragmentTests, DepthReplacing, DepthLess and DepthGreater. #423 and #448 are rebased on top of it. Builds; the driver tests pass apart fromagc_driver_scalar_sop1, which fails without this PR too.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-06T20:40:11Z.
Review: CHANGES_REQUESTED
Checked the validator part (SampleId/Layer inputs, FragDepth with DepthReplacing,
SampleMask[1]arrays, and Geometry/SampleRateShading gated on the device enables) against what the recompiler emits. Build + full ctest pass on cc1ed88c (360/360). This PR's own commits look good to me.What blocks merging is the base: this branch carries #295's two commits, and #295 has open review requests (
DrawRejection'sread(cx, 0x1c4)throws when the register is missing, and the Z-export formats have no test). The same code is here atGraphics/src/State.cpp:793. Once #295 is fixed and merged, rebase this ontomainso only the three validator commits remain, and I'll merge it.Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-07T13:02:02Z.
I've been running Ghost of Yotei (PPSA26344 v1.008) with this PR in our integration tree, and it's what gets the game's depth-writing pixel shaders through now. The game has two depth-only draws that export Z: a
DRAW_INDEX_AUTOwith DB_SHADER_CONTROL 0x00000001 that runs once or twice per present from boot, and aDRAW_INDEX_2with 0x00002021 that runs twice per present from the menus on.In a 1,500 s run on an older main (before #295) and without this PR, 1,825 of those draws were skipped. With this PR at cc1ed88c9 on main
0d3c1eec8, a 2,700 s run skips none of them, and nothing else rejects them instead: nounsupported fragment built-in, no execution-mode error, no FATAL and no device lost. A second 2,700 s run that got past the New Game settings had none either. Both runs were on Windows 11 with an RTX 3080 Laptop GPU.Since #295 already brought the DB_SHADER_CONTROL part to main, I checked what main does on its own. Main's recompiler emits
gl_FragDepthwithDepthReplacing, butInspectstill accepts only FragCoord, FrontFacing and HelperInvocation as fragment built-ins and doesn't listDepthReplacing, so I'd expect these draws to stop there without your validator change. I haven't run main by itself to confirm that.The PR conflicts with main at the moment. In our tree the merge was mechanical: main added
imageInt64Atomics,runtimeDescriptorArrayandpartiallyBoundat the same places in VulkanDevice, Context,ValidateShadersand Draw.cpp, so I kept those and put yours after them, and I took #295'szFormatSupported(zFormat)form of the 0x1c4 check inDrawRejection. I'm happy to run Yotei again on the rebased branch.Details
Builds:
yotei/integration5c55633a3 = main0d3c1eec8(#934 merge, 2026-10-07) + our open PRs + #375 at cc1ed88c9 + #1073 at 74870921d + env-gated local probes. Main there already has #295 (zFormatSupported) and the CONSERVATIVE_Z_EXPORT decoding.yotei/integrationc26df5aac, on a main from before #295, without #375.The skipped draws, from
stderrof the run without the PR:With the PR: 0 and 0 in the cold 2,700 s run (1,115 presents) and in the warm 2,700 s run. Neither run's log has
unsupported fragment built-in,unsupported fragment execution mode,unsupported SPIR-V interface type,depth or sample-mask export, FATAL or device lost. 0x2021 also sets CONSERVATIVE_Z_EXPORT to 1, so those shaders go through main's conservative-Z mapping as well.gh_conflict_checkof cc1ed88c9 onto main68010dfbflists VulkanDevice.cpp, Context.hpp, Pipeline.hpp, Draw.cpp, ShaderValidation.cpp and State.cpp.Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-07T17:31:04Z.
Rebased onto current
main(now29aa2756). #295 is merged, so the branch now carries only this PR's three validator commits. Conflicts:mainaddedimageInt64Atomicsat the same places (VulkanDevice,Context,ValidateShaders/Inspectand theDraw.cppcall). Both stay, withmain's parameter first, and the validator tests now passimageInt64Atomics = falsebeforegeometryShaderandsampleRateShading. Build and ctest pass.@Celegans12 thanks for the Yotei runs. That matches what I see:
main'sInspectstill rejectsFragDepthandDepthReplacingwithout this PR.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-07T20:02:07Z.
Review: APPROVED
Rechecked on
29aa2756merged with current main: build + full ctest pass (400/400), and the base issue from my previous review is gone now that #295 is merged, so I'm withdrawing that request.SampleMaskArrayTypeisint[1], Layer/SampleId are loaded asint).Signature()doesn't let arrayedLocationvariables through:AddLocationsstill unrolls them first.Runtime coverage is good too: GTA V, Dreaming Sarah and Demon's Souls from the author, plus @Celegans12's 2,700 s Ghost of Yotei run with no skipped Z-export draws. Merging. @oneandonlydean, if your PPSA21564 run turns something up, a follow-up PR can handle it.