zink: use a safer iteration for fb surfaces during rp init

doing a pointer iteration looks cool, but if the array is full, then it
goes out of bounds and we crash

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9542>
This commit is contained in:
Mike Blumenkrantz 2020-10-29 17:19:12 -04:00 committed by Marge Bot
parent 38f7faa8a4
commit 86bd643d6a
1 changed files with 5 additions and 2 deletions

View File

@ -1154,8 +1154,11 @@ zink_begin_render_pass(struct zink_context *ctx, struct zink_batch *batch)
framebuffer_state_buffer_barriers_setup(ctx, fb_state, batch);
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);
for (int i = 0; i < ARRAY_SIZE(ctx->framebuffer->surfaces); i++) {
if (!ctx->framebuffer->surfaces[i])
break;
zink_batch_reference_resource_rw(batch, zink_resource(ctx->framebuffer->surfaces[i]->texture), true);
}
vkCmdBeginRenderPass(batch->cmdbuf, &rpbi, VK_SUBPASS_CONTENTS_INLINE);
batch->in_rp = true;