i965/miptree: Replace is_lossless_compressed with mt->aux_usage checks
[mesa.git] / src / mesa / drivers / dri / i965 / intel_tex_image.c
index b1fe8dd584e4c13c6fe7a617d04068f01ad4c3d5..68d0a5766709134838fdfa48fb671a65440a7dcd 100644 (file)
@@ -214,98 +214,6 @@ intel_set_texture_image_mt(struct brw_context *brw,
    intel_miptree_reference(&intel_texobj->mt, mt);
 }
 
-static struct intel_mipmap_tree *
-create_mt_for_planar_dri_image(struct brw_context *brw,
-                               GLenum target, __DRIimage *image)
-{
-   struct intel_image_format *f = image->planar_format;
-   struct intel_mipmap_tree *planar_mt;
-
-   for (int i = 0; i < f->nplanes; i++) {
-      const int index = f->planes[i].buffer_index;
-      const uint32_t dri_format = f->planes[i].dri_format;
-      const mesa_format format = driImageFormatToGLFormat(dri_format);
-      const uint32_t width = image->width >> f->planes[i].width_shift;
-      const uint32_t height = image->height >> f->planes[i].height_shift;
-
-      /* 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.
-       */
-      struct intel_mipmap_tree *mt =
-         intel_miptree_create_for_bo(brw, image->bo, format,
-                                     image->offsets[index],
-                                     width, height, 1,
-                                     image->strides[index],
-                                     MIPTREE_LAYOUT_DISABLE_AUX);
-      if (mt == NULL)
-         return NULL;
-
-      mt->target = target;
-      mt->total_width = width;
-      mt->total_height = height;
-
-      if (i == 0)
-         planar_mt = mt;
-      else
-         planar_mt->plane[i - 1] = mt;
-   }
-
-   return planar_mt;
-}
-
-/**
- * Binds a BO to a texture image, as if it was uploaded by glTexImage2D().
- *
- * Used for GLX_EXT_texture_from_pixmap and EGL image extensions,
- */
-static struct intel_mipmap_tree *
-create_mt_for_dri_image(struct brw_context *brw,
-                        GLenum target, __DRIimage *image)
-{
-   struct gl_context *ctx = &brw->ctx;
-   struct intel_mipmap_tree *mt;
-   uint32_t draw_x, draw_y;
-
-   if (!ctx->TextureFormatSupported[image->format])
-      return NULL;
-
-   /* 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.
-    */
-   mt = intel_miptree_create_for_bo(brw, image->bo, image->format,
-                                    0, image->width, image->height, 1,
-                                    image->pitch,
-                                    MIPTREE_LAYOUT_DISABLE_AUX);
-   if (mt == NULL)
-      return NULL;
-
-   mt->target = target;
-   mt->total_width = image->width;
-   mt->total_height = image->height;
-   mt->level[0].slice[0].x_offset = image->tile_x;
-   mt->level[0].slice[0].y_offset = image->tile_y;
-
-   intel_miptree_get_tile_offsets(mt, 0, 0, &draw_x, &draw_y);
-
-   /* From "OES_EGL_image" error reporting. We report GL_INVALID_OPERATION
-    * for EGL images from non-tile aligned sufaces in gen4 hw and earlier which has
-    * trouble resolving back to destination image due to alignment issues.
-    */
-   if (!brw->has_surface_tile_offset &&
-       (draw_x != 0 || draw_y != 0)) {
-      _mesa_error(&brw->ctx, GL_INVALID_OPERATION, __func__);
-      intel_miptree_release(&mt);
-      return NULL;
-   }
-
-   mt->offset = image->offset;
-
-   return mt;
-}
 
 void
 intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
@@ -448,10 +356,8 @@ intel_image_target_texture_2d(struct gl_context *ctx, GLenum target,
       return;
    }
 
-   if (image->planar_format && image->planar_format->nplanes > 0)
-      mt = create_mt_for_planar_dri_image(brw, target, image);
-   else
-      mt = create_mt_for_dri_image(brw, target, image);
+   mt = intel_miptree_create_for_dri_image(brw, image, target,
+                                           ISL_COLORSPACE_NONE, false);
    if (mt == NULL)
       return;