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

Use OpenGL 3.3 Core Profile #7

Merged
merged 1 commit into from
Oct 26, 2021
Merged

Conversation

clayjohn
Copy link

@clayjohn clayjohn commented Oct 23, 2021

This removes enough deprecated functionality to make the Core Profile display correctly for editor usage.

The core profile changes were just made for Windows as I don't have a linux test environment right now.

You need to run in single window mode because creating separate windows still does not work.

But we now have all the basics for editor usage.

GLES3-working

@github-actions
Copy link

github-actions bot commented Oct 23, 2021

Download the artifacts for this pull request:

@Whimfoome
Copy link

Can confirm that it works on Linux with Wayland, but I don't know what Core Profile display really means
image
Got some opengl errors
drivers/opengl/shader_opengl.cpp:90 - Condition "!version" is true. Returning: false drivers/opengl/shader_opengl.cpp:90 - Condition "!version" is true. Returning: false

Also, not really related to this PR, but does the renderer switcher really need to be in the top right corner at all times? You change that option maybe once or twice for the whole project, I don't think we need it visible all the time.

@Calinou
Copy link
Owner

Calinou commented Oct 24, 2021

Also, not really related to this PR, but does the renderer switcher really need to be in the top right corner at all times? You change that option maybe once or twice for the whole project, I don't think we need it visible all the time.

The dropdown is useful for engine maintainers, as it lets us know which renderer is being used whenever an editor screenshot is posted somewhere 🙂

This makes troubleshooting easier.

@clayjohn
Copy link
Author

@Whimfoome Thank you for checking, but X11 is still set to Compatibility Profile. Once @Calinou merges this, he can update X11 to use core profile in the parent branch.

Those shader errors you see are unrelated to this PR. They come from 3D features which haven't been re-enabled yet.

@clayjohn clayjohn force-pushed the OPENGL branch 2 times, most recently from 262efa4 to 77dfa4f Compare October 25, 2021 01:07
@clayjohn
Copy link
Author

@Calinou this is ready for merging whenever you are available.

@Calinou
Copy link
Owner

Calinou commented Oct 25, 2021

@Calinou this is ready for merging whenever you are available.

I tried to run it on X11 with this change:

diff --git a/platform/linuxbsd/gl_manager_x11.cpp b/platform/linuxbsd/gl_manager_x11.cpp
index 5928ff3147..1b1c55a550 100644
--- a/platform/linuxbsd/gl_manager_x11.cpp
+++ b/platform/linuxbsd/gl_manager_x11.cpp
@@ -175,12 +175,10 @@ Error GLManager_X11::_create_context(GLDisplay &gl_display) {
 
 	switch (context_type) {
 		case GLES_3_0_COMPATIBLE: {
-			// FIXME: Use `GLX_CONTEXT_CORE_PROFILE_BIT_ARB` instead of compatibility profile
-			// once deprecated API usages are fixed.
 			static int context_attribs[] = {
 				GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
 				GLX_CONTEXT_MINOR_VERSION_ARB, 3,
-				GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
+				GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
 				GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB /*|GLX_CONTEXT_DEBUG_BIT_ARB*/,
 				None
 			};

However, I'm getting a black screen with a white quadrant on the project manager with --rendering-driver opengl --single-window:

image

Godot Engine v4.0.dev.custom_build.77dfa4f7f - https://godotengine.org
creating display driver : x11
creating rendering driver : opengl
rendering_driver opengl
ERROR: BUG: Unreferenced static string to 0: interface_added
   at: unref (core/string/string_name.cpp:116)
ERROR: BUG: Unreferenced static string to 0: interface_added
   at: unref (core/string/string_name.cpp:116)
rendering_driver opengl
window_create window id 0
WARNING: Property not found: rendering/quality/2d/use_nvidia_rect_flicker_workaround
     at: _get (core/config/project_settings.cpp:245)
WARNING: Property not found: rendering/quality/shading/force_lambert_over_burley
     at: _get (core/config/project_settings.cpp:245)
WARNING: Property not found: rendering/quality/shading/force_blinn_over_ggx
     at: _get (core/config/project_settings.cpp:245)
OpenGL Renderer: NVIDIA GeForce GTX 1080/PCIe/SSE2
ERROR: Condition "!props.has(p_prop)" is true.
   at: set_custom_property_info (core/config/project_settings.cpp:971)
ERROR: Condition "!props.has(p_prop)" is true.
   at: set_custom_property_info (core/config/project_settings.cpp:971)

... [shader code printed out] ...

ERROR: CanvasShaderOpenGL: Vertex shader compilation failed:
0(18) : error C7555: 'attribute' is deprecated, use 'in/out' instead
0(25) : error C7555: 'attribute' is deprecated, use 'in/out' instead
0(26) : error C7555: 'attribute' is deprecated, use 'in/out' instead
0(63) : error C7555: 'varying' is deprecated, use 'in/out' instead
0(64) : error C7555: 'varying' is deprecated, use 'in/out' instead

   at: _display_error_with_code (drivers/opengl/shader_opengl.cpp:129)
ERROR: Method/function failed. Returning: __null
   at: get_current_version (drivers/opengl/shader_opengl.cpp:300)
ERROR: Condition "!version" is true. Returning: false
   at: bind (drivers/opengl/shader_opengl.cpp:90)
ERROR: Condition "!version" is true. Returning: -1
   at: _get_uniform (./drivers/opengl/shader_opengl.h:263)

@clayjohn
Copy link
Author

Ah nice to see. I guess my drivers are a little too forgiving. Windows drivers often are.

I can update the PR with the fix this evening.

@clayjohn clayjohn force-pushed the OPENGL branch 2 times, most recently from 15de79e to 4d9436d Compare October 26, 2021 04:19
@clayjohn
Copy link
Author

@Calinou this should be ready to go now. I tested on my laptop which has a stricter driver.

Copy link
Owner

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on Linux (GeForce GTX 1080), it works.

Thanks!

@Calinou Calinou changed the title Use Opengl 3.3 core profile on windows Use OpenGL 3.3 Core Profile Oct 26, 2021
@Calinou Calinou merged this pull request into Calinou:add-opengl-renderer Oct 26, 2021
Calinou pushed a commit that referenced this pull request Oct 26, 2021
@clayjohn clayjohn deleted the OPENGL branch October 26, 2021 15:54
Calinou pushed a commit that referenced this pull request Jun 23, 2023
Fixes godotengine#76581.

TSAN flagged this issue on starting the editor:

1. main calls register_core_types, which calls IP::create(), which calls Thread::start on the resolver thread
2. Thread::callback calls ScriptServer::thread_enter(), as "Scripts may need to attach a stack."
3. ScriptServer::thread_enter() accesses ScriptServer::_languages, which is still being initialized on the main thread by initialize_gdscript_module

This fixes the issue by skipping thread enter/exit notifications if languages have not finished initializing yet.
I'm assuming that notifying un-initialized languages of thread starts/stops would have been pointless anyways. If we need to somehow notify languages of threads before the languages initialize, we'll need a different solution.

```
Godot Engine v4.0.2.stable.custom_build.7a0977ce2 - https://godotengine.org
==================
WARNING: ThreadSanitizer: data race (pid=9426)
  Write of size 4 at 0x55615b187cd0 by main thread:
    #0 ScriptServer::register_language(ScriptLanguage*) /home/rcorre/src/godot/godot/core/object/script_language.cpp:177:28 (godot.linuxbsd.editor.x86_64.llvm.san+0x9e52ab9) (BuildId: 780a9db7c37d88e78d5ee659c4fa1cd378abd048)
    #1 initialize_gdscript_module(ModuleInitializationLevel) /home/rcorre/src/godot/godot/modules/gdscript/register_types.cpp:118:3 (godot.linuxbsd.editor.x86_64.llvm.san+0x36f9c6f) (BuildId: 780a9db7c37d88e78d5ee659c4fa1cd378abd048)
    #2 initialize_modules(ModuleInitializationLevel) /home/rcorre/src/godot/godot/modules/register_module_types.gen.cpp:93:2 (godot.linuxbsd.editor.x86_64.llvm.san+0x2f50499) (BuildId: 780a9db7c37d88e78d5ee659c4fa1cd378abd048)
    #3 Main::setup2(unsigned long) /home/rcorre/src/godot/godot/main/main.cpp:1961:2 (godot.linuxbsd.editor.x86_64.llvm.san+0x2f1d40d) (BuildId: 780a9db7c37d88e78d5ee659c4fa1cd378abd048)
    #4 Main::setup(char const*, int, char**, bool) /home/rcorre/src/godot/godot/main/main.cpp:1879:10 (godot.linuxbsd.editor.x86_64.llvm.san+0x2f16370) (BuildId: 780a9db7c37d88e78d5ee659c4fa1cd378abd048)
    #5 main /home/rcorre/src/godot/godot/platform/linuxbsd/godot_linuxbsd.cpp:61:14 (godot.linuxbsd.editor.x86_64.llvm.san+0x2e67e1f) (BuildId: 780a9db7c37d88e78d5ee659c4fa1cd378abd048)

  Previous read of size 4 at 0x55615b187cd0 by thread T1:
    #0 ScriptServer::thread_enter() /home/rcorre/src/godot/godot/core/object/script_language.cpp:244:22 (godot.linuxbsd.editor.x86_64.llvm.san+0x9e54aed) (BuildId: 780a9db7c37d88e78d5ee659c4fa1cd378abd048)
    #1 Thread::callback(unsigned long, Thread::Settings const&, void (*)(void*), void*) /home/rcorre/src/godot/godot/core/os/thread.cpp:61:2 (godot.linuxbsd.editor.x86_64.llvm.san+0x9464ab0) (BuildId: 780a9db7c37d88e78d5ee659c4fa1cd378abd048)
    #2 void std::__invoke_impl<void, void (*)(unsigned long, Thread::Settings const&, void (*)(void*), void*), unsigned long, Thread::Settings, void (*)(void*), void*>(std::__invoke_other, void (*&&)(unsigned long, Thread::Settings const&, void (*)(void*), void*), unsigned long&&, Thread::Settings&&, void (*&&)(void*), void*&&) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.1/../../../../include/c++/12.2.1/bits/invoke.h:61:14 (godot.linuxbsd.editor.x86_64.llvm.san+0x9465283) (BuildId: 780a9db7c37d88e78d5ee659c4fa1cd378abd048)
    #3 std::__invoke_result<void (*)(unsigned long, Thread::Settings const&, void (*)(void*), void*), unsigned long, Thread::Settings, void (*)(void*), void*>::type std::__invoke<void (*)(unsigned long, Thread::Settings const&, void (*)(void*), void*), unsigned long, Thread::Settings, void (*)(void*), void*>(void (*&&)(unsigned long, Thread::Settings const&, void (*)(void*), void*), unsigned long&&, Thread::Settings&&, void (*&&)(void*), void*&&) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.1/../../../../include/c++/12.2.1/bits/invoke.h:96:14 (godot.linuxbsd.editor.x86_64.llvm.san+0x9465283)
    #4 void std::thread::_Invoker<std::tuple<void (*)(unsigned long, Thread::Settings const&, void (*)(void*), void*), unsigned long, Thread::Settings, void (*)(void*), void*>>::_M_invoke<0ul, 1ul, 2ul, 3ul, 4ul>(std::_Index_tuple<0ul, 1ul, 2ul, 3ul, 4ul>) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.1/../../../../include/c++/12.2.1/bits/std_thread.h:258:13 (godot.linuxbsd.editor.x86_64.llvm.san+0x9465283)
    #5 std::thread::_Invoker<std::tuple<void (*)(unsigned long, Thread::Settings const&, void (*)(void*), void*), unsigned long, Thread::Settings, void (*)(void*), void*>>::operator()() /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.1/../../../../include/c++/12.2.1/bits/std_thread.h:265:11 (godot.linuxbsd.editor.x86_64.llvm.san+0x9465283)
    #6 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(unsigned long, Thread::Settings const&, void (*)(void*), void*), unsigned long, Thread::Settings, void (*)(void*), void*>>>::_M_run() /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.1/../../../../include/c++/12.2.1/bits/std_thread.h:210:13 (godot.linuxbsd.editor.x86_64.llvm.san+0x9465283)
    #7 execute_native_thread_routine /usr/src/debug/gcc/gcc/libstdc++-v3/src/c++11/thread.cc:82:18 (libstdc++.so.6+0xd72c2) (BuildId: 6fe66a2d539a78c993bd2d377e00fad389220963)

  Location is global 'ScriptServer::_language_count' of size 4 at 0x55615b187cd0 (godot.linuxbsd.editor.x86_64.llvm.san+0xbf46cd0)

  Thread T1 (tid=9431, running) created by main thread at:
    #0 pthread_create <null> (godot.linuxbsd.editor.x86_64.llvm.san+0x2de5776) (BuildId: 780a9db7c37d88e78d5ee659c4fa1cd378abd048)
    #1 __gthread_create /usr/src/debug/gcc/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu/bits/gthr-default.h:663:35 (libstdc++.so.6+0xd73a9) (BuildId: 6fe66a2d539a78c993bd2d377e00fad389220963)
    #2 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State>>, void (*)()) /usr/src/debug/gcc/gcc/libstdc++-v3/src/c++11/thread.cc:147:37 (libstdc++.so.6+0xd73a9)
    #3 IP::IP() /home/rcorre/src/godot/godot/core/io/ip.cpp:347:19 (godot.linuxbsd.editor.x86_64.llvm.san+0x962cbcd) (BuildId: 780a9db7c37d88e78d5ee659c4fa1cd378abd048)
    #4 IPUnix::IPUnix() /home/rcorre/src/godot/godot/drivers/unix/ip_unix.cpp:261:9 (godot.linuxbsd.editor.x86_64.llvm.san+0x4aee599) (BuildId: 780a9db7c37d88e78d5ee659c4fa1cd378abd048)
    #5 IPUnix::_create_unix() /home/rcorre/src/godot/godot/drivers/unix/ip_unix.cpp:258:9 (godot.linuxbsd.editor.x86_64.llvm.san+0x4aee599)
    #6 IP::create() /home/rcorre/src/godot/godot/core/io/ip.cpp:339:9 (godot.linuxbsd.editor.x86_64.llvm.san+0x962ca5e) (BuildId: 780a9db7c37d88e78d5ee659c4fa1cd378abd048)
    #7 register_core_types() /home/rcorre/src/godot/godot/core/register_core_types.cpp:279:7 (godot.linuxbsd.editor.x86_64.llvm.san+0x93e2333) (BuildId: 780a9db7c37d88e78d5ee659c4fa1cd378abd048)
    #8 Main::setup(char const*, int, char**, bool) /home/rcorre/src/godot/godot/main/main.cpp:690:2 (godot.linuxbsd.editor.x86_64.llvm.san+0x2f08a49) (BuildId: 780a9db7c37d88e78d5ee659c4fa1cd378abd048)
    #9 main /home/rcorre/src/godot/godot/platform/linuxbsd/godot_linuxbsd.cpp:61:14 (godot.linuxbsd.editor.x86_64.llvm.san+0x2e67e1f) (BuildId: 780a9db7c37d88e78d5ee659c4fa1cd378abd048)

SUMMARY: ThreadSanitizer: data race /home/rcorre/src/godot/godot/core/object/script_language.cpp:177:28 in ScriptServer::register_language(ScriptLanguage*)
```

Co-authored-by: Pedro J. Estébanez <RandomShaper@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants