Index | Thread | Search

From:
Thomas Frohwein <tfrohwein@fastmail.com>
Subject:
Disabling DRI_PRIME use in godot/*
To:
ports@openbsd.org
Cc:
jsg@jsg.id.au, op@omarpolo.com
Date:
Thu, 19 Mar 2026 08:58:03 -0700

Download raw body.

Thread
Hi,

Godot has shown stdout messages about trying to set DRI_PRIME for a
while. From my prior discussions and testing, we don't have support for
this (yet), and when I tested it once, the laptop with iGPU and dGPU
just hung.

I'm therefore planning to disable the parts of the godot/* ports that
set DRI_PRIME to avoid errors of the kind until we may have working
DRI_PRIME. I will commit this in the next days unless there are
concerns about this.

Index: pack1/Makefile
===================================================================
RCS file: /cvs/ports/games/godot/pack1/Makefile,v
diff -u -p -r1.2 Makefile
--- pack1/Makefile	5 Mar 2026 08:33:59 -0000	1.2
+++ pack1/Makefile	19 Mar 2026 15:04:47 -0000
@@ -6,6 +6,7 @@ COMMENT-sharp=	.NET libs for mono/C# mod
 VERSION =	3.6.2
 PKGNAME =	godot3-${VERSION}
 SHARPFILES_V =	3.5.2
+REVISION =	0
 
 MULTI_PACKAGES =	-main -sharp
 
Index: pack1/patches/patch-platform_x11_detect_prime_cpp
===================================================================
RCS file: /cvs/ports/games/godot/pack1/patches/patch-platform_x11_detect_prime_cpp,v
diff -u -p -r1.1.1.1 patch-platform_x11_detect_prime_cpp
--- pack1/patches/patch-platform_x11_detect_prime_cpp	4 Mar 2026 05:35:04 -0000	1.1.1.1
+++ pack1/patches/patch-platform_x11_detect_prime_cpp	19 Mar 2026 15:04:47 -0000
@@ -1,9 +1,23 @@
 we don't seem to have quick_exit; no big deal
+we don't support DRI_PRIME as of March 2026 and setting it can lead to crashes
+	in multi-GPU setups
 
 Index: platform/x11/detect_prime.cpp
 --- platform/x11/detect_prime.cpp.orig
 +++ platform/x11/detect_prime.cpp
-@@ -204,9 +204,8 @@ int detect_prime() {
+@@ -181,9 +181,11 @@ int detect_prime() {
+ 
+ 			close(fdset[0]);
+ 
++			/*
+ 			if (i) {
+ 				setenv("DRI_PRIME", "1", 1);
+ 			}
++			*/
+ 			create_context();
+ 
+ 			const char *vendor = (const char *)glGetString(GL_VENDOR);
+@@ -204,9 +206,8 @@ int detect_prime() {
  			}
  			close(fdset[1]);
  
Index: pack1/patches/patch-platform_x11_os_x11_cpp
===================================================================
RCS file: /cvs/ports/games/godot/pack1/patches/patch-platform_x11_os_x11_cpp,v
diff -u -p -r1.1.1.1 patch-platform_x11_os_x11_cpp
--- pack1/patches/patch-platform_x11_os_x11_cpp	4 Mar 2026 05:35:04 -0000	1.1.1.1
+++ pack1/patches/patch-platform_x11_os_x11_cpp	19 Mar 2026 15:04:47 -0000
@@ -1,6 +1,8 @@
 fix libXrandr library name and load sndio
 use OpenBSD joypad class
 suspend X11 screensaver for release builds
+we don't support DRI_PRIME as of March 2026 and setting it can lead to crashes
+	in multi-GPU setups
 
 Index: platform/x11/os_x11.cpp
 --- platform/x11/os_x11.cpp.orig
