zink: track all framebuffers per batch

now that 1 batch != 1 renderpass, this needs to be a set

Fixes: 1cb3015a31 ("zink: just end the current renderpass in zink_batch_no_rp()")

Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9298>
This commit is contained in:
Mike Blumenkrantz 2021-02-25 16:30:34 -05:00 committed by Marge Bot
parent b9cb1cae43
commit 0c18454e8b
3 changed files with 25 additions and 7 deletions

View file

@ -24,8 +24,6 @@ zink_reset_batch(struct zink_context *ctx, struct zink_batch *batch)
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;
@ -63,6 +61,12 @@ zink_reset_batch(struct zink_context *ctx, struct zink_batch *batch)
}
_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");
@ -196,6 +200,16 @@ zink_batch_reference_sampler_view(struct zink_batch *batch,
batch->has_work = true;
}
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)

View file

@ -51,7 +51,7 @@ struct zink_batch {
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;
@ -70,6 +70,9 @@ struct zink_batch {
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

View file

@ -61,6 +61,7 @@ destroy_batch(struct zink_context* ctx, struct zink_batch* batch)
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);
@ -846,7 +847,6 @@ setup_framebuffer(struct zink_context *ctx)
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);
@ -914,8 +914,8 @@ zink_begin_render_pass(struct zink_context *ctx, struct zink_batch *batch)
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);
@ -952,7 +952,7 @@ zink_batch_rp(struct zink_context *ctx)
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;
}
@ -1780,6 +1780,7 @@ init_batch(struct zink_context *ctx, struct zink_batch *batch, unsigned idx)
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);