fix(shader): load and store 16-bit data of converted packed images #11580

Merged
QRMOE merged 2 commits from upstream-pr/11580 into main 2026-11-02 10:29:11 +00:00
QRMOE commented 2026-10-26 21:15:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by QRMOE on 2026-10-26T21:15:52Z.


What

Since #8898, 11_11_10_FLOAT storage images take the in-shader conversion path that 10_11_11_FLOAT and 11_11_10_UNORM already used (an R32_UINT view, packed and unpacked in the shader). That path refused every image access with 16-bit data (D16): ResourceMaterializer rejected the descriptor and the SPIR-V emitter failed with reads or writes a converted float image with 16-bit data, which is not implemented. Before #8898 these images were native B10G11R11_UFLOAT storage images, so D16 stores to them worked. RESIDENT EVIL requiem (PPSA31246) stops about 135 s into boot on this error (compute shader 0x210689b100).

This implements D16 for converted unorm and float images, for every input:

  • Store: the converted packer already widened halves to f32 before encoding; the blanket refusal in RequireConvertedUnormAccess is removed, so each half goes through the same encoder as a 32-bit store of its exact f32 value.
  • Load: the decoded components are f32 bits in a uvec4. A D16 load now packs them as halves (f32 to f16, round to nearest even, EmitPackHalf2x16) instead of truncating each word to its low 16 bits (LoadedTexelResult). This also fixes D16 loads of the other converted formats with float results.
  • ResourceMaterializer no longer drops the converted modes of an image that has a D16 access, and refuses D16 only for converted unorm samples, which stay unimplemented (samples a converted unorm image with 16-bit data).

image_load is always a sampled-class resource, and sampled 10_11_11/11_11_10 FLOAT images are read through their native B10G11R11_UFLOAT view (nativeRepacked). D16 float loads therefore already worked and do not take this path; the test still checks them on both layouts, including a load and store of the same image. The converted D16 load path runs for 11_11_10_UNORM.

The f16 rounding of these accesses is not measured on hardware. That is recorded in docs/dev/debt/shader.md: stores are exact, and UNORM loads are rounded twice (to f32, then to f16).

agc_driver_image_converted_unorm (ImageConvertedUnorm.cpp) now:

  • runs D16 image_store with DMASK 0x7 and 0x5 on both float layouts (10_11_11 and 11_11_10). The halves include ±0, ±1, ±Inf, NaNs with high and low payloads, f16 denormals, the largest half, values past the format's largest finite value, and round-to-even ties in 5- and 6-bit mantissas. Each texel must match a 32-bit store of the widened values, and texels made of exact values must also match their known encoding;
  • runs D16 image_load on both float layouts, alone and followed by a D16 store to the same image, over 1024 texels (every exponent/mantissa edge, then hashed bit patterns). It checks every half exactly (any NaN for a NaN field), that only two result dwords are written, and that the store writes every non-NaN field back unchanged;
  • runs D16 image_load of 11_11_10_UNORM over 2048 texels with swizzles X Y Z 1 and Z Y X 1 (within one f16 ULP), and D16 image_store with DMASK 0x7 and 0x5. These replace the two assertions that D16 is refused.

Tested

Windows 11, MinGW GCC (x86_64-w64-mingw32), Release build. I checked that the test catches the bugs, each tried separately and then reverted:

  • main fails with reads or writes a converted float image with 16-bit data, which is not implemented, the RE Requiem error;
  • the fix without the f16 packing of loads fails on image_load d16 X Y Z 1;
  • the fix without the half widening of stores fails on image_store d16 dmask:0x7 of R10_G11_B11_FLOAT.

Validation-layer comparison on main (18ef6be0cd) and this branch, same machine and GPU. Both runs used 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_(converted_unorm|packed16)" -V:

main this PR
agc_driver_image_packed16_storage_133/134/136 Passed Passed
agc_driver_image_packed16_load Passed Passed
agc_driver_image_converted_unorm Failed (refusal above) Passed
VUID- / other validation messages 0 / 0 0 / 0
was not found but was requested by env var VK_INSTANCE_LAYERS absent absent
validation layer inserted (loader log) 5 of 5 tests 5 of 5 tests

