freedreno: surfaces can be PIPE_BUFFER
authorRob Clark <robdclark@gmail.com>
Tue, 27 Feb 2018 17:59:57 +0000 (12:59 -0500)
committerRob Clark <robdclark@gmail.com>
Mon, 5 Mar 2018 13:05:33 +0000 (08:05 -0500)
At least for clover.

Signed-off-by: Rob Clark <robdclark@gmail.com>
src/gallium/drivers/freedreno/freedreno_surface.c

index 5ebc4937ed896878e1a5839b5b20433f4d00ab78..1295fc265994cdd7068b2bf59adfc0cb0c9636ee 100644 (file)
@@ -44,7 +44,6 @@ fd_create_surface(struct pipe_context *pctx,
        if (!surface)
                return NULL;
 
-       debug_assert(surf_tmpl->u.tex.first_layer == surf_tmpl->u.tex.last_layer);
 
        struct pipe_surface *psurf = &surface->base;
        unsigned level = surf_tmpl->u.tex.level;
@@ -56,9 +55,16 @@ fd_create_surface(struct pipe_context *pctx,
        psurf->format = surf_tmpl->format;
        psurf->width = u_minify(ptex->width0, level);
        psurf->height = u_minify(ptex->height0, level);
-       psurf->u.tex.level = level;
-       psurf->u.tex.first_layer = surf_tmpl->u.tex.first_layer;
-       psurf->u.tex.last_layer = surf_tmpl->u.tex.last_layer;
+
+       if (ptex->target == PIPE_BUFFER) {
+               psurf->u.buf.first_element = surf_tmpl->u.buf.first_element;
+               psurf->u.buf.last_element = surf_tmpl->u.buf.last_element;
+       } else {
+               debug_assert(surf_tmpl->u.tex.first_layer == surf_tmpl->u.tex.last_layer);
+               psurf->u.tex.level = level;
+               psurf->u.tex.first_layer = surf_tmpl->u.tex.first_layer;
+               psurf->u.tex.last_layer = surf_tmpl->u.tex.last_layer;
+       }
 
        // TODO
        DBG("TODO: %ux%u", psurf->width, psurf->height);