From: Gurchetan Singh Date: Tue, 14 Jan 2020 02:03:23 +0000 (-0800) Subject: st/mesa: implement EGLImageTargetTexStorage X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6c978b1362ecd40523a87516b3ac8fa2d34b1da9;p=mesa.git st/mesa: implement EGLImageTargetTexStorage We can now support this extension. Acked-by: Marek Olšák Tested-by: Marge Bot Part-of: --- diff --git a/src/mesa/state_tracker/st_cb_eglimage.c b/src/mesa/state_tracker/st_cb_eglimage.c index de1a6003ca4..d441c161449 100644 --- a/src/mesa/state_tracker/st_cb_eglimage.c +++ b/src/mesa/state_tracker/st_cb_eglimage.c @@ -268,10 +268,22 @@ st_bind_egl_image(struct gl_context *ctx, break; default: texFormat = st_pipe_format_to_mesa_format(stimg->format); + /* Use previously derived internalformat as specified by + * EXT_EGL_image_storage. + */ + if (tex_storage && texObj->Target == GL_TEXTURE_2D + && stimg->internalformat) { + internalFormat = stimg->internalformat; + if (internalFormat == GL_NONE) { + _mesa_error(ctx, GL_INVALID_OPERATION, __func__); + return; + } + } break; } assert(texFormat != MESA_FORMAT_NONE); + /* Minify texture size based on level set on the EGLImage. */ uint32_t width = u_minify(stimg->texture->width0, stimg->level); uint32_t height = u_minify(stimg->texture->height0, stimg->level); @@ -308,9 +320,26 @@ st_egl_image_target_texture_2d(struct gl_context *ctx, GLenum target, pipe_resource_reference(&stimg.texture, NULL); } +static void +st_egl_image_target_tex_storage(struct gl_context *ctx, GLenum target, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage, + GLeglImageOES image_handle) +{ + struct st_egl_image stimg; + + if (!st_get_egl_image(ctx, image_handle, PIPE_BIND_SAMPLER_VIEW, + "glEGLImageTargetTexture2D", &stimg)) + return; + + st_bind_egl_image(ctx, texObj, texImage, &stimg, true); + pipe_resource_reference(&stimg.texture, NULL); +} + void st_init_eglimage_functions(struct dd_function_table *functions) { functions->EGLImageTargetTexture2D = st_egl_image_target_texture_2d; + functions->EGLImageTargetTexStorage = st_egl_image_target_tex_storage; functions->EGLImageTargetRenderbufferStorage = st_egl_image_target_renderbuffer_storage; } diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index f31ea043ee0..3f89d3d115d 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -1018,6 +1018,7 @@ void st_init_extensions(struct pipe_screen *screen, extensions->EXT_blend_color = GL_TRUE; extensions->EXT_blend_func_separate = GL_TRUE; extensions->EXT_blend_minmax = GL_TRUE; + extensions->EXT_EGL_image_storage = GL_TRUE; extensions->EXT_gpu_program_parameters = GL_TRUE; extensions->EXT_pixel_buffer_object = GL_TRUE; extensions->EXT_point_parameters = GL_TRUE;