Open kcbanner opened 1 month ago
Hmm, yeah, I tiptoed around being able to select a specific depth- or depth-stencil format, and tbh, I would like to allow some wiggle room in the future too (at least for the 'basic' DEPTH and DEPTH_STENCIL pixelformats which don't explicitly specify a precision).
For instance in WebGPU the float32+stencil8 format is behind a feature flag because it's not supported everywhere.
In general, we should use the WebGPU naming convention for explicit depth- and depth-stencil formats (because I also used WebGPU as reference for the entire pixel formats list in sokol-gfx), converted to the sokol-gfx style it would be:
SG_PIXELFORMAT_DEPTH32F_STENCIL8
...and if we want other explicit formats too:
SG_PIXELFORMAT_DEPTH24PLUS
SG_PIXELFORMAT_DEPTH24PLUS_STENCIL8
SG_PIXELFORMAT_DEPTH32F
...I think we can leave out WebGPU's depth16unorm
and stencil8
formats, since 16-bit depth is hopefully irrelevant by now, and a stencil8
without depth seems fairly exotic.
The 'flexible' SG_PIXELFORMAT_DEPTH
and SG_PIXELFORMAT_DEPTH_STENCIL
should stay though which allows us to provide a 'recommended' explicit format for a specific backend / target platform.
That all sounds good to me, I'll take a look at implementing this.
Currently, both
SG_PIXELFORMAT_DEPTH
andSG_PIXELFORMAT_DEPTH_STENCIL
are supported, with the former being a 32 bit floating point depth buffer, and the latter being a 24 bit unsigned depth buffer and 8 bit stencil.OpenGL 4.3 and ES 3.0 have:
DEPTH32F_STENCIL8
D3D11 has:
DXGI_FORMAT_D32_FLOAT_S8X24_UINT
Metal has:MTLPixelFormatDepth32Float_Stencil8
(https://developer.apple.com/documentation/metal/mtlpixelformat/mtlpixelformatdepth32float_stencil8)Is there room for an
SG_PIXELFORMAT
that maps to this format, if so what would it be called? I'm not sure how it would map onto the current naming convention.I'm happy to implement this, although I won't be able to test the Metal version.