if (batch->submitted)
zink_fence_finish(screen, &ctx->base, batch->fence, PIPE_TIMEOUT_INFINITE);
- zink_framebuffer_reference(screen, &batch->fb, NULL);
-
/* unref all used resources */
set_foreach(batch->resources, entry) {
struct pipe_resource *pres = (struct pipe_resource *)entry->key;
}
_mesa_set_clear(batch->programs, NULL);
+ set_foreach(batch->fbs, entry) {
+ struct zink_framebuffer *fb = (void*)entry->key;
+ zink_framebuffer_reference(screen, &fb, NULL);
+ _mesa_set_remove(batch->fbs, entry);
+ }
+
if (vkResetDescriptorPool(screen->dev, batch->descpool, 0) != VK_SUCCESS)
fprintf(stderr, "vkResetDescriptorPool failed\n");
}
void
+zink_batch_reference_framebuffer(struct zink_batch *batch,
+ struct zink_framebuffer *fb)
+{
+ bool found;
+ _mesa_set_search_or_add(batch->fbs, fb, &found);
+ if (!found)
+ pipe_reference(NULL, &fb->reference);
+}
+
+void
zink_batch_reference_program(struct zink_batch *batch,
struct zink_program *pg)
{
unsigned short descs_used; //number of descriptors currently allocated
struct zink_fence *fence;
- struct zink_framebuffer *fb;
+ struct set *fbs;
struct set *programs;
struct set *resources;
void
zink_reset_batch(struct zink_context *ctx, struct zink_batch *batch);
void
+zink_batch_reference_framebuffer(struct zink_batch *batch,
+ struct zink_framebuffer *fb);
+void
zink_start_batch(struct zink_context *ctx, struct zink_batch *batch);
void
vkFreeCommandBuffers(screen->dev, batch->cmdpool, 1, &batch->cmdbuf);
vkDestroyCommandPool(screen->dev, batch->cmdpool, NULL);
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);
void
zink_begin_render_pass(struct zink_context *ctx, struct zink_batch *batch)
{
- struct zink_screen *screen = zink_screen(ctx->base.screen);
assert(batch == zink_curr_batch(ctx));
setup_framebuffer(ctx);
framebuffer_state_buffer_barriers_setup(ctx, fb_state, batch);
- zink_framebuffer_reference(screen, &batch->fb, ctx->framebuffer);
- for (struct zink_surface **surf = (struct zink_surface **)batch->fb->surfaces; *surf; surf++)
+ zink_batch_reference_framebuffer(batch, ctx->framebuffer);
+ for (struct zink_surface **surf = (struct zink_surface **)ctx->framebuffer->surfaces; *surf; surf++)
zink_batch_reference_resource_rw(batch, zink_resource((*surf)->base.texture), true);
vkCmdBeginRenderPass(batch->cmdbuf, &rpbi, VK_SUBPASS_CONTENTS_INLINE);
struct zink_batch *batch = zink_curr_batch(ctx);
if (!batch->in_rp) {
zink_begin_render_pass(ctx, batch);
- assert(batch->fb && batch->fb->rp);
+ assert(ctx->framebuffer && ctx->framebuffer->rp);
}
return batch;
}
if (vkAllocateCommandBuffers(screen->dev, &cbai, &batch->cmdbuf) != VK_SUCCESS)
return false;
+ batch->fbs = _mesa_pointer_set_create(NULL);
batch->resources = _mesa_pointer_set_create(NULL);
batch->sampler_views = _mesa_pointer_set_create(NULL);
batch->programs = _mesa_pointer_set_create(NULL);