zink: handle swapchain acquire failures more directly
if acquire fails, the pending operation cannot be completed, so just drop it Reviewed-by: Adam Jackson <ajax@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16038>
This commit is contained in:
parent
494d02eacf
commit
625457caaf
|
@ -293,8 +293,10 @@ zink_blit(struct pipe_context *pctx,
|
||||||
struct zink_resource *src = zink_resource(info->src.resource);
|
struct zink_resource *src = zink_resource(info->src.resource);
|
||||||
struct zink_resource *dst = zink_resource(info->dst.resource);
|
struct zink_resource *dst = zink_resource(info->dst.resource);
|
||||||
bool needs_present_readback = false;
|
bool needs_present_readback = false;
|
||||||
if (zink_is_swapchain(dst))
|
if (zink_is_swapchain(dst)) {
|
||||||
zink_kopper_acquire(ctx, dst, UINT64_MAX);
|
if (!zink_kopper_acquire(ctx, dst, UINT64_MAX))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (src_desc == dst_desc ||
|
if (src_desc == dst_desc ||
|
||||||
src_desc->nr_channels != 4 || src_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN ||
|
src_desc->nr_channels != 4 || src_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN ||
|
||||||
|
|
|
@ -154,8 +154,10 @@ clear_color_no_rp(struct zink_context *ctx, struct zink_resource *res, const uni
|
||||||
color.uint32[2] = pcolor->ui[2];
|
color.uint32[2] = pcolor->ui[2];
|
||||||
color.uint32[3] = pcolor->ui[3];
|
color.uint32[3] = pcolor->ui[3];
|
||||||
|
|
||||||
if (zink_is_swapchain(res))
|
if (zink_is_swapchain(res)) {
|
||||||
zink_kopper_acquire(ctx, res, UINT64_MAX);
|
if (!zink_kopper_acquire(ctx, res, UINT64_MAX))
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (zink_resource_image_needs_barrier(res, VK_IMAGE_LAYOUT_GENERAL, 0, 0) &&
|
if (zink_resource_image_needs_barrier(res, VK_IMAGE_LAYOUT_GENERAL, 0, 0) &&
|
||||||
zink_resource_image_needs_barrier(res, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 0, 0))
|
zink_resource_image_needs_barrier(res, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 0, 0))
|
||||||
zink_resource_image_barrier(ctx, res, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 0, 0);
|
zink_resource_image_barrier(ctx, res, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 0, 0);
|
||||||
|
|
|
@ -806,8 +806,10 @@ zink_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *pres,
|
||||||
templ.u.tex.last_layer = state->u.tex.last_layer;
|
templ.u.tex.last_layer = state->u.tex.last_layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zink_is_swapchain(res))
|
if (zink_is_swapchain(res)) {
|
||||||
zink_kopper_acquire(ctx, res, UINT64_MAX);
|
if (!zink_kopper_acquire(ctx, res, UINT64_MAX))
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
ivci = create_ivci(screen, res, &templ, state->target);
|
ivci = create_ivci(screen, res, &templ, state->target);
|
||||||
ivci.subresourceRange.levelCount = state->u.tex.last_level - state->u.tex.first_level + 1;
|
ivci.subresourceRange.levelCount = state->u.tex.last_level - state->u.tex.first_level + 1;
|
||||||
|
@ -2162,8 +2164,8 @@ setup_framebuffer(struct zink_context *ctx)
|
||||||
struct zink_resource *res = zink_resource(ctx->fb_state.cbufs[i]->texture);
|
struct zink_resource *res = zink_resource(ctx->fb_state.cbufs[i]->texture);
|
||||||
if (zink_is_swapchain(res)) {
|
if (zink_is_swapchain(res)) {
|
||||||
has_swapchain = true;
|
has_swapchain = true;
|
||||||
zink_kopper_acquire(ctx, res, UINT64_MAX);
|
if (zink_kopper_acquire(ctx, res, UINT64_MAX))
|
||||||
zink_surface_swapchain_update(ctx, zink_csurface(ctx->fb_state.cbufs[i]));
|
zink_surface_swapchain_update(ctx, zink_csurface(ctx->fb_state.cbufs[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (has_swapchain && (ctx->swapchain_size.width || ctx->swapchain_size.height)) {
|
if (has_swapchain && (ctx->swapchain_size.width || ctx->swapchain_size.height)) {
|
||||||
|
@ -2200,7 +2202,8 @@ prep_fb_attachment(struct zink_context *ctx, struct zink_surface *surf, unsigned
|
||||||
VkAccessFlags access;
|
VkAccessFlags access;
|
||||||
VkPipelineStageFlags pipeline;
|
VkPipelineStageFlags pipeline;
|
||||||
if (zink_is_swapchain(res)) {
|
if (zink_is_swapchain(res)) {
|
||||||
zink_kopper_acquire(ctx, res, UINT64_MAX);
|
if (!zink_kopper_acquire(ctx, res, UINT64_MAX))
|
||||||
|
return VK_NULL_HANDLE;
|
||||||
zink_surface_swapchain_update(ctx, surf);
|
zink_surface_swapchain_update(ctx, surf);
|
||||||
if (!i)
|
if (!i)
|
||||||
zink_update_fbfetch(ctx);
|
zink_update_fbfetch(ctx);
|
||||||
|
@ -2221,7 +2224,7 @@ prep_fb_attachment(struct zink_context *ctx, struct zink_surface *surf, unsigned
|
||||||
return surf->image_view;
|
return surf->image_view;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static bool
|
||||||
prep_fb_attachments(struct zink_context *ctx, VkImageView *att)
|
prep_fb_attachments(struct zink_context *ctx, VkImageView *att)
|
||||||
{
|
{
|
||||||
const unsigned cresolve_offset = ctx->fb_state.nr_cbufs + !!ctx->fb_state.zsbuf;
|
const unsigned cresolve_offset = ctx->fb_state.nr_cbufs + !!ctx->fb_state.zsbuf;
|
||||||
|
@ -2235,6 +2238,9 @@ prep_fb_attachments(struct zink_context *ctx, VkImageView *att)
|
||||||
num_resolves++;
|
num_resolves++;
|
||||||
} else {
|
} else {
|
||||||
att[i] = prep_fb_attachment(ctx, surf, i);
|
att[i] = prep_fb_attachment(ctx, surf, i);
|
||||||
|
if (!att[i])
|
||||||
|
/* dead swapchain */
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ctx->fb_state.zsbuf) {
|
if (ctx->fb_state.zsbuf) {
|
||||||
|
@ -2247,6 +2253,7 @@ prep_fb_attachments(struct zink_context *ctx, VkImageView *att)
|
||||||
att[ctx->fb_state.nr_cbufs] = prep_fb_attachment(ctx, surf, ctx->fb_state.nr_cbufs);
|
att[ctx->fb_state.nr_cbufs] = prep_fb_attachment(ctx, surf, ctx->fb_state.nr_cbufs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned
|
static unsigned
|
||||||
|
@ -2313,7 +2320,8 @@ begin_render_pass(struct zink_context *ctx)
|
||||||
infos.pNext = NULL;
|
infos.pNext = NULL;
|
||||||
infos.attachmentCount = ctx->framebuffer->state.num_attachments;
|
infos.attachmentCount = ctx->framebuffer->state.num_attachments;
|
||||||
infos.pAttachments = att;
|
infos.pAttachments = att;
|
||||||
prep_fb_attachments(ctx, att);
|
if (!prep_fb_attachments(ctx, att))
|
||||||
|
return 0;
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
const unsigned cresolve_offset = ctx->fb_state.nr_cbufs + !!ctx->fb_state.zsbuf;
|
const unsigned cresolve_offset = ctx->fb_state.nr_cbufs + !!ctx->fb_state.zsbuf;
|
||||||
for (int i = 0; i < ctx->fb_state.nr_cbufs; i++) {
|
for (int i = 0; i < ctx->fb_state.nr_cbufs; i++) {
|
||||||
|
@ -2653,10 +2661,13 @@ unbind_fb_surface(struct zink_context *ctx, struct pipe_surface *surf, unsigned
|
||||||
if (changed) {
|
if (changed) {
|
||||||
if (zink_fb_clear_enabled(ctx, idx)) {
|
if (zink_fb_clear_enabled(ctx, idx)) {
|
||||||
if (zink_is_swapchain(res)) {
|
if (zink_is_swapchain(res)) {
|
||||||
zink_kopper_acquire(ctx, res, UINT64_MAX);
|
if (zink_kopper_acquire(ctx, res, UINT64_MAX)) {
|
||||||
zink_surface_swapchain_update(ctx, zink_csurface(surf));
|
zink_surface_swapchain_update(ctx, zink_csurface(surf));
|
||||||
|
zink_fb_clears_apply(ctx, surf->texture);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
zink_fb_clears_apply(ctx, surf->texture);
|
||||||
}
|
}
|
||||||
zink_fb_clears_apply(ctx, surf->texture);
|
|
||||||
}
|
}
|
||||||
if (zink_batch_usage_exists(zink_csurface(surf)->batch_uses)) {
|
if (zink_batch_usage_exists(zink_csurface(surf)->batch_uses)) {
|
||||||
zink_batch_reference_surface(&ctx->batch, zink_csurface(surf));
|
zink_batch_reference_surface(&ctx->batch, zink_csurface(surf));
|
||||||
|
@ -3506,18 +3517,21 @@ zink_copy_image_buffer(struct zink_context *ctx, struct zink_resource *dst, stru
|
||||||
struct zink_resource *img = dst->base.b.target == PIPE_BUFFER ? src : dst;
|
struct zink_resource *img = dst->base.b.target == PIPE_BUFFER ? src : dst;
|
||||||
struct zink_resource *buf = dst->base.b.target == PIPE_BUFFER ? dst : src;
|
struct zink_resource *buf = dst->base.b.target == PIPE_BUFFER ? dst : src;
|
||||||
struct zink_batch *batch = &ctx->batch;
|
struct zink_batch *batch = &ctx->batch;
|
||||||
|
bool needs_present_readback = false;
|
||||||
zink_batch_no_rp(ctx);
|
zink_batch_no_rp(ctx);
|
||||||
|
|
||||||
bool buf2img = buf == src;
|
bool buf2img = buf == src;
|
||||||
|
|
||||||
if (buf2img) {
|
if (buf2img) {
|
||||||
if (zink_is_swapchain(img))
|
if (zink_is_swapchain(img)) {
|
||||||
zink_kopper_acquire(ctx, img, UINT64_MAX);
|
if (!zink_kopper_acquire(ctx, img, UINT64_MAX))
|
||||||
|
return;
|
||||||
|
}
|
||||||
zink_resource_image_barrier(ctx, img, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 0, 0);
|
zink_resource_image_barrier(ctx, img, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 0, 0);
|
||||||
zink_resource_buffer_barrier(ctx, buf, VK_ACCESS_TRANSFER_READ_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
|
zink_resource_buffer_barrier(ctx, buf, VK_ACCESS_TRANSFER_READ_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
|
||||||
} else {
|
} else {
|
||||||
if (zink_is_swapchain(img))
|
if (zink_is_swapchain(img))
|
||||||
zink_kopper_acquire_readback(ctx, img);
|
needs_present_readback = zink_kopper_acquire_readback(ctx, img);
|
||||||
zink_resource_image_barrier(ctx, img, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, 0, 0);
|
zink_resource_image_barrier(ctx, img, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, 0, 0);
|
||||||
zink_resource_buffer_barrier(ctx, buf, VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
|
zink_resource_buffer_barrier(ctx, buf, VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
|
||||||
util_range_add(&dst->base.b, &dst->valid_buffer_range, dstx, dstx + src_box->width);
|
util_range_add(&dst->base.b, &dst->valid_buffer_range, dstx, dstx + src_box->width);
|
||||||
|
@ -3596,7 +3610,7 @@ zink_copy_image_buffer(struct zink_context *ctx, struct zink_resource *dst, stru
|
||||||
else
|
else
|
||||||
VKCTX(CmdCopyImageToBuffer)(batch->state->cmdbuf, img->obj->image, img->layout, buf->obj->buffer, 1, ®ion);
|
VKCTX(CmdCopyImageToBuffer)(batch->state->cmdbuf, img->obj->image, img->layout, buf->obj->buffer, 1, ®ion);
|
||||||
}
|
}
|
||||||
if (!buf2img && img->obj->dt)
|
if (needs_present_readback)
|
||||||
zink_kopper_present_readback(ctx, img);
|
zink_kopper_present_readback(ctx, img);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -543,6 +543,9 @@ zink_draw(struct pipe_context *pctx,
|
||||||
zink_query_update_gs_states(ctx, dinfo->was_line_loop);
|
zink_query_update_gs_states(ctx, dinfo->was_line_loop);
|
||||||
|
|
||||||
zink_batch_rp(ctx);
|
zink_batch_rp(ctx);
|
||||||
|
/* check dead swapchain */
|
||||||
|
if (unlikely(!ctx->batch.in_rp))
|
||||||
|
return;
|
||||||
|
|
||||||
if (BATCH_CHANGED)
|
if (BATCH_CHANGED)
|
||||||
zink_update_descriptor_refs(ctx, false);
|
zink_update_descriptor_refs(ctx, false);
|
||||||
|
|
Loading…
Reference in New Issue