render: optionally clear buffer before rendering

It's suboptimal to do it separately, and some drivers can do it for free this way
Prevents UNASSIGNED-BestPractices-vkCmdClearAttachments-clear-after-load warning
This commit is contained in:
Julia Tatz 2023-12-12 17:54:27 -05:00 committed by Julia Tatz
parent ce89f49b7a
commit 534266b3f8
4 changed files with 37 additions and 10 deletions

View file

@ -1321,6 +1321,14 @@ static struct wlr_render_pass *vulkan_begin_buffer_pass(struct wlr_renderer *wlr
if (render_pass == NULL) {
return NULL;
}
// TODO: switch to using `VkRenderPassBeginInfo.pClearValues`
if (options->clear_buffer) {
wlr_render_pass_add_rect(&render_pass->base, &(struct wlr_render_rect_options){
.box = { .width = buffer->width, .height = buffer->height },
.color = options->clear_color,
.blend_mode = WLR_RENDER_BLEND_MODE_NONE,
});
}
return &render_pass->base;
}