feat(libSceAgcDriver): sample guest 8_24_UNORM images as D24_UNORM_S8_UINT #16294

Merged
akkadbakkad89 merged 2 commits from upstream-pr/16294 into main 2026-11-07 12:40:22 +00:00
akkadbakkad89 commented 2026-11-06 06:09:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by akkadbakkad89 on 2026-11-06T06:09:03Z.


What

Maps guest image format 141 (8_24_UNORM in the AMD GFX10 IMG_FMT table, palFormat.h X8Y24 LSB-first = S8 in the top byte over D24) to VK_FORMAT_D24_UNORM_S8_UINT where the device supports it, whose depth-aspect buffer element (X8_D24_UNORM_PACK32) is byte-identical to the guest texel.

  • kFormatLookup gains the row; kFormatInfoTable samples it as Float; GetFormatInfo describes the single 24-bit channel (bitfield, element 4 bytes); IrBufferFormat::Format8_24UNorm = 141 is new.
  • SampledTextureFormat queries optimalTilingFeatures for SAMPLED_IMAGE | TRANSFER_DST per physical device (cached, DepthSurface-style): AMD Vulkan drivers report no features for D24_UNORM_S8_UINT (RX 6700 XT, driver 26.10.1), so there format 141 samples through VK_FORMAT_R32_SFLOAT instead, and the detiler's repack pass gains a depthToFloat mode that converts each guest word's low 24 bits to float(d24) / 16777215 in place before the buffer-to-image copy (fma(d * 2^-24, 2^-24, d * 2^-24) for a correctly-rounded, bit-exact round-trip). APS5_NO_D24S8 forces the fallback.
  • Texture now distinguishes copy/view aspect from barrier aspect for a native depth/stencil format: image barriers on the combined D24S8 image cover DEPTH|STENCIL (required without separateDepthStencilLayouts), while the vkCmdCopyBufferToImage region and the sampled view keep DEPTH alone so the packed stencil byte is dropped rather than written.
  • depthCompare also accepts a native depth/stencil format (D24S8/D32S8) instead of only the R32/R16 numeric depth-plane formats, so a compare sampler on format 141 works without the R-to-D conversion; on the R32F fallback it takes the existing R32→D32 path.
  • Storage images of 141 still throw (no storage-view fallback for a depth/stencil format), and the sibling formats stay unmapped: 8_24_UINT/X24_8_32_UINT have no Vulkan depth UINT, the 24_8 pair packs stencil first with no host equivalent, and X24_8_32_FLOAT keeps eight-byte elements that need a new repack pass. Recorded in the libSceAgcDriver debt file.

Tested

Windows 11, MinGW GCC 15.2, NVIDIA RTX 3070 (driver 617.42), VK_LAYER_KHRONOS_validation loaded (SDK 1.4.363, VK_LAYER_PATH), ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1:

  • agc_driver_image_depth24 (native D24S8) and agc_driver_image_depth24_float (APS5_NO_D24S8=1, the R32F repack): image_load fetches every 8_24 texel's 24-bit depth round-trip-exact and image_sample_lz samples it; both return G=0 B=0 A=1.
  • 78-test suite (texture_format_lookup, agc_driver_image_converted_unorm, agc_driver_image_packed16_* (133/134/136), agc_driver_image_one_dimensional_compare (the depthCompare path), all agc_driver_depth_*, agc_driver_native_depth_*, gathers) passes; no VUID- and no missing-layer line in the logs. The first iteration of this change produced VUID-VkImageMemoryBarrier-image-03320 on the upload barrier, which the barrier-aspect split fixes.
  • AMD RX 6700 XT, driver 26.10.1 (JJenkx): the pre-fallback tree failed agc_driver_image_depth24 at vkCreateImage (VK_ERROR_FORMAT_NOT_SUPPORTED, zero format features for D24S8) — the datapoint the fallback answers; a re-run of the current head should take the R32F path.

No console measurement: channel semantics and the missing-channel default of the sampled result are per Vulkan/GFX10 documentation only (debt entry).

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: none
  • GPUs tested: NVIDIA GeForce RTX 3070, driver 617.42, Windows 11
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5183739190 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16294). Originally posted by [akkadbakkad89](https://github.com/akkadbakkad89) on 2026-11-06T06:09:03Z. --- ### What Maps guest image format 141 (`8_24_UNORM` in the AMD GFX10 `IMG_FMT` table, `palFormat.h` `X8Y24` LSB-first = `S8` in the top byte over `D24`) to `VK_FORMAT_D24_UNORM_S8_UINT` where the device supports it, whose depth-aspect buffer element (`X8_D24_UNORM_PACK32`) is byte-identical to the guest texel. - `kFormatLookup` gains the row; `kFormatInfoTable` samples it as Float; `GetFormatInfo` describes the single 24-bit channel (bitfield, element 4 bytes); `IrBufferFormat::Format8_24UNorm = 141` is new. - `SampledTextureFormat` queries `optimalTilingFeatures` for `SAMPLED_IMAGE | TRANSFER_DST` per physical device (cached, `DepthSurface`-style): AMD Vulkan drivers report no features for `D24_UNORM_S8_UINT` (RX 6700 XT, driver 26.10.1), so there format 141 samples through `VK_FORMAT_R32_SFLOAT` instead, and the detiler's repack pass gains a `depthToFloat` mode that converts each guest word's low 24 bits to `float(d24) / 16777215` in place before the buffer-to-image copy (`fma(d * 2^-24, 2^-24, d * 2^-24)` for a correctly-rounded, bit-exact round-trip). `APS5_NO_D24S8` forces the fallback. - `Texture` now distinguishes *copy/view* aspect from *barrier* aspect for a native depth/stencil format: image barriers on the combined D24S8 image cover `DEPTH|STENCIL` (required without `separateDepthStencilLayouts`), while the `vkCmdCopyBufferToImage` region and the sampled view keep `DEPTH` alone so the packed stencil byte is dropped rather than written. - `depthCompare` also accepts a native depth/stencil format (D24S8/D32S8) instead of only the R32/R16 numeric depth-plane formats, so a compare sampler on format 141 works without the R-to-D conversion; on the R32F fallback it takes the existing R32→D32 path. - Storage images of 141 still throw (no storage-view fallback for a depth/stencil format), and the sibling formats stay unmapped: `8_24_UINT`/`X24_8_32_UINT` have no Vulkan depth `UINT`, the `24_8` pair packs stencil first with no host equivalent, and `X24_8_32_FLOAT` keeps eight-byte elements that need a new repack pass. Recorded in the libSceAgcDriver debt file. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11, MinGW GCC 15.2, NVIDIA RTX 3070 (driver 617.42), `VK_LAYER_KHRONOS_validation` loaded (SDK 1.4.363, `VK_LAYER_PATH`), `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`: - `agc_driver_image_depth24` (native D24S8) and `agc_driver_image_depth24_float` (`APS5_NO_D24S8=1`, the R32F repack): `image_load` fetches every `8_24` texel's 24-bit depth round-trip-exact and `image_sample_lz` samples it; both return G=0 B=0 A=1. - 78-test suite (`texture_format_lookup`, `agc_driver_image_converted_unorm`, `agc_driver_image_packed16_*` (133/134/136), `agc_driver_image_one_dimensional_compare` (the depthCompare path), all `agc_driver_depth_*`, `agc_driver_native_depth_*`, gathers) passes; no `VUID-` and no missing-layer line in the logs. The first iteration of this change produced `VUID-VkImageMemoryBarrier-image-03320` on the upload barrier, which the barrier-aspect split fixes. - AMD RX 6700 XT, driver 26.10.1 (JJenkx): the pre-fallback tree failed `agc_driver_image_depth24` at `vkCreateImage` (`VK_ERROR_FORMAT_NOT_SUPPORTED`, zero format features for D24S8) — the datapoint the fallback answers; a re-run of the current head should take the R32F path. No console measurement: channel semantics and the missing-channel default of the sampled result are per Vulkan/GFX10 documentation only (debt entry). ### 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: <!-- #PR, or none -->none - [x] Fixes: <!-- issue it closes as Fixes #N, or none -->none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none -->none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a -->NVIDIA GeForce RTX 3070, driver 617.42, Windows 11 - [x] AI-assisted: <!-- yes / no -->yes
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!16294
No description provided.