lunixbochs / glshim

OpenGL 1.x driver shim for OpenGL ES devices.
https://boards.openpandora.org/topic/11506-glshim/
MIT License
159 stars 32 forks source link

Trying to build for Android #160

Closed tobimensch closed 8 years ago

tobimensch commented 8 years ago

and the first problem I've run into is:

/src/util/extypes.h:5:22: fatal error: X11/Xlib.h: No such file or directory

include <X11/Xlib.h>

                  ^

It is fairly obvious that Android has no X11.

Hope you can help.

lunixbochs commented 8 years ago

duplicate of #158 - X11 isn't actually required, it's just included for glx compatibility on normal linux desktops. I haven't gotten around to making it completely optional yet during build.

tobimensch commented 8 years ago

Thanks for your response!

Can you give a short list of what I need to do to get rid of the X dependencies?

The guy in that duplicate thread didn't seem to have much luck.

lunixbochs commented 8 years ago

remove the x11 headers, typedef all the x11 types to void (like GLXContext, Display, XVisualInfo, etc), and remove calls to XOpenDisplay, XMatchVisualInfo, and other x11 functions

this used to just be in glx.c but there are some calls in remote rendering too now

tobimensch commented 8 years ago

Thanks.

tobimensch commented 8 years ago

I just noticed there is a fork which already supports Android and other platforms:

https://github.com/ptitSeb/glshim

Maybe you should consider merging with or linking to that fork?

lunixbochs commented 8 years ago

I've talked to ptitseb many times about merging, but his fork is from a extremely old revision before several major changes so it would be a significant amount of work. My solution has been to track his features and reimplement most of them. The upstream repo is generally cleaner, more stable, complies to the OpenGL spec better (I have a spreadsheet tracking it), and has unit tests, but his has better game-specific hacks because he's actively using it to release games. We have different feature sets too at this point.

Also, when you say "supports android and other platforms", it's worth noting that upstream glshim also supports all of these platforms without separate build scripts... I just haven't finished removing compile-time X11 req yet.

tobimensch commented 8 years ago

the thing I obviously want you to merge most is android compatibility. :-) Glad that there's a little competition, although it's a lot of work to keep up with it, I suppose, just look at the recent commits by ptitseb.

I'm trying to port a game, so using ptitseb's port might make sense if it's tested with more games.

lunixbochs commented 8 years ago

It's worth trying them both, as we have many different feature sets. You can actually check compatibility with my glshim by using it on a desktop machine via - LD_LIBRARY_PATH=/path/to/glshim/lib LIBGL_GLES=/path/to/real/libGL.so.1

tobimensch commented 8 years ago

It's great to have an alternative, but in the interest of not reinventing the wheel, long term you (both!) should really work towards merging each other's code. One tool with the advantages of both > two tools with different disadvantages.

Thanks for that tip!

lunixbochs commented 8 years ago

That's nothing new. Ptitseb is the one you need to convince :)

tobimensch commented 8 years ago

I just tried the preload trick and it failed so far :-(

glXGetProcAddress: glXQueryDrawable not found. libGL:loaded: .../glshim/lib/libGL.so.1 libGL:loaded: libEGL.so

Then it hangs in the console and I can't even get out of it with cntrl+c.

Not even a window gets started. FYI the app uses SDL2.

tobimensch commented 8 years ago

ooh, and the app continues to run and uses 100% CPU. :-)

lunixbochs commented 8 years ago

uhh you recursively loaded glshim? libgl_gles needs to point to real opengl

lunixbochs commented 8 years ago

glxgears is a good test, and libgl is usually somewhere in /usr/lib

tobimensch commented 8 years ago

You are right, my mistake.

Now that I changed it to /usr/lib64/libGLESv2.so

I get this beautiful segfault

glXGetProcAddress: glXQueryDrawable not found. libGL:loaded: /usr/lib64/libGLESv2.so libGL:loaded: libEGL.so libGL: built on May 20 2016 21:49:22 glXGetProcAddress: glXQueryDrawable not found. libGL: warning, gles_glShadeModel is NULL stub glShadeModel(0x1D01); Segmentation fault (core dumped)

And when I change it to export LIBGL_GLES=/usr/lib64/libGL.so.1 I get

glXGetProcAddress: glXQueryDrawable not found. libGL:loaded: /usr/lib64/libGL.so.1 libGL:loaded: libEGL.so libGL error: unable to load driver: i965_dri.so libGL error: driver pointer missing libGL error: failed to load driver: i965 libGL error: unable to load driver: i965_dri.so libGL error: driver pointer missing libGL error: failed to load driver: i965 libGL error: unable to load driver: swrast_dri.so libGL error: failed to load driver: swrast libGL: built on May 20 2016 21:49:22

:-(

tobimensch commented 8 years ago

Those were the results with the app I'm porting.

With glxgears it is simply: glxgears glxgears: symbol lookup error: glxgears: undefined symbol: glXQueryDrawable

for both /usr/lib64/libGL.so.1 and /usr/lib64/libGLESv2.so

tobimensch commented 8 years ago

I just noticed there's only libGL.so libGL.so.1 libGL.so.1.2.0 in glshim/lib

is there supposed to be GLX and if yes, what am I doing wrong?

lunixbochs commented 8 years ago

set LIBGL_EGL=/usr/lib64/libGL.so.1 as well

tobimensch commented 8 years ago

Done and then I still get this:

glXGetProcAddress: glXQueryDrawable not found. libGL:loaded: /lib64/libGL.so libGL:loaded: /usr/lib64/libGL.so libGL error: unable to load driver: i965_dri.so libGL error: driver pointer missing libGL error: failed to load driver: i965 libGL error: unable to load driver: i965_dri.so libGL error: driver pointer missing libGL error: failed to load driver: i965 libGL error: unable to load driver: swrast_dri.so libGL error: failed to load driver: swrast libGL: built on May 20 2016 22:14:23

then it hangs with no window created and I have to kill it but no high cpu usage.

tobimensch commented 8 years ago

explanation about the path confusion, on fedora /lib64 is just a link to /usr/lib64

lunixbochs commented 8 years ago

K, which opengl library will glxgears load on its own? Try ldd /usr/bin/glxgears

tobimensch commented 8 years ago

bash-4.3$ ldd /usr/bin/glxgears linux-vdso.so.1 (0x00007fff482bf000) libGL.so.1 => /lib64/libGL.so.1 (0x00007f345ca05000) libm.so.6 => /lib64/libm.so.6 (0x00007f345c6fb000) libX11.so.6 => /lib64/libX11.so.6 (0x00007f345c3ba000) libc.so.6 => /lib64/libc.so.6 (0x00007f345bff7000) libexpat.so.1 => /lib64/libexpat.so.1 (0x00007f345bdcb000) libxcb-dri3.so.0 => /lib64/libxcb-dri3.so.0 (0x00007f345bbc7000) libxcb-present.so.0 => /lib64/libxcb-present.so.0 (0x00007f345b9c4000) libxcb-randr.so.0 => /lib64/libxcb-randr.so.0 (0x00007f345b7b6000) libxcb-xfixes.so.0 => /lib64/libxcb-xfixes.so.0 (0x00007f345b5ad000) libxcb-render.so.0 => /lib64/libxcb-render.so.0 (0x00007f345b3a3000) libxcb-shape.so.0 => /lib64/libxcb-shape.so.0 (0x00007f345b19f000) libxcb-sync.so.1 => /lib64/libxcb-sync.so.1 (0x00007f345af97000) libxshmfence.so.1 => /lib64/libxshmfence.so.1 (0x00007f345ad94000) libglapi.so.0 => /lib64/libglapi.so.0 (0x00007f345ab65000) libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f345a93d000) libXext.so.6 => /lib64/libXext.so.6 (0x00007f345a72b000) libXdamage.so.1 => /lib64/libXdamage.so.1 (0x00007f345a528000) libXfixes.so.3 => /lib64/libXfixes.so.3 (0x00007f345a321000) libX11-xcb.so.1 => /lib64/libX11-xcb.so.1 (0x00007f345a11f000) libxcb-glx.so.0 => /lib64/libxcb-glx.so.0 (0x00007f3459f06000) libxcb-dri2.so.0 => /lib64/libxcb-dri2.so.0 (0x00007f3459d00000) libxcb.so.1 => /lib64/libxcb.so.1 (0x00007f3459ade000) libXxf86vm.so.1 => /lib64/libXxf86vm.so.1 (0x00007f34598d8000) libdrm.so.2 => /lib64/libdrm.so.2 (0x00007f34596c8000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f34594ac000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f34592a8000) /lib64/ld-linux-x86-64.so.2 (0x000055cb416ef000) libXau.so.6 => /lib64/libXau.so.6 (0x00007f34590a3000) libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f3458e32000)

tobimensch commented 8 years ago

This is an overview of my system: http://paste.fedoraproject.org/369075/46378320/

If you ever want to test it with comparable hardware/software. The short story is fedora 24 and intel baytrail.

tobimensch commented 8 years ago

I did some googling for this libGL error: unable to load driver: i965_dri.so libGL error: driver pointer missing

Some people with radeon drivers had the same problem on Archlinux and it turned out libgcrypt was the culprit.

I remembered that I got warnings about libgcrypt also when installing updates and so on.

Turned out I had some old left-over libgcrypt.so.11, which is superseded by libgcrypt.so.20.

Removed it and ... now my application runs with glshim! :-)

So it was all my fault.

tobimensch commented 8 years ago

And I might have found the first bug (maybe). When I open up the in-game menu a couple of times the menu doesn't properly disappear anymore. It stays overlayed, although you can continue playing, ...

tobimensch commented 8 years ago

The problem seems to be with nested menus particularly.

tobimensch commented 8 years ago

I had too many terminals open so everything got confusing and I didn't know where which ENV variable was set anymore.

1) I still can't use glshim on the desktop, same error as ever. I started the app with default GL drivers and no preload. 2) So the menu bug has actually existed forever I just didn't know about it.

I think I give up running glshim on the desktop, unless you've an idea.

FabbiX commented 7 years ago

Hi, I have discover this beatiful project only recently. First, thanks: it's very useful and I'm using it on linux. How is android situation now? Is it possible to get libGL.so for android or it requires some unreachable dependencies? And how can be compiled? I've read it was possible some times ago but I haven't understood how to compile it.