fix(shader_recompiler): pack format 11_11_10 float image stores in shader #8898
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8898"
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 camezaro-intc on 2026-10-21T05:04:14Z.
What
Packs storage image stores into guest format 36 (
Format11_11_10Float) in-shader viaFormat32UIntviews rather than relying on Vulkan'sVK_FORMAT_B10G11R11_UFLOAT_PACK32write path. Real RDNA 2 hardware rounds toward zero and saturates finite values exceeding maximum representable range to 65024.0 (11-bit) and 64512.0 (10-bit), whereas host Vulkan drivers round to nearest-even and overflow to infinity.Routes DCC fast clears for formats 36 and 43 through
VK_FORMAT_B10G11R11_UFLOAT_PACK32viaDccClearTextureFormatso fast clears produce valid 3-channel packed float layouts rather than single-channelR32_UINT.Tested
ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation:ctest --test-dir build -R "agc_driver_image_converted_unorm|agc_driver_image_repacked_float|texture_format_lookup|agc_driver$" -Vpassed 100% with zero validation 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 thuanquang on 2026-10-21T11:58:07Z.
Runs of this head (
5236bb622) on AMD hardware and on lavapipe.The edge rows on hardware. The seven
Float36StoreEdgesrows match an RX 6700 XT (gfx1031, AMD's Windows driver 32.0.21045.5002). Each row was stored withimage_storethrough a format 36 T# and read back through a32_UINTT#, as raw ISA through the HIP runtime. All seven dwords equal the test's expected values, with f32 denormals kept and with them flushed.RX 6700 XT (Windows 11 26200, MinGW Release,
ANYPS5_NO_SHADER_CACHE=1,ANYPS5_REQUIRE_VULKAN=1), the four tests from the body:maina07e985c8with only this PR's test changes: 3 of 4 pass.agc_driver_graphicsfails withformat 36 must be sampled as B10G11R11_UFLOAT and stored as R32_UINT. The new store case passes onmainhere, so AMD's ownB10G11R11_UFLOAT_PACK32storage write already converts as the hardware does.mainmerged with this head: 4 of 4 pass, 3 rounds.-V: 4 of 4 pass, 0VUID-lines.VK_LOADER_DEBUG=layershows the layer inserted inagc_driver_image_converted_unormandagc_driver_image_repacked_float.lavapipe (WSL Ubuntu 24.04, Mesa 25.2.8 with LLVM 20.1.2 as in the Linux CI, GCC 13.3 Release with SPIRV-Tools on),
agc_driver_image_converted_unorm. The tree ismaind0852defawith #8055, #8884 and #8886 applied; none of them touches image stores.image_store of R11_G11_B10_FLOAT: texel 6 is 0xfc3f07e0, expected 0xfa3e0fc1. Texels 0 to 5 already match: lavapipe also rounds these fields toward zero, saturates and stores 0 for negatives. Only the NaN row differs. lavapipe writes the canonical quiet NaN in each field (0x7e0,0x7e0,0x3f0). The hardware keeps the top bits of the payload and sets the lowest mantissa bit when none of them is set (0x7c1,0x7c1,0x3e8).Two notes:
0x7bf, which the test uses). 65504 is the f16 maximum.16_FLOAT,16_16_FLOATand16_16_16_16_FLOAT, which #8998 handles. WithFixes #8282, merging this PR would close the issue while #8998 is still open.Part of #8282would keep it open until both are in.Imported from boykopovar/AnyPS5. Originally posted by ryanc2112 on 2026-10-21T12:23:33Z.
Tested on Linux / RADV (SteamOS 3.8.28, AMD Radeon RX 570 / Polaris10, Mesa 26.2.5, GCC 16.2.1, Release), this PR (5236bb622) merged onto
main3e91c8edfvsmain, withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(loader confirms the layer is inserted).agc_driver_image_store_*: 10/10 pass on both, zeroVUID-on both.ImageConvertedUnorm.cppon unpatchedmainfails withimage_store of R11_G11_B10_FLOAT: texel 0 is 0xffc00000, expected 0xfc000000(RADV writes the canonical all-ones NaN mantissa), and passes with the PR.agc_*+texture_format_lookup(855 tests): identical pass/fail set on both, identical validation output (6×VUID-VkWriteDescriptorSet-descriptorType-00337, 2×VUID-vkResetFences-pFences-01123on both). No regressions observed.One issue from reading the diff:
remapGuestFormatnow resolves format 36 toR32_UINTeverywhere, and the DCC clear paths derive the clear layout fromResolveTextureFormat(DccMetadata.cpp:529,777,786,ShaderResources.cpp:740). Onmainformat 36 uses theB10G11R11_UFLOAT_PACK32layout (3 float channels,DccMetadata.cpp:409); with this PR it gets theR32_UINTlayout (1 uint channel,:401), whichFillDccCleartreats as alpha. SoClear1111fills0x00000001instead of 1.0 in each channel, andClear1110fills 0. No existing test covers a format-36 DCC clear, which is why the full run is unchanged. Could the DCC clear layout use the native format for 36 (and 43, which looks to have the same gap)?AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by camezaro-intc on 2026-10-21T16:17:47Z.
Thanks @thuanquang and @ryanc2112 for the thorough review, measurements, and tests across real hardware and lavapipe!
65504.0to65024.0(0x7bf), and changedFixes #8282toPart of #8282so the issue remains open for #8998.DccClearTextureFormat(guestFormat)returningVK_FORMAT_B10G11R11_UFLOAT_PACK32for formats 36 and 43 (IsRepackedTextureFormat), and updated the clear-format resolution calls inDccMetadata.cppandShaderResources.cpp.FillDccClearnow receives the native 3-channel layout (Clear1111andClear1110produce0x781e03c0u,Clear0000produces0u) instead of defaulting to single-channelR32_UINT. Added test coverage inpackedFloatDccClearTestsfor both formats 36 and 43 underClear1111,Clear1110, andClear0000withReadTextureSurface.All validation tests pass 100% with 0
VUID-validation errors on RX 5700 XT.Imported from boykopovar/AnyPS5. Originally posted by MaxLikesCode on 2026-10-21T16:35:22Z.
RTX 4090 (Ada) on Windows, head
9e8f18888merged ontomaincecb540a6(clean). The four tests from the Tested section (agc_driver_image_converted_unorm,agc_driver_image_repacked_float,texture_format_lookup,agc_driver), plus the 8 tests matchingdccfor the packed-float DCC clear change:main: 12 of 12 in 3 runs without and 3 with the validation layer.agc_driver_image_converted_unorm.VUID-.NVIDIA GeForce RTX 4090, driver 617.42, Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release,
BUILD_TESTING=ON,ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,ctest --test-dir build -R <tests> -V. Validation runs addVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(Vulkan-ValidationLayersvulkan-sdk-1.4.363.0, implicit layers disabled); the loader log shows the layer inserted in every Vulkan test process, and no log haswas not found but was requested by env var VK_INSTANCE_LAYERS.AI-assisted: yes (Claude Code)