From 834b00a1ce4d0f6c93271198f227843cc4a356d8 Mon Sep 17 00:00:00 2001 From: JiDe Zhang Date: Sat, 31 Jan 2026 14:00:13 +0800 Subject: [PATCH] render/gles2: export gl fromat on texture attribs When importing a wlr_texture as an external resource into Qt, Qt needs to know its pixel format. This is similar to the usage scenario of the format field in wlr_vk_image_attribs. Although it is possible to query GL_TEXTURE_INTERNAL_FORMAT through the OpenGL API, it is not the same value as the format that was originally passed to OpenGL when the wlr_texture was created. The internal_format and format do not have a one-to-one correspondence, and the correct original format cannot be retrieved from outside. --- include/render/gles2.h | 1 + include/wlr/render/gles2.h | 1 + render/gles2/texture.c | 2 ++ 3 files changed, 4 insertions(+) diff --git a/include/render/gles2.h b/include/render/gles2.h index 6b852dcb7..64a69a85a 100644 --- a/include/render/gles2.h +++ b/include/render/gles2.h @@ -124,6 +124,7 @@ struct wlr_gles2_texture { // case. GLuint tex; GLuint fbo; + GLint format; bool has_alpha; diff --git a/include/wlr/render/gles2.h b/include/wlr/render/gles2.h index 454e7eb0e..44cf1abaf 100644 --- a/include/wlr/render/gles2.h +++ b/include/wlr/render/gles2.h @@ -40,6 +40,7 @@ struct wlr_gles2_texture_attribs { GLuint tex; bool has_alpha; + GLint format; }; bool wlr_renderer_is_gles2(struct wlr_renderer *wlr_renderer); diff --git a/render/gles2/texture.c b/render/gles2/texture.c index 9a967ebdb..cfeb9d849 100644 --- a/render/gles2/texture.c +++ b/render/gles2/texture.c @@ -325,6 +325,7 @@ static struct wlr_texture *gles2_texture_from_pixels( } texture->target = GL_TEXTURE_2D; texture->has_alpha = pixel_format_has_alpha(fmt->drm_format); + texture->format = fmt->gl_format; texture->drm_format = fmt->drm_format; GLint internal_format = fmt->gl_internalformat; @@ -436,5 +437,6 @@ void wlr_gles2_texture_get_attribs(struct wlr_texture *wlr_texture, .target = texture->target, .tex = texture->tex, .has_alpha = texture->has_alpha, + .format = texture->format, }; }