Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash GLManager_X11::set_use_vsync(bool) #68722

Closed
alcomposer opened this issue Nov 16, 2022 · 1 comment · Fixed by #68727
Closed

Crash GLManager_X11::set_use_vsync(bool) #68722

alcomposer opened this issue Nov 16, 2022 · 1 comment · Fixed by #68727

Comments

@alcomposer
Copy link
Contributor

alcomposer commented Nov 16, 2022

Godot version

#68700

System information

Arch Linux, GeForce RTX 3090 driver: nvidia v: 520.56.06

Issue description

I get a crash on load for latest build. This call crashes my system:
uname -a:
Linux stream 6.0.8-arch1-1
INXI -G:

Graphics:
  Device-1: NVIDIA GA102 [GeForce RTX 3090] driver: nvidia v: 520.56.06
  Display: x11 server: X.Org v: 21.1.4 with: Xwayland v: 22.1.5 driver: X:
    loaded: nvidia gpu: nvidia,nvidia-nvswitch resolution: 1: 1920x1080~60Hz
    2: 1920x1080~60Hz
  API: OpenGL v: 4.6.0 NVIDIA 520.56.06 renderer: NVIDIA GeForce RTX
    3090/PCIe/SSE2

backtrace:

(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x0000555555ff7e2f in GLManager_X11::set_use_vsync(bool) ()
#2  0x0000555555fd6b14 in DisplayServerX11::window_set_vsync_mode(DisplayServer::VSyncMode, int) ()
#3  0x0000555555fe395a in DisplayServerX11::_create_window(DisplayServer::WindowMode, DisplayServer::VSyncMode, unsigned int, Rect2i const&) ()

Placing setup code for glXSwapIntervalEXT/MESA/SGI fixes this. This was removed at some point, old file was:
context_gl_x11.cpp

--- a/platform/linuxbsd/x11/gl_manager_x11.cpp
+++ b/platform/linuxbsd/x11/gl_manager_x11.cpp
@@ -330,6 +330,7 @@ Error GLManager_X11::initialize() {
 }
 
 void GLManager_X11::set_use_vsync(bool p_use) {
+       static bool setup = false;
        static PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT = nullptr;
        static PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalMESA = nullptr;
        static PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI = nullptr;
@@ -346,6 +347,17 @@ void GLManager_X11::set_use_vsync(bool p_use) {
        }
        const GLDisplay &disp = get_current_display();
 
+       if (!setup) {
+               setup = true;
+               String extensions = glXQueryExtensionsString(disp.x11_display, DefaultScreen(disp.x11_display));
+               if (extensions.find("GLX_EXT_swap_control") != -1)
+                       glXSwapIntervalEXT  = (PFNGLXSWAPINTERVALEXTPROC) glXGetProcAddressARB((const GLubyte*)"glXSwapIntervalEXT");
+               if (extensions.find("GLX_MESA_swap_control") != -1)
+                       glXSwapIntervalMESA = (PFNGLXSWAPINTERVALSGIPROC) glXGetProcAddressARB((const GLubyte*)"glXSwapIntervalMESA");
+               if (extensions.find("GLX_SGI_swap_control") != -1)
+                       glXSwapIntervalSGI  = (PFNGLXSWAPINTERVALSGIPROC) glXGetProcAddressARB((const GLubyte*)"glXSwapIntervalSGI");
+       }
+
        int val = p_use ? 1 : 0;
        if (GLAD_GLX_MESA_swap_control) {
                glXSwapIntervalMESA(val);

Steps to reproduce

Build and run Godot editor

Minimal reproduction project

No response

@alcomposer
Copy link
Contributor Author

Apparently already fixed with: #68714 (comment)
I can confirm that this solution works.

@akien-mga akien-mga added this to the 4.0 milestone Nov 16, 2022
akien-mga added a commit to akien-mga/godot that referenced this issue Nov 16, 2022
Fixes godotengine#68722.

Co-authored-by: alcomposer <alex.w.mitchell@gmail.com>
rohanrhu pushed a commit to rohanrhu/godot that referenced this issue Dec 19, 2022
Fixes godotengine#68722.

Co-authored-by: alcomposer <alex.w.mitchell@gmail.com>
rohanrhu pushed a commit to rohanrhu/godot that referenced this issue Dec 28, 2022
Fixes godotengine#68722.

Co-authored-by: alcomposer <alex.w.mitchell@gmail.com>
rohanrhu pushed a commit to rohanrhu/godot that referenced this issue Dec 28, 2022
Fixes godotengine#68722.

Co-authored-by: alcomposer <alex.w.mitchell@gmail.com>
Streq pushed a commit to Streq/godot that referenced this issue Feb 9, 2023
Fixes godotengine#68722.

Co-authored-by: alcomposer <alex.w.mitchell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants