From 4f0f80776fa55538a725fb7248a2f22c6aafdc2c Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Wed, 11 Oct 2017 10:57:34 -0400 Subject: freedreno: implement pipe->invalidate_resource() Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/freedreno_resource.c | 27 ++++++++++++++++++++++ src/gallium/drivers/freedreno/freedreno_screen.c | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c index 31686786e39..880666d3af5 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.c +++ b/src/gallium/drivers/freedreno/freedreno_resource.c @@ -1159,6 +1159,32 @@ fd_flush_resource(struct pipe_context *pctx, struct pipe_resource *prsc) assert(!rsc->write_batch); } +static void +fd_invalidate_resource(struct pipe_context *pctx, struct pipe_resource *prsc) +{ + 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? + */ + + 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) + batch->resolve &= ~(FD_BUFFER_DEPTH | FD_BUFFER_STENCIL); + + for (unsigned i = 0; i < pfb->nr_cbufs; i++) { + if (pfb->cbufs[i] && pfb->cbufs[i]->texture == prsc) { + batch->resolve &= ~(PIPE_CLEAR_COLOR0 << i); + } + } + } +} + void fd_resource_screen_init(struct pipe_screen *pscreen) { @@ -1181,4 +1207,5 @@ fd_resource_context_init(struct pipe_context *pctx) pctx->resource_copy_region = fd_resource_copy_region; pctx->blit = fd_blit; pctx->flush_resource = fd_flush_resource; + pctx->invalidate_resource = fd_invalidate_resource; } diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c index 37875019226..4efd41f32b5 100644 --- a/src/gallium/drivers/freedreno/freedreno_screen.c +++ b/src/gallium/drivers/freedreno/freedreno_screen.c @@ -182,6 +182,7 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_STRING_MARKER: case PIPE_CAP_MIXED_COLOR_DEPTH_BITS: case PIPE_CAP_TEXTURE_BARRIER: + case PIPE_CAP_INVALIDATE_BUFFER: return 1; case PIPE_CAP_VERTEXID_NOBASE: @@ -293,7 +294,6 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_TGSI_PACK_HALF_FLOAT: case PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL: case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL: - case PIPE_CAP_INVALIDATE_BUFFER: case PIPE_CAP_GENERATE_MIPMAP: case PIPE_CAP_SURFACE_REINTERPRET_BLOCKS: case PIPE_CAP_FRAMEBUFFER_NO_ATTACHMENT: -- cgit v1.2.3