Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gfx proposal: support for floating point depth buffer with a stencil component #1122

Open
kcbanner opened this issue Oct 14, 2024 · 2 comments · May be fixed by #1124
Open

gfx proposal: support for floating point depth buffer with a stencil component #1122

kcbanner opened this issue Oct 14, 2024 · 2 comments · May be fixed by #1124

Comments

@kcbanner
Copy link
Contributor

Currently, both SG_PIXELFORMAT_DEPTH and SG_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.

@floooh
Copy link
Owner

floooh commented Oct 14, 2024

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.

@kcbanner
Copy link
Contributor Author

That all sounds good to me, I'll take a look at implementing this.

@kcbanner kcbanner linked a pull request Oct 15, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants