st/mesa: implement EGLImageTargetTexStorage
authorGurchetan Singh <gurchetansingh@chromium.org>
Tue, 14 Jan 2020 02:03:23 +0000 (18:03 -0800)
committerMarge Bot <eric+marge@anholt.net>
Wed, 15 Jan 2020 01:18:54 +0000 (01:18 +0000)
We can now support this extension.

Acked-by: Marek Olšák <marek.olsak@amd.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3375>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3375>

src/mesa/state_tracker/st_cb_eglimage.c
src/mesa/state_tracker/st_extensions.c

index de1a6003ca43989d5841ce197bab6810216bdac1..d441c161449067c80e8e5498b01edc6a9a3bf267 100644 (file)
@@ -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;
 }
index f31ea043ee0d0a0e1dd19607572ea34d8cf6311c..3f89d3d115d19c048bd5566bb87952fb420d8199 100644 (file)
@@ -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;