i965: Lift some restrictions on dma_buf EGLImages
authorChad Versace <chad.versace@intel.com>
Fri, 10 Apr 2015 03:29:59 +0000 (20:29 -0700)
committerChad Versace <chad.versace@intel.com>
Mon, 13 Apr 2015 14:36:32 +0000 (07:36 -0700)
Allow glEGLImageTargetRenderbufferStorageOES and
glEGLImageTargetTexture2DOES for dma_buf EGLImages if the image is
a single RGBA8 unorm plane. This is safe, despite fast color clears,
because i965 disables allocation of auxiliary buffers for EGLImages.

Chrome OS needs this, because its compositor uses dma_buf EGLImages for
its scanout buffers.

Testing:
  - Tested on Ivybridge Chromebook Pixel with WebGL Aquarium and
    YouTube.
  - No Piglit regressions on Broadwell with `piglit run -p gbm
    tests/quick.py`, with my Piglit patches that update the
    EGL_EXT_image_dma_buf_import tests.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
src/mesa/drivers/dri/i965/intel_fbo.c
src/mesa/drivers/dri/i965/intel_image.h
src/mesa/drivers/dri/i965/intel_tex_image.c

index fb26038f327776ffd3d5986b7d764bf4a76c3204..8a398f73e49d6b0ffde6385e57a9afb4173ad6af 100644 (file)
@@ -363,13 +363,6 @@ intel_image_target_renderbuffer_storage(struct gl_context *ctx,
       return;
    }
 
-   /* Buffers originating from outside are for read-only. */
-   if (image->dma_buf_imported) {
-      _mesa_error(ctx, GL_INVALID_OPERATION,
-            "glEGLImageTargetRenderbufferStorage(dma buffers are read-only)");
-      return;
-   }
-
    /* __DRIimage is opaque to the core so it has to be checked here */
    switch (image->format) {
    case MESA_FORMAT_R8G8B8A8_UNORM:
index 0cae7119a9a75db8369d7f8e528c766ad1155125..a82cf3b3bd1a99070afd399f8ef7902d2fdf1b5e 100644 (file)
@@ -89,18 +89,18 @@ struct __DRIimageRec {
    GLuint tile_y;
    bool has_depthstencil;
 
+   /** The image was created with EGL_EXT_image_dma_buf_import. */
+   bool dma_buf_imported;
+
    /**
     * Provided by EGL_EXT_image_dma_buf_import.
-    *
-    * The flag is set in order to restrict the use of the image later on.
-    *
-    * See intel_image_target_texture_2d()
+    * \{
     */
-   bool dma_buf_imported;
    enum __DRIYUVColorSpace yuv_color_space;
    enum __DRISampleRange sample_range;
    enum __DRIChromaSiting horizontal_siting;
    enum __DRIChromaSiting vertical_siting;
+   /* \} */
 
    void *data;
 };
index 290d313465d147b2e7376d90cf3538ec0ff3704e..b70f8de6430ca3023d7c9737dcb01e4f4372d290 100644 (file)
@@ -320,17 +320,9 @@ intel_image_target_texture_2d(struct gl_context *ctx, GLenum target,
    if (image == NULL)
       return;
 
-   /**
-    * Images originating via EGL_EXT_image_dma_buf_import can be used only
-    * with GL_OES_EGL_image_external only.
+   /* We support external textures only for EGLImages created with
+    * EGL_EXT_image_dma_buf_import. We may lift that restriction in the future.
     */
-   if (image->dma_buf_imported && target != GL_TEXTURE_EXTERNAL_OES) {
-      _mesa_error(ctx, GL_INVALID_OPERATION,
-            "glEGLImageTargetTexture2DOES(dma buffers can be used with "
-               "GL_OES_EGL_image_external only");
-      return;
-   }
-
    if (target == GL_TEXTURE_EXTERNAL_OES && !image->dma_buf_imported) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
             "glEGLImageTargetTexture2DOES(external target is enabled only "