mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-04 20:38:06 +02:00
zink: ensure sampler-views survive a batch
we don't need to track the resources for the samplers any longer, as the sampler view holds a reference instead. Acked-by: Jordan Justen <jordan.l.justen@intel.com>
This commit is contained in:
parent
09e20d88e7
commit
2a7302075d
3 changed files with 31 additions and 2 deletions
|
|
@ -30,6 +30,13 @@ reset_batch(struct zink_screen *screen, struct zink_batch *batch)
|
|||
}
|
||||
_mesa_set_clear(batch->resources, NULL);
|
||||
|
||||
/* unref all used sampler-views */
|
||||
set_foreach(batch->sampler_views, entry) {
|
||||
struct pipe_sampler_view *pres = (struct pipe_sampler_view *)entry->key;
|
||||
pipe_sampler_view_reference(&pres, NULL);
|
||||
}
|
||||
_mesa_set_clear(batch->sampler_views, NULL);
|
||||
|
||||
util_dynarray_foreach(&batch->zombie_samplers, VkSampler, samp) {
|
||||
vkDestroySampler(screen->dev, *samp, NULL);
|
||||
}
|
||||
|
|
@ -97,3 +104,15 @@ zink_batch_reference_resoure(struct zink_batch *batch,
|
|||
pipe_resource_reference(&tmp, &res->base);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
zink_batch_reference_sampler_view(struct zink_batch *batch,
|
||||
struct zink_sampler_view *sv)
|
||||
{
|
||||
struct set_entry *entry = _mesa_set_search(batch->sampler_views, sv);
|
||||
if (!entry) {
|
||||
struct pipe_sampler_view *tmp = NULL;
|
||||
entry = _mesa_set_add(batch->sampler_views, sv);
|
||||
pipe_sampler_view_reference(&tmp, &sv->base);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ struct zink_fence;
|
|||
struct zink_framebuffer;
|
||||
struct zink_render_pass;
|
||||
struct zink_resource;
|
||||
struct zink_sampler_view;
|
||||
|
||||
struct zink_batch {
|
||||
VkCommandBuffer cmdbuf;
|
||||
|
|
@ -42,6 +43,7 @@ struct zink_batch {
|
|||
struct zink_framebuffer *fb;
|
||||
|
||||
struct set *resources;
|
||||
struct set *sampler_views;
|
||||
|
||||
struct util_dynarray zombie_samplers;
|
||||
};
|
||||
|
|
@ -56,4 +58,8 @@ void
|
|||
zink_batch_reference_resoure(struct zink_batch *batch,
|
||||
struct zink_resource *res);
|
||||
|
||||
void
|
||||
zink_batch_reference_sampler_view(struct zink_batch *batch,
|
||||
struct zink_sampler_view *sv);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -971,7 +971,7 @@ zink_draw_vbo(struct pipe_context *pctx,
|
|||
image_infos[num_image_info].sampler = ctx->samplers[i][index];
|
||||
wds[num_wds].pImageInfo = image_infos + num_image_info;
|
||||
++num_image_info;
|
||||
zink_batch_reference_resoure(batch, res);
|
||||
zink_batch_reference_sampler_view(batch, sampler_view);
|
||||
}
|
||||
|
||||
wds[num_wds].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
||||
|
|
@ -1343,7 +1343,11 @@ zink_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
|
|||
|
||||
ctx->batches[i].resources = _mesa_set_create(NULL, _mesa_hash_pointer,
|
||||
_mesa_key_pointer_equal);
|
||||
if (!ctx->batches[i].resources)
|
||||
ctx->batches[i].sampler_views = _mesa_set_create(NULL,
|
||||
_mesa_hash_pointer,
|
||||
_mesa_key_pointer_equal);
|
||||
|
||||
if (!ctx->batches[i].resources || !ctx->batches[i].sampler_views)
|
||||
goto fail;
|
||||
|
||||
util_dynarray_init(&ctx->batches[i].zombie_samplers, NULL);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue