EGL_BAD_DISPLAY error on Mali G52 driver blob (GKD Mini Plus)
Hello, been trying to use gl4es on the GKD Mini Plus but unfortunately i would get strange issues with gl4es specfically. Mind you, GLES games with SDL2 are actually working fine ! I also had a similar issue with Dolphin emulator and we tracked it down to eglGetDisplay somehow failling. I attempted something like this on Dolphin but it failed :
EGLDisplay GLContextEGL::OpenEGLDisplay()
{
const char* client_extensions = eglQueryString(NULL, EGL_EXTENSIONS);
PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display = nullptr;
EGLDisplay eglDisplay = EGL_NO_DISPLAY;
if (strstr(client_extensions, "EGL_KHR_platform_base")) {
get_platform_display = reinterpret_cast<PFNEGLGETPLATFORMDISPLAYEXTPROC>(
eglGetProcAddress("eglGetPlatformDisplay"));
} else if (strstr(client_extensions, "EGL_EXT_platform_base")) {
get_platform_display = reinterpret_cast<PFNEGLGETPLATFORMDISPLAYEXTPROC>(
eglGetProcAddress("eglGetPlatformDisplayEXT"));
}
if (get_platform_display) {
eglDisplay = get_platform_display(EGL_PLATFORM_GBM_MESA, EGL_DEFAULT_DISPLAY, nullptr);
} else {
eglDisplay = eglGetDisplay(static_cast<EGLNativeDisplayType>(m_wsi.render_surface));
}
return eglDisplay;
}
Here's how i run the game with it, i also tried with a simplier SDL2 GL test executable and it fails on creating the window (like CroMagRally does)
cd /storage/games/cromagrally
export SDL_VIDEODRIVER=kmsdrm
export SDL_VIDEO_EGL_DRIVER="/usr/lib/libmali.so"
export SDL_VIDEO_GL_DRIVER="/usr/lib/libmali.so"
export LIBGL_ES=2
export LIBGL_FB=1
export LIBGL_NOTEST=1
export LD_LIBRARY_PATH="$PWD/lib"
#export LD_PRELOAD="$PWD/lib/libGL.so.1"
SDL_GAMECONTROLLERCONFIG="19009b4d4b4800000111000000010000,retrogame_joypad,b:b0,a:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,lefttrigger:b6,righttrigger:b7,back:b8,start:b9,misc1:b10,leftstick:b11,rightstick:b12,dpup:b13,dpdown:b14,dpleft:b15,dpright:b16,guide:b17,leftx:a0,lefty:a1,rightx:a2,righty:a3,platform:Linux," ./CroMagRally &>log.txt
Here's the log from it :
LIBGL: v1.1.5 built on Aug 17 2023 16:51:23
LIBGL: framebuffer output enabled
LIBGL: Using GLES 2.0 backend
LIBGL: loaded: libGLESv2.so
LIBGL: loaded: libEGL.so
LIBGL: loaded: libgbm.so
LIBGL: loaded: libdrm.so
LIBGL: Hardware test disabled, nothing activated...
LIBGL: Targeting OpenGL 2.1
LIBGL: Not forcing NPOT support
LIBGL: Not trying to batch small subsequent glDrawXXXX
LIBGL: try to use VBO
LIBGL: glXMakeCurrent FBO workaround enabled
LIBGL: Force texture for Attachment color0 on FBO
LIBGL: Hack to trigger a SwapBuffers when a Full Framebuffer Blit on default FBO is done
LIBGL: Current folder is:/storage/games/boomshine
LIBGL: Not using PSA (prgbin_n=0, notexarray=0)
arm_release_ver of this libmali is 'g2p0-01eac0', rk_so_ver is '3'.Uncaught exception: Couldn't create SDL window.
LIBGL: Shuting down
I have no idea what kind of wizardry SDL2 is doing to work on this. If i didn't disable the tests, it would fail at LIBGL: Error while gathering supported extension (eglInitialize: EGL_BAD_DISPLAY), default to none
Have you tried LIBGL_FB=1? Maybe it doesn't have x11 support and only support Framebuffer here?
Yes, that's the first thing i tried (export LIBGL_FB=1 as seen above in my post). It doesn't have X11 indeed, it's framebuffer only. SDL2 does work but i tried looking at how they do it but it's a verbose mess...
I got further with
export LIBGL_ES=2
export LIBGL_GL=21
export LIBGL_FB=4
and it no longer crashes at EGL_BAD_DISPLAY it seems altho it still fails to create the SDL2 window for it :/
LIBGL: Initialising gl4es
LIBGL: v1.1.5 built on Aug 17 2023 16:51:23
LIBGL: using GBM
LIBGL: Using GLES 2.0 backend
LIBGL: loaded: libGLESv2.so
LIBGL: loaded: libEGL.so
LIBGL: loaded: libgbm.so
LIBGL: loaded: libdrm.so
LIBGL: Using GLES 2.0 backend
LIBGL: GBM on card /dev/dri/card0 is Available
arm_release_ver of this libmali is 'g2p0-01eac0', rk_so_ver is '3'.LIBGL: Hardware Full NPOT detected and used
LIBGL: Extension GL_EXT_blend_minmax detected and used
LIBGL: FBO are in core, and so used
LIBGL: PointSprite are in core, and so used
LIBGL: CubeMap are in core, and so used
LIBGL: BlendColor is in core, and so used
LIBGL: Blend Subtract is in core, and so used
LIBGL: Blend Function and Equation Separation is in core, and so used
LIBGL: Texture Mirrored Repeat is in core, and so used
LIBGL: Extension GL_OES_mapbuffer detected
LIBGL: Extension GL_OES_element_index_uint detected and used
LIBGL: Extension GL_OES_packed_depth_stencil detected and used
LIBGL: Extension GL_OES_depth24 detected and used
LIBGL: Extension GL_OES_rgb8_rgba8 detected and used
LIBGL: Extension GL_EXT_texture_format_BGRA8888 detected and used
LIBGL: Extension GL_OES_depth_texture detected and used
LIBGL: Extension GL_OES_texture_stencil8 detected and used
LIBGL: Extension GL_EXT_texture_rg detected and used
LIBGL: Extension GL_EXT_color_buffer_float detected and used
LIBGL: Extension GL_EXT_color_buffer_half_float detected and used
LIBGL: high precision float in fragment shader available and used
LIBGL: Max vertex attrib: 16
LIBGL: Extension GL_OES_standard_derivatives detected and used
LIBGL: Extension GL_ARM_shader_framebuffer_fetch detected and used
LIBGL: Extension GL_OES_get_program_binary detected and used
LIBGL: Number of supported Program Binary Format: 1
LIBGL: Max texture size: 16383
LIBGL: Max Varying Vector: 31
LIBGL: Texture Units: 16/16 (hardware: 16), Max lights: 8, Max planes: 6
LIBGL: Extension GL_EXT_texture_filter_anisotropic detected and used
LIBGL: Max Anisotropic filtering: 16
LIBGL: Max Color Attachments: 1 / Draw buffers: 1
LIBGL: Hardware vendor is ARM
LIBGL: sRGB surface supported
LIBGL: EGLImage to Texture2D supported
LIBGL: EGLImage to RenderBuffer supported
LIBGL: Targeting OpenGL 2.1
LIBGL: Not trying to batch small subsequent glDrawXXXX
LIBGL: try to use VBO
LIBGL: glXMakeCurrent FBO workaround enabled
LIBGL: FBO workaround for using binded texture enabled
LIBGL: Force texture for Attachment color0 on FBO
LIBGL: Hack to trigger a SwapBuffers when a Full Framebuffer Blit on default FBO is done
LIBGL: glX Will try to recycle EGL Surface
LIBGL: Current folder is:/storage/games/boomshine
arm_release_ver of this libmali is 'g2p0-01eac0', rk_so_ver is '3'.
Uncaught exception: Couldn't create SDL window.
LIBGL: Shuting down
Ah, issue is gbm is still experimental on gl4es (so, it's still buggy). That's probably a bug in gl4es that needs fixing :(
That's a shame : ( I talked to the portmaster guys about it and they did confirm GBM does not work properly on the mali blob, only panforst. As for dolphin, they "fixed" it by adding an EGL SDL2 backend to it. So they never really looked hard into it.
Whatever SDL2 does, the fix is in there...
Thanks @JohnnyonFlame , he told me a trick that does work. Basically build GL4ES without any backend :
cmake -DCMAKE_TOOLCHAIN_FILE="/opt/gkdminiplus-toolchain/usr/share/buildroot/toolchainfile.cmake" -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS_RELEASE="-DEGL_NO_X11=1" -DNOX11=ON -DGLX_STUBS=ON -DGBM=OFF -DNOEGL=ON ..
And then in the game's source code, force GLES so for SDL2, it's like this
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK,
SDL_GL_CONTEXT_PROFILE_ES);
The game that i was playing (CroMagRally) will then work.
Unfortunately this (for now) rules out proprietary ports unless i hack up SDL2 within itself to force GLES... I will still leave this up.
You don't have the source of this SDL2 to see how they are creating the context?
Well i'm just using SDL2 mainline source code, if i knew what the issue was i would tell you... I was not aware of it until now but seems like johnny did merge a fix for that within box86 https://github.com/ptitSeb/box86/pull/455
(See the my2_SDL_CreateWindow changes)
Ah yeah, this thing. It's quite old now, I forgot about it.