From 5dde2812b9aa5a8a2c5018341ce99f5ef7a9f22b Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Thu, 30 Oct 2025 19:58:59 +0100 Subject: [PATCH] mesa/main: correct formatquery error-handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Most of the time, we remember to check for both extensions. But in one case, it seems we forgot the GLES extension. Whoops. Let's switch to a helper here, so we don't have to repeat the logic over and over again. Fixes: b4c0c514b10 ("mesa: add OES_texture_buffer and EXT_texture_buffer support") Reviewed-by: Lars-Ivar Hesselberg Simonsen Reviewed-by: Iago Toral Quiroga Reviewed-by: Marek Olšák (cherry picked from commit 9d5e0c1ad27102f496161bee4ee0011d0f5c4b3b) Part-of: --- .pick_status.json | 2 +- src/mesa/main/bufferobj.c | 4 +--- src/mesa/main/context.h | 7 +++++++ src/mesa/main/formatquery.c | 2 +- src/mesa/main/get.c | 4 +--- src/mesa/main/teximage.c | 9 +++------ src/mesa/main/texobj.c | 10 ++++------ src/mesa/main/texparam.c | 3 +-- 8 files changed, 19 insertions(+), 22 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index e27a0646b30..113ac6ca466 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -344,7 +344,7 @@ "description": "mesa/main: correct formatquery error-handling", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "b4c0c514b10ed85b50e4fc3bbd9c740db21e5720", "notes": null diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 08017988de6..91aef13a574 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -728,9 +728,7 @@ get_buffer_target(struct gl_context *ctx, GLenum target, bool no_error) } break; case GL_TEXTURE_BUFFER: - if (no_error || - _mesa_has_ARB_texture_buffer_object(ctx) || - _mesa_has_OES_texture_buffer(ctx)) { + if (no_error || _mesa_has_texture_buffer_object(ctx)) { return &ctx->Texture.BufferObject; } break; diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h index 06bfe91b003..6b7cb306174 100644 --- a/src/mesa/main/context.h +++ b/src/mesa/main/context.h @@ -483,6 +483,13 @@ _mesa_has_texture_cube_map_array(const struct gl_context *ctx) _mesa_has_OES_texture_cube_map_array(ctx); } +static inline bool +_mesa_has_texture_buffer_object(const struct gl_context *ctx) +{ + return _mesa_has_ARB_texture_buffer_object(ctx) || + _mesa_has_OES_texture_buffer(ctx); +} + static inline bool _mesa_has_texture_view(const struct gl_context *ctx) { diff --git a/src/mesa/main/formatquery.c b/src/mesa/main/formatquery.c index ca57571e798..7158c1c2c7a 100644 --- a/src/mesa/main/formatquery.c +++ b/src/mesa/main/formatquery.c @@ -473,7 +473,7 @@ _is_target_supported(struct gl_context *ctx, GLenum target) break; case GL_TEXTURE_BUFFER: - if (!_mesa_has_ARB_texture_buffer_object(ctx)) + if (!_mesa_has_texture_buffer_object(ctx)) return false; break; diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 6d2415d8a09..a778c298926 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -2528,9 +2528,7 @@ tex_binding_to_index(const struct gl_context *ctx, GLenum binding) || _mesa_is_gles3(ctx) ? TEXTURE_2D_ARRAY_INDEX : -1; case GL_TEXTURE_BINDING_BUFFER: - return (_mesa_has_ARB_texture_buffer_object(ctx) || - _mesa_has_OES_texture_buffer(ctx)) ? - TEXTURE_BUFFER_INDEX : -1; + return _mesa_has_texture_buffer_object(ctx) ? TEXTURE_BUFFER_INDEX : -1; case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY: return _mesa_has_texture_cube_map_array(ctx) ? TEXTURE_CUBE_ARRAY_INDEX : -1; diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 59a8885ed97..184ba3bb2fe 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -525,8 +525,7 @@ _mesa_max_texture_levels(const struct gl_context *ctx, GLenum target) return _mesa_has_texture_cube_map_array(ctx) ? ctx->Const.MaxCubeTextureLevels : 0; case GL_TEXTURE_BUFFER: - return (_mesa_has_ARB_texture_buffer_object(ctx) || - _mesa_has_OES_texture_buffer(ctx)) ? 1 : 0; + return _mesa_has_texture_buffer_object(ctx) ? 1 : 0; case GL_TEXTURE_2D_MULTISAMPLE: case GL_PROXY_TEXTURE_2D_MULTISAMPLE: case GL_TEXTURE_2D_MULTISAMPLE_ARRAY: @@ -6499,8 +6498,7 @@ _mesa_get_texbuffer_format(const struct gl_context *ctx, GLenum internalFormat) } } - if (_mesa_has_ARB_texture_buffer_object_rgb32(ctx) || - _mesa_has_OES_texture_buffer(ctx)) { + if (_mesa_has_texture_buffer_object(ctx)) { switch (internalFormat) { case GL_RGB32F: return MESA_FORMAT_RGB_FLOAT32; @@ -6649,8 +6647,7 @@ texture_buffer_range(struct gl_context *ctx, /* NOTE: ARB_texture_buffer_object might not be supported in * the compatibility profile. */ - if (!_mesa_has_ARB_texture_buffer_object(ctx) && - !_mesa_has_OES_texture_buffer(ctx)) { + if (!_mesa_has_texture_buffer_object(ctx)) { _mesa_error(ctx, GL_INVALID_OPERATION, "%s(ARB_texture_buffer_object is not" " implemented for the compatibility profile)", caller); diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index e60af1868b7..e768e0e9910 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -202,9 +202,8 @@ _mesa_get_current_tex_object(struct gl_context *ctx, GLenum target) case GL_PROXY_TEXTURE_2D_ARRAY_EXT: return arrayTex ? ctx->Texture.ProxyTex[TEXTURE_2D_ARRAY_INDEX] : NULL; case GL_TEXTURE_BUFFER: - return (_mesa_has_ARB_texture_buffer_object(ctx) || - _mesa_has_OES_texture_buffer(ctx)) ? - texUnit->CurrentTex[TEXTURE_BUFFER_INDEX] : NULL; + return _mesa_has_texture_buffer_object(ctx) + ? texUnit->CurrentTex[TEXTURE_BUFFER_INDEX] : NULL; case GL_TEXTURE_EXTERNAL_OES: return _mesa_is_gles(ctx) && ctx->Extensions.OES_EGL_image_external ? texUnit->CurrentTex[TEXTURE_EXTERNAL_INDEX] : NULL; @@ -1639,9 +1638,8 @@ _mesa_tex_target_to_index(const struct gl_context *ctx, GLenum target) || _mesa_is_gles3(ctx) ? TEXTURE_2D_ARRAY_INDEX : -1; case GL_TEXTURE_BUFFER: - return (_mesa_has_ARB_texture_buffer_object(ctx) || - _mesa_has_OES_texture_buffer(ctx)) ? - TEXTURE_BUFFER_INDEX : -1; + return _mesa_has_texture_buffer_object(ctx) + ? TEXTURE_BUFFER_INDEX : -1; case GL_TEXTURE_EXTERNAL_OES: return _mesa_is_gles(ctx) && ctx->Extensions.OES_EGL_image_external ? TEXTURE_EXTERNAL_INDEX : -1; diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c index 98ae15a006a..a3fc26adb78 100644 --- a/src/mesa/main/texparam.c +++ b/src/mesa/main/texparam.c @@ -1931,8 +1931,7 @@ get_tex_level_parameter_image(struct gl_context *ctx, /* GL_ARB_texture_buffer_object */ case GL_TEXTURE_BUFFER_DATA_STORE_BINDING: - if (!_mesa_has_ARB_texture_buffer_object(ctx) && - !_mesa_has_OES_texture_buffer(ctx)) + if (!_mesa_has_texture_buffer_object(ctx)) goto invalid_pname; *params = 0; break;