From ed55f52b399cc420cb264c0535d3c71b2a60c740 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 12 May 2021 22:19:42 -0700 Subject: [PATCH] iris: Replace no_gpu flag with PIPE_MAP_DIRECTLY Here, we're deciding when to map the buffer directly, rather than using the GPU to blit to/from a temporary. There is already a flag for that, PIPE_MAP_DIRECTLY, which has the added benefit of not being a negative (such as "no_gpu"). Currently, we intend to map directly if: 1. Direct mappings were requested explicitly 2. Persistent or coherent mappings were requested (and so we must) 3. ASTC textures (we currently can't blit those correctly) 4. There is no need for a temporary (there's no image compression that the CPU wouldn't understand, and we don't need to avoid stalls due to the buffer being busy on the GPU) Expressing "please memory map this directly" is easier to follow than "please don't use the GPU as part of mapping this". Acked-by: Lionel Landwerlin Part-of: --- src/gallium/drivers/iris/iris_resource.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c index 38cdc161187..77c185ffe2f 100644 --- a/src/gallium/drivers/iris/iris_resource.c +++ b/src/gallium/drivers/iris/iris_resource.c @@ -2048,9 +2048,8 @@ iris_transfer_map(struct pipe_context *ctx, * contain state we're constructing for a GPU draw call, which would * kill us with infinite stack recursion. */ - bool no_gpu = usage & (PIPE_MAP_PERSISTENT | - PIPE_MAP_COHERENT | - PIPE_MAP_DIRECTLY); + if (usage & (PIPE_MAP_PERSISTENT | PIPE_MAP_COHERENT)) + usage |= PIPE_MAP_DIRECTLY; /* GPU copies are not useful for buffer reads. Instead of stalling to * read from the original buffer, we'd simply copy it to a temporary... @@ -2063,19 +2062,19 @@ iris_transfer_map(struct pipe_context *ctx, */ if (!(usage & PIPE_MAP_DISCARD_RANGE) && !iris_has_invalid_primary(res, level, 1, box->z, box->depth)) { - no_gpu = true; + usage |= PIPE_MAP_DIRECTLY; } const struct isl_format_layout *fmtl = isl_format_get_layout(surf->format); if (fmtl->txc == ISL_TXC_ASTC) - no_gpu = true; + usage |= PIPE_MAP_DIRECTLY; if (!map_would_stall && !isl_aux_usage_has_compression(res->aux.usage)) { - no_gpu = true; + usage |= PIPE_MAP_DIRECTLY; } - if (!no_gpu) { + if (!(usage & PIPE_MAP_DIRECTLY)) { /* If we need a synchronous mapping and the resource is busy, or needs * resolving, we copy to/from a linear temporary buffer using the GPU. */