fix(shader): gather a 3D image's image_gather4_lz from one slice as measured #9183

Merged
fma-rc merged 14 commits from upstream-pr/9183 into main 2026-11-03 19:10:40 +00:00
fma-rc commented 2026-10-21 14:34:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-21T14:34:56Z.


What

image_gather4_lz through a 3D T# was emitted as OpImageGather on a 3D image, which SPIR-V does not allow (gathers take 2D, cube and rect images). NVIDIA's compiler dies on it with SIGILL, RADV crashes, and lavapipe refuses the pipeline (vkCreateComputePipelines: Vulkan result -13). Death Stranding 2 (PPSA02015) has such a compute shader (0xc280112c00) and stops there: NVIDIA with SIGILL at 157 s, the 680M with a crash (rc 139).

The hardware gathers four texels of one slice. Measured on a Radeon 610M (gfx1036) with the hardware oracle, 3742 rows over every clamp mode and border color:

  • each coordinate is reduced by its axis's clamp mode (wrap to [0,1), mirror to [0,2), otherwise clamped to [-4,4]; NaN reads as 0, infinities as -4 and 4), multiplied by the extent and 256 and rounded half up, exactly;
  • x and y take the texel pair around that point minus half a texel, z the slice that contains it; the order is (x0,y1), (x1,y1), (x1,y0), (x0,y0);
  • clamp modes address each texel; the half-border modes keep the pair together with its lower texel pinned to [-1, extent-1], and act as clamp to edge on z; border texels read transparent black, opaque black or white;
  • the sampler's LOD clamp, bias, filters and anisotropy are ignored, and the view's base level is read.

The recompiler now emits four OpImageFetch reads with that addressing. The sampler state reaches the shader as a specialization constant, or through the image's runtime metadata in registration modules. A border color table, a swizzled or integer texture with border addressing, image or sampler tables, unnormalized coordinates and samplers that disagree throw. The shader debt file records the measurement. Probes, results and the model check: evidence/gather-3d-volume (checkall.py matches all 3742 rows).

@mrfelek found the same shader in #5424 (comment) and fixed it on their fork (fix/volume-gather-lz), without a PR, with four level-zero samples at the footprint's texel centres, from a Radeon 780M measurement of the slice choice and of wrap and clamp on it. This PR fetches the texels instead, because the measurement above shows that the sampler's filters, LOD clamp and bias do not change a gather, and it adds the per-axis modes, the 1/256 snap, the half-border modes and the border colors.

Tested

Arch Linux, rebased on main 4f41f4c375 (2026-11-03, 3cb6fb3ebb). With main's own new ImageResource fields the info encoder now counts 50 fields and the record stays 108 bytes. The two checks that expected the unimplemented border paths to throw are dropped. The FreeType submodule is main's again (my earlier rebase had moved it back to 2.13.3).

  • On this head, 112 image, shader and disk cache tests (agc_driver_image_*, agc_shader_*, agc_shader_disk_cache*) pass on the RTX 5080, RADV (Radeon 610M) and lavapipe, except three that skip on RADV (agc_driver_image_array_rows_past_layer_limit, agc_driver_image_array_window_past_layer_limit, agc_driver_image_table_vouched_lookups). The Windows build and ctest pass (3919 of 3919), with no failure the merge base lacks.
  • The wrapped texel index is reduced with an unsigned remainder: OpSRem with a negative operand is undefined in Vulkan without maintenance8, and the NVIDIA RTX 2000 Ada in CI returned 3 for -1 mod 7. agc_driver_image_gather_volume now also fails if the gather shader contains OpSRem or OpSMod; it fails at e92ec413c9 (test only) and passes with the fix.
  • @jotitadev ran the test on an Apple M2 Max with MoltenVK (review): with the merge base's recompiler it fails at pipeline creation (Metal has no 3D gather); with the PR it passes.
  • New test agc_driver_image_gather_volume: red channel, alpha and blue gathers over all eight clamp modes and three border colors, an odd 7x5x3 volume, per-axis modes, rounding ties and denormal coordinates, a 241-texel-wide volume at 1/256 boundaries, a base level, a swizzle, null images, a vertex-shader variant through the registration path, and a gather next to a 3D sample through another sampler. Expected values come from the measured model.
  • On main the test fails on every device: NVIDIA RTX 5080 SIGILL (132), Radeon 610M and 680M crash (139), lavapipe vkCreateComputePipelines: Vulkan result -13, llvmpipe rc 1. With the PR it passes on all five.
  • Each later fix is red without it and green with it on the RTX 5080, 610M, 680M, lavapipe and llvmpipe: per-axis modes, the registration path, z half border, and pairing the state only with the gather's own sampler. A null image divided by a zero extent; no device shows a wrong value for that, so the test checks the SPIR-V instead, which fails with main's extent and passes with the fix.
  • agc_driver_image_gather_one_dimensional, image_converted_unorm, image_sample_reduction, image_sint8, image_srgb_load, image_sample_unnormalized pass on main and with the PR on the RTX 5080, 610M and lavapipe.
  • Full suite on lavapipe: 1756 of 1763 pass; the 7 failures (conventions_env_reference, conventions_blob_reads, agc_driver_f64_denorm_preserve_spirv, agc_driver_f16_to_f32_unpack_spirv, the three net_dontwait_blocking_send*) fail the same way on the merge base on this machine.
  • Death Stranding 2, 400 s, hidden, on main with PR 5426, PR 7978, PR 6565, PR 6182, PR 8223 and our multisampled-target retire change, which it needs to reach this shader: without this PR the RTX 5080 stops with SIGILL in the shader compiler at 157 s and the 680M crashes; with it both run on to the next stop, color targets with fewer fragments than samples (EQAA) are unsupported (RTX 5080 at 86 s, frame 88; 680M at 228 s, frame 63, picture visible).
  • tools/check_conventions.py --base origin/main passes.

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: none
  • Unblocks: PPSA02015 #5424
  • GPUs tested: NVIDIA RTX 5080 (driver 615.78.08, Linux), AMD Radeon 610M and 680M (RADV, Mesa 26.1.4 / 26.2.4, Linux), lavapipe, llvmpipe
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4953337099 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9183). Originally posted by [fma-rc](https://github.com/fma-rc) on 2026-10-21T14:34:56Z. --- ### What `image_gather4_lz` through a 3D T# was emitted as `OpImageGather` on a 3D image, which SPIR-V does not allow (gathers take 2D, cube and rect images). NVIDIA's compiler dies on it with SIGILL, RADV crashes, and lavapipe refuses the pipeline (`vkCreateComputePipelines: Vulkan result -13`). Death Stranding 2 (PPSA02015) has such a compute shader (`0xc280112c00`) and stops there: NVIDIA with SIGILL at 157 s, the 680M with a crash (rc 139). The hardware gathers four texels of one slice. Measured on a Radeon 610M (gfx1036) with the hardware oracle, 3742 rows over every clamp mode and border color: - each coordinate is reduced by its axis's clamp mode (wrap to [0,1), mirror to [0,2), otherwise clamped to [-4,4]; NaN reads as 0, infinities as -4 and 4), multiplied by the extent and 256 and rounded half up, exactly; - x and y take the texel pair around that point minus half a texel, z the slice that contains it; the order is (x0,y1), (x1,y1), (x1,y0), (x0,y0); - clamp modes address each texel; the half-border modes keep the pair together with its lower texel pinned to [-1, extent-1], and act as clamp to edge on z; border texels read transparent black, opaque black or white; - the sampler's LOD clamp, bias, filters and anisotropy are ignored, and the view's base level is read. The recompiler now emits four `OpImageFetch` reads with that addressing. The sampler state reaches the shader as a specialization constant, or through the image's runtime metadata in registration modules. A border color table, a swizzled or integer texture with border addressing, image or sampler tables, unnormalized coordinates and samplers that disagree throw. The shader debt file records the measurement. Probes, results and the model check: [evidence/gather-3d-volume](https://github.com/fma-rc/AnyPS5/tree/evidence/gather-3d-volume) (`checkall.py` matches all 3742 rows). @mrfelek found the same shader in #5424 ([comment](https://github.com/boykopovar/AnyPS5/discussions/5424#discussioncomment-19078289)) and fixed it on their fork ([`fix/volume-gather-lz`](https://github.com/mrfelek/AnyPS5/tree/fix/volume-gather-lz)), without a PR, with four level-zero samples at the footprint's texel centres, from a Radeon 780M measurement of the slice choice and of wrap and clamp on it. This PR fetches the texels instead, because the measurement above shows that the sampler's filters, LOD clamp and bias do not change a gather, and it adds the per-axis modes, the 1/256 snap, the half-border modes and the border colors. ### Tested Arch Linux, rebased on `main` 4f41f4c375 (2026-11-03, 3cb6fb3ebb). With `main`'s own new `ImageResource` fields the info encoder now counts 50 fields and the record stays 108 bytes. The two checks that expected the unimplemented border paths to throw are dropped. The FreeType submodule is `main`'s again (my earlier rebase had moved it back to 2.13.3). - On this head, 112 image, shader and disk cache tests (`agc_driver_image_*`, `agc_shader_*`, `agc_shader_disk_cache*`) pass on the RTX 5080, RADV (Radeon 610M) and lavapipe, except three that skip on RADV (`agc_driver_image_array_rows_past_layer_limit`, `agc_driver_image_array_window_past_layer_limit`, `agc_driver_image_table_vouched_lookups`). The Windows build and ctest pass (3919 of 3919), with no failure the merge base lacks. - The wrapped texel index is reduced with an unsigned remainder: `OpSRem` with a negative operand is undefined in Vulkan without `maintenance8`, and the NVIDIA RTX 2000 Ada in CI returned 3 for -1 mod 7. `agc_driver_image_gather_volume` now also fails if the gather shader contains `OpSRem` or `OpSMod`; it fails at e92ec413c9 (test only) and passes with the fix. - @jotitadev ran the test on an Apple M2 Max with MoltenVK ([review](https://github.com/boykopovar/AnyPS5/pull/9183#pullrequestreview-5611298883)): with the merge base's recompiler it fails at pipeline creation (Metal has no 3D gather); with the PR it passes. - New test `agc_driver_image_gather_volume`: red channel, alpha and blue gathers over all eight clamp modes and three border colors, an odd 7x5x3 volume, per-axis modes, rounding ties and denormal coordinates, a 241-texel-wide volume at 1/256 boundaries, a base level, a swizzle, null images, a vertex-shader variant through the registration path, and a gather next to a 3D sample through another sampler. Expected values come from the measured model. - On `main` the test fails on every device: NVIDIA RTX 5080 SIGILL (132), Radeon 610M and 680M crash (139), lavapipe `vkCreateComputePipelines: Vulkan result -13`, llvmpipe rc 1. With the PR it passes on all five. - Each later fix is red without it and green with it on the RTX 5080, 610M, 680M, lavapipe and llvmpipe: per-axis modes, the registration path, z half border, and pairing the state only with the gather's own sampler. A null image divided by a zero extent; no device shows a wrong value for that, so the test checks the SPIR-V instead, which fails with `main`'s extent and passes with the fix. - `agc_driver_image_gather_one_dimensional`, `image_converted_unorm`, `image_sample_reduction`, `image_sint8`, `image_srgb_load`, `image_sample_unnormalized` pass on `main` and with the PR on the RTX 5080, 610M and lavapipe. - Full suite on lavapipe: 1756 of 1763 pass; the 7 failures (`conventions_env_reference`, `conventions_blob_reads`, `agc_driver_f64_denorm_preserve_spirv`, `agc_driver_f16_to_f32_unpack_spirv`, the three `net_dontwait_blocking_send*`) fail the same way on the merge base on this machine. - Death Stranding 2, 400 s, hidden, on `main` with PR 5426, PR 7978, PR 6565, PR 6182, PR 8223 and our multisampled-target retire change, which it needs to reach this shader: without this PR the RTX 5080 stops with SIGILL in the shader compiler at 157 s and the 680M crashes; with it both run on to the next stop, `color targets with fewer fragments than samples (EQAA) are unsupported` (RTX 5080 at 86 s, frame 88; 680M at 228 s, frame 63, picture visible). - `tools/check_conventions.py --base origin/main` passes. ### 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: none - [x] Unblocks: PPSA02015 #5424 - [x] GPUs tested: NVIDIA RTX 5080 (driver 615.78.08, Linux), AMD Radeon 610M and 680M (RADV, Mesa 26.1.4 / 26.2.4, Linux), lavapipe, llvmpipe - [x] AI-assisted: yes
jotitadev commented 2026-10-22 00:01:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-22T00:01:48Z.

Review: COMMENTED


First Apple GPU / MoltenVK run. It confirms the bug here as a distinct vendor failure, shows the fix clears it, and surfaces one case in the new test that cannot run on this device.

Machine: Apple M2 Max, macOS 27.2, x86_64 under Rosetta 2. Vulkan loader + MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0). Release, BUILD_TESTING=ON.

Base/method: PR #8658 feat/macos-port @ a1fb8e3e9c (current main a6dcea9279 plus the macOS port), not main — main does not build on macOS. This PR's diff (git diff merge-base..df4fd534d -- . ':!docs') applied on top, clean.

Negative control (revert the production files to the PR's base, keep the new ImageGatherVolume.cpp): agc_driver_image_gather_volume fails at pipeline creation. MoltenVK translates the OpImageGather on a 3D image to MSL and Metal refuses it:

program_source:84:49: error: no member named 'gather' in 'metal::texture3d<float, metal::access::sample, metal::memory_coherence_threadgroup>'
    float4 _544 = spvDescriptorSet0.image_7[0u].gather(spvDescriptorSet0.samplers[0u], float3(...), component::x);
vkCreateComputePipelines: Vulkan result -3

So this is a fourth vendor's manifestation of the same bug the PR fixes: alongside the RTX 5080 SIGILL, the RADV crash and lavapipe's -13, MoltenVK rejects texture3d.gather at MSL compile with VK_ERROR_INITIALIZATION_FAILED.

With this PR: the shader compiles (the fix emits OpImageFetch instead), so the pipeline-creation failure is gone. The test then aborts on a Metal device limit, at the 3001-texel-wide volume case:

-[MTLTextureDescriptorInternal validateWithDevice:]:1421: failed assertion `Texture Descriptor Validation
MTLTextureDescriptor has width (3001) greater than the maximum allowed size of 2048.'

Metal caps a 3D texture at 2048 on this GPU (maxImageDimension3D is 2048 on MoltenVK here), and the 1/256-boundary case asks for 3001, which trips a hard Metal assertion that takes down the whole test. The fix itself is fine on MoltenVK — the gather lowering compiles and the pipeline builds; it is the test that can't run to completion here. A maxImageDimension3D guard on the wide-volume case (skip, or clamp the width) would let it run on Apple and on any device with a 2048 3D limit.

I could not get the test past that case to check the gathered values on MoltenVK, so this is not a value check — only the compile (red→green) and the device-limit abort.

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:5607688950 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9183#pullrequestreview-5607688950). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-22T00:01:48Z. **Review:** COMMENTED --- First Apple GPU / MoltenVK run. It confirms the bug here as a distinct vendor failure, shows the fix clears it, and surfaces one case in the new test that cannot run on this device. **Machine:** Apple M2 Max, macOS 27.2, x86_64 under Rosetta 2. Vulkan loader + MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0). Release, `BUILD_TESTING=ON`. **Base/method:** PR #8658 `feat/macos-port` @ `a1fb8e3e9c` (current `main` `a6dcea9279` plus the macOS port), not `main` — `main` does not build on macOS. This PR's diff (`git diff merge-base..df4fd534d -- . ':!docs'`) applied on top, clean. **Negative control** (revert the production files to the PR's base, keep the new `ImageGatherVolume.cpp`): `agc_driver_image_gather_volume` fails at pipeline creation. MoltenVK translates the `OpImageGather` on a 3D image to MSL and Metal refuses it: ``` program_source:84:49: error: no member named 'gather' in 'metal::texture3d<float, metal::access::sample, metal::memory_coherence_threadgroup>' float4 _544 = spvDescriptorSet0.image_7[0u].gather(spvDescriptorSet0.samplers[0u], float3(...), component::x); vkCreateComputePipelines: Vulkan result -3 ``` So this is a fourth vendor's manifestation of the same bug the PR fixes: alongside the RTX 5080 SIGILL, the RADV crash and lavapipe's `-13`, MoltenVK rejects `texture3d.gather` at MSL compile with `VK_ERROR_INITIALIZATION_FAILED`. **With this PR:** the shader compiles (the fix emits `OpImageFetch` instead), so the pipeline-creation failure is gone. The test then aborts on a Metal device limit, at the `3001`-texel-wide volume case: ``` -[MTLTextureDescriptorInternal validateWithDevice:]:1421: failed assertion `Texture Descriptor Validation MTLTextureDescriptor has width (3001) greater than the maximum allowed size of 2048.' ``` Metal caps a 3D texture at 2048 on this GPU (`maxImageDimension3D` is 2048 on MoltenVK here), and the 1/256-boundary case asks for 3001, which trips a hard Metal assertion that takes down the whole test. The fix itself is fine on MoltenVK — the gather lowering compiles and the pipeline builds; it is the test that can't run to completion here. A `maxImageDimension3D` guard on the wide-volume case (skip, or clamp the width) would let it run on Apple and on any device with a 2048 3D limit. I could not get the test past that case to check the gathered values on MoltenVK, so this is not a value check — only the compile (red→green) and the device-limit abort. 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.
fma-rc commented 2026-10-22 00:36:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-22T00:36:38Z.


Thanks @jotitadev, the MoltenVK compile failure is a good fourth data point. You're right that 3001 was too wide: Vulkan only guarantees maxImageDimension3D of 256. a8779a382d moves that case to a 241 texel wide volume, which every device can create, with 32 new coordinates that each land a texel apart depending on whether u times the width is rounded to float before the 1/256 snap or taken exactly, the same property the 3001 inputs had. It passes on NVIDIA, RADV and lavapipe here and still fails at that case with the recompiler from before the exact product, so it should now run to the end on your M2.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6329779441 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9183#issuecomment-6329779441). Originally posted by [fma-rc](https://github.com/fma-rc) on 2026-10-22T00:36:38Z. --- Thanks @jotitadev, the MoltenVK compile failure is a good fourth data point. You're right that 3001 was too wide: Vulkan only guarantees `maxImageDimension3D` of 256. a8779a382d moves that case to a 241 texel wide volume, which every device can create, with 32 new coordinates that each land a texel apart depending on whether u times the width is rounded to float before the 1/256 snap or taken exactly, the same property the 3001 inputs had. It passes on NVIDIA, RADV and lavapipe here and still fails at that case with the recompiler from before the exact product, so it should now run to the end on your M2.
MarcZX10 commented 2026-10-22 08:11:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T08:11:36Z.

Review: DISMISSED


The hardware evidence and the expanded coordinate/clamp coverage are unusually useful. I reviewed head a8779a382d3655ba1376b753cf76bc423247b56 and compiled the new focused test. I need two repository requirements completed before this is ready:

  1. The checklist says this is based on current main at a806c69bfe, but that is the merge base and the PR is 1,198 commits behind the current main (d6eafa54d0). The product build jobs for this head are skipped, so the reported device results do not validate the current merge base. Please update the branch, correct the checklist, and rerun the focused test against the updated code (or a current-main merge commit) on a supported host. My exact-head Release build of agc_driver_image_gather_volume_tests succeeded. I attempted its CTest run with lavapipe, but the test process exits before Vulkan initialization because this host's Intel Xeon E5-1620 v2 lacks the required LZCNT, BMI1, BMI2, MOVBE, AVX2 and FMA extensions. I therefore could not independently execute the value checks here.

  2. CONTRIBUTING.md requires the Game bring-up discussion to list the open PRs and local changes the title still needs. The current PPSA02015 discussion (#5424) does not list this PR. Please update it with #9183 and the outstanding work needed to reach the shader; the PR description says the reproduction also needs #8223, #9186 and the local multisampled-target-retire change.

Local checks on this head: git diff --check passed; the conventions command exited 0 with one warning that the new debt entry is 1,026 characters, over the 1,000-character guideline. The focused test target compiled. Its execution was blocked by this host CPU check, as described above.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5611101909 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9183#pullrequestreview-5611101909). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T08:11:36Z. **Review:** DISMISSED --- The hardware evidence and the expanded coordinate/clamp coverage are unusually useful. I reviewed head `a8779a382d3655ba1376b753cf76bc423247b56` and compiled the new focused test. I need two repository requirements completed before this is ready: 1. The checklist says this is based on current `main` at `a806c69bfe`, but that is the merge base and the PR is 1,198 commits behind the current `main` (`d6eafa54d0`). The product build jobs for this head are skipped, so the reported device results do not validate the current merge base. Please update the branch, correct the checklist, and rerun the focused test against the updated code (or a current-main merge commit) on a supported host. My exact-head Release build of `agc_driver_image_gather_volume_tests` succeeded. I attempted its CTest run with lavapipe, but the test process exits before Vulkan initialization because this host's Intel Xeon E5-1620 v2 lacks the required LZCNT, BMI1, BMI2, MOVBE, AVX2 and FMA extensions. I therefore could not independently execute the value checks here. 2. CONTRIBUTING.md requires the Game bring-up discussion to list the open PRs and local changes the title still needs. The current PPSA02015 discussion (#5424) does not list this PR. Please update it with #9183 and the outstanding work needed to reach the shader; the PR description says the reproduction also needs #8223, #9186 and the local multisampled-target-retire change. Local checks on this head: `git diff --check` passed; the conventions command exited 0 with one warning that the new debt entry is 1,026 characters, over the 1,000-character guideline. The focused test target compiled. Its execution was blocked by this host CPU check, as described above.
jotitadev commented 2026-10-22 08:26:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-22T08:26:06Z.

Review: COMMENTED


Re-ran a8779a382 on the M2 after the 241-wide change. The test now runs to the end on MoltenVK. The new wide case also fails without the exact product here, as it does on your GPUs.

Machine: Apple M2 Max, macOS 27.2, x86_64 under Rosetta 2. Release, BUILD_TESTING=ON.
Drivers: MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0), and MoltenVK main + SPIRV-Cross #2704.
Base/method: PR #8658 feat/macos-port @ ee0a438415 (current main plus the macOS port), not main, which does not build on macOS. This PR's diff (git diff merge-base..a8779a382 -- . ':!docs') applied on top, clean. Full rebuild before each run.

  • With the PR: agc_driver_image_gather_volume passes 3 of 3 on both drivers. The Metal width (3001) greater than the maximum allowed size of 2048 abort from my earlier run is gone, so this is now a full value check on Apple, not just the compile.
  • Test only, production files at the merge base: fails on both drivers at pipeline creation with the same MSL error as before (no member named 'gather' in 'metal::texture3d<...>', vkCreateComputePipelines result -3).
  • Recompiler from before the exact product (production files at c4381c7a13, test from a8779a382): the full test fails earlier, at 3D gather of red, wrap: thread 26 component 0 is 98/255, expected 2/255, because that commit also predates the addressing-mode reduction. So I ran only the 241-wide case through a local one-off patch (not part of the PR). It fails on both drivers with 3D gather of red from a 241 texel wide volume at 1/256 texel boundaries: thread 0 component 0 is 243/255, expected 242/255. With the full PR, the same case alone passes 3 of 3.
  • Full ^agc suite with the PR: -j1 --timeout 30, 857 tests. Base: 17 failures with MoltenVK 1.4.2 and 16 with main + #2704. With the PR there is one more on each driver: agc_driver_uint8x4_color_target on 1.4.2 and agc_driver_cross_workgroup_flag on main + #2704. Both also fail intermittently on the base without this PR, with the same messages (a UINT16_ABGR export byte mismatch, and a workgroup did not see another workgroup's flag store). Neither involves a 3D gather. No timeouts.

GPUs tested: Apple M2 Max (MoltenVK 1.4.2; MoltenVK main + SPIRV-Cross #2704)

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

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5611298883 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9183#pullrequestreview-5611298883). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-22T08:26:06Z. **Review:** COMMENTED --- <!-- head: a8779a382 --> Re-ran a8779a382 on the M2 after the 241-wide change. The test now runs to the end on MoltenVK. The new wide case also fails without the exact product here, as it does on your GPUs. **Machine:** Apple M2 Max, macOS 27.2, x86_64 under Rosetta 2. Release, `BUILD_TESTING=ON`. **Drivers:** MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0), and MoltenVK main + SPIRV-Cross #2704. **Base/method:** PR #8658 `feat/macos-port` @ `ee0a438415` (current `main` plus the macOS port), not `main`, which does not build on macOS. This PR's diff (`git diff merge-base..a8779a382 -- . ':!docs'`) applied on top, clean. Full rebuild before each run. - **With the PR:** `agc_driver_image_gather_volume` passes 3 of 3 on both drivers. The Metal `width (3001) greater than the maximum allowed size of 2048` abort from my earlier run is gone, so this is now a full value check on Apple, not just the compile. - **Test only, production files at the merge base:** fails on both drivers at pipeline creation with the same MSL error as before (`no member named 'gather' in 'metal::texture3d<...>'`, `vkCreateComputePipelines` result -3). - **Recompiler from before the exact product** (production files at c4381c7a13, test from a8779a382): the full test fails earlier, at `3D gather of red, wrap: thread 26 component 0 is 98/255, expected 2/255`, because that commit also predates the addressing-mode reduction. So I ran only the 241-wide case through a local one-off patch (not part of the PR). It fails on both drivers with `3D gather of red from a 241 texel wide volume at 1/256 texel boundaries: thread 0 component 0 is 243/255, expected 242/255`. With the full PR, the same case alone passes 3 of 3. - **Full `^agc` suite with the PR:** `-j1 --timeout 30`, 857 tests. Base: 17 failures with MoltenVK 1.4.2 and 16 with main + #2704. With the PR there is one more on each driver: `agc_driver_uint8x4_color_target` on 1.4.2 and `agc_driver_cross_workgroup_flag` on main + #2704. Both also fail intermittently on the base without this PR, with the same messages (a UINT16_ABGR export byte mismatch, and `a workgroup did not see another workgroup's flag store`). Neither involves a 3D gather. No timeouts. GPUs tested: Apple M2 Max (MoltenVK 1.4.2; MoltenVK main + SPIRV-Cross #2704) Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
XairRrR commented 2026-11-03 13:19:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T13:19:41Z.

Review: APPROVED


Reviewed — approved

The 3D image_gather4_lz lowering merges cleanly, builds, and passes the focused image, gather and disk cache tests on lavapipe. The new test fails with main's recompiler. Two things were not checked here: the measured hardware model (no AMD GPU on this machine) and the bring-up list. The only new validation IDs come from main's sampler creation, not from this change.

What I ran

Head 3cb6fb3ebb3fa6d30b8a373c3a006504f6247445, main 4f41f4c375f5abb487dbd184fbc150f31994d762, merged tree 8d1e202a94108a3eba9754cfc8d4744b136fc146. Debian 13 VM (Xeon Gold 6136, AVX2/FMA), GCC 14.2.0, Release, Ninja. Vulkan was lavapipe (Mesa 26.1.6, LLVM 19); there is no GPU.

git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...3cb6fb3ebb3fa6d30b8a373c3a006504f6247445
python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762
env VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 VK_LOADER_DEBUG=error,warn,layer ctest --test-dir build -V -R '^agc_driver_image_gather_volume$'
# negative control: the 8 production files restored from main
ninja -C build -j32 -l32 agc_driver_image_gather_volume_tests
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ctest --test-dir build --output-on-failure -R '^agc_driver_image_gather_volume$'
# merged files restored, full rebuild
ninja -C build -j32 -l32
ANYPS5_REQUIRE_VULKAN=1 ctest --test-dir build -j8 --test-load 32 --output-on-failure -R 'gather|disk_cache|agc_driver_image_sample|agc_driver_image_table|shader_info|resource_tracker|descriptor_binding'
git status --porcelain

Results

Check Result
git diff --check clean
check_conventions.py All conventions checks passed
Configure / build / libs (script) ok
Script test run (2163 tests) no new failures, no timeouts; 7 known failures that also fail on main
Focused run (28 tests: gather, image sample, image table, disk cache) 27 passed, 1 skipped (agc_driver_image_sample_lod_clamp, a device limitation)
agc_driver_image_gather_volume passes in about 9.4 s on lavapipe with validation (limit is 30 s)
Validation layer loaded; 8 new VUID- lines, all in the new test, all from vkCreateSampler with MIRROR_CLAMP_TO_EDGE (see Non-blocking)
Worktree after the control git status --porcelain empty
New validation IDs in agc_driver_image_gather_volume
Validation Error: [ VUID-VkSamplerCreateInfo-addressModeU-parameter ]
vkCreateSampler(): pCreateInfo->addressModeU (VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) requires the extensions VK_KHR_sampler_mirror_clamp_to_edge.
Validation Error: [ VUID-VkSamplerCreateInfo-addressModeV-parameter ] ...
Validation Error: [ VUID-VkSamplerCreateInfo-addressModeW-parameter ] ...
Validation Error: [ VUID-VkSamplerCreateInfo-addressModeU-01079 ]
vkCreateSampler(): pCreateInfo->addressModeU is VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE but the VK_KHR_sampler_mirror_clamp_to_edge extension or samplerMirrorClampToEdge feature was not enabled.

Negative control

I restored the eight production files from main: Resources.hpp, ResourceMaterializer.hpp/.cpp, DescriptorBindingBuilder.cpp, ResourceTracker.cpp, PipelineSpecialization.hpp, ShaderDiskCache.cpp and SpirvImageEmitter.cpp. I kept the new test and rebuilt it. It fails on the first case:

Output
ShaderRecompiler::Recompile: SPIR-V validation before optimization failed:
level=2 word=607: [VUID-StandaloneSpirv-OpImage-04777] Expected Image 'Dim' to be 2D, Cube, or Rect
  %531 = OpImageGather %v4float %529 %518 %uint_0

This matches the description's lavapipe result on main (pipeline refused). I then restored the merged files, rebuilt everything, and the test passed again.

Findings

Blocking

None.

Non-blocking

  • The new test hits main's missing samplerMirrorClampToEdge enablement (core/libs/prx/libSceAgcDriver/Graphics/src/GuestSamplerResource.cpp:32-44).
    • The test's mirror-once samplers (guest clamp modes 3, 5 and 7) go to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE through toVkAddressMode.
    • Nothing under core/ enables samplerMirrorClampToEdge or VK_KHR_sampler_mirror_clamp_to_edge.
    • The PR does not touch this code, and the gather itself never reads the sampler (it fetches). The 8 VUIDs therefore come from main and are listed as new only because the test does not exist there.
    • They still mean undefined behaviour in vkCreateSampler for every guest sampler with those modes. Fixing it is a separate change: enable the feature, or throw when it is unavailable. It is worth a debt entry or a follow-up issue.
  • Unverified hardware claims are mentioned only in the debt entry. The debt entry in docs/dev/debt/shader.md correctly says the model comes from gfx1036, not the PS5's gfx1013. The 4.0 clamp bound and the half-border pinning are the parts most likely to differ between RDNA2 parts. A later run on a second RDNA2 GPU would firm them up. Not required for this PR.

Earlier review points, checked on this head:

  • The RunThrows checks are gone.
  • 3rdparty/freetype is no longer in the diff.
  • The NVIDIA wrap failure from the RTX 2000 Ada run is addressed: the index reduction in SpirvImageEmitter.cpp:925-928 adds one period and uses OpUMod with a nonzero divisor (the extent is UMax(size, 1)). The test rejects any OpSRem or OpSMod in the gather shader.

I also checked by hand:

  • The exact snap in EmitVolumeGatherLz (SpirvImageEmitter.cpp:839): the rounding bias for negative values, the 64-bit shift split at shift 32, and denormals.
  • That the 11-bit gather state fits RuntimeAbi::CompareStateMask (13 bits) for registration modules.
  • That the disk cache picks up the changed encoding through the generated source version.

Not verified

  • Hardware model: I could not check the measured model (the 1/256 snap, half-border pinning, slice choice, border colors) against hardware: there is no AMD GPU here, and the evidence branch is outside the repository, so I did not rerun checkall.py. Everything here is lavapipe only.
  • Other vendors: NVIDIA, RADV and MoltenVK results come from the author and other commenters, not from me.
  • Bring-up list: I could not check whether the PPSA02015 bring-up discussion (#5424) now lists this PR, which an earlier review asked for (no network).
  • In-game behaviour: not run (no titles are launched here).
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5752872387 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9183#pullrequestreview-5752872387). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-11-03T13:19:41Z. **Review:** APPROVED --- # Reviewed — approved The 3D `image_gather4_lz` lowering merges cleanly, builds, and passes the focused image, gather and disk cache tests on lavapipe. The new test fails with `main`'s recompiler. Two things were not checked here: the measured hardware model (no AMD GPU on this machine) and the bring-up list. The only new validation IDs come from `main`'s sampler creation, not from this change. ## What I ran Head `3cb6fb3ebb3fa6d30b8a373c3a006504f6247445`, `main` `4f41f4c375f5abb487dbd184fbc150f31994d762`, merged tree `8d1e202a94108a3eba9754cfc8d4744b136fc146`. Debian 13 VM (Xeon Gold 6136, AVX2/FMA), GCC 14.2.0, Release, Ninja. Vulkan was lavapipe (Mesa 26.1.6, LLVM 19); there is no GPU. ``` git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...3cb6fb3ebb3fa6d30b8a373c3a006504f6247445 python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762 env VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 VK_LOADER_DEBUG=error,warn,layer ctest --test-dir build -V -R '^agc_driver_image_gather_volume$' # negative control: the 8 production files restored from main ninja -C build -j32 -l32 agc_driver_image_gather_volume_tests ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ctest --test-dir build --output-on-failure -R '^agc_driver_image_gather_volume$' # merged files restored, full rebuild ninja -C build -j32 -l32 ANYPS5_REQUIRE_VULKAN=1 ctest --test-dir build -j8 --test-load 32 --output-on-failure -R 'gather|disk_cache|agc_driver_image_sample|agc_driver_image_table|shader_info|resource_tracker|descriptor_binding' git status --porcelain ``` ## Results | Check | Result | |---|---| | `git diff --check` | clean | | `check_conventions.py` | All conventions checks passed | | Configure / build / `libs` (script) | ok | | Script test run (2163 tests) | no new failures, no timeouts; 7 known failures that also fail on `main` | | Focused run (28 tests: gather, image sample, image table, disk cache) | 27 passed, 1 skipped (`agc_driver_image_sample_lod_clamp`, a device limitation) | | `agc_driver_image_gather_volume` | passes in about 9.4 s on lavapipe with validation (limit is 30 s) | | Validation layer | loaded; 8 new `VUID-` lines, all in the new test, all from `vkCreateSampler` with `MIRROR_CLAMP_TO_EDGE` (see Non-blocking) | | Worktree after the control | `git status --porcelain` empty | <details><summary>New validation IDs in agc_driver_image_gather_volume</summary> ``` Validation Error: [ VUID-VkSamplerCreateInfo-addressModeU-parameter ] vkCreateSampler(): pCreateInfo->addressModeU (VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) requires the extensions VK_KHR_sampler_mirror_clamp_to_edge. Validation Error: [ VUID-VkSamplerCreateInfo-addressModeV-parameter ] ... Validation Error: [ VUID-VkSamplerCreateInfo-addressModeW-parameter ] ... Validation Error: [ VUID-VkSamplerCreateInfo-addressModeU-01079 ] vkCreateSampler(): pCreateInfo->addressModeU is VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE but the VK_KHR_sampler_mirror_clamp_to_edge extension or samplerMirrorClampToEdge feature was not enabled. ``` </details> ## Negative control I restored the eight production files from `main`: `Resources.hpp`, `ResourceMaterializer.hpp/.cpp`, `DescriptorBindingBuilder.cpp`, `ResourceTracker.cpp`, `PipelineSpecialization.hpp`, `ShaderDiskCache.cpp` and `SpirvImageEmitter.cpp`. I kept the new test and rebuilt it. It fails on the first case: <details><summary>Output</summary> ``` ShaderRecompiler::Recompile: SPIR-V validation before optimization failed: level=2 word=607: [VUID-StandaloneSpirv-OpImage-04777] Expected Image 'Dim' to be 2D, Cube, or Rect %531 = OpImageGather %v4float %529 %518 %uint_0 ``` </details> This matches the description's lavapipe result on `main` (pipeline refused). I then restored the merged files, rebuilt everything, and the test passed again. ## Findings ### Blocking None. ### Non-blocking - **The new test hits `main`'s missing `samplerMirrorClampToEdge` enablement** (`core/libs/prx/libSceAgcDriver/Graphics/src/GuestSamplerResource.cpp:32-44`). - The test's mirror-once samplers (guest clamp modes 3, 5 and 7) go to `VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE` through [`toVkAddressMode`](https://github.com/boykopovar/AnyPS5/blob/4f41f4c375f5abb487dbd184fbc150f31994d762/core/libs/prx/libSceAgcDriver/Graphics/src/GuestSamplerResource.cpp#L32-L44). - Nothing under `core/` enables `samplerMirrorClampToEdge` or `VK_KHR_sampler_mirror_clamp_to_edge`. - The PR does not touch this code, and the gather itself never reads the sampler (it fetches). The 8 VUIDs therefore come from `main` and are listed as new only because the test does not exist there. - They still mean undefined behaviour in `vkCreateSampler` for every guest sampler with those modes. Fixing it is a separate change: enable the feature, or throw when it is unavailable. It is worth a debt entry or a follow-up issue. - **Unverified hardware claims are mentioned only in the debt entry.** The debt entry in `docs/dev/debt/shader.md` correctly says the model comes from gfx1036, not the PS5's gfx1013. The 4.0 clamp bound and the half-border pinning are the parts most likely to differ between RDNA2 parts. A later run on a second RDNA2 GPU would firm them up. Not required for this PR. Earlier review points, checked on this head: - The `RunThrows` checks are gone. - `3rdparty/freetype` is no longer in the diff. - The NVIDIA wrap failure from the RTX 2000 Ada run is addressed: the index reduction in `SpirvImageEmitter.cpp:925-928` adds one period and uses `OpUMod` with a nonzero divisor (the extent is `UMax(size, 1)`). The test rejects any `OpSRem` or `OpSMod` in the gather shader. I also checked by hand: - The exact snap in `EmitVolumeGatherLz` (`SpirvImageEmitter.cpp:839`): the rounding bias for negative values, the 64-bit shift split at shift 32, and denormals. - That the 11-bit gather state fits `RuntimeAbi::CompareStateMask` (13 bits) for registration modules. - That the disk cache picks up the changed encoding through the generated source version. ## Not verified - **Hardware model:** I could not check the measured model (the 1/256 snap, half-border pinning, slice choice, border colors) against hardware: there is no AMD GPU here, and the evidence branch is outside the repository, so I did not rerun `checkall.py`. Everything here is lavapipe only. - **Other vendors:** NVIDIA, RADV and MoltenVK results come from the author and other commenters, not from me. - **Bring-up list:** I could not check whether the PPSA02015 bring-up discussion (#5424) now lists this PR, which an earlier review asked for (no network). - **In-game behaviour:** not run (no titles are launched here). <!-- anyps5-bots job=3347 head=3cb6fb3ebb3fa6d30b8a373c3a006504f6247445 -->
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!9183
No description provided.