_mesa_set_remove(batch->resources, entry);
}
- /* unref all used sampler-views */
- set_foreach(batch->sampler_views, entry) {
- struct pipe_sampler_view *pres = (struct pipe_sampler_view *)entry->key;
- struct zink_sampler_view *sampler_view = zink_sampler_view(pres);
- sampler_view->batch_uses &= ~BITFIELD_BIT(batch->batch_id);
- if (sampler_view->base.target == PIPE_BUFFER) {
- struct zink_buffer_view *buffer_view = sampler_view->buffer_view;
- zink_buffer_view_reference(screen, &buffer_view, NULL);
- } else {
- struct zink_surface *surface = sampler_view->image_view;
- pipe_surface_reference((struct pipe_surface**)&surface, NULL);
- }
- pipe_sampler_view_reference(&pres, NULL);
- _mesa_set_remove(batch->sampler_views, entry);
- }
-
set_foreach(batch->surfaces, entry) {
struct zink_surface *surf = (struct zink_surface *)entry->key;
surf->batch_uses &= ~BITFIELD64_BIT(batch->batch_id);
return batch_to_flush;
}
-void
-zink_batch_reference_sampler_view(struct zink_batch *batch,
- struct zink_sampler_view *sv)
+static bool
+ptr_add_usage(struct zink_batch *batch, struct set *s, void *ptr, uint32_t *u)
{
bool found = false;
uint32_t bit = BITFIELD_BIT(batch->batch_id);
- if (sv->batch_uses & bit)
- return;
- _mesa_set_search_and_add(batch->sampler_views, sv, &found);
+ if ((*u) & bit)
+ return false;
+ _mesa_set_search_and_add(s, ptr, &found);
assert(!found);
- sv->batch_uses |= bit;
- pipe_reference(NULL, &sv->base.reference);
- if (sv->base.target == PIPE_BUFFER)
+ *u |= bit;
+ return true;
+}
+
+void
+zink_batch_reference_sampler_view(struct zink_batch *batch,
+ struct zink_sampler_view *sv)
+{
+ if (sv->base.target == PIPE_BUFFER) {
+ if (!ptr_add_usage(batch, batch->bufferviews, sv->buffer_view, &sv->buffer_view->batch_uses))
+ return;
pipe_reference(NULL, &sv->buffer_view->reference);
- else
+ } else {
+ if (!ptr_add_usage(batch, batch->surfaces, sv->image_view, &sv->image_view->batch_uses))
+ return;
pipe_reference(NULL, &sv->image_view->base.reference);
+ }
batch->has_work = true;
}
zink_fence_reference(screen, &batch->fence, NULL);
_mesa_set_destroy(batch->fbs, NULL);
_mesa_set_destroy(batch->resources, NULL);
- _mesa_set_destroy(batch->sampler_views, NULL);
util_dynarray_fini(&batch->zombie_samplers);
_mesa_set_destroy(batch->surfaces, NULL);
_mesa_set_destroy(batch->programs, NULL);
batch->fbs = _mesa_pointer_set_create(NULL);
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 ||
+ if (!batch->resources || !batch->desc_sets ||
!batch->programs || !batch->surfaces || !batch->bufferviews)
return false;