Module: Mesa Branch: master Commit: c5029ddf8c01ad6b66e794ffb4789b4dafe31923 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c5029ddf8c01ad6b66e794ffb4789b4dafe31923
Author: Mike Blumenkrantz <[email protected]> Date: Tue Oct 6 16:59:02 2020 -0400 zink: optimize resource usage tracking we already have the batch usage info here for the resource, so if we know the resource is already used on the batch then we don't need to also perform a hash lookup to double check that it's really there Reviewed-by: Dave Airlie <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9565> --- src/gallium/drivers/zink/zink_batch.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/gallium/drivers/zink/zink_batch.c b/src/gallium/drivers/zink/zink_batch.c index 9b3d815b6e4..395d3b4ac46 100644 --- a/src/gallium/drivers/zink/zink_batch.c +++ b/src/gallium/drivers/zink/zink_batch.c @@ -163,6 +163,7 @@ zink_batch_reference_resource_rw(struct zink_batch *batch, struct zink_resource zink_get_depth_stencil_resources((struct pipe_resource*)res, NULL, &stencil); uint32_t cur_uses = zink_get_resource_usage(res); + uint32_t uses_check = cur_uses; cur_uses &= ~(ZINK_RESOURCE_ACCESS_READ << batch->batch_id); cur_uses &= ~(ZINK_RESOURCE_ACCESS_WRITE << batch->batch_id); if (batch->batch_id == ZINK_COMPUTE_BATCH_ID) { @@ -174,14 +175,18 @@ zink_batch_reference_resource_rw(struct zink_batch *batch, struct zink_resource batch_to_flush = ZINK_COMPUTE_BATCH_ID; } - struct set_entry *entry = _mesa_set_search(batch->resources, res); - if (!entry) { - entry = _mesa_set_add(batch->resources, res); - pipe_reference(NULL, &res->base.reference); - batch->resource_size += res->size; - if (stencil) { - pipe_reference(NULL, &stencil->base.reference); - batch->resource_size += stencil->size; + /* if the resource already has usage of any sort set for this batch, we can skip hashing */ + uint32_t check_mask = (ZINK_RESOURCE_ACCESS_READ | ZINK_RESOURCE_ACCESS_WRITE) << batch->batch_id; + if (!(uses_check & check_mask)) { + struct set_entry *entry = _mesa_set_search(batch->resources, res); + if (!entry) { + entry = _mesa_set_add(batch->resources, res); + pipe_reference(NULL, &res->base.reference); + batch->resource_size += res->size; + if (stencil) { + pipe_reference(NULL, &stencil->base.reference); + batch->resource_size += stencil->size; + } } } /* multiple array entries are fine */ _______________________________________________ mesa-commit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-commit
