fix(shader): declare lock-emulated 64-bit atomic images as Rg32ui #21749

Merged
androidbaklava merged 1 commit from upstream-pr/21749 into main 2026-11-27 17:44:18 +00:00
androidbaklava commented 2026-11-16 18:26:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by androidbaklava on 2026-11-16T18:26:57Z.


What

Since #18842, agc_driver_image_atomics64 fails on every run on an Intel UHD iGPU on Windows:

ShaderRecompiler::Recompile: SPIR-V module emission failed: 64-bit image atomics without VK_EXT_shader_image_atomic_int64 need storage image reads and writes without format

This driver has neither shaderImageInt64Atomics nor shaderStorageImageReadWithoutFormat, so every 64-bit image atomic (and every program holding one) is refused, where before #18842 the test skipped.

The lock emulation always binds the image through an R32G32_UINT view (StorageTexture::AtomicView, and PlaceholderImageShapeForDevice for the placeholder), and reads and writes it as two uint components. The image type no longer leaves its format Unknown: a lock-emulated 64-bit atomic image is declared Rg32ui, which needs StorageImageExtendedFormats instead of StorageImageReadWithoutFormat and StorageImageWriteWithoutFormat. Vulkan allows that capability without a feature, VulkanDevice's CoreVulkanCapability already accepts it, and R32G32_UINT storage images are mandatory. ShaderValidation now accepts it too. Devices with shaderImageInt64Atomics keep R64ui.

agc_shader_memory_tests compiled the lock path with both formatless capabilities in the device list, so a device without them was never covered. They are dropped from that list, and the test now checks that the locked image_atomic_swap declares StorageImageExtendedFormats and neither formatless capability. Without this change the test fails with the error above.

The 64-bit image atomics entry in docs/dev/debt/shader.md is changed through a fragment to name Intel's Windows driver and this measurement.

Tested

Windows 11 Home 10.0.26200, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON, main ed957ca35c. ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ctest --test-dir build -R '^agc_driver_(image_atomics64|buffer_atomics_or_swap64|buffer_atomics_inc_dec64)$' -V, 3 runs each, rebuilding in between:

agc_driver_image_atomics64 agc_driver_buffer_atomics_or_swap64 agc_driver_buffer_atomics_inc_dec64 VUID- lines
main fails 3/3 (error above) passes 3/3 passes 3/3 0
this PR passes 3/3 passes 3/3 passes 3/3 0

With this PR agc_driver_image_atomics64 runs every case on this GPU: all operations on 32_32 UINT, SINT and FLOAT images and 2,048 contended image_atomic_add and image_atomic_umax on one texel in wave32 and wave64, all exact. Every log shows Insert instance layer "VK_LAYER_KHRONOS_validation" and none shows was not found but was requested.

agc_shader_memory_tests (default mode): fails on main's recompiler with the tightened test, passes with this PR. ctest -R 'atomic|^agc_shader|placeholder': 108 of 108 pass; the skips are the same as on main. To build main on Windows I applied #19899's _putenv_s change to UploadCacheReadOnlyFlush.cpp locally; it is not part of this PR.

