mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-02-05 18:00:43 +08:00
Simplify SDL_GL_EGL_PLATFORM handling
This commit is contained in:
committed by
Sam Lantinga
parent
eceb35c96c
commit
f8331d50ff
@@ -549,7 +549,7 @@ static void SDL_EGL_GetVersion(SDL_VideoDevice *_this)
|
||||
}
|
||||
}
|
||||
|
||||
bool SDL_EGL_LoadLibrary(SDL_VideoDevice *_this, const char *egl_path, NativeDisplayType native_display, EGLenum platform)
|
||||
bool SDL_EGL_LoadLibrary(SDL_VideoDevice *_this, const char *egl_path, NativeDisplayType native_display)
|
||||
{
|
||||
if (!SDL_EGL_LoadLibraryOnly(_this, egl_path)) {
|
||||
return false;
|
||||
@@ -558,6 +558,7 @@ bool SDL_EGL_LoadLibrary(SDL_VideoDevice *_this, const char *egl_path, NativeDis
|
||||
_this->egl_data->egl_display = EGL_NO_DISPLAY;
|
||||
|
||||
#ifndef SDL_VIDEO_DRIVER_VITA
|
||||
EGLenum platform = _this->gl_config.egl_platform;
|
||||
if (platform) {
|
||||
/* EGL 1.5 allows querying for client version with EGL_NO_DISPLAY
|
||||
* --
|
||||
|
||||
@@ -118,11 +118,8 @@ typedef enum SDL_EGL_ExtensionType
|
||||
extern bool SDL_EGL_HasExtension(SDL_VideoDevice *_this, SDL_EGL_ExtensionType type, const char *ext);
|
||||
|
||||
extern bool SDL_EGL_GetAttribute(SDL_VideoDevice *_this, SDL_GLAttr attrib, int *value);
|
||||
/* SDL_EGL_LoadLibrary can get a display for a specific platform (EGL_PLATFORM_*)
|
||||
* or, if 0 is passed, let the implementation decide.
|
||||
*/
|
||||
extern bool SDL_EGL_LoadLibraryOnly(SDL_VideoDevice *_this, const char *path);
|
||||
extern bool SDL_EGL_LoadLibrary(SDL_VideoDevice *_this, const char *path, NativeDisplayType native_display, EGLenum platform);
|
||||
extern bool SDL_EGL_LoadLibrary(SDL_VideoDevice *_this, const char *path, NativeDisplayType native_display);
|
||||
extern SDL_FunctionPointer SDL_EGL_GetProcAddressInternal(SDL_VideoDevice *_this, const char *proc);
|
||||
extern void SDL_EGL_UnloadLibrary(SDL_VideoDevice *_this);
|
||||
extern void SDL_EGL_SetRequiredVisualId(SDL_VideoDevice *_this, int visual_id);
|
||||
|
||||
@@ -331,7 +331,7 @@ struct SDL_VideoDevice
|
||||
bool (*GL_GetSwapInterval)(SDL_VideoDevice *_this, int *interval);
|
||||
bool (*GL_SwapWindow)(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
bool (*GL_DestroyContext)(SDL_VideoDevice *_this, SDL_GLContext context);
|
||||
void (*GL_DefaultProfileConfig)(SDL_VideoDevice *_this, int *mask, int *major, int *minor);
|
||||
void (*GL_SetDefaultProfileConfig)(SDL_VideoDevice *_this);
|
||||
|
||||
/* * * */
|
||||
/*
|
||||
|
||||
@@ -4964,12 +4964,6 @@ void SDL_GL_ResetAttributes(void)
|
||||
_this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES;
|
||||
#endif
|
||||
|
||||
if (_this->GL_DefaultProfileConfig) {
|
||||
_this->GL_DefaultProfileConfig(_this, &_this->gl_config.profile_mask,
|
||||
&_this->gl_config.major_version,
|
||||
&_this->gl_config.minor_version);
|
||||
}
|
||||
|
||||
_this->gl_config.flags = 0;
|
||||
_this->gl_config.framebuffer_srgb_capable = -1;
|
||||
_this->gl_config.no_error = 0;
|
||||
@@ -4979,6 +4973,10 @@ void SDL_GL_ResetAttributes(void)
|
||||
_this->gl_config.share_with_current_context = 0;
|
||||
|
||||
_this->gl_config.egl_platform = 0;
|
||||
|
||||
if (_this->GL_SetDefaultProfileConfig) {
|
||||
_this->GL_SetDefaultProfileConfig(_this);
|
||||
}
|
||||
}
|
||||
|
||||
bool SDL_GL_SetAttribute(SDL_GLAttr attr, int value)
|
||||
|
||||
@@ -82,7 +82,7 @@ bool Android_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
|
||||
bool Android_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path)
|
||||
{
|
||||
return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType)0, 0);
|
||||
return SDL_EGL_LoadLibrary(_this, path, EGL_DEFAULT_DISPLAY);
|
||||
}
|
||||
|
||||
#endif // SDL_VIDEO_DRIVER_ANDROID
|
||||
|
||||
@@ -51,7 +51,7 @@ bool Cocoa_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path)
|
||||
}
|
||||
|
||||
if (_this->egl_data == NULL) {
|
||||
return SDL_EGL_LoadLibrary(_this, NULL, EGL_DEFAULT_DISPLAY, _this->gl_config.egl_platform);
|
||||
return SDL_EGL_LoadLibrary(_this, NULL, EGL_DEFAULT_DISPLAY);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -127,7 +127,7 @@ bool Cocoa_GLES_SetupWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
#if 0 // When hint SDL_HINT_OPENGL_ES_DRIVER is set to "1" (e.g. for ANGLE support), _this->gl_config.driver_loaded can be 1, while the below lines function.
|
||||
SDL_assert(!_this->gl_config.driver_loaded);
|
||||
#endif
|
||||
if (!SDL_EGL_LoadLibrary(_this, NULL, EGL_DEFAULT_DISPLAY, _this->gl_config.egl_platform)) {
|
||||
if (!SDL_EGL_LoadLibrary(_this, NULL, EGL_DEFAULT_DISPLAY)) {
|
||||
SDL_EGL_UnloadLibrary(_this);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -49,16 +49,18 @@
|
||||
|
||||
// EGL implementation of SDL OpenGL support
|
||||
|
||||
void KMSDRM_GLES_DefaultProfileConfig(SDL_VideoDevice *_this, int *mask, int *major, int *minor)
|
||||
void KMSDRM_GLES_SetDefaultProfileConfig(SDL_VideoDevice *_this)
|
||||
{
|
||||
/* if SDL was _also_ built with the Raspberry Pi driver (so we're
|
||||
definitely a Pi device) or with the ROCKCHIP video driver
|
||||
(it's a ROCKCHIP device), default to GLES2. */
|
||||
#if defined(SDL_VIDEO_DRIVER_RPI) || defined(SDL_VIDEO_DRIVER_ROCKCHIP)
|
||||
*mask = SDL_GL_CONTEXT_PROFILE_ES;
|
||||
*major = 2;
|
||||
*minor = 0;
|
||||
_this->gl_config.mask = SDL_GL_CONTEXT_PROFILE_ES;
|
||||
_this->gl_config.major = 2;
|
||||
_this->gl_config.minor = 0;
|
||||
#endif
|
||||
|
||||
_this->gl_config.egl_platform = EGL_PLATFORM_GBM_MESA;
|
||||
}
|
||||
|
||||
bool KMSDRM_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path)
|
||||
@@ -70,7 +72,7 @@ bool KMSDRM_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path)
|
||||
call order in SDL_CreateWindow(). */
|
||||
#if 0
|
||||
NativeDisplayType display = (NativeDisplayType)_this->internal->gbm_dev;
|
||||
return SDL_EGL_LoadLibrary(_this, path, display, EGL_PLATFORM_GBM_MESA);
|
||||
return SDL_EGL_LoadLibrary(_this, path, display);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#define KMSDRM_GLES_DestroyContext SDL_EGL_DestroyContext
|
||||
#define KMSDRM_GLES_GetSwapInterval SDL_EGL_GetSwapInterval
|
||||
|
||||
extern void KMSDRM_GLES_DefaultProfileConfig(SDL_VideoDevice *_this, int *mask, int *major, int *minor);
|
||||
extern void KMSDRM_GLES_SetDefaultProfileConfig(SDL_VideoDevice *_this);
|
||||
extern bool KMSDRM_GLES_SetSwapInterval(SDL_VideoDevice *_this, int interval);
|
||||
extern bool KMSDRM_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path);
|
||||
extern void KMSDRM_GLES_UnloadLibrary(SDL_VideoDevice *_this);
|
||||
|
||||
@@ -74,10 +74,6 @@ static char kmsdrm_dri_cardpath[32];
|
||||
#define DRM_FORMAT_MOD_LINEAR fourcc_mod_code(NONE, 0)
|
||||
#endif
|
||||
|
||||
#ifndef EGL_PLATFORM_GBM_MESA
|
||||
#define EGL_PLATFORM_GBM_MESA 0x31D7
|
||||
#endif
|
||||
|
||||
static int get_driindex(void)
|
||||
{
|
||||
int available = -ENOENT;
|
||||
@@ -696,7 +692,7 @@ static SDL_VideoDevice *KMSDRM_CreateDevice(void)
|
||||
device->GL_GetSwapInterval = KMSDRM_GLES_GetSwapInterval;
|
||||
device->GL_SwapWindow = KMSDRM_GLES_SwapWindow;
|
||||
device->GL_DestroyContext = KMSDRM_GLES_DestroyContext;
|
||||
device->GL_DefaultProfileConfig = KMSDRM_GLES_DefaultProfileConfig;
|
||||
device->GL_SetDefaultProfileConfig = KMSDRM_GLES_SetDefaultProfileConfig;
|
||||
|
||||
#ifdef SDL_VIDEO_VULKAN
|
||||
device->Vulkan_LoadLibrary = KMSDRM_Vulkan_LoadLibrary;
|
||||
@@ -2132,12 +2128,12 @@ bool KMSDRM_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propert
|
||||
before we call KMSDRM_GBMInit(), causing all GLES programs to fail. */
|
||||
if (!_this->egl_data) {
|
||||
egl_display = (NativeDisplayType)_this->internal->gbm_dev;
|
||||
if (!SDL_EGL_LoadLibrary(_this, NULL, egl_display, EGL_PLATFORM_GBM_MESA)) {
|
||||
if (!SDL_EGL_LoadLibrary(_this, NULL, egl_display)) {
|
||||
// Try again with OpenGL ES 2.0
|
||||
_this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES;
|
||||
_this->gl_config.major_version = 2;
|
||||
_this->gl_config.minor_version = 0;
|
||||
if (!SDL_EGL_LoadLibrary(_this, NULL, egl_display, EGL_PLATFORM_GBM_MESA)) {
|
||||
if (!SDL_EGL_LoadLibrary(_this, NULL, egl_display)) {
|
||||
return SDL_SetError("Can't load EGL/GL library on window creation.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1029,7 +1029,7 @@ static bool SDL_EGL_InitInternal(SDL_VideoData * vd)
|
||||
// Linux, EGL, etc.
|
||||
static bool OVR_EGL_LoadLibrary(SDL_VideoDevice *_this, const char *path)
|
||||
{
|
||||
return SDL_EGL_LoadLibrary(_this, path, /*displaydata->native_display*/0, 0);
|
||||
return SDL_EGL_LoadLibrary(_this, path, EGL_DEFAULT_DISPLAY);
|
||||
}
|
||||
|
||||
static SDL_FunctionPointer OVR_EGL_GetProcAddress(SDL_VideoDevice *_this, const char *proc)
|
||||
|
||||
@@ -27,16 +27,16 @@
|
||||
|
||||
// EGL implementation of SDL OpenGL support
|
||||
|
||||
void RPI_GLES_DefaultProfileConfig(SDL_VideoDevice *_this, int *mask, int *major, int *minor)
|
||||
void RPI_GLES_SetDefaultProfileConfig(SDL_VideoDevice *_this)
|
||||
{
|
||||
*mask = SDL_GL_CONTEXT_PROFILE_ES;
|
||||
*major = 2;
|
||||
*minor = 0;
|
||||
_this->gl_config.mask = SDL_GL_CONTEXT_PROFILE_ES;
|
||||
_this->gl_config.major = 2;
|
||||
_this->gl_config.minor = 0;
|
||||
}
|
||||
|
||||
bool RPI_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path)
|
||||
{
|
||||
return SDL_EGL_LoadLibrary(_this, path, EGL_DEFAULT_DISPLAY, 0);
|
||||
return SDL_EGL_LoadLibrary(_this, path, EGL_DEFAULT_DISPLAY);
|
||||
}
|
||||
|
||||
bool RPI_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
|
||||
@@ -40,7 +40,7 @@ extern bool RPI_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path);
|
||||
extern SDL_GLContext RPI_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
extern bool RPI_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
extern bool RPI_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context);
|
||||
extern void RPI_GLES_DefaultProfileConfig(SDL_VideoDevice *_this, int *mask, int *major, int *minor);
|
||||
extern void RPI_GLES_SetDefaultProfileConfig(SDL_VideoDevice *_this);
|
||||
|
||||
#endif // SDL_VIDEO_DRIVER_RPI && SDL_VIDEO_OPENGL_EGL
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ static SDL_VideoDevice *RPI_Create(void)
|
||||
device->GL_GetSwapInterval = RPI_GLES_GetSwapInterval;
|
||||
device->GL_SwapWindow = RPI_GLES_SwapWindow;
|
||||
device->GL_DestroyContext = RPI_GLES_DestroyContext;
|
||||
device->GL_DefaultProfileConfig = RPI_GLES_DefaultProfileConfig;
|
||||
device->GL_SetDefaultProfileConfig = RPI_GLES_SetDefaultProfileConfig;
|
||||
|
||||
device->PumpEvents = RPI_PumpEvents;
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ bool VITA_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path)
|
||||
PVRSRVCreateVirtualAppHint(&hint);
|
||||
}
|
||||
|
||||
return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType)0, 0);
|
||||
return SDL_EGL_LoadLibrary(_this, path, EGL_DEFAULT_DISPLAY);
|
||||
}
|
||||
|
||||
SDL_GLContext VITA_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
|
||||
@@ -62,7 +62,7 @@ bool VITA_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path)
|
||||
PVRSRVCreateVirtualAppHint(&hint);
|
||||
}
|
||||
|
||||
return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType)0, 0);
|
||||
return SDL_EGL_LoadLibrary(_this, path, EGL_DEFAULT_DISPLAY);
|
||||
}
|
||||
|
||||
SDL_GLContext VITA_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
|
||||
@@ -31,7 +31,7 @@ bool VIVANTE_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path)
|
||||
{
|
||||
SDL_DisplayData *displaydata = SDL_GetDisplayDriverData(SDL_GetPrimaryDisplay());
|
||||
|
||||
return SDL_EGL_LoadLibrary(_this, path, displaydata->native_display, 0);
|
||||
return SDL_EGL_LoadLibrary(_this, path, displaydata->native_display);
|
||||
}
|
||||
|
||||
SDL_EGL_CreateContext_impl(VIVANTE)
|
||||
|
||||
@@ -34,16 +34,20 @@
|
||||
|
||||
// EGL implementation of SDL OpenGL ES support
|
||||
|
||||
void Wayland_GLES_SetDefaultProfileConfig(SDL_VideoDevice *_this)
|
||||
{
|
||||
#if defined(SDL_PLATFORM_QNXNTO)
|
||||
// QNX defaults to EGL_PLATFORM_SCREEN_QNX unless this is explicitly specified
|
||||
_this->gl_config.egl_platform = EGL_PLATFORM_WAYLAND_EXT;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Wayland_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path)
|
||||
{
|
||||
bool result;
|
||||
SDL_VideoData *data = _this->internal;
|
||||
|
||||
#if defined(SDL_PLATFORM_QNXNTO)
|
||||
SDL_GL_SetAttribute(SDL_GL_EGL_PLATFORM, EGL_PLATFORM_WAYLAND_EXT);
|
||||
#endif
|
||||
|
||||
result = SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType)data->display, _this->gl_config.egl_platform);
|
||||
result = SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType)data->display);
|
||||
|
||||
Wayland_PumpEvents(_this);
|
||||
WAYLAND_wl_display_flush(data->display);
|
||||
|
||||
@@ -43,6 +43,7 @@ extern bool Wayland_GLES_GetSwapInterval(SDL_VideoDevice *_this, int *interval);
|
||||
extern bool Wayland_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
extern bool Wayland_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context);
|
||||
extern bool Wayland_GLES_DestroyContext(SDL_VideoDevice *_this, SDL_GLContext context);
|
||||
extern void Wayland_GLES_SetDefaultProfileConfig(SDL_VideoDevice *_this);
|
||||
extern SDL_EGLSurface Wayland_GLES_GetEGLSurface(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
|
||||
#endif // SDL_waylandopengles_h_
|
||||
|
||||
@@ -634,6 +634,7 @@ static SDL_VideoDevice *Wayland_CreateDevice(bool require_preferred_protocols)
|
||||
device->GL_UnloadLibrary = Wayland_GLES_UnloadLibrary;
|
||||
device->GL_GetProcAddress = Wayland_GLES_GetProcAddress;
|
||||
device->GL_DestroyContext = Wayland_GLES_DestroyContext;
|
||||
device->GL_SetDefaultProfileConfig = Wayland_GLES_SetDefaultProfileConfig;
|
||||
device->GL_GetEGLSurface = Wayland_GLES_GetEGLSurface;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ bool WIN_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path)
|
||||
}
|
||||
|
||||
if (!_this->egl_data) {
|
||||
return SDL_EGL_LoadLibrary(_this, NULL, EGL_DEFAULT_DISPLAY, _this->gl_config.egl_platform);
|
||||
return SDL_EGL_LoadLibrary(_this, NULL, EGL_DEFAULT_DISPLAY);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -115,7 +115,7 @@ bool WIN_GLES_SetupWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
#if 0 // When hint SDL_HINT_OPENGL_ES_DRIVER is set to "1" (e.g. for ANGLE support), _this->gl_config.driver_loaded can be 1, while the below lines function.
|
||||
SDL_assert(!_this->gl_config.driver_loaded);
|
||||
#endif
|
||||
if (!SDL_EGL_LoadLibrary(_this, NULL, EGL_DEFAULT_DISPLAY, _this->gl_config.egl_platform)) {
|
||||
if (!SDL_EGL_LoadLibrary(_this, NULL, EGL_DEFAULT_DISPLAY)) {
|
||||
SDL_EGL_UnloadLibrary(_this);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ bool X11_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path)
|
||||
#endif
|
||||
}
|
||||
|
||||
return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType)data->display, _this->gl_config.egl_platform);
|
||||
return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType)data->display);
|
||||
}
|
||||
|
||||
XVisualInfo *X11_GLES_GetVisual(SDL_VideoDevice *_this, Display *display, int screen, bool transparent)
|
||||
|
||||
Reference in New Issue
Block a user