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 <airlied@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9565>
This commit is contained in:
parent
db0a71c9ae
commit
c5029ddf8c
|
@ -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);
|
zink_get_depth_stencil_resources((struct pipe_resource*)res, NULL, &stencil);
|
||||||
|
|
||||||
uint32_t cur_uses = zink_get_resource_usage(res);
|
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_READ << batch->batch_id);
|
||||||
cur_uses &= ~(ZINK_RESOURCE_ACCESS_WRITE << batch->batch_id);
|
cur_uses &= ~(ZINK_RESOURCE_ACCESS_WRITE << batch->batch_id);
|
||||||
if (batch->batch_id == ZINK_COMPUTE_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;
|
batch_to_flush = ZINK_COMPUTE_BATCH_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct set_entry *entry = _mesa_set_search(batch->resources, res);
|
/* if the resource already has usage of any sort set for this batch, we can skip hashing */
|
||||||
if (!entry) {
|
uint32_t check_mask = (ZINK_RESOURCE_ACCESS_READ | ZINK_RESOURCE_ACCESS_WRITE) << batch->batch_id;
|
||||||
entry = _mesa_set_add(batch->resources, res);
|
if (!(uses_check & check_mask)) {
|
||||||
pipe_reference(NULL, &res->base.reference);
|
struct set_entry *entry = _mesa_set_search(batch->resources, res);
|
||||||
batch->resource_size += res->size;
|
if (!entry) {
|
||||||
if (stencil) {
|
entry = _mesa_set_add(batch->resources, res);
|
||||||
pipe_reference(NULL, &stencil->base.reference);
|
pipe_reference(NULL, &res->base.reference);
|
||||||
batch->resource_size += stencil->size;
|
batch->resource_size += res->size;
|
||||||
|
if (stencil) {
|
||||||
|
pipe_reference(NULL, &stencil->base.reference);
|
||||||
|
batch->resource_size += stencil->size;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* multiple array entries are fine */
|
/* multiple array entries are fine */
|
||||||
|
|
Loading…
Reference in New Issue