mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-04-18 06:47:31 -04:00
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:
parent
ce89f49b7a
commit
534266b3f8
4 changed files with 37 additions and 10 deletions
|
|
@ -27,9 +27,23 @@ struct wlr_render_pass;
|
||||||
*/
|
*/
|
||||||
struct wlr_render_timer;
|
struct wlr_render_timer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A color value.
|
||||||
|
*
|
||||||
|
* Each channel has values between 0 and 1 inclusive. The R, G, B
|
||||||
|
* channels need to be pre-multiplied by A.
|
||||||
|
*/
|
||||||
|
struct wlr_render_color {
|
||||||
|
float r, g, b, a;
|
||||||
|
};
|
||||||
|
|
||||||
struct wlr_buffer_pass_options {
|
struct wlr_buffer_pass_options {
|
||||||
/* Timer to measure the duration of the render pass */
|
/* Timer to measure the duration of the render pass */
|
||||||
struct wlr_render_timer *timer;
|
struct wlr_render_timer *timer;
|
||||||
|
/* Clear the buffer before rendering into it */
|
||||||
|
bool clear_buffer;
|
||||||
|
/* If clearing the buffer, what color to clear it with */
|
||||||
|
struct wlr_render_color clear_color;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -93,16 +107,6 @@ struct wlr_render_texture_options {
|
||||||
void wlr_render_pass_add_texture(struct wlr_render_pass *render_pass,
|
void wlr_render_pass_add_texture(struct wlr_render_pass *render_pass,
|
||||||
const struct wlr_render_texture_options *options);
|
const struct wlr_render_texture_options *options);
|
||||||
|
|
||||||
/**
|
|
||||||
* A color value.
|
|
||||||
*
|
|
||||||
* Each channel has values between 0 and 1 inclusive. The R, G, B
|
|
||||||
* channels need to be pre-multiplied by A.
|
|
||||||
*/
|
|
||||||
struct wlr_render_color {
|
|
||||||
float r, g, b, a;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct wlr_render_rect_options {
|
struct wlr_render_rect_options {
|
||||||
/* Rectangle coordinates */
|
/* Rectangle coordinates */
|
||||||
struct wlr_box box;
|
struct wlr_box box;
|
||||||
|
|
|
||||||
|
|
@ -268,6 +268,14 @@ static struct wlr_render_pass *gles2_begin_buffer_pass(struct wlr_renderer *wlr_
|
||||||
if (!pass) {
|
if (!pass) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
// TODO: switch to using `glClearColor` + `glClear`
|
||||||
|
if (options->clear_buffer) {
|
||||||
|
wlr_render_pass_add_rect(&pass->base, &(struct wlr_render_rect_options){
|
||||||
|
.box = { .width = buffer->buffer->width, .height = buffer->buffer->height },
|
||||||
|
.color = options->clear_color,
|
||||||
|
.blend_mode = WLR_RENDER_BLEND_MODE_NONE,
|
||||||
|
});
|
||||||
|
}
|
||||||
return &pass->base;
|
return &pass->base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -307,6 +307,13 @@ static struct wlr_render_pass *pixman_begin_buffer_pass(struct wlr_renderer *wlr
|
||||||
if (pass == NULL) {
|
if (pass == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
if (options->clear_buffer) {
|
||||||
|
wlr_render_pass_add_rect(&pass->base, &(struct wlr_render_rect_options){
|
||||||
|
.box = { .width = buffer->buffer->width, .height = buffer->buffer->height },
|
||||||
|
.color = options->clear_color,
|
||||||
|
.blend_mode = WLR_RENDER_BLEND_MODE_NONE,
|
||||||
|
});
|
||||||
|
}
|
||||||
return &pass->base;
|
return &pass->base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1321,6 +1321,14 @@ static struct wlr_render_pass *vulkan_begin_buffer_pass(struct wlr_renderer *wlr
|
||||||
if (render_pass == NULL) {
|
if (render_pass == NULL) {
|
||||||
return 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;
|
return &render_pass->base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue