zink: split up get_clear_data()

make the array extension part reusable

cc: mesa-stable

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18627>
This commit is contained in:
Mike Blumenkrantz
2022-09-02 10:25:35 -04:00
committed by Marge Bot
parent 11a5297ef5
commit d7c64ffcb8
+10 -8
View File
@@ -116,23 +116,25 @@ clear_in_rp(struct pipe_context *pctx,
ctx->base.texture_barrier(&ctx->base, PIPE_TEXTURE_BARRIER_FRAMEBUFFER);
}
static struct zink_framebuffer_clear_data *
add_new_clear(struct zink_framebuffer_clear *fb_clear)
{
struct zink_framebuffer_clear_data cd = {0};
util_dynarray_append(&fb_clear->clears, struct zink_framebuffer_clear_data, cd);
return zink_fb_clear_element(fb_clear, zink_fb_clear_count(fb_clear) - 1);
}
static struct zink_framebuffer_clear_data *
get_clear_data(struct zink_context *ctx, struct zink_framebuffer_clear *fb_clear, const struct pipe_scissor_state *scissor_state)
{
struct zink_framebuffer_clear_data *clear = NULL;
unsigned num_clears = zink_fb_clear_count(fb_clear);
if (num_clears) {
struct zink_framebuffer_clear_data *last_clear = zink_fb_clear_element(fb_clear, num_clears - 1);
/* if we're completely overwriting the previous clear, merge this into the previous clear */
if (!scissor_state || (last_clear->has_scissor && scissor_states_equal(&last_clear->scissor, scissor_state)))
clear = last_clear;
return last_clear;
}
if (!clear) {
struct zink_framebuffer_clear_data cd = {0};
util_dynarray_append(&fb_clear->clears, struct zink_framebuffer_clear_data, cd);
clear = zink_fb_clear_element(fb_clear, zink_fb_clear_count(fb_clear) - 1);
}
return clear;
return add_new_clear(fb_clear);
}
static void