Module: Mesa Branch: master Commit: 0c18454e8bde9a1db5afd8b4bfb62c79b1941945 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0c18454e8bde9a1db5afd8b4bfb62c79b1941945
Author: Mike Blumenkrantz <[email protected]> Date: Thu Feb 25 16:30:34 2021 -0500 zink: track all framebuffers per batch now that 1 batch != 1 renderpass, this needs to be a set Fixes: 1cb3015a31c ("zink: just end the current renderpass in zink_batch_no_rp()") Acked-by: Erik Faye-Lund <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9298> --- src/gallium/drivers/zink/zink_batch.c | 18 ++++++++++++++++-- src/gallium/drivers/zink/zink_batch.h | 5 ++++- src/gallium/drivers/zink/zink_context.c | 9 +++++---- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/zink/zink_batch.c b/src/gallium/drivers/zink/zink_batch.c index 40764fb1841..cb83a1153b7 100644 --- a/src/gallium/drivers/zink/zink_batch.c +++ b/src/gallium/drivers/zink/zink_batch.c @@ -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) diff --git a/src/gallium/drivers/zink/zink_batch.h b/src/gallium/drivers/zink/zink_batch.h index 79ab9be4cc1..83def45a1ca 100644 --- a/src/gallium/drivers/zink/zink_batch.h +++ b/src/gallium/drivers/zink/zink_batch.h @@ -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 diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index bcec36e0bac..97d8d3cf0a0 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -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); _______________________________________________ mesa-commit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-commit
