diff options
author | Vasily Khoruzhick <[email protected]> | 2020-03-03 22:05:52 -0800 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-03-10 02:41:27 +0000 |
commit | 251c6991a3a3b6f25239ef746f786e91a7553798 (patch) | |
tree | a67ec86684ce7509160390fb0f427e21e1232fa1 /src/gallium/drivers | |
parent | 53d6bb9fc633a4d0ad99c25ac4a9ca09f12d87bf (diff) |
lima: enable minmax cache for index buffers
Re-use minmax cache for index buffers from panfrost.
Reviewed-by: Andreas Baierl <[email protected]>
Signed-off-by: Vasily Khoruzhick <[email protected]>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4051>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4051>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/lima/lima_draw.c | 17 | ||||
-rw-r--r-- | src/gallium/drivers/lima/lima_resource.c | 18 | ||||
-rw-r--r-- | src/gallium/drivers/lima/lima_resource.h | 2 |
3 files changed, 34 insertions, 3 deletions
diff --git a/src/gallium/drivers/lima/lima_draw.c b/src/gallium/drivers/lima/lima_draw.c index 12059cb1c62..637d5ec59d0 100644 --- a/src/gallium/drivers/lima/lima_draw.c +++ b/src/gallium/drivers/lima/lima_draw.c @@ -45,6 +45,8 @@ #include "lima_util.h" #include "lima_gpu.h" +#include "pan_minmax_cache.h" + #include <drm-uapi/lima_drm.h> static bool @@ -1007,14 +1009,14 @@ lima_draw_vbo_indexed(struct pipe_context *pctx, struct lima_context *ctx = lima_context(pctx); struct lima_job *job = lima_job_get(ctx); struct pipe_resource *indexbuf = NULL; + bool needs_indices = true; /* Mali Utgard GPU always need min/max index info for index draw, * compute it if upper layer does not do for us */ - if (info->max_index == ~0u) - u_vbuf_get_minmax_index(pctx, info, &ctx->min_index, &ctx->max_index); - else { + if (info->max_index != ~0u) { ctx->min_index = info->min_index; ctx->max_index = info->max_index; + needs_indices = false; } if (info->has_user_indices) { @@ -1024,6 +1026,15 @@ lima_draw_vbo_indexed(struct pipe_context *pctx, else { ctx->index_res = lima_resource(info->index.resource); ctx->index_offset = 0; + needs_indices = !panfrost_minmax_cache_get(ctx->index_res->index_cache, info->start, + info->count, &ctx->min_index, &ctx->max_index); + } + + if (needs_indices) { + u_vbuf_get_minmax_index(pctx, info, &ctx->min_index, &ctx->max_index); + if (!info->has_user_indices) + panfrost_minmax_cache_add(ctx->index_res->index_cache, info->start, info->count, + ctx->min_index, ctx->max_index); } lima_job_add_bo(job, LIMA_PIPE_GP, ctx->index_res->bo, LIMA_SUBMIT_BO_READ); diff --git a/src/gallium/drivers/lima/lima_resource.c b/src/gallium/drivers/lima/lima_resource.c index 2cb4cde718e..9f429f8c32a 100644 --- a/src/gallium/drivers/lima/lima_resource.c +++ b/src/gallium/drivers/lima/lima_resource.c @@ -45,6 +45,8 @@ #include "lima_resource.h" #include "lima_bo.h" #include "lima_util.h" + +#include "pan_minmax_cache.h" #include "pan_tiling.h" static struct pipe_resource * @@ -224,6 +226,9 @@ _lima_resource_create_with_modifiers(struct pipe_screen *pscreen, struct lima_resource *res = lima_resource(pres); res->tiled = should_tile; + if (templat->bind & PIPE_BIND_INDEX_BUFFER) + res->index_cache = CALLOC_STRUCT(panfrost_minmax_cache); + debug_printf("%s: pres=%p width=%u height=%u depth=%u target=%d " "bind=%x usage=%d tile=%d last_level=%d\n", __func__, pres, pres->width0, pres->height0, pres->depth0, @@ -275,6 +280,9 @@ lima_resource_destroy(struct pipe_screen *pscreen, struct pipe_resource *pres) if (res->damage.region) FREE(res->damage.region); + if (res->index_cache) + FREE(res->index_cache); + FREE(res); } @@ -584,9 +592,17 @@ lima_transfer_map(struct pipe_context *pctx, return trans->staging; } else { + unsigned dpw = PIPE_TRANSFER_MAP_DIRECTLY | PIPE_TRANSFER_WRITE | + PIPE_TRANSFER_PERSISTENT; + if ((usage & dpw) == dpw && res->index_cache) + return NULL; + ptrans->stride = res->levels[level].stride; ptrans->layer_stride = res->levels[level].layer_stride; + if ((usage & PIPE_TRANSFER_WRITE) && (usage & PIPE_TRANSFER_MAP_DIRECTLY)) + panfrost_minmax_cache_invalidate(res->index_cache, ptrans); + return bo->map + res->levels[level].offset + box->z * res->levels[level].layer_stride + box->y / util_format_get_blockheight(pres->format) * ptrans->stride + @@ -630,6 +646,8 @@ lima_transfer_unmap(struct pipe_context *pctx, free(trans->staging); } + panfrost_minmax_cache_invalidate(res->index_cache, ptrans); + pipe_resource_reference(&ptrans->resource, NULL); slab_free(&ctx->transfer_pool, trans); } diff --git a/src/gallium/drivers/lima/lima_resource.h b/src/gallium/drivers/lima/lima_resource.h index d1f15eb5024..0b2d150b5ee 100644 --- a/src/gallium/drivers/lima/lima_resource.h +++ b/src/gallium/drivers/lima/lima_resource.h @@ -31,6 +31,7 @@ #define LIMA_MAX_MIP_LEVELS 13 struct lima_screen; +struct panfrost_minmax_cache; struct lima_resource_level { uint32_t width; @@ -52,6 +53,7 @@ struct lima_resource { struct lima_damage_region damage; struct renderonly_scanout *scanout; struct lima_bo *bo; + struct panfrost_minmax_cache *index_cache; bool tiled; struct lima_resource_level levels[LIMA_MAX_MIP_LEVELS]; |