diff options
author | Erik Reider <[email protected]> | 2023-12-31 00:32:39 +0100 |
---|---|---|
committer | Erik Reider <[email protected]> | 2024-01-03 23:49:04 +0100 |
commit | 51c7078b9ec413ebd8316501f01ccf769a090f64 (patch) | |
tree | c66ea9c9e7dd010c069acf1578dd617d23a1d0cc /include/render/fx_renderer/fx_renderer.h | |
parent | b6a990da71b5b0947650a50dcf1a083acfce868c (diff) |
Converted fx_renderer to impl wlr_renderer
Makes the fx_renderer the default renderer for everything, no wlr_gles2 rendering.
This includes wlr_render_pass (fx_render_pass in our case)
Diffstat (limited to 'include/render/fx_renderer/fx_renderer.h')
-rw-r--r-- | include/render/fx_renderer/fx_renderer.h | 230 |
1 files changed, 112 insertions, 118 deletions
diff --git a/include/render/fx_renderer/fx_renderer.h b/include/render/fx_renderer/fx_renderer.h index ffd31da..6483f12 100644 --- a/include/render/fx_renderer/fx_renderer.h +++ b/include/render/fx_renderer/fx_renderer.h @@ -4,74 +4,63 @@ #include <GLES2/gl2.h> #include <GLES2/gl2ext.h> #include <stdbool.h> +#include <time.h> #include <wlr/render/egl.h> -#include <wlr/render/gles2.h> +#include <wlr/render/interface.h> #include <wlr/render/wlr_texture.h> #include <wlr/util/addon.h> #include <wlr/util/box.h> + #include "render/fx_renderer/fx_stencilbuffer.h" +#include "render/fx_renderer/shaders.h" +#include "render/pass.h" #include "types/fx/shadow_data.h" -enum fx_tex_shader_source { - SHADER_SOURCE_TEXTURE_RGBA = 1, - SHADER_SOURCE_TEXTURE_RGBX = 2, - SHADER_SOURCE_TEXTURE_EXTERNAL = 3, -}; - -struct quad_shader { - GLuint program; - GLint proj; - GLint color; - GLint pos_attrib; +struct fx_pixel_format { + uint32_t drm_format; + // optional field, if empty then internalformat = format + GLint gl_internalformat; + GLint gl_format, gl_type; + bool has_alpha; }; -struct tex_shader { - GLuint program; - GLint proj; - GLint tex; - GLint alpha; - GLint pos_attrib; - GLint tex_attrib; - GLint size; - GLint position; - GLint radius; -}; +bool is_fx_pixel_format_supported(const struct fx_renderer *renderer, + const struct fx_pixel_format *format); +const struct fx_pixel_format *get_fx_format_from_drm(uint32_t fmt); +const struct fx_pixel_format *get_fx_format_from_gl( + GLint gl_format, GLint gl_type, bool alpha); +const uint32_t *get_fx_shm_formats(const struct fx_renderer *renderer, + size_t *len); -struct stencil_mask_shader { - GLuint program; - GLint proj; - GLint color; - GLint pos_attrib; - GLint half_size; - GLint position; - GLint radius; -}; - -struct box_shadow_shader { - GLuint program; - GLint proj; - GLint color; - GLint pos_attrib; - GLint position; - GLint size; - GLint blur_sigma; - GLint corner_radius; -}; +/// +/// fx_framebuffer +/// struct fx_framebuffer { - bool initialized; - - GLuint fbo; - GLuint rbo; - - struct wlr_buffer *wlr_buffer; + struct wlr_buffer *buffer; struct fx_renderer *renderer; struct wl_list link; // fx_renderer.buffers - struct wlr_addon addon; EGLImageKHR image; + GLuint rbo; + GLuint fbo; + + struct wlr_addon addon; }; +struct fx_framebuffer *fx_framebuffer_get_or_create(struct fx_renderer *renderer, + struct wlr_buffer *wlr_buffer); + +void fx_framebuffer_bind(struct fx_framebuffer *buffer); + +void fx_framebuffer_bind_wlr_fbo(struct fx_renderer *renderer); + +void fx_framebuffer_destroy(struct fx_framebuffer *buffer); + +/// +/// fx_texture +/// + struct fx_texture { struct wlr_texture wlr_texture; struct fx_renderer *fx_renderer; @@ -94,34 +83,62 @@ struct fx_texture { struct wlr_addon buffer_addon; }; -struct fx_renderer { - float projection[9]; +struct fx_texture_attribs { + GLenum target; /* either GL_TEXTURE_2D or GL_TEXTURE_EXTERNAL_OES */ + GLuint tex; - int viewport_width, viewport_height; + bool has_alpha; +}; - struct wlr_output *wlr_output; +struct fx_texture *fx_get_texture(struct wlr_texture *wlr_texture); - struct wlr_egl *egl; +struct wlr_texture *fx_texture_from_buffer(struct wlr_renderer *wlr_renderer, + struct wlr_buffer *buffer); - struct fx_stencilbuffer stencil_buffer; +void fx_texture_destroy(struct fx_texture *texture); - struct wl_list textures; // fx_texture.link - struct wl_list buffers; // fx_framebuffer.link +bool wlr_texture_is_fx(struct wlr_texture *wlr_texture); - // The FBO and texture used by wlroots - GLuint wlr_main_buffer_fbo; - struct wlr_gles2_texture_attribs wlr_main_texture_attribs; +void fx_texture_get_attribs(struct wlr_texture *texture, + struct fx_texture_attribs *attribs); - struct wlr_addon addon; +/// +/// fx_renderer +/// +struct fx_renderer { + struct wlr_renderer wlr_renderer; + + float projection[9]; + struct wlr_egl *egl; + int drm_fd; + + const char *exts_str; struct { + bool EXT_read_format_bgra; + bool KHR_debug; bool OES_egl_image_external; bool OES_egl_image; + bool EXT_texture_type_2_10_10_10_REV; + bool OES_texture_half_float_linear; + bool EXT_texture_norm16; + bool EXT_disjoint_timer_query; } exts; struct { PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES; + PFNGLDEBUGMESSAGECALLBACKKHRPROC glDebugMessageCallbackKHR; + PFNGLDEBUGMESSAGECONTROLKHRPROC glDebugMessageControlKHR; + PFNGLPOPDEBUGGROUPKHRPROC glPopDebugGroupKHR; + PFNGLPUSHDEBUGGROUPKHRPROC glPushDebugGroupKHR; PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC glEGLImageTargetRenderbufferStorageOES; + PFNGLGETGRAPHICSRESETSTATUSKHRPROC glGetGraphicsResetStatusKHR; + PFNGLGENQUERIESEXTPROC glGenQueriesEXT; + PFNGLDELETEQUERIESEXTPROC glDeleteQueriesEXT; + PFNGLQUERYCOUNTEREXTPROC glQueryCounterEXT; + PFNGLGETQUERYOBJECTIVEXTPROC glGetQueryObjectivEXT; + PFNGLGETQUERYOBJECTUI64VEXTPROC glGetQueryObjectui64vEXT; + PFNGLGETINTEGER64VEXTPROC glGetInteger64vEXT; } procs; struct { @@ -132,60 +149,35 @@ struct fx_renderer { struct box_shadow_shader box_shadow; struct stencil_mask_shader stencil_mask; } shaders; -}; - -/// -/// 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 -/// + struct wl_list buffers; // fx_framebuffer.link + struct wl_list textures; // fx_texture.link -void fx_renderer_init_addon(struct wlr_egl *egl, struct wlr_output *output, - struct wlr_addon_set *addons, const void * owner); + struct fx_stencilbuffer stencil_buffer; -struct fx_renderer *fx_renderer_addon_find(struct wlr_addon_set *addons, - const void * owner); + struct fx_framebuffer *current_buffer; + uint32_t viewport_width, viewport_height; +}; -struct fx_renderer *fx_renderer_create(struct wlr_egl *egl, struct wlr_output *output); +bool wlr_renderer_is_fx(struct wlr_renderer *wlr_renderer); -void fx_renderer_begin(struct fx_renderer *renderer, int width, int height); +struct fx_renderer *fx_get_renderer( + struct wlr_renderer *wlr_renderer); +struct fx_render_timer *fx_get_render_timer( + struct wlr_render_timer *timer); +struct fx_texture *fx_get_texture( + struct wlr_texture *wlr_texture); -void fx_renderer_end(struct fx_renderer *renderer); +struct wlr_renderer *fx_renderer_create_with_drm_fd(int drm_fd); +struct wlr_renderer *fx_renderer_create(struct wlr_backend *backend); +struct wlr_renderer *fx_renderer_create_egl(struct wlr_egl *egl); -void fx_renderer_clear(const float color[static 4]); +struct wlr_egl *wlr_fx_renderer_get_egl(struct wlr_renderer *renderer); -void fx_renderer_scissor(struct wlr_box *box); +void push_fx_debug_(struct fx_renderer *renderer, + const char *file, const char *func); +#define push_fx_debug(renderer) push_fx_debug_(renderer, _WLR_FILENAME, __func__) +void pop_fx_debug(struct fx_renderer *renderer); // Initialize the stenciling work void fx_renderer_stencil_mask_init(void); @@ -200,17 +192,19 @@ void fx_renderer_stencil_enable(void); void fx_renderer_stencil_disable(void); -bool fx_render_subtexture_with_matrix(struct fx_renderer *renderer, - struct wlr_texture *wlr_texture, const struct wlr_fbox *src_box, - const struct wlr_box *dst_box, const float matrix[static 9], - float opacity, int corner_radius); +/// +/// Render Timer +/// -void fx_render_rect(struct fx_renderer *renderer, const struct wlr_box *box, - const float color[static 4], const float projection[static 9]); +struct fx_render_timer { + struct wlr_render_timer base; + struct fx_renderer *renderer; + struct timespec cpu_start; + struct timespec cpu_end; + GLuint id; + GLint64 gl_cpu_end; +}; -void fx_render_box_shadow(struct fx_renderer *renderer, - const struct wlr_box *box, const struct wlr_box *stencil_box, - const float matrix[static 9], int corner_radius, - struct shadow_data *shadow_data); +bool wlr_render_timer_is_fx(struct wlr_render_timer *timer); #endif |