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

Merged
harry-z-kang merged 3 commits from upstream-pr/6218 into main 2026-10-23 09:44:30 +00:00
harry-z-kang commented 2026-10-15 04:39:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by harry-z-kang on 2026-10-15T04:39:47Z.


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 main 001d132f4 (including merged #8087) and rebased PR head f30acac3c: 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.

  • Rebuilt the six focused GPU test targets and their driver/runtime/shader dependencies on main and the PR. This pass did not repeat the full default build or libs build; both passed in the previous validation on base 9b34cba9e.

  • Ran the same nine focused cases on main's implementation and the PR with the identical regression harness. Both runs used ANYPS5_GPU=5080, ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation.

  • Command: ctest --test-dir build -R '^agc_driver_(image_(converted_unorm|packed16_load|store_sint|sint8|repacked_float|packed16_storage_(133|134|136))|fmask_image_reads)$' -V --parallel 1.

  • Main passed the six existing cases and refused the three new packed-storage cases because their formats cannot be used as storage images. The PR passed 9/9 with zero skipped, including all three packed-storage cases; the final restored-PR run took 3.56 s.

  • Used Khronos validation 1.4.365 from the official Windows CI artifact, commit aea761f4d54b86682be4099c428dba27b6609940, supplied through a workspace-local VK_LAYER_PATH. Loader logs confirm insertion in every test. Neither log contains a missing-layer warning or any VUID- error: zero on main, zero on the PR.

  • The rebase applied cleanly. All three commit patches are unchanged. Conventions, whitespace and registration of all nine focused cases passed.

The wider suite was not repeated in this focused validation pass. Its previously reported image-table reuse failure was reproduced on the older main 60fb8078c.

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.

  • All 81 selected Linux tests passed on both heads, including the three packed-storage cases.

  • Cyberpunk 2077 PPSA04029 v02.120.000 had no storage-format exception in six PR runs; both baseline runs reproduced it. The 628767b52 run recorded 645 presents and 1,497 completed draws before the later clip-control refusal.

  • Later stops are the separate CLIP_DISABLE/PA_CL_CLIP_CNTL refusal and the intermittent watchdog tracked in #4634. This PR fixes the reported storage-format stop; it does not establish complete title compatibility.

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

  • Based on current main; no other open PR implements the same functions

  • One topic per PR; follow-ups go in a new PR

  • No comments in code except technical debt

  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file

  • No notes, investigation .md files or images added to the repository (attach them to this PR)

  • New third-party code is a submodule built from source

  • Generic behaviour, not specific to one title

  • Depends on: none

  • Fixes: Fixes #6119

  • Unblocks: PPSA04029 #3308 past the format-133 storage-image stop, confirmed by the issue reporter

  • GPUs tested: NVIDIA GeForce RTX 5080, driver 617.42, Windows 11 (local, main/PR Khronos validation comparison); NVIDIA GeForce RTX 3090, driver 610.57.04, Linux kernel 7.2.5 (reported by @snoozedDev on the earlier heads above)

  • AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4868278514 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6218). Originally posted by [harry-z-kang](https://github.com/harry-z-kang) on 2026-10-15T04:39:47Z. --- ### 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](https://docs.vulkan.org/spec/latest/chapters/formats.html#formats-compatibility-classes), [extended image usage](https://docs.vulkan.org/refpages/latest/refpages/source/VkImageCreateFlagBits.html) and [normalized fixed-point conversion](https://docs.vulkan.org/spec/latest/chapters/fundamentals.html#fundamentals-fixedconv) 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 <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Local validation on `main` `001d132f4` (including merged #8087) and rebased PR head `f30acac3c`: 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`. - Rebuilt the six focused GPU test targets and their driver/runtime/shader dependencies on main and the PR. This pass did not repeat the full default build or `libs` build; both passed in the previous validation on base `9b34cba9e`. - Ran the same nine focused cases on main's implementation and the PR with the identical regression harness. Both runs used `ANYPS5_GPU=5080`, `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1` and `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`. - Command: `ctest --test-dir build -R '^agc_driver_(image_(converted_unorm|packed16_load|store_sint|sint8|repacked_float|packed16_storage_(133|134|136))|fmask_image_reads)$' -V --parallel 1`. - Main passed the six existing cases and refused the three new packed-storage cases because their formats cannot be used as storage images. The PR passed 9/9 with zero skipped, including all three packed-storage cases; the final restored-PR run took 3.56 s. - Used Khronos validation 1.4.365 from the [official Windows CI artifact](https://github.com/KhronosGroup/Vulkan-ValidationLayers/actions/runs/39081605124), commit `aea761f4d54b86682be4099c428dba27b6609940`, supplied through a workspace-local `VK_LAYER_PATH`. Loader logs confirm insertion in every test. Neither log contains a missing-layer warning or any `VUID-` error: zero on main, zero on the PR. - The rebase applied cleanly. All three commit patches are unchanged. Conventions, whitespace and registration of all nine focused cases passed. The wider suite was not repeated in this focused validation pass. Its previously reported image-table reuse failure was reproduced on the older main `60fb8078c`. 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](https://github.com/boykopovar/AnyPS5/issues/6119#issuecomment-6196484935), 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`. - All 81 selected Linux tests passed on both heads, including the three packed-storage cases. - Cyberpunk 2077 PPSA04029 v02.120.000 had no storage-format exception in six PR runs; both baseline runs reproduced it. The `628767b52` run recorded 645 presents and 1,497 completed draws before the later clip-control refusal. - Later stops are the separate `CLIP_DISABLE`/`PA_CL_CLIP_CNTL` refusal and the intermittent watchdog tracked in #4634. This PR fixes the reported storage-format stop; it does not establish complete title compatibility. 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 <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: Fixes #6119 - [x] Unblocks: PPSA04029 #3308 past the format-133 storage-image stop, confirmed by the issue reporter - [x] GPUs tested: NVIDIA GeForce RTX 5080, driver 617.42, Windows 11 (local, main/PR Khronos validation comparison); NVIDIA GeForce RTX 3090, driver 610.57.04, Linux kernel 7.2.5 (reported by @snoozedDev on the earlier heads above) - [x] AI-assisted: yes
harry-z-kang commented 2026-10-15 05:46:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by harry-z-kang on 2026-10-15T05:46:36Z.


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

  • #5899 adds D16 stores to SINT images. This PR handles packed 16-bit UNORM images. Commit 628767b52f17a4dcdc39e559d912eddac6373fe2 keeps our half-to-float conversion in PackImageTexel, leaving StoreTexel unchanged from main and removing the conflict with #5899.
  • #5958 adds sampling of converted 32-bit UNORM/float images; this PR preserves native sampling for the packed 16-bit formats. The conflict was between adjacent technical-debt entries; the packed-format entry has been moved without changing either entry's meaning.

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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6185392699 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6218#issuecomment-6185392699). Originally posted by [harry-z-kang](https://github.com/harry-z-kang) on 2026-10-15T05:46:36Z. --- Reviewed both PRs in the overlap report. Neither is a prerequisite, so `Depends on: none` remains accurate. - #5899 adds D16 stores to SINT images. This PR handles packed 16-bit UNORM images. Commit `628767b52f17a4dcdc39e559d912eddac6373fe2` keeps our half-to-float conversion in `PackImageTexel`, leaving `StoreTexel` unchanged from main and removing the conflict with #5899. - #5958 adds sampling of converted 32-bit UNORM/float images; this PR preserves native sampling for the packed 16-bit formats. The conflict was between adjacent technical-debt entries; the packed-format entry has been moved without changing either entry's meaning. 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.
jotitadev commented 2026-10-15 16:30:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-15T16:30:14Z.

Review: COMMENTED


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 @ b7eb6b6b + 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.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5536520779 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6218#pullrequestreview-5536520779). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-15T16:30:14Z. **Review:** COMMENTED --- 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 @ b7eb6b6b + 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 commented 2026-10-15 16:35:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by harry-z-kang on 2026-10-15T16:35:34Z.


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6197158485 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6218#issuecomment-6197158485). Originally posted by [harry-z-kang](https://github.com/harry-z-kang) on 2026-10-15T16:35:34Z. --- Addressed the updated overlap report and incorporated [the issue reporter's title/Linux validation](https://github.com/boykopovar/AnyPS5/issues/6119#issuecomment-6196484935) 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.
Dextroid17 commented 2026-10-18 14:55:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-18T14:55:19Z.


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 #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

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6251349610 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6218#issuecomment-6251349610). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-18T14:55:19Z. --- 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 #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
DavidAmsellem commented 2026-10-19 18:23:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DavidAmsellem on 2026-10-19T18:23:49Z.


First AMD-on-Linux (RADV) run of this PR. Merged onto main 8d5d4df96 (clean merge), built in full and compared with the same main, on the same machine.

AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 (Ubuntu 24.04 base), kernel 7.0.0-38, GCC 13.3, Release.

Full suite (ANYPS5_REQUIRE_VULKAN=1 ctest -j8) at b74c8abf4: 1641/1643 with this PR, against 1638/1640 on main. The two failures are the same on both, so this PR adds none: agc_driver_image_table_vouched_lookups (#7766, fixed by #7916) and agc_driver_guest_memory_lifetime (#7784).

The PR's three new ctest entries (agc_driver_image_packed16_storage_133, _134 and _136) all run and pass here; none is skipped. No other ctest entry is added, skipped or removed compared with main.

This checks correctness only; I did not measure performance.

GPUs tested: AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 / kernel 7.0.0-38

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6274234041 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6218#issuecomment-6274234041). Originally posted by [DavidAmsellem](https://github.com/DavidAmsellem) on 2026-10-19T18:23:49Z. --- First AMD-on-Linux (RADV) run of this PR. Merged onto `main` `8d5d4df96` (clean merge), built in full and compared with the same `main`, on the same machine. AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 (Ubuntu 24.04 base), kernel 7.0.0-38, GCC 13.3, Release. Full suite (`ANYPS5_REQUIRE_VULKAN=1 ctest -j8`) at `b74c8abf4`: **1641/1643 with this PR**, against 1638/1640 on `main`. The two failures are the same on both, so this PR adds none: `agc_driver_image_table_vouched_lookups` (#7766, fixed by #7916) and `agc_driver_guest_memory_lifetime` (#7784). The PR's three new ctest entries (`agc_driver_image_packed16_storage_133`, `_134` and `_136`) all run and pass here; none is skipped. No other ctest entry is added, skipped or removed compared with `main`. This checks correctness only; I did not measure performance. GPUs tested: AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 / kernel 7.0.0-38 AI-assisted: yes
klosixgaming-arch commented 2026-10-19 18:40:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by klosixgaming-arch on 2026-10-19T18:40:58Z.


Cyberpunk 2077 PPSA03974 (v02.120.000, the same title as #6119 under another region's ID) on Windows 11 26200, RTX 5090, NVIDIA 617.42, WinLibs GCC 15.2.0.

  • main b13183e59 stops 160 s in:
    [gpu] driver failure: compute shader 0x1aa4f07500: AGC graphics: guest storage texture format 4 cannot be used as a storage image
    
  • This PR's merge ref a337b8895 (head 4adf40588 on main c70524a3d): that stop is gone and the title runs for 440 s, then stops with the #6806 line:
    unsupported PA_CL_CLIP_CNTL flags is unsupported (register 0x204 = 0x00090000)
    
    That base predates #8046, which accepts this value on main now.

AI-assisted: yes. Written with AI assistance and reviewed by me.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6274569959 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6218#issuecomment-6274569959). Originally posted by [klosixgaming-arch](https://github.com/klosixgaming-arch) on 2026-10-19T18:40:58Z. --- Cyberpunk 2077 PPSA03974 (v02.120.000, the same title as #6119 under another region's ID) on Windows 11 26200, RTX 5090, NVIDIA 617.42, WinLibs GCC 15.2.0. - `main` b13183e59 stops 160 s in: ``` [gpu] driver failure: compute shader 0x1aa4f07500: AGC graphics: guest storage texture format 4 cannot be used as a storage image ``` - This PR's merge ref a337b8895 (head 4adf40588 on `main` c70524a3d): that stop is gone and the title runs for 440 s, then stops with the #6806 line: ``` unsupported PA_CL_CLIP_CNTL flags is unsupported (register 0x204 = 0x00090000) ``` That base predates #8046, which accepts this value on `main` now. AI-assisted: yes. Written with AI assistance and reviewed by me.
thuanquang commented 2026-10-20 08:28:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-20T08:28:33Z.


Hardware data for the packed stores on RDNA 2: RX 6700 XT (gfx1031), raw ISA through the HIP runtime of AMD's Windows driver 32.0.21045.5002, so the conversion is the hardware's, not a Vulkan driver's.

Method: image_store v[4:7] ... dmask:0xf dim:SQ_RSRC_IMG_2D unorm glc through a linear 2D T# of each format (GFX10 codes), then image_load of the same texel through a 16_UINT T# over the same memory. First, one-channel stores of 1.0 locate each field. Then each channel gets 0, -0, 0x00000001, 0.25, 0.5, 0.5 ± 1 ulp, 1, 1 + 1 ulp, 2, -1, ±inf, ±NaN, a signalling NaN, 1/3 and 2/3, plus the f32 neighbours of every rounding midpoint (k + 0.5) / (2^n - 1) of its field. The same rows ran at IEEE 0 and 1, DX10_CLAMP 0 and 1, and with f32 denormals flushed and kept, and again with d16 half-precision data for the special values.

code fields, low bit first matches this PR's layout
133 5_6_5 R 0-4, G 5-10, B 11-15 yes
134 R 0-4, G 5-9, B 10-14, A bit 15 yes (5_5_5_1, W in bit 15)
135 R bit 0, G 1-5, B 6-10, A 11-15 not mapped by the PR
136 4_4_4_4 R 0-3, G 4-7, B 8-11, A 12-15 yes

Per field, in every mode, f32 and d16 alike:

  • The stored value is the exact product x * (2^n - 1) rounded to nearest, not fl32(x * scale) rounded: 429 of 429 rows for 133, 252 of 252 for 136, and the same for 134/135 except the tie below. Rounding fl32(x * scale) misses 32 to 78 rows per format.
  • NaN of either sign and signalling NaN store 0. -0, negative values and -inf store 0. +inf and values ≥ 1 store the field maximum. No bits outside the field are touched.
  • The one exact tie, 0.5 into a 1-bit field, stores 1 (the A bit of 134 and the R bit of 135, with f32 0x3f000000 and with d16 0x3800). This is 2 of 354 rows per format.

So NormStoreBits' round-half-to-even differs from the hardware on that tie: it stores 0, the GPU stores 1. With f32 or f16 inputs, a 1-bit field at exactly 0.5 is the only tie that can occur: a tie needs x = (2k + 1) / (2 (2^n - 1)), which is a binary fraction only for n = 1. So rounding exact ties up would only change that case. The test's StoreField uses std::nearbyint, which rounds half to even too, and StoreValues contains 0.5, so the test expects 0 for that W bit as well.

This is desktop RDNA 2, not a PS5. I haven't run the PR's Vulkan tests here.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6286799228 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6218#issuecomment-6286799228). Originally posted by [thuanquang](https://github.com/thuanquang) on 2026-10-20T08:28:33Z. --- Hardware data for the packed stores on RDNA 2: RX 6700 XT (gfx1031), raw ISA through the HIP runtime of AMD's Windows driver 32.0.21045.5002, so the conversion is the hardware's, not a Vulkan driver's. Method: `image_store v[4:7] ... dmask:0xf dim:SQ_RSRC_IMG_2D unorm glc` through a linear 2D T# of each format (GFX10 codes), then `image_load` of the same texel through a `16_UINT` T# over the same memory. First, one-channel stores of 1.0 locate each field. Then each channel gets 0, -0, 0x00000001, 0.25, 0.5, 0.5 ± 1 ulp, 1, 1 + 1 ulp, 2, -1, ±inf, ±NaN, a signalling NaN, 1/3 and 2/3, plus the f32 neighbours of every rounding midpoint (k + 0.5) / (2^n - 1) of its field. The same rows ran at IEEE 0 and 1, DX10_CLAMP 0 and 1, and with f32 denormals flushed and kept, and again with `d16` half-precision data for the special values. | code | fields, low bit first | matches this PR's layout | |---|---|---| | 133 `5_6_5` | R 0-4, G 5-10, B 11-15 | yes | | 134 | R 0-4, G 5-9, B 10-14, A bit 15 | yes (`5_5_5_1`, W in bit 15) | | 135 | R bit 0, G 1-5, B 6-10, A 11-15 | not mapped by the PR | | 136 `4_4_4_4` | R 0-3, G 4-7, B 8-11, A 12-15 | yes | Per field, in every mode, f32 and d16 alike: - The stored value is the exact product `x * (2^n - 1)` rounded to nearest, not `fl32(x * scale)` rounded: 429 of 429 rows for 133, 252 of 252 for 136, and the same for 134/135 except the tie below. Rounding `fl32(x * scale)` misses 32 to 78 rows per format. - NaN of either sign and signalling NaN store 0. -0, negative values and -inf store 0. +inf and values ≥ 1 store the field maximum. No bits outside the field are touched. - **The one exact tie, 0.5 into a 1-bit field, stores 1** (the A bit of 134 and the R bit of 135, with f32 0x3f000000 and with d16 0x3800). This is 2 of 354 rows per format. So `NormStoreBits`' round-half-to-even differs from the hardware on that tie: it stores 0, the GPU stores 1. With f32 or f16 inputs, a 1-bit field at exactly 0.5 is the only tie that can occur: a tie needs `x = (2k + 1) / (2 (2^n - 1))`, which is a binary fraction only for n = 1. So rounding exact ties up would only change that case. The test's `StoreField` uses `std::nearbyint`, which rounds half to even too, and `StoreValues` contains 0.5, so the test expects 0 for that W bit as well. This is desktop RDNA 2, not a PS5. I haven't run the PR's Vulkan tests here.
DavidSamir commented 2026-10-21 06:30:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-21T06:30:57Z.


First run on AMD's Windows Vulkan driver. It shows a different failure on main than on NVIDIA and lavapipe.

Setup: Windows 11 Pro 26200, AMD Radeon 680M (RDNA 2 iGPU, 1002:1681), AMD driver 32.0.21030.2001 (Vulkan 1.4.315), WinLibs GCC 15.2.0 r7, Release. main 1ff5c8ac5. This PR's head 4adf40588 merged into it cleanly. Khronos validation layer from SDK 1.4.363 (VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation), plus ANYPS5_REQUIRE_VULKAN=1 and ANYPS5_NO_SHADER_CACHE=1. The command is the PR's own nine-case ctest -R '^agc_driver_(image_(converted_unorm|packed16_load|store_sint|sint8|repacked_float|packed16_storage_(133|134|136))|fmask_image_reads)$' -V -j1. On the main side, main's implementation is built with only this PR's ImageConvertedUnorm.cpp and its test registration, so both sides run the same cases.

This driver reports optimal-tiling STORAGE_IMAGE for R5G6B5, B5G6R5, A1R5G5B5, R5G5B5A1, B4G4R4A4 and R4G4B4A4_UNORM_PACK16 (vulkaninfo --show-formats). So main does not refuse these formats here, as it does on the RTX 3090 and lavapipe. It uses them, and the result is wrong:

Case main this PR
agc_driver_image_packed16_storage_133 fails: packed image load/store changed guest bytes for format 133 passes
agc_driver_image_packed16_storage_134 fails: ... for format 134 passes
agc_driver_image_packed16_storage_136 fails: ... for format 136 passes
the six existing cases pass pass
total 6 of 9 9 of 9

No VUID- lines on either side, and no was not found but was requested by env var VK_INSTANCE_LAYERS.

On AMD's Windows driver, main doesn't stop on these formats the way it does on NVIDIA. It writes the wrong guest bytes without any error, so a title would render wrongly instead of stopping. This PR's route through the R16_UINT view gives the bit-exact round trip on this driver too.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6309650788 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6218#issuecomment-6309650788). Originally posted by [DavidSamir](https://github.com/DavidSamir) on 2026-10-21T06:30:57Z. --- First run on AMD's Windows Vulkan driver. It shows a different failure on `main` than on NVIDIA and lavapipe. **Setup:** Windows 11 Pro 26200, AMD Radeon 680M (RDNA 2 iGPU, `1002:1681`), AMD driver 32.0.21030.2001 (Vulkan 1.4.315), WinLibs GCC 15.2.0 r7, Release. `main` `1ff5c8ac5`. This PR's head `4adf40588` merged into it cleanly. Khronos validation layer from SDK 1.4.363 (`VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`), plus `ANYPS5_REQUIRE_VULKAN=1` and `ANYPS5_NO_SHADER_CACHE=1`. The command is the PR's own nine-case `ctest -R '^agc_driver_(image_(converted_unorm|packed16_load|store_sint|sint8|repacked_float|packed16_storage_(133|134|136))|fmask_image_reads)$' -V -j1`. On the `main` side, `main`'s implementation is built with only this PR's `ImageConvertedUnorm.cpp` and its test registration, so both sides run the same cases. **This driver reports optimal-tiling `STORAGE_IMAGE` for `R5G6B5`, `B5G6R5`, `A1R5G5B5`, `R5G5B5A1`, `B4G4R4A4` and `R4G4B4A4_UNORM_PACK16`** (`vulkaninfo --show-formats`). So `main` does not refuse these formats here, as it does on the RTX 3090 and lavapipe. It uses them, and the result is wrong: | Case | `main` | this PR | |---|---|---| | `agc_driver_image_packed16_storage_133` | fails: `packed image load/store changed guest bytes for format 133` | passes | | `agc_driver_image_packed16_storage_134` | fails: `... for format 134` | passes | | `agc_driver_image_packed16_storage_136` | fails: `... for format 136` | passes | | the six existing cases | pass | pass | | total | 6 of 9 | 9 of 9 | No `VUID-` lines on either side, and no `was not found but was requested by env var VK_INSTANCE_LAYERS`. On AMD's Windows driver, `main` doesn't stop on these formats the way it does on NVIDIA. It writes the wrong guest bytes without any error, so a title would render wrongly instead of stopping. This PR's route through the `R16_UINT` view gives the bit-exact round trip on this driver too. AI-assisted: yes
oneandonlydean commented 2026-10-21 06:32:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T06:32:56Z.


@harry-z-kang a useful data point from @DavidSamir: on AMD's Windows driver, which reports storage support for these packed 16-bit formats, main silently writes the wrong guest bytes for formats 133, 134 and 136, and this PR's R16_UINT route round-trips them exactly. Thanks @DavidSamir; that makes this a correctness fix on that driver, not just a refusal-to-support change. The gate on current main is next.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6309679965 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6218#issuecomment-6309679965). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-21T06:32:56Z. --- @harry-z-kang a useful data point from @DavidSamir: on AMD's Windows driver, which reports storage support for these packed 16-bit formats, `main` silently writes the wrong guest bytes for formats 133, 134 and 136, and this PR's `R16_UINT` route round-trips them exactly. Thanks @DavidSamir; that makes this a correctness fix on that driver, not just a refusal-to-support change. The gate on current `main` is next.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!6218
No description provided.