render: introduce wlr_render_texture_pass

Split texture rendering out of wlr_render_pass and introduce a
dedicated wlr_render_texture_pass interface.

Remove the add_texture hook from wlr_render_pass_impl and route
texture rendering through renderer->texture_pass instead.
This commit is contained in:
YaoBing Xiao 2026-03-13 12:36:51 +08:00
parent 33a27b055c
commit fee962af36
11 changed files with 222 additions and 8 deletions

View file

@ -983,7 +983,6 @@ static void render_pass_add_texture(struct wlr_render_pass *wlr_pass,
static const struct wlr_render_pass_impl render_pass_impl = {
.submit = render_pass_submit,
.add_texture = render_pass_add_texture,
};
void vk_color_transform_destroy(struct wlr_addon *addon) {
@ -1393,3 +1392,41 @@ struct wlr_vk_render_rect_pass *wlr_vk_render_rect_pass_from_pass(
return pass;
}
static void render_texture_pass_destroy(struct wlr_render_texture_pass *pass) {
struct wlr_vk_render_texture_pass *vk_pass =
wlr_vk_render_texture_pass_from_pass(pass);
free(vk_pass);
}
static const struct wlr_render_texture_pass_impl render_texture_pass_impl = {
.destroy = render_texture_pass_destroy,
.render = render_pass_add_texture,
};
struct wlr_render_texture_pass *wlr_vk_render_texture_pass_create(void) {
struct wlr_vk_render_texture_pass *pass = calloc(1, sizeof(*pass));
if (pass == NULL) {
wlr_log_errno(WLR_ERROR, "failed to allocate wlr_vk_render_texture_pass");
return NULL;
}
wlr_render_texture_pass_init(&pass->base, &render_texture_pass_impl);
return &pass->base;
}
bool wlr_render_texture_pass_is_vk(const struct wlr_render_texture_pass *texture_pass) {
return texture_pass->impl == &render_texture_pass_impl;
}
struct wlr_vk_render_texture_pass *wlr_vk_render_texture_pass_from_pass(
const struct wlr_render_texture_pass *texture_pass) {
if (!wlr_render_texture_pass_is_vk(texture_pass)) {
return NULL;
}
struct wlr_vk_render_texture_pass *vk_pass = wl_container_of(texture_pass, vk_pass, base);
return vk_pass;
}