Not tested on MoltenVK, where shaderStorageImageReadWithoutFormat is present and the declared format changes from Unknown to Rg32ui over the same R32G32_UINT view.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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: none
  • Unblocks: none
  • GPUs tested: Intel UHD Graphics (Raptor Lake, 8086:a7a8), Intel driver 101.7084, Windows 11
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5342656469 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21749). Originally posted by [androidbaklava](https://github.com/androidbaklava) on 2026-11-16T18:26:57Z. --- ### What Since #18842, `agc_driver_image_atomics64` fails on every run on an Intel UHD iGPU on Windows: ``` ShaderRecompiler::Recompile: SPIR-V module emission failed: 64-bit image atomics without VK_EXT_shader_image_atomic_int64 need storage image reads and writes without format ``` This driver has neither `shaderImageInt64Atomics` nor `shaderStorageImageReadWithoutFormat`, so every 64-bit image atomic (and every program holding one) is refused, where before #18842 the test skipped. The lock emulation always binds the image through an `R32G32_UINT` view (`StorageTexture::AtomicView`, and `PlaceholderImageShapeForDevice` for the placeholder), and reads and writes it as two `uint` components. The image type no longer leaves its format `Unknown`: a lock-emulated 64-bit atomic image is declared `Rg32ui`, which needs `StorageImageExtendedFormats` instead of `StorageImageReadWithoutFormat` and `StorageImageWriteWithoutFormat`. Vulkan allows that capability without a feature, `VulkanDevice`'s `CoreVulkanCapability` already accepts it, and `R32G32_UINT` storage images are mandatory. `ShaderValidation` now accepts it too. Devices with `shaderImageInt64Atomics` keep `R64ui`. `agc_shader_memory_tests` compiled the lock path with both formatless capabilities in the device list, so a device without them was never covered. They are dropped from that list, and the test now checks that the locked `image_atomic_swap` declares `StorageImageExtendedFormats` and neither formatless capability. Without this change the test fails with the error above. The `64-bit image atomics` entry in `docs/dev/debt/shader.md` is changed through a fragment to name Intel's Windows driver and this measurement. ### Tested Windows 11 Home 10.0.26200, WinLibs GCC 15.2.0 r7, Release, `BUILD_TESTING=ON`, `main` `ed957ca35c`. `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ctest --test-dir build -R '^agc_driver_(image_atomics64|buffer_atomics_or_swap64|buffer_atomics_inc_dec64)$' -V`, 3 runs each, rebuilding in between: | | `agc_driver_image_atomics64` | `agc_driver_buffer_atomics_or_swap64` | `agc_driver_buffer_atomics_inc_dec64` | `VUID-` lines | |---|---|---|---|---| | `main` | fails 3/3 (error above) | passes 3/3 | passes 3/3 | 0 | | this PR | passes 3/3 | passes 3/3 | passes 3/3 | 0 | With this PR `agc_driver_image_atomics64` runs every case on this GPU: all operations on 32_32 UINT, SINT and FLOAT images and 2,048 contended `image_atomic_add` and `image_atomic_umax` on one texel in wave32 and wave64, all exact. Every log shows `Insert instance layer "VK_LAYER_KHRONOS_validation"` and none shows `was not found but was requested`. `agc_shader_memory_tests` (default mode): fails on `main`'s recompiler with the tightened test, passes with this PR. `ctest -R 'atomic|^agc_shader|placeholder'`: 108 of 108 pass; the skips are the same as on `main`. To build `main` on Windows I applied #19899's `_putenv_s` change to `UploadCacheReadOnlyFlush.cpp` locally; it is not part of this PR. Not tested on MoltenVK, where `shaderStorageImageReadWithoutFormat` is present and the declared format changes from `Unknown` to `Rg32ui` over the same `R32G32_UINT` view. ### 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) and the licence notice of code adapted from upstream (see AGENTS.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: none - [x] Unblocks: none - [x] GPUs tested: Intel UHD Graphics (Raptor Lake, `8086:a7a8`), Intel driver 101.7084, Windows 11 - [x] AI-assisted: yes
MarcZX10 commented 2026-11-20 11:29:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T11:29:57Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing blocks this change; the inspected code supports the stated fix, but one changed test file was not fully reviewed.

What I ran

Inspected the prepared diff for head e4e7ad54a82640801e64837c210dcdea66b98012, the PR description and manifest, and targeted code at the pinned head using repo_read.py.

No build or tests were run. I read the full changed lines and surrounding code for ShaderValidation.cpp, SpirvDescriptors.cpp, and SpirvModuleSetup.cpp; for ShaderMemory.cpp, I read the changed lines and the surrounding verifyInt64AtomicCapabilities function range. I also inspected targeted Vulkan capability, atomic-emission, image-view, and related test code. ShaderMemory.cpp was excluded from the review folder because it was too large; it was accessed through the reader for the relevant range.

Results

Check Result Note
Diff and changed lines passed All four changed files inspected at changed lines
Targeted code review passed Related capability and lock-emulation paths inspected
Build and tests not run No commands run

Findings

Blocking

None identified in the code inspected.

Non-blocking

None.

Not verified

  • No build or test commands were run; the reported Windows and GPU results are author-reported.
  • The complete ShaderMemory.cpp file was not read; only the changed lines and relevant function range were inspected.
  • MoltenVK behavior was not tested, as noted in the PR description.
  • The excluded debt fragment docs/dev/debt/changes/fix-agc-image-atomics64-typed-locks.md was not reviewed.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5991978943 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21749#pullrequestreview-5991978943). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T11:29:57Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing blocks this change; the inspected code supports the stated fix, but one changed test file was not fully reviewed. ## What I ran Inspected the prepared diff for head `e4e7ad54a82640801e64837c210dcdea66b98012`, the PR description and manifest, and targeted code at the pinned head using `repo_read.py`. No build or tests were run. I read the full changed lines and surrounding code for `ShaderValidation.cpp`, `SpirvDescriptors.cpp`, and `SpirvModuleSetup.cpp`; for `ShaderMemory.cpp`, I read the changed lines and the surrounding `verifyInt64AtomicCapabilities` function range. I also inspected targeted Vulkan capability, atomic-emission, image-view, and related test code. `ShaderMemory.cpp` was excluded from the review folder because it was too large; it was accessed through the reader for the relevant range. ## Results | Check | Result | Note | |---|---|---| | Diff and changed lines | passed | All four changed files inspected at changed lines | | Targeted code review | passed | Related capability and lock-emulation paths inspected | | Build and tests | not run | No commands run | ## Findings ### Blocking None identified in the code inspected. ### Non-blocking None. ## Not verified - No build or test commands were run; the reported Windows and GPU results are author-reported. - The complete `ShaderMemory.cpp` file was not read; only the changed lines and relevant function range were inspected. - MoltenVK behavior was not tested, as noted in the PR description. - The excluded debt fragment `docs/dev/debt/changes/fix-agc-image-atomics64-typed-locks.md` was not reviewed. ## To get this to a good state Nothing is required.
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!21749
No description provided.