summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTopi Pohjolainen <[email protected]>2017-04-25 17:31:51 +0300
committerTopi Pohjolainen <[email protected]>2017-06-19 22:57:44 +0300
commit3cf470f2b6c7d67116c42fecc68099e6b641bdc1 (patch)
tree7ca75cd988031cae0f2be599866f9e0eff341e13 /src
parent5d125f999e4ac0c8b17782a50ca933daec61f491 (diff)
i965: Add isl based miptree creator
v2: Use new brw_bo_alloc_tiled() interface Reviewed-by: Nanley Chery <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Topi Pohjolainen <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/i965/intel_mipmap_tree.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
index 5580ce21c2c..8206b0e7270 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
@@ -667,6 +667,78 @@ free_aux_state_map(enum isl_aux_state **state)
}
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 brw_bo *bo)
+{
+ struct intel_mipmap_tree *mt = calloc(sizeof(*mt), 1);
+ if (!mt)
+ return NULL;
+
+ if (!create_mapping_table(target, first_level, last_level, depth0,
+ mt->level)) {
+ free(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);
+
+ 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 - first_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;
+
+ assert(mt->surf.size % mt->surf.row_pitch == 0);
+
+ if (!bo) {
+ mt->bo = brw_bo_alloc_tiled(brw->bufmgr, "isl-miptree",
+ mt->surf.size,
+ isl_tiling_to_bufmgr_tiling(isl_tiling),
+ mt->surf.row_pitch, alloc_flags);
+ if (!mt->bo)
+ goto fail;
+ } else {
+ mt->bo = bo;
+ }
+
+ mt->first_level = first_level;
+ mt->last_level = last_level;
+ mt->target = target;
+ mt->format = format;
+ mt->refcount = 1;
+ mt->aux_state = NULL;
+
+ return mt;
+
+fail:
+ intel_miptree_release(&mt);
+ return NULL;
+}
+
+static struct intel_mipmap_tree *
miptree_create(struct brw_context *brw,
GLenum target,
mesa_format format,