summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/nv50/nv50_miptree.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/nv50/nv50_miptree.c')
-rw-r--r--src/gallium/drivers/nv50/nv50_miptree.c53
1 files changed, 30 insertions, 23 deletions
diff --git a/src/gallium/drivers/nv50/nv50_miptree.c b/src/gallium/drivers/nv50/nv50_miptree.c
index dd0e8fd41b..309b6503ca 100644
--- a/src/gallium/drivers/nv50/nv50_miptree.c
+++ b/src/gallium/drivers/nv50/nv50_miptree.c
@@ -276,46 +276,53 @@ nv50_miptree_from_handle(struct pipe_screen *pscreen,
*/
struct pipe_surface *
-nv50_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_resource *pt,
- unsigned face, unsigned level, unsigned zslice,
- unsigned flags)
+nv50_miptree_surface_new(struct pipe_context *pipe, struct pipe_resource *pt,
+ const struct pipe_surface *surf_tmpl)
{
+ unsigned level = surf_tmpl->u.tex.level;
struct nv50_miptree *mt = nv50_miptree(pt);
struct nv50_miptree_level *lvl = &mt->level[level];
- struct pipe_surface *ps;
- unsigned img = 0;
+ struct nv50_surface *ns;
+ unsigned img = 0, zslice = 0;
+ assert(surf_tmpl->u.tex.first_layer == surf_tmpl->u.tex.last_layer);
+
+ /* XXX can't unify these here? */
if (pt->target == PIPE_TEXTURE_CUBE)
- img = face;
+ img = surf_tmpl->u.tex.first_layer;
+ else if (pt->target == PIPE_TEXTURE_3D)
+ zslice = surf_tmpl->u.tex.first_layer;
- ps = CALLOC_STRUCT(pipe_surface);
- if (!ps)
+ ns = CALLOC_STRUCT(nv50_surface);
+ if (!ns)
return NULL;
- pipe_resource_reference(&ps->texture, pt);
- ps->format = pt->format;
- ps->width = u_minify(pt->width0, level);
- ps->height = u_minify(pt->height0, level);
- ps->usage = flags;
- pipe_reference_init(&ps->reference, 1);
- ps->face = face;
- ps->level = level;
- ps->zslice = zslice;
- ps->offset = lvl->image_offset[img];
+ pipe_resource_reference(&ns->base.texture, pt);
+ ns->base.context = pipe;
+ ns->base.format = pt->format;
+ ns->base.width = u_minify(pt->width0, level);
+ ns->base.height = u_minify(pt->height0, level);
+ ns->base.usage = surf_tmpl->usage;
+ pipe_reference_init(&ns->base.reference, 1);
+ ns->base.u.tex.level = level;
+ ns->base.u.tex.first_layer = surf_tmpl->u.tex.first_layer;
+ ns->base.u.tex.last_layer = surf_tmpl->u.tex.last_layer;
+ ns->offset = lvl->image_offset[img];
if (pt->target == PIPE_TEXTURE_3D) {
- unsigned nb_h = util_format_get_nblocksy(pt->format, ps->height);
- ps->offset += get_zslice_offset(lvl->tile_mode, zslice,
+ unsigned nb_h = util_format_get_nblocksy(pt->format, ns->base.height);
+ ns->offset += get_zslice_offset(lvl->tile_mode, zslice,
lvl->pitch, nb_h);
}
- return ps;
+ return &ns->base;
}
void
-nv50_miptree_surface_del(struct pipe_surface *ps)
+nv50_miptree_surface_del(struct pipe_context *pipe,
+ struct pipe_surface *ps)
{
struct nv50_surface *s = nv50_surface(ps);
- pipe_resource_reference(&ps->texture, NULL);
+ pipe_resource_reference(&s->base.texture, NULL);
FREE(s);
}