From 756dedae20eead72af6cfc7f724d0b2af6597eeb Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 21 Jun 2022 22:39:29 +0200 Subject: Add a new renderer API Goals: - Extensibility: we need to be able to add new params to the calls to render a texture/rect. For instance we'll need to add fences to the render texture operation for explicit sync purposes. - No implicit state: no more bind_buffer, begin, end. - No matrices: these hurt Pixman and we don't need them. - Clip regions for optimized damage repainting. Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3188 --- render/meson.build | 1 + render/pass.c | 25 +++++++++++++++++++++++++ render/wlr_renderer.c | 20 +++++++++++++++----- 3 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 render/pass.c (limited to 'render') diff --git a/render/meson.build b/render/meson.build index 4c3d4522..f09905c7 100644 --- a/render/meson.build +++ b/render/meson.build @@ -8,6 +8,7 @@ endif wlr_files += files( 'dmabuf.c', 'drm_format_set.c', + 'pass.c', 'pixel_format.c', 'swapchain.c', 'wlr_renderer.c', diff --git a/render/pass.c b/render/pass.c new file mode 100644 index 00000000..c1b88b8d --- /dev/null +++ b/render/pass.c @@ -0,0 +1,25 @@ +#include +#include +#include +#include + +void wlr_render_pass_init(struct wlr_render_pass *render_pass, + const struct wlr_render_pass_impl *impl) { + assert(impl->submit && impl->add_texture && impl->add_rect); + memset(render_pass, 0, sizeof(*render_pass)); + render_pass->impl = impl; +} + +bool wlr_render_pass_submit(struct wlr_render_pass *render_pass) { + return render_pass->impl->submit(render_pass); +} + +void wlr_render_pass_add_texture(struct wlr_render_pass *render_pass, + const struct wlr_render_texture_options *options) { + render_pass->impl->add_texture(render_pass, options); +} + +void wlr_render_pass_add_rect(struct wlr_render_pass *render_pass, + const struct wlr_render_rect_options *options) { + render_pass->impl->add_rect(render_pass, options); +} diff --git a/render/wlr_renderer.c b/render/wlr_renderer.c index 3b1e87e2..459016b6 100644 --- a/render/wlr_renderer.c +++ b/render/wlr_renderer.c @@ -33,11 +33,13 @@ void wlr_renderer_init(struct wlr_renderer *renderer, const struct wlr_renderer_impl *impl) { - assert(impl->begin); - assert(impl->clear); - assert(impl->scissor); - assert(impl->render_subtexture_with_matrix); - assert(impl->render_quad_with_matrix); + if (!impl->begin_buffer_pass) { + assert(impl->begin); + assert(impl->clear); + assert(impl->scissor); + assert(impl->render_subtexture_with_matrix); + assert(impl->render_quad_with_matrix); + } assert(impl->get_shm_texture_formats); assert(impl->get_render_buffer_caps); @@ -409,3 +411,11 @@ int wlr_renderer_get_drm_fd(struct wlr_renderer *r) { } return r->impl->get_drm_fd(r); } + +struct wlr_render_pass *wlr_renderer_begin_buffer_pass( + struct wlr_renderer *renderer, struct wlr_buffer *buffer) { + if (!renderer->impl->begin_buffer_pass) { + return NULL; + } + return renderer->impl->begin_buffer_pass(renderer, buffer); +} -- cgit v1.2.3