Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

Commit

Permalink
Refactor EGL/GL API loading
Browse files Browse the repository at this point in the history
Remove glapi.sh code generation, replace it with hand-written loading
code that checks extension strings before calling eglGetProcAddress.

The GLES2 renderer still uses global state because of:

- {PUSH,POP}_GLES2_DEBUG macros
- wlr_gles2_texture_from_* taking a wlr_egl instead of the renderer
  • Loading branch information
emersion authored and ascent12 committed Dec 20, 2019
1 parent 7745486 commit 515679e
Show file tree
Hide file tree
Showing 11 changed files with 191 additions and 245 deletions.
1 change: 0 additions & 1 deletion backend/drm/renderer.c
Expand Up @@ -11,7 +11,6 @@
#include <wlr/types/wlr_matrix.h>
#include <wlr/util/log.h>
#include "backend/drm/drm.h"
#include "glapi.h"

bool init_drm_renderer(struct wlr_drm_backend *drm,
struct wlr_drm_renderer *renderer, wlr_renderer_create_func_t create_renderer_func) {
Expand Down
1 change: 0 additions & 1 deletion backend/headless/backend.c
Expand Up @@ -6,7 +6,6 @@
#include <wlr/render/gles2.h>
#include <wlr/util/log.h>
#include "backend/headless.h"
#include "glapi.h"
#include "util/signal.h"

struct wlr_headless_backend *headless_backend_from_backend(
Expand Down
1 change: 0 additions & 1 deletion backend/rdp/backend.c
Expand Up @@ -6,7 +6,6 @@
#include <wlr/render/gles2.h>
#include <wlr/util/log.h>
#include "backend/rdp.h"
#include "glapi.h"
#include "util/signal.h"

struct wlr_rdp_backend *rdp_backend_from_backend(
Expand Down
103 changes: 0 additions & 103 deletions glgen.sh

This file was deleted.

11 changes: 10 additions & 1 deletion include/render/gles2.h
Expand Up @@ -14,6 +14,16 @@
#include <wlr/render/wlr_texture.h>
#include <wlr/util/log.h>

struct wlr_gles2_procs {
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES;
PFNGLDEBUGMESSAGECALLBACKKHRPROC glDebugMessageCallbackKHR;
PFNGLDEBUGMESSAGECONTROLKHRPROC glDebugMessageControlKHR;
PFNGLPOPDEBUGGROUPKHRPROC glPopDebugGroupKHR;
PFNGLPUSHDEBUGGROUPKHRPROC glPushDebugGroupKHR;
};

extern struct wlr_gles2_procs gles2_procs;

struct wlr_gles2_pixel_format {
enum wl_shm_format wl_format;
GLint gl_format, gl_type;
Expand All @@ -33,7 +43,6 @@ struct wlr_gles2_renderer {
struct wlr_renderer wlr_renderer;

struct wlr_egl *egl;
const char *exts_str;

struct {
bool read_format_bgra_ext;
Expand Down
23 changes: 19 additions & 4 deletions include/wlr/render/egl.h
Expand Up @@ -22,6 +22,8 @@

#include <EGL/egl.h>
#include <EGL/eglext.h>
// TODO: remove eglmesaext.h
#include <EGL/eglmesaext.h>
#include <pixman.h>
#include <stdbool.h>
#include <wayland-server-core.h>
Expand All @@ -34,19 +36,32 @@ struct wlr_egl {
EGLConfig config;
EGLContext context;

const char *exts_str;

struct {
bool bind_wayland_display_wl;
bool buffer_age_ext;
bool image_base_khr;
bool image_dma_buf_export_mesa;
bool image_dmabuf_import_ext;
bool image_dmabuf_import_modifiers_ext;
bool swap_buffers_with_damage_ext;
bool swap_buffers_with_damage_khr;
bool swap_buffers_with_damage;
} exts;

struct {
PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT;
PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC eglCreatePlatformWindowSurfaceEXT;
PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR;
PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR;
PFNEGLQUERYWAYLANDBUFFERWL eglQueryWaylandBufferWL;
PFNEGLBINDWAYLANDDISPLAYWL eglBindWaylandDisplayWL;
PFNEGLUNBINDWAYLANDDISPLAYWL eglUnbindWaylandDisplayWL;
PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC eglSwapBuffersWithDamage; // KHR or EXT
PFNEGLQUERYDMABUFFORMATSEXTPROC eglQueryDmaBufFormatsEXT;
PFNEGLQUERYDMABUFMODIFIERSEXTPROC eglQueryDmaBufModifiersEXT;
PFNEGLEXPORTDMABUFIMAGEQUERYMESAPROC eglExportDMABUFImageQueryMESA;
PFNEGLEXPORTDMABUFIMAGEMESAPROC eglExportDMABUFImageMESA;
PFNEGLDEBUGMESSAGECONTROLKHRPROC eglDebugMessageControlKHR;
} procs;

struct wl_display *wl_display;

struct wlr_drm_format_set dmabuf_formats;
Expand Down

0 comments on commit 515679e

Please sign in to comment.