[Mesa-dev] [v2 36/39] i965: Add isl based miptree creator
Jason Ekstrand
jason at jlekstrand.net
Mon May 8 23:23:40 UTC 2017
On Wed, May 3, 2017 at 2:22 AM, Topi Pohjolainen <topi.pohjolainen at gmail.com
> wrote:
> Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
> ---
> src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 91
> +++++++++++++++++++++++++++
> 1 file changed, 91 insertions(+)
>
> diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> index 4ddcb13..ced1e0e 100644
> --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> @@ -575,6 +575,97 @@ intel_lower_compressed_format(struct brw_context
> *brw, mesa_format format)
> }
> }
>
> +static bool
> +init_mapping_table(GLenum target, unsigned first_level, unsigned
> last_level,
> + unsigned depth0, struct intel_mipmap_level *table)
> +{
> + unsigned level = first_level;
> + for ( ; level <= last_level; level++) {
> + const unsigned d = target == GL_TEXTURE_3D ? depth0 >> level :
> depth0;
> +
> + table[level].slice = calloc(d, sizeof(*table[0].slice));
> + if (!table[level].slice)
> + goto fail;
>
It's nice to allocate the table, but I see nothing that actually sets it up.
> + }
> +
> + return true;
> +
> +fail:
> + for (unsigned i = first_level; i < level; i++)
> + free(table[level].slice);
> +
> + return false;
> +}
> +
> +static struct intel_mipmap_tree *
> +make_surface(struct brw_context *brw, GLenum target, mesa_format format,
> + unsigned first_level, unsigned last_level,
> + unsigned width0, unsigned height0, unsigned depth0,
> + unsigned num_samples, enum isl_tiling isl_tiling,
> + isl_surf_usage_flags_t isl_usage_flags, uint32_t alloc_flags)
> +{
> + struct intel_mipmap_tree *mt = calloc(sizeof(*mt), 1);
> + if (!mt)
> + return NULL;
> +
> + if (target == GL_TEXTURE_CUBE_MAP ||
> + target == GL_TEXTURE_CUBE_MAP_ARRAY)
> + isl_usage_flags |= ISL_SURF_USAGE_CUBE_BIT;
> +
> + DBG("%s: %s %s %ux %u:%u:%u %d..%d <-- %p\n",
> + __func__,
> + _mesa_enum_to_string(target),
> + _mesa_get_format_name(format),
> + num_samples, width0, height0, depth0,
> + first_level, last_level, mt);
> +
> + if (!init_mapping_table(target, first_level, last_level, depth0,
> + mt->level))
> + goto fail;
> +
> + struct isl_surf_init_info init_info = {
> + .dim = get_isl_surf_dim(target),
> + .format = translate_tex_format(brw, format, false),
> + .width = width0,
> + .height = height0,
> + .depth = target == GL_TEXTURE_3D ? depth0 : 1,
> + .levels = last_level + 1,
> + .array_len = target == GL_TEXTURE_3D ? 1 : depth0,
> + .samples = MAX2(num_samples, 1),
> + .usage = isl_usage_flags,
> + .tiling_flags = 1u << isl_tiling
> + };
> +
> + if (!isl_surf_init_s(&brw->isl_dev, &mt->surf, &init_info))
> + goto fail;
>
This leaks the mapping table
> +
> + assert(mt->surf.size % mt->surf.row_pitch == 0);
> +
> + unsigned pitch = mt->surf.row_pitch;
> + mt->bo = brw_bo_alloc_tiled(brw->bufmgr, "isl-miptree",
> + mt->surf.row_pitch,
> + mt->surf.size / mt->surf.row_pitch,
> + 1, isl_tiling_to_bufmgr_tiling(
> isl_tiling),
> + &pitch, alloc_flags);
> + if (!mt->bo)
> + goto fail;
>
As does this.
> +
> + assert(pitch == mt->surf.row_pitch);
> +
> + mt->target = target;
> + mt->format = format;
> + mt->refcount = 1;
> +
> + exec_list_make_empty(&mt->hiz_map);
> + exec_list_make_empty(&mt->color_resolve_map);
> +
> + return mt;
> +
> +fail:
> + free(mt);
> + return NULL;
> +}
> +
> static struct intel_mipmap_tree *
> miptree_create(struct brw_context *brw,
> GLenum target,
> --
> 2.9.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170508/18bb3af8/attachment.html>
More information about the mesa-dev
mailing list