freedreno: Move fs functions after geometry pipeline stages
[mesa.git] / src / gallium / drivers / freedreno / freedreno_surface.c
index 250fe4bc0f5ad6df5efd013fdc6d196b7558f508..24da54798b62418fe868f3fcaf6a6be01371f3af 100644 (file)
@@ -1,5 +1,3 @@
-/* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */
-
 /*
  * Copyright (C) 2012 Rob Clark <robclark@freedesktop.org>
  *
@@ -41,27 +39,35 @@ fd_create_surface(struct pipe_context *pctx,
 //     struct fd_resource* tex = fd_resource(ptex);
        struct fd_surface* surface = CALLOC_STRUCT(fd_surface);
 
-       assert(surf_tmpl->u.tex.first_layer == surf_tmpl->u.tex.last_layer);
+       if (!surface)
+               return NULL;
+
+
+       struct pipe_surface *psurf = &surface->base;
+       unsigned level = surf_tmpl->u.tex.level;
 
-       if (surface) {
-               struct pipe_surface *psurf = &surface->base;
-               unsigned level = surf_tmpl->u.tex.level;
+       pipe_reference_init(&psurf->reference, 1);
+       pipe_resource_reference(&psurf->texture, ptex);
 
-               pipe_reference_init(&psurf->reference, 1);
-               pipe_resource_reference(&psurf->texture, ptex);
+       psurf->context = pctx;
+       psurf->format = surf_tmpl->format;
+       psurf->width = u_minify(ptex->width0, level);
+       psurf->height = u_minify(ptex->height0, level);
+       psurf->nr_samples = surf_tmpl->nr_samples;
 
-               psurf->context = pctx;
-               psurf->format = surf_tmpl->format;
-               psurf->width = u_minify(ptex->width0, level);
-               psurf->height = u_minify(ptex->height0, level);
+       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);
        }
 
+       // TODO
+       DBG("TODO: %ux%u", psurf->width, psurf->height);
+
        return &surface->base;
 }