From ca2fbfdaa0f1c56920e54dc8e89e1bef34cda1cf Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Thu, 6 Jun 2024 22:13:08 +0200 Subject: [PATCH] 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 Part-of: --- src/mesa/main/glformats.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c index e2f105ad553..cf40dd0a8e6 100644 --- a/src/mesa/main/glformats.c +++ b/src/mesa/main/glformats.c @@ -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);