feat(agc): present 16-bit float display buffers #3134

Merged
SleglJan merged 1 commit from upstream-pr/3134 into main 2026-10-11 05:20:13 +00:00
SleglJan commented 2026-10-10 22:51:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-10T22:51:32Z.


What

Presents display buffers in pixel formats 0xC001000622000000 and 0xC001000600000000, R16G16B16A16 and B16G16R16A16 float as KytyPS5 maps them and SharpProspero names them (Rgba16Float, Bgra16Float). PPSA11386 (007 First Light) registers 3840x2160 tiled buffers of the first (tiling 0, no DCC) and stops on VideoOut: unsupported display pixel format 0xc001000622000000.

  • Eight bytes per texel. The tiled layout is assumed to be the 8-byte SW_64KB_R_X equation of TextureSwizzleEquations.hpp applied to full coordinates, as AMD addrlib applies it (PAL addrlib, ComputeSurfaceAddrFromCoordMacroTiled) and TextureDetile.comp does; 128x64 texels per 64 KiB block. ColorTargetLayout applies the equations to in-block coordinates, which differs for 8-byte texels in every odd 64-row block row (address bit 11 takes y bit 6), and for 16-byte texels also in every odd 64-column block column (address bit 10 takes x bit 6); recorded in TechnicalDebt, not changed here.
  • The values are assumed to be linear light and encoded with the sRGB curve for the 8-bit output; NaN and negative values give 0, values of 1 and above 255, alpha is linear. SharpProspero's format list supports only that these formats are not sRGB-encoded (bits 32-39 are 0x06, as in its 10-bit formats without sRGB transfer; its sRGB formats have 0x00, its 10-bit PQ formats 0x04 and its float BT.2100 PQ formats 0x07). Neither the layout nor the transfer is verified against console frames; HDR output is not modelled.
  • The encoding compares the raw half-float bits against two tables of 255 thresholds (color, alpha), the smallest half bit pattern whose value reaches each sRGB code midpoint. The CPU decode (a 64K lookup built from them) and the color transfer shader share the tables, so both paths give the same bytes on any driver, with no float comparison against NaN on the GPU.
  • Guest-memory detile (GpuColorTransfer::Detile), the resident image path (DetileImage of an R16G16B16A16_SFLOAT image, ResidentPresent::Convert, never a blit) and the CPU decode handle both formats. DCC metadata on a float buffer, and writing float texels back to the guest, throw.
  • DisplayBufferOffset is added for the layout tests.

This is 007's next stop on main now that #2946 (SharePlay) is merged: row 4 of #2523.

Overlap: no open pull request changes DisplayBuffer, DisplayFormat, GpuColorTransfer, HalfFloatScanout or the display buffer tests.

Tested

  • Linux (CachyOS, kernel 7.2.9, GCC 16.2.1), Ryzen 9 7950X3D, RTX 3080 (NVIDIA 615.71.09) and RADV (Mesa 26.2.4, the iGPU), Release with BUILD_TESTING=ON and ANYPS5_ENABLE_SPIRV_TOOLS=ON, this branch on main a883f22f:
    • Full ctest on the RTX 3080: of 717 tests, 712 pass. Four video_out_flip_* tests (lifetime, reopen, controls, overlay) skip, because SDL's offscreen video driver has no Vulkan. agc_driver_dcc_keys_first_write fails, which is #2767.
    • linear_display_buffer and agc_driver_bda_device pass 3 repeats on each GPU, forced with VK_DRIVER_FILES.
    • tools/check_conventions.py --base upstream/main, tools/check_test_registration.py and git diff --check pass.
  • What the tests cover:
    • linear_display_buffer (CPU): the decode of hand-computed half values in both channel orders, sizes, and offsets of every texel of a 300x200 buffer against the equation table on full coordinates for 4- and 8-byte texels. Also the rejection of DCC and of an unknown float variant, the format decisions, and all 65,536 half bit patterns against an independent floor(255 * sRGB(v) + 0.5) reference.
    • agc_driver_bda_device (ColorTransferTests, Vulkan): random halves, including NaN, infinities, denormals and negative zero, in both channel orders through guest-memory detile and through DetileImage of an R16G16B16A16_SFLOAT image, against a reference built from the equation table and the shared tables.
  • The float case in ResidentPresent.cpp runs only in the full agc_driver_recorder_tests executable. ctest runs that executable only in its --*-only modes. Run by hand on each GPU, it prints resident present format and conversion tests passed. The executable then fails a later test: on NVIDIA a guest allocation is still pinned after 60 s, on RADV storage-image results are still pending. The same executable built from main a883f22f fails the same way on both.
  • Mutations, one line each, applied to this head. Each fails the test named:
    • linear_display_buffer: dropping the y-bit-6 term of the CPU layout, a 128-row instead of 64-row block height, a linear instead of sRGB threshold table, swapped red and blue, and skipping the DCC check;
    • agc_driver_bda_device: dropping the y-bit-6 term of the shader layout, and removing the shader's NaN/negative guard.
  • PPSA11386 v01.018.000, relinked and run in a bubblewrap sandbox, with SPIRV-Tools off in this build.
    • On main a883f22f it stops after 0.6 s on VideoOut: unsupported display pixel format 0xc001000622000000 (SIGABRT).
    • With this change the title passes that check (its swapchain already exists before it) and ends after 0.7 s with SIGSEGV (exit code 139), which is row 5 of #2523: the PlayGo trap fixed by SleglJan/AnyPS5#19. With that commit added too, it reaches row 6 of #2523 (141 shaders) within a 90 s window.
    • It presents no frame in this window, so the transfer is not checked against its output here. On the #2523 integration stack, which carries the same commit, the title presents 140 to 168 frames before a later, unrelated stall. Their content has not been compared with console output.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

