src/video/x11/SDL_x11opengl.c


Log

Author Commit Date CI Message
Cameron Gutman 45372b1c 2022-04-04T21:36:25 x11: Don't unload libGL.so to prevent a crash in XCloseDisplay() libGL.so may register callbacks that can be invoked upon XCloseDisplay(). If XCloseDisplay() is called after libGL.so is unloaded, the callback pointer will point at freed memory and invoking it will crash. The texture framebuffer check optimized out in f37e4a9 was causing libGL.so to never be unloaded as a side-effect. Skipping it exposed this bug by allowing libGL.so to actually unload.
Sam Lantinga 120c76c8 2022-01-03T09:40:00 Updated copyright for 2022
Ozkan Sezer 77c8d111 2021-08-10T20:55:50 configuration updates for dlopen: - cmake, configure (CheckDLOPEN): --enable-sdl-dlopen is now history.. detach the dl api discovery from SDL_LOADSO_DLOPEN functionality. define HAVE_DLOPEN. also define DYNAPI_NEEDS_DLOPEN (CheckDLOPEN is called only for relevant platforms.) - update SDL_config.in and SDL_config.cmake accordingly. - SDL_dynapi.h: set SDL_DYNAMIC_API to 0 if DYNAPI_NEEDS_DLOPEN is defined, but HAVE_DLOPEN is not. - pthread/SDL_systhread.c: conditionalize dl api use to HAVE_DLOPEN - SDL_x11opengl.c, SDL_DirectFB_opengl.c, SDL_naclopengles.c: rely on HAVE_DLOPEN, not SDL_LOADSO_DLOPEN. - SDL_config_android.h, SDL_config_iphoneos.h, SDL_config_macosx.h, SDL_config_pandora.h, and SDL_config_wiz.h: define HAVE_DLOPEN. Closes: https://github.com/libsdl-org/SDL/pull/4351
Aaron Plattner 1e07dba0 2021-06-09T15:26:38 x11: Use glXChooseFBConfig when available in X11_GL_GetVisual When choosing an X11 Visual for a window based on its GLX capabilities, first try glXChooseFBConfig (if available) before falling back to glXChooseVisual. This normally does not make a difference because most GLX drivers create a Visual for every GLXFBConfig, exposing all of the same capabilities. For GLX render offload configurations (also know as "PRIME") where one GPU is providing GLX rendering support for windows on an X screen running on a different GPU, the GPU doing the offloading needs to use the Visuals that were created by the host GPU's driver rather than being able to add its own. This means that there may be fewer Visuals available for all of the GLXFBConfigs the guest driver wants to expose. In order to handle that situation, the NVIDIA GLX driver creates many GLXFBConfigs that map to the same Visual when running in a render offload configuration. This can result in a glXChooseVisual request failing to find a supported Visual when there is a GLXFBConfig for that configuration that would have worked. For example, when the game "Unnamed SDVX Clone" [1] tries to create a configuration with multisample, glXChooseVisual fails because the Visual assigned to the multisample GLXFBConfigs is shared with the GLXFBConfigs without multisample. Avoid this problem by using glXChooseFBConfig, when available, to find a GLXFBConfig with the requested capabilities and then using glXGetVisualFromFBConfig to find the corresponding X11 Visual. This allows the game to run, although it doesn't make me any better at actually playing it... Signed-off-by: Aaron Plattner <aplattner@nvidia.com> Fixes: https://forums.developer.nvidia.com/t/prime-run-cannot-create-window-x-glxcreatecontext/180214 [1] https://github.com/Drewol/unnamed-sdvx-clone
Sam Lantinga 9130f7c3 2021-01-02T10:25:38 Updated copyright for 2021
Sam Lantinga cb361896 2020-12-09T07:16:22 Fixed bug 5235 - All internal sources should include SDL_assert.h Ryan C. Gordon We should really stick this in SDL_internal.h or something so it's always available.
Sam Lantinga ce293eed 2020-06-23T10:12:24 Fixed bug 5208 - Fix libGL loading on OpenBSD
Sam Lantinga e05d92a1 2020-04-05T09:01:33 Fixed bug 5075 - Don't assume a GL library version number on NetBSD. Nia Alarie If you install X as part of NetBSD, the GL library is libGL.so.3, but if you install the GL library later as a package, it's libGL.so.1.
Sam Lantinga 4b585e75 2020-02-03T08:06:52 Fixed bug 4833 - Use EGL for X11? Martin Fiedler To be precise, this is about *desktop OpenGL* on X11. For OpenGL ES, EGL is already used (as it's the only way to get an OpenGL ES context), as Sylvain noted above. To shine some light on why this is needed: In 99% of all cases, using GLX on X11 is fine, even though it's effectively deprecated in favor of EGL [1]. However, there's at least one use case that *requires* the OpenGL context being created with EGL instead of GLX, and that's DRM_PRIME interoperability: The function glEGLImageTargetTexture2DOES simply doesn't work with GLX. (Currently, Mesa actually crashes when trying that.) Some example code: https://gist.github.com/kajott/d1b29c613be30893c855621edd1f212e Runs on Intel and open-source AMD drivers just fine (others unconfirmed), but with #define USE_EGL 0 (i.e. forcing it to GLX), it crashes. The same happens when using SDL for window and context creation. The good news is that most of the pieces for EGL support on X11 are already in place: SDL_egl.c is pretty complete (and used for desktop OpenGL on Wayland, for example), and SDL_x11opengl.c has the aforementioned OpenGL-ES-on-EGL support. However, when it comes to desktop OpenGL, it's hardcoded to fall back to GLX. I'm not advocating to make EGL the default for desktop OpenGL on X11; don't fix what ain't broken. But something like an SDL_HINT_VIDEO_X11_FORCE_EGL would be very appreciated to make use cases like the above work with SDL. [1] source: Eric Anholt, major Linux graphics stack developer, 7 years ago already - see last paragraph of https://www.phoronix.com/scan.php?page=news_item&px=MTE3MTI
Sam Lantinga a8780c6a 2020-01-16T20:49:25 Updated copyright date for 2020
Ryan C. Gordon ed7483f8 2019-10-15T22:36:08 x11: On macOS, look for X11 install in /opt/X11 instead of /usr/X11R6. This is where Apple installs XQuartz now (and apparently, the compatibility symlink at /usr/X11R6 can be missing). Fixes Bugzilla #4706.
Sam Lantinga 5e13087b 2019-01-04T22:01:14 Updated copyright for 2019
sezero 40b27fd5 2018-02-12T17:00:00 revert the recent typecast assignment changes (see bug #4079) also change the void* typedefs for the two vulkan function pointers added in vulkan_internal.h into generic function pointer typedefs.
Sam Lantinga 90e72bf4 2018-01-30T18:08:34 Fixed ISO C99 compatibility SDL now builds with gcc 7.2 with the following command line options: -Wall -pedantic-errors -Wno-deprecated-declarations -Wno-overlength-strings --std=c99
Sam Lantinga e3cc5b2c 2018-01-03T10:03:25 Updated copyright for 2018
Sven Hesse b89cac67 2017-10-22T20:24:58 Don't X error in SDL_CreateWindow with unsupported GL attributes
Ryan C. Gordon 74043994 2017-09-01T14:08:09 x11: Correctly restore previous GL context after sacrificial context is done.
Ryan C. Gordon a3dda100 2017-09-01T14:00:11 x11: don't try to make a NULL GL context current when we already did that.
Ryan C. Gordon 4649ac46 2017-09-01T13:57:40 x11: Clean up sacrificial GL context code. Check for failures, restore any previously-current context.
Ryan C. Gordon 507659c6 2017-09-01T13:27:53 x11: Make a sacrificial glX context to check for extensions during init. This is necessary because we need to see if GLES compat extensions exist. All of this code (including ShouldUseTextureFramebuffer()) should be revisited after 2.0.6 ships; ideally we don't make throwaway contexts if we can avoid it...but maybe we can't. I hear Vulkan is pretty cool. Fixes Bugzilla #3725.
Ethan Lee 685890a2 2017-08-24T22:57:42 Fix KHR_no_error support
Ryan C. Gordon d8fc70ea 2017-08-24T21:30:53 opengl: add support for GL_KHR_no_error. This is completely untested! Fixes Bugzilla #3721.
Ryan C. Gordon 01e0d8fc 2017-08-19T15:02:03 opengl: Add support for [GLX|WGL]_ARB_create_context_robustness. This patch was originally written by Marc Di Luzio for glX and enhanced by Maximilian Malek for WGL, etc. Thanks to both of you! Fixes Bugzilla #3643. Fixes Bugzilla #3735.
Philipp Wiesemann 266816b4 2017-03-26T21:00:19 Removed newlines from error messages.
Sam Lantinga a52d48c5 2017-01-10T08:54:33 Fixed bugs 2570, 3145, improved OpenGL ES context support on Windows and X11 Mark Callow The attached patch does the following for the X11 and Windows platforms, the only ones where SDL attempts to use context_create_es_profile: - Adds SDL_HINT_OPENGL_ES_DRIVER by which the application can say to use the OpenGL ES driver & EGL rather than the Open GL driver. (For bug #2570) - Adds code to {WIN,X11}_GL_InitExtensions to determine the maximum OpenGL ES version supported by the OpenGL driver (for bug #3145) - Modifies the test that determines whether to use the OpenGL driver or the real OpenGL ES driver to take into account the hint, the requested and supported ES version and whether ES 1.X is being requested. (For bug #2570 & bug #3145) - Enables the testgles2 test for __WINDOWS__ and __LINUX__ and adds the test to the VisualC projects. With the fix in place I have run testdraw2, testgl and testgles2 without any issues and have run my own apps that use OpenGL, OpenGL ES 3 and OpenGL ES 1.1.
Ryan C. Gordon 13f2e542 2017-01-07T19:55:29 x11: make the X11 target work on macOS with Xquartz.
Sam Lantinga 45b774e3 2017-01-01T18:33:28 Updated copyright for 2017
Sam Lantinga 524bf3c2 2016-12-09T01:47:43 Fixed bug 3513 - SDL_GL_SwapWindow does not return error status Return an error code from SDL_GL_SwapWindow(), like the other SDL APIs.
Sam Lantinga 0d24495b 2016-11-15T01:24:58 Removed unused constants Except for SDL_bmp.c where they are historically interesting and I've left them in.
Sam Lantinga 57d01d7d 2016-11-13T22:57:41 Patch from Sylvain to fix clang warnings
Sam Lantinga a1f42765 2016-11-01T10:46:47 Patch from Tapani P?lli to fix a memory leak in X11_GL_CreateContext
Philipp Wiesemann d7b9d321 2016-05-20T22:15:28 X11: Fixed typos in error messages and source comments.
Philipp Wiesemann e964d00f 2016-05-11T21:11:12 X11: Fixed SDL_GL_GetSwapInterval() returning -1 if interval is unknown. It should return 0 as a safe default if the interval can not be determined.
Sam Lantinga 42065e78 2016-01-02T10:10:34 Updated copyright to 2016
Ryan C. Gordon f5cf8676 2015-07-28T00:12:50 x11: Catch fatal X errors when calling glXMakeCurrent(). In extremely rare cases, probably due to misconfigured drivers, one might see this happen, and rather than terminate the process, we try to recover by reporting an error to the app. Fixes Bugzilla #3068.
Philipp Wiesemann 0e45984f 2015-06-21T17:33:46 Fixed crash if initialization of EGL failed but was tried again later. The internal function SDL_EGL_LoadLibrary() did not delete and remove a mostly uninitialized data structure if loading the library first failed. A later try to use EGL then skipped initialization and assumed it was previously successful because the data structure now already existed. This led to at least one crash in the internal function SDL_EGL_ChooseConfig() because a NULL pointer was dereferenced to make a call to eglBindAPI().
Sam Lantinga 2c4a6ea0 2015-05-26T06:27:46 Updated the copyright year to 2015
Ryan C. Gordon b72938c8 2015-04-20T12:22:44 Windows: Always set the system timer resolution to 1ms by default. An existing hint lets apps that don't need the timer resolution changed avoid this, to save battery, etc, but this fixes several problems in timing, audio callbacks not firing fast enough, etc. Fixes Bugzilla #2944.
Alex Szpakowski fe6c797c 2015-04-10T23:30:31 Fixed an iOS view orientation issue when SDL_GL_CreateContext or SDL_CreateRenderer is called.
Ryan C. Gordon f3590aba 2015-04-06T00:11:58 X11: Always specify "True" if setting GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB. Fixes Bugzilla #2897.
Ryan C. Gordon 83aeb31d 2015-04-06T00:10:54 This function can be static.
Marc Di Luzio f5d96416 2015-03-06T16:03:40 Allow setting of GL_CONTEXT_RELEASE_BEHAVIOR when creating the GL context when GLX_ARB_context_flush_control is available. This extension allows the user to specify whether a full flush is performed when making a context not current. The only way to set this currently is at context creation, so this patch provides that functionality. Defualt behaviour is set at FLUSH, as per the spec. This patch does not contain the changes to WGL, appleGL or other platforms as I do not have access to GL 4.5 hardware on those platforms. Full details on the use of KHR_context_flush_control can be found here: https://www.opengl.org/registry/specs/KHR/context_flush_control.txt
Ryan C. Gordon f75d6c09 2015-02-17T23:00:46 X11: Don't create a window and GL context to look up the glX extension string. It's not necessary.
Ryan C. Gordon f0c061d1 2015-02-17T22:59:56 glX HasExtension(): check for NULL ext string first. It's slightly faster than failing later, after a strchr() call, since this will get called multiple times with a NULL string if the system totally fails elsewhere.
Edward Rudd b88ca1b4 2015-02-10T16:28:56 the last parameter of XChangeProperty is the number of elements.. and when the element format is 32.. the element is "long" so we have 5 long elements here. Yes this seems confusing as on mac+linux Long is either 32 or 64bits depending on the architecture, but this is how the X11 protocol is defined. Thus 5 is the correct value for the nelts here. Not 5 or 10 depending on the architecture. More info on the confusion https://bugs.freedesktop.org/show_bug.cgi?id=16802
Ryan C. Gordon ece8d2bb 2015-02-02T01:05:41 X11: Fixes for OpenGL 3.0 and later context creation. - Don't create a temporary context first; this was probably due to Windows needing one to get the address of wglCreateContextAttribsARB(), but that's a unique quirk of WGL, and doesn't apply to glX. The glX spec explicitly says you have to get a function pointer that works with any context from glXGetProcAddress(), including when no context exists. - Properly check for the GLX_ARB_create_context instead of just looking for a non-NULL glXCreateContextAttribsARB()...some implementations, like Mesa, never return NULL for function lookups (Mesa returns pointers into a jump table that is filled out when the GL is initialized; since you can look up functions before you have a valid context, it can't definitely say a function isn't valid at that point).
Philipp Wiesemann b48e54aa 2015-01-26T22:00:29 Fixed bug 2802 - [patch] Fix android build compiling in wrong filesystem implementation Jonas Kulla The configure script didn't differentiate between Linux and Android, unconditionally compiling in the unix implementation of SDL_sysfilesystem.c. I'm probably one of the very few people building SDL for android using classic configure + standalone toolchain, so this has gone undetected all along.
David Ludwig 70438be2 2014-12-03T10:55:23 WinRT: fixed bug whereby SDL would override an app's default orientation WinRT apps can set a default, preferred orientation via a .appxmanifest file. SDL was overriding this on app startup, and making the app use all possible orientations (landscape and portrait). Thanks to Eric Wing for the heads up on this!
Philipp Wiesemann 9c398852 2014-11-22T22:20:40 Corrected header file documentation comment.
Pierre-Loup A. Griffais 24c86b55 2014-09-11T19:24:42 [X11] Reconcile logical keyboard state with physical state on FocusIn since the window system doesn't do it for us like other platforms. This prevents sticky keys and missed keys when going in and out of focus, for example Alt would appear to stick if switching away from an SDL app with Alt-Tab and had to be pressed again. CR: Sam
Sam Lantinga 610225b4 2014-06-28T19:51:26 Fixed null terminating the X11 error string
J?rgen P. Tjern? c1e11f69 2014-06-03T21:13:00 X11: Provide specific X error when SDL_GL_CreateContext fails. This makes the X error handler used for GL context creation handle *all* errors and provide the user with specific error messages when SDL_GL_CreateContext fails. CR: icculus@icculus.org
David Ludwig 3dcb451f 2014-04-09T21:29:19 Added a README file regarding WinRT support To note, this file is currently formatted with CRLF line endings, rather than LF, to allow the file to be viewed with Notepad.
Sam Lantinga 58edac3e 2014-02-02T00:53:27 Fixed bug 2374 - Update copyright for 2014... Is it that time already??
Gabriel Jacobo f848adff 2013-11-29T10:06:08 Improve Android pause/resume behavior.
Ryan C. Gordon 7e1289af 2013-11-24T23:56:17 Make internal SDL sources include SDL_internal.h instead of SDL_config.h The new header will include SDL_config.h, but allows for other global stuff.
Ryan C. Gordon 0e699eb5 2013-10-20T21:18:05 Added SDL_GL_FRAMEBUFFER_SRGB_CAPABLE (thanks, David!). Fixes Bugzilla #1985.
Ryan C. Gordon a2bd8970 2013-10-18T01:36:41 Don't supply duplicate X11 symbols inside SDL. Fixes static linking when something else also uses X11.
Gabriel Jacobo ace1e98a 2013-08-29T15:02:32 Fixes bug #2040, prepare SDL_GL_CONTEXT_EGL for deprecation on v2.1 SDL_GL_CONTEXT_EGL = 1 is now internally treated as profile_mask = SDL_GL_CONTEXT_PROFILE_ES
Sam Lantinga f79fc33a 2013-08-29T08:29:21 Christoph Mallon: Remove pointless if (x) before SDL_free(x)
Gabriel Jacobo 2490166d 2013-08-21T10:12:16 Fixes for -Wdeclaration-after-statement
Gabriel Jacobo 0eeb76d8 2013-08-19T16:29:46 Fixes bug #2037, common EGL code for Android and X11
Gabriel Jacobo dad42067 2013-08-12T11:13:50 Fixes #2022, do not resume on Android when surfaceChanged If the app is in landscape mode and the user presses the power button, a pause is followed immediately by a surfaceChanged event because the lock screen is shown in portrait mode. This triggers a "false" resume. So, we just pause and resume following the onWindowFocusChanged events. Also, wait for SDL_APP_WILLENTERBACKGROUND and SDL_APP_DIDENTERBACKGROUND before blocking the event pump.
Sam Lantinga 1ad936eb 2013-08-11T19:56:43 Fixed bug 2027 - Full-screen appears to be broken - hang in SDL_DestroyWindow() Rainer Deyke I'm running Linux Mint 15 with the Cinnamon window manager. SDL_DestroyWindow consistently locks up for me when the window if fullscreen.
Sam Lantinga e14e0ef9 1970-01-01T04:04:21 Fixed crash if the OpenGL library hasn't been loaded yet