freedreno: mark stencil buffer valid too in case of z32x24s8
authorRob Clark <robdclark@gmail.com>
Mon, 4 Dec 2017 16:01:52 +0000 (11:01 -0500)
committerRob Clark <robdclark@gmail.com>
Mon, 4 Dec 2017 16:50:45 +0000 (11:50 -0500)
The separate stencil buffer was not also getting marked as valid if
written by a draw/clear, resulting in gmem2mem getting skipped.  Move
this into fd_batch_resource_used() which also handles the separate
stencil case.

Also fix restore_buffers typo.

Fixes: 4ab6ab80365 freedreno: avoid mem2gmem for invalidated buffers
Signed-off-by: Rob Clark <robdclark@gmail.com>
src/gallium/drivers/freedreno/freedreno_batch.c
src/gallium/drivers/freedreno/freedreno_draw.c

index 9c66dc98bc763f314685c6be36ed392b941f88b5..6e208d350ea2368dad78f6882559fced485e7bf6 100644 (file)
@@ -382,6 +382,9 @@ fd_batch_resource_used(struct fd_batch *batch, struct fd_resource *rsc, bool wri
 
        DBG("%p: %s %p", batch, write ? "write" : "read", rsc);
 
+       if (write)
+               rsc->valid = true;
+
        /* note, invalidate write batch, to avoid further writes to rsc
         * resulting in a write-after-read hazard.
         */
index fc24776e4a9f54a59be7f2a4a1e8badb1c3120a2..d3bf3165276191a616883c6279f3bea63969a5ec 100644 (file)
@@ -55,7 +55,6 @@ resource_written(struct fd_batch *batch, struct pipe_resource *prsc)
 {
        if (!prsc)
                return;
-       fd_resource(prsc)->valid = true;
        fd_batch_resource_used(batch, fd_resource(prsc), true);
 }
 
@@ -147,7 +146,7 @@ fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info)
 
        if (fd_stencil_enabled(ctx)) {
                if (fd_resource(pfb->zsbuf->texture)->valid)
-                       restore_buffers |= FD_BUFFER_DEPTH;
+                       restore_buffers |= FD_BUFFER_STENCIL;
                buffers |= FD_BUFFER_STENCIL;
                resource_written(batch, pfb->zsbuf->texture);
                batch->gmem_reason |= FD_GMEM_STENCIL_ENABLED;