[Mesa-dev] [PATCH 27/30] i965/screen: Support import and export of surfaces with CCS
Pohjolainen, Topi
topi.pohjolainen at gmail.com
Mon Jun 26 19:50:28 UTC 2017
On Fri, Jun 16, 2017 at 03:41:49PM -0700, Jason Ekstrand wrote:
> ---
> src/mesa/drivers/dri/i965/intel_screen.c | 55 +++++++++++++++++++++++++++++---
> 1 file changed, 50 insertions(+), 5 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
> index 94787ff..7d6adb7 100644
> --- a/src/mesa/drivers/dri/i965/intel_screen.c
> +++ b/src/mesa/drivers/dri/i965/intel_screen.c
> @@ -671,7 +671,21 @@ intel_create_image_common(__DRIscreen *dri_screen,
> return NULL;
> }
>
> - image->bo = brw_bo_alloc_tiled(screen->bufmgr, "image", surf.size,
> + struct isl_surf aux_surf;
> + if (mod_info->aux_usage == ISL_AUX_USAGE_CCS_E) {
> + ok = isl_surf_get_ccs_surf(&screen->isl_dev, &surf, &aux_surf, 0);
> + assert(ok);
> + if (!ok) {
> + free(image);
> + return NULL;
> + }
> + } else {
> + assert(mod_info->aux_usage == ISL_AUX_USAGE_NONE);
> + aux_surf.size = 0;
> + }
> +
> + image->bo = brw_bo_alloc_tiled(screen->bufmgr, "image",
> + surf.size + aux_surf.size,
> isl_tiling_to_i915_tiling(mod_info->tiling),
> surf.row_pitch, 0);
> if (image->bo == NULL) {
> @@ -683,6 +697,11 @@ intel_create_image_common(__DRIscreen *dri_screen,
> image->pitch = surf.row_pitch;
> image->modifier = modifier;
>
> + if (aux_surf.size) {
> + image->aux_offset = surf.size;
> + image->aux_pitch = aux_surf.row_pitch;
> + }
> +
> return image;
> }
>
> @@ -896,18 +915,18 @@ intel_create_image_from_fds_common(__DRIscreen *dri_screen,
> else
> image->modifier = tiling_to_modifier(image->bo->tiling_mode);
>
> + const struct isl_drm_modifier_info *mod_info =
> + isl_drm_modifier_get_info(image->modifier);
> +
> int size = 0;
> + struct isl_surf surf;
> for (i = 0; i < f->nplanes; i++) {
> index = f->planes[i].buffer_index;
> image->offsets[index] = offsets[index];
> image->strides[index] = strides[index];
>
> - const struct isl_drm_modifier_info *mod_info =
> - isl_drm_modifier_get_info(image->modifier);
> -
> mesa_format format = driImageFormatToGLFormat(f->planes[i].dri_format);
>
> - struct isl_surf surf;
> ok = isl_surf_init(&screen->isl_dev, &surf,
> .dim = ISL_SURF_DIM_2D,
> .format = brw_isl_format_for_mesa_format(format),
> @@ -933,6 +952,32 @@ intel_create_image_from_fds_common(__DRIscreen *dri_screen,
> size = end;
> }
>
> + if (mod_info->aux_usage == ISL_AUX_USAGE_CCS_E) {
> + /* Even though we initialize surf in the loop above, we know that
> + * anything with CCS_E will have exactly one plane so surf is properly
> + * initialized when we get here.
> + */
> + assert(f->nplanes == 1);
> +
> + image->aux_offset = offsets[1];
> + image->aux_pitch = strides[1];
> +
> + struct isl_surf aux_surf;
> + ok = isl_surf_get_ccs_surf(&screen->isl_dev, &surf, &aux_surf,
> + image->aux_pitch);
> + if (!ok) {
> + brw_bo_unreference(image->bo);
> + free(image);
> + return NULL;
> + }
> +
> + const int end = image->aux_offset + surf.size;
Shouldn't we use 'aux_surf.size' instead of 'surf.size'?
> + if (size < end)
> + size = end;
> + } else {
> + assert(mod_info->aux_usage == ISL_AUX_USAGE_NONE);
> + }
> +
> /* Check that the requested image actually fits within the BO. 'size'
> * is already relative to the offsets, so we don't need to add that. */
> if (image->bo->size == 0) {
> --
> 2.5.0.400.gff86faf
>
> _______________________________________________
> 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