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

Wayland: Add support for OpenGL ES driver #91466

Merged
merged 1 commit into from
May 3, 2024

Conversation

Riteo
Copy link
Contributor

@Riteo Riteo commented May 2, 2024

Fixes #91371.

Everything was already there, we just had to wire it up in the display server.

@akien-mga
Copy link
Member

Code looks super clean.

I tested it locally on Fedora 40 Wayland and it works great with:

$ godot-git --display-driver wayland --rendering-driver opengl3_es

However I tried to test the fallback code by setting MESA_GL_VERSION_OVERRIDE to something we don't support, and the fallback code seems to crash:

$ MESA_GL_VERSION_OVERRIDE=2.1 godot-git --display-driver wayland --rendering-method gl_compatibility
Godot Engine v4.3.dev.custom_build.1c4122376 (2024-05-02 17:49:46 UTC) - https://godotengine.org
Plugin "GTK3 plugin" uses conflicting symbol "png_free".
Invalid value (0) for DRI_PRIME. Should be > 0
Inconsistent value (2) for DRI_PRIME. Should be < 2 (GPU devices count). Using: 1
Inconsistent value (3) for DRI_PRIME. Should be < 2 (GPU devices count). Using: 1
ERROR: Can't create an EGL context. Error code: 12297
   at: _gldisplay_create_context (drivers/egl/egl_manager.cpp:171)
ERROR: Method/function failed. Returning: -1
   at: _get_gldisplay_id (drivers/egl/egl_manager.cpp:79)
ERROR: Condition "gldisplay_id < 0" is true. Returning: ERR_CANT_CREATE
   at: window_create (drivers/egl/egl_manager.cpp:202)
ERROR: Can't show a GLES3 window.
   at: _show_window (platform/linuxbsd/wayland/display_server_wayland.cpp:178)
ERROR: Error initializing GLAD.
   at: RasterizerGLES3 (drivers/gles3/rasterizer_gles3.cpp:271)

================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.3.dev.custom_build (1c41223767035888e1e6590caf90aca073080dd0)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /lib64/libc.so.6(+0x40710) [0x7f074e2e2710] (??:0)
[2] RendererSceneCull::set_scene_render(RendererSceneRender*) (/home/akien/Godot/godot/./servers/rendering/renderer_scene_cull.cpp:4238)
[3] RenderingServerDefault::RenderingServerDefault(bool) (/home/akien/Godot/godot/./servers/rendering/rendering_server_default.cpp:416)
[4] Main::setup2() (/home/akien/Godot/godot/main/main.cpp:2776 (discriminator 3))
[5] Main::setup(char const*, int, char**, bool) (/home/akien/Godot/godot/main/main.cpp:2429)
[6] godot-git(main+0xff) [0x5a9b965] (/home/akien/Godot/godot/platform/linuxbsd/godot_linuxbsd.cpp:74)
[7] /lib64/libc.so.6(+0x2a088) [0x7f074e2cc088] (??:0)
[8] /lib64/libc.so.6(__libc_start_main+0x8b) [0x7f074e2cc14b] (??:0)
[9] godot-git(_start+0x25) [0x5a9b7a5] (??:?)
-- END OF BACKTRACE --
================================================================
Aborted (core dumped)

While with X11 it seems to work:

$ MESA_GL_VERSION_OVERRIDE=2.1 godot-git --rendering-method gl_compatibility
Godot Engine v4.3.dev.custom_build.1c4122376 (2024-05-02 17:49:46 UTC) - https://godotengine.org
ERROR: Condition "ctxErrorOccurred || !gl_display.context->glx_context" is true. Returning: ERR_UNCONFIGURED
   at: _create_context (platform/linuxbsd/x11/gl_manager_x11.cpp:183)
WARNING: Your video card drivers seem not to support the required OpenGL version, switching to OpenGLES.
     at: DisplayServerX11 (platform/linuxbsd/x11/display_server_x11.cpp:6121)
OpenGL API OpenGL ES 3.2 Mesa 24.0.5 - Compatibility - Using Device: AMD - AMD Radeon Graphics (radeonsi, gfx1103_r1, LLVM 18.1.1, DRM 3.57, 6.8.7-300.1.copr.fc40.x86_64)

@akien-mga
Copy link
Member

This seems to fix it, and is similar to what X11 and is similar to what X11 and macOS do.

diff --git a/platform/linuxbsd/wayland/display_server_wayland.cpp b/platform/linuxbsd/wayland/display_server_wayland.cpp
index 6efa1de7d2..f4b9d79867 100644
--- a/platform/linuxbsd/wayland/display_server_wayland.cpp
+++ b/platform/linuxbsd/wayland/display_server_wayland.cpp
@@ -1331,7 +1331,7 @@ DisplayServerWayland::DisplayServerWayland(const String &p_rendering_driver, Win
 		if (rendering_driver == "opengl3") {
 			egl_manager = memnew(EGLManagerWayland);
 
-			if (egl_manager->initialize() != OK) {
+			if (egl_manager->initialize() != OK || egl_manager->open_display(nullptr) != OK) {
 				memdelete(egl_manager);
 				egl_manager = nullptr;
 

Then I get:

$ MESA_GL_VERSION_OVERRIDE=2.1 godot-git --rendering-method gl_compatibility
Godot Engine v4.3.dev.custom_build.1c4122376 (2024-05-02 17:49:46 UTC) - https://godotengine.org
ERROR: Condition "ctxErrorOccurred || !gl_display.context->glx_context" is true. Returning: ERR_UNCONFIGURED
   at: _create_context (platform/linuxbsd/x11/gl_manager_x11.cpp:183)
WARNING: Your video card drivers seem not to support the required OpenGL version, switching to OpenGLES.
     at: DisplayServerX11 (platform/linuxbsd/x11/display_server_x11.cpp:6121)
OpenGL API OpenGL ES 3.2 Mesa 24.0.5 - Compatibility - Using Device: AMD - AMD Radeon Graphics (radeonsi, gfx1103_r1, LLVM 18.1.1, DRM 3.57, 6.8.7-300.1.copr.fc40.x86_64)

@Riteo
Copy link
Contributor Author

Riteo commented May 3, 2024

@akien-mga thanks for testing and for the patch!

Indeed, it looks like EGLManager::initialize just loads EGL itself. #84288 added this new EGLManager::open_display method which also forces it to bind to the actual API too.

I'll push the patch which I can confirm also works on my machine with the steps you provided :D

Everything was already there, we just had to wire it up in the display
server.
@akien-mga akien-mga merged commit 479b2ab into godotengine:master May 3, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wayland DisplayServer does not properly support opengl3_es rendering driver
2 participants