ptitSeb / gl4es

GL4ES is a OpenGL 2.1/1.5 to GL ES 2.0/1.1 translation library, with support for Pandora, ODroid, OrangePI, CHIP, Raspberry PI, Android, Emscripten and AmigaOS4.
http://ptitseb.github.io/gl4es/
MIT License
669 stars 151 forks source link

LIBGL_FB=3 question - or - using mali fb drivers inside of x11 #119

Closed hexdump0815 closed 4 years ago

hexdump0815 commented 4 years ago

hello,

first a big thank you for this amazing piece of software - it helps in so many areas when trying to use opengl apps on arm devices with mali gpus.

i have a question regarding the LIBGL_FB=3 option: do i understand it right, that i could use this to use for instance a mali fbdev blob to run accelerated opengl apps in x11 with it? as i understand it will will use the mali fbdev blob then to render the images into a buffer which is then copied to a window in the x11 server. of course this is slow due to the extra memory copying, but it is still way faster than software rendering and uses way less cpu. the background of my questions is that i would like to find a way to run gpu accelerated user interfaces on x11 on platforms, for which there is no mali x11 blob at all (allwinner h6 and amlogic s905x2 come to mind). the rendering speed is in my case (www.vcvrack.com) not that important, but much more important is that the ui is still somewhat useable and the cpu is not used mostly for ui rendering.

i did some basic test of the LIBGL_FB=3 scenario using the non-x11 mali blob and the modesetting xorg server on a amlogic s905w tv box and it really seems to work quite well for vcvrack, although glmark2 for instance seem to crash. performance seems to be about the same as using the mali x11 blob with the hacked armsoc xorg server, which i think does nothing else than copying the rendered images around and thus is not any faster in the end.

a lot of thanks in advance and best wishes - hexdump

ptitSeb commented 4 years ago

Well, here is how LIBGL_FB=3 mode works: for each context created, an offscreen buffer is created. It first try to create a PixmapBuffer, and in your case, I guess this will fail because there no x11 driver, and it will fallback to a Pbuffer, that should always succeed. When a glXSwapBuffers(...) occurs, the offscreen buffer is blitted in the x11 windows. It's using X11 internal stuff if the buffer was a PixmapBuffer, and it's using plain cpu memcpy if it was a PBuffer.

It should be quite stable. I use it on my side for some stuff. The crash with glmark2 is strange, if you can get a gdb backtrace, because glmark2 works on my side, and it should also work with LIBGL_FB=3. What I'm more suspicious is the "mutli-thread" safety. There are some global variable that are not thread unique...

Also, using the fbdev driver, you should be able to use LIBGL_FB=1 to have "fullscreen" rendering (in fullspeed in that case, with no copying). And also, on the Pandora, I'm able to use LIBGL_FB=2, to have a pseudo-windowed rendering, using intermediary FBO, without much copying too.

hexdump0815 commented 4 years ago

thanks a lot for the quick response. this all sounds very good - i'll try to have a look at the glmark2 problem as soon as i find some time.

how is the mouse cursor handled in the LIBGL_FB=1 fullscreen mode?

once more a lot of thanks in advance and best wishes - hexdump

ptitSeb commented 4 years ago

In LIBGL_FB=1, the applicatin is running fullscreen. So if the app/game is in fact not fullscreen, that may pause an issue indeed.

With LIBGL_FB=2 if the app/game is windowed, gl4es will try to show it at the right place. X11 cursor integration can still be an issue of course. For that, only LIBGL_FB=0 (so actual x11 driver) and LIBGL_FB=3 works properly.

hexdump0815 commented 4 years ago

i'm impressed - it really works :)

i just got opengl on x11 running on a allwinner h6 tv box (for which no x11 mali blob exists) using gl4es and the allwinner h6 fbdev mali blob - this is really really cool! ... vcvrack is working fine this way, glxinfo works, glxgears as well, but glmark2 is crashing with:

LIBGL: Initialising gl4es
LIBGL: v1.1.1 built on Feb  4 2019 22:03:46
LIBGL: using pbuffer
LIBGL: Using GLES 2.0 backend
LIBGL: loaded: libGLESv2.so
LIBGL: loaded: libEGL.so
LIBGL: Using GLES 2.0 backend
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 Substract 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_EXT_texture_rg 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: Max texture size: 8192
LIBGL: Max Varying Vector: 15
LIBGL: Texture Units: 8(8), Max lights: 8, Max planes: 6
LIBGL: Hardware vendor is ARM
LIBGL: sRGB surface supported
LIBGL: Targeting OpenGL 2.0
LIBGL: glXMakeCurrent FBO workaround enabled
LIBGL: FBO workaround for using binded texture enabled
LIBGL: Current folder is:/home/mrnobody/Desktop/vcvrack.aarch64-v1
LIBGL: ERROR: EGL Error detected: EGL_BAD_SURFACE
=======================================================
    glmark2 2014.03+git20150611.fa71af2d
=======================================================
    OpenGL Information
    GL_VENDOR:     ptitSeb
    GL_RENDERER:   GL4ES wrapper
    GL_VERSION:    2.0 gl4es wrapper 1.1.1
=======================================================
LIBGL: ERROR: EGL Error detected: EGL_BAD_SURFACE
Error: glXMakeCurrent failed
Error: CanvasGeneric: Invalid EGL state
Segmentation fault (core dumped)

do you have any idea what might be the problem there? maybe there are more gl4es env variables required? maybe different compile time options or a newer version of gl4es (this is an old compiled one)? any info, which might be useful for you to find out what the problem is?

a lot of thanks and best wishes - hexdump

hexdump0815 commented 4 years ago

just for completeness: here is the coredump output of glmark2 on an amlogic s905w tv box

LIBGL: Initialising gl4es
LIBGL: v1.1.1 built on Feb  4 2019 22:03:46
LIBGL: using pbuffer
LIBGL: Using GLES 2.0 backend
LIBGL: loaded: libGLESv2.so
LIBGL: loaded: libEGL.so
LIBGL: Using GLES 2.0 backend
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 Substract 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_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: Max vertex attrib: 16
LIBGL: Extension GL_OES_standard_derivatives detected and used
LIBGL: Max texture size: 4096
LIBGL: Max Varying Vector: 12
LIBGL: Texture Units: 8(8), Max lights: 8, Max planes: 6
LIBGL: Hardware vendor is ARM
LIBGL: Targeting OpenGL 2.0
LIBGL: glXMakeCurrent FBO workaround enabled
LIBGL: FBO workaround for using binded texture enabled
LIBGL: Current folder is:/home/mrnobody
=======================================================
    glmark2 2014.03+git20150611.fa71af2d
=======================================================
    OpenGL Information
    GL_VENDOR:     ptitSeb
    GL_RENDERER:   GL4ES wrapper
    GL_VERSION:    2.0 gl4es wrapper 1.1.1
=======================================================
LIBGL: ERROR: EGL Error detected: EGL_BAD_SURFACE
Error: glXMakeCurrent failed
Error: CanvasGeneric: Invalid EGL state
Segmentation fault (core dumped)

looks very similar to the allwinner h6 case to me.

btw. the LIBGL_FB=1 and =2 cases do not work in my case.

best wishes - hexdump

ptitSeb commented 4 years ago

Maybe try to uncomment line 40 of src\glx\glx.c to have more debug info. Something interresting maybe pop up.

ptitSeb commented 4 years ago

Ah nevermind, I reproduce the issue on my side ! I'll work on that.

hexdump0815 commented 4 years ago

cool - please let me know when i should test anything

ptitSeb commented 4 years ago

Ok, it's fixed :)

hexdump0815 commented 4 years ago

tested - works - horses and cats are rotating fine now :)

how about bumping the version number?

hexdump0815 commented 4 years ago

strange - since your fix the vcvrack app does not work anymore - it gives a core dump now ... will have to investigate deeper, but it looks like my monitor has died, so have to get this fixed first.

this is the display code of vcvrack: https://github.com/VCVRack/Rack/blob/v1/src/window.cpp

in case you want to try yourself - here are my armv7l and aarch64 builds of vcvrack: https://github.com/hexdump0815/vcvrack-dockerbuild-v1/releases - it just needs to be unpacked and then one has to run "./Rack -d"

ptitSeb commented 4 years ago

I'll see if I can reproduce the crash on my side.

hexdump0815 commented 4 years ago

got the monitor back to work - here is the backtrace if i run Rack in gdb:

Thread 1 "Rack" received signal SIGSEGV, Segmentation fault.
__memcpy_generic () at ../sysdeps/aarch64/multiarch/../memcpy.S:170
170 ../sysdeps/aarch64/multiarch/../memcpy.S: No such file or directory.
(gdb) bt
#0  __memcpy_generic () at ../sysdeps/aarch64/multiarch/../memcpy.S:170
#1  0x0000ffffbf5c6630 in preproc () from /opt/mali-s905-fbdev/libGL.so.1
#2  0x0000ffffbf5d95a4 in ConvertShader () from /opt/mali-s905-fbdev/libGL.so.1
#3  0x0000ffffbf5d8604 in glShaderSourceARB () from /opt/mali-s905-fbdev/libGL.so.1
#4  0x0000aaaaaac77ca4 in glnvg__createShader (shader=shader@entry=0xaaaaab625ae0, header=header@entry=0xaaaaaaf60cc0 "#define NANOVG_GL2 1\n#define UNIFORMARRAY_SIZE 11\n\n", opts=opts@entry=0xaaaaaaf60ca8 "#define EDGE_AA 1\n", 
    vshader=vshader@entry=0xaaaaaaf60b28 "#ifdef NANOVG_GL3\n\tuniform vec2 viewSize;\n\tin vec2 vertex;\n\tin vec2 tcoord;\n\tout vec2 ftcoord;\n\tout vec2 fpos;\n#else\n\tuniform vec2 viewSize;\n\tattribute vec2 vertex;\n\tattribute vec2 tcoord;\n\tvarying ve"..., 
    fshader=fshader@entry=0xaaaaaaf5fec8 "#ifdef GL_ES\n#if defined(GL_FRAGMENT_PRECISION_HIGH) || defined(NANOVG_GL3)\n precision highp float;\n#else\n precision mediump float;\n#endif\n#endif\n#ifdef NANOVG_GL3\n#ifdef USE_UNIFORMBUFFER\n\tlayout(std"..., 
    name=0xaaaaaaf9bc48 "shader") at dep/include/nanovg_gl.h:445
#5  0x0000aaaaaac79124 in glnvg__renderCreate (uptr=0xaaaaab625ae0) at dep/include/nanovg_gl.h:679
#6  0x0000aaaaaac3b044 in nvgCreateInternal (params=params@entry=0xfffffffff190) at dep/nanovg/src/nanovg.c:311
#7  0x0000aaaaaac7e974 in nvgCreateGL2 (flags=flags@entry=1) at dep/include/nanovg_gl.h:1586
#8  0x0000aaaaaac8a9a8 in rack::Window::Window (this=0xaaaaab604f50) at src/window.cpp:280
#9  0x0000aaaaaac91788 in rack::App::init (this=0xaaaaab604e40) at src/app.cpp:18
#10 rack::appInit () at src/app.cpp:47
#11 0x0000aaaaaac105ac in main (argc=<optimized out>, argv=<optimized out>) at src/main.cpp:162

it is absolutely reproducable: old gl4es = works, current one = does not work ... but might also be due to other changes inbetween, as my old gl4es build is a few months old already.

best wishes - hexdump

ptitSeb commented 4 years ago

So it crash in preproc...

Can you uncomment line 10 of src/gl/preproc.c and launch again. There should be more trace, hopefully enough for me to understand the issue.

hexdump0815 commented 4 years ago

here we are: https://pastebin.com/raw/KdJkddQp

good luck :)

ptitSeb commented 4 years ago

Ok thanks. That should be enough.

ptitSeb commented 4 years ago

O, I have push a fix. Hopefully it works now.

hexdump0815 commented 4 years ago

thanks a lot - that fixes it indeed - now glxinfo, glxgeras, glmark2 and vcvrack are running fine :)

hexdump0815 commented 4 years ago

@ptitSeb - i have another one for you :) - i tried the same on an amlogic s905x2 tv box with mali bitfrost g31 gpu - i got the LIBGL_FB=3 way working with a r9 mali blob for this soc/gpu - glxinfo, glxgears and vcvrack are all working, but glmark2 fails - here is the output with debugging enabled in glx.c:

LIBGL: Initialising gl4es
LIBGL: v1.1.1 built on Aug  8 2019 17:07:47
LIBGL: using pbuffer
LIBGL: Using GLES 2.0 backend
LIBGL: loaded: libGLESv2.so
LIBGL: loaded: libEGL.so
LIBGL: Using GLES 2.0 backend
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 Substract 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_OES_get_program detected and used
LIBGL: Number of supported Program Binary Format: 1
LIBGL: Max texture size: 8192
LIBGL: Max Varying Vector: 15
LIBGL: Texture Units: 8(8), Max lights: 8, Max planes: 6
LIBGL: Hardware vendor is ARM
LIBGL: sRGB surface supported
LIBGL: Targeting OpenGL 2.0
LIBGL: Not trying to batch small subsequent glDrawXXXX
LIBGL: glXMakeCurrent FBO workaround enabled
LIBGL: FBO workaround for using binded texture enabled
LIBGL: Current folder is:/home/mrnobody
glXQueryVersion(0x10845ca0, 0xffffd43d2ae0, 0xffffd43d2ae4)
glXChooseFBConfig(0x10845ca0, 0, 0x4e4968, 0xffffd43d2b5c)
FBConfig renderable=1
FBConfig drawableType=0x1
FBConfig visual type=32770
FBConfig redBits=1
FBConfig greenBits=1
FBConfig blueBits=1
FBConfig alphaBits=1
FBConfig depthBits=1
FBConfig stencilBits=0
FBConfig doubleBufferMode=1
glXChooseFBConfig found 9 config
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517200, 0x0002, 0xffffd43d2ae0) -> 0x0010
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517200, 0x0008, 0xffffd43d2ac8) => 0x0008
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517200, 0x0009, 0xffffd43d2acc) => 0x0008
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517200, 0x000A, 0xffffd43d2ad0) => 0x0008
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517200, 0x000B, 0xffffd43d2ad4) => 0x0008
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517200, 0x000C, 0xffffd43d2ad8) => 0x0018
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517200, 0x000D, 0xffffd43d2adc) => 0x0000
glXGetFBConfigAttrib(0x10845ca0, 0xffffb35172e8, 0x0002, 0xffffd43d2ae0) -> 0x0010
glXGetFBConfigAttrib(0x10845ca0, 0xffffb35172e8, 0x0008, 0xffffd43d2ac8) => 0x0008
glXGetFBConfigAttrib(0x10845ca0, 0xffffb35172e8, 0x0009, 0xffffd43d2acc) => 0x0008
glXGetFBConfigAttrib(0x10845ca0, 0xffffb35172e8, 0x000A, 0xffffd43d2ad0) => 0x0008
glXGetFBConfigAttrib(0x10845ca0, 0xffffb35172e8, 0x000B, 0xffffd43d2ad4) => 0x0008
glXGetFBConfigAttrib(0x10845ca0, 0xffffb35172e8, 0x000C, 0xffffd43d2ad8) => 0x0018
glXGetFBConfigAttrib(0x10845ca0, 0xffffb35172e8, 0x000D, 0xffffd43d2adc) => 0x0008
glXGetFBConfigAttrib(0x10845ca0, 0xffffb35173d0, 0x0002, 0xffffd43d2ae0) -> 0x0010
glXGetFBConfigAttrib(0x10845ca0, 0xffffb35173d0, 0x0008, 0xffffd43d2ac8) => 0x0008
glXGetFBConfigAttrib(0x10845ca0, 0xffffb35173d0, 0x0009, 0xffffd43d2acc) => 0x0008
glXGetFBConfigAttrib(0x10845ca0, 0xffffb35173d0, 0x000A, 0xffffd43d2ad0) => 0x0008
glXGetFBConfigAttrib(0x10845ca0, 0xffffb35173d0, 0x000B, 0xffffd43d2ad4) => 0x0008
glXGetFBConfigAttrib(0x10845ca0, 0xffffb35173d0, 0x000C, 0xffffd43d2ad8) => 0x0018
glXGetFBConfigAttrib(0x10845ca0, 0xffffb35173d0, 0x000D, 0xffffd43d2adc) => 0x0008
glXGetFBConfigAttrib(0x10845ca0, 0xffffb35174b8, 0x0002, 0xffffd43d2ae0) -> 0x0010
glXGetFBConfigAttrib(0x10845ca0, 0xffffb35174b8, 0x0008, 0xffffd43d2ac8) => 0x0008
glXGetFBConfigAttrib(0x10845ca0, 0xffffb35174b8, 0x0009, 0xffffd43d2acc) => 0x0008
glXGetFBConfigAttrib(0x10845ca0, 0xffffb35174b8, 0x000A, 0xffffd43d2ad0) => 0x0008
glXGetFBConfigAttrib(0x10845ca0, 0xffffb35174b8, 0x000B, 0xffffd43d2ad4) => 0x0008
glXGetFBConfigAttrib(0x10845ca0, 0xffffb35174b8, 0x000C, 0xffffd43d2ad8) => 0x0018
glXGetFBConfigAttrib(0x10845ca0, 0xffffb35174b8, 0x000D, 0xffffd43d2adc) => 0x0008
glXGetFBConfigAttrib(0x10845ca0, 0xffffb35175a0, 0x0002, 0xffffd43d2ae0) -> 0x0010
glXGetFBConfigAttrib(0x10845ca0, 0xffffb35175a0, 0x0008, 0xffffd43d2ac8) => 0x0008
glXGetFBConfigAttrib(0x10845ca0, 0xffffb35175a0, 0x0009, 0xffffd43d2acc) => 0x0008
glXGetFBConfigAttrib(0x10845ca0, 0xffffb35175a0, 0x000A, 0xffffd43d2ad0) => 0x0008
glXGetFBConfigAttrib(0x10845ca0, 0xffffb35175a0, 0x000B, 0xffffd43d2ad4) => 0x0008
glXGetFBConfigAttrib(0x10845ca0, 0xffffb35175a0, 0x000C, 0xffffd43d2ad8) => 0x0018
glXGetFBConfigAttrib(0x10845ca0, 0xffffb35175a0, 0x000D, 0xffffd43d2adc) => 0x0008
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517688, 0x0002, 0xffffd43d2ae0) -> 0x0010
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517688, 0x0008, 0xffffd43d2ac8) => 0x0005
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517688, 0x0009, 0xffffd43d2acc) => 0x0005
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517688, 0x000A, 0xffffd43d2ad0) => 0x0005
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517688, 0x000B, 0xffffd43d2ad4) => 0x0001
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517688, 0x000C, 0xffffd43d2ad8) => 0x0018
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517688, 0x000D, 0xffffd43d2adc) => 0x0008
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517770, 0x0002, 0xffffd43d2ae0) -> 0x0010
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517770, 0x0008, 0xffffd43d2ac8) => 0x0004
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517770, 0x0009, 0xffffd43d2acc) => 0x0004
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517770, 0x000A, 0xffffd43d2ad0) => 0x0004
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517770, 0x000B, 0xffffd43d2ad4) => 0x0004
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517770, 0x000C, 0xffffd43d2ad8) => 0x0018
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517770, 0x000D, 0xffffd43d2adc) => 0x0008
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517858, 0x0002, 0xffffd43d2ae0) -> 0x0010
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517858, 0x0008, 0xffffd43d2ac8) => 0x0005
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517858, 0x0009, 0xffffd43d2acc) => 0x0005
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517858, 0x000A, 0xffffd43d2ad0) => 0x0005
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517858, 0x000B, 0xffffd43d2ad4) => 0x0001
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517858, 0x000C, 0xffffd43d2ad8) => 0x0018
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517858, 0x000D, 0xffffd43d2adc) => 0x0008
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517940, 0x0002, 0xffffd43d2ae0) -> 0x0010
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517940, 0x0008, 0xffffd43d2ac8) => 0x0004
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517940, 0x0009, 0xffffd43d2acc) => 0x0004
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517940, 0x000A, 0xffffd43d2ad0) => 0x0004
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517940, 0x000B, 0xffffd43d2ad4) => 0x0004
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517940, 0x000C, 0xffffd43d2ad8) => 0x0018
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517940, 0x000D, 0xffffd43d2adc) => 0x0008
glXGetFBConfigAttrib(0x10845ca0, 0xffffb3517200, 0x800B, 0xffffd43d2bd4) => 0x10BBA0A
Error: Error: Could not get a valid XVisualInfo!
Error: Error: Couldn't create native window!
Error: main: Could not initialize canvas
LIBGL: Shuting down

do you have any idea what might be the problem here? any more debug flags i should enable?

another thing i have noticed is that the opengl ui of vcvrack is much slower on this soc/gpu than it was with LIBGL_FB=3 on an allwinner h6, which is similar speedwise, but actually even a bit lower and cheaper hardware. are there maybe any other env variables for gl4es, which might give a little speedup?

a lot of thanks in advance and best wishes - hexdump

hexdump0815 commented 4 years ago

@ptitSeb - any idea?

ptitSeb commented 4 years ago

Mmm, no I have to check in glmark2 source to understand how this can happens.

Also, slower speed, in LIBGL_FB=3 probably means the X11 blit is slower. I'm unsure how X11 is setup on both your config, but maybe one has some 2D acceleration blit that the other doesn't have (maybe just fbturbo can make a difference I guess). Does windows movement is equally smooth on both setup?

hexdump0815 commented 4 years ago

hi @ptitSeb, thanks a lot for your response. the xorg setup is on both systems the same (simple modesetting setup). window movement is similar, but maybe a tiny bit faster on the allwinner h6 system than on the amlogic s905x2 system (mostly visible when switching a window from normal to maximum size and back). below i attached the output of glxinfo, glxgears -info and the xorg log for reference for both systems. glxgears runs at about 95fps on the h6 and only at about 13fps on the s905x2 (all with fbdev mali blob and LIBGL_FB=3 for gl4es). can it be, that the framebuffer implementation makes the difference between them? - the mainline linux support for both systems is relatively new and it can be that they are not yet optimized properly maybe.

gl4es-h6-mali-t720.txt gl4es-s905x2-mali-g31.txt

ptitSeb commented 4 years ago

Wow, 12 fps for glxgears ?! That's wrong. There must be something wrong with the driver, because even on the Pandora I get better speed than that (and the Pandora is quite a slow device compared to any current SBC).

I don't see anything wrong or suspicious in the glx output. Can you test som es2gears also, to check the speed? Also, with the s905x2, can you try with LIBGL_FB=1 or LIBGL_FB=2 also?

And just to be sure, can you try with the GLEs1.1 backend, with LIBGL_ES=1?

hexdump0815 commented 4 years ago

with LIBGL_FB=1 and LIBGL_FB=2 i only got an empty glxgears window and around 8fps :)

LIBGL_ES=1 did not change anything - same values.

looks like it might be better to wait a bit more for the s905x2 support to mature.

ptitSeb commented 4 years ago

The LIBGL_FB=1 test is interresting. Even if the windows is empty, it seems it tries to draw things, but this time, there is no X11 blit (because this mode dirrectly draw on the framebuffer). So 8fps is still not good. So yeah, the driver needs to mature!

hexdump0815 commented 4 years ago

i'm not 100% sure, but to me it looks this: https://forum.odroid.com/viewtopic.php?t=35255#p259457 is maybe the explaination for the extremely low performance on the s905x2 (which is similar in design to the s922x of the odroid n2 the link is about) ...

ptitSeb commented 4 years ago

You, could be similar. Meaning, driver issue...

hexdump0815 commented 4 years ago

happy new year! i have a new one for you :) ... i just tried to get gl4es in LIBGL_FB=3 mode working on an odroid mc1 using the mali blobs - so far it looks quite good: glxinfo works well, glmark2 works well and also the opengl app vcvrack works ... only glxgears do not work - here is the output of the try to start it with DEBUG enabled in gl4es - any idea what might bbe the problem?

a lot of thanks in advance and best wishes - hexdump

mc1:~$ glxgears 
LIBGL: Initialising gl4es
LIBGL: v1.1.3 built on Jan  1 2020 20:16:31
LIBGL: using pbuffer
LIBGL: Using GLES 2.0 backend
LIBGL: loaded: libGLESv2.so
LIBGL: loaded: libEGL.so
LIBGL: Using GLES 2.0 backend
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 Substract 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: 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_OES_get_program detected and used
LIBGL: Number of supported Program Binary Format: 1
LIBGL: Max texture size: 8192
LIBGL: Max Varying Vector: 15
LIBGL: Texture Units: 8(8), Max lights: 8, Max planes: 6
LIBGL: Hardware vendor is ARM
LIBGL: sRGB surface supported
LIBGL: Targeting OpenGL 2.0
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: Current folder is:/home/mrnobody
glXChooseVisual(0x58bbd8, 0, 0xbecbceac[4,5,8,1,9,1,a,1,c,1,0])
glXChooseFBConfig(0x58bbd8, 0, 0xbecbcd1c, 0xbecbccf8)
FBConfig doubleBufferMode=1
FBConfig redBits=1
FBConfig greenBits=1
FBConfig blueBits=1
FBConfig depthBits=1
glXChooseFBConfig found 15 config
glXChooseVisual return 0x55e490
glXCreateContext(0x58bbd8, 0x55e490, (nil), 1) fbcontext_count=0 Creating R:8 G:8 B:8 A:0 visual deth=24 Depth:24 Stencil:8 Multisample:0/0
 => (nil)
LIBGL: No EGL configs found (depth=24, stencil=8).
Error: glXCreateContext failed
LIBGL: Shuting down
ptitSeb commented 4 years ago

I don't really understand why it would not create the context.

for the sake of testing, can you try to change in src/glx/glx.c line 598 from

default_glxfbconfig.alphaBits = (visual==0)?0:(visual->depth!=32)?0:8;

to

default_glxfbconfig.alphaBits = (visual==0)?0:(visual->depth!=32)?1:8;

Just to see. Also, you can try

default_glxfbconfig.alphaBits = (visual==0)?0:(visual->depth!=32)?EGL_DONT_CARE:8;
hexdump0815 commented 4 years ago

hello,

i just tried both options - first:

LIBGL: Initialising gl4es
LIBGL: v1.1.3 built on Jan 15 2020 21:38:01
LIBGL: using pbuffer
LIBGL: Using GLES 2.0 backend
LIBGL: loaded: libGLESv2.so
LIBGL: loaded: libEGL.so
LIBGL: Float and Half-Float texture support disabled
LIBGL: Using GLES 2.0 backend
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 Substract 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: 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_OES_get_program detected and used
LIBGL: Number of supported Program Binary Format: 1
LIBGL: Max texture size: 8192
LIBGL: Max Varying Vector: 15
LIBGL: Texture Units: 8(8), Max lights: 8, Max planes: 6
LIBGL: Hardware vendor is ARM
LIBGL: sRGB surface supported
LIBGL: Targeting OpenGL 2.0
LIBGL: NPOT texture handled in hardware
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: Current folder is:/home/mrnobody
glXChooseVisual(0x5c8bd8, 0, 0xbeb8fe9c[4,5,8,1,9,1,a,1,c,1,0])
glXChooseFBConfig(0x5c8bd8, 0, 0xbeb8fd0c, 0xbeb8fce8)
FBConfig doubleBufferMode=1
FBConfig redBits=1
FBConfig greenBits=1
FBConfig blueBits=1
FBConfig depthBits=1
glXChooseFBConfig found 15 config
glXChooseVisual return 0x59b490
glXCreateContext(0x5c8bd8, 0x59b490, (nil), 1) fbcontext_count=0 Creating R:8 G:8 B:8 A:0 visual deth=24 Depth:24 Stencil:8 Multisample:0/0
 => (nil)
LIBGL: No EGL configs found (depth=24, stencil=8).
Error: glXCreateContext failed
LIBGL: Shuting down

second:

LIBGL: Initialising gl4es
LIBGL: v1.1.3 built on Jan 15 2020 21:36:46
LIBGL: using pbuffer
LIBGL: Using GLES 2.0 backend
LIBGL: loaded: libGLESv2.so
LIBGL: loaded: libEGL.so
LIBGL: Float and Half-Float texture support disabled
LIBGL: Using GLES 2.0 backend
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 Substract 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: 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_OES_get_program detected and used
LIBGL: Number of supported Program Binary Format: 1
LIBGL: Max texture size: 8192
LIBGL: Max Varying Vector: 15
LIBGL: Texture Units: 8(8), Max lights: 8, Max planes: 6
LIBGL: Hardware vendor is ARM
LIBGL: sRGB surface supported
LIBGL: Targeting OpenGL 2.0
LIBGL: NPOT texture handled in hardware
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: Current folder is:/home/mrnobody
glXChooseVisual(0x56fbd8, 0, 0xbefd5e9c[4,5,8,1,9,1,a,1,c,1,0])
glXChooseFBConfig(0x56fbd8, 0, 0xbefd5d0c, 0xbefd5ce8)
FBConfig doubleBufferMode=1
FBConfig redBits=1
FBConfig greenBits=1
FBConfig blueBits=1
FBConfig depthBits=1
glXChooseFBConfig found 15 config
glXChooseVisual return 0x542490
glXCreateContext(0x56fbd8, 0x542490, (nil), 1) fbcontext_count=0 Creating R:8 G:8 B:8 A:0 visual deth=24 Depth:24 Stencil:8 Multisample:0/0
 => (nil)
LIBGL: No EGL configs found (depth=24, stencil=8).
Error: glXCreateContext failed
LIBGL: Shuting down

for comparision - this is glmark2 (without any modifications to gl4es), which is working fine:

LIBGL: Initialising gl4es
LIBGL: v1.1.3 built on Jan 15 2020 21:38:28
LIBGL: using pbuffer
LIBGL: Using GLES 2.0 backend
LIBGL: loaded: libGLESv2.so
LIBGL: loaded: libEGL.so
LIBGL: Float and Half-Float texture support disabled
LIBGL: Using GLES 2.0 backend
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 Substract 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: 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_OES_get_program detected and used
LIBGL: Number of supported Program Binary Format: 1
LIBGL: Max texture size: 8192
LIBGL: Max Varying Vector: 15
LIBGL: Texture Units: 8(8), Max lights: 8, Max planes: 6
LIBGL: Hardware vendor is ARM
LIBGL: sRGB surface supported
LIBGL: Targeting OpenGL 2.0
LIBGL: NPOT texture handled in hardware
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: Current folder is:/home/mrnobody
glXQueryVersion(0x1e84d0, 0xbe815e64, 0xbe815e68)
glXChooseFBConfig(0x1e84d0, 0, 0xc34d4, 0xbe815e94)
FBConfig renderable=1
FBConfig drawableType=0x1
FBConfig visual type=32770
FBConfig redBits=1
FBConfig greenBits=1
FBConfig blueBits=1
FBConfig alphaBits=1
FBConfig depthBits=1
FBConfig stencilBits=0
FBConfig doubleBufferMode=1
glXChooseFBConfig found 8 config
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e3b8, 0x0002, 0xbe815e48) -> 0x0010
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e3b8, 0x0008, 0xbe815e30) => 0x0008
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e3b8, 0x0009, 0xbe815e34) => 0x0008
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e3b8, 0x000A, 0xbe815e38) => 0x0008
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e3b8, 0x000B, 0xbe815e3c) => 0x0008
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e3b8, 0x000C, 0xbe815e40) => 0x0018
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e3b8, 0x000D, 0xbe815e44) => 0x0000
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e4a0, 0x0002, 0xbe815e48) -> 0x0010
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e4a0, 0x0008, 0xbe815e30) => 0x0008
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e4a0, 0x0009, 0xbe815e34) => 0x0008
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e4a0, 0x000A, 0xbe815e38) => 0x0008
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e4a0, 0x000B, 0xbe815e3c) => 0x0008
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e4a0, 0x000C, 0xbe815e40) => 0x0018
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e4a0, 0x000D, 0xbe815e44) => 0x0008
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e588, 0x0002, 0xbe815e48) -> 0x0010
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e588, 0x0008, 0xbe815e30) => 0x0008
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e588, 0x0009, 0xbe815e34) => 0x0008
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e588, 0x000A, 0xbe815e38) => 0x0008
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e588, 0x000B, 0xbe815e3c) => 0x0008
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e588, 0x000C, 0xbe815e40) => 0x0018
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e588, 0x000D, 0xbe815e44) => 0x0008
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e670, 0x0002, 0xbe815e48) -> 0x0010
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e670, 0x0008, 0xbe815e30) => 0x0008
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e670, 0x0009, 0xbe815e34) => 0x0008
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e670, 0x000A, 0xbe815e38) => 0x0008
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e670, 0x000B, 0xbe815e3c) => 0x0008
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e670, 0x000C, 0xbe815e40) => 0x0018
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e670, 0x000D, 0xbe815e44) => 0x0008
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e758, 0x0002, 0xbe815e48) -> 0x0010
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e758, 0x0008, 0xbe815e30) => 0x0005
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e758, 0x0009, 0xbe815e34) => 0x0005
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e758, 0x000A, 0xbe815e38) => 0x0005
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e758, 0x000B, 0xbe815e3c) => 0x0001
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e758, 0x000C, 0xbe815e40) => 0x0018
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e758, 0x000D, 0xbe815e44) => 0x0008
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e840, 0x0002, 0xbe815e48) -> 0x0010
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e840, 0x0008, 0xbe815e30) => 0x0004
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e840, 0x0009, 0xbe815e34) => 0x0004
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e840, 0x000A, 0xbe815e38) => 0x0004
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e840, 0x000B, 0xbe815e3c) => 0x0004
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e840, 0x000C, 0xbe815e40) => 0x0018
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e840, 0x000D, 0xbe815e44) => 0x0008
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e928, 0x0002, 0xbe815e48) -> 0x0010
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e928, 0x0008, 0xbe815e30) => 0x0005
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e928, 0x0009, 0xbe815e34) => 0x0005
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e928, 0x000A, 0xbe815e38) => 0x0005
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e928, 0x000B, 0xbe815e3c) => 0x0001
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e928, 0x000C, 0xbe815e40) => 0x0018
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e928, 0x000D, 0xbe815e44) => 0x0008
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7ea10, 0x0002, 0xbe815e48) -> 0x0010
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7ea10, 0x0008, 0xbe815e30) => 0x0004
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7ea10, 0x0009, 0xbe815e34) => 0x0004
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7ea10, 0x000A, 0xbe815e38) => 0x0004
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7ea10, 0x000B, 0xbe815e3c) => 0x0004
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7ea10, 0x000C, 0xbe815e40) => 0x0018
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7ea10, 0x000D, 0xbe815e44) => 0x0008
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e3b8, 0x800B, 0xbe815ee8) => 0x0021
glXCreateNewContext(0x1e84d0, 0xb6d7e3b8, 32788, (nil), 1), drawableType=0x06
glXCreateContextAttribsARB(0x1e84d0, 0xb6d7e3b8, (nil), 1) config is RGBA:8888, depth=24, stencil=0, drawable=6
LIBGL: No EGL configs found.
glXGetCurrentContext()
glXQueryExtensionString(0x1e84d0, 0)
glXMakeCurrent(0x1e84d0, 0x3e00002, 0x1b1ef0), isPBuffer(drawable)=0, context->drawable=(nil), context->eglSurface=(nil)((nil)), context->doublebuff=0, glxContext=(nil)
XGetGeometry gives 800x600 for drawable 0x3e00002
LIBGL: eglMakeCurrent(0xd2080, 0xf4ee0, 0xf4ee0, 0xf52e8)
LIBGL: EGLSurface for drawable 0x3e00002 Added
 => True (glstate=0x1f7720)
glXSwapInterval(0)
LIBGL: ERROR: EGL Error detected: EGL_BAD_SURFACE
glXQueryDrawable(0x1e84d0, 0x3e00002(0), GLX_SWAP_INTERVAL_EXT, 0xbe815f58 = 0)
=======================================================
    glmark2 2014.03+git20150611.fa71af2d
=======================================================
glXGetCurrentContext()
    OpenGL Information
    GL_VENDOR:     ptitSeb
    GL_RENDERER:   GL4ES wrapper
    GL_VERSION:    2.0 gl4es wrapper 1.1.3
=======================================================
glXDestroyContext(0x1e84d0, 0x1b1ef0), fbcontext_count=0, ctx_type=0
  egDestroySurface(0xd2080, 0xf4ee0), drawable=0x3e00002
LIBGL: EGLSurface for drawable 0x3e00002 removed
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e3b8, 0x800B, 0xbe815eb8) => 0x0021
glXCreateNewContext(0x1e84d0, 0xb6d7e3b8, 32788, (nil), 1), drawableType=0x06
glXCreateContextAttribsARB(0x1e84d0, 0xb6d7e3b8, (nil), 1) config is RGBA:8888, depth=24, stencil=0, drawable=6
LIBGL: No EGL configs found.
glXGetCurrentContext()
glXQueryExtensionString(0x1e84d0, 0)
glXMakeCurrent(0x1e84d0, 0x3e00002, 0x1b1ef0), isPBuffer(drawable)=0, context->drawable=(nil), context->eglSurface=(nil)((nil)), context->doublebuff=0, glxContext=(nil)
XGetGeometry gives 800x600 for drawable 0x3e00002
LIBGL: eglMakeCurrent(0xd2080, 0xf4ee0, 0xf4ee0, 0xf52e8)
LIBGL: EGLSurface for drawable 0x3e00002 Added
 => True (glstate=0x1f7710)
glXSwapInterval(0)
LIBGL: ERROR: EGL Error detected: EGL_BAD_SURFACE
glXQueryDrawable(0x1e84d0, 0x3e00002(0), GLX_SWAP_INTERVAL_EXT, 0xbe815f28 = 0)
glXSwapBuffers(0x1e84d0, 0x3e00002)  FPS: 29 FrameTime: 34.483 ms
glXDestroyContext(0x1e84d0, 0x1b1ef0), fbcontext_count=0, ctx_type=0
  egDestroySurface(0xd2080, 0xf4ee0), drawable=0x3e00002
LIBGL: EGLSurface for drawable 0x3e00002 removed
glXGetFBConfigAttrib(0x1e84d0, 0xb6d7e3b8, 0x800B, 0xbe815eb8) => 0x0021
glXCreateNewContext(0x1e84d0, 0xb6d7e3b8, 32788, (nil), 1), drawableType=0x06
glXCreateContextAttribsARB(0x1e84d0, 0xb6d7e3b8, (nil), 1) config is RGBA:8888, depth=24, stencil=0, drawable=6
LIBGL: No EGL configs found.
glXGetCurrentContext()
glXQueryExtensionString(0x1e84d0, 0)
glXMakeCurrent(0x1e84d0, 0x3e00002, 0x1b1ef0), isPBuffer(drawable)=0, context->drawable=(nil), context->eglSurface=(nil)((nil)), context->doublebuff=0, glxContext=(nil)
XGetGeometry gives 800x600 for drawable 0x3e00002
LIBGL: eglMakeCurrent(0xd2080, 0xf4ee0, 0xf4ee0, 0xf52e8)
LIBGL: EGLSurface for drawable 0x3e00002 Added
 => True (glstate=0x1f7710)
glXSwapInterval(0)
LIBGL: ERROR: EGL Error detected: EGL_BAD_SURFACE
glXQueryDrawable(0x1e84d0, 0x3e00002(0), GLX_SWAP_INTERVAL_EXT, 0xbe815f28 = 0)
glXSwapBuffers(0x1e84d0, 0x3e00002)

any idea?

a lot of thanks in advance and best wishes - hexdump

ptitSeb commented 4 years ago

Ok, thanks for all those logs. I can see something is still wrong here, even with the working glmark2 log. I need to rethink all this. This will take a bit of time probably, and I will probably have some more tests for you.

ptitSeb commented 4 years ago

Can you do a new test, replacing line 637 of src/glx/glx.c from

EGL_SURFACE_TYPE, (globals4es.usegbm)?EGL_WINDOW_BIT:(EGL_WINDOW_BIT | EGL_PBUFFER_BIT),

to

EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
hexdump0815 commented 4 years ago

new test result from glxgears:

LIBGL: Initialising gl4es
LIBGL: v1.1.3 built on Jan 16 2020 08:39:11
LIBGL: using pbuffer
LIBGL: Using GLES 2.0 backend
LIBGL: loaded: libGLESv2.so
LIBGL: loaded: libEGL.so
LIBGL: Float and Half-Float texture support disabled
LIBGL: Using GLES 2.0 backend
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 Substract 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: 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_OES_get_program detected and used
LIBGL: Number of supported Program Binary Format: 1
LIBGL: Max texture size: 8192
LIBGL: Max Varying Vector: 15
LIBGL: Texture Units: 8(8), Max lights: 8, Max planes: 6
LIBGL: Hardware vendor is ARM
LIBGL: sRGB surface supported
LIBGL: Targeting OpenGL 2.0
LIBGL: NPOT texture handled in hardware
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: Current folder is:/home/mrnobody
glXChooseVisual(0x54ebd8, 0, 0xbeef6e9c[4,5,8,1,9,1,a,1,c,1,0])
glXChooseFBConfig(0x54ebd8, 0, 0xbeef6d0c, 0xbeef6ce8)
FBConfig doubleBufferMode=1
FBConfig redBits=1
FBConfig greenBits=1
FBConfig blueBits=1
FBConfig depthBits=1
glXChooseFBConfig found 15 config
glXChooseVisual return 0x521490
glXCreateContext(0x54ebd8, 0x521490, (nil), 1) fbcontext_count=0 Creating R:8 G:8 B:8 A:0 visual deth=24 Depth:24 Stencil:8 Multisample:0/0
 => (nil)
LIBGL: No EGL configs found (depth=24, stencil=8).
Error: glXCreateContext failed
LIBGL: Shuting down

please let me know in case i should test other things too ...

ptitSeb commented 4 years ago

Ooh, I sudenly realized that all this is while using LIBGL_FB=3 !

So the previous test, it should not be

EGL_SURFACE_TYPE, EGL_WINDOW_BIT,

but

EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
hexdump0815 commented 4 years ago

hey yes - with this i have working glxgears and the other things still work well - is this just for debugging or already the fix? for completeness here is the debug output:

LIBGL: Initialising gl4es
LIBGL: v1.1.3 built on Jan 17 2020 10:34:13
LIBGL: using pbuffer
LIBGL: Using GLES 2.0 backend
LIBGL: loaded: libGLESv2.so
LIBGL: loaded: libEGL.so
LIBGL: Float and Half-Float texture support disabled
LIBGL: Using GLES 2.0 backend
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 Substract 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: 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_OES_get_program detected and used
LIBGL: Number of supported Program Binary Format: 1
LIBGL: Max texture size: 8192
LIBGL: Max Varying Vector: 15
LIBGL: Texture Units: 8(8), Max lights: 8, Max planes: 6
LIBGL: Hardware vendor is ARM
LIBGL: sRGB surface supported
LIBGL: Targeting OpenGL 2.0
LIBGL: NPOT texture handled in hardware
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: Current folder is:/home/mrnobody
LIBGL: Loaded a PSA with 1 Precompiled Programs
glXChooseVisual(0x610bd8, 0, 0xbed50e9c[4,5,8,1,9,1,a,1,c,1,0])
glXChooseFBConfig(0x610bd8, 0, 0xbed50d0c, 0xbed50ce8)
FBConfig doubleBufferMode=1
FBConfig redBits=1
FBConfig greenBits=1
FBConfig blueBits=1
FBConfig depthBits=1
glXChooseFBConfig found 15 config
glXChooseVisual return 0x5e3490
glXCreateContext(0x610bd8, 0x5e3490, (nil), 1) fbcontext_count=0 Creating R:8 G:8 B:8 A:0 visual deth=24 Depth:24 Stencil:8 Multisample:0/0
 => 0x5eee98
glXMakeCurrent(0x610bd8, 0x4000002, 0x5eee98), isPBuffer(drawable)=0, context->drawable=(nil), context->eglSurface=(nil)((nil)), context->doublebuff=1, glxContext=(nil)
XGetGeometry gives 300x300 for drawable 0x4000002
LIBGL: eglMakeCurrent(0x50f028, 0x57c348, 0x57c348, 0x566938)
LIBGL: EGLSurface for drawable 0x4000002 Added
 => True (glstate=0x67a9f0)
glXQueryExtensionString(0x610bd8, 0)
glXQueryDrawable(0x610bd8, 0x4000002(0), GLX_SWAP_INTERVAL_EXT, 0xbed51010 = 1)
Running synchronized to the vertical refresh.  The framerate should be
approximately the same as the monitor refresh rate.
ptitSeb commented 4 years ago

No, it's not the actual fix, but now I know what to do. I'll do a commit soon :)

ptitSeb commented 4 years ago

I have commited the fix, if you can try.

hexdump0815 commented 4 years ago

i just pulled freshly to get your fix and rebuilt - it still does not work:

LIBGL: Initialising gl4es
LIBGL: v1.1.3 built on Jan 17 2020 12:04:07
LIBGL: using pbuffer
LIBGL: Using GLES 2.0 backend
LIBGL: loaded: libGLESv2.so
LIBGL: loaded: libEGL.so
LIBGL: Float and Half-Float texture support disabled
LIBGL: Using GLES 2.0 backend
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 Substract 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: 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_OES_get_program detected and used
LIBGL: Number of supported Program Binary Format: 1
LIBGL: Max texture size: 8192
LIBGL: Max Varying Vector: 15
LIBGL: Texture Units: 8(8), Max lights: 8, Max planes: 6
LIBGL: Hardware vendor is ARM
LIBGL: sRGB surface supported
LIBGL: Targeting OpenGL 2.0
LIBGL: NPOT texture handled in hardware
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: Current folder is:/home/mrnobody
LIBGL: Loaded a PSA with 1 Precompiled Programs
glXChooseVisual(0x545bd8, 0, 0xbeba9e9c[4,5,8,1,9,1,a,1,c,1,0])
glXChooseFBConfig(0x545bd8, 0, 0xbeba9d0c, 0xbeba9ce8)
FBConfig doubleBufferMode=1
FBConfig redBits=1
FBConfig greenBits=1
FBConfig blueBits=1
FBConfig depthBits=1
glXChooseFBConfig found 15 config
glXChooseVisual return 0x518490
glXCreateContext(0x545bd8, 0x518490, (nil), 1) fbcontext_count=0 Creating R:8 G:8 B:8 A:0 visual deth=24 Depth:24 Stencil:8 Multisample:0/0
 => (nil)
LIBGL: No EGL configs found (depth=24, stencil=8).
Error: glXCreateContext failed
LIBGL: Shuting down
hexdump0815 commented 4 years ago

just some stupid idea: would it maybe make sense to add the git commit hash of the tree used into the debug output? - this way you can always be sure the proper tree/version is used ...

ptitSeb commented 4 years ago

Oh, sorry, I've made a mistake and now I've fixed it, for good (hopefully).

hexdump0815 commented 4 years ago

yes - now it works :) ... thanks a lot ... for completeness the logs again:

LIBGL: Initialising gl4es
LIBGL: v1.1.3 built on Jan 17 2020 22:42:12
LIBGL: using pbuffer
LIBGL: Using GLES 2.0 backend
LIBGL: loaded: libGLESv2.so
LIBGL: loaded: libEGL.so
LIBGL: Float and Half-Float texture support disabled
LIBGL: Using GLES 2.0 backend
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 Substract 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: 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_OES_get_program detected and used
LIBGL: Number of supported Program Binary Format: 1
LIBGL: Max texture size: 8192
LIBGL: Max Varying Vector: 15
LIBGL: Texture Units: 8(8), Max lights: 8, Max planes: 6
LIBGL: Hardware vendor is ARM
LIBGL: sRGB surface supported
LIBGL: Targeting OpenGL 2.0
LIBGL: NPOT texture handled in hardware
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: Current folder is:/home/mrnobody
LIBGL: Loaded a PSA with 1 Precompiled Programs
glXChooseVisual(0x5adbd8, 0, 0xbe829e9c[4,5,8,1,9,1,a,1,c,1,0])
glXChooseFBConfig(0x5adbd8, 0, 0xbe829d0c, 0xbe829ce8)
FBConfig doubleBufferMode=1
FBConfig redBits=1
FBConfig greenBits=1
FBConfig blueBits=1
FBConfig depthBits=1
glXChooseFBConfig found 15 config
glXChooseVisual return 0x580490
glXCreateContext(0x5adbd8, 0x580490, (nil), 1) fbcontext_count=0 Creating R:8 G:8 B:8 A:0 visual deth=24 Depth:24 Stencil:8 Multisample:0/0
 => 0x58be98