https://claude.ai/code/session_01Fnrk5Dazjb2tLooVSpdRQq

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4815004651 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3134). Originally posted by [SleglJan](https://github.com/SleglJan) on 2026-10-10T22:51:32Z. --- ### What Presents display buffers in pixel formats `0xC001000622000000` and `0xC001000600000000`, R16G16B16A16 and B16G16R16A16 float as [KytyPS5](https://github.com/KytyPS5/KytyPS5/blob/59183dbfa81ed7efdff6069177fed50de0552725/src/graphics/host_gpu/renderer/image/imageInfo.h) maps them and [SharpProspero](https://github.com/SvenGDK/SharpProspero/blob/5dfdb4b0b166e83dc9ae275001afb695f12c7174/src/SharpProspero/Interop/VideoOut/VideoOutTypes.cs) names them (`Rgba16Float`, `Bgra16Float`). PPSA11386 (007 First Light) registers 3840x2160 tiled buffers of the first (tiling 0, no DCC) and stops on `VideoOut: unsupported display pixel format 0xc001000622000000`. - Eight bytes per texel. The tiled layout is assumed to be the 8-byte SW_64KB_R_X equation of `TextureSwizzleEquations.hpp` applied to full coordinates, as AMD addrlib applies it ([PAL addrlib](https://github.com/GPUOpen-Drivers/pal/blob/c5e800072a32/src/core/imported/addrlib/src/gfx10/gfx10addrlib.cpp), `ComputeSurfaceAddrFromCoordMacroTiled`) and `TextureDetile.comp` does; 128x64 texels per 64 KiB block. `ColorTargetLayout` applies the equations to in-block coordinates, which differs for 8-byte texels in every odd 64-row block row (address bit 11 takes y bit 6), and for 16-byte texels also in every odd 64-column block column (address bit 10 takes x bit 6); recorded in TechnicalDebt, not changed here. - The values are assumed to be linear light and encoded with the sRGB curve for the 8-bit output; NaN and negative values give 0, values of 1 and above 255, alpha is linear. SharpProspero's format list supports only that these formats are not sRGB-encoded (bits 32-39 are `0x06`, as in its 10-bit formats without sRGB transfer; its sRGB formats have `0x00`, its 10-bit PQ formats `0x04` and its float BT.2100 PQ formats `0x07`). Neither the layout nor the transfer is verified against console frames; HDR output is not modelled. - The encoding compares the raw half-float bits against two tables of 255 thresholds (color, alpha), the smallest half bit pattern whose value reaches each sRGB code midpoint. The CPU decode (a 64K lookup built from them) and the color transfer shader share the tables, so both paths give the same bytes on any driver, with no float comparison against NaN on the GPU. - Guest-memory detile (`GpuColorTransfer::Detile`), the resident image path (`DetileImage` of an R16G16B16A16_SFLOAT image, `ResidentPresent::Convert`, never a blit) and the CPU decode handle both formats. DCC metadata on a float buffer, and writing float texels back to the guest, throw. - `DisplayBufferOffset` is added for the layout tests. This is 007's next stop on `main` now that #2946 (SharePlay) is merged: row 4 of #2523. Overlap: no open pull request changes DisplayBuffer, DisplayFormat, GpuColorTransfer, HalfFloatScanout or the display buffer tests. ### Tested - Linux (CachyOS, kernel 7.2.9, GCC 16.2.1), Ryzen 9 7950X3D, RTX 3080 (NVIDIA 615.71.09) and RADV (Mesa 26.2.4, the iGPU), Release with `BUILD_TESTING=ON` and `ANYPS5_ENABLE_SPIRV_TOOLS=ON`, this branch on `main` a883f22f: - Full `ctest` on the RTX 3080: of 717 tests, 712 pass. Four `video_out_flip_*` tests (lifetime, reopen, controls, overlay) skip, because SDL's offscreen video driver has no Vulkan. `agc_driver_dcc_keys_first_write` fails, which is #2767. - `linear_display_buffer` and `agc_driver_bda_device` pass 3 repeats on each GPU, forced with `VK_DRIVER_FILES`. - `tools/check_conventions.py --base upstream/main`, `tools/check_test_registration.py` and `git diff --check` pass. - What the tests cover: - `linear_display_buffer` (CPU): the decode of hand-computed half values in both channel orders, sizes, and offsets of every texel of a 300x200 buffer against the equation table on full coordinates for 4- and 8-byte texels. Also the rejection of DCC and of an unknown float variant, the format decisions, and all 65,536 half bit patterns against an independent `floor(255 * sRGB(v) + 0.5)` reference. - `agc_driver_bda_device` (`ColorTransferTests`, Vulkan): random halves, including NaN, infinities, denormals and negative zero, in both channel orders through guest-memory detile and through `DetileImage` of an R16G16B16A16_SFLOAT image, against a reference built from the equation table and the shared tables. - The float case in `ResidentPresent.cpp` runs only in the full `agc_driver_recorder_tests` executable. ctest runs that executable only in its `--*-only` modes. Run by hand on each GPU, it prints `resident present format and conversion tests passed`. The executable then fails a later test: on NVIDIA a guest allocation is still pinned after 60 s, on RADV storage-image results are still pending. The same executable built from `main` a883f22f fails the same way on both. - Mutations, one line each, applied to this head. Each fails the test named: - `linear_display_buffer`: dropping the y-bit-6 term of the CPU layout, a 128-row instead of 64-row block height, a linear instead of sRGB threshold table, swapped red and blue, and skipping the DCC check; - `agc_driver_bda_device`: dropping the y-bit-6 term of the shader layout, and removing the shader's NaN/negative guard. - PPSA11386 v01.018.000, relinked and run in a bubblewrap sandbox, with SPIRV-Tools off in this build. - On `main` a883f22f it stops after 0.6 s on `VideoOut: unsupported display pixel format 0xc001000622000000` (SIGABRT). - With this change the title passes that check (its swapchain already exists before it) and ends after 0.7 s with SIGSEGV (exit code 139), which is row 5 of #2523: the PlayGo trap fixed by SleglJan/AnyPS5#19. With that commit added too, it reaches row 6 of #2523 (141 shaders) within a 90 s window. - It presents no frame in this window, so the transfer is not checked against its output here. On the #2523 integration stack, which carries the same commit, the title presents 140 to 168 frames before a later, unrelated stall. Their content has not been compared with console output. ### Checklist - [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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Fnrk5Dazjb2tLooVSpdRQq
Dextroid17 commented 2026-10-10 23:24:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-10T23:24:10Z.

Review: COMMENTED


This is the acceptance bar answered in full: a named title (PPSA11386, 007 First Light), the exact line it stops on (unsupported display pixel format 0xc001000622000000), the buffer geometry and the tiling. That is what makes a display-format change landable without an argument.

Two external references, and they are not of equal weight. SharpProspero is an independent implementation, so its names for these two formats are real corroboration. KytyPS5 is the weaker one to lean on: it shares lineage and house style with this project, so a mapping taken from it may agree with us for reasons that are not independent. Worth noting that the recorded evidence for that lineage is shared decoder style rather than format tables, so it is a caution here rather than a demonstration.

The details worth keeping are the ones a reader would otherwise get wrong: eight bytes per texel, and the fact that the two identifiers differ in one field while naming different channel orders — exactly the pair that gets collapsed into a single enum by mistake. Carrying the presented-frame transfer in a shader is the right place for it, since it keeps the work on the device that already holds the data; and the CPU decode path stays for the resident and reference cases, so the two share the threshold tables rather than one replacing the other.

One question about scope. The description registers the first format and stops on it; is the second exercised by a title yet, or is it included because it is the same code path — and either way, does the test pin both identifiers rather than only the one that was seen?

Written with AI assistance.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5481174450 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3134#pullrequestreview-5481174450). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-10T23:24:10Z. **Review:** COMMENTED --- This is the acceptance bar answered in full: a named title (PPSA11386, 007 First Light), the exact line it stops on (`unsupported display pixel format 0xc001000622000000`), the buffer geometry and the tiling. That is what makes a display-format change landable without an argument. **Two external references, and they are not of equal weight.** SharpProspero is an independent implementation, so its names for these two formats are real corroboration. KytyPS5 is the weaker one to lean on: it shares lineage and house style with this project, so a mapping taken from it may agree with us for reasons that are not independent. Worth noting that the recorded evidence for that lineage is shared decoder style rather than format tables, so it is a caution here rather than a demonstration. **The details worth keeping are the ones a reader would otherwise get wrong:** eight bytes per texel, and the fact that the two identifiers differ in one field while naming different channel orders — exactly the pair that gets collapsed into a single enum by mistake. Carrying the presented-frame transfer in a shader is the right place for it, since it keeps the work on the device that already holds the data; and the CPU decode path stays for the resident and reference cases, so the two share the threshold tables rather than one replacing the other. **One question about scope.** The description registers the first format and stops on it; is the second exercised by a title yet, or is it included because it is the same code path — and either way, does the test pin both identifiers rather than only the one that was seen? Written with AI assistance.
SleglJan commented 2026-10-10 23:33:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-10T23:33:13Z.


@Dextroid17 thanks for the review.

Is the second format used by a title? None that I've seen. 007's 0xC001000622000000 is the only format I've observed, and it's the one the title stops on. Nothing I've logged shows 0xC001000600000000. 0xC001000600000000 is included because SharpProspero (Bgra16Float) and KytyPS5 (bgra16) define it as the same eight-byte layout with red and blue swapped. In this change the two differ only in DisplayRedLow, which picks the channel order for the decode and for the shader.

Do the tests pin both identifiers? Yes.

  • linear_display_buffer (HalfFloatDisplay) sets each identifier on a buffer and checks the format decision, the Vulkan texel format, eight bytes per texel, the red-low flag, and the decode of hand-computed halves in its channel order.
  • agc_driver_bda_device runs the GPU detile in both channel orders.

On the references, agreed: SharpProspero is the independent source for the names. The tiled layout is an assumption that doesn't rest on either project: addrlib's 8-byte SW_64KB_R_X equation, which TextureDetile.comp already applies to R_X textures. It isn't verified against console frames.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6103352431 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3134#issuecomment-6103352431). Originally posted by [SleglJan](https://github.com/SleglJan) on 2026-10-10T23:33:13Z. --- @Dextroid17 thanks for the review. **Is the second format used by a title?** None that I've seen. 007's `0xC001000622000000` is the only format I've observed, and it's the one the title stops on. Nothing I've logged shows `0xC001000600000000`. `0xC001000600000000` is included because SharpProspero (`Bgra16Float`) and KytyPS5 (`bgra16`) define it as the same eight-byte layout with red and blue swapped. In this change the two differ only in `DisplayRedLow`, which picks the channel order for the decode and for the shader. **Do the tests pin both identifiers?** Yes. - `linear_display_buffer` (`HalfFloatDisplay`) sets each identifier on a buffer and checks the format decision, the Vulkan texel format, eight bytes per texel, the red-low flag, and the decode of hand-computed halves in its channel order. - `agc_driver_bda_device` runs the GPU detile in both channel orders. **On the references,** agreed: SharpProspero is the independent source for the names. The tiled layout is an assumption that doesn't rest on either project: addrlib's 8-byte SW_64KB_R_X equation, which `TextureDetile.comp` already applies to R_X textures. It isn't verified against console frames. AI-assisted: yes (Claude Code)
Silverash-i8 commented 2026-10-11 01:35:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Silverash-i8 on 2026-10-11T01:35:09Z.


Windows run, since the PR has no Windows results yet: Windows 11, WinLibs GCC 15.2.0 r7, Release, merged onto main d31b57a4 in one build with #3039, #3134, #3175 and #3194, on an RTX 5060 Laptop and the Arrow Lake iGPU (ANYPS5_GPU=Intel).

  • linear_display_buffer and agc_driver_bda_device (which builds ColorTransferTests.cpp) pass on both GPUs.
  • I also built the excluded agc_driver_recorder_tests for the ResidentPresent.cpp change: "Recorder read tracking and label tests passed" on both.

Across all agc_* tests in that build, the only new failure on either GPU is agc_driver_flat_store, which comes from #3175 alone (reported there). The Intel failures besides it are the known ones from #2114 and #3207.

AI-assisted (Claude Code); I ran this on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6104244076 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3134#issuecomment-6104244076). Originally posted by [Silverash-i8](https://github.com/Silverash-i8) on 2026-10-11T01:35:09Z. --- Windows run, since the PR has no Windows results yet: Windows 11, WinLibs GCC 15.2.0 r7, Release, merged onto `main` d31b57a4 in one build with #3039, #3134, #3175 and #3194, on an RTX 5060 Laptop and the Arrow Lake iGPU (`ANYPS5_GPU=Intel`). - `linear_display_buffer` and `agc_driver_bda_device` (which builds `ColorTransferTests.cpp`) pass on both GPUs. - I also built the excluded `agc_driver_recorder_tests` for the `ResidentPresent.cpp` change: "Recorder read tracking and label tests passed" on both. Across all `agc_*` tests in that build, the only new failure on either GPU is `agc_driver_flat_store`, which comes from #3175 alone (reported there). The Intel failures besides it are the known ones from #2114 and #3207. AI-assisted (Claude Code); I ran this on my machine.
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!3134
No description provided.