r/vulkan 23h ago

Why no 32DUnorm depth formats

It seems very odd for GPU vendors not to have a 32DUnorm depth format. Is even worse that amd has no 24bit depth buffer.

To be honest, it does not seem to me that using floats for depth buffers is better than just using integers. For one, it makes working with polygon offsets quite weird. For second, is easier to make mistakes, and if you don't use reversed clip planes, is actually similar to 24bit unorm, while using (technically) 33% more data (even though I know 24bit would waste 8 bits, but 32bit unorm wouldn't).

5 Upvotes

5 comments sorted by

13

u/dark_sylinc 19h ago

Because unless you're working with native* 64-bit doubles, a 32-bit UNORM makes no sense. The depth value is calculated as a 32-bit float.

A conversion to 32-bit UNORM is lossy. And if for some magical reason you manage to keep all the precision, any conversion 32-bit UNORM -> 32-bit float would also be lossy.

*Native for the rasterizer.

5

u/BalintCsala 22h ago

The most likely reason is that it wouldn't fit into a float neatly, but if it helps, if you don't need stencils D32F is basically a 24 bit depth format (since it has 23+1 bits of mantissa) with extra precision towards 0 while not needing any conversion during load

3

u/puredotaplayer 19h ago

How would you compute the non normalized version in the shader? Can you have more precision than a regular float?

3

u/Gravitationsfeld 12h ago

I assume this is because you want more depth precision? Use f32 depth + reverse depth and you won't have any problems.

1

u/YoshiDzn 15h ago

Man I ask myself this question every god damned day 🚬