freedreno: fix depth usage logic
authorJonathan Marek <jonathan@marek.ca>
Mon, 21 Jan 2019 16:04:47 +0000 (11:04 -0500)
committerRob Clark <robdclark@gmail.com>
Tue, 29 Jan 2019 20:22:33 +0000 (20:22 +0000)
Depth can be used even when there is no restore/resolve of depth. This
happens when the depth buffer is invalidated after rendering to avoid
the resolve operation.

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

index dd35dfa29fa94441111158333aa966fcaa66cbe8..be82a1eed879271e9ec4f27ad534ad09e5504537 100644 (file)
@@ -122,8 +122,8 @@ calculate_tiles(struct fd_batch *batch)
        uint8_t cbuf_cpp[MAX_RENDER_TARGETS] = {0}, zsbuf_cpp[2] = {0};
        uint32_t i, j, t, xoff, yoff;
        uint32_t tpp_x, tpp_y;
-       bool has_zs = !!((batch->resolve | batch->restore) &
-                       (FD_BUFFER_DEPTH | FD_BUFFER_STENCIL));
+       bool has_zs = !!(batch->gmem_reason & (FD_GMEM_DEPTH_ENABLED |
+               FD_GMEM_STENCIL_ENABLED | FD_GMEM_CLEARS_DEPTH_STENCIL));
        int tile_n[npipes];
 
        if (has_zs) {
@@ -131,6 +131,10 @@ calculate_tiles(struct fd_batch *batch)
                zsbuf_cpp[0] = rsc->cpp;
                if (rsc->stencil)
                        zsbuf_cpp[1] = rsc->stencil->cpp;
+       } else {
+               /* we might have a zsbuf, but it isn't used */
+               batch->restore &= ~(FD_BUFFER_DEPTH | FD_BUFFER_STENCIL);
+               batch->resolve &= ~(FD_BUFFER_DEPTH | FD_BUFFER_STENCIL);
        }
        for (i = 0; i < pfb->nr_cbufs; i++) {
                if (pfb->cbufs[i])