feat(agc): read color-target merges through typed storage images #17056
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/17056"
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 sherySJ on 2026-11-08T08:50:26Z.
What
Pixel-shader color-target merges read the merge image through a storage image declared with the target's format instead of a formatless one, so they run on GPUs without
shaderStorageImageReadWithoutFormat(Intel Gen9 to Gen12.0 on Linux ANV and on the Windows Intel driver: HD 520/530/620/630, Ice Lake, Tiger Lake, Alder/Raptor Lake UHD 7xx). Until nowEmitStorageImageReadrefused every merge draw there (storage image reads without a format are unavailable on the target device); the same failure is reported in #11943, #12968, #12522, #16968 and #16984, which were answered with test skips.StorageImageFormat(newcore/shader/recompiler/StorageImageFormat.hpp) onImageResource, set inAddTargetMerge: 4_4_4_4 ->R16ui, 11_11_10 and 10_11_11 ->R32ui, unclamped UNORM/SNORM blends -> the target's format (R8, RG8, RGBA8, R16, RG16, RGBA16, UNORM and SNORM). BGRA8 and any other format stayUnknownand keep today's refusal.ImageTypeemits the concrete SPIR-V format;EmitStorageImageReadand the formatless write capability are demanded only forUnknown. Formats other thanR32uiand RGBA8 needStorageImageExtendedFormats: advertised fromVulkanDevice.cppwhenshaderStorageImageExtendedFormatsis enabled, accepted byShaderDeviceProfile.cppandShaderValidation.cpp, and gated onsupportedCapabilities(absent:Unknown, today's refusal).ExportTargetMerges(TargetMerge::storageFormat) and is part ofCacheKey.hpp, theRecompiler.cppkey,DrawLookup.cppandRequestSerializer.cpp(version 56 -> 57, older streams read asUnknown). Disk cache: encoder and decoder lines,fieldCount<ImageResource>() == 51,FormatVersion60 -> 61.VUID-VkShaderModuleCreateInfo-pCode-08737): the merge images of a draw shared one heap array variable declared with the first entry's type.DefineDescriptorsnow declares one variable per distinct SPIR-V format in a heap; with more than one they areAliasedon the same binding (ShaderValidation.cppaccepts aliased storage-image variables the way it accepts aliased buffer views). If the device has formatless read and write, a heap that would need more than one format is declared without a format as before, so devices that worked before see the same modules and the same validation output.shaderStorageImageReadWithoutFormatskips inPackedUnorm4444PartialWrite.cppandUnclampedNormalizedBlend.cppare removed;Graphics.cppkeeps the refusal for a 4_4_4_4 merge withoutStorageImageExtendedFormatsand adds the typed case (no formatless capability, oner16uiimage);ShaderDiskCache.cppround-tripsstorageFormat;ShaderMemory.cppandRequestSerializerTests.cppcover the key, the serializer field, version 56 streams and an invalid format byte;ShaderDeviceProfile.cppcovers the new capability check.PackedFloatBlend.cppis untouched (the skip in #16984 is not onmain; this change makes that test pass on the HD 520 without a skip).docs/dev/debt/changes/agc-typed-merge-read.md, changes thelibSceAgcDriverentries for 11_11_10 blending and unclamped normalized targets now describe what is left (BGRA8 and formats without a SPIR-V storage format, devices with neither feature, the aliased-variable validation warning). MSAA (shaderStorageImageMultisample) is not touched.Known limit: a draw that merges targets of different formats on a device without formatless access (the three two-target draws of
agc_driver_unclamped_normalized_blendon the HD 520) now runs, but the Khronos layer reports 2Undefined-Value-StorageImage-FormatMismatch-ImageViewwarnings (not VUIDs) because it checks every element of the aliased array against each variable; every access uses the variable of its own format and the pixels match. A separate binding per format would avoid it and changes the runtime ABI (56 fixed heap bindings, placeholders, descriptor writes), which is a separate change.Tested
Host: Intel HD Graphics 520 (Skylake GT2, Mesa 26.2.5 ANV,
shaderStorageImageReadWithoutFormatfalse) and llvmpipe (LLVM 23.1.3), Linux. Windows and macOS not tested. No title run. Control =mainbuilt atb6b443106e(binaries kept apart), change = this branch rebased on4ab649f4d8with no conflicts (the rebase touchedRecompiler.hpp,ShaderDiskCache.cppand tests outside this diff's hunks).Validation layer: Khronos 1.4.363 extracted without root from the Arch
extrapackage, SHA-256 904f4eba2e708c9c96579900688a284309cd56dc09b5af3f78c563ffda13df9e checked against/var/lib/pacman/sync/extra.db;VK_LOADER_DEBUG=layershowsInserted device layer "VK_LAYER_KHRONOS_validation"and nowas not found but was requestedline in any log.agc_driver_packed_float_blendagc_driver_packed_unorm4444_partial_writeagc_driver_unclamped_normalized_blendagc_driver_graphicsagc_shader_disk_cacherequest_serializeragc_shader_memoryVUID-lines in the logs: 0 on main and 0 on the change, on both GPUs. Other validation messages: llvmpipe main and change both log 30Undefined-Value-ShaderOutputNotConsumed-DynamicRendering; HD 520 change logs the same 30 and the 2FormatMismatchwarnings above (main's HD 520 run refuses or skips these tests, so it logs none).Sweep on the HD 520 (
ANYPS5_GPU=Intel ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ctest --test-dir build -R '^agc_driver_' -j1 --timeout 90, no validation layer): mainb6b443106e1038 tests, 11 failed, 33 skipped; change (branch on4b37092bef, before the last rebase) 1039 tests, 9 failed, 31 skipped. Fixed:agc_driver_packed_float_blend(failed),agc_driver_packed_unorm4444_partial_writeandagc_driver_unclamped_normalized_blend(skipped). New failures: none. The 9 remaining failures are the same on main:f32_denormal_flush,f64_rounding_denormal_modes,image_sample_lod_clamp,sample_multisample_target,native_color_initial_nonuniform(+_lifetime,_capabilities,_hook), andguest_memory_lifetime_converted(itslibGuestMemoryFixture.prxtarget is not built in this tree).agc_driver_unsupported_diagnosticsfailed in the first control sweep only because of how the control binaries were relocated and passes on main when rerun.After
maintook request serialization version 56 (c7078a8762, wave-shared VGPR words),main1086833f9awas merged into this branch (404a564341, no rebase, sob9596591dastays in the history): this change'sstorageFormatbyte moved to version 57, the reader keepsmain's version-56 gate for the compute VGPR words,RequestSerializerTests.cppkeepsmain's version 55 and 56 replays and adds the same replays for graphics streams (ba45036777). The seven tests above were rerun at ba45036777's parent with the validation layer: 7/7 pass on the HD 520 and on llvmpipe, 0VUID-lines;request_serializerpasses atba45036777.After
maintook disk cache format 60 (74407aac46),main9fabd4aa7ewas merged in again (2b83ae06fc, no rebase):FormatVersionis now 61 and the request serializer stays at 57 (mainis still at 56). The seven tests above were rerun at2b83ae06fcwith the validation layer: 7/7 pass on the HD 520 and on llvmpipe, 0VUID-lines, and the same 30ShaderOutputNotConsumedwarnings on both plus the 2FormatMismatchwarnings on the HD 520.After
maintook disk cache format 68 (mergedmainat32b292ba38, merge commite91dcedb0b), the shader disk cacheFormatVersionis 69, one abovemain's 68.main's request serializer is still at 56, so this PR's serializer stays at 57, and theImageResourcefield count assert stays at 51. The merge was a plain merge, not a rebase, withShaderDiskCache.hppthe only conflict. I reran the seven tests (agc_driver_packed_float_blend,agc_driver_packed_unorm4444_partial_write,agc_driver_unclamped_normalized_blend,agc_driver_graphics,agc_shader_disk_cache,request_serializer,agc_shader_memory) with the Khronos validation layer,ANYPS5_REQUIRE_VULKAN=1andANYPS5_NO_SHADER_CACHE=1on the Intel HD 520 and on llvmpipe: all seven pass on both, with noVUID-errors, 30ShaderOutputNotConsumedon both and 2FormatMismatchon the HD 520 only.Latest sync:
main43fccc9323, then41fbfacd01, merged in (a4c787c7ad, no rebase).mainis at request version 63 and disk cache format 95, so this PR uses request version 64 andFormatVersion96.main's version 62 barycentric fixture now strips the merge storage byte this PR writes (69c5cdb01a, test only). The debt changes moved to the fragment above. A second sync withmain41fbfacd01(24a4b065c1) kept the same version numbers, sincemaindid not bump them, and movedmain's newVerifySingleSampleVersion63test to version 64 (1a8d2dfaa4). The eight tests (the seven above pluspublic_headers) pass on the HD 520 and llvmpipe with the validation layer and noVUID-lines.Other devices: On Raptor Lake under Windows (no
shaderStorageImageReadWithoutFormat, with extended formats and pixel interlock), @androidbaklava ran head1a8d2dfaa4merged ontomain56d4f9fe7eon a UHD Graphics8086:a7a8with driver 101.7084. The three blend tests, whichmainskips, passed every run, 210 PR runs in all with and without the validation layer and with all seven tests run in parallel, and logged 0VUID-lines (comment). On an8086:A78Bwith the older driver 31.0.101.5081, @mihiii1337 sawpacked_float_blendandpacked_unorm4444_partial_writefail intermittently. Thepacked_float_color_targetcontrol fails onmainthere too, so the failures track that driver (comment). A follow-up on the same build alternated the ordinary path withAPS5_NO_GPL=1:packed_float_blendand the plainpacked_float_color_targetcontrol each failed 3 of 3 with the graphics pipeline library and passed 3 of 3 without it, with noVUID-lines, which ties both to the separate pipeline library problem on that driver (#25697) (comment). After updating that GPU to driver 32.0.101.6127, the same binaries passed all four packed tests 3 of 3 with the pipeline library enabled, with and withoutAPS5_NO_BARRIER_BATCH=1, with noVUID-lines (comment). @GiannisG1 ran headb9596591damerged ontomain105c9e4d91(Linux Mint 22.3, GCC 13.3.0, Release, Xvfb; "masked" = Khronos profiles layer 1.3.275 reportingshaderStorageImageReadWithoutFormatfalse): Intel HD Graphics 630 (Mesa 25.2.8 ANV, false natively) goes frompacked_float_blendfailed and the other two skipped to 7/7 passing; GTX 1050 Ti (580.178.04) and llvmpipe pass 7/7 on both sides, and with the read masked both go from the same failure and skips to 7/7. Full suite: 4538 tests on the GTX and the 1149 GPU tests on the HD 630 and llvmpipe, with the three tests above on the HD 630 as the only changed results. Validation layer 1.3.275 logs the same 3VUID-VkDeviceCreateInfo-pNext-pNextonmainand this PR (GTX, llvmpipe) and prints no warnings, so it does not show the twoFormatMismatchwarnings (comment).python3 tools/check_conventions.py --base origin/main: 0 errors, 2debt-lengthwarnings (the two debt entries were already over 1000 characters).Overlap
tools/pr_overlap.pylists 104 open pull requests that share files, none implementing typed storage-image reads for merges. The relevant shared lines are the serializer and disk cache version numbers (RequestSerializer.cpp56 -> 57,FormatVersion69): #10359, #11483 and #15343 also edit the serializer and #14944 and #16260 the disk cache, so whichever lands second renumbers. #16984 (skip foragc_driver_packed_float_blend) becomes unnecessary on devices withshaderStorageImageExtendedFormats; if it merges first this change drops its skips.After
maintook request serialization version 57 (tail fields maxImageArrayLayers and fixedPushSlots) and disk cache format 69,main37646cd2cawas merged into this branch (merge commit9d7f18fbce, no rebase). This change'sstorageFormatbyte moves to serialization version 58, the reader gates it at version 58 andRequestSerializerTests.cppandShaderMemory.cpptakemain's version 56 and 57 replays, with their version 56 helper now removing the storage byte so its streams stay valid version 56. The shader disk cacheFormatVersionis 70, one abovemain's 69, and theImageResourcefield count assert is 52 (main's new field plus this one). I reran the seven tests (agc_driver_packed_float_blend,agc_driver_packed_unorm4444_partial_write,agc_driver_unclamped_normalized_blend,agc_driver_graphics,agc_shader_disk_cache,request_serializer,agc_shader_memory) with the Khronos validation layer,ANYPS5_REQUIRE_VULKAN=1andANYPS5_NO_SHADER_CACHE=1on the Intel HD 520 and on llvmpipe: noVUID-errors on either, all seven pass on llvmpipe, and on the HD 520 six pass andagc_driver_packed_float_blendskips becausemainnow skips it withoutshaderStorageImageReadWithoutFormat(the skip merged unchanged).public_headersandtools/check_conventions.py --base origin/mainpass.The packed float blend test no longer skips without
shaderStorageImageReadWithoutFormat. Main commit3c6c68bf5bmadeagc_driver_packed_float_blendreturn a skip on devices lacking that feature, because its merge shader read the color target without a format. With typed storage image reads for color-target merges the feature is not needed, so the skip is removed ina877caf5c2(the overdraw benchmark keeps only its pixel interlock guard), as already done for the packed unorm4444 and unclamped normalized blend tests. On an Intel HD 520 the test passes in three runs and on llvmpipe once, with no VUID- errors under the Khronos validation layer, and the same test on main with the skip removed fails there with "storage image reads without a format are unavailable on the target device".Merged main at
1af270fa29(b52d39b252): request serialization is renumbered to version 63 after main's 62, accepted beside main's refusals of 58 to 61, with the storage format byte read from version 63; ShaderDiskCache::FormatVersion is 89 and the ImageResource field count is 52. The legacy fixtures in ShaderMemory.cpp and RequestSerializerTests.cpp start from version 63 (prefixNVNQQT8AAAA=) and trim 6 trailing bytes to reach version 56. The per-format storage image variables now follow main's 64-bit image atomic lock rule. The blend, graphics, disk cache, request serializer and shader memory tests pass on Intel HD 520 and llvmpipe with the validation layer inserted and no VUID- errors.Merged main
3c07e1d05e(merge commit207866fb41).ShaderDiskCache::FormatVersionis 91, one above main's 90; the recompile request serialization version stays 63 because main is still at 62. Rerun with the Khronos validation layer on an Intel HD 520 and on llvmpipe: the request serializer, public header, packed float blend, packed unorm4444 partial write, unclamped normalized blend, graphics, shader disk cache and shader memory tests pass on both with no VUID- errors.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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T12:16:16Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing in the inspected code blocks merging; the remaining uncertainty is limited to changed files whose complete text was excluded from the review bundle.
What I ran
Reviewed head
69c5cdb01af08c04bf048c26754356dcd439fbacusing the prepared diff andrepo_read.pysource reads. No commands or tests were run by me; test results below are author reported.Results
Findings
Blocking
None in the code inspected.
Non-blocking
None.
Not verified
Full text of
VulkanDevice.cpp,Graphics.cpp, andShaderMemory.cppwas excluded as too large for the review folder, so I did not verify those files. Other changed files were listed as included; targeted source reads covered the descriptor format selection and emit paths. I did not run tests or independently confirm the author-reported results.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T03:33:57Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the reported targeted tests pass, with two documented format-mismatch warnings for mixed-format MRT draws.
What I ran
Reviewed head
1a8d2dfaa4c4f17637a2ac4203b6cab6da9879e8usingrepo_read.py-backed review tools. I did not run tests or build commands; the results below are author-reported. Readdescription.md,commits.md,manifest.json,diff.patch, and the changed source and test files listed below.VulkanDevice.cpp,Graphics.cpp, andShaderMemory.cppwere read through the pinned reader because their full text was excluded from the review folder.Results
Findings
Blocking
None.
Non-blocking
Undefined-Value-StorageImage-FormatMismatch-ImageViewvalidation warnings on mixed-format MRT draws. They explain that each access uses its matching typed variable and report matching pixels. Track the warning or eliminate it in a follow-up if clean validation output is required.Not verified
I did not run builds, tests, convention checks, or validation-layer checks. Windows, macOS, and physical-console behavior were not tested in the reported runs.
files.jsonwas not available as a review document; the reader’s file listing showed all changed paths and identifiedVulkanDevice.cpp,Graphics.cpp, andShaderMemory.cppas excluded from the review folder due to size. I read the relevant changed ranges of those files through the pinned reader. The remaining full contents of those three files were not read. No other changed file was excluded from the review folder.To get this to a good state
Nothing is required. The validation warnings above are optional follow-up feedback.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T22:36:04Z.
Review: COMMENTED
I compiled the exact request serializer. It round-trips a typed color-target merge using version 64. Both main
c1601e56d5and this head reject the other’s version 64 capture, and the same is true with the mesh-compute layout in #17611. Please reconcile the serializer version and preserve historical main captures when rebasing the local conflicts in shader resources, disk cache, and request tests. The native checks covered format compatibility. I have no Intel GPU result.AI-assisted: yes.
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.