fix(shader): keep the half bits of a 16-bit float image store's D16 data #12191

Merged
JJenkx merged 1 commit from upstream-pr/12191 into main 2026-10-29 03:25:21 +00:00
JJenkx commented 2026-10-28 02:50:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-28T02:50:56Z.


What

#8998 stores write-only 16_FLOAT, 16_16_FLOAT and 16_16_16_16_FLOAT storage images through a UINT view: the materializer gives the image the Uint numeric class, and StoreTexel converts each component with EmitFormatStoreComponent, which reads its input as f32 bits. Because the image is now Uint, StoreTexel is called with integer = true, so for an image_store with D16 data the value it converts is the raw half (for example 0x3c00 for 1.0). Read as f32 bits that is a denormal, and the store writes 0.

This skips the f32-to-half conversion when the store's data is 16-bit (mem.dataBits == 16): the half bits are stored as they are. 32-bit data keeps #8998's round-toward-zero conversion.

ImageStoreFloatRounding gains the same cases with D16 set on both stores (full and dmask 0x5 writes, for the three formats), with packed halves as input.

Why

Echoes of the End (PPSA25636) presents pure black frames once it leaves its in-world loading screen, while it still records a full scene each frame. A bisect over the first-parent merges of main (each point with the same title prerequisites, save, scripted input and seeded caches; one 1700 s run each, screenshots at 1440-1695 s) ends at #8998:

  • b241428c634 (#10984, the merge before #8998): the in-play scene renders at 1560, 1640 and 1695 s (largest luma 254)
  • 76dec1794ba (#8998): every screenshot from 1560 s on is black (largest luma 0)
  • an integration tree on 801d5b9bc11 that was black from 1440 s renders the in-play scene at 1300-1695 s with this change cherry-picked

I did not identify the individual Echoes shader; a D16 store into one of these formats writing 0 matches a frame that is drawn but presents black, and the change restores it.

Tested

  • Linux 7.2.9, AMD Radeon RX 6650 XT, RADV Mesa 26.2.4.
  • Focused Vulkan gate, ctest -V -j1 -R '^agc_driver_image_store_float_rounding$' with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (layer inserted in each arm, no "was not found" line):
    • main cccdaa2734a: passed
    • main with only the new D16 cases: failed, "D16 image_store of 16_FLOAT: texel (1, 0) component 0 is 0, expected 15360"
    • this change c3c947e9c1e: passed
    • 0 VUIDs in any arm. Logs: main, D16 cases only, change.
  • Echoes of the End (PPSA25636), see Why. The title runs needed open PRs to boot here (#4449, #8089, #8091, #6867); they are not part of this change. This makes no performance claim.

Independent Windows/NVIDIA validation

maskym reports this exact head c3c947e9c1 merged onto main 16e1b95117 on Windows11 26300, i7-12700K, RTX2070SUPER/NVIDIA621.01, WinLibs GCC15.2.0. The focused agc_driver_image_store_float_rounding test passed. The broader AGC/VideoOut selection reported main1150/1151 and candidate1151/1152: both had the same mesh-barycentric test failure and the same pre-existing blend-state VUID (18 occurrences), with1012 actual KHR layer insertions in each log and no missing layer. This was a joint tree also carrying #12322, #12318, #12306, #12302 and #12200; it is third-party evidence, not an isolated run performed by this author or an all-green suite claim. No PS5 run or performance gain is claimed.

Checklist

  • Based on current main; no other open PR implements the same functions. #11580 also edits SpirvImageEmitter.cpp (D16 for converted packed images, a different path); it merges with this branch without conflict.
  • 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: none claimed
  • GPUs tested: AMD Radeon RX 6650 XT, RADV Mesa 26.2.4, Linux 7.2.9
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5044386243 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12191). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-28T02:50:56Z. --- ### What #8998 stores write-only `16_FLOAT`, `16_16_FLOAT` and `16_16_16_16_FLOAT` storage images through a UINT view: the materializer gives the image the Uint numeric class, and `StoreTexel` converts each component with `EmitFormatStoreComponent`, which reads its input as f32 bits. Because the image is now Uint, `StoreTexel` is called with `integer = true`, so for an `image_store` with D16 data the value it converts is the raw half (for example `0x3c00` for 1.0). Read as f32 bits that is a denormal, and the store writes 0. This skips the f32-to-half conversion when the store's data is 16-bit (`mem.dataBits == 16`): the half bits are stored as they are. 32-bit data keeps #8998's round-toward-zero conversion. `ImageStoreFloatRounding` gains the same cases with D16 set on both stores (full and `dmask 0x5` writes, for the three formats), with packed halves as input. ### Why Echoes of the End (PPSA25636) presents pure black frames once it leaves its in-world loading screen, while it still records a full scene each frame. A bisect over the first-parent merges of `main` (each point with the same title prerequisites, save, scripted input and seeded caches; one 1700 s run each, screenshots at 1440-1695 s) ends at #8998: - `b241428c634` (#10984, the merge before #8998): the in-play scene renders at 1560, 1640 and 1695 s (largest luma 254) - `76dec1794ba` (#8998): every screenshot from 1560 s on is black (largest luma 0) - an integration tree on `801d5b9bc11` that was black from 1440 s renders the in-play scene at 1300-1695 s with this change cherry-picked I did not identify the individual Echoes shader; a D16 store into one of these formats writing 0 matches a frame that is drawn but presents black, and the change restores it. ### Tested - Linux 7.2.9, AMD Radeon RX 6650 XT, RADV Mesa 26.2.4. - Focused Vulkan gate, `ctest -V -j1 -R '^agc_driver_image_store_float_rounding$'` with `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` (layer inserted in each arm, no "was not found" line): - `main` `cccdaa2734a`: passed - `main` with only the new D16 cases: failed, "D16 image_store of 16_FLOAT: texel (1, 0) component 0 is 0, expected 15360" - this change `c3c947e9c1e`: passed - 0 VUIDs in any arm. Logs: [main](https://github.com/JJenkx/AnyPS5/releases/download/d16-float16-store-evidence/vvlf16-main.log), [D16 cases only](https://github.com/JJenkx/AnyPS5/releases/download/d16-float16-store-evidence/vvlf16-testonly.log), [change](https://github.com/JJenkx/AnyPS5/releases/download/d16-float16-store-evidence/vvlf16-change.log). - Echoes of the End (PPSA25636), see Why. The title runs needed open PRs to boot here (#4449, #8089, #8091, #6867); they are not part of this change. This makes no performance claim. ### Independent Windows/NVIDIA validation [maskym reports](https://github.com/boykopovar/AnyPS5/pull/12191#issuecomment-6466020622) this exact head `c3c947e9c1` merged onto main `16e1b95117` on Windows11 26300, i7-12700K, RTX2070SUPER/NVIDIA621.01, WinLibs GCC15.2.0. The focused `agc_driver_image_store_float_rounding` test passed. The broader AGC/VideoOut selection reported main1150/1151 and candidate1151/1152: both had the same mesh-barycentric test failure and the same pre-existing blend-state VUID (18 occurrences), with1012 actual KHR layer insertions in each log and no missing layer. This was a joint tree also carrying #12322, #12318, #12306, #12302 and #12200; it is third-party evidence, not an isolated run performed by this author or an all-green suite claim. No PS5 run or performance gain is claimed. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions. #11580 also edits `SpirvImageEmitter.cpp` (D16 for converted packed images, a different path); it merges with this branch without conflict. - [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: none claimed - [x] GPUs tested: AMD Radeon RX 6650 XT, RADV Mesa 26.2.4, Linux 7.2.9 - [x] AI-assisted: yes
MarcZX10 commented 2026-10-28 03:12:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T03:12:27Z.

Review: APPROVED


I reviewed the exact head c3c947e9c1e721fb0b58b1905b961cfea7621dc7 and inspected the three attached focused-test logs. On the same RX 6650 XT/RADV setup, main passes, the test-only arm fails specifically with D16 16_FLOAT storing 0 instead of 15360, and this change passes; all three report zero VUIDs, and the validation-layer-missing diagnostic is absent. This directly exercises the regression and fix. The one-line emitter change preserves raw 16-bit values for D16 while retaining the existing conversion for wider data; the expanded cases cover full and sparse component masks across the three 16-bit float storage formats. I also verified a clean merge preview with current main, passing conventions, and clean git diff --check. Hosted policy checks and Windows build pass; Linux full build is skipped by the workflow path filter. I found no blocking issue in this revision.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5677329391 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12191#pullrequestreview-5677329391). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-28T03:12:27Z. **Review:** APPROVED --- I reviewed the exact head `c3c947e9c1e721fb0b58b1905b961cfea7621dc7` and inspected the three attached focused-test logs. On the same RX 6650 XT/RADV setup, main passes, the test-only arm fails specifically with D16 `16_FLOAT` storing 0 instead of 15360, and this change passes; all three report zero VUIDs, and the validation-layer-missing diagnostic is absent. This directly exercises the regression and fix. The one-line emitter change preserves raw 16-bit values for D16 while retaining the existing conversion for wider data; the expanded cases cover full and sparse component masks across the three 16-bit float storage formats. I also verified a clean merge preview with current `main`, passing conventions, and clean `git diff --check`. Hosted policy checks and Windows build pass; Linux full build is skipped by the workflow path filter. I found no blocking issue in this revision.
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!12191
No description provided.