freedreno: add core infrastructure support for MRTs
authorIlia Mirkin <imirkin@alum.mit.edu>
Mon, 30 Mar 2015 00:39:48 +0000 (20:39 -0400)
committerIlia Mirkin <imirkin@alum.mit.edu>
Thu, 2 Apr 2015 04:09:14 +0000 (00:09 -0400)
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
src/gallium/drivers/freedreno/freedreno_context.c
src/gallium/drivers/freedreno/freedreno_context.h
src/gallium/drivers/freedreno/freedreno_draw.c
src/gallium/drivers/freedreno/freedreno_gmem.c

index 79a27fe0e1523beb10bf86552ef92adce52828c1..bb1b52797a85f82cc7a5d4e50d142a954ba8b46e 100644 (file)
@@ -95,6 +95,7 @@ fd_context_render(struct pipe_context *pctx)
 {
        struct fd_context *ctx = fd_context(pctx);
        struct pipe_framebuffer_state *pfb = &ctx->framebuffer;
+       int i;
 
        DBG("needs_flush: %d", ctx->needs_flush);
 
@@ -116,8 +117,9 @@ fd_context_render(struct pipe_context *pctx)
        ctx->gmem_reason = 0;
        ctx->num_draws = 0;
 
-       if (pfb->cbufs[0])
-               fd_resource(pfb->cbufs[0]->texture)->dirty = false;
+       for (i = 0; i < pfb->nr_cbufs; i++)
+               if (pfb->cbufs[i])
+                       fd_resource(pfb->cbufs[i]->texture)->dirty = false;
        if (pfb->zsbuf)
                fd_resource(pfb->zsbuf->texture)->dirty = false;
 }
index bf9abaf8855d5fb0957bf64335a8956cef983750..244d527ad2005f9178e142b7974741b9b9013e7b 100644 (file)
@@ -189,7 +189,7 @@ struct fd_context {
         */
        enum {
                /* align bitmask values w/ PIPE_CLEAR_*.. since that is convenient.. */
-               FD_BUFFER_COLOR   = PIPE_CLEAR_COLOR0,
+               FD_BUFFER_COLOR   = PIPE_CLEAR_COLOR,
                FD_BUFFER_DEPTH   = PIPE_CLEAR_DEPTH,
                FD_BUFFER_STENCIL = PIPE_CLEAR_STENCIL,
                FD_BUFFER_ALL     = FD_BUFFER_COLOR | FD_BUFFER_DEPTH | FD_BUFFER_STENCIL,
index 213bad84e84ad1e6109fcb28214d58c7e192bd11..423ae23769c15613a4415dbf548ae35afd9d329c 100644 (file)
@@ -92,7 +92,7 @@ fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info)
                surf = pfb->cbufs[i]->texture;
 
                fd_resource(surf)->dirty = true;
-               buffers |= FD_BUFFER_COLOR;
+               buffers |= PIPE_CLEAR_COLOR0 << i;
 
                if (surf->nr_samples > 1)
                        ctx->gmem_reason |= FD_GMEM_MSAA_ENABLED;
@@ -147,6 +147,7 @@ fd_clear(struct pipe_context *pctx, unsigned buffers,
        struct pipe_framebuffer_state *pfb = &ctx->framebuffer;
        struct pipe_scissor_state *scissor = fd_context_get_scissor(ctx);
        unsigned cleared_buffers;
+       int i;
 
        /* for bookkeeping about which buffers have been cleared (and thus
         * can fully or partially skip mem2gmem) we need to ignore buffers
@@ -173,7 +174,9 @@ fd_clear(struct pipe_context *pctx, unsigned buffers,
        ctx->needs_flush = true;
 
        if (buffers & PIPE_CLEAR_COLOR)
-               fd_resource(pfb->cbufs[0]->texture)->dirty = true;
+               for (i = 0; i < pfb->nr_cbufs; i++)
+                       if (buffers & (PIPE_CLEAR_COLOR0 << i))
+                               fd_resource(pfb->cbufs[i]->texture)->dirty = true;
 
        if (buffers & (PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL)) {
                fd_resource(pfb->zsbuf->texture)->dirty = true;
index 4040d1f76152f6862188cdb9d639020394ee561c..afe088ac261c86070caa5b36cdb265ad9360e335 100644 (file)
@@ -319,7 +319,7 @@ void
 fd_gmem_render_tiles(struct fd_context *ctx)
 {
        struct pipe_framebuffer_state *pfb = &ctx->framebuffer;
-       uint32_t timestamp = 0;
+       uint32_t i, timestamp = 0;
        bool sysmem = false;
 
        if (ctx->emit_sysmem_prep) {
@@ -373,8 +373,9 @@ fd_gmem_render_tiles(struct fd_context *ctx)
 
        /* update timestamps on render targets: */
        timestamp = fd_ringbuffer_timestamp(ctx->ring);
-       if (pfb->cbufs[0])
-               fd_resource(pfb->cbufs[0]->texture)->timestamp = timestamp;
+       for (i = 0; i < pfb->nr_cbufs; i++)
+               if (pfb->cbufs[i])
+                       fd_resource(pfb->cbufs[i]->texture)->timestamp = timestamp;
        if (pfb->zsbuf)
                fd_resource(pfb->zsbuf->texture)->timestamp = timestamp;