i965: Disable aux buffers for EGLImage-backed miptrees
[mesa.git] / src / mesa / drivers / dri / i965 / intel_tex_image.c
index 53efbbb2f740698048bae6c5f6bcc53a701bd920..290d313465d147b2e7376d90cf3538ec0ff3704e 100644 (file)
@@ -103,11 +103,20 @@ intelTexImage(struct gl_context * ctx,
        _mesa_lookup_enum_by_nr(format), _mesa_lookup_enum_by_nr(type),
        texImage->Level, texImage->Width, texImage->Height, texImage->Depth);
 
+   /* Allocate storage for texture data. */
+   if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage)) {
+      _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage%uD", dims);
+      return;
+   }
+
+   assert(intelImage->mt);
+
    ok = _mesa_meta_pbo_TexSubImage(ctx, dims, texImage, 0, 0, 0,
                                    texImage->Width, texImage->Height,
                                    texImage->Depth,
                                    format, type, pixels,
-                                   true, tex_busy, unpack);
+                                   false /*allocate_storage*/,
+                                   tex_busy, unpack);
    if (ok)
       return;
 
@@ -117,7 +126,7 @@ intelTexImage(struct gl_context * ctx,
                                        texImage->Height,
                                        texImage->Depth,
                                        format, type, pixels, unpack,
-                                       true /*for_glTexImage*/);
+                                       false /*allocate_storage*/);
    if (ok)
       return;
 
@@ -145,7 +154,8 @@ intel_set_texture_image_bo(struct gl_context *ctx,
                            uint32_t offset,
                            GLuint width, GLuint height,
                            GLuint pitch,
-                           GLuint tile_x, GLuint tile_y)
+                           GLuint tile_x, GLuint tile_y,
+                           bool disable_aux_buffers)
 {
    struct brw_context *brw = brw_context(ctx);
    struct intel_texture_image *intel_image = intel_texture_image(image);
@@ -160,7 +170,8 @@ intel_set_texture_image_bo(struct gl_context *ctx,
    ctx->Driver.FreeTextureImageBuffer(ctx, image);
 
    intel_image->mt = intel_miptree_create_for_bo(brw, bo, image->TexFormat,
-                                                 0, width, height, 1, pitch);
+                                                 0, width, height, 1, pitch,
+                                                 disable_aux_buffers);
    if (intel_image->mt == NULL)
        return;
    intel_image->mt->target = target;
@@ -244,7 +255,8 @@ intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
                               rb->Base.Base.Width,
                               rb->Base.Base.Height,
                               rb->mt->pitch,
-                              0, 0);
+                              0, 0,
+                              false /*disable_aux_buffers*/);
    _mesa_unlock_texture(&brw->ctx, texObj);
 }
 
@@ -334,12 +346,18 @@ intel_image_target_texture_2d(struct gl_context *ctx, GLenum target,
       return;
    }
 
+   /* Disable creation of the texture's aux buffers because the driver exposes
+    * no EGL API to manage them. That is, there is no API for resolving the aux
+    * buffer's content to the main buffer nor for invalidating the aux buffer's
+    * content.
+    */
    intel_set_texture_image_bo(ctx, texImage, image->bo,
                               target, image->internal_format,
                               image->format, image->offset,
                               image->width,  image->height,
                               image->pitch,
-                              image->tile_x, image->tile_y);
+                              image->tile_x, image->tile_y,
+                              true /*disable_aux_buffers*/);
 }
 
 /**
@@ -392,7 +410,15 @@ intel_gettexsubimage_tiled_memcpy(struct gl_context *ctx,
        packing->Invert)
       return false;
 
-   if (!intel_get_memcpy(texImage->TexFormat, format, type, &mem_copy, &cpp))
+   /* We can't handle copying from RGBX or BGRX because the tiled_memcpy
+    * function doesn't set the last channel to 1.
+    */
+   if (texImage->TexFormat == MESA_FORMAT_B8G8R8X8_UNORM ||
+       texImage->TexFormat == MESA_FORMAT_R8G8B8X8_UNORM)
+      return false;
+
+   if (!intel_get_memcpy(texImage->TexFormat, format, type, &mem_copy, &cpp,
+                         INTEL_DOWNLOAD))
       return false;
 
    /* If this is a nontrivial texture view, let another path handle it instead. */