From df7fdae127a78f400f5827bd88c6db89dada6da6 Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Thu, 17 Jun 2021 13:24:45 -0700 Subject: [PATCH] freedreno: Skip staging blits from uninitialized resources. When storing depth- or stencil-only texture data that has been packed into a depth/stencil texture, the tex store gets PIPE_MAP_READ added onto it since the other channel will get ORed into the incoming data, but sometimes we know that the other component is undefined because the whole texture is either fresh or just invalidated. Cleans up a confusing extra blit in a dEQP case I've been debugging, and should be less work for dEQP CI. Part-of: --- src/gallium/drivers/freedreno/freedreno_resource.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c index 913355a392e..6b27cead2e3 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.c +++ b/src/gallium/drivers/freedreno/freedreno_resource.c @@ -797,6 +797,13 @@ resource_transfer_map(struct pipe_context *pctx, struct pipe_resource *prsc, tc_assert_driver_thread(ctx->tc); + /* Strip the read flag if the buffer has been invalidated (or is freshly + * created). Avoids extra staging blits of undefined data on glTexSubImage of + * a fresh DEPTH_COMPONENT or STENCIL_INDEX texture being stored as z24s8. + */ + if (!rsc->valid) + usage &= ~PIPE_MAP_READ; + /* we always need a staging texture for tiled buffers: * * TODO we might sometimes want to *also* shadow the resource to avoid