Module: Mesa Branch: master Commit: 4ab6ab80365578cc9366b6d2d4a626694e0604a7 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4ab6ab80365578cc9366b6d2d4a626694e0604a7
Author: Rob Clark <robdcl...@gmail.com> Date: Sun Nov 19 12:50:50 2017 -0500 freedreno: avoid mem2gmem for invalidated buffers Signed-off-by: Rob Clark <robdcl...@gmail.com> --- src/gallium/drivers/freedreno/freedreno_draw.c | 13 +++++++++++-- src/gallium/drivers/freedreno/freedreno_resource.c | 5 +++++ src/gallium/drivers/freedreno/freedreno_resource.h | 1 + 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/freedreno/freedreno_draw.c b/src/gallium/drivers/freedreno/freedreno_draw.c index 3f70c89ce0..bcd21a232d 100644 --- a/src/gallium/drivers/freedreno/freedreno_draw.c +++ b/src/gallium/drivers/freedreno/freedreno_draw.c @@ -54,6 +54,7 @@ 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); } @@ -64,7 +65,7 @@ fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info) struct fd_batch *batch = ctx->batch; struct pipe_framebuffer_state *pfb = &batch->framebuffer; struct pipe_scissor_state *scissor = fd_context_get_scissor(ctx); - unsigned i, prims, buffers = 0; + unsigned i, prims, buffers = 0, restore_buffers = 0; if (!info->count_from_stream_output && !info->indirect && !info->primitive_restart && @@ -127,12 +128,16 @@ fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info) mtx_lock(&ctx->screen->lock); if (fd_depth_enabled(ctx)) { + if (fd_resource(pfb->zsbuf->texture)->valid) + restore_buffers |= FD_BUFFER_DEPTH; buffers |= FD_BUFFER_DEPTH; resource_written(batch, pfb->zsbuf->texture); batch->gmem_reason |= FD_GMEM_DEPTH_ENABLED; } if (fd_stencil_enabled(ctx)) { + if (fd_resource(pfb->zsbuf->texture)->valid) + restore_buffers |= FD_BUFFER_DEPTH; buffers |= FD_BUFFER_STENCIL; resource_written(batch, pfb->zsbuf->texture); batch->gmem_reason |= FD_GMEM_STENCIL_ENABLED; @@ -150,6 +155,10 @@ fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info) surf = pfb->cbufs[i]->texture; resource_written(batch, surf); + + if (fd_resource(surf)->valid) + restore_buffers |= PIPE_CLEAR_COLOR0 << i; + buffers |= PIPE_CLEAR_COLOR0 << i; if (surf->nr_samples > 1) @@ -223,7 +232,7 @@ fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info) ctx->stats.prims_generated += prims; /* any buffers that haven't been cleared yet, we need to restore: */ - batch->restore |= buffers & (FD_BUFFER_ALL & ~batch->cleared); + batch->restore |= restore_buffers & (FD_BUFFER_ALL & ~batch->cleared); /* and any buffers used, need to be resolved: */ batch->resolve |= buffers; diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c index 54b66c0940..8ba43a10d7 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.c +++ b/src/gallium/drivers/freedreno/freedreno_resource.c @@ -672,6 +672,9 @@ fd_resource_transfer_map(struct pipe_context *pctx, offset = 0; } + if (usage & PIPE_TRANSFER_WRITE) + rsc->valid = true; + *pptrans = ptrans; return buf + offset; @@ -1195,6 +1198,8 @@ fd_invalidate_resource(struct pipe_context *pctx, struct pipe_resource *prsc) } } } + + rsc->valid = false; } void diff --git a/src/gallium/drivers/freedreno/freedreno_resource.h b/src/gallium/drivers/freedreno/freedreno_resource.h index 5bdb007576..539470c2b8 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.h +++ b/src/gallium/drivers/freedreno/freedreno_resource.h @@ -73,6 +73,7 @@ struct fd_resource { struct fd_resource_slice slices[MAX_MIP_LEVELS]; /* buffer range that has been initialized */ struct util_range valid_buffer_range; + bool valid; /* reference to the resource holding stencil data for a z32_s8 texture */ /* TODO rename to secondary or auxiliary? */ _______________________________________________ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit