}
_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);
}
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);
+ }
+}
struct zink_framebuffer;
struct zink_render_pass;
struct zink_resource;
+struct zink_sampler_view;
struct zink_batch {
VkCommandBuffer cmdbuf;
struct zink_framebuffer *fb;
struct set *resources;
+ struct set *sampler_views;
struct util_dynarray zombie_samplers;
};
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
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;
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);