fix(agc): read a 16-bit integer view of a depth plane as its stored values #188

Merged
MichonGoddijn231849 merged 1 commit from upstream-pr/188 into main 2026-09-30 17:24:56 +00:00
MichonGoddijn231849 commented 2026-09-30 15:55:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-09-30T15:55:21Z.


What

A shader can read a D16 depth plane through a 16-bit integer view: a T# of format 16_UINT with the depth-layout swizzle. It expects the stored 16-bit values. Before, the driver refused the view on a depth surface ("sampling the depth plane of depth surface ... is not implemented"), and the draw or dispatch aborted.

  • DepthBitsTextureWidth tells a 32-bit depth-bits view (as before) from a 16-bit one; IsDepthBitsTexture covers both.
  • The recompiler marks a 16-bit one depthUnorm16: it samples the depth as float, as for 32-bit, and returns uint(depth * 65535 + 0.5), which is the stored value. The flag is part of the resource specialization, its equality and the shader disk cache records.
  • On a D16 depth surface the depth view is bound as for the 32-bit case.
  • When the memory is no depth surface, the texture is bound as 16_UNORM, so the same conversion returns the stored integers.
  • A 32-bit raw read of memory that is no depth surface still throws, as before.

Tested

Windows 11 Pro, AMD Ryzen 5 7600, NVIDIA GeForce RTX 5080 (driver 32.0.16.1074), 32 GB DDR5-5600, MinGW-w64 GCC 15.2.0.

  • GTA V (PPSA04264) with #167 on current main: the Story Mode prologue aborted after the North Yankton title at compute shader 0x242d48e00 (sampling the depth plane of depth surface 0x296da0000 (1024x1536, vk format 124) as a 1024x1536 texture of guest format 11). With this change it renders the world.
  • ctest: agc_structurizer, agc_shader_disk_cache, agc_dpp_write and guest_memory pass.

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
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes. Written with Claude (Anthropic) under my direction; I reviewed and tested it.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4692858080 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/188). Originally posted by [MichonGoddijn231849](https://github.com/MichonGoddijn231849) on 2026-09-30T15:55:21Z. --- ### What A shader can read a D16 depth plane through a 16-bit integer view: a T# of format `16_UINT` with the depth-layout swizzle. It expects the stored 16-bit values. Before, the driver refused the view on a depth surface ("sampling the depth plane of depth surface ... is not implemented"), and the draw or dispatch aborted. - `DepthBitsTextureWidth` tells a 32-bit depth-bits view (as before) from a 16-bit one; `IsDepthBitsTexture` covers both. - The recompiler marks a 16-bit one `depthUnorm16`: it samples the depth as float, as for 32-bit, and returns `uint(depth * 65535 + 0.5)`, which is the stored value. The flag is part of the resource specialization, its equality and the shader disk cache records. - On a D16 depth surface the depth view is bound as for the 32-bit case. - When the memory is no depth surface, the texture is bound as `16_UNORM`, so the same conversion returns the stored integers. - A 32-bit raw read of memory that is no depth surface still throws, as before. ### Tested Windows 11 Pro, AMD Ryzen 5 7600, NVIDIA GeForce RTX 5080 (driver 32.0.16.1074), 32 GB DDR5-5600, MinGW-w64 GCC 15.2.0. - GTA V (PPSA04264) with #167 on current `main`: the Story Mode prologue aborted after the North Yankton title at compute shader `0x242d48e00` (`sampling the depth plane of depth surface 0x296da0000 (1024x1536, vk format 124) as a 1024x1536 texture of guest format 11`). With this change it renders the world. - `ctest`: `agc_structurizer`, `agc_shader_disk_cache`, `agc_dpp_write` and `guest_memory` pass. ### 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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [x] No notes, investigation `.md` files or images added to the repository - [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. Written with Claude (Anthropic) under my direction; I reviewed and tested it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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!188
No description provided.