fix(libSceAgcDriver): store 32-bit exports into narrow UINT targets as Navi21 does #15693
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15693"
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 Tamalero on 2026-11-04T06:57:18Z.
What
A raw 32-bit export into an 8- or 16-bit UINT color target is passed to the attachment unchanged on
main. Vulkan leaves an integer write that does not fit the channel undefined, and the drivers I tried saturate it. Navi21 hardware does something different, and it depends on the export format:32_R0x12345678→0x78/0x5678,0x100→0x00)UintMask8/UintMask16:word & 0xff/0xffff32_GR,32_ABGR0x7f→0x7f,0x100→0xff,0x80000000→0xff)UintClamp8/UintClamp16, the clamp #14243 uses forFP16_ABGR32_ARSPI_SHADER_COL_FORMAT, the same method as #11513. The ISA shows the raw words exported with no compiler clamp. Sixteen words from0to0xffffffffwent intoR8,R16,RG8,RG16,RGBA8andRGBA16UINT targets, with identical results on both GPUs. This is desktop RDNA2, not the console.State.cpp.SelectExportPackingmasks for32_Rand clamps for32_GR,32_ABGRandFP16_ABGR; both read the target width from the packing specialization constant. The new packings travel intargetExportPackinglike the existing ones.32_AR, blending into integer targets, and the console itself.This follows #14243, which added the clamp for
FP16_ABGR.Tested
ctest -V -R '^(agc_driver_uint_color_target|agc_driver_graphics)$'withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1andANYPS5_REQUIRE_VULKAN=1, onmain5b1d381d5aand on this branch (0ce0944491). Both pass. Neither log reportswas not found but was requested by env var VK_INSTANCE_LAYERS. Both report onlyVUID-vkCreateDevice-ppEnabledExtensionNames-01387at device creation.agc_driver_uint_color_target_tests:0x1ffand0x12345678, go intoR8_UINTandR16_UINT(32_R),R8G8_UINT(32_GR), andR8G8B8A8_UINTandR16G16B16A16_UINT(32_ABGR).R32_UINTandR32G32B32A32_UINT, where the driver cannot saturate.agc_driver_graphics_tests:uintTargetTestsdecodes each export format into 8- and 16-bit targets to its packing (32_ARkeepsUint). The invalid-packing check now uses 9.0xffstored,0x00expected (32_R,R8_UINT)FP16_ABGR0x1ffstored,0xffexpected (32_ABGR,UintClamp8)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)Tested and written by Claude (AI assistant) on a contributor's machine.
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by Superseabas on 2026-11-04T17:49:38Z.
Review: APPROVED
Head
0ce0944491merged onto currentmainb11c7bf84f(clean merge, local only): code read, red/green check and a run on AMD's Windows driver, with an NVIDIA Blackwell run alongside.Windows 11 Home 10.0.26200, WinLibs GCC 16.2.0 (
x86_64-ucrt-posix-seh, r3), Release,BUILD_TESTING=ON.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ctest -R '^(agc_driver_graphics|agc_driver_.*uint.*|agc_driver_pixel_.*|agc_driver_.*float16.*|agc_driver_.*storage_image.*|agc_driver_.*export.*)$'(44 tests,agc_driver_uint_color_targetamong them),ANYPS5_GPUselecting the device (confirmed bySelected GPU):main10de:2c05)1002:164e)VUID-in either tree isVUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605(#11990), which is onmaintoo. No new ID appears, and there is no missing-layer line.State.cppandSpirvModuleEmitter.cppchanges reversed fails on both GPUs:agc_driver_uint_color_targetwitha 32_R export of 0x3f800000 … into a tiled R8_UINT target …: channel 0 of pixel (0, 0) written holds 0x000000ff, expected 0x00000000. So both Windows drivers saturate where the PR masks, as the description says of the drivers it tried.agc_driver_graphicswitha 32_ABGR export into an 8-bit UINT target did not get the clamping packing.Read through the change:
NarrowUintPackingpicks clamp for32_GR,FP16_ABGRand32_ABGR, and mask for32_R.32_ARstays unpacked, and any other export into a UINT target still throws.ColorExportPackingvalues are appended afterUintClamp16.RequestSerializerandFragmentOutputSpecializationraise their upper bound toUintMask16, so the existing values keep their numbers.SelectExportPacking, the mask path ANDs the bitcast word with the same0xff/0xfffflimit the clamp path uses.IsUintPackingincludes the new modes.One non-blocking note:
check_conventions.py --base mainpasses with onedebt-lengthwarning on theUINT color targetsentry, which this PR takes from 2,119 to 2,497 characters. It was already over the limit onmain.AI-assisted: yes (Claude Code)