glXMakeCurrent(0x5adbd8, 0x3e00002, 0x58be98), isPBuffer(drawable)=0, context->drawable=(nil), context->eglSurface=(nil)((nil)), context->doublebuff=1, glxContext=(nil)
XGetGeometry gives 300x300 for drawable 0x3e00002
LIBGL: eglMakeCurrent(0x4ac028, 0x519348, 0x519348, 0x503938)
LIBGL: EGLSurface for drawable 0x3e00002 Added
 => True (glstate=0x6179f0)
glXQueryExtensionString(0x5adbd8, 0)
glXQueryDrawable(0x5adbd8, 0x3e00002(0), GLX_SWAP_INTERVAL_EXT, 0xbe82a010 = 1)
Running synchronized to the vertical refresh.  The framerate should be
approximately the same as the monitor refresh rate.
hexdump0815 commented 4 years ago

one more LIBGL_FB=3 question: with the mali drivers it works pretty well to use the LIBGL_FB=3 mode to get gpu accelerated graphics on a headless system when accessing it via xpra or vnc (accellerated does not mean very fast, but at least the rendering is done by the gpu and the cpu is free for other things). if i want to do the same with mesa (example raspberry-pi and its vc4/v3d drivers) i have the problem that somehow the app is using gl4es and via that the mesa egl lib, which then somehow rseems to egognize that it is running in an x-window context and tries to enable the egl acceleration against the display device below it which does not work as it is for instance an xvfb. all this is just my limited interpretation of things, but in the end i so far was not able to get my virtual x session opengl renedered via the gpu, but it would be nice if that would be possible too. is there a way to get there maybe by combining gl4es options, mesa options, some hacks or maybe some virtual gl stuff? my idea was to use LIBGL_FB=3 to let mesa egl render into a pbuffer which is then copied to the virtual x server by gl4es like it works so well for mali, but usually the egl setup always fails already in such a setup ...

a lot of thanks in advance and best wishes - hexdump

ptitSeb commented 4 years ago

For now, in LIBGL_FB=3 mode, gl4es first try to create a Pixbuf (so x11 surface), and fallback to PBuffer if it fails. I do like this because, in most case, Pixbuff are much faster to blit in a XWindow than a PBuffer. In your case, it seems you want a way to force PBuffer. Does that seems correct to you?

hexdump0815 commented 4 years ago

i'm not 100% sure if this is exactly the problem. let me put some gl4es outputs here - first rpi3, 64bit mainline kernel, mesa 20rc1 self compiled, ubuntu 18.04, xorg modesetting, everything working well as expexted:

LIBGL: Initialising gl4es
LIBGL: v1.1.3 built on Feb  1 2020 23:46:51
LIBGL: Using GLES 2.0 backend
LIBGL: loaded: libGLESv2.so
LIBGL: loaded: libEGL.so
LIBGL: Float and Half-Float texture support disabled
LIBGL: Using GLES 2.0 backend
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 Substract 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_multi_draw_arrays detected
LIBGL: Extension GL_EXT_texture_format_BGRA8888 detected and used
LIBGL: Extension GL_OES_depth_texture detected and used
LIBGL: high precision float in fragment shader available and used
LIBGL: Extension GL_EXT_frag_depth detected and used
LIBGL: Max vertex attrib: 8
LIBGL: Extension GL_OES_get_program detected and used
LIBGL: Number of supported Program Binary Format: 0
LIBGL: Max texture size: 2048
LIBGL: Max Varying Vector: 8
LIBGL: Texture Units: 4(8), Max lights: 8, Max planes: 6
LIBGL: Hardware vendor is Broadcom
LIBGL: sRGB surface supported
LIBGL: Targeting OpenGL 2.0
LIBGL: NPOT texture handled in hardware
LIBGL: Not trying to batch small subsequent glDrawXXXX
LIBGL: try to use VBO
LIBGL: glX Will try to recycle EGL Surface

second case - all the same but no xorg modesetting server (which can make use of the gpu acceleration of mesa) and instead this is running via xpra using Xvfb (which can not make use of the gpu acceleration of mesa) plus LIBGL_FB=3:

LIBGL: Initialising gl4es
LIBGL: v1.1.3 built on Feb  1 2020 23:46:51
LIBGL: using pbuffer
LIBGL: Using GLES 2.0 backend
LIBGL: loaded: libGLESv2.so
LIBGL: loaded: libEGL.so
LIBGL: Float and Half-Float texture support disabled
LIBGL: Using GLES 2.0 backend
libEGL warning: MESA-LOADER: failed to open swrast (search paths /opt/mesa-rpi-aarch64/lib/aarch64-linux-gnu/dri)

libEGL warning: MESA-LOADER: failed to open swrast (search paths /opt/mesa-rpi-aarch64/lib/aarch64-linux-gnu/dri)

LIBGL: Error while gathering supported extension (eglInitialize: EGL_NOT_INITIALIZED), default to none
LIBGL: Targeting OpenGL 2.0
LIBGL: WARNING, No Limited or Full NPOT support in hardware, Forcing NPOT have no effect!
LIBGL: Not trying to batch small subsequent glDrawXXXX
LIBGL: try to use VBO
...
libEGL warning: MESA-LOADER: failed to open swrast (search paths /opt/mesa-rpi-aarch64/lib/aarch64-linux-gnu/dri)

libEGL warning: MESA-LOADER: failed to open swrast (search paths /opt/mesa-rpi-aarch64/lib/aarch64-linux-gnu/dri)

LIBGL: ERROR: EGL Error detected: EGL_NOT_INITIALIZED
LIBGL: Unable to initialize EGL display.
LIBGL: Unable to initialize EGL.

gl4es was compiled from master recently btw. in both cases. as can be seen in the second case gl4es loads the gles library and it somehow tries to initialize the gpu acceleration which does not work, so it falls back to software rendering which i did not compile in. so somehow one needs to load the gles library in a way that it is not aware it is running in x and thus trying to establish the gpu acceleration link to the x server and fail. not sure if it would be possible to load gles differently from gl4es so that it does not know about x (maybe faking it running in framebuffer or maybe even some headless mode or something similar)?

a lot of thanks in advance and best wishes - hexdump

update: i just did another try (which works perfectly fine too) - running in the normal xorg modesetting session with LIBGL_FB=3 - the output is the same as without LIBGL_FB=3, just with the "LIBGL: using pbuffer" in and the last line "LIBGL: glX Will try to recycle EGL Surface" out ...

ptitSeb commented 4 years ago

Mmmm, looking at your logs, it seems mesa itself wont load the EGL driver without X modsetting: the "dri" driver is not present, so it doesn't load the driver. That's an issue, because without EGL, LIBGL_FB=3 will not work anyway. I don't have a solution here. Maybe things like osmesa can work (honestly, I have no idea, I haven't checked that)?

hexdump0815 commented 4 years ago

i searched a bit more about that topic and looks like things to try would be xpra+xdummy or maybe virtualgl, but i'll have to read a bit more to understand things properly first :) ...

jgmdev commented 4 years ago

I'm getting the same glmark2 message when using the mali fbdev driver under Odroid N2 or Odroid C4:

Error: Error: Could not get a valid XVisualInfo!
Error: Error: Couldn't create native window!
Error: main: Could not initialize canvas

Without a clue I was inspecting to see what could be happening and the snippet of code that triggers the first message is here:

Error: Error: Could not get a valid XVisualInfo!

/* The X window visual must match the supplied visual id */
vis_tmpl.visualid = properties_.visual_id;
vis_info = XGetVisualInfo(xdpy_, VisualIDMask, &vis_tmpl,
                                            &num_visuals);
if (!vis_info) {
    Log::error("Error: Could not get a valid XVisualInfo!\n");
    return false;
}

I wrote a small wrapper (to try and troubleshoot since I know NULL about graphics) that intercepts XGetVisualInfo with LD_PRELOAD and the value of VisualIDMask == 1 and vinfo_template.visualid = 17545738 which I think doesn't tells much, but here I am trying to be helpful :)

also the variable xdpy_ as the name implies is initialized with XOpenDisplay which seems to done before gl4es is loaded as shown with the wrapper loaded and gl4es output:

WRAPPER: [LOADED]
WRAPPER: XOpenDisplay (param) display: (nil)
WRAPPER: XOpenDisplay return: 0xaaaae1838180
LIBGL: Initialising gl4es
LIBGL: v1.1.3 built on May 20 2020 03:59:47
LIBGL: xrefresh will be called on cleanup
LIBGL: framebuffer output enabled
LIBGL: Using GLES 2.0 backend
LIBGL: LIBGL:loaded: /usr/lib/libMali.so
LIBGL: LIBGL:loaded: /usr/lib/libMali.so
LIBGL: Using GLES 2.0 backend
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 Substract 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: Max texture size: 8192
LIBGL: Max Varying Vector: 15
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: Targeting OpenGL 2.1
LIBGL: NPOT texture handled in hardware
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: Current folder is:/home/alarm/Development
WRAPPER: XGetVisualInfo (param) display: 0xaaaae1838180
WRAPPER: XGetVisualInfo (param) vinfo_mask: 1
WRAPPER: XGetVisualInfo (param) vinfo_template.visualid 17545738
WRAPPER: XGetVisualInfo return: (nil)
Error: Error: Could not get a valid XVisualInfo!
Error: Error: Couldn't create native window!
Error: main: Could not initialize canvas
WRAPPER: [LOADED]
WRAPPER: XOpenDisplay (param) display: (nil)
WRAPPER: XOpenDisplay return: 0xaaaadb51c130
LIBGL: Shuting down

Something between:

WRAPPER: XOpenDisplay return: 0xaaaae1838180
LIBGL: Initialising gl4es

is happening which I don't know what is since I'm not familiar on what triggers the gl4es library to load and I guess there may be the issue.

Let me know if I can do something else to help find the cause.

ptitSeb commented 4 years ago

Well. Nice debugging.

Problem is, XGetVisualInfo is called by the app, not by gl4es. So, whatever is happening is in the app, not in gl4es.

Not sure I can help much, I'm not that fluent in X11 API...

What I note, in the glmark2 sources, is that: https://github.com/glmark2/glmark2/blob/80d3a977cc3a207acc00f2b85b9061459c4962aa/src/native-state-x11.cpp#L103 I would prefer something like XVisualInfo vis_tmpl = {0}; To be sure the template is set to 0 (it most likely is 0 on x86/x86_64, but certainly not on arm).

jgmdev commented 4 years ago

Tried your suggestion on the wrapper overwrite of XGetVisualInfo about "XVisualInfo vis_tmpl = {0};" but that didn't fixed the issue so I was reading https://www.x.org/releases/X11R7.5/doc/man/man3/XVisualInfo.3.html and looking at the X11 header files for clues on how to retrieve a default XVisualInfo and found VisualNoMask defined on Xutil.h which if I guess correctly should tell XGetVisualInfo to return the default XVisualInfo of the display... So I did a change to the wrapper XGetVisualInfo function on libwrapper as follows:

XVisualInfo* XGetVisualInfo(
    Display* display,
    long vinfo_mask,
    XVisualInfo* vinfo_template,
    int*   nitems_return
)
{
    printf("WRAPPER: XGetVisualInfo (param) display: %p\n", (void*) display);
    printf("WRAPPER: XGetVisualInfo (param) vinfo_mask: %ld\n", vinfo_mask);
    printf("WRAPPER: XGetVisualInfo (param) vinfo_template.visualid %ld\n", vinfo_template->visualid);

    XVisualInfo* out = (*(wrapper_g.XGetVisualInfo))(
    display,
    VisualNoMask, //ignore user given vinfo_mask
    vinfo_template,
    nitems_return
    );

    printf("WRAPPER: XGetVisualInfo return: %p\n", (void*) out);

    return out;
}

And glmark2 finally ran!!! some samples until it crashed on the process:

LIBGL: Current folder is:/home/alarm/Development
WRAPPER: XGetVisualInfo (param) display: 0xaaaaea6db180
WRAPPER: XGetVisualInfo (param) vinfo_mask: 1
WRAPPER: XGetVisualInfo (param) vinfo_template.visualid 17545738
WRAPPER: XGetVisualInfo return: 0xaaaaea7d5270
=======================================================
    glmark2 2020.04
=======================================================
    OpenGL Information
    GL_VENDOR:     ptitSeb
    GL_RENDERER:   GL4ES wrapper
    GL_VERSION:    2.1 gl4es wrapper 1.1.3
=======================================================
[build] use-vbo=false: FPS: 47 FrameTime: 21.277 ms
[build] use-vbo=true: FPS: 47 FrameTime: 21.277 ms
[texture] texture-filter=nearest: FPS: 47 FrameTime: 21.277 ms
[texture] texture-filter=linear: FPS: 47 FrameTime: 21.277 ms
WRAPPER: [LOADED]
WRAPPER: XOpenDisplay (param) display: (nil)
WRAPPER: XOpenDisplay return: 0xaaaadba6b130
[1]    10192 segmentation fault (core dumped)  LD_PRELOAD="./libwrapper.so" LD_LIBRARY_PATH=/usr/lib/gl4es glmark2

With glmark2 --fullscreen it renders the following samples too:

LIBGL: Current folder is:/home/alarm/Development
WRAPPER: XGetVisualInfo (param) display: 0xaaaae48ca180
WRAPPER: XGetVisualInfo (param) vinfo_mask: 1
WRAPPER: XGetVisualInfo (param) vinfo_template.visualid 17545738
WRAPPER: XGetVisualInfo return: 0xaaaae49c4270
=======================================================
    glmark2 2020.04
=======================================================
    OpenGL Information
    GL_VENDOR:     ptitSeb
    GL_RENDERER:   GL4ES wrapper
    GL_VERSION:    2.1 gl4es wrapper 1.1.3
=======================================================
[build] use-vbo=false: FPS: 47 FrameTime: 21.277 ms
[build] use-vbo=true: FPS: 48 FrameTime: 20.833 ms
[texture] texture-filter=nearest: FPS: 47 FrameTime: 21.277 ms
[texture] texture-filter=linear: FPS: 48 FrameTime: 20.833 ms
WRAPPER: [LOADED]
WRAPPER: XOpenDisplay (param) display: (nil)
WRAPPER: XOpenDisplay return: 0xaaaaf3aad130
[1]    9865 segmentation fault (core dumped)  LD_PRELOAD="./libwrapper.so" LD_LIBRARY_PATH=/usr/lib/gl4es glmark2

But after running it and trying to run it again it crashes before even starting so one has to keep trying until it runs, here is how it crashes:

LIBGL: Current folder is:/home/alarm/Development
WRAPPER: XGetVisualInfo (param) display: 0xaaab19e83180
WRAPPER: XGetVisualInfo (param) vinfo_mask: 1
WRAPPER: XGetVisualInfo (param) vinfo_template.visualid 17545738
WRAPPER: XGetVisualInfo return: 0xaaab19f7d270
=======================================================
    glmark2 2020.04
=======================================================
    OpenGL Information
    GL_VENDOR:     ptitSeb
    GL_RENDERER:   GL4ES wrapper
    GL_VERSION:    2.1 gl4es wrapper 1.1.3
=======================================================
terminate called after throwing an instance of '__gnu_cxx::recursive_init_error'
  what():  std::exception
[1]    10094 abort (core dumped)  LD_PRELOAD="./libwrapper.so" LD_LIBRARY_PATH=/usr/lib/gl4es glmark2

At least this is some start to fix this for libMali fbdev

ptitSeb commented 4 years ago

I'm unsure I get it. I was not suggesting to make that change in the wrapper, but in glmark2 itself. Unless you create a new structure in your wrapper and just copy the visualid and use that local structure in the call to XGetVisualInfo instead?

Any the "random" behavour is quite typical of a non-initialized variable...