@@ -25,7 +27,23 @@ Index: platform/x11/os_x11.cpp
  	if (!xrandr_handle) {
  		err = dlerror();
  		// For some arcane reason, NetBSD now ships libXrandr.so.3 while the rest of the world has libXrandr.so.2...
-@@ -664,9 +668,13 @@ Error OS_X11::initialize(const VideoMode &p_desired, i
+@@ -336,6 +340,7 @@ Error OS_X11::initialize(const VideoMode &p_desired, i
+ 			}
+ 		}
+ 
++		/*
+ 		if (use_prime == -1) {
+ 			print_verbose("Detecting GPUs, set DRI_PRIME in the environment to override GPU detection logic.");
+ 			use_prime = detect_prime();
+@@ -346,6 +351,7 @@ Error OS_X11::initialize(const VideoMode &p_desired, i
+ 			print_line("Note: Set DRI_PRIME=0 in the environment to disable Godot from using the discrete GPU.");
+ 			setenv("DRI_PRIME", "1", 1);
+ 		}
++		*/
+ 	}
+ 
+ 	ContextGL_X11::ContextType opengl_api_type = ContextGL_X11::GLES_3_0_COMPATIBLE;
+@@ -664,9 +670,13 @@ Error OS_X11::initialize(const VideoMode &p_desired, i
  
  	window_has_focus = true; // Set focus to true at init
  #ifdef JOYDEV_ENABLED
@@ -40,7 +58,7 @@ Index: platform/x11/os_x11.cpp
  	power_manager = memnew(PowerX11);
  
  	if (p_desired.layered) {
-@@ -4474,6 +4482,11 @@ void OS_X11::update_real_mouse_position() {
+@@ -4474,6 +4484,11 @@ void OS_X11::update_real_mouse_position() {
  }
  
  OS_X11::OS_X11() {
Index: pack2/Makefile
===================================================================
RCS file: /cvs/ports/games/godot/pack2/Makefile,v
diff -u -p -r1.2 Makefile
--- pack2/Makefile	5 Mar 2026 08:33:59 -0000	1.2
+++ pack2/Makefile	19 Mar 2026 15:04:47 -0000
@@ -7,6 +7,7 @@ COMMENT =	2D and 3D game engine
 
 VERSION =	4.4.1
 PKGNAME =	godot44-${VERSION}
+REVISION =	0
 DIST_TUPLE +=	codeberg godotsteam godotsteam v4.3 godotsteam
 
 WANTLIB += ${COMPILER_LIBCXX} SPIRV X11 Xcursor Xext Xi Xinerama
Index: pack2/patches/patch-platform_linuxbsd_wayland_detect_prime_egl_cpp
===================================================================
RCS file: pack2/patches/patch-platform_linuxbsd_wayland_detect_prime_egl_cpp
diff -N pack2/patches/patch-platform_linuxbsd_wayland_detect_prime_egl_cpp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ pack2/patches/patch-platform_linuxbsd_wayland_detect_prime_egl_cpp	19 Mar 2026 15:04:47 -0000
@@ -0,0 +1,15 @@
+we don't support DRI_PRIME as of March 2026 and setting it can lead to crashes
+	in multi-GPU setups
+
+Index: platform/linuxbsd/wayland/detect_prime_egl.cpp
+--- platform/linuxbsd/wayland/detect_prime_egl.cpp.orig
++++ platform/linuxbsd/wayland/detect_prime_egl.cpp
+@@ -168,7 +168,7 @@ int DetectPrimeEGL::detect_prime(EGLenum p_platform_en
+ 
+ 			close(fdset[0]);
+ 
+-			setenv("DRI_PRIME", itos(i).utf8().ptr(), 1);
++			//setenv("DRI_PRIME", itos(i).utf8().ptr(), 1);
+ 
+ 			create_context(p_platform_enum);
+ 
Index: pack2/patches/patch-platform_linuxbsd_wayland_display_server_wayland_cpp
===================================================================
RCS file: pack2/patches/patch-platform_linuxbsd_wayland_display_server_wayland_cpp
diff -N pack2/patches/patch-platform_linuxbsd_wayland_display_server_wayland_cpp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ pack2/patches/patch-platform_linuxbsd_wayland_display_server_wayland_cpp	19 Mar 2026 15:04:47 -0000
@@ -0,0 +1,20 @@
+we don't support DRI_PRIME as of March 2026 and setting it can lead to crashes
+	in multi-GPU setups
+
+Index: platform/linuxbsd/wayland/display_server_wayland.cpp
+--- platform/linuxbsd/wayland/display_server_wayland.cpp.orig
++++ platform/linuxbsd/wayland/display_server_wayland.cpp
+@@ -1518,11 +1518,13 @@ DisplayServerWayland::DisplayServerWayland(const Strin
+ 				prime_idx = DetectPrimeEGL::detect_prime(EGL_PLATFORM_WAYLAND_KHR);
+ 			}
+ 
++			/*
+ 			if (prime_idx) {
+ 				print_line(vformat("Found discrete GPU, setting DRI_PRIME=%d to use it.", prime_idx));
+ 				print_line("Note: Set DRI_PRIME=0 in the environment to disable Godot from using the discrete GPU.");
+ 				setenv("DRI_PRIME", itos(prime_idx).utf8().ptr(), 1);
+ 			}
++			*/
+ 		}
+ 
+ 		if (rendering_driver == "opengl3") {
Index: pack2/patches/patch-platform_linuxbsd_x11_detect_prime_x11_cpp
===================================================================
RCS file: /cvs/ports/games/godot/pack2/patches/patch-platform_linuxbsd_x11_detect_prime_x11_cpp,v
diff -u -p -r1.1.1.1 patch-platform_linuxbsd_x11_detect_prime_x11_cpp
--- pack2/patches/patch-platform_linuxbsd_x11_detect_prime_x11_cpp	4 Mar 2026 05:35:04 -0000	1.1.1.1
+++ pack2/patches/patch-platform_linuxbsd_x11_detect_prime_x11_cpp	19 Mar 2026 15:04:47 -0000
@@ -1,3 +1,6 @@
+we don't support DRI_PRIME as of March 2026 and setting it can lead to crashes
+	in multi-GPU setups
+
 Index: platform/linuxbsd/x11/detect_prime_x11.cpp
 --- platform/linuxbsd/x11/detect_prime_x11.cpp.orig
 +++ platform/linuxbsd/x11/detect_prime_x11.cpp
@@ -10,3 +13,15 @@ Index: platform/linuxbsd/x11/detect_prim
  int silent_error_handler(Display *display, XErrorEvent *error) {
  	static char message[1024];
  	XGetErrorText(display, error->error_code, message, sizeof(message));
+@@ -192,9 +194,11 @@ int DetectPrimeX11::detect_prime() {
+ 
+ 			close(fdset[0]);
+ 
++			/*
+ 			if (i) {
+ 				setenv("DRI_PRIME", "1", 1);
+ 			}
++			*/
+ 
+ 			create_context();
+ 
Index: pack2/patches/patch-platform_linuxbsd_x11_display_server_x11_cpp
===================================================================
RCS file: /cvs/ports/games/godot/pack2/patches/patch-platform_linuxbsd_x11_display_server_x11_cpp,v
diff -u -p -r1.1.1.1 patch-platform_linuxbsd_x11_display_server_x11_cpp
--- pack2/patches/patch-platform_linuxbsd_x11_display_server_x11_cpp	4 Mar 2026 05:35:04 -0000	1.1.1.1
+++ pack2/patches/patch-platform_linuxbsd_x11_display_server_x11_cpp	19 Mar 2026 15:04:47 -0000
@@ -1,4 +1,6 @@
 fix libXrandr (double) loading attempt.
+we don't support DRI_PRIME as of March 2026 and setting it can lead to crashes
+	in multi-GPU setups
 
 Index: platform/linuxbsd/x11/display_server_x11.cpp
 --- platform/linuxbsd/x11/display_server_x11.cpp.orig
@@ -20,3 +22,17 @@ Index: platform/linuxbsd/x11/display_ser
  		}
  	}
  
+@@ -6855,11 +6855,13 @@ DisplayServerX11::DisplayServerX11(const String &p_ren
+ 				use_prime = DetectPrimeX11::detect_prime();
+ 			}
+ 
++			/*
+ 			if (use_prime) {
+ 				print_line("Found discrete GPU, setting DRI_PRIME=1 to use it.");
+ 				print_line("Note: Set DRI_PRIME=0 in the environment to disable Godot from using the discrete GPU.");
+ 				setenv("DRI_PRIME", "1", 1);
+ 			}
++			*/
+ 		}
+ 	}
+ 	if (rendering_driver == "opengl3") {
Index: pack3/Makefile
===================================================================
RCS file: /cvs/ports/games/godot/pack3/Makefile,v
diff -u -p -r1.1.1.1 Makefile
--- pack3/Makefile	4 Mar 2026 05:35:04 -0000	1.1.1.1
+++ pack3/Makefile	19 Mar 2026 15:04:47 -0000
@@ -8,6 +8,7 @@ COMMENT-editor=	2D and 3D game engine (w
 
 VERSION =	4.6.1
 PKGNAME =	godot-${VERSION}
+REVISION =	0
 DIST_TUPLE +=	codeberg godotsteam godotsteam v4.3 godotsteam
 
 MULTI_PACKAGES =	-main -editor
Index: pack3/patches/patch-platform_linuxbsd_wayland_detect_prime_egl_cpp
===================================================================
RCS file: pack3/patches/patch-platform_linuxbsd_wayland_detect_prime_egl_cpp
diff -N pack3/patches/patch-platform_linuxbsd_wayland_detect_prime_egl_cpp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ pack3/patches/patch-platform_linuxbsd_wayland_detect_prime_egl_cpp	19 Mar 2026 15:04:47 -0000
@@ -0,0 +1,15 @@
+we don't support DRI_PRIME as of March 2026 and setting it can lead to crashes
+	in multi-GPU setups
+
+Index: platform/linuxbsd/wayland/detect_prime_egl.cpp
+--- platform/linuxbsd/wayland/detect_prime_egl.cpp.orig
++++ platform/linuxbsd/wayland/detect_prime_egl.cpp
+@@ -165,7 +165,7 @@ int DetectPrimeEGL::detect_prime(EGLenum p_platform_en
+ 
+ 			close(fdset[0]);
+ 
+-			setenv("DRI_PRIME", itos(i).utf8().ptr(), 1);
++			//setenv("DRI_PRIME", itos(i).utf8().ptr(), 1);
+ 
+ 			create_context(p_platform_enum);
+ 
Index: pack3/patches/patch-platform_linuxbsd_wayland_display_server_wayland_cpp
===================================================================
RCS file: pack3/patches/patch-platform_linuxbsd_wayland_display_server_wayland_cpp
diff -N pack3/patches/patch-platform_linuxbsd_wayland_display_server_wayland_cpp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ pack3/patches/patch-platform_linuxbsd_wayland_display_server_wayland_cpp	19 Mar 2026 15:04:47 -0000
@@ -0,0 +1,20 @@
+we don't support DRI_PRIME as of March 2026 and setting it can lead to crashes
+	in multi-GPU setups
+
+Index: platform/linuxbsd/wayland/display_server_wayland.cpp
+--- platform/linuxbsd/wayland/display_server_wayland.cpp.orig
++++ platform/linuxbsd/wayland/display_server_wayland.cpp
+@@ -2150,11 +2150,13 @@ DisplayServerWayland::DisplayServerWayland(const Strin
+ 				prime_idx = DetectPrimeEGL::detect_prime(EGL_PLATFORM_WAYLAND_KHR);
+ 			}
+ 
++			/*
+ 			if (prime_idx) {
+ 				print_line(vformat("Found discrete GPU, setting DRI_PRIME=%d to use it.", prime_idx));
+ 				print_line("Note: Set DRI_PRIME=0 in the environment to disable Godot from using the discrete GPU.");
+ 				setenv("DRI_PRIME", itos(prime_idx).utf8().ptr(), 1);
+ 			}
++			*/
+ 		}
+ 
+ 		if (rendering_driver == "opengl3") {
Index: pack3/patches/patch-platform_linuxbsd_x11_detect_prime_x11_cpp
===================================================================
RCS file: /cvs/ports/games/godot/pack3/patches/patch-platform_linuxbsd_x11_detect_prime_x11_cpp,v
diff -u -p -r1.1.1.1 patch-platform_linuxbsd_x11_detect_prime_x11_cpp
--- pack3/patches/patch-platform_linuxbsd_x11_detect_prime_x11_cpp	4 Mar 2026 05:35:04 -0000	1.1.1.1
+++ pack3/patches/patch-platform_linuxbsd_x11_detect_prime_x11_cpp	19 Mar 2026 15:04:47 -0000
@@ -1,3 +1,6 @@
+we don't support DRI_PRIME as of March 2026 and setting it can lead to crashes
+	in multi-GPU setups
+
 Index: platform/linuxbsd/x11/detect_prime_x11.cpp
 --- platform/linuxbsd/x11/detect_prime_x11.cpp.orig
 +++ platform/linuxbsd/x11/detect_prime_x11.cpp
@@ -10,3 +13,15 @@ Index: platform/linuxbsd/x11/detect_prim
  int silent_error_handler(Display *display, XErrorEvent *error) {
  	static char message[1024];
  	XGetErrorText(display, error->error_code, message, sizeof(message));
+@@ -191,9 +193,11 @@ int DetectPrimeX11::detect_prime() {
+ 
+ 			close(fdset[0]);
+ 
++			/*
+ 			if (i) {
+ 				setenv("DRI_PRIME", "1", 1);
+ 			}
++			*/
+ 
+ 			create_context();
+ 
Index: pack3/patches/patch-platform_linuxbsd_x11_display_server_x11_cpp
===================================================================
RCS file: /cvs/ports/games/godot/pack3/patches/patch-platform_linuxbsd_x11_display_server_x11_cpp,v
diff -u -p -r1.1.1.1 patch-platform_linuxbsd_x11_display_server_x11_cpp
--- pack3/patches/patch-platform_linuxbsd_x11_display_server_x11_cpp	4 Mar 2026 05:35:04 -0000	1.1.1.1
+++ pack3/patches/patch-platform_linuxbsd_x11_display_server_x11_cpp	19 Mar 2026 15:04:47 -0000
@@ -1,4 +1,6 @@
 fix libXrandr (double) loading attempt.
+we don't support DRI_PRIME as of March 2026 and setting it can lead to crashes
+	in multi-GPU setups
 
 Index: platform/linuxbsd/x11/display_server_x11.cpp
 --- platform/linuxbsd/x11/display_server_x11.cpp.orig
@@ -20,3 +22,17 @@ Index: platform/linuxbsd/x11/display_ser
  		}
  	}
  
+@@ -7106,11 +7106,13 @@ DisplayServerX11::DisplayServerX11(const String &p_ren
+ 				use_prime = DetectPrimeX11::detect_prime();
+ 			}
+ 
++			/*
+ 			if (use_prime) {
+ 				print_line("Found discrete GPU, setting DRI_PRIME=1 to use it.");
+ 				print_line("Note: Set DRI_PRIME=0 in the environment to disable Godot from using the discrete GPU.");
+ 				setenv("DRI_PRIME", "1", 1);
+ 			}
++			*/
+ 		}
+ 	}
+ 	if (rendering_driver == "opengl3") {