fix(agc): accept any fragment export where the draw has no color target #6708
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6708"
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 milescoviello on 2026-10-16T05:56:58Z.
What
Crimson Desert (PPSA25286) stops at its first draw:
A throwaway print at the refusal in
ValidateShaders(ShaderValidation.cpp) shows the draw:The draw binds no color target (no blends, no colors), probably a depth-only pass. Its pixel shader still exports a uint4 at MRT0. The check goes over every output below
max(blends, 1)and requiresf32x4, oru32x4for integer and packed targets. At location 0 it finds no target, so it falls back tof32x4and refuses the draw.A location without a color target has no attachment in the pipeline. With no blends,
colorAttachmentCountis 0, and a gap between written slots isVK_ATTACHMENT_UNUSED. Vulkan discards an output that has no attachment, whatever its type. The check now applies only where a color target exists. The location still goes into the returned output set as before, so masks and pipeline keys of draws that already ran don't change.Tested
Linux (Ubuntu 24.04, GCC 13.3, Release), RTX 4070 Ti, NVIDIA 595.99.
agc_driver_graphics: the packed-export shader there exports a uint4 at location 0. It's now validated against a state with no color targets and no blends, and against one with a target at slot 1 and slot 0 unused, the gap a draw can actually have. (@jotitadev pointed out that my first unused-slot state, no colors with one blend, is one the pipeline refuses before validation.) Both are accepted, and validating it against a float target still fails withfloat4 colors. Withmain'sShaderValidation.cppthe test fails with the title's line,fragment shader must export float4 colors to its attachments. It passes 3 of 3 with this change.^agc_driver_|^agc_vertex_barrier|recompiler|shader_cache|request_serializer|spirv, 468 tests): 467 pass.agc_driver_store_over_untrackedfails the same way onmain5d9dcc42dhere; #6385 addresses it.Crimson Desert, scripted pad input, with #6612, #6613, #6706 and #6178 (for memory), which it needs to reach this draw:
Nothing is presented by then, so I haven't seen this draw's result. The test above covers the validation.
Validated on Windows 11 with an AMD Radeon 860M (RDNA 3.5, driver 32.0.13058.8001) by @LeandroLP23 (comment), in one build of
main6efb7261bwith this head and 13 other pull requests:agc_driver_graphicsandagc_driver_store_over_untrackedpass 3 runs of 3. 713 of 716agc_*tests pass; the 3 that fail fail the same way onmainthere.Not checked on Intel or on a console.
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest -R '^agc_' -Vonmaine2a2914aa1and onmain+ this PR (3d5335ab3a, a local merge).main: 815 of 815 pass; with this PR: 815 of 815 pass. Neither log reports the layer missing. VUIDs onmain:VUID-VkImageViewCreateInfo-usage-02275×6,VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605×18,VUID-vkCmdCopyBuffer-srcBuffer-00118×2,VUID-vkCmdDraw-multisampledRenderToSingleSampled-07285×2,VUID-vkCmdWaitEvents-srcStageMask-01158×2,VUID-vkSetEvent-event-09543×2; with this PR:VUID-VkImageViewCreateInfo-usage-02275×6,VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605×18,VUID-vkCmdCopyBuffer-srcBuffer-00118×2,VUID-vkCmdDraw-multisampledRenderToSingleSampled-07285×2,VUID-vkCmdWaitEvents-srcStageMask-01158×2,VUID-vkSetEvent-event-09543×2. None is new with this PR.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T06:09:22Z.
I also found a hole in the targetless case.
ValidateShadersstill loops only up tomax(blends.size(), 1)and validates the export type when noColorTargetexists at that location. So withcolors.empty()butblends.size() == 1(an unused attachment slot), auint4export still hits the fallbackf32x4check. The new test resizesblendsbut uses a packed export? It should exercise this exact state with a write-enabled blend entry; skipping type validation whenfind_if(state.colors, exportIndex)returns end fixes it while retaining the location in the returned set. I reproduced the path from the current function; the full graphics test build is currently blocked in unrelated GCC 12 parsing atSrtDescriptorEvaluation.cpp:183.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T06:10:30Z.
Correction: my previous comment was a false positive. I checked the PR diff again and its
Require(color == state.colors.end() || ...)already skips type validation for a location with noColorTarget, including whenblendshas an unused slot. The added tests cover the no-blend and unused-slot cases, so the extra write-mask case I suggested is redundant. Sorry for the noise.Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-16T06:28:08Z.
Review: COMMENTED
Static review of head d5b49fdac (no build, no GPU run).
The fix looks right to me: a location with no
ColorTargetmaps toVK_ATTACHMENT_UNUSED(or no attachment at all) inPipeline.cpp, so skipping the type check there matches what Vulkan does with that output.One note on the second new test case.
targetless.colors.clear(); targetless.blends.resize(1);is a state thePipelineconstructor rejects:With no colors,
blends.size()has to be 0, so a draw never reachesValidateShaderswith that state's pipeline. The unused-slot shape a real draw can have is a target atexportIndex1 with slot 0 empty (colors = {exportIndex 1},blends.size() == 2), with the shader still exporting at location 0. The change covers it too (thefind_ifmisses location 0), but neither case in the test builds it. Swapping the second case for that state would test the gap the description talks about.Method: read the diff against
main5d9dcc42dand modelled bothRequires in a small Python script; nothing was built.Written with AI assistance (Claude Code). No builds or tests were run for this note; only the standalone snippet above.
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-16T06:37:00Z.
Thanks @jotitadev, good catch: the pipeline would refuse my unused-slot state before validation. f663675f7a replaces it with your shape, a target at slot 1 with slot 0 unused and the shader exporting at location 0. It fails on
main'sShaderValidation.cppwith the title's line, and passes 3 of 3 with the change.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-16T06:49:10Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppImported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-18T16:33:09Z.
AMD on Windows: the tests this PR names pass on an RDNA 3.5 GPU.
Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), Windows 11 26300, WinLibs GCC 15.2.0 r7, Release.
main6efb7261bwith this PR (3d5335ab3) merged, together with #7296, #7446, #7377, #7445, #6748, #6785, #6706, #6613, #7449, #7391, #7489, #7484, #7514. They were built once, so the result is for the combination; each merge was clean.agc_driver_graphics,agc_driver_store_over_untracked: pass, 3 runs of 3.agc_*test on the combined build: 713 of 716 pass. The 3 that fail,agc_driver_host_import_lifetime,agc_driver_quad_pixel_maskandagc_driver_layered_volume_vertex_no_gpl, fail the same way on unchangedmainhere, so none comes from these PRs.AI-assisted
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-18T18:45:53Z.
Thanks @LeandroLP23 for the AMD run on Windows. I added it to the description.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-20T09:07:54Z.
Re-checked against current main: the merge is clean,
ShaderValidation.cppis untouched by main since the last review, and the two new test cases (no targets, and a gap below a target) are still in place after main'sGraphics.cppchanges. The one-line change skips the export type check where noColorTargetexists, which matches the pipeline (no attachment /VK_ATTACHMENT_UNUSED), and the location stays in the returned set. The new cases fail on main with thefloat4 colorsmessage and a float target still fails. Merged.