From 84781a7b6f3e8fd0335b331946bc237a7fed00ad Mon Sep 17 00:00:00 2001
From: Cameron Cawley <[EMAIL REDACTED]>
Date: Wed, 23 Nov 2022 18:55:34 +0000
Subject: [PATCH] Disable the offscreen video driver if EGL is unavailable
(#6234)
---
CMakeLists.txt | 17 ++++++++++-------
configure.ac | 19 ++++++++++---------
2 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 57b32101628f..443aa36ad191 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1177,13 +1177,6 @@ if(SDL_VIDEO)
set(HAVE_DUMMYVIDEO TRUE)
set(HAVE_SDL_VIDEO TRUE)
endif()
- if(SDL_OFFSCREEN)
- set(SDL_VIDEO_DRIVER_OFFSCREEN 1)
- file(GLOB VIDEO_OFFSCREEN_SOURCES ${SDL3_SOURCE_DIR}/src/video/offscreen/*.c)
- list(APPEND SOURCE_FILES ${VIDEO_OFFSCREEN_SOURCES})
- set(HAVE_OFFSCREEN TRUE)
- set(HAVE_SDL_VIDEO TRUE)
- endif()
endif()
# Platform-specific options and settings
@@ -2748,6 +2741,16 @@ endif()
# Platform-independent options
CheckLibSampleRate()
+if(SDL_VIDEO)
+ if(SDL_OFFSCREEN AND SDL_VIDEO_OPENGL_EGL)
+ set(SDL_VIDEO_DRIVER_OFFSCREEN 1)
+ file(GLOB VIDEO_OFFSCREEN_SOURCES ${SDL3_SOURCE_DIR}/src/video/offscreen/*.c)
+ list(APPEND SOURCE_FILES ${VIDEO_OFFSCREEN_SOURCES})
+ set(HAVE_OFFSCREEN TRUE)
+ set(HAVE_SDL_VIDEO TRUE)
+ endif()
+endif()
+
# Dummies
# configure.ac does it differently:
# if not have X
diff --git a/configure.ac b/configure.ac
index f8e71411dda0..b986dc2aabe1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2177,7 +2177,11 @@ CheckOffscreenVideo()
AC_ARG_ENABLE(video-offscreen,
[AS_HELP_STRING([--enable-video-offscreen], [use offscreen video driver [default=yes]])],
, enable_video_offscreen=yes)
- if test x$enable_video_offscreen = xyes; then
+
+ if test x$enable_video = xyes && \
+ test x$enable_video_offscreen = xyes && \
+ test x$video_opengl_egl = xyes; then
+
AC_DEFINE(SDL_VIDEO_DRIVER_OFFSCREEN, 1, [ ])
SOURCES="$SOURCES $srcdir/src/video/offscreen/*.c"
have_video=yes
@@ -3470,7 +3474,6 @@ case "$host" in
CheckWerror
CheckDeclarationAfterStatement
CheckDummyVideo
- CheckOffscreenVideo
CheckDiskAudio
CheckDummyAudio
CheckDLOPEN
@@ -3487,8 +3490,9 @@ case "$host" in
# Need to check for Raspberry PI first and add platform specific compiler flags, otherwise the test for GLES fails!
CheckRPI
CheckX11
- # Need to check for EGL first because KMSDRM and Wayland depends on it.
+ # Need to check for EGL first because Offscreen, KMSDRM and Wayland depend on it.
CheckEGL
+ CheckOffscreenVideo
CheckKMSDRM
CheckGLX
CheckOpenGL
@@ -3686,12 +3690,12 @@ case "$host" in
CheckWerror
CheckDeclarationAfterStatement
CheckDummyVideo
- CheckOffscreenVideo
CheckDiskAudio
CheckDummyAudio
CheckWINDOWS
CheckWINDOWSGL
CheckWINDOWSGLES
+ CheckOffscreenVideo
CheckVulkan
CheckDIRECTX
CheckHIDAPI
@@ -3847,7 +3851,6 @@ dnl BeOS support removed after SDL 2.0.1. Haiku still works. --ryan.
ARCH=haiku
ac_default_prefix=/boot/system
CheckDummyVideo
- CheckOffscreenVideo
CheckDiskAudio
CheckDummyAudio
CheckDLOPEN
@@ -3909,7 +3912,6 @@ dnl BeOS support removed after SDL 2.0.1. Haiku still works. --ryan.
CheckNoErrorDeprecatedDeclarationsWerror
CheckDeclarationAfterStatement
CheckDummyVideo
- CheckOffscreenVideo
CheckDiskAudio
CheckDummyAudio
CheckDLOPEN
@@ -4026,7 +4028,6 @@ dnl BeOS support removed after SDL 2.0.1. Haiku still works. --ryan.
CheckNoErrorDeprecatedDeclarationsWerror
CheckDeclarationAfterStatement
CheckDummyVideo
- CheckOffscreenVideo
CheckDiskAudio
CheckDummyAudio
CheckDLOPEN
@@ -4038,6 +4039,7 @@ dnl BeOS support removed after SDL 2.0.1. Haiku still works. --ryan.
CheckMacGLES
CheckGLX
CheckOpenGL
+ CheckOffscreenVideo
CheckVulkan
CheckPTHREAD
CheckHIDAPI
@@ -4129,13 +4131,13 @@ dnl BeOS support removed after SDL 2.0.1. Haiku still works. --ryan.
CheckWerror
CheckDeclarationAfterStatement
CheckDummyVideo
- CheckOffscreenVideo
CheckDiskAudio
CheckDummyAudio
CheckPTHREAD
CheckDLOPEN
CheckClockGettime
CheckEmscriptenGLES
+ CheckOffscreenVideo
# Set up files for the misc library
if test x$enable_misc = xyes; then
@@ -4181,7 +4183,6 @@ dnl BeOS support removed after SDL 2.0.1. Haiku still works. --ryan.
CheckWerror
CheckDeclarationAfterStatement
CheckDummyVideo
- CheckOffscreenVideo
CheckDiskAudio
CheckDummyAudio
CheckDLOPEN