godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.37k stars 21.26k forks source link

Godot does not open on compatibility renderer (self-compiled without ANGLE, old AMD GPU) #86941

Closed LimaneGaya closed 8 months ago

LimaneGaya commented 10 months ago

Tested versions

System information

Windows 11 - Godot Engine v4.3.dev.custom_build.c8c483cf5 - opengl3

Issue description

Theres an error that occures when using opengl3 that didn't happen in previous versions of godot 4.2.1 stable

When opening in Godot 4.2.1.stable:

Godot Engine v4.2.1.stable.official.b09f793f5 - https://godotengine.org
OpenGL API 3.3.13596 Core Profile Forward-Compatible Context 20.10.35.02 27.20.1034.6 - Compatibility - Using Device: ATI Technologies Inc. - AMD Radeon HD 8200 / R3 Series

When opening in latest master commit:

WARNING: Your video card drivers seem not to support the required OpenGL 3.3 version, switching to ANGLE.
     at: DisplayServerWindows::DisplayServerWindows (platform\windows\display_server_windows.cpp:4733)
ERROR: Can't load EGL.
   at: (drivers\egl\egl_manager.cpp:351)
ERROR: Unable to create DisplayServer, all display drivers failed.
Use "--headless" command line argument to run the engine in headless mode if this is desired (e.g. for continuous integration).
   at: Main::setup2 (main\main.cpp:2466)
ERROR: BUG: Unreferenced static string to 0: TextServerDummy
   at: StringName::unref (core\string\string_name.cpp:129)

When opening in latest master commit with opengl3_angle:

 .\godot.windows.editor.x86_64.exe --rendering-driver opengl3_angle
Godot Engine v4.3.dev.custom_build.c8c483cf5 - https://godotengine.org
ERROR: Can't load EGL.
   at: (drivers\egl\egl_manager.cpp:351)
ERROR: Unable to create DisplayServer, all display drivers failed.
Use "--headless" command line argument to run the engine in headless mode if this is desired (e.g. for continuous integration).
   at: Main::setup2 (main\main.cpp:2466)
ERROR: BUG: Unreferenced static string to 0: TextServerDummy
   at: StringName::unref (core\string\string_name.cpp:129)

Works fine in Forward+

ss

Steps to reproduce

openning godot.

Minimal reproduction project (MRP)

text (2).zip

kleonc commented 10 months ago

Can reproduce on AMD Radeon HD 6450, this is a regression from #85273. cc @bruvzg

The problem is it's forced to use ANGLE even though it reports to support OpenGL 3.3 (gl_info["version"].operator int() returns 30003).

Because fallback_to_angle defaults to true it makes the Project Manager fail to open if ANGLE fails to initialize. (Can a project setting be overridden for running the Project Manager? :thinking:)

To successfully open a project in the latest master one would need to manually set [rendering] gl_compatibility/fallback_to_angle=false in the project.godot/override.cfg and open the project directly (e.g. via cmd), skipping the Project Manager.

+The warning message is misleading, it states that the drivers don't support OpenGL 3.3 while this is not necessarily true, after disabling fallback_to_angle it launches just fine (contrary to ANGLE failing to initilize).

https://github.com/godotengine/godot/blob/c8c483cf57a768110fce57e509f9b855e69d34b7/main/main.cpp#L1785 https://github.com/godotengine/godot/blob/c8c483cf57a768110fce57e509f9b855e69d34b7/platform/windows/display_server_windows.cpp#L4717-L4736

$ ./bin/godot.windows.editor.dev.x86_64.exe -v --rendering-driver opengl3
Godot Engine v4.3.dev.custom_build.ef58929e7 - https://godotengine.org
TextServer: Added interface "Dummy"
TextServer: Added interface "ICU / HarfBuzz / Graphite (Built-in)"
Native OpenGL API detected: 3.3: ATI Technologies Inc. - AMD Radeon HD 6450
WARNING: Your video card drivers seem not to support the required OpenGL 3.3 version, switching to ANGLE.
     at: DisplayServerWindows::DisplayServerWindows (platform\windows\display_server_windows.cpp:4733)
ERROR: Can't load EGL.
   at: (drivers\egl\egl_manager.cpp:351)
ERROR: Unable to create DisplayServer, all display drivers failed.
Use "--headless" command line argument to run the engine in headless mode if this is desired (e.g. for continuous integration).
   at: Main::setup2 (main\main.cpp:2466)
ERROR: BUG: Unreferenced static string to 0: TextServerDummy
   at: StringName::unref ({godot-path}/core/string/string_name.cpp:129)
Segmentation fault

Crash stacktrace (crash after failing to create DisplayServer is likely a separate issue):

godot.windows.editor.dev.x86_64.exe!_err_print_error(const char * p_function, const char * p_file, int p_line, const char * p_error, const char * p_message, bool p_editor_notify, ErrorHandlerType p_type) Line 98 ({godot-path}\core\error\error_macros.cpp:98)
godot.windows.editor.dev.x86_64.exe!_err_print_error(const char * p_function, const char * p_file, int p_line, const String & p_error, bool p_editor_notify, ErrorHandlerType p_type) Line 81 ({godot-path}\core\error\error_macros.cpp:81)
godot.windows.editor.dev.x86_64.exe!StringName::unref() Line 129 ({godot-path}\core\string\string_name.cpp:129)
godot.windows.editor.dev.x86_64.exe!StringName::~StringName() Line 195 ({godot-path}\core\string\string_name.h:195)
godot.windows.editor.dev.x86_64.exe!KeyValue<StringName,ClassDB::ClassInfo>::~KeyValue<StringName,ClassDB::ClassInfo>() (Unknown Source:0)
godot.windows.editor.dev.x86_64.exe!HashMapElement<StringName,ClassDB::ClassInfo>::~HashMapElement<StringName,ClassDB::ClassInfo>() (Unknown Source:0)
godot.windows.editor.dev.x86_64.exe!HashMapElement<StringName,ClassDB::ClassInfo>::`scalar deleting destructor'(unsigned int) (Unknown Source:0)
godot.windows.editor.dev.x86_64.exe!memdelete<HashMapElement<StringName,ClassDB::ClassInfo>>(HashMapElement<StringName,ClassDB::ClassInfo> * p_class) Line 112 ({godot-path}\core\os\memory.h:112)
godot.windows.editor.dev.x86_64.exe!DefaultTypedAllocator<HashMapElement<StringName,ClassDB::ClassInfo>>::delete_allocation(HashMapElement<StringName,ClassDB::ClassInfo> * p_allocation) Line 206 ({godot-path}\core\os\memory.h:206)
godot.windows.editor.dev.x86_64.exe!HashMap<StringName,ClassDB::ClassInfo,HashMapHasherDefault,HashMapComparatorDefault<StringName>,DefaultTypedAllocator<HashMapElement<StringName,ClassDB::ClassInfo>>>::clear() Line 266 ({godot-path}\core\templates\hash_map.h:266)
godot.windows.editor.dev.x86_64.exe!HashMap<StringName,ClassDB::ClassInfo,HashMapHasherDefault,HashMapComparatorDefault<StringName>,DefaultTypedAllocator<HashMapElement<StringName,ClassDB::ClassInfo>>>::~HashMap<StringName,ClassDB::ClassInfo,HashMapHasherDefault,HashMapComparatorDefault<StringName>,DefaultTypedAllocator<HashMapElement<StringName,ClassDB::ClassInfo>>>() Line 618 ({godot-path}\core\templates\hash_map.h:618)
godot.windows.editor.dev.x86_64.exe!`dynamic atexit destructor for 'ClassDB::classes''() (Unknown Source:0)
...
bruvzg commented 10 months ago

Reproducible in the latest master ERROR: Can't load EGL.

Make sure you are building with ANGLE enabled, download and unzip release from https://github.com/godotengine/godot-angle-static and add angle_libs={path_to_unzipped_folder} build flag.

Or download Minimal Distribution of CEF from https://cef-builds.spotifycdn.com/index.html and extract libEGL.dll and libGLESv2.dll to the Godot executable folder.

kleonc commented 10 months ago

Make sure you are building with ANGLE enabled, download and unzip release from https://github.com/godotengine/godot-angle-static and add angle_libs={path_to_unzipped_folder} build flag.

Or download Minimal Distribution of CEF from https://cef-builds.spotifycdn.com/index.html and extract libEGL.dll and libGLESv2.dll to the Godot executable folder.

This indeed does the thing.

So probably the alerts shown to the user should be updated to take ANGLE into account: (currently it would show the last one complaining about OpenGL 3.3, not mentioning anything about ANGLE) https://github.com/godotengine/godot/blob/35da70f953f6eeba6ba7b13795029d7a134a61fd/platform/windows/display_server_windows.cpp#L4847-L4873

LimaneGaya commented 10 months ago

This seems to work now after adding libEGL.dll and libGLESv2.dll. But why was this change implemented? Is it a deliberate choice that we have to use angle going forward? even when opengl3 worked fine untill now? or is it an actual bug? Isn't it possible to run godot like before? and how will this affect performance?

bruvzg commented 10 months ago

Is it a deliberate choice that we have to use angle going forward?

It is a deliberate choice specifically for the old AMD GPUs (listed in https://github.com/godotengine/godot/pull/85273/files) that have a lot of issues with native OpenGL drivers. Relatively modern GPUs (GCN 4th gen +) should use native driver.

You can override this behavior in the project settings, by unsetting rendering/gl_compatibility/fallback_to_angle or changing the affected GPU list in the rendering/gl_compatibility/force_angle_on_devices.

akien-mga commented 8 months ago

@bruvzg Can we add logic so that if the ANGLE libs are missing, rendering/gl_compatibility/force_angle_on_devices and rendering/gl_compatibility/fallback_to_angle are bypassed? I.e. we fallback to native GL from the fallback to ANGLE? :)