Broader run on this branch: 204 of 206 tests matching image, storage, D16, format, shader, SPIR-V, recompiler and resource tests pass (ctest -R "agc_driver_(image|storage|d16|format|tbuffer|flat_d16|depth_storage|depth_surface|fmask|bindless|runtime_images|cached_image)|shader|spirv|recompiler|resource|materializ" -j2). The other two, agc_driver_image_plane_address_on_line_implicit_lod and agc_driver_image_plane_bias_on_single_level_volume, were not built: their dependency-file paths exceed the Windows path limit in this checkout. Neither uses D16 or a converted format.

Not run against RESIDENT EVIL requiem from this branch. Reverting #8898 locally lets the title boot past this point.

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: PPSA31246 #11599 (RESIDENT EVIL requiem), the boot stop at compute shader 0x210689b100 introduced by #8898
  • GPUs tested: AMD Radeon RX 9070 XT, AMD proprietary driver 26.6.2 (LLPC), Vulkan 1.4.349, Windows 11 Home 10.0.26200
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5024766453 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11580). Originally posted by [QRMOE](https://github.com/QRMOE) on 2026-10-26T21:15:52Z. --- ### What Since #8898, `11_11_10_FLOAT` storage images take the in-shader conversion path that `10_11_11_FLOAT` and `11_11_10_UNORM` already used (an R32_UINT view, packed and unpacked in the shader). That path refused every image access with 16-bit data (D16): `ResourceMaterializer` rejected the descriptor and the SPIR-V emitter failed with `reads or writes a converted float image with 16-bit data, which is not implemented`. Before #8898 these images were native `B10G11R11_UFLOAT` storage images, so D16 stores to them worked. RESIDENT EVIL requiem (PPSA31246) stops about 135 s into boot on this error (`compute shader 0x210689b100`). This implements D16 for converted unorm and float images, for every input: - **Store:** the converted packer already widened halves to f32 before encoding; the blanket refusal in `RequireConvertedUnormAccess` is removed, so each half goes through the same encoder as a 32-bit store of its exact f32 value. - **Load:** the decoded components are f32 bits in a `uvec4`. A D16 load now packs them as halves (f32 to f16, round to nearest even, `EmitPackHalf2x16`) instead of truncating each word to its low 16 bits (`LoadedTexelResult`). This also fixes D16 loads of the other converted formats with float results. - `ResourceMaterializer` no longer drops the converted modes of an image that has a D16 access, and refuses D16 only for converted unorm *samples*, which stay unimplemented (`samples a converted unorm image with 16-bit data`). `image_load` is always a sampled-class resource, and sampled `10_11_11`/`11_11_10` FLOAT images are read through their native `B10G11R11_UFLOAT` view (`nativeRepacked`). D16 float loads therefore already worked and do not take this path; the test still checks them on both layouts, including a load and store of the same image. The converted D16 load path runs for `11_11_10_UNORM`. The f16 rounding of these accesses is not measured on hardware. That is recorded in `docs/dev/debt/shader.md`: stores are exact, and UNORM loads are rounded twice (to f32, then to f16). `agc_driver_image_converted_unorm` (`ImageConvertedUnorm.cpp`) now: - runs D16 `image_store` with DMASK 0x7 and 0x5 on both float layouts (10_11_11 and 11_11_10). The halves include ±0, ±1, ±Inf, NaNs with high and low payloads, f16 denormals, the largest half, values past the format's largest finite value, and round-to-even ties in 5- and 6-bit mantissas. Each texel must match a 32-bit store of the widened values, and texels made of exact values must also match their known encoding; - runs D16 `image_load` on both float layouts, alone and followed by a D16 store to the same image, over 1024 texels (every exponent/mantissa edge, then hashed bit patterns). It checks every half exactly (any NaN for a NaN field), that only two result dwords are written, and that the store writes every non-NaN field back unchanged; - runs D16 `image_load` of `11_11_10_UNORM` over 2048 texels with swizzles X Y Z 1 and Z Y X 1 (within one f16 ULP), and D16 `image_store` with DMASK 0x7 and 0x5. These replace the two assertions that D16 is refused. ### Tested Windows 11, MinGW GCC (`x86_64-w64-mingw32`), Release build. I checked that the test catches the bugs, each tried separately and then reverted: - `main` fails with `reads or writes a converted float image with 16-bit data, which is not implemented`, the RE Requiem error; - the fix without the f16 packing of loads fails on `image_load d16 X Y Z 1`; - the fix without the half widening of stores fails on `image_store d16 dmask:0x7 of R10_G11_B11_FLOAT`. Validation-layer comparison on `main` (`18ef6be0cd`) and this branch, same machine and GPU. Both runs used `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_(converted_unorm|packed16)" -V`: | | `main` | this PR | |---|---|---| | `agc_driver_image_packed16_storage_133/134/136` | Passed | Passed | | `agc_driver_image_packed16_load` | Passed | Passed | | `agc_driver_image_converted_unorm` | **Failed** (refusal above) | Passed | | `VUID-` / other validation messages | 0 / 0 | 0 / 0 | | `was not found but was requested by env var VK_INSTANCE_LAYERS` | absent | absent | | validation layer inserted (loader log) | 5 of 5 tests | 5 of 5 tests | Broader run on this branch: 204 of 206 tests matching image, storage, D16, format, shader, SPIR-V, recompiler and resource tests pass (`ctest -R "agc_driver_(image|storage|d16|format|tbuffer|flat_d16|depth_storage|depth_surface|fmask|bindless|runtime_images|cached_image)|shader|spirv|recompiler|resource|materializ" -j2`). The other two, `agc_driver_image_plane_address_on_line_implicit_lod` and `agc_driver_image_plane_bias_on_single_level_volume`, were not built: their dependency-file paths exceed the Windows path limit in this checkout. Neither uses D16 or a converted format. Not run against RESIDENT EVIL requiem from this branch. Reverting #8898 locally lets the title boot past this point. ### 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: PPSA31246 #11599 (RESIDENT EVIL requiem), the boot stop at `compute shader 0x210689b100` introduced by #8898 - [x] GPUs tested: AMD Radeon RX 9070 XT, AMD proprietary driver 26.6.2 (LLPC), Vulkan 1.4.349, Windows 11 Home 10.0.26200 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-26 22:15:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T22:15:56Z.

Review: CHANGES_REQUESTED


The focused GPU evidence is unusually complete: it compares the same five tests on main and this change on the same RX 9070 XT/driver with the validation layer, reports no VUIDs, and records the layer-insertion checks. I also inspected the overlap warnings; the edits I checked in the neighboring resource/image paths are in separate blocks, though the stale conflicted PR comparisons need to remain manually tracked as these branches are integrated.\n\nThere is one repository checklist blocker: CONTRIBUTING.md requires a title-fixing PR to name the title ID and its Game bring-up discussion on the Unblocks line. The current line explicitly says no discussion exists, and a repository search for PPSA31246 finds none. Please create or locate the title’s Game bring-up discussion, add the PPSA31246 #<discussion> reference, and list this open PR/local changes there. I’ll recheck the updated checklist and discussion before approval.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5659843203 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11580#pullrequestreview-5659843203). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-26T22:15:56Z. **Review:** CHANGES_REQUESTED --- The focused GPU evidence is unusually complete: it compares the same five tests on `main` and this change on the same RX 9070 XT/driver with the validation layer, reports no VUIDs, and records the layer-insertion checks. I also inspected the overlap warnings; the edits I checked in the neighboring resource/image paths are in separate blocks, though the stale conflicted PR comparisons need to remain manually tracked as these branches are integrated.\n\nThere is one repository checklist blocker: `CONTRIBUTING.md` requires a title-fixing PR to name the title ID and its Game bring-up discussion on the `Unblocks` line. The current line explicitly says no discussion exists, and a repository search for `PPSA31246` finds none. Please create or locate the title’s Game bring-up discussion, add the `PPSA31246 #<discussion>` reference, and list this open PR/local changes there. I’ll recheck the updated checklist and discussion before approval.
MarcZX10 commented 2026-10-27 00:16:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-27T00:16:23Z.

Review: APPROVED


Re-reviewed exact head dbf2107ba6276e2394bc7fddbfcf0d9a665ef68d after the requested Game bring-up entry was added. The fix has a focused before/after negative control: baseline refuses converted D16 access, dropping the new half packing breaks loads, and dropping store widening breaks float stores. The test covers both float layouts and converted UNORM loads/stores, with format boundaries, masks, swizzles, same-image load/store, and write-width checks. The reported Windows RX 9070 XT validation-layer comparison has no new VUIDs and confirms layer insertion; independent Linux RTX 4080 SUPER and Windows RTX 3070 reports also show the former title stop no longer reproduces. #11599 now lists #11580 and the title’s blocker order. The acknowledged hardware rounding limitation for D16 UNORM loads is recorded in debt; no exact console rounding claim is made. Hosted policy checks pass; product/relinker checks are skipped by path policy. I found no remaining blocker in this focused review.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5660783454 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11580#pullrequestreview-5660783454). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-27T00:16:23Z. **Review:** APPROVED --- Re-reviewed exact head `dbf2107ba6276e2394bc7fddbfcf0d9a665ef68d` after the requested Game bring-up entry was added. The fix has a focused before/after negative control: baseline refuses converted D16 access, dropping the new half packing breaks loads, and dropping store widening breaks float stores. The test covers both float layouts and converted UNORM loads/stores, with format boundaries, masks, swizzles, same-image load/store, and write-width checks. The reported Windows RX 9070 XT validation-layer comparison has no new VUIDs and confirms layer insertion; independent Linux RTX 4080 SUPER and Windows RTX 3070 reports also show the former title stop no longer reproduces. #11599 now lists #11580 and the title’s blocker order. The acknowledged hardware rounding limitation for D16 UNORM loads is recorded in debt; no exact console rounding claim is made. Hosted policy checks pass; product/relinker checks are skipped by path policy. I found no remaining blocker in this focused review.
MarcZX10 commented 2026-10-29 06:20:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T06:20:27Z.

Review: APPROVED


Re-checked — approved

The only commit after my previous approval removes three tests that asserted unrelated converted-image border/gather/LOD paths must refuse. The D16 load/store implementation and its positive coverage are unchanged, and the removed assertions no longer pin behavior that has since changed elsewhere in the shader path. The PR continues to list its Game bring-up reference in #11599.

Hosted Windows, relinker, conventions, eligibility, labels, and report checks pass; Linux product tests are skipped. The author’s matched validation-layer comparison and negative controls are documented in the PR, but I did not rerun GPU tests for this test-only cleanup.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5693651060 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11580#pullrequestreview-5693651060). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-29T06:20:27Z. **Review:** APPROVED --- ## Re-checked — approved The only commit after my previous approval removes three tests that asserted unrelated converted-image border/gather/LOD paths must refuse. The D16 load/store implementation and its positive coverage are unchanged, and the removed assertions no longer pin behavior that has since changed elsewhere in the shader path. The PR continues to list its Game bring-up reference in #11599. Hosted Windows, relinker, conventions, eligibility, labels, and report checks pass; Linux product tests are skipped. The author’s matched validation-layer comparison and negative controls are documented in the PR, but I did not rerun GPU tests for this test-only cleanup.
XairRrR commented 2026-10-29 06:34:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-29T06:34:15Z.

Review: APPROVED


Reviewed — approved

The D16 load/store change merges cleanly onto current main, builds, passes the focused AGC tests with the validation layer on Linux NVIDIA (0 VUID- on both main and the merge), and its test fails without the production change.

What I ran

  • PR head: fedf3e91a70676e839b89d2abdf97fca4deda6be
  • main: 2960e9a6e7e1fc99c4ed180c71495b5eb83464c7
  • Machine: Arch Linux 7.2.11-zen, GCC 16.2.1 (Release, Ninja), Intel Core i9-14900KF, NVIDIA GeForce RTX 4070 Ti SUPER (driver 615.78.08).

All build and test commands ran in a clean worktree, inside a sandbox with no network.

git fetch origin main pull/11580/head:refs/review/11580
git checkout --detach origin/main
git merge --no-ff --no-edit refs/review/11580
git diff --check origin/main...refs/review/11580
python3 tools/check_conventions.py --base origin/main

T="agc_driver_image_converted_unorm_tests agc_driver_image_repacked_float_tests agc_driver_image_store_float_rounding_tests \
   agc_driver_image_store_packed_tests agc_driver_image_packed16_load_tests agc_driver_image_load_packed_tests \
   agc_driver_packed_float_color_target_tests agc_spirv_module_tests agc_driver_format_d16_tests \
   agc_driver_format_d16_store_tests agc_driver_image_table_tests agc_shader_memory_tests agc_driver_d16_memory_tests \
   agc_driver_guest_memory_lifetime_tests"
nice -n 10 cmake --build build -j10 --target $T libs

R='^agc_driver_(image_converted_unorm|image_packed16_storage_13[346]|image_packed16_load|image_repacked_float|image_store_float_rounding|image_store_packed|packed_float_color_target|image_load_packed|format_d16|format_d16_store|d16_memory|image_table|guest_memory_lifetime_converted)$|^agc_spirv_module$|^agc_shader_type_zero_image_materialization$'
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 VK_LOADER_DEBUG=error,warn,layer \
  nice -n 10 ctest --test-dir build -R "$R" -V -j4 --output-on-failure

# the same build and ctest run on origin/main in the same worktree

# negative control: main production code + this PR's test file
git checkout <merge> -- core/libs/prx/libSceAgcDriver/tests/execution/ImageConvertedUnorm.cpp
cmake --build build -j10 --target agc_driver_image_converted_unorm_tests
ctest --test-dir build -R '^agc_driver_image_converted_unorm$' --output-on-failure

# partial control: merged tree, with LoadedTexelResult's D16 branch replaced by the old ResultVector(unpacked, numericClass) call
ctest --test-dir build -R '^agc_driver_image_converted_unorm$' --output-on-failure

Results

Check Result
Merge onto main Clean (auto-merged ResourceMaterializer.cpp, SpirvImageEmitter.cpp, docs/dev/debt/shader.md)
git diff --check Clean
tools/check_conventions.py --base origin/main All conventions checks passed.
Build (14 test targets + libs), merged tree and main OK
Focused tests, merged tree 17/17 passed
Focused tests, main 17/17 passed (main's agc_driver_image_converted_unorm still asserts the D16 refusal)
VUID- lines 0 on main, 0 on the merge
was not found but was requested by env var VK_INSTANCE_LAYERS absent on both
Validation layer inserted (loader log) 14 of 14 Vulkan tests on both runs; agc_spirv_module, agc_shader_type_zero_image_materialization and agc_driver_guest_memory_lifetime_converted don't log a layer insertion
agc_driver_image_converted_unorm run time 1.01 s (merge), well under the 30 s limit
Negative control Fails on main code (see below)
Merged tree, focused tests
 1/17 Test  #891: agc_driver_image_packed16_storage_134 ........   Passed    0.99 sec
 2/17 Test  #890: agc_driver_image_packed16_storage_133 ........   Passed    1.00 sec
 3/17 Test  #910: agc_shader_type_zero_image_materialization ...   Passed    0.00 sec
 4/17 Test  #928: agc_spirv_module .............................   Passed    0.00 sec
 5/17 Test #1289: agc_driver_packed_float_color_target .........   Passed    1.03 sec
 6/17 Test #1116: agc_driver_format_d16 ........................   Passed    0.55 sec
 7/17 Test  #892: agc_driver_image_packed16_storage_136 ........   Passed    0.62 sec
 8/17 Test  #993: agc_driver_d16_memory ........................   Passed    0.61 sec
 9/17 Test #1117: agc_driver_format_d16_store ..................   Passed    0.64 sec
10/17 Test #1160: agc_driver_image_load_packed .................   Passed    0.81 sec
11/17 Test #1157: agc_driver_image_converted_unorm .............   Passed    1.01 sec
12/17 Test #1164: agc_driver_image_packed16_load ...............   Passed    0.45 sec
13/17 Test #1173: agc_driver_image_repacked_float ..............   Passed    0.58 sec
14/17 Test #1192: agc_driver_image_store_float_rounding ........   Passed    0.57 sec
15/17 Test #1199: agc_driver_image_table .......................   Passed    3.25 sec
16/17 Test #1195: agc_driver_image_store_packed ................   Passed    0.65 sec
17/17 Test #1625: agc_driver_guest_memory_lifetime_converted ...   Passed    0.48 sec
1157: image converted unorm tests passed
main, focused tests
 3/17 Test #1157: agc_driver_image_converted_unorm .............   Passed    1.17 sec
...
17/17 Test #1164: agc_driver_image_packed16_load ...............   Passed    0.46 sec
VUID- lines: 0; "was not found but was requested": 0; validation layer inserted: 14

Negative control

  • main production code with this PR's ImageConvertedUnorm.cpp: agc_driver_image_converted_unorm fails with
    ShaderRecompiler::Recompile: reads or writes a converted float image with 16-bit data, which is not implemented, the error from the description.
  • Merged tree without the f16 packing of loads: in LoadedTexelResult, I replaced the final ResultVector(..., OpBitcast to vec4 f32, IrTextureNumericClass::Float, ...) with the old ResultVector(ctx, access, unpacked, numericClass, ...). The test fails with
    image_load d16 X Y Z 1: texel 0 component 1 is 0x00000000, expected 1.000000 within one half ULP.

Both match what the author and DeveshB-1 reported. I didn't repeat the store-widening control.

Findings

Blocking

None.

Non-blocking

Line numbers below are at the PR head.

  1. The emitter no longer refuses D16 on the converted sample path. Only the materializer refuses it now. Removing the 16-bit check from RequireConvertedUnormAccess also removes it from the filtered converted-unorm sample in EmitSampleOp. At the PR head, SpirvImageEmitter.cpp:1694-1695 still passes UnpackImageTexel's f32-bit uvec4 to ResultVector with the image's Uint numeric class. For a D16 access, that takes the integer branch and keeps the low 16 bits of each f32 pattern (1.0 becomes 0x0000), which is the bug LoadedTexelResult fixes for loads. Today the materializer refuses that combination (ResourceMaterializer.cpp:276, and convertedSampleCompatible at ResourceMaterializer.cpp:1403-1404 requires depthBitsCompatible), so I found no input that reaches it. But if a later change lets one through, the result is silently wrong instead of a refusal. A cheap fix is to keep a ctx.Fail(access.inst, "samples a converted unorm image with 16-bit data, which is not implemented") in EmitSampleOp when the conversion format is unorm and mem.dataBits == 16u. Alternatively, send that result through the same f32-to-f16 packing as LoadedTexelResult.

Not verified

  • No hardware f16 rounding measurement. The PR records this in docs/dev/debt/shader.md, and I didn't check it on hardware either.
  • No title runs (by policy). The RE Requiem, Townfall, LEGO Horizon, GTA V and Cyberpunk results in the comments are other people's.
  • I didn't run the store-widening negative control, the runtime image-table D16 mode path (RuntimeImageModes) on the GPU, or the full test suite.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5693759537 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11580#pullrequestreview-5693759537). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-10-29T06:34:15Z. **Review:** APPROVED --- # Reviewed — approved The D16 load/store change merges cleanly onto current `main`, builds, passes the focused AGC tests with the validation layer on Linux NVIDIA (0 `VUID-` on both `main` and the merge), and its test fails without the production change. ## What I ran - PR head: `fedf3e91a70676e839b89d2abdf97fca4deda6be` - `main`: `2960e9a6e7e1fc99c4ed180c71495b5eb83464c7` - Machine: Arch Linux 7.2.11-zen, GCC 16.2.1 (Release, Ninja), Intel Core i9-14900KF, NVIDIA GeForce RTX 4070 Ti SUPER (driver 615.78.08). All build and test commands ran in a clean worktree, inside a sandbox with no network. ```sh git fetch origin main pull/11580/head:refs/review/11580 git checkout --detach origin/main git merge --no-ff --no-edit refs/review/11580 git diff --check origin/main...refs/review/11580 python3 tools/check_conventions.py --base origin/main T="agc_driver_image_converted_unorm_tests agc_driver_image_repacked_float_tests agc_driver_image_store_float_rounding_tests \ agc_driver_image_store_packed_tests agc_driver_image_packed16_load_tests agc_driver_image_load_packed_tests \ agc_driver_packed_float_color_target_tests agc_spirv_module_tests agc_driver_format_d16_tests \ agc_driver_format_d16_store_tests agc_driver_image_table_tests agc_shader_memory_tests agc_driver_d16_memory_tests \ agc_driver_guest_memory_lifetime_tests" nice -n 10 cmake --build build -j10 --target $T libs R='^agc_driver_(image_converted_unorm|image_packed16_storage_13[346]|image_packed16_load|image_repacked_float|image_store_float_rounding|image_store_packed|packed_float_color_target|image_load_packed|format_d16|format_d16_store|d16_memory|image_table|guest_memory_lifetime_converted)$|^agc_spirv_module$|^agc_shader_type_zero_image_materialization$' VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 VK_LOADER_DEBUG=error,warn,layer \ nice -n 10 ctest --test-dir build -R "$R" -V -j4 --output-on-failure # the same build and ctest run on origin/main in the same worktree # negative control: main production code + this PR's test file git checkout <merge> -- core/libs/prx/libSceAgcDriver/tests/execution/ImageConvertedUnorm.cpp cmake --build build -j10 --target agc_driver_image_converted_unorm_tests ctest --test-dir build -R '^agc_driver_image_converted_unorm$' --output-on-failure # partial control: merged tree, with LoadedTexelResult's D16 branch replaced by the old ResultVector(unpacked, numericClass) call ctest --test-dir build -R '^agc_driver_image_converted_unorm$' --output-on-failure ``` ## Results | Check | Result | |---|---| | Merge onto `main` | Clean (auto-merged `ResourceMaterializer.cpp`, `SpirvImageEmitter.cpp`, `docs/dev/debt/shader.md`) | | `git diff --check` | Clean | | `tools/check_conventions.py --base origin/main` | `All conventions checks passed.` | | Build (14 test targets + `libs`), merged tree and `main` | OK | | Focused tests, merged tree | 17/17 passed | | Focused tests, `main` | 17/17 passed (`main`'s `agc_driver_image_converted_unorm` still asserts the D16 refusal) | | `VUID-` lines | 0 on `main`, 0 on the merge | | `was not found but was requested by env var VK_INSTANCE_LAYERS` | absent on both | | Validation layer inserted (loader log) | 14 of 14 Vulkan tests on both runs; `agc_spirv_module`, `agc_shader_type_zero_image_materialization` and `agc_driver_guest_memory_lifetime_converted` don't log a layer insertion | | `agc_driver_image_converted_unorm` run time | 1.01 s (merge), well under the 30 s limit | | Negative control | Fails on `main` code (see below) | <details><summary>Merged tree, focused tests</summary> ```text 1/17 Test #891: agc_driver_image_packed16_storage_134 ........ Passed 0.99 sec 2/17 Test #890: agc_driver_image_packed16_storage_133 ........ Passed 1.00 sec 3/17 Test #910: agc_shader_type_zero_image_materialization ... Passed 0.00 sec 4/17 Test #928: agc_spirv_module ............................. Passed 0.00 sec 5/17 Test #1289: agc_driver_packed_float_color_target ......... Passed 1.03 sec 6/17 Test #1116: agc_driver_format_d16 ........................ Passed 0.55 sec 7/17 Test #892: agc_driver_image_packed16_storage_136 ........ Passed 0.62 sec 8/17 Test #993: agc_driver_d16_memory ........................ Passed 0.61 sec 9/17 Test #1117: agc_driver_format_d16_store .................. Passed 0.64 sec 10/17 Test #1160: agc_driver_image_load_packed ................. Passed 0.81 sec 11/17 Test #1157: agc_driver_image_converted_unorm ............. Passed 1.01 sec 12/17 Test #1164: agc_driver_image_packed16_load ............... Passed 0.45 sec 13/17 Test #1173: agc_driver_image_repacked_float .............. Passed 0.58 sec 14/17 Test #1192: agc_driver_image_store_float_rounding ........ Passed 0.57 sec 15/17 Test #1199: agc_driver_image_table ....................... Passed 3.25 sec 16/17 Test #1195: agc_driver_image_store_packed ................ Passed 0.65 sec 17/17 Test #1625: agc_driver_guest_memory_lifetime_converted ... Passed 0.48 sec 1157: image converted unorm tests passed ``` </details> <details><summary><code>main</code>, focused tests</summary> ```text 3/17 Test #1157: agc_driver_image_converted_unorm ............. Passed 1.17 sec ... 17/17 Test #1164: agc_driver_image_packed16_load ............... Passed 0.46 sec VUID- lines: 0; "was not found but was requested": 0; validation layer inserted: 14 ``` </details> ## Negative control - **`main` production code with this PR's `ImageConvertedUnorm.cpp`:** `agc_driver_image_converted_unorm` fails with `ShaderRecompiler::Recompile: reads or writes a converted float image with 16-bit data, which is not implemented`, the error from the description. - **Merged tree without the f16 packing of loads:** in `LoadedTexelResult`, I replaced the final `ResultVector(..., OpBitcast to vec4 f32, IrTextureNumericClass::Float, ...)` with the old `ResultVector(ctx, access, unpacked, numericClass, ...)`. The test fails with `image_load d16 X Y Z 1: texel 0 component 1 is 0x00000000, expected 1.000000 within one half ULP`. Both match what the author and DeveshB-1 reported. I didn't repeat the store-widening control. ## Findings ### Blocking None. ### Non-blocking Line numbers below are at the PR head. 1. **The emitter no longer refuses D16 on the converted *sample* path. Only the materializer refuses it now.** Removing the 16-bit check from [`RequireConvertedUnormAccess`](https://github.com/boykopovar/AnyPS5/blob/fedf3e91a70676e839b89d2abdf97fca4deda6be/core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp#L553-L560) also removes it from the filtered converted-unorm sample in `EmitSampleOp`. At the PR head, [`SpirvImageEmitter.cpp:1694-1695`](https://github.com/boykopovar/AnyPS5/blob/fedf3e91a70676e839b89d2abdf97fca4deda6be/core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp#L1694-L1695) still passes `UnpackImageTexel`'s f32-bit `uvec4` to `ResultVector` with the image's `Uint` numeric class. For a D16 access, that takes the integer branch and keeps the low 16 bits of each f32 pattern (1.0 becomes `0x0000`), which is the bug `LoadedTexelResult` fixes for loads. Today the materializer refuses that combination ([`ResourceMaterializer.cpp:276`](https://github.com/boykopovar/AnyPS5/blob/fedf3e91a70676e839b89d2abdf97fca4deda6be/core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp#L276), and `convertedSampleCompatible` at [`ResourceMaterializer.cpp:1403-1404`](https://github.com/boykopovar/AnyPS5/blob/fedf3e91a70676e839b89d2abdf97fca4deda6be/core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp#L1403-L1404) requires `depthBitsCompatible`), so I found no input that reaches it. But if a later change lets one through, the result is silently wrong instead of a refusal. A cheap fix is to keep a `ctx.Fail(access.inst, "samples a converted unorm image with 16-bit data, which is not implemented")` in `EmitSampleOp` when the conversion format is unorm and `mem.dataBits == 16u`. Alternatively, send that result through the same f32-to-f16 packing as `LoadedTexelResult`. ## Not verified - No hardware f16 rounding measurement. The PR records this in `docs/dev/debt/shader.md`, and I didn't check it on hardware either. - No title runs (by policy). The RE Requiem, Townfall, LEGO Horizon, GTA V and Cyberpunk results in the comments are other people's. - I didn't run the store-widening negative control, the runtime image-table D16 mode path (`RuntimeImageModes`) on the GPU, or the full test suite.
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!11580
No description provided.