render: make GLES2 renderer optional

Allow selecting whether the GLES2 renderer gets enabled.

Co-authored-by: Simon Ser <contact@emersion.fr>
This commit is contained in:
ayaka 2021-04-09 10:48:01 +08:00 committed by Simon Ser
parent 122d6c6988
commit ed1924800d
9 changed files with 60 additions and 10 deletions

View File

@ -23,6 +23,11 @@ if libavutil.found() and not cc.has_header('libavutil/hwcontext_drm.h', dependen
libavutil = disabler()
endif
wlr_gles2_renderer = []
if not features['gles2-renderer']
wlr_gles2_renderer = disabler()
endif
compositors = {
'simple': {
'src': 'simple.c',
@ -32,18 +37,23 @@ compositors = {
},
'touch': {
'src': ['touch.c', 'cat.c'],
'dep': [wlr_gles2_renderer],
},
'tablet': {
'src': 'tablet.c',
'dep': [wlr_gles2_renderer],
},
'rotation': {
'src': ['rotation.c', 'cat.c'],
'dep': [wlr_gles2_renderer],
},
'multi-pointer': {
'src': 'multi-pointer.c',
'dep': [wlr_gles2_renderer],
},
'output-layout': {
'src': ['output-layout.c', 'cat.c'],
'dep': [wlr_gles2_renderer],
},
'fullscreen-shell': {
'src': 'fullscreen-shell.c',
@ -193,7 +203,7 @@ foreach name, info : compositors
executable(
name,
[info.get('src'), extra_src],
dependencies: [wlroots, libdrm],
dependencies: [wlroots, libdrm, info.get('dep', [])],
include_directories: [wlr_inc, proto_inc],
build_by_default: get_option('examples'),
)

View File

@ -9,6 +9,9 @@ if not features.get('xwayland')
else
subdir('xwayland')
endif
if not features.get('gles2-renderer')
exclude_files += ['render/egl.h', 'render/gles2.h']
endif
install_subdir('wlr',
install_dir: get_option('includedir'),

View File

@ -3,6 +3,8 @@
#mesondefine WLR_HAS_X11_BACKEND
#mesondefine WLR_HAS_GLES2_RENDERER
#mesondefine WLR_HAS_XWAYLAND
#endif

View File

@ -88,6 +88,7 @@ endif
features = {
'x11-backend': false,
'xwayland': false,
'gles2-renderer': false,
}
internal_features = {
'xcb-errors': false,
@ -96,8 +97,6 @@ internal_features = {
wayland_server = dependency('wayland-server', version: '>=1.19')
wayland_client = dependency('wayland-client')
wayland_protos = dependency('wayland-protocols', version: '>=1.17')
egl = dependency('egl')
glesv2 = dependency('glesv2')
drm = dependency('libdrm', version: '>=2.4.95')
gbm = dependency('gbm', version: '>=17.1.0')
libinput = dependency('libinput', version: '>=1.14.0')
@ -113,8 +112,6 @@ wlr_deps = [
wayland_server,
wayland_client,
wayland_protos,
egl,
glesv2,
drm,
gbm,
libinput,

View File

@ -3,3 +3,4 @@ option('xwayland', type: 'feature', value: 'auto', yield: true, description: 'En
option('x11-backend', type: 'feature', value: 'auto', description: 'Enable X11 backend')
option('examples', type: 'boolean', value: true, description: 'Build example applications')
option('icon_directory', description: 'Location used to look for cursors (default: ${datadir}/icons)', type: 'string', value: '')
option('renderers', type: 'array', choices: ['auto', 'gles2'], value: ['auto'], description: 'Select built-in renderers')

View File

@ -1,3 +1,12 @@
glesv2 = dependency('glesv2', required: 'gles2' in renderers)
if not (glesv2.found() and egl.found())
subdir_done()
endif
features += { 'gles2-renderer': true }
wlr_deps += glesv2
wlr_files += files(
'pixel_format.c',
'renderer.c',

View File

@ -1,7 +1,13 @@
renderers = get_option('renderers')
if 'auto' in renderers and get_option('auto_features').enabled()
renderers = ['gles2']
elif 'auto' in renderers and get_option('auto_features').disabled()
renderers = []
endif
wlr_files += files(
'allocator.c',
'dmabuf.c',
'egl.c',
'drm_format_set.c',
'gbm_allocator.c',
'pixel_format.c',
@ -11,5 +17,14 @@ wlr_files += files(
'wlr_texture.c',
)
subdir('gles2')
egl = dependency('egl', required: 'gles2' in renderers)
if egl.found()
wlr_deps += egl
wlr_files += files('egl.c')
endif
if 'gles2' in renderers or 'auto' in renderers
subdir('gles2')
endif
subdir('pixman')

View File

@ -1,4 +1,5 @@
pixman = dependency('pixman-1')
wlr_deps += pixman
wlr_files += files(

View File

@ -2,13 +2,19 @@
#include <stdbool.h>
#include <stdlib.h>
#include <gbm.h>
#include <wlr/render/egl.h>
#include <wlr/render/gles2.h>
#include <wlr/render/pixman.h>
#include <wlr/render/interface.h>
#include <wlr/render/pixman.h>
#include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_matrix.h>
#include <wlr/util/log.h>
#include <wlr/config.h>
#if WLR_HAS_GLES2_RENDERER
#include <wlr/render/egl.h>
#include <wlr/render/gles2.h>
#endif
#include "util/signal.h"
#include "render/pixel_format.h"
#include "render/wlr_renderer.h"
@ -222,6 +228,7 @@ bool wlr_renderer_init_wl_display(struct wlr_renderer *r,
}
struct wlr_renderer *wlr_renderer_autocreate_with_drm_fd(int drm_fd) {
#if WLR_HAS_GLES2_RENDERER
struct gbm_device *gbm_device = gbm_create_device(drm_fd);
if (!gbm_device) {
wlr_log(WLR_ERROR, "Failed to create GBM device");
@ -241,9 +248,14 @@ struct wlr_renderer *wlr_renderer_autocreate_with_drm_fd(int drm_fd) {
if (!renderer) {
wlr_log(WLR_ERROR, "Failed to create GLES2 renderer");
wlr_egl_destroy(egl);
return NULL;
}
return renderer;
#endif
wlr_log(WLR_ERROR, "Failed to initialize any renderer");
return NULL;
}
struct wlr_renderer *wlr_renderer_autocreate(struct wlr_backend *backend) {