diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/freedreno/freedreno_draw.c | 13 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/freedreno_resource.c | 5 | ||||
-rw-r--r-- | 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 3f70c89ce08..bcd21a232d2 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 54b66c0940c..8ba43a10d71 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 5bdb0075761..539470c2b8b 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? */ |