Skip to content

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

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
JJenkx:fix/agc-d16-float16-image-store
Oct 29, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
JJenkx:fix/agc-d16-float16-image-store

Conversation

@JJenkx

@JJenkx JJenkx commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

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:

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

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. fix(shader): load and store 16-bit data of converted packed images #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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 907 core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 5021 core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 5371 core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 6280 core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 6488 core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 7642 core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 9508 core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 9889 core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 10193 core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 10652 core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@maskym

maskym commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Windows + NVIDIA result for head c3c947e9c1, merged into main 16e1b95117 (the PR's GPUs tested line names no NVIDIA run on Windows).

This PR's own tests: agc_driver_image_store_float_rounding (0.48 s), all passed.

Host: Windows 11 26300, Intel i7-12700K, NVIDIA GeForce RTX 2070 SUPER (vendor 0x10de, device 0x1e84; Vulkan loader 1.4.357 from the NVIDIA driver 621.01), Khronos Validation Layers nightly 1.4.366 through VK_ADD_LAYER_PATH, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh, r6), Release, BUILD_TESTING=ON, Ninja. Build clean.

Same focused run on main 16e1b95117 and on this tree, same machine and GPU: 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 -R '^(agc|guest_video_out|video_out)' --parallel 4 -V: main 1150/1151, this tree 1151/1152, the one failure in both being agc_driver_mesh_barycentric_emulation (#12121, fixed by the open #12062). The loader inserted VK_LAYER_KHRONOS_validation in every test (1012 insertions in each log), neither log contains was not found but was requested by env var VK_INSTANCE_LAYERS, and both report exactly one VUID, VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 18 times (pre-existing on main, #11990 / #6782): this PR adds no new VUID- error.

The tree also carried the open PRs #12322, #12318, #12306, #12302, #12200, all merged cleanly, so the run is a joint one. Not run on a PS5.

AI-assisted: yes (Claude Code), the runs and the numbers above are from this machine.

@dantdmdarealguy

Copy link
Copy Markdown
Contributor

This also unblocks ASTRO BOT (PPSA21564). Windows 11, RTX 5080 (driver 32.0.16.1742), WinLibs GCC 15.2.0, Release.

  • On main 7fea877: in the crash-site tutorial, which every New Game passes through, every screen tile holding only sky renders black. The black area ends in a staircase of tiles along the dune horizon and cuts into Astro's helmet. Nothing throws and nothing is logged. It shows during the fade-in and in gameplay after the first Shake. It reproduced in every run that reached the scene, including with APS5_NO_DIRECT_DEPTH_COPY=1 APS5_NO_SHAPE_MEMO=1 APS5_NO_EXACT_ROBUST_LOADS=1 APS5_EXACT_DRAW_WRITES=0 APS5_NO_RECENT_IMPORTS=1.
  • Bisect: first-parent, libraries only, with the same relinked executable throughout. Between c7b4878fa8 (good) and 7fea87746b (bad) it ends at fix(agc): round 16-bit float image stores toward zero #8998 (76dec1794b, fix(agc): round 16-bit float image stores toward zero): b241428c63 is good, 6af5e2de7f and f1adec7eb1 are bad. That matches your description of the D16 path: the raw half is reinterpreted as f32 bits and stored as a denormal 0.
  • main + this PR (cherry-pick of c3c947e9c1): the sky renders, with the sandstorm haze, in 3 of 3 screenshots of the same scene. The galaxy map loads afterwards at 82-92 presents per 10 s, and the first level (underwater_aerial_garden) runs 4 minutes with no throw or crash.

So the Unblocks line could also name ASTRO BOT PPSA21564 (crash-site tutorial sky).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants