freedreno: fix invalidate logic
authorJonathan Marek <jonathan@marek.ca>
Mon, 21 Jan 2019 16:32:30 +0000 (11:32 -0500)
committerRob Clark <robdclark@gmail.com>
Tue, 29 Jan 2019 20:22:32 +0000 (20:22 +0000)
Set dirty bits on invalidate to trigger invalidate logic in fd_draw_vbo.

Also, resource_written for color needs to be after the invalidate logic.

Signed-off-by: Jonathan Marek <jonathan@marek.ca>
src/gallium/drivers/freedreno/freedreno_draw.c
src/gallium/drivers/freedreno/freedreno_resource.c

index 8b4073da476354fa40856ba33afbfff87d264032..c35b0d9f4a1ab2be48b611edac9364b7b984d0d3 100644 (file)
@@ -165,15 +165,6 @@ fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info)
                }
        }
 
-       if (ctx->dirty & FD_DIRTY_FRAMEBUFFER) {
-               for (i = 0; i < pfb->nr_cbufs; i++) {
-                       if (!pfb->cbufs[i])
-                               continue;
-
-                       resource_written(batch, pfb->cbufs[i]->texture);
-               }
-       }
-
        if (fd_logicop_enabled(ctx))
                batch->gmem_reason |= FD_GMEM_LOGICOP_ENABLED;
 
@@ -195,6 +186,9 @@ fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info)
 
                if (fd_blend_enabled(ctx, i))
                        batch->gmem_reason |= FD_GMEM_BLEND_ENABLED;
+
+               if (ctx->dirty & FD_DIRTY_FRAMEBUFFER)
+                       resource_written(batch, pfb->cbufs[i]->texture);
        }
 
        /* Mark SSBOs as being written.. we don't actually know which ones are
index 9adc3ce1d11bfbaa2b6ae0131b7234aa02839402..ce8e4480be1342e655d218ce24245a95c4e5e0e3 100644 (file)
@@ -1188,24 +1188,30 @@ fd_blitter_pipe_end(struct fd_context *ctx)
 static void
 fd_invalidate_resource(struct pipe_context *pctx, struct pipe_resource *prsc)
 {
+       struct fd_context *ctx = fd_context(pctx);
        struct fd_resource *rsc = fd_resource(prsc);
 
        /*
         * TODO I guess we could track that the resource is invalidated and
         * use that as a hint to realloc rather than stall in _transfer_map(),
         * even in the non-DISCARD_WHOLE_RESOURCE case?
+        *
+        * Note: we set dirty bits to trigger invalidate logic fd_draw_vbo
         */
 
        if (rsc->write_batch) {
                struct fd_batch *batch = rsc->write_batch;
                struct pipe_framebuffer_state *pfb = &batch->framebuffer;
 
-               if (pfb->zsbuf && pfb->zsbuf->texture == prsc)
+               if (pfb->zsbuf && pfb->zsbuf->texture == prsc) {
                        batch->resolve &= ~(FD_BUFFER_DEPTH | FD_BUFFER_STENCIL);
+                       ctx->dirty |= FD_DIRTY_ZSA;
+               }
 
                for (unsigned i = 0; i < pfb->nr_cbufs; i++) {
                        if (pfb->cbufs[i] && pfb->cbufs[i]->texture == prsc) {
                                batch->resolve &= ~(PIPE_CLEAR_COLOR0 << i);
+                               ctx->dirty |= FD_DIRTY_FRAMEBUFFER;
                        }
                }
        }