mesa/main: check depth/stencil formats

GL_DEPTH_COMPONENT is supported from OpenGL 1.4 and later, or using
OES_depth_texture on OpenGL ES.

GL_DEPTH_STENCIL is supported from OpenGL 3.0 on, or by
EXT_packed_depth_stencil. The latter is always supported in the first
place, so no need to test for the former.

In addition, there's an interaction between OES_depth_texture and
OES_packed_depth_stencil that allows this on OpenGL ES 2.0 and later.

The end result is that we alway support GL_DEPTH_STENCIL, with the
notable exception of OpenGL ES 1.x.

Similarly, we always support either EXT_packed_depth_stencil or the OES
variant, both of which adds support for the GL_UNSIGNED_INT_24_8 type.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29835>
This commit is contained in:
Erik Faye-Lund 2024-06-06 22:13:08 +02:00 committed by Marge Bot
parent ea6f960ec8
commit ca2fbfdaa0

View file

@ -1729,9 +1729,21 @@ static bool
valid_texture_format_enum(const struct gl_context *ctx, GLenum format)
{
switch (format) {
case GL_STENCIL_INDEX:
return _mesa_is_desktop_gl(ctx) || _mesa_is_gles31(ctx);
case GL_RG:
return _mesa_has_rg_textures(ctx);
case GL_DEPTH_COMPONENT:
return _mesa_is_desktop_gl(ctx) ||
_mesa_has_OES_depth_texture(ctx);
case GL_DEPTH_STENCIL:
return _mesa_has_EXT_packed_depth_stencil(ctx) ||
(_mesa_has_OES_packed_depth_stencil(ctx) &&
_mesa_has_OES_depth_texture(ctx));
case GL_YCBCR_MESA:
return _mesa_has_MESA_ycbcr_texture(ctx);
@ -1757,6 +1769,11 @@ valid_texture_type_enum(const struct gl_context *ctx, GLenum type)
case GL_UNSIGNED_INT_5_9_9_9_REV:
return _mesa_has_texture_shared_exponent(ctx);
case GL_UNSIGNED_INT_24_8:
assert(_mesa_has_EXT_packed_depth_stencil(ctx) ||
_mesa_has_OES_packed_depth_stencil(ctx));
return true;
case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
return _mesa_has_float_depth_buffer(ctx);