HomeWildfire Games

Use GLAD2 a multi-Language Vulkan/GL/GLES/EGL/GLX/WGL Loader-Generator.

Description

Use GLAD2 a multi-Language Vulkan/GL/GLES/EGL/GLX/WGL Loader-Generator.

Comments by: @nwtour, @Langbart, @bb
Based on patch by: @echotangoecho
Tested on Windows 7 & 10, Ubuntu and macos.

Differential Revision: https://code.wildfiregames.com/D721

Event Timeline

test_ParamNode.cpp
In file included from ../../../source/simulation2/tests/test_ParamNode.cpp:8:
../../../source/lib/external_libraries/libsdl.h:59:39: warning: "CONFIG2_GLES" is not defined, evaluates to 0 [-Wundef]
   59 | #if defined(SDL_VIDEO_DRIVER_X11) && !CONFIG2_GLES
      |                                       ^~~~~~~~~~~~
test_SerializeTemplates.cpp
In file included from ../../../source/simulation2/tests/test_SerializeTemplates.cpp:9:
../../../source/lib/external_libraries/libsdl.h:59:39: warning: "CONFIG2_GLES" is not defined, evaluates to 0 [-Wundef]
   59 | #if defined(SDL_VIDEO_DRIVER_X11) && !CONFIG2_GLES
      |                                       ^~~~~~~~~~~~
test_Serializer.cpp
In file included from ../../../source/simulation2/tests/test_Serializer.cpp:10:
../../../source/lib/external_libraries/libsdl.h:59:39: warning: "CONFIG2_GLES" is not defined, evaluates to 0 [-Wundef]
   59 | #if defined(SDL_VIDEO_DRIVER_X11) && !CONFIG2_GLES
      |                                       ^~~~~~~~~~~~
test_Simulation2.cpp
In file included from ../../../source/simulation2/tests/test_Simulation2.cpp:9:
../../../source/lib/external_libraries/libsdl.h:59:39: warning: "CONFIG2_GLES" is not defined, evaluates to 0 [-Wundef]
   59 | #if defined(SDL_VIDEO_DRIVER_X11) && !CONFIG2_GLES
      |                                       ^~~~~~~~~~~~
test_root.cpp
In file included from ../../../source/test_root.cpp:8:
../../../source/lib/external_libraries/libsdl.h:59:39: warning: "CONFIG2_GLES" is not defined, evaluates to 0 [-Wundef]
   59 | #if defined(SDL_VIDEO_DRIVER_X11) && !CONFIG2_GLES
      |                                       ^~~~~~~~~~~~
test_setup.cpp
test_pkcs5_pbkdf5.cpp
In file included from ../../../source/third_party/encryption/tests/test_pkcs5_pbkdf5.cpp:8:
../../../source/lib/external_libraries/libsdl.h:59:39: warning: "CONFIG2_GLES" is not defined, evaluates to 0 [-Wundef]
   59 | #if defined(SDL_VIDEO_DRIVER_X11) && !CONFIG2_GLES
      |                                       ^~~~~~~~~~~~
test_Preprocessor.cpp
In file included from ../../../source/third_party/ogre3d_preprocessor/tests/test_Preprocessor.cpp:9:
../../../source/lib/external_libraries/libsdl.h:59:39: warning: "CONFIG2_GLES" is not defined, evaluates to 0 [-Wundef]
   59 | #if defined(SDL_VIDEO_DRIVER_X11) && !CONFIG2_GLES
      |                                       ^~~~~~~~~~~~
test_AtlasObjectXML.cpp
In file included from ../../../source/tools/atlas/AtlasObject/tests/test_AtlasObjectXML.cpp:9:
../../../source/lib/external_libraries/libsdl.h:59:39: warning: "CONFIG2_GLES" is not defined, evaluates to 0 [-Wundef]
   59 | #if defined(SDL_VIDEO_DRIVER_X11) && !CONFIG2_GLES
      |                                       ^~~~~~~~~~~~

And some more. (Compiled without PCH.)

Executes the code for glsl with the option disabled (this did not happen before the commit)

~/.config/0ad/config/user.cfg

forceglmajorversion = "1"
forceglminorversion = "4"
forceglprofile = "compatibility"
forceglversion = "true"
preferglsl = "false"
Thread 1 "main" received signal SIGSEGV, Segmentation fault.

#1  0x083b5d79 in CShaderProgramGLSL::Compile (shader=1, file=..., code=..., this=0x96b76e0) at ../../../source/graphics/ShaderProgram.cpp:309
#2  0x083b78cc in CShaderProgramGLSL::Reload (this=0x96b76e0) at ../../../source/graphics/ShaderProgram.cpp:490
#3  0x083aaff5 in CShaderManager::NewProgram (this=0x8e97018, name=<optimized out>, baseDefines=..., program=std::shared_ptr<CShaderProgram> (use count 1, weak count 0) = {...})
    at ../../../source/graphics/ShaderManager.cpp:268
#4  0x083aca40 in CShaderManager::LoadProgram (this=0x8e97018, name=0xbfffecb4 "glsl/canvas2d", defines=...) at ../../../source/graphics/ShaderManager.cpp:74
#5  0x083ae267 in CShaderManager::NewEffect (this=0x8e97018, name=<optimized out>, baseDefines=..., tech=std::shared_ptr<CShaderTechnique> (use count 1, weak count 0) = {...})
    at /usr/include/c++/8/bits/basic_string.h:2290
#6  0x083aeb89 in CShaderManager::LoadEffect (this=0x8e97018, name=..., defines=...) at ../../../source/graphics/ShaderManager.cpp:363
#7  0x0836ef27 in CCanvas2D::Impl::BindTechIfNeeded (this=<optimized out>) at ../../../source/ps/Singleton.h:49
#8  CCanvas2D::DrawTexture (this=0xbffff0ec, texture=std::shared_ptr<CTexture> (use count 3, weak count 8) = {...}, destination=..., source=..., multiply=..., add=..., grayscaleFactor=0)
    at ../../../source/graphics/Canvas2D.cpp:185
#9  0x08559f70 in GUIRenderer::Draw (Calls=..., canvas=...) at /usr/include/c++/8/ext/atomicity.h:96
#10 0x08554a8a in CGUISpriteInstance::Draw (this=0x9025650, pGUI=..., canvas=..., Size=..., Sprites=std::map with 102 elements = {...}) at ../../../source/gui/CGUISprite.cpp:36
forceglmajorversion = "1"
forceglminorversion = "4"
forceglprofile = "compatibility"
forceglversion = "true"
preferglsl = "false"

The preferGLSL option is outdated, now it's called rendererbackend.

The preferGLSL option is outdated, now it's called rendererbackend.

And how to turn off the compilation of shaders now?

rendererbackend = "gl"

And how to turn off the compilation of shaders now?

Technically preferGLSL doesn't enable shaders, it switches them from ARB to GLSL shaders.

You might want to use rendererbackend = "glarb", see default.cfg.

Silier added a subscriber: Silier.Dec 22 2021, 2:48 PM

but it shouldnt segfault if wrong option is passed

but it shouldnt segfault if wrong option is passed

I agree.

You might want to use rendererbackend = "glarb", see default.cfg.

Thanks
With rendererbackend = "glarb" and opengl 1.4 - game work

With rendererbackend = "gl" or "glarb" and MESA_GL_VERSION_OVERRIDE=2.1

Thread 1 "main" received signal SIGSEGV, Segmentation fault.
#1  0x0842aef8 in Renderer::Backend::GL::CDevice::Report (this=0x8b5d930, rq=..., settings=...) at ../../../source/renderer/backend/gl/Device.cpp:341
#2  0x082c610f in RunHardwareDetection () at ../../../libraries/source/spidermonkey/include-unix-release/js/RootingAPI.h:1260
Thread 1 "main" received signal SIGSEGV, Segmentation fault.
#1  0x0842aef8 in Renderer::Backend::GL::CDevice::Report (this=0x8b5d930, rq=..., settings=...) at ../../../source/renderer/backend/gl/Device.cpp:341
#2  0x082c610f in RunHardwareDetection () at ../../../libraries/source/spidermonkey/include-unix-release/js/RootingAPI.h:1260

And this crash was introduced in that commit?

Stan added inline comments.Dec 22 2021, 3:23 PM
/ps/trunk/source/renderer/backend/gl/Device.cpp
341

So it crashes here after testing for an extension...

With rendererbackend = "glarb" and opengl 1.4 - game work
With rendererbackend = "gl" or "glarb" and MESA_GL_VERSION_OVERRIDE=2.1

Also could you try same options with forceglversion = "false"?

And this crash was introduced in that commit?

Yes.
"HEAD is now at 2e4abb5514 Moves backbuffer swap and error check to GL device." = successfull started with MESA_GL_VERSION_OVERRIDE=2.1 (rendererbackend = "glarb" and rendererbackend = "gl")

Stan added a comment.EditedDec 22 2021, 3:52 PM

Then I suppose the MESA_GL_VERSION_OVERRIDEoption conflicts with the force GL option

Also could you try same options with forceglversion = "false"?

Segfault (last two lines):

$ rm -f ~/.config/0ad/config/user.cfg 
$ ./binaries/system/pyrogenesis > /dev/null && echo "Success"
Segmentation fault

$ echo -ne 'forceglmajorversion = "1"\nforceglminorversion = "4"\nforceglversion = "true"\nforceglprofile = "compatibility"\n' > ~/.config/0ad/config/user.cfg
$ ./binaries/system/pyrogenesis > /dev/null && echo "Success"
Segmentation fault

$ echo -ne 'rendererbackend = "glarb"\nforceglmajorversion = "1"\nforceglminorversion = "4"\nforceglversion = "true"\nforceglprofile = "compatibility"\n' > ~/.config/0ad/config/user.cfg
$ ./binaries/system/pyrogenesis > /dev/null && echo "Success"
Success

$ echo -ne 'rendererbackend = "gl"\nforceglmajorversion = "1"\nforceglminorversion = "4"\nforceglversion = "true"\nforceglprofile = "compatibility"\n' > ~/.config/0ad/config/user.cfg
$ ./binaries/system/pyrogenesis > /dev/null && echo "Success"
Segmentation fault

$ echo -ne 'rendererbackend = "gl"\nforceglmajorversion = "2"\nforceglminorversion = "1"\nforceglversion = "true"\nforceglprofile = "compatibility"\n' > ~/.config/0ad/config/user.cfg
$ ./binaries/system/pyrogenesis > /dev/null && echo "Success"
Segmentation fault

$ echo -ne 'rendererbackend = "glarb"\nforceglmajorversion = "2"\nforceglminorversion = "1"\nforceglversion = "true"\nforceglprofile = "compatibility"\n' > ~/.config/0ad/config/user.cfg
$ ./binaries/system/pyrogenesis > /dev/null && echo "Success"
Segmentation fault
$ MESA_GL_VERSION_OVERRIDE=2.1 ./binaries/system/pyrogenesis > /dev/null && echo "Success"
Segmentation fault

$ echo -ne 'rendererbackend = "gl"\nforceglmajorversion = "2"\nforceglminorversion = "1"\nforceglversion = "true"\nforceglprofile = "compatibility"\n' > ~/.config/0ad/config/user.cfg
$ MESA_GL_VERSION_OVERRIDE=2.1 ./binaries/system/pyrogenesis > /dev/null && echo "Success"
Segmentation fault

$ echo -ne 'forceglmajorversion = "1"\nforceglminorversion = "4"\nforceglversion = "true"\nforceglprofile = "compatibility"\n' > ~/.config/0ad/config/user.cfg
$ MESA_GL_VERSION_OVERRIDE=2.1 ./binaries/system/pyrogenesis > /dev/null && echo "Success"
Segmentation fault

$ echo -ne 'forceglmajorversion = "2"\nforceglminorversion = "1"\nforceglversion = "true"\nforceglprofile = "compatibility"\n' > ~/.config/0ad/config/user.cfg
$ MESA_GL_VERSION_OVERRIDE=2.1 ./binaries/system/pyrogenesis > /dev/null && echo "Success"
Segmentation fault

$ echo -ne 'rendererbackend = "gl"\n' > ~/.config/0ad/config/user.cfg
$ MESA_GL_VERSION_OVERRIDE=2.1 ./binaries/system/pyrogenesis > /dev/null && echo "Success"
Segmentation fault

$ echo -ne 'rendererbackend = "glarb"\n' > ~/.config/0ad/config/user.cfg
$ MESA_GL_VERSION_OVERRIDE=2.1 ./binaries/system/pyrogenesis > /dev/null && echo "Success"
Segmentation fault
nwtour added inline comments.Dec 22 2021, 5:32 PM
/ps/trunk/source/renderer/backend/gl/Device.cpp
255
printf("IN QUERY\n"); \
glGetQueryivARB(GL_##target, GL_##pname, &i); \
printf("IN QUERY 2\n"); \

MESA_GL_VERSION_OVERRIDE=2.1 ./binaries/system/pyrogenesis
IN QUERY
Segmentation fault

Stan added a comment.EditedDec 22 2021, 5:46 PM

Can you upload your hwdetect_userreporter.txt files? Check if they are different depending on the mesa and forcegl flags.. It seems to crash on GL_ARB_occlusion_query which means maybe your GPU is pretending to support something it does not.

In rP26093#54857, @Stan wrote:

Can you upload your hwdetect_userreporter.txt files? Check if they are different depending on the mesa and forcegl flags.. It seems to crash on GL_ARB_occlusion_query which means maybe your GPU is pretending to support something it does not.

Launched with software rendering - the game started. So these are just local problems with the driver - then don't pay attention
$ MESA_GL_VERSION_OVERRIDE=2.1 LIBGL_ALWAYS_SOFTWARE=true ./binaries/system/pyrogenesis
IN QUERY
IN QUERY 2

FYI Mesa update from 20.3 to 21.0.3 solves the issue with glGetQueryivARB