AGC: depth EQUAL misses 187 D16 values after a storage write to a D16S8 plane held as D24S8 #28611

Open
opened 2026-12-02 01:24:40 +00:00 by zeezey · 0 comments
zeezey commented 2026-12-02 01:24:40 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by zeezey on 2026-12-02T01:24:40Z.


What happens

Depth EQUAL fails for 187 of the 65,536 D16 values after a storage write to the depth plane of a D16_UNORM_S8_UINT surface held as D24_UNORM_S8_UINT. Low priority: no title is known to hit it.

Title, test or build step

A local execution test (not in the tree; I can open it as a PR if wanted). No title.

AnyPS5 commit

main at 7d3d015fee, nothing on top.

System

Windows 11, RTX 4090, driver 621.24, MinGW-w64 GCC, Release.

Host report

The host depth format for D16S8 is D24_UNORM_S8_UINT (the fallback from #18185).

Steps to reproduce

  1. A compute dispatch stores float(id) / 65535 for every id 0..65535 into the D16 depth plane through a storage image, one texel per id. The plane is held as D24, so d16ToD24 in Graphics/shaders/DepthConvert.comp converts it.
  2. One draw per id then tests depth EQUAL at z = id / 65535, the same value written as id * (1/65535) or float(id) / 65535, over that texel, and the covered count is read back.
  3. The reverse: a draw writes depth z = id / 65535, then a compute reads the plane as 16 bits and compares it with id.

The run takes about 60 s.

Log

forward: tested 65536 ids in 20.5 s; EQUAL fails with z=id*c(mul): 187, with z=id/65535 (div): 187
  fail id=128  z=0.0019531548  model D24 32768
  fail id=383  z=0.00584420562 model D24 98049
  fail id=384  z=0.00585946441 model D24 98305
  fail id=638  z=0.00973525643 model D24 163330
  fail id=894  z=0.013641566   model D24 228867
  fail id=1148 z=0.0175173581  model D24 293892
reverse: tested 65536 ids; raw-read != id: 0
  • Where it fails: ids 0-127 all pass. The failures start at 128 and come in short runs of 3-5 ids, where id * 16777215 / 65535 sits close to x.5.
  • The model: a CPU model of d16ToD24 and a model of the rasterizer's round(z * 16777215) give the same D24 for these ids.
  • A probe: EQUAL draws at (S + d) / 16777215 for d = -2..2 around the modelled value S also cover nothing.

So the plane does not seem to hold the value either model predicts, or the draw's z doesn't quantize the way I modelled it. I have not found which. The reverse direction (D24 to D16) is exact for every id.

A possibly simpler conversion: map the 16-bit code straight to D24 in integer arithmetic, id * 256 + ((id + 128) >> 8), which rounds id * 16777215 / 65535 to nearest, ties up. That would avoid the float step. I have not tested it against the rasterizer.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:6734628975 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/28611). Originally posted by [zeezey](https://github.com/zeezey) on 2026-12-02T01:24:40Z. --- ### What happens Depth EQUAL fails for 187 of the 65,536 D16 values after a storage write to the depth plane of a D16_UNORM_S8_UINT surface held as D24_UNORM_S8_UINT. Low priority: no title is known to hit it. ### Title, test or build step A local execution test (not in the tree; I can open it as a PR if wanted). No title. ### AnyPS5 commit `main` at 7d3d015fee, nothing on top. ### System Windows 11, RTX 4090, driver 621.24, MinGW-w64 GCC, Release. ### Host report The host depth format for D16S8 is D24_UNORM_S8_UINT (the fallback from #18185). ### Steps to reproduce 1. A compute dispatch stores `float(id) / 65535` for every id 0..65535 into the D16 depth plane through a storage image, one texel per id. The plane is held as D24, so `d16ToD24` in `Graphics/shaders/DepthConvert.comp` converts it. 2. One draw per id then tests depth EQUAL at `z = id / 65535`, the same value written as `id * (1/65535)` or `float(id) / 65535`, over that texel, and the covered count is read back. 3. The reverse: a draw writes depth `z = id / 65535`, then a compute reads the plane as 16 bits and compares it with `id`. The run takes about 60 s. ### Log ``` forward: tested 65536 ids in 20.5 s; EQUAL fails with z=id*c(mul): 187, with z=id/65535 (div): 187 fail id=128 z=0.0019531548 model D24 32768 fail id=383 z=0.00584420562 model D24 98049 fail id=384 z=0.00585946441 model D24 98305 fail id=638 z=0.00973525643 model D24 163330 fail id=894 z=0.013641566 model D24 228867 fail id=1148 z=0.0175173581 model D24 293892 reverse: tested 65536 ids; raw-read != id: 0 ``` - **Where it fails:** ids 0-127 all pass. The failures start at 128 and come in short runs of 3-5 ids, where `id * 16777215 / 65535` sits close to x.5. - **The model:** a CPU model of `d16ToD24` and a model of the rasterizer's `round(z * 16777215)` give the same D24 for these ids. - **A probe:** EQUAL draws at `(S + d) / 16777215` for d = -2..2 around the modelled value S also cover nothing. So the plane does not seem to hold the value either model predicts, or the draw's z doesn't quantize the way I modelled it. I have not found which. The reverse direction (D24 to D16) is exact for every id. A possibly simpler conversion: map the 16-bit code straight to D24 in integer arithmetic, `id * 256 + ((id + 128) >> 8)`, which rounds `id * 16777215 / 65535` to nearest, ties up. That would avoid the float step. I have not tested it against the rasterizer. AI-assisted: yes.
Sign in to join this conversation.
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#28611
No description provided.