[Mesa-dev] [PATCH 3/7] i965: Create multiple miptrees planar YUV images
Kristian Høgsberg Kristensen
krh at bitplanet.net
Mon May 9 19:21:29 UTC 2016
"Pohjolainen, Topi" <topi.pohjolainen at intel.com> writes:
> On Thu, May 05, 2016 at 05:04:02PM -0700, Kristian H?gsberg wrote:
>> From: Kristian Høgsberg Kristensen <kristian.h.kristensen at intel.com>
>>
>> ---
>> src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 3 ++
>> src/mesa/drivers/dri/i965/intel_mipmap_tree.h | 5 ++
>> src/mesa/drivers/dri/i965/intel_tex_image.c | 73 ++++++++++++++++++++++-----
>> src/mesa/drivers/dri/i965/intel_tex_obj.h | 2 +
>> 4 files changed, 71 insertions(+), 12 deletions(-)
>>
>> diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
>> index 26c297d..e3e2a8f 100644
>> --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
>> +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
>> @@ -990,6 +990,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 7862152..9ab4b23 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 bee8be1..ad7ee97 100644
>> --- a/src/mesa/drivers/dri/i965/intel_tex_image.c
>> +++ b/src/mesa/drivers/dri/i965/intel_tex_image.c
>> @@ -332,18 +332,67 @@ 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,
>> - MIPTREE_LAYOUT_DISABLE_AUX);
>> + struct intel_texture_image *intel_image = intel_texture_image(texImage);
>> + struct gl_texture_object *texobj = texImage->TexObject;
>> + struct intel_texture_object *intel_texobj = intel_texture_object(texobj);
>> + struct intel_image_format *f = image->planar_format;
>> + struct intel_mipmap_tree *planar_mt;
>> +
>> + for (int i = 0; i < f->nplanes; i++) {
>> + int index = f->planes[i].buffer_index;
>
> All the others are marked 'const', this is fixed also, isn't it?
It is, I'll make it const too.
>> + 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;
>> + mt->level[0].slice[0].x_offset = 0;
>> + mt->level[0].slice[0].y_offset = 0;
>> +
>> + if (i == 0)
>> + planar_mt = mt;
>> + else
>> + planar_mt->plane[i - 1] = mt;
>> + }
>> +
>> + intel_texobj->dri_image = image;
>> +
>> + const uint32_t internal_format = _mesa_get_format_base_format(planar_mt->format);
>> + _mesa_init_teximage_fields(&brw->ctx, texImage,
>> + image->width, image->height, 1,
>> + 0, internal_format, planar_mt->format);
>> +
>> + ctx->Driver.FreeTextureImageBuffer(ctx, texImage);
>> +
>> + intel_miptree_reference(&intel_image->mt, planar_mt);
>> +
>> + assert(planar_mt->pitch % planar_mt->cpp == 0);
>> + intel_image->base.RowStride = planar_mt->pitch / planar_mt->cpp;
>> +
>> + /* The miptree is in a validated state, so no need to check later. */
>> + intel_miptree_reference(&intel_texobj->mt, intel_image->mt);
>> + intel_texobj->validated_first_level = 0;
>> + intel_texobj->validated_last_level = 0;
>> + intel_texobj->_Format = planar_mt->format;
>> + intel_texobj->needs_validate = true;
>
> Comment a few lines before says otherwise?
Ah, yes, should be false.
thanks,
Kristian
>> +
>> + intel_miptree_reference(&planar_mt, NULL);
>> }
>>
>> /**
>> diff --git a/src/mesa/drivers/dri/i965/intel_tex_obj.h b/src/mesa/drivers/dri/i965/intel_tex_obj.h
>> index 750e4c3..ad78570 100644
>> --- a/src/mesa/drivers/dri/i965/intel_tex_obj.h
>> +++ b/src/mesa/drivers/dri/i965/intel_tex_obj.h
>> @@ -58,6 +58,8 @@ struct intel_texture_object
>> * since the mt is shared across views with differing formats.
>> */
>> mesa_format _Format;
>> +
>> + struct __DRIimageRec *dri_image;
>> };
>>
>>
>> --
>> 2.5.0
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list