fix(shader): defer guarded fragment V# type faults #7689
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7689"
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 MarcZX10 on 2026-10-18T23:30:17Z.
What
This is a fragment-stage follow-up to #6412. Its author confirmed that #6412 remains compute-only and asked that the Kena case be handled separately.
Tested
Rebased onto current upstream
main1da991f9bb. Current PR head75e1ccb8be(one commit on top ofmain; the previous head3e63c0489ais replaced).Windows 11, Ryzen 7 260 (AVX2, FMA and BMI2 present), GCC 15.2 UCRT, Release, with
BUILD_TESTING=ON. No GPU or Vulkan validation-layer run on this host.agc_driver_draw_unsupported_buffer_type_tests,agc_driver_stencil_replay_tests,agc_shader_disk_cache_testsandagc_driver_image_table_reuse_tests: passed.draw_unsupported_buffer_type(including_deferred_fault,_skip_refused,_draw_pipeline,_plan_verify),image_table_reuse(all 8 entries),stencil_replay(both entries) andagc_shader_disk_cache(all 5 entries): 24 of 24 passed.python3 tools/check_conventions.py --base origin/main: passed.git diff --check origin/main...HEAD: clean.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Cache format coordination
Current
mainuses shader cache format 96. This PR uses 97, which is abovemain. TheFormatVersion - 1round-trip checks inShaderDiskCachetests are unchanged. Open #6924 and #6412 may propose other versions; recheck the next unused version if cache-format changes land before this PR.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-19T00:21:46Z.
@MarcZX10 I ran
agc_driver_draw_unsupported_buffer_typeon an RTX 4090 (Linux, NVIDIA): it is the first run of this test anywhere, since your host can't build it. On b0507123c8 it fails before any assertion, withunsupported SOP1 opcode 0.The first word of
InactivePixelCode,0xbe8c0080, decodes as SOP1 opcode 0 into s12. On GFX10,s_mov_b32is SOP1 opcode 3, and opcode 0 doesn't exist, so the recompiler refuses the shader. Even with opcode 3,s_mov_b32doesn't write SCC, so thes_cbranch_scc1after it would branch on whatever SCC holds at entry rather than skip the load as intended.Could you build the inactive case from instructions the translator accepts and that make the load's lanes inactive for certain? For example, clear EXEC first (
s_mov_b32 exec_lo, 0, ors_mov_b64 exec, 0for wave64) and either keep the load in the program or skip it withs_cbranch_execz. Then check the encodings against the GFX10 tables, the wayPixelCodedoes. Keeping the load in the program with no active lanes is closer to the case in #5879, where the load is still in the shader. Once it runs,InactiveLaneDoesNotFaultandNamesShaderAndDescriptorwould cover both sides.Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-19T06:54:59Z.
Rebase handoff, with one serializer collision resolved and one open failure —
mainand this PR each added aDescriptorBindingfield and anaddGuestBufferparameter (main'sbufferExtent, yourbufferDeferredTypeFault); the merged version carries both: both struct fields, both parameters, both encoder/decoder lines, with the disk-cache format bumped to v41 and the size assert pinned to the merged 696.The open failure:
agc_driver_draw_unsupported_buffer_typefails withunsupported SOP1 opcode 0— it fails identically on your own unrebased head, so it is the PR's own state, not the merge: with the deferred type fault wired through, a path that previously threw at bind time now reaches the shader with an unencoded SOP1 instruction (opcode 0), which surfaces as a driver failure rather than the expected refusal. Beyond that and the three knownmainregressions (#5444 Mesa, #7584 BDA, #7766 image-table vouch), the suite is green and conventions pass.To pick it up:
Head is
b0507123c.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-19T16:09:28Z.
I checked the failing fixture and confirmed
0xbe8c0080is unsupported SOP1 opcode 0. I replaced it locally with0xbefe0480(s_mov_b64 exec, 0), leaving the invalid V# load in the shader with all lanes inactive; this avoids relying on SCC state and matches the intended regression.git diff --checkpasses. I could not build the execution target in this worktree because it has no configured build tree, and rebasing the current PR onto today’smainstops on six conflicts in ShaderResources.hpp/.cpp, DescriptorBindingBuilder.cpp, Recompiler.hpp, and ShaderDiskCache.cpp/.hpp. The fix is ready as a small isolated patch, but I have not pushed it since the rebase would need those serializer and cache conflicts resolved.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-19T16:25:23Z.
Update: I resolved the current-main conflicts while preserving both
bufferExtentandbufferDeferredTypeFault, encoded/decoded both fields, and bumped the shader disk-cache format to v41. The combinedDescriptorBindingsize assertion (696 bytes) and the fullagc_driver_draw_unsupported_buffer_type_teststarget compile and link successfully on Linux. The runtime test aborts before entering the test because this host lacks LZCNT, BMI1/BMI2, MOVBE, AVX2, and FMA. I replaced the malformed inactive fixture instruction withs_mov_b64 exec, 0, so the load remains in the program with no active lanes. Rebased head pushed:bde890a15e.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T17:01:04Z.
Review: CHANGES_REQUESTED
Thanks for the follow-up. The deferral design looks consistent with #6412, and the
s_mov_b64 exec, 0fixture is correctly encoded. One thing to fix:core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp:5466and:5470:CheckFaults()andWriteBackBuffers()now only callbda->CheckFault()whenfaultChecksis set. This is not specific to deferred fragment faults and changes every BDA user. The copied-writes path (Draw.cpp:1683) callsWriteBackBuffers()whether or notfaultChecksis set, so a fault on a draw whereprepareAddressBindingsleftfaultChecksfalse (for exampletableFaultsOnlywithoutimageTableFaults/poisonedSrtReads) is no longer reported. Previously it threw. Please restore the unconditionalif (bda) bda->CheckFault();. The new case already setsfaultChecksthroughdeferredBufferTypeFaults, so nothing else is needed. If you want the skip for a measured reason, scope it and add a test that shows the fault is still reported.Also note that #6924 and #6683 both take shader disk-cache
FormatVersion41. Whichever lands second has to move to the next free number.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-19T17:12:43Z.
Thanks for identifying the regression. I rebased this branch onto current
mainand restored unconditionalbda->CheckFault()calls in bothCheckFaults()andWriteBackBuffers()in commitb5e75434b4. I also moved this branch's cache format to 42 in separate commit487f12f9d6; current main uses 40, while the open #6412, #6488, #6924 and #7395 branches currently propose 41.On current main
7a015c0946e2f421b7977129dc7fc255a133019b, conventions and the focused target builds pass, andshader_cache_file_readpasses. The AGC test aborts before assertions because this host lacks LZCNT, BMI1/2, MOVBE, AVX2 and FMA, and I cannot run the required Vulkan validation-layer comparison here. Could you rerun the focused test on this head with validation enabled and compare it with current main?Imported from boykopovar/AnyPS5. Originally posted by ymatrix1 on 2026-10-19T17:16:46Z.
Ran Kena (PPSA01802) on Windows, RTX 4070 Super, to see whether this PR carries it past Continue.
c050c1755, on676d42396): reaches the menu; after Continue it stops withcompute shader 0x2008b80000: buffer specialization has an unsupported format. That is a typed-buffer format 0 on the same stale V# from #5879, not a TYPE rejection, so a TYPE-only deferral will not get Kena past Continue by itself. Earlier traces on #5879 hit reserved bit, unaligned base and an unreadable range from the same slot.b0507123c, ona6dd29b3d): Kena never shows a frame; it stops at startup withindirect register sentinel semantics are not implemented. The base commita6dd29b3dwithout this PR stops the same way, so it is not caused by this PR, and I could not evaluate the PR on Kena at that base.ShaderResources.hpp/.cpp,ShaderAddressResources.cpp,ShaderInfo.hpp,DescriptorBindingBuilder.cpp,ResourceMaterializer.cpp,Recompiler.hppandShaderDiskCache.cpp/.hpp, so I did not run the combination.Suggestion: for Kena the deferral would also have to cover the non-TYPE validations on that slot. I can re-run Kena once #6412 is merged and this PR is rebased on it.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-19T20:27:03Z.
Thanks for the Kena comparison. It confirms the startup failure, “indirect register sentinel semantics are not implemented,” is identical on the PR and its tested base, so this run does not establish a regression or show Kena progressing with this change. I also note that #6412 alone reaches the menu but then stops on typed-buffer format 0, and the stacked combination was not tested because of conflicts. I’ll keep the PR’s claims limited to deferring the guarded TYPE fault and won’t present this as a Kena fix.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T09:54:51Z.
I merged current
maind14a186f46into #7689 ase5cdc78345, resolving the cache changes by retaining main’s mesh-barycentric serialization and this PR’s deferred-type fields with format version 42. The exact merged tree buildsagc_driver_draw_unsupported_buffer_type_testsandshader_cache_file_read_tests;shader_cache_file_readpasses 1/1. The AGC runtime test still stops at this host’s CPU feature guard before assertions. Conventions andgit diff --checkpass on the merge. I updated the Tested section to keep the earlier Kena report explicitly tied to its old head/base; it does not establish a current-head Kena result.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T17:02:23Z.
Thanks for the EXEC fix:
s_mov_b64 exec, 0is a valid encoding now, and the test gets past the recompiler. I ran this head (e5cdc78345) on an RTX 4090 with the test enabled, and it shows two problems:NamesShaderAndDescriptorfails at recompile:ShaderRecompiler::Recompile: BDA fault function is missingfor the active-lane pixel shader. For an eligible buffer the branch setsusesFaultBufferandSpirvRuntimeBuffer.cppcallsfaultIf(..., InvalidDescriptor), butRecordBdaFault/RecordBdaFaultReasoninSpirvBdaFault.cppalso requireusesDma, which a plain buffer load in a pixel shader doesn't set. So the deferred fault can't be emitted. Linux CI runs this test on lavapipe, so it will fail there too.InactiveLaneDoesNotFaultpasses even with the deferral disabled (I seededdeferInvalidBufferTypeFaultswithfalseinResourceMaterializer.cpp, and the case still passed). With a constantexec = 0, the load is probably folded away, so the buffer never reaches the resource checks. Could you take EXEC from a value the compiler can't fold (for example a user SGPR set to 0), so that the case fails without the deferral?Separately, the branch conflicts with current
maininShaderResources.cpp(main's newclassified/writeOnlylines next to yourdeferTypeFaultargument) and in theShaderDiskCache.cppsize asserts (IrValueis 128 on main now).Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T18:06:33Z.
I merged current
main(892a4f1328) into this branch and addressed both findings from the exact-head review. Commitebcc556b01letsRecordBdaFaultandRecordBdaFaultReasonuse the non-DMA fault-buffer ABI when a fault function exists, emitting the high address word as zero for these 32-bit guest-buffer addresses. Commit4f855d1cadmakes the inactive-lane case load EXEC from zero-valued runtime user SGPRs, so it is not folded away. The cache assertion now reflects the mergedIrValuesize of 128 bytes; theIrResourcePlanassertion remains 768 bytes.The focused
agc_driver_draw_unsupported_buffer_type_teststarget builds successfully, andcheck_conventions.py --base upstream/mainplusgit diff --checkpass. CTest cannot reach the assertions on this Xeon: the project CPU guard aborts because the host lacks LZCNT, BMI1/2, MOVBE, AVX2 and FMA. Could you rerun the focused test on a supported Vulkan host to confirm both the active fault path and inactive-lane behavior on this exact head?Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T18:09:14Z.
Correction to my earlier note: after checking current main (
FormatVersion = 41) and open #6924 (which proposes 42), I changed this branch to format 43 in commita24ccea56bto avoid the collision. The PR description is updated accordingly. The current-main build of both focused targets passes,shader_cache_file_readpasses 1/1, and the unsupported-buffer runtime test still cannot reach assertions on this CPU.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T03:25:37Z.
I checked the current diff against this point. Commit
b5e75434b49brestores unconditionalbda->CheckFault()calls in bothCheckFaults()andWriteBackBuffers(), whilefaultChecksis still used only to decide whether the deferred fragment fault path is armed. That preserves fault reporting for other BDA users. I also moved this branch to cache format 43 to avoid the #6924/#6683 collision. Thanks for identifying both issues.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-21T17:34:02Z.
Review: CHANGES_REQUESTED
The new commits address the earlier findings, but
mainmoved and this no longer merges:core/shader/recompiler/ShaderDiskCache.cpp(size asserts next to main's newuserDataRegisterReads/remappedDepth1D/flatSlotsfields) and intests/execution/DrawUnsupportedBufferType.cpp.ShaderDiskCache.hpp: main is atFormatVersion = 44now, the branch sets 43. Needs to be above main's value (45), or the merge lowers it.agc_driver_draw_unsupported_buffer_type_skip_refused(952ddb784,--skip-refusedmode of the same test) submits this exact fragment shader and expects the draw to be refused and skipped. With this PR the type-2 V# is deferred to a draw-completion fault instead, so that test no longer exercises a refused draw. It needs a case that is still refused (for example a buffer the defer conditions exclude: written, atomic or formatted), or an updated expectation, while keepingInactiveLaneDoesNotFaultand the fault check.Please merge current
main, bump the cache version, and rerun both ctest entries of that test.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T03:35:01Z.
Review: COMMENTED
I rechecked this against current
mainand the latest review. The PR head remains based on the older cache schema: current main hasShaderDiskCache::FormatVersion = 44, while this branch sets 43. The current tree merge also conflicts inShaderAddressResources.cpp,DrawUnsupportedBufferType.cpp, andShaderDiskCache.cpp/.hpp. More importantly, the latest review points outagc_driver_draw_unsupported_buffer_type_skip_refusedcurrently uses the same fragment TYPE 2 V# that this PR defers to draw-completion, so the test may stop verifying refusal; it requests a still-refused case (for example written, atomic, or formatted) and rerunning both CTest modes. I have not changed the branch because these are behavior and cache-compatibility questions that need a carefully reviewed fix, not mechanical conflict resolution. The local compatible-CPU runtime test is also unavailable here due the Xeon missing LZCNT/BMI1/BMI2/MOVBE/AVX2/FMA.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-27T00:49:18Z.
Review: CHANGES_REQUESTED
Checked the current head merged onto
main(full Agc/AgcDriver ctest on CI's lavapipe). Not mergeable yet:ResourceMaterializer.cpp(ApplyStaticInterface, defer eligibility): every read-only pixel-stage buffer with plainLoadBufferU32*loads is marked deferred and setsusesFaultBuffer, even when its V# is valid.StencilReplay.cpp:851rejects any shader withusesFaultBufferand noguardedSrtSlots, soagc_driver_stencil_replayandagc_driver_stencil_replay_no_gplfail with "stencil reference export emulation requires a replay-safe pixel shader with late tests"; both pass onmain. The deferral has to apply only to a descriptor that is actually invalid (or the replay check has to accept it), without changing what valid draws do.ExtractPlan:materializeTableschecks the plan from there, andApplyStaticInterfaceruns later, so the draw is still refused at capture. One shared helper for both.materializeTables: the ADD_TID check must apply only to TYPE 0; the type-2 V# in the test has bit 23 set and is rejected as "ADD_TID is only valid for compute shaders" before the deferral is reached.SpirvRuntimeBuffer.cpp/SpirvBdaFault.cpp: record the deferred fault withRecordBdaFaultWords(it handles both fault ABIs) and revert the non-DMA branch inRecordBdaFault/RecordBdaFaultReason: their other callers pass 64-bit addresses, which emits invalid SPIR-V in a shader without DMA wheremainthrows.DrawUnsupportedBufferType.cpp: the fault reports the IR stage (stage=2for a pixel shader), not 5.ReportsDeferredTypeFaultandNamesShaderAndDescriptorcan't share a process: after the first failed draw the driver failure is latched and the next draw rethrows it. Run the deferred-fault case as its own ctest entry (e.g.--deferred-fault).Happy to look again once the first point has a design.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-27T02:46:22Z.
Review: CHANGES_REQUESTED
Thanks for keeping it merged with
main.e82d0abec6only mergesmain, though, and every point of the previous review still applies to it:ResourceMaterializer.cpp:2186-2209(ApplyStaticInterface): every read-only pixel buffer with plainLoadBufferU32*loads is still marked deferred and setsusesFaultBuffer, even when its V# is valid.StencilReplaySafe(StencilReplay.cpp:852) then refuses the shader, soagc_driver_stencil_replayandagc_driver_stencil_replay_no_gplfail ("stencil reference export emulation requires a replay-safe pixel shader with late tests"). Both pass onmain. Valid draws must behave as they do onmain. Either arm the deferral only for a descriptor that is actually invalid, or show that replaying a shader that records the deferred fault is safe and let the replay check accept that case.ExtractPlanstill doesn't compute the eligibility.materializeTables(:1520) reads it from the plan, which is extracted beforeApplyStaticInterfaceruns, so the draw is still refused at capture. Use one helper for both.materializeTables:1519: the ADD_TID check still runs before the TYPE check. The test's type-2 V# has bit 23 set, so it gets "ADD_TID is only valid for compute shaders" before the deferral is reached. Apply the check to TYPE 0 only.SpirvBdaFault.cpp:79-93: the non-DMA branch inRecordBdaFault/RecordBdaFaultReasonis still there. Their other callers pass 64-bit addresses, which would emit invalid SPIR-V in a shader without DMA, wheremainthrows. Record the deferred fault inSpirvRuntimeBuffer.cpp:110throughRecordBdaFaultWords, which handles both fault ABIs.DrawUnsupportedBufferType.cpp:108: the fault reports the IR stage (stage=2for a pixel shader), not 5.:164-166: the three cases still share one process, and after the first failed draw the driver failure is latched and the next draw rethrows it. Give the deferred-fault case its own ctest entry (for example--deferred-fault).View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.