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
673 stars 152 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

jgmdev commented 4 years ago

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?

That is what I did and in glmark2 the vis_tmpl variable isn't used anywhere else just on the XGetVisualInfo call.

jgmdev commented 4 years ago

So now I tested with the wrapper and glmark2 with llvmpipe and everything worked as expected except for some unimplemented error messages thrown on the output:

LD_PRELOAD="./libwrapper.so" glmark2

WRAPPER: [LOADED]
WRAPPER: XOpenDisplay (param) display: (nil)
WRAPPER: XOpenDisplay return: 0xaaaae0dfc180
WRAPPER: XGetVisualInfo (param) display: 0xaaaae0dfc180
WRAPPER: XGetVisualInfo (param) vinfo_mask: 1
WRAPPER: XGetVisualInfo (param) vinfo_template.visualid 661
WRAPPER: XGetVisualInfo return: 0xaaaae0e18380
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
WRAPPER: XGetVisualInfo (param) display: 0xaaaae0dfc180
WRAPPER: XGetVisualInfo (param) vinfo_mask: 3
WRAPPER: XGetVisualInfo (param) vinfo_template.visualid 661
WRAPPER: XGetVisualInfo return: 0xaaaae10b9100
** Failed to set swap interval. Results may be bounded above by refresh rate.
=======================================================
    glmark2 2020.04
=======================================================
    OpenGL Information
    GL_VENDOR:     VMware, Inc.
    GL_RENDERER:   llvmpipe (LLVM 10.0.0, 128 bits)
    GL_VERSION:    3.1 Mesa 20.0.7
=======================================================
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
[build] use-vbo=false: FPS: 86 FrameTime: 11.628 ms
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
[build] use-vbo=true: FPS: 88 FrameTime: 11.364 ms
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
[texture] texture-filter=nearest: FPS: 163 FrameTime: 6.135 ms
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
[texture] texture-filter=linear: FPS: 147 FrameTime: 6.803 ms
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
[texture] texture-filter=mipmap: FPS: 133 FrameTime: 7.519 ms
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
[shading] shading=gouraud: FPS: 61 FrameTime: 16.393 ms
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
[shading] shading=blinn-phong-inf: FPS: 56 FrameTime: 17.857 ms
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
[shading] shading=phong: FPS: 49 FrameTime: 20.408 ms
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
[shading] shading=cel: FPS: 50 FrameTime: 20.000 ms
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
[bump] bump-render=high-poly: FPS: 29 FrameTime: 34.483 ms
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
[bump] bump-render=normals: FPS: 159 FrameTime: 6.289 ms
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
[bump] bump-render=height: FPS: 148 FrameTime: 6.757 ms
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
[effect2d] kernel=0,1,0;1,-4,1;0,1,0;: FPS: 87 FrameTime: 11.494 ms
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
[effect2d] kernel=1,1,1,1,1;1,1,1,1,1;1,1,1,1,1;: FPS: 64 FrameTime: 15.625 ms
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
[pulsar] light=false:quads=5:texture=false: FPS: 121 FrameTime: 8.264 ms
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
[desktop] blur-radius=5:effect=blur:passes=1:separable=true:windows=4: FPS: 25 FrameTime: 40.000 ms
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
[desktop] effect=shadow:windows=4: FPS: 50 FrameTime: 20.000 ms
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
[buffer] columns=200:interleave=false:update-dispersion=0.9:update-fraction=0.5:update-method=map: FPS: 43 FrameTime: 23.256 ms
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
[buffer] columns=200:interleave=false:update-dispersion=0.9:update-fraction=0.5:update-method=subdata: FPS: 42 FrameTime: 23.810 ms
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
[buffer] columns=200:interleave=true:update-dispersion=0.9:update-fraction=0.5:update-method=map: FPS: 46 FrameTime: 21.739 ms
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
[ideas] speed=duration: FPS: 51 FrameTime: 19.608 ms
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
[jellyfish] <default>: FPS: 39 FrameTime: 25.641 ms
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
[terrain] <default>: FPS: 2 FrameTime: 500.000 ms
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
[shadow] <default>: FPS: 45 FrameTime: 22.222 ms
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
[refract] <default>: FPS: 6 FrameTime: 166.667 ms
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
[conditionals] fragment-steps=0:vertex-steps=0: FPS: 100 FrameTime: 10.000 ms
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
[conditionals] fragment-steps=5:vertex-steps=0: FPS: 101 FrameTime: 9.901 ms
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
[conditionals] fragment-steps=0:vertex-steps=5: FPS: 106 FrameTime: 9.434 ms
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
[function] fragment-complexity=low:fragment-steps=5: FPS: 102 FrameTime: 9.804 ms
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
[function] fragment-complexity=medium:fragment-steps=5: FPS: 91 FrameTime: 10.989 ms
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
[loop] fragment-loop=false:fragment-steps=5:vertex-steps=5: FPS: 98 FrameTime: 10.204 ms
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
[loop] fragment-steps=5:fragment-uniform=false:vertex-steps=5: FPS: 91 FrameTime: 10.989 ms
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
[loop] fragment-steps=5:fragment-uniform=true:vertex-steps=5: FPS: 97 FrameTime: 10.309 ms
=======================================================
                                  glmark2 Score: 78 
=======================================================
jgmdev commented 4 years ago

I compiled both gl4es-git and glmark2-git with debugging symbols enabled and changed the glmark2 code from:

src/native-state-x11.cpp

XVisualInfo vis_tmpl;
XVisualInfo *vis_info = 0;
int num_visuals;

/* 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);

to

XVisualInfo vis_tmpl = {0}; <-- as you suggested
XVisualInfo *vis_info = 0;
int num_visuals;

/* The X window visual must match the supplied visual id */
vis_tmpl.visualid = properties_.visual_id;
vis_info = XGetVisualInfo(xdpy_, VisualNoMask /* to make it run with gl4es*/, &vis_tmpl,
                         &num_visuals);

