zink: track persistent, non-coherent, writable transfer map count for resources

these require explicit memory flushes before being submitted to a batch

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8942>
This commit is contained in:
Mike Blumenkrantz 2020-08-13 10:53:25 -04:00 committed by Marge Bot
parent 4a7a226e49
commit b92ba0100e
5 changed files with 11 additions and 0 deletions

View file

@ -55,6 +55,7 @@ zink_batch_release(struct zink_screen *screen, struct zink_batch *batch)
vkDestroySampler(screen->dev, *samp, NULL);
}
util_dynarray_clear(&batch->zombie_samplers);
util_dynarray_clear(&batch->persistent_resources);
}
static void
@ -161,6 +162,9 @@ zink_batch_reference_resource_rw(struct zink_batch *batch, struct zink_resource
if (stencil)
pipe_reference(NULL, &stencil->base.reference);
}
/* multiple array entries are fine */
if (res->persistent_maps)
util_dynarray_append(&batch->persistent_resources, struct zink_resource*, res);
/* the batch_uses value for this batch is guaranteed to not be in use now because
* reset_batch() waits on the fence and removes access before resetting
*/

View file

@ -56,6 +56,7 @@ struct zink_batch {
struct set *sampler_views;
struct set *surfaces;
struct util_dynarray persistent_resources;
struct util_dynarray zombie_samplers;
struct set *active_queries; /* zink_query objects which were active at some point in this batch */

View file

@ -1618,6 +1618,7 @@ init_batch(struct zink_context *ctx, struct zink_batch *batch, unsigned idx)
return false;
util_dynarray_init(&batch->zombie_samplers, NULL);
util_dynarray_init(&batch->persistent_resources, NULL);
if (vkCreateDescriptorPool(screen->dev, &dpci, 0,
&batch->descpool) != VK_SUCCESS)

View file

@ -665,6 +665,8 @@ zink_transfer_map(struct pipe_context *pctx,
ptr = ((uint8_t *)ptr) + offset;
}
}
if ((usage & PIPE_MAP_PERSISTENT) && !(usage & PIPE_MAP_COHERENT))
res->persistent_maps++;
*transfer = &trans->base;
return ptr;
@ -696,6 +698,8 @@ zink_transfer_unmap(struct pipe_context *pctx,
pipe_resource_reference(&trans->staging_res, NULL);
} else
vkUnmapMemory(screen->dev, res->mem);
if ((trans->base.usage & PIPE_MAP_PERSISTENT) && !(trans->base.usage & PIPE_MAP_COHERENT))
res->persistent_maps--;
pipe_resource_reference(&trans->base.resource, NULL);
slab_free(&ctx->transfer_pool, ptrans);

View file

@ -59,6 +59,7 @@ struct zink_resource {
struct sw_displaytarget *dt;
unsigned dt_stride;
unsigned persistent_maps; //if nonzero, requires vkFlushMappedMemoryRanges during batch use
/* this has to be atomic for fence access, so we can't use a bitmask and make everything neat */
uint8_t batch_uses[5]; //ZINK_NUM_BATCHES