From b6a990da71b5b0947650a50dcf1a083acfce868c Mon Sep 17 00:00:00 2001 From: Erik Reider <35975961+ErikReider@users.noreply.github.com> Date: Sat, 30 Dec 2023 12:45:04 +0100 Subject: Added fx_texture and fx_framebuffer --- include/render/fx_renderer/fx_renderer.h | 99 ++++++++++++++++++++++++++++++-- 1 file changed, 94 insertions(+), 5 deletions(-) (limited to 'include/render/fx_renderer') diff --git a/include/render/fx_renderer/fx_renderer.h b/include/render/fx_renderer/fx_renderer.h index f569aa9..ffd31da 100644 --- a/include/render/fx_renderer/fx_renderer.h +++ b/include/render/fx_renderer/fx_renderer.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -57,19 +58,70 @@ struct box_shadow_shader { GLint corner_radius; }; +struct fx_framebuffer { + bool initialized; + + GLuint fbo; + GLuint rbo; + + struct wlr_buffer *wlr_buffer; + struct fx_renderer *renderer; + struct wl_list link; // fx_renderer.buffers + struct wlr_addon addon; + + EGLImageKHR image; +}; + +struct fx_texture { + struct wlr_texture wlr_texture; + struct fx_renderer *fx_renderer; + struct wl_list link; // fx_renderer.textures + + // Basically: + // GL_TEXTURE_2D == mutable + // GL_TEXTURE_EXTERNAL_OES == immutable + GLuint target; + GLuint tex; + + EGLImageKHR image; + + bool has_alpha; + + // Only affects target == GL_TEXTURE_2D + uint32_t drm_format; // used to interpret upload data + // If imported from a wlr_buffer + struct wlr_buffer *buffer; + struct wlr_addon buffer_addon; +}; + struct fx_renderer { float projection[9]; + int viewport_width, viewport_height; + + struct wlr_output *wlr_output; + + struct wlr_egl *egl; + struct fx_stencilbuffer stencil_buffer; + struct wl_list textures; // fx_texture.link + struct wl_list buffers; // fx_framebuffer.link + + // The FBO and texture used by wlroots + GLuint wlr_main_buffer_fbo; + struct wlr_gles2_texture_attribs wlr_main_texture_attribs; + struct wlr_addon addon; struct { bool OES_egl_image_external; + bool OES_egl_image; } exts; struct { PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES; + PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC glEGLImageTargetRenderbufferStorageOES; } procs; struct { @@ -82,18 +134,55 @@ struct fx_renderer { } shaders; }; -void fx_renderer_init_addon(struct wlr_egl *egl, struct wlr_addon_set *addons, - const void * owner); +/// +/// fx_framebuffer +/// + +struct fx_framebuffer fx_framebuffer_create(void); + +void fx_framebuffer_bind(struct fx_framebuffer *buffer); + +void fx_framebuffer_bind_wlr_fbo(struct fx_renderer *renderer); + +void fx_framebuffer_update(struct fx_renderer *fx_renderer, struct fx_framebuffer *fx_buffer, + int width, int height); + +void fx_framebuffer_add_stencil_buffer(struct fx_framebuffer *buffer, int width, int height); + +void fx_framebuffer_release(struct fx_framebuffer *buffer); + +/// +/// fx_texture +/// + +struct fx_texture *fx_get_texture(struct wlr_texture *wlr_texture); + +struct fx_texture *fx_texture_from_buffer(struct fx_renderer *fx_renderer, + struct wlr_buffer *buffer); + +void fx_texture_destroy(struct fx_texture *texture); + +bool wlr_texture_is_fx(struct wlr_texture *wlr_texture); + +void wlr_gles2_texture_get_fx_attribs(struct fx_texture *texture, + struct wlr_gles2_texture_attribs *attribs); + +/// +/// fx_renderer +/// + +void fx_renderer_init_addon(struct wlr_egl *egl, struct wlr_output *output, + struct wlr_addon_set *addons, const void * owner); struct fx_renderer *fx_renderer_addon_find(struct wlr_addon_set *addons, const void * owner); -struct fx_renderer *fx_renderer_create(struct wlr_egl *egl); - -void fx_renderer_fini(struct fx_renderer *renderer); +struct fx_renderer *fx_renderer_create(struct wlr_egl *egl, struct wlr_output *output); void fx_renderer_begin(struct fx_renderer *renderer, int width, int height); +void fx_renderer_end(struct fx_renderer *renderer); + void fx_renderer_clear(const float color[static 4]); void fx_renderer_scissor(struct wlr_box *box); -- cgit v1.2.3