diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index 3a30737b7ee..4df38c98c4e 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -1827,6 +1827,8 @@ zink_set_framebuffer_state(struct pipe_context *pctx, zink_fb_clears_apply(ctx, surf->texture); ctx->rp_changed = true; } + if (surf) + zink_resource(surf->texture)->fb_binds--; } if (ctx->fb_state.zsbuf) { struct pipe_surface *surf = ctx->fb_state.zsbuf; @@ -1834,6 +1836,7 @@ zink_set_framebuffer_state(struct pipe_context *pctx, zink_fb_clears_apply(ctx, ctx->fb_state.zsbuf->texture); ctx->rp_changed = true; } + zink_resource(surf->texture)->fb_binds--; } /* renderpass changes if the number or types of attachments change */ ctx->rp_changed |= ctx->fb_state.nr_cbufs != state->nr_cbufs; @@ -1843,6 +1846,15 @@ zink_set_framebuffer_state(struct pipe_context *pctx, unsigned h = ctx->fb_state.height; util_copy_framebuffer_state(&ctx->fb_state, state); + for (int i = 0; i < ctx->fb_state.nr_cbufs; i++) { + struct pipe_surface *surf = ctx->fb_state.cbufs[i]; + if (surf) + zink_resource(surf->texture)->fb_binds++; + } + if (ctx->fb_state.zsbuf) { + struct pipe_surface *surf = ctx->fb_state.zsbuf; + zink_resource(surf->texture)->fb_binds++; + } if (ctx->fb_state.width != w || ctx->fb_state.height != h) ctx->scissor_changed = true; rebind_fb_state(ctx, NULL, true); diff --git a/src/gallium/drivers/zink/zink_resource.h b/src/gallium/drivers/zink/zink_resource.h index 821f616c807..8a277a3a10f 100644 --- a/src/gallium/drivers/zink/zink_resource.h +++ b/src/gallium/drivers/zink/zink_resource.h @@ -105,6 +105,7 @@ struct zink_resource { VkImageAspectFlags aspect; bool optimal_tiling; uint32_t sampler_binds[PIPE_SHADER_TYPES]; + uint8_t fb_binds; uint16_t image_bind_count[2]; //gfx, compute }; };