The crash that happens sometimes when running the application seems to be harder to reproduce with debegging symbols enabled.

Crash for reference (info on stackoverflow):

terminate called after throwing an instance of '__gnu_cxx::recursive_init_error'
  what():  std::exception

So I proceed to run now glmark2 using valgrind to see if I get any useful informantion and here is the output, but since I don't know nothing about graphics I'm kind of look for the meaning of this:

=======================================================
    glmark2 2020.04
=======================================================
    OpenGL Information
    GL_VENDOR:     ptitSeb
    GL_RENDERER:   GL4ES wrapper
    GL_VERSION:    2.1 gl4es wrapper 1.1.3
=======================================================
==32691== Conditional jump or move depends on uninitialised value(s)
==32691==    at 0x5BAE59C: ??? (in /usr/lib/mali-egl/libmali.so)
==32691== 
==32691== Syscall param ioctl(generic) points to uninitialised byte(s)
==32691==    at 0x4E852FC: ioctl (in /usr/lib/libc-2.31.so)
==32691==    by 0x5806EDB: ??? (in /usr/lib/mali-egl/libmali.so)
==32691==  Address 0x1ffefff2e9 is on thread 1's stack
==32691== 
[build] use-vbo=false:==32691== Conditional jump or move depends on uninitialised value(s)
==32691==    at 0x5BC3668: ??? (in /usr/lib/mali-egl/libmali.so)
==32691== 
 FPS: 4 FrameTime: 250.000 ms
[build] use-vbo=true: FPS: 5 FrameTime: 200.000 ms
[texture] texture-filter=nearest: FPS: 5 FrameTime: 200.000 ms
[texture] texture-filter=linear: FPS: 5 FrameTime: 200.000 ms
==32691== Invalid read of size 2
==32691==    at 0x58C26BC: ??? (in /usr/lib/mali-egl/libmali.so)
==32691==  Address 0xcc98ffb is 11 bytes inside a block of size 12 alloc'd
==32691==    at 0x484914C: malloc (vg_replace_malloc.c:309)
==32691==    by 0x5418303: pixel_halfscale (pixel.c:1215)
==32691==    by 0x543949F: glTexImage2D (texture.c:1452)
==32691==    by 0x196893: setup_texture (texture.cpp:88)
==32691==    by 0x196893: Texture::load(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int*, ...) (texture.cpp:135)
==32691==    by 0x18CA23: SceneTexture::setup() (scene-texture.cpp:143)
==32691==    by 0x11F60F: Benchmark::setup_scene() (benchmark.cpp:111)
==32691==    by 0x1234B3: MainLoop::step() (main-loop.cpp:86)
==32691==    by 0x114FAF: do_benchmark(Canvas&) (main.cpp:123)
==32691==    by 0x112763: main (main.cpp:221)
==32691== 
==32691== Invalid read of size 1
==32691==    at 0x58C26C0: ??? (in /usr/lib/mali-egl/libmali.so)
==32691==  Address 0xcc98ffd is 1 bytes after a block of size 12 alloc'd
==32691==    at 0x484914C: malloc (vg_replace_malloc.c:309)
==32691==    by 0x5418303: pixel_halfscale (pixel.c:1215)
==32691==    by 0x543949F: glTexImage2D (texture.c:1452)
==32691==    by 0x196893: setup_texture (texture.cpp:88)
==32691==    by 0x196893: Texture::load(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int*, ...) (texture.cpp:135)
==32691==    by 0x18CA23: SceneTexture::setup() (scene-texture.cpp:143)
==32691==    by 0x11F60F: Benchmark::setup_scene() (benchmark.cpp:111)
==32691==    by 0x1234B3: MainLoop::step() (main-loop.cpp:86)
==32691==    by 0x114FAF: do_benchmark(Canvas&) (main.cpp:123)
==32691==    by 0x112763: main (main.cpp:221)
==32691== 
==32691== Jump to the invalid address stated on the next line
==32691==    at 0x0: ???
==32691==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==32691== 
==32691== 
==32691== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==32691==    at 0x4DF2734: raise (in /usr/lib/libc-2.31.so)
==32691==    by 0x5456257: signal_handler (glx.c:467)
==32691==    by 0x580C4F4B: ??? (in /usr/lib/valgrind/memcheck-arm64-linux)
==32691== 
==32691== HEAP SUMMARY:
==32691==     in use at exit: 6,264,013 bytes in 5,159 blocks
==32691==   total heap usage: 75,248 allocs, 70,089 frees, 30,829,099 bytes allocated
==32691== 
==32691== LEAK SUMMARY:
==32691==    definitely lost: 5,176 bytes in 34 blocks
==32691==    indirectly lost: 520 bytes in 30 blocks
==32691==      possibly lost: 1,436,848 bytes in 337 blocks
==32691==    still reachable: 4,821,469 bytes in 4,758 blocks
==32691==                       of which reachable via heuristic:
==32691==                         length64           : 15,120 bytes in 185 blocks
==32691==                         newarray           : 37,648 bytes in 14 blocks
==32691==                         multipleinheritance: 672 bytes in 4 blocks
==32691==         suppressed: 0 bytes in 0 blocks
==32691== Rerun with --leak-check=full to see details of leaked memory
==32691== 
==32691== Use --track-origins=yes to see where uninitialised values come from
==32691== For lists of detected and suppressed errors, rerun with: -s
==32691== ERROR SUMMARY: 9241 errors from 56 contexts (suppressed: 0 from 0)
[1]    32691 segmentation fault (core dumped)  valgrind ./glmark2

That should be some light at least on why glmark is crashing with gl4es when starting to run the third sample gl benchmark.

ptitSeb commented 4 years ago

I tried some changes in how VisualID is gathered in gl4es. Maybe it's better now?

ptitSeb commented 4 years ago

Also, I get the segfault when using latest sources for glmark2 (I didn't had it with older sources). I don't think it's relatd to the VisualID issue. I'll debug it...

jgmdev commented 4 years ago

Still getting the XVisualInfo error with git build of glmark2, I'm looking at your changes to try and understand.

ptitSeb commented 4 years ago

I have found the issue with the segfault: that's not gl4es fault this time. If you want to run without segfault, use LIBGL_GL=30 export to expose a (fake) OpenGL 3.0 profile.

The problem is with glGenerateMipmap(...). This function is OpenGL 3.0+ (but supported by gl4es). It's used in 3 test, but the function pointer is only taken if opengl 3.0+ is detected. They are not even trying if it's present with some extension.

ptitSeb commented 4 years ago

Still getting the XVisualInfo error with git build of glmark2, I'm looking at your changes to try and understand.

In src/glx/glx.c uncomment line 45. That way, all function in glx.c will gives many debug info. That will help the debugging.

jgmdev commented 4 years ago

Will do that, and found that forcing this to true fixes the issue

if(true /*!configs[j]->associatedVisualId*/) {

And using the troubleshooting wrapper I shared earlier get this:

Calling XGetVisualInfo from GL4ES
WRAPPER: XGetVisualInfo (param) display: 0xaaaac8cfc1a0
WRAPPER: XGetVisualInfo (param) vinfo_mask: 12
WRAPPER: XGetVisualInfo (param) vinfo_template.visualid 0
WRAPPER: XGetVisualInfo return: 0xaaaac8df6290
GL4ES visualid after call: 33

This second call is form glmark
WRAPPER: XGetVisualInfo (param) display: 0xaaaac8cfc1a0
WRAPPER: XGetVisualInfo (param) vinfo_mask: 1
WRAPPER: XGetVisualInfo (param) vinfo_template.visualid 33
WRAPPER: XGetVisualInfo return: 0xaaaac8df6290

The id is properly set to 33 same as glmark so maybe the if should be changed to something like:

if(!configs[j]->associatedVisualId || is_running_in_fb) {

Now will test with the debugging messages you told me.

jgmdev commented 4 years ago

This is what I get when turning it on and restoring the if statement I changed to original

LIBGL: Initialising gl4es
LIBGL: v1.1.3 built on May 22 2020 06:13:34
LIBGL: xrefresh will be called on cleanup
LIBGL: framebuffer output enabled
LIBGL: Using GLES 2.0 backend
LIBGL: LIBGL:loaded: /usr/lib/mali-egl/libmali.so
LIBGL: LIBGL:loaded: /usr/lib/mali-egl/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
glXQueryVersion(0xaaaaec7fb0b0, 0xffffdbf60930, 0xffffdbf60934)
glXQueryExtensionString(0xaaaaec7fb0b0, 0)
glXQueryExtensionString(0xaaaaec7fb0b0, 0)
glXQueryVersion(0xaaaaec7fb0b0, 0xffffdbf607c0, 0xffffdbf607c4)
glXChooseFBConfig(0xaaaaec7fb0b0, 0, 0xaaaab5f50018, 0xffffdbf6084c)
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 5 config
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f620, 0x0002, 0xffffdbf607c0) -> 0x0010
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f620, 0x0008, 0xffffdbf607a8) => 0x0008
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f620, 0x0009, 0xffffdbf607ac) => 0x0008
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f620, 0x000A, 0xffffdbf607b0) => 0x0008
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f620, 0x000B, 0xffffdbf607b4) => 0x0008
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f620, 0x000C, 0xffffdbf607b8) => 0x0018
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f620, 0x000D, 0xffffdbf607bc) => 0x0000
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f708, 0x0002, 0xffffdbf607c0) -> 0x0010
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f708, 0x0008, 0xffffdbf607a8) => 0x0008
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f708, 0x0009, 0xffffdbf607ac) => 0x0008
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f708, 0x000A, 0xffffdbf607b0) => 0x0008
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f708, 0x000B, 0xffffdbf607b4) => 0x0008
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f708, 0x000C, 0xffffdbf607b8) => 0x0018
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f708, 0x000D, 0xffffdbf607bc) => 0x0008
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f7f0, 0x0002, 0xffffdbf607c0) -> 0x0010
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f7f0, 0x0008, 0xffffdbf607a8) => 0x0008
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f7f0, 0x0009, 0xffffdbf607ac) => 0x0008
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f7f0, 0x000A, 0xffffdbf607b0) => 0x0008
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f7f0, 0x000B, 0xffffdbf607b4) => 0x0008
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f7f0, 0x000C, 0xffffdbf607b8) => 0x0018
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f7f0, 0x000D, 0xffffdbf607bc) => 0x0008
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f8d8, 0x0002, 0xffffdbf607c0) -> 0x0010
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f8d8, 0x0008, 0xffffdbf607a8) => 0x0008
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f8d8, 0x0009, 0xffffdbf607ac) => 0x0008
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f8d8, 0x000A, 0xffffdbf607b0) => 0x0008
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f8d8, 0x000B, 0xffffdbf607b4) => 0x0008
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f8d8, 0x000C, 0xffffdbf607b8) => 0x0018
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f8d8, 0x000D, 0xffffdbf607bc) => 0x0008
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f9c0, 0x0002, 0xffffdbf607c0) -> 0x0010
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f9c0, 0x0008, 0xffffdbf607a8) => 0x0008
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f9c0, 0x0009, 0xffffdbf607ac) => 0x0008
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f9c0, 0x000A, 0xffffdbf607b0) => 0x0008
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f9c0, 0x000B, 0xffffdbf607b4) => 0x0008
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f9c0, 0x000C, 0xffffdbf607b8) => 0x0018
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f9c0, 0x000D, 0xffffdbf607bc) => 0x0008
glXGetFBConfigAttrib(0xaaaaec7fb0b0, 0xffff8e34f620, 0x800B, 0xffffdbf608c4) => 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
ptitSeb commented 4 years ago

My call to XGetVisualInfo is different from the one from glmark2. vinfo_mask should be printed in hex, not in decimal, as it is a mask.

Look here: https://tronche.com/gui/x/xlib/utilities/visual.html#XVisualInfo

I used VisualDepthMask|VisualClassMask to select a visual by filtering Depth (using default X11 Depth), and Class (using TrueColor, to have 24bits). I don't filter by VisualID (so it's 0) Where glmark2 filter only with VisualIDMask, with the VisualID provided by gl4es.

I have made a change to indeed discard the VisualID provided by the EGLConfig and use one gathered with XGetVisualInfo(...) in case when using some FB driver, because the one from EGLConfig is probably not an X11 Native ID (because the FB driver doesn't use X11).

jgmdev commented 4 years ago

Yess!!! Does changes fixed it!

jgmdev commented 4 years ago

Again, Thanks a lot! I sent you a paypal tip for your next coffee for your great work on this project! Will keep testing.

ptitSeb commented 4 years ago

Ok great! I hope performances are ok (it's hit or miss with LIBGL_FB=3)

And thanks for the tip!

jgmdev commented 4 years ago

Ok great! I hope performances are ok (it's hit or miss with LIBGL_FB=3)

I'm actually using LIBGL_FB=1 since the performance with LIBGL_FB=3 is really bad at least with the mali drivers last time I tested. I wonder how possible would be to have something like LIBGL_FB=4 that runs in LIBGL_FB=3 when applications are windowed and LIBGL_FB=1 if window goes fullscreen. And now that you mentioned, tested glmark2 with LIBGL_FB=3 and got LIBGL: ERROR: EGL Error detected: EGL_BAD_SURFACE:

=======================================================
    glmark2 2020.04
=======================================================
    OpenGL Information
    GL_VENDOR:     ptitSeb
    GL_RENDERER:   GL4ES wrapper
    GL_VERSION:    2.1 gl4es wrapper 1.1.3
=======================================================
LIBGL: ERROR: EGL Error detected: EGL_BAD_SURFACE
[build] use-vbo=false: FPS: 8 FrameTime: 125.000 ms
LIBGL: ERROR: EGL Error detected: EGL_BAD_SURFACE
[build] use-vbo=true: FPS: 8 FrameTime: 125.000 ms
LIBGL: ERROR: EGL Error detected: EGL_BAD_SURFACE
[texture] texture-filter=nearest: FPS: 8 FrameTime: 125.000 ms
LIBGL: ERROR: EGL Error detected: EGL_BAD_SURFACE
[texture] texture-filter=linear: FPS: 8 FrameTime: 125.000 ms
LIBGL: ERROR: EGL Error detected: EGL_BAD_SURFACE
[1]    7490 segmentation fault (core dumped)  LIBGL_FB=3 glmark2

Now I'm going to play with the gbm enabled mali drivers that so far only work under wayland and see if they work with gl4es under X since I see some GBM compile flag on cmake.

ptitSeb commented 4 years ago

The LIBGL_FB=3 config works on my side, so I'll need the full debug trace of glx.c to try understand what's wrong.

LIBGL_FB=4 is the GBM backend (it's still experimental...). The Fullscreen/Windowed mode you suggest would be neat, but it's tricky to have because that's really two different context. I don't know, maybe I'll try that one day.

jgmdev commented 4 years ago

Here is the output with line 45 uncommented:

LIBGL: Initialising gl4es
LIBGL: v1.1.3 built on May 22 2020 07:28:49
LIBGL: xrefresh will be called on cleanup
LIBGL: using pbuffer
LIBGL: Using GLES 2.0 backend
LIBGL: LIBGL:loaded: /usr/lib/mali-egl/libmali.so
LIBGL: LIBGL:loaded: /usr/lib/mali-egl/libmali.so
LIBGL: loaded: libgbm.so
LIBGL: loaded: libdrm.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/GitHub/archlinux-odroid.git/odroid-gl4es/gl4es-clean
glXQueryVersion(0xaaaae5b7f0b0, 0xffffdad9f950, 0xffffdad9f954)
glXQueryExtensionString(0xaaaae5b7f0b0, 0)
glXQueryExtensionString(0xaaaae5b7f0b0, 0)
glXQueryVersion(0xaaaae5b7f0b0, 0xffffdad9f7e0, 0xffffdad9f7e4)
glXChooseFBConfig(0xaaaae5b7f0b0, 0, 0xaaaae0fe3018, 0xffffdad9f86c)
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(0xaaaae5b7f0b0, 0xffffbbfbc4c8, 0x0002, 0xffffdad9f7e0) -> 0x0010
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc4c8, 0x0008, 0xffffdad9f7c8) => 0x0008
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc4c8, 0x0009, 0xffffdad9f7cc) => 0x0008
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc4c8, 0x000A, 0xffffdad9f7d0) => 0x0008
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc4c8, 0x000B, 0xffffdad9f7d4) => 0x0008
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc4c8, 0x000C, 0xffffdad9f7d8) => 0x0018
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc4c8, 0x000D, 0xffffdad9f7dc) => 0x0000
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc5b0, 0x0002, 0xffffdad9f7e0) -> 0x0010
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc5b0, 0x0008, 0xffffdad9f7c8) => 0x0008
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc5b0, 0x0009, 0xffffdad9f7cc) => 0x0008
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc5b0, 0x000A, 0xffffdad9f7d0) => 0x0008
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc5b0, 0x000B, 0xffffdad9f7d4) => 0x0008
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc5b0, 0x000C, 0xffffdad9f7d8) => 0x0018
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc5b0, 0x000D, 0xffffdad9f7dc) => 0x0008
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc698, 0x0002, 0xffffdad9f7e0) -> 0x0010
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc698, 0x0008, 0xffffdad9f7c8) => 0x0008
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc698, 0x0009, 0xffffdad9f7cc) => 0x0008
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc698, 0x000A, 0xffffdad9f7d0) => 0x0008
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc698, 0x000B, 0xffffdad9f7d4) => 0x0008
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc698, 0x000C, 0xffffdad9f7d8) => 0x0018
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc698, 0x000D, 0xffffdad9f7dc) => 0x0008
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc780, 0x0002, 0xffffdad9f7e0) -> 0x0010
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc780, 0x0008, 0xffffdad9f7c8) => 0x0008
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc780, 0x0009, 0xffffdad9f7cc) => 0x0008
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc780, 0x000A, 0xffffdad9f7d0) => 0x0008
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc780, 0x000B, 0xffffdad9f7d4) => 0x0008
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc780, 0x000C, 0xffffdad9f7d8) => 0x0018
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc780, 0x000D, 0xffffdad9f7dc) => 0x0008
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc868, 0x0002, 0xffffdad9f7e0) -> 0x0010
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc868, 0x0008, 0xffffdad9f7c8) => 0x0008
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc868, 0x0009, 0xffffdad9f7cc) => 0x0008
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc868, 0x000A, 0xffffdad9f7d0) => 0x0008
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc868, 0x000B, 0xffffdad9f7d4) => 0x0008
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc868, 0x000C, 0xffffdad9f7d8) => 0x0018
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc868, 0x000D, 0xffffdad9f7dc) => 0x0008
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc950, 0x0002, 0xffffdad9f7e0) -> 0x0010
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc950, 0x0008, 0xffffdad9f7c8) => 0x0005
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc950, 0x0009, 0xffffdad9f7cc) => 0x0005
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc950, 0x000A, 0xffffdad9f7d0) => 0x0005
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc950, 0x000B, 0xffffdad9f7d4) => 0x0001
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc950, 0x000C, 0xffffdad9f7d8) => 0x0018
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc950, 0x000D, 0xffffdad9f7dc) => 0x0008
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbca38, 0x0002, 0xffffdad9f7e0) -> 0x0010
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbca38, 0x0008, 0xffffdad9f7c8) => 0x0004
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbca38, 0x0009, 0xffffdad9f7cc) => 0x0004
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbca38, 0x000A, 0xffffdad9f7d0) => 0x0004
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbca38, 0x000B, 0xffffdad9f7d4) => 0x0004
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbca38, 0x000C, 0xffffdad9f7d8) => 0x0018
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbca38, 0x000D, 0xffffdad9f7dc) => 0x0008
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbcb20, 0x0002, 0xffffdad9f7e0) -> 0x0010
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbcb20, 0x0008, 0xffffdad9f7c8) => 0x0005
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbcb20, 0x0009, 0xffffdad9f7cc) => 0x0005
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbcb20, 0x000A, 0xffffdad9f7d0) => 0x0005
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbcb20, 0x000B, 0xffffdad9f7d4) => 0x0001
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbcb20, 0x000C, 0xffffdad9f7d8) => 0x0018
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbcb20, 0x000D, 0xffffdad9f7dc) => 0x0008
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbcc08, 0x0002, 0xffffdad9f7e0) -> 0x0010
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbcc08, 0x0008, 0xffffdad9f7c8) => 0x0004
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbcc08, 0x0009, 0xffffdad9f7cc) => 0x0004
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbcc08, 0x000A, 0xffffdad9f7d0) => 0x0004
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbcc08, 0x000B, 0xffffdad9f7d4) => 0x0004
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbcc08, 0x000C, 0xffffdad9f7d8) => 0x0018
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbcc08, 0x000D, 0xffffdad9f7dc) => 0x0008
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc4c8, 0x800B, 0xffffdad9f8e4) => 0x0021
glXCreateNewContext(0xaaaae5b7f0b0, 0xffffbbfbc4c8, 32788, (nil), 1), drawableType=0x07
glXCreateContextAttribsARB(0xaaaae5b7f0b0, 0xffffbbfbc4c8, (nil), 1) config is RGBA:8888, depth=24, stencil=0, drawable=7
 => return 0xaaaae5ca06d0 (context->shared=(nil))
glXGetCurrentContext()
glXQueryExtensionString(0xaaaae5b7f0b0, 0)
glXMakeCurrent(0xaaaae5b7f0b0, 0x6c00002, 0xaaaae5ca06d0), isPBuffer(drawable)=0, context->drawable=(nil), context->eglSurface=(nil)((nil)), context->doublebuff=1, glxContext=(nil)
XGetGeometry gives 800x600 for drawable 0x6c00002
LIBGL: eglMakeCurrent(0xaaaae5b66ca0, 0xaaaae5c40be8, 0xaaaae5c40be8, 0xaaaae5bd89b8)
LIBGL: EGLSurface for drawable 0x6c00002 Added
 => True (glstate=0xaaaae5cbd270)
glXSwapInterval(0)
LIBGL: ERROR: EGL Error detected: EGL_BAD_SURFACE
glXQueryDrawable(0xaaaae5b7f0b0, 0x6c00002(0), GLX_SWAP_INTERVAL_EXT, 0xffffdad9f984 = 0)
=======================================================
    glmark2 2020.04
=======================================================
glXGetCurrentContext()
    OpenGL Information
    GL_VENDOR:     ptitSeb
    GL_RENDERER:   GL4ES wrapper
    GL_VERSION:    2.1 gl4es wrapper 1.1.3
=======================================================
glXDestroyContext(0xaaaae5b7f0b0, 0xaaaae5ca06d0), fbcontext_count=0, ctx_type=0
  egDestroySurface(0xaaaae5b66ca0, 0xaaaae5c40be8), drawable=0x6c00002
LIBGL: EGLSurface for drawable 0x6c00002 removed
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc4c8, 0x800B, 0xffffdad9f864) => 0x0021
glXCreateNewContext(0xaaaae5b7f0b0, 0xffffbbfbc4c8, 32788, (nil), 1), drawableType=0x07
glXCreateContextAttribsARB(0xaaaae5b7f0b0, 0xffffbbfbc4c8, (nil), 1) config is RGBA:8888, depth=24, stencil=0, drawable=7
 => return 0xaaaae5ca06d0 (context->shared=(nil))
glXGetCurrentContext()
glXQueryExtensionString(0xaaaae5b7f0b0, 0)
glXMakeCurrent(0xaaaae5b7f0b0, 0x6c00002, 0xaaaae5ca06d0), isPBuffer(drawable)=0, context->drawable=(nil), context->eglSurface=(nil)((nil)), context->doublebuff=1, glxContext=(nil)
XGetGeometry gives 800x600 for drawable 0x6c00002
LIBGL: eglMakeCurrent(0xaaaae5b66ca0, 0xaaaae5c30118, 0xaaaae5c30118, 0xaaaae5c5fab8)
LIBGL: EGLSurface for drawable 0x6c00002 Added
 => True (glstate=0xaaaae5cd5170)
glXSwapInterval(0)
LIBGL: ERROR: EGL Error detected: EGL_BAD_SURFACE
glXQueryDrawable(0xaaaae5b7f0b0, 0x6c00002(0), GLX_SWAP_INTERVAL_EXT, 0xffffdad9f904 = 0)
glXSwapBuffers(0xaaaae5b7f0b0, 0x6c00002)  FPS: 8 FrameTime: 125.000 ms
glXDestroyContext(0xaaaae5b7f0b0, 0xaaaae5ca06d0), fbcontext_count=0, ctx_type=0
  egDestroySurface(0xaaaae5b66ca0, 0xaaaae5c30118), drawable=0x6c00002
LIBGL: EGLSurface for drawable 0x6c00002 removed
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc4c8, 0x800B, 0xffffdad9f864) => 0x0021
glXCreateNewContext(0xaaaae5b7f0b0, 0xffffbbfbc4c8, 32788, (nil), 1), drawableType=0x07
glXCreateContextAttribsARB(0xaaaae5b7f0b0, 0xffffbbfbc4c8, (nil), 1) config is RGBA:8888, depth=24, stencil=0, drawable=7
 => return 0xaaaae5ca06d0 (context->shared=(nil))
glXGetCurrentContext()
glXQueryExtensionString(0xaaaae5b7f0b0, 0)
glXMakeCurrent(0xaaaae5b7f0b0, 0x6c00002, 0xaaaae5ca06d0), isPBuffer(drawable)=0, context->drawable=(nil), context->eglSurface=(nil)((nil)), context->doublebuff=1, glxContext=(nil)
XGetGeometry gives 800x600 for drawable 0x6c00002
LIBGL: eglMakeCurrent(0xaaaae5b66ca0, 0xaaaae5c96fe8, 0xaaaae5c96fe8, 0xaaaae5da8a68)
LIBGL: EGLSurface for drawable 0x6c00002 Added
 => True (glstate=0xaaaae5d9f3b0)
glXSwapInterval(0)
LIBGL: ERROR: EGL Error detected: EGL_BAD_SURFACE
glXQueryDrawable(0xaaaae5b7f0b0, 0x6c00002(0), GLX_SWAP_INTERVAL_EXT, 0xffffdad9f904 = 0)
glXSwapBuffers(0xaaaae5b7f0b0, 0x6c00002)  FPS: 8 FrameTime: 125.000 ms
glXDestroyContext(0xaaaae5b7f0b0, 0xaaaae5ca06d0), fbcontext_count=0, ctx_type=0
  egDestroySurface(0xaaaae5b66ca0, 0xaaaae5c96fe8), drawable=0x6c00002
LIBGL: EGLSurface for drawable 0x6c00002 removed
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc4c8, 0x800B, 0xffffdad9f864) => 0x0021
glXCreateNewContext(0xaaaae5b7f0b0, 0xffffbbfbc4c8, 32788, (nil), 1), drawableType=0x07
glXCreateContextAttribsARB(0xaaaae5b7f0b0, 0xffffbbfbc4c8, (nil), 1) config is RGBA:8888, depth=24, stencil=0, drawable=7
 => return 0xaaaae5ca06d0 (context->shared=(nil))
glXGetCurrentContext()
glXQueryExtensionString(0xaaaae5b7f0b0, 0)
glXMakeCurrent(0xaaaae5b7f0b0, 0x6c00002, 0xaaaae5ca06d0), isPBuffer(drawable)=0, context->drawable=(nil), context->eglSurface=(nil)((nil)), context->doublebuff=1, glxContext=(nil)
XGetGeometry gives 800x600 for drawable 0x6c00002
LIBGL: eglMakeCurrent(0xaaaae5b66ca0, 0xaaaae5c620c8, 0xaaaae5c620c8, 0xaaaae5da8a68)
LIBGL: EGLSurface for drawable 0x6c00002 Added
 => True (glstate=0xaaaae5dcae00)
glXSwapInterval(0)
LIBGL: ERROR: EGL Error detected: EGL_BAD_SURFACE
glXQueryDrawable(0xaaaae5b7f0b0, 0x6c00002(0), GLX_SWAP_INTERVAL_EXT, 0xffffdad9f904 = 0)
glXSwapBuffers(0xaaaae5b7f0b0, 0x6c00002)  FPS: 8 FrameTime: 125.000 ms
glXDestroyContext(0xaaaae5b7f0b0, 0xaaaae5ca06d0), fbcontext_count=0, ctx_type=0
  egDestroySurface(0xaaaae5b66ca0, 0xaaaae5c620c8), drawable=0x6c00002
LIBGL: EGLSurface for drawable 0x6c00002 removed
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc4c8, 0x800B, 0xffffdad9f864) => 0x0021
glXCreateNewContext(0xaaaae5b7f0b0, 0xffffbbfbc4c8, 32788, (nil), 1), drawableType=0x07
glXCreateContextAttribsARB(0xaaaae5b7f0b0, 0xffffbbfbc4c8, (nil), 1) config is RGBA:8888, depth=24, stencil=0, drawable=7
 => return 0xaaaae5ca06d0 (context->shared=(nil))
glXGetCurrentContext()
glXQueryExtensionString(0xaaaae5b7f0b0, 0)
glXMakeCurrent(0xaaaae5b7f0b0, 0x6c00002, 0xaaaae5ca06d0), isPBuffer(drawable)=0, context->drawable=(nil), context->eglSurface=(nil)((nil)), context->doublebuff=1, glxContext=(nil)
XGetGeometry gives 800x600 for drawable 0x6c00002
LIBGL: eglMakeCurrent(0xaaaae5b66ca0, 0xaaaae5cd0f18, 0xaaaae5cd0f18, 0xaaaae5da8a68)
LIBGL: EGLSurface for drawable 0x6c00002 Added
 => True (glstate=0xaaaae5dcae00)
glXSwapInterval(0)
LIBGL: ERROR: EGL Error detected: EGL_BAD_SURFACE
glXQueryDrawable(0xaaaae5b7f0b0, 0x6c00002(0), GLX_SWAP_INTERVAL_EXT, 0xffffdad9f904 = 0)
glXSwapBuffers(0xaaaae5b7f0b0, 0x6c00002)  FPS: 8 FrameTime: 125.000 ms
glXDestroyContext(0xaaaae5b7f0b0, 0xaaaae5ca06d0), fbcontext_count=0, ctx_type=0
  egDestroySurface(0xaaaae5b66ca0, 0xaaaae5cd0f18), drawable=0x6c00002
LIBGL: EGLSurface for drawable 0x6c00002 removed
glXGetFBConfigAttrib(0xaaaae5b7f0b0, 0xffffbbfbc4c8, 0x800B, 0xffffdad9f864) => 0x0021
glXCreateNewContext(0xaaaae5b7f0b0, 0xffffbbfbc4c8, 32788, (nil), 1), drawableType=0x07
glXCreateContextAttribsARB(0xaaaae5b7f0b0, 0xffffbbfbc4c8, (nil), 1) config is RGBA:8888, depth=24, stencil=0, drawable=7
 => return 0xaaaae5ca06d0 (context->shared=(nil))
glXGetCurrentContext()
glXQueryExtensionString(0xaaaae5b7f0b0, 0)
glXMakeCurrent(0xaaaae5b7f0b0, 0x6c00002, 0xaaaae5ca06d0), isPBuffer(drawable)=0, context->drawable=(nil), context->eglSurface=(nil)((nil)), context->doublebuff=1, glxContext=(nil)
XGetGeometry gives 800x600 for drawable 0x6c00002
LIBGL: eglMakeCurrent(0xaaaae5b66ca0, 0xaaaae5d6e768, 0xaaaae5d6e768, 0xaaaae5da8a68)
LIBGL: EGLSurface for drawable 0x6c00002 Added
 => True (glstate=0xaaaae5dcae00)
glXSwapInterval(0)
LIBGL: ERROR: EGL Error detected: EGL_BAD_SURFACE
glXQueryDrawable(0xaaaae5b7f0b0, 0x6c00002(0), GLX_SWAP_INTERVAL_EXT, 0xffffdad9f904 = 0)
[1]    9138 segmentation fault (core dumped)  LIBGL_FB=3 glmark2

LIBGL_FB=4 is the GBM backend (it's still experimental...)

Thanks for the detail! tried it on xfce but segfaulted will boot to gnome wayland and see if I can get it working there.

ptitSeb commented 4 years ago

Ok, I pushed a small change. Maybe that was the issue (setting eglSwapInterval(...) when using PBuffer seems a bad idea)

jgmdev commented 4 years ago

Ok tested LIBGL_FB=3 glxgears and runs but still slow performance, then moved to glmark2 and now it is just segfaulting with no apparent cause, stripped some lines for brevity:

...
glXGetFBConfigAttrib(0xaaaaf45c10b0, 0xffff8c5c6d60, 0x000B, 0xffffcc07ce64) => 0x0004
glXGetFBConfigAttrib(0xaaaaf45c10b0, 0xffff8c5c6d60, 0x000C, 0xffffcc07ce68) => 0x0018
glXGetFBConfigAttrib(0xaaaaf45c10b0, 0xffff8c5c6d60, 0x000D, 0xffffcc07ce6c) => 0x0008
glXGetFBConfigAttrib(0xaaaaf45c10b0, 0xffff8c5c6620, 0x800B, 0xffffcc07cf74) => 0x0021
glXCreateNewContext(0xaaaaf45c10b0, 0xffff8c5c6620, 32788, (nil), 1), drawableType=0x07
glXCreateContextAttribsARB(0xaaaaf45c10b0, 0xffff8c5c6620, (nil), 1) config is RGBA:8888, depth=24, stencil=0, drawable=7
 => return 0xaaaaf46e0650 (context->shared=(nil))
glXGetCurrentContext()
glXQueryExtensionString(0xaaaaf45c10b0, 0)
glXMakeCurrent(0xaaaaf45c10b0, 0x5800002, 0xaaaaf46e0650), isPBuffer(drawable)=0, context->drawable=(nil), context->eglSurface=(nil)((nil)), context->doublebuff=1, glxContext=(nil)
XGetGeometry gives 800x600 for drawable 0x5800002
LIBGL: eglMakeCurrent(0xaaaaf45a8ca0, 0xaaaaf4680b68, 0xaaaaf4680b68, 0xaaaaf4618968)
LIBGL: EGLSurface for drawable 0x5800002 Added
 => True (glstate=0xaaaaf46fd1f0)
glXSwapInterval(0)
Ignoring glXSwapInterval(0) on PBuffer surface
glXQueryDrawable(0xaaaaf45c10b0, 0x5800002(0), GLX_SWAP_INTERVAL_EXT, 0xffffcc07d014 = 1)
glXSwapInterval(0)
Ignoring glXSwapInterval(0) on PBuffer surface
[1]    12429 segmentation fault (core dumped)  LIBGL_FB=3 glmark2

Also valrgrind doesn't tells much even with debugging symbols on both glmark2 and gl4es:

==12674== Jump to the invalid address stated on the next line
==12674==    at 0x0: ???
==12674==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==12674== 
==12674== 
==12674== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==12674==    at 0x4DF7734: raise (in /usr/lib/libc-2.31.so)
==12674==    by 0x545DDD7: signal_handler (glx.c:478)
==12674==    by 0x580C4F4B: ??? (in /usr/lib/valgrind/memcheck-arm64-linux)
==12674== 
==12674== HEAP SUMMARY:
==12674==     in use at exit: 4,154,091 bytes in 3,046 blocks
==12674==   total heap usage: 4,345 allocs, 1,299 frees, 5,495,369 bytes allocated
==12674== 
==12674== LEAK SUMMARY:
==12674==    definitely lost: 776 bytes in 4 blocks
==12674==    indirectly lost: 0 bytes in 0 blocks
==12674==      possibly lost: 3,424,632 bytes in 367 blocks
==12674==    still reachable: 728,683 bytes in 2,675 blocks
==12674==                       of which reachable via heuristic:
==12674==                         length64           : 14,992 bytes in 183 blocks
==12674==         suppressed: 0 bytes in 0 blocks
==12674== Rerun with --leak-check=full to see details of leaked memory
==12674== 
==12674== Use --track-origins=yes to see where uninitialised values come from
==12674== For lists of detected and suppressed errors, rerun with: -s
==12674== ERROR SUMMARY: 7472 errors from 51 contexts (suppressed: 0 from 0)
[1]    12674 segmentation fault (core dumped)  LIBGL_FB=3 valgrind glmark2
jgmdev commented 4 years ago

Testing it seems that on the if:

        if(globals4es.usepbuffer) {
            DBG(printf("Ignoring glXSwapInterval(%d) on PBuffer surface\n", interval);)
        }

re-adding at least these lines fixes the segfault:

if(interval<minswap || interval>maxswap) {
                SHUT_LOGE("Warning, Swap Interval %d is out of possible values %d, %d\n", interval, minswap, maxswap);
            } else
                swapinterval = interval;

so maybe the swapinterval is not initialized elsewhere?

ptitSeb commented 4 years ago

You mean adding swapinterval = interval; inside the if(globals4es.usepbuffer)? I can add it, it doesn't hurt. But I doubt it's reason of the fix. I see a Jump to 0x0 in the valgrind trace, so it looks like a call to a missing function (like when you launch glmark2 without LIBGL_GL=30).

jgmdev commented 4 years ago

Just tried and doing the initialization to zero fixed it:

if(globals4es.usepbuffer) {
            DBG(printf("Ignoring glXSwapInterval(%d) on PBuffer surface\n", interval);)
            swapinterval = 0;
        }

like when you launch glmark2 without LIBGL_GL=30

Ahh didn't know it was implementing parts of 3.0 great!

Edit: strange because swapinterval seems initialized at declaration on line 153.

jgmdev commented 4 years ago

This is great! I didn't know about LIBGL_GL=30 and was using LIBGL_GL=21 so that is why glmark2 wasn't fully running all samples

ptitSeb commented 4 years ago

I mentionned it earlier (https://github.com/ptitSeb/gl4es/issues/119#issuecomment-632600372 ) but it got lost in the flow of update.

Also, LIBGL_GL=21 is the default now (unless you used PANDORA profile for building).

So, is the swapinterval affectation absolutly necessary?

jgmdev commented 4 years ago

So, is the swapinterval affectation absolutly necessary?

Did several test and if not initialized on the if statement it caused a crash for glmark2 on LIBGL_FB=3 mode even if LIBGL_GL=30 is set

if(globals4es.usepbuffer) {
    DBG(printf("Ignoring glXSwapInterval(%d) on PBuffer surface\n", interval);)
    swapinterval = 0; // <-- not sure why but setting this prevents the segfault
}
ptitSeb commented 4 years ago

Ok. Fine, I pushed that change.

ptitSeb commented 4 years ago

I wonder if this ticket can be closed now.

jgmdev commented 4 years ago

@hexdump0815 hasn't responded but I think the issues that he had were fixed.

hexdump0815 commented 4 years ago

@jgmdev @ptitSeb - i think from my side this issue can be closed ... but in the past i always found new cases to debug regarding this topic :) ... for completeness just to followup to my last comment regarding getting mesa gpu accel kind of remotely virtualized the same way via gl4es as i did with the mali blob and LIBGL_FB=3: in the end i found a way to run mesa opengl (without gl4es) remote with gpu accel from the remote machine (so for instance an rpi) via xpra by using the xorgxrdp xserver as virtual x server for xpra (it supports glamor accel) - weird setup, but works with both vc4/v3d on the rpi and with panfrost on some s912 amlogic system ...