zink: massively beef up batch tracking for shader images
the struct for these isn't allocated, so we need to ensure that the objects in it are explicitly tracked on batches when they're used Reviewed-by: Dave Airlie <airlied@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9543>
This commit is contained in:
parent
78068d039b
commit
1b96e3e2b0
|
@ -50,10 +50,17 @@ zink_reset_batch(struct zink_context *ctx, struct zink_batch *batch)
|
|||
}
|
||||
|
||||
set_foreach(batch->surfaces, entry) {
|
||||
struct pipe_surface *surf = (struct pipe_surface *)entry->key;
|
||||
pipe_surface_reference(&surf, NULL);
|
||||
struct zink_surface *surf = (struct zink_surface *)entry->key;
|
||||
surf->batch_uses &= ~BITFIELD64_BIT(batch->batch_id);
|
||||
pipe_surface_reference((struct pipe_surface**)&surf, NULL);
|
||||
_mesa_set_remove(batch->surfaces, entry);
|
||||
}
|
||||
set_foreach(batch->bufferviews, entry) {
|
||||
struct zink_buffer_view *buffer_view = (struct zink_buffer_view *)entry->key;
|
||||
buffer_view->batch_uses &= ~BITFIELD64_BIT(batch->batch_id);
|
||||
zink_buffer_view_reference(ctx, &buffer_view, NULL);
|
||||
_mesa_set_remove(batch->bufferviews, entry);
|
||||
}
|
||||
|
||||
util_dynarray_foreach(&batch->zombie_samplers, VkSampler, samp) {
|
||||
vkDestroySampler(screen->dev, *samp, NULL);
|
||||
|
@ -286,13 +293,25 @@ zink_batch_add_desc_set(struct zink_batch *batch, struct zink_descriptor_set *zd
|
|||
}
|
||||
|
||||
void
|
||||
zink_batch_reference_surface(struct zink_batch *batch,
|
||||
struct zink_surface *surface)
|
||||
zink_batch_reference_image_view(struct zink_batch *batch,
|
||||
struct zink_image_view *image_view)
|
||||
{
|
||||
struct pipe_surface *surf = &surface->base;
|
||||
bool found = false;
|
||||
_mesa_set_search_and_add(batch->surfaces, surf, &found);
|
||||
if (!found)
|
||||
pipe_reference(NULL, &surf->reference);
|
||||
uint32_t bit = BITFIELD64_BIT(batch->batch_id);
|
||||
if (image_view->base.resource->target == PIPE_BUFFER) {
|
||||
if (image_view->buffer_view->batch_uses & bit)
|
||||
return;
|
||||
_mesa_set_search_and_add(batch->bufferviews, image_view->buffer_view, &found);
|
||||
assert(!found);
|
||||
image_view->buffer_view->batch_uses |= bit;
|
||||
pipe_reference(NULL, &image_view->buffer_view->reference);
|
||||
} else {
|
||||
if (image_view->surface->batch_uses & bit)
|
||||
return;
|
||||
_mesa_set_search_and_add(batch->surfaces, image_view->surface, &found);
|
||||
assert(!found);
|
||||
image_view->surface->batch_uses |= bit;
|
||||
pipe_reference(NULL, &image_view->surface->base.reference);
|
||||
}
|
||||
batch->has_work = true;
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ struct zink_context;
|
|||
struct zink_descriptor_set;
|
||||
struct zink_fence;
|
||||
struct zink_framebuffer;
|
||||
struct zink_image_view;
|
||||
struct zink_program;
|
||||
struct zink_render_pass;
|
||||
struct zink_resource;
|
||||
|
@ -57,6 +58,7 @@ struct zink_batch {
|
|||
struct set *resources;
|
||||
struct set *sampler_views;
|
||||
struct set *surfaces;
|
||||
struct set *bufferviews;
|
||||
struct set *desc_sets;
|
||||
|
||||
struct util_dynarray persistent_resources;
|
||||
|
@ -96,8 +98,8 @@ zink_batch_reference_program(struct zink_batch *batch,
|
|||
struct zink_program *pg);
|
||||
|
||||
void
|
||||
zink_batch_reference_surface(struct zink_batch *batch,
|
||||
struct zink_surface *surface);
|
||||
zink_batch_reference_image_view(struct zink_batch *batch,
|
||||
struct zink_image_view *image_view);
|
||||
|
||||
bool
|
||||
zink_batch_add_desc_set(struct zink_batch *batch, struct zink_descriptor_set *zds);
|
||||
|
|
|
@ -2123,11 +2123,12 @@ init_batch(struct zink_context *ctx, struct zink_batch *batch, unsigned idx)
|
|||
batch->resources = _mesa_pointer_set_create(NULL);
|
||||
batch->sampler_views = _mesa_pointer_set_create(NULL);
|
||||
batch->surfaces = _mesa_pointer_set_create(NULL);
|
||||
batch->bufferviews = _mesa_pointer_set_create(NULL);
|
||||
batch->programs = _mesa_pointer_set_create(NULL);
|
||||
batch->desc_sets = _mesa_pointer_set_create(ctx);
|
||||
|
||||
if (!batch->resources || !batch->sampler_views || !batch->desc_sets ||
|
||||
!batch->programs || !batch->surfaces)
|
||||
!batch->programs || !batch->surfaces || !batch->bufferviews)
|
||||
return false;
|
||||
|
||||
util_dynarray_init(&batch->zombie_samplers, NULL);
|
||||
|
|
|
@ -78,6 +78,7 @@ struct zink_buffer_view {
|
|||
struct pipe_reference reference;
|
||||
VkBufferView buffer_view;
|
||||
uint32_t hash;
|
||||
uint32_t batch_uses;
|
||||
};
|
||||
|
||||
struct zink_sampler_view {
|
||||
|
|
|
@ -713,8 +713,8 @@ update_image_descriptors(struct zink_context *ctx, struct zink_descriptor_set *z
|
|||
NULL, imageview, bufferview, !k);
|
||||
|
||||
struct zink_batch *batch = is_compute ? &ctx->compute_batch : zink_curr_batch(ctx);
|
||||
if (image_view->surface)
|
||||
zink_batch_reference_surface(batch, image_view->surface);
|
||||
if (res)
|
||||
zink_batch_reference_image_view(batch, image_view);
|
||||
}
|
||||
assert(num_wds < num_descriptors);
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ struct zink_surface {
|
|||
VkImageViewCreateInfo ivci;
|
||||
VkImageView image_view;
|
||||
uint32_t hash;
|
||||
uint32_t batch_uses;
|
||||
};
|
||||
|
||||
static inline struct zink_surface *
|
||||
|
|
Loading…
Reference in New Issue