Skip to content

fix(agc): support packed 16-bit storage images - #6218

Open
harry-z-kang wants to merge 3 commits into
boykopovar:mainfrom
harry-z-kang:codex/issue-6119-packed-storage
Open

harry-z-kang wants to merge 3 commits into
boykopovar:mainfrom
harry-z-kang:codex/issue-6119-packed-storage

Conversation

@harry-z-kang

@harry-z-kang harry-z-kang commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

What

Fixes #6119: guest format 133 (5_6_5_UNORM) fails when NVIDIA does not expose the packed format as a storage image. Formats 134 (5_5_5_1_UNORM) and 136 (4_4_4_4_UNORM) have the same capability gap.

Keep the packed image and native sampled/attachment formats, but write through a compatible R16_UINT storage view. Materialize storage descriptors with the original conversion format and pack stores into the original 16-bit guest layout, including half-precision inputs. Restrict each view's usage to the operations its format supports.

Packing reuses EmitFormatStoreComponent in SpirvBackend/src/SpirvMemory/SpirvFormatConvert.cpp and the existing packed texture channel mappings. Vulkan's format compatibility classes, extended image usage and normalized fixed-point conversion define the view compatibility and clamping/scaling. AMD/PS5 comparison of rounding ties and NaN handling remains unverified and is recorded with the existing packed-texture entry in docs/dev/debt/libSceAgcDriver.md.

The branch retains merged native format-43 repacking (#7271), converted 32-bit sampling (#5958), R8/RG8 sRGB copy handling (#6054), D16 SINT stores (#5899) and float-mode handling (#5943). No open PR is required.

Tested

Local validation on the branch rebased onto main 60fb8078c: Windows 11 (NT build 26300), NVIDIA GeForce RTX 5080, driver 617.42, WinLibs GCC 15.2.0, Release, BUILD_TESTING=ON, ANYPS5_ENABLE_SPIRV_TOOLS=OFF. Vulkan tests required the physical GPU with ANYPS5_GPU=5080 and ANYPS5_REQUIRE_VULKAN=1.

  • cmake --build build --parallel 12: passed, including all test executables.
  • cmake --build build --target libs --parallel 12: passed.
  • ctest --test-dir build -R 'agc_.*(texture|image|storage|shader|runtime)' --output-on-failure --parallel 2: 119/120 passed in 22.79 s, zero skipped. All three packed-storage cases passed.
  • agc_driver_image_table_reuse fails with 2 reused and 1 resolved tables where it expects 1 and 2. Building the two investigated tests from sources verified identical to main 60fb8078c reproduces this exact image-table failure. No unrelated test changes are included.
  • agc_driver_storage_file_write failed in the initial parallel run, then passed in isolation on both the PR and main, and in the final parallel suite.
  • Conventions, whitespace and test-registration checks passed.

Three new packed-format cases cover channel order, 2,048-texel bit-exact sampled-load/store round trips, full/partial masks, swizzles, 32-bit/half-precision stores, clamping and NaN/infinity inputs, sampling after repeated stores and packed guest-memory write-back.

Title and Linux validation reported by @snoozedDev, on the original main d92a8dad3 plus PR heads 8322164f1 and 628767b52: Linux kernel 7.2.5, GCC 16.2.1, RTX 3090, NVIDIA 610.57.04, Release with ANYPS5_ENABLE_SPIRV_TOOLS=ON.

The packed-storage additions are unchanged. No new title run on the rebased head, AMD/PS5 packed-store comparison or lavapipe run is claimed.

Checklist

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

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.

Pull request Shared files not compared
PR 907 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 1341 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 1368 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 1395 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 2434 core/libs/prx/libSceAgcDriver/CMakeLists.txt
docs/dev/debt/libSceAgcDriver.md
PR 4448 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/debt/libSceAgcDriver.md
PR 4449 docs/dev/debt/libSceAgcDriver.md
PR 4891 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5021 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 5058 docs/dev/debt/libSceAgcDriver.md
PR 5371 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 5372 docs/dev/debt/libSceAgcDriver.md
PR 5426 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5480 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 5499 core/libs/prx/libSceAgcDriver/CMakeLists.txt
docs/dev/debt/libSceAgcDriver.md
PR 5609 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 5656 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5925 core/libs/prx/libSceAgcDriver/CMakeLists.txt
docs/dev/debt/libSceAgcDriver.md
PR 6044 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6146 core/libs/prx/libSceAgcDriver/CMakeLists.txt
docs/dev/debt/libSceAgcDriver.md
PR 6185 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6186 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6188 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6192 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6194 docs/dev/debt/libSceAgcDriver.md
PR 6197 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6202 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6223 docs/dev/debt/libSceAgcDriver.md
PR 6249 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6292 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6300 core/libs/prx/libSceAgcDriver/CMakeLists.txt
docs/dev/debt/libSceAgcDriver.md
PR 6451 core/libs/prx/libSceAgcDriver/CMakeLists.txt
docs/dev/debt/libSceAgcDriver.md
PR 6457 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6479 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6501 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6539 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6548 docs/dev/debt/libSceAgcDriver.md
PR 6549 docs/dev/debt/libSceAgcDriver.md
PR 6563 docs/dev/debt/libSceAgcDriver.md
PR 6588 core/libs/prx/libSceAgcDriver/CMakeLists.txt
docs/dev/debt/libSceAgcDriver.md
PR 6611 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6612 docs/dev/debt/libSceAgcDriver.md
PR 6615 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6636 docs/dev/debt/libSceAgcDriver.md
PR 6639 docs/dev/debt/libSceAgcDriver.md
PR 6674 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 6683 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6701 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6718 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6727 docs/dev/debt/libSceAgcDriver.md
PR 6730 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6747 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6759 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6762 docs/dev/debt/libSceAgcDriver.md
PR 6763 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6786 docs/dev/debt/libSceAgcDriver.md
PR 6788 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6808 core/libs/prx/libSceAgcDriver/CMakeLists.txt
docs/dev/debt/libSceAgcDriver.md
PR 6820 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6867 docs/dev/debt/libSceAgcDriver.md
PR 6868 core/libs/prx/libSceAgcDriver/CMakeLists.txt
docs/dev/debt/libSceAgcDriver.md
PR 6887 core/libs/prx/libSceAgcDriver/CMakeLists.txt
docs/dev/debt/libSceAgcDriver.md
PR 6905 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6937 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6941 core/libs/prx/libSceAgcDriver/CMakeLists.txt
docs/dev/debt/libSceAgcDriver.md
PR 6946 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6947 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6958 docs/dev/debt/libSceAgcDriver.md
PR 6960 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6963 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6965 core/libs/prx/libSceAgcDriver/CMakeLists.txt
docs/dev/debt/libSceAgcDriver.md
PR 6966 docs/dev/debt/libSceAgcDriver.md
PR 6971 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6973 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6977 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/RdnaDecoder/include/RdnaDecoder/RdnaDescriptorFormat.hpp
core/shader/recompiler/RdnaDecoder/src/RdnaDescriptorFormat.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6987 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6989 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6995 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7002 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7008 docs/dev/debt/libSceAgcDriver.md
PR 7048 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7085 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7154 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7201 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7223 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 7254 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7256 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7258 docs/dev/debt/libSceAgcDriver.md
PR 7332 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7381 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 7390 docs/dev/debt/libSceAgcDriver.md
PR 7395 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 7432 docs/dev/debt/libSceAgcDriver.md
PR 7449 docs/dev/debt/libSceAgcDriver.md
PR 7505 core/libs/prx/libSceAgcDriver/CMakeLists.txt
docs/dev/debt/libSceAgcDriver.md
PR 7514 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7550 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 7604 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7615 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7642 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7650 docs/dev/debt/libSceAgcDriver.md
PR 7677 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7689 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp

@github-actions github-actions Bot added build shader core/shader docs agc libSceAgc* labels Oct 15, 2026
@harry-z-kang

Copy link
Copy Markdown
Contributor Author

Reviewed both PRs in the overlap report. Neither is a prerequisite, so Depends on: none remains accurate.

Using the overlap checker's normalized merge procedure, the updated branch merges cleanly with #5899 at 8c1193744ac5 and #5958 at 8338defe54dd, in either order, and with both combined. No fixed merge order is required for those heads. These are merge checks; combined runtime builds were not run.

The updated standalone branch passed the full build, libs, all 98 related tests on the RTX 5080, and conventions/whitespace checks. Cyberpunk remains untested. The PR description now records the dependency review; the scheduled overlap report can refresh against the new head.

This was referenced Oct 15, 2026

@jotitadev jotitadev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on Apple as another vendor. This is the case where the new path actually runs: MoltenVK reports no STORAGE_IMAGE for any packed-16 format (R5G6B5, A1R5G5B5, R4G4B4A4…) in optimal tiling, so the R16_UINT reinterpret view is what gets exercised, and it works.

  • With the fix: agc_driver_image_packed16_storage_133, _134, _136 and agc_driver_image_converted_unorm all pass.
  • Test only, on the base without the Texture / descriptor-format / SPIR-V image changes: the three packed-16 cases fail with
    AGC graphics: guest storage texture format <N> cannot be used as a storage image (format 4, 8 and 3 respectively),
    so the tests do guard the new path.
  • Full ^agc suite: 13 failures, same set as the base (all pre-existing on MoltenVK). No new failures from this PR.

So the Metal reinterpret from the packed-16 formats to r16Uint (MUTABLE / EXTENDED_USAGE) holds up on Apple silicon.

Method: macos-port @ b7eb6b6 + ImportWatched + PR diff, not main. Machine: Apple M2 Max, macOS 27.2, x86-64 build under Rosetta, driver SDK MoltenVK 1.4.2.
GPUs tested: Apple M2 Max (MoltenVK 1.4.2).

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

@harry-z-kang
harry-z-kang force-pushed the codex/issue-6119-packed-storage branch from 628767b to 1ba7a4b Compare October 15, 2026 16:35
@harry-z-kang

Copy link
Copy Markdown
Contributor Author

Addressed the updated overlap report and incorporated the issue reporter's title/Linux validation into the description, with attribution and the tested commit IDs. The format failure is confirmed fixed on those heads; later clip-control and watchdog stops remain separate.

Rebased onto main 0029e62f9. The packed-storage code is unchanged. Its limitations are now consolidated into the existing packed-texture entry in docs/dev/debt/libSceAgcDriver.md, so this PR no longer changes docs/dev/debt/shader.md. The merge check against #5943 is clean; its float-to-half instruction changes are not a prerequisite for our half-to-float store conversion.

I manually reviewed the shared-file diffs of all 51 PRs in the bot's uncompleted-comparison table, including the repeated AOT patches, depth/sample paths, storage lifetime/cache work, sampler changes and CMake test registration changes. None supplies a prerequisite or duplicates the packed-storage conversion. Depends on: none remains accurate. Several of those branches already conflict with main; this review does not claim they all merge or run together.

Current local validation: relinker, libs and all 70 related test executables built, and 100/100 selected tests passed on RTX 5080 / NVIDIA 617.42 / Windows 11. Conventions, whitespace and registration checks passed. The full test build encountered an unchanged upstream MinGW alignment error in GpuIndirectArgumentsMisalignedWriterAhead.cpp:25; it is documented in the PR and is outside this change.

@harry-z-kang
harry-z-kang force-pushed the codex/issue-6119-packed-storage branch from 1ba7a4b to 1057f47 Compare October 16, 2026 00:16
@harry-z-kang
harry-z-kang force-pushed the codex/issue-6119-packed-storage branch 2 times, most recently from a05cb98 to 50642a5 Compare October 16, 2026 20:13
@oneandonlydean oneandonlydean self-assigned this Oct 17, 2026
@github-actions github-actions Bot added fix error Closes an issue (Fixes #N) needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Oct 17, 2026
@Dextroid17

Copy link
Copy Markdown
Contributor

Repeated @jotitadev's MoltenVK check on Linux, on the current head and plain main: 5d3a43196 merged onto main a62c724c3, lavapipe (llvmpipe, Mesa 26.2.4, LLVM 23.1.1), GCC 16.2.1, Release, ANYPS5_ENABLE_SPIRV_TOOLS=ON. lavapipe reports no optimal-tiling STORAGE_IMAGE for R5G6B5, A1R5G5B5 or B4G4R4A4_UNORM_PACK16 (it does for R16_UINT), so main refuses these three formats here, as on the RTX 3090 in #6119. By reading Texture.cpp, the PR sends them through the R16_UINT view on every device, not only on drivers without the bit.

  • agc_driver_image_packed16_storage_{133,134,136}, agc_driver_image_packed16_load and agc_driver_image_converted_unorm: 15/15 passed (3 repeats).
  • With the six non-test source files checked out from main (the PR's tests and CMakeLists.txt kept), the three packed-storage tests fail with the Cyberpunk 2077 (PPSA04029) on NVIDIA: guest storage texture format 4 (R5G6B5) cannot be used as a storage image #6119 error, guest storage texture format 4 cannot be used as a storage image for 133, and format 8 and 3 for 134 and 136. With the PR sources restored, all 5 pass again.
  • Full ctest: 1 failure out of 1,451 (65 skipped), agc_compute_pipeline_replay (replay did not export a pipeline cache header). It fails the same way with those six files from main, and the PR does not touch it.

AI-assisted: yes

@github-actions github-actions Bot added unblocks title Names a title ID on the Unblocks line needs rebase Conflicts with main, rebase needed labels Oct 18, 2026
@harry-z-kang
harry-z-kang force-pushed the codex/issue-6119-packed-storage branch from 5d3a431 to ca0ad2c Compare October 19, 2026 00:25
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 19, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* build docs fix error Closes an issue (Fixes #N) shader core/shader unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cyberpunk 2077 (PPSA04029) on NVIDIA: guest storage texture format 4 (R5G6B5) cannot be used as a storage image

4 participants