summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKristian Høgsberg Kristensen <[email protected]>2016-05-01 21:24:00 -0700
committerKristian Høgsberg Kristensen <[email protected]>2016-05-24 10:14:57 -0700
commit3352f2d746d3959b22ca47f50828290a1b0d7b93 (patch)
tree0cf3cddfba17fe916f4633804fc2b085be219e23 /src
parent6eede8763121f6d197cf2fcf0d6c30d304cd065c (diff)
i965: Create multiple miptrees for planar YUV images
Reviewed-by: Jordan Justen <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/i965/intel_mipmap_tree.c3
-rw-r--r--src/mesa/drivers/dri/i965/intel_mipmap_tree.h5
-rw-r--r--src/mesa/drivers/dri/i965/intel_tex_image.c46
3 files changed, 53 insertions, 1 deletions
diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
index beacfdbc302..3b032c7b0fa 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
@@ -1026,6 +1026,9 @@ intel_miptree_release(struct intel_mipmap_tree **mt)
intel_miptree_release(&(*mt)->mcs_mt);
intel_resolve_map_clear(&(*mt)->hiz_map);
+ intel_miptree_release(&(*mt)->plane[0]);
+ intel_miptree_release(&(*mt)->plane[1]);
+
for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
free((*mt)->level[i].slice);
}
diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
index 4fb5b6946e2..9543b33b8ce 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
@@ -625,6 +625,11 @@ struct intel_mipmap_tree
struct intel_mipmap_tree *mcs_mt;
/**
+ * Planes 1 and 2 in case this is a planar surface.
+ */
+ struct intel_mipmap_tree *plane[2];
+
+ /**
* Fast clear state for this buffer.
*/
enum intel_fast_clear_state fast_clear_state;
diff --git a/src/mesa/drivers/dri/i965/intel_tex_image.c b/src/mesa/drivers/dri/i965/intel_tex_image.c
index 4d20a8607fd..095b94b3e81 100644
--- a/src/mesa/drivers/dri/i965/intel_tex_image.c
+++ b/src/mesa/drivers/dri/i965/intel_tex_image.c
@@ -162,6 +162,47 @@ 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().
*
@@ -348,7 +389,10 @@ intel_image_target_texture_2d(struct gl_context *ctx, GLenum target,
return;
}
- mt = create_mt_for_dri_image(brw, target, image);
+ 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);
if (mt == NULL)
return;