i965: support EXT_EGL_image_storage
authorGurchetan Singh <gurchetansingh@chromium.org>
Thu, 15 Aug 2019 01:09:28 +0000 (18:09 -0700)
committerGurchetan Singh <gurchetansingh@chromium.org>
Mon, 13 Jan 2020 22:57:36 +0000 (14:57 -0800)
i965 can support this.

Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
src/mesa/drivers/dri/i965/intel_extensions.c
src/mesa/drivers/dri/i965/intel_tex_image.c

index 39524925cf1ded3d3c5f07f21d425fd3ac14b9c3..e7ea8cde52e555cdd4125c9561633473c78ecb33 100644 (file)
@@ -97,6 +97,7 @@ intelInitExtensions(struct gl_context *ctx)
    ctx->Extensions.EXT_blend_func_separate = true;
    ctx->Extensions.EXT_blend_minmax = true;
    ctx->Extensions.EXT_draw_buffers2 = true;
+   ctx->Extensions.EXT_EGL_image_storage = true;
    ctx->Extensions.EXT_float_blend = true;
    ctx->Extensions.EXT_framebuffer_sRGB = true;
    ctx->Extensions.EXT_gpu_program_parameters = true;
index 34491aa36efa51cc12f19dca9d776a721233a96d..fba925dee5aaab971e032e6762baa3bb17cd3cc4 100644 (file)
@@ -649,6 +649,17 @@ intel_image_target_texture(struct gl_context *ctx, GLenum target,
          internal_format = GL_RGB10_A2;
    }
 
+   /* Guess sized internal format for dma-bufs, as specified by
+    * EXT_EGL_image_storage.
+    */
+   if (storage && target == GL_TEXTURE_2D && image->imported_dmabuf) {
+      internal_format = driGLFormatToSizedInternalGLFormat(image->format);
+      if (internal_format == GL_NONE) {
+         _mesa_error(ctx, GL_INVALID_OPERATION, __func__);
+         return;
+      }
+   }
+
    intel_set_texture_image_mt(brw, texImage, internal_format, mt->format, mt);
    intel_miptree_release(&mt);
 }
@@ -663,6 +674,23 @@ intel_image_target_texture_2d(struct gl_context *ctx, GLenum target,
                               false);
 }
 
+static void
+intel_image_target_tex_storage(struct gl_context *ctx, GLenum target,
+                              struct gl_texture_object *texObj,
+                              struct gl_texture_image *texImage,
+                              GLeglImageOES image_handle)
+{
+   struct intel_texture_object *intel_texobj = intel_texture_object(texObj);
+   intel_image_target_texture(ctx, target, texObj, texImage, image_handle,
+                              true);
+
+   /* The miptree is in a validated state, so no need to check later. */
+   intel_texobj->needs_validate = false;
+   intel_texobj->validated_first_level = 0;
+   intel_texobj->validated_last_level = 0;
+   intel_texobj->_Format = texImage->TexFormat;
+}
+
 static bool
 intel_gettexsubimage_blorp(struct brw_context *brw,
                            struct gl_texture_image *tex_image,
@@ -955,6 +983,7 @@ intelInitTextureImageFuncs(struct dd_function_table *functions)
    functions->TexSubImage = intelTexSubImage;
    functions->CompressedTexSubImage = intelCompressedTexSubImage;
    functions->EGLImageTargetTexture2D = intel_image_target_texture_2d;
+   functions->EGLImageTargetTexStorage = intel_image_target_tex_storage;
    functions->BindRenderbufferTexImage = intel_bind_renderbuffer_tex_image;
    functions->GetTexSubImage = intel_get_tex_sub_image;
 }