-
-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to run glxinfo/glxgears #174
Comments
This seems bad. Have you tried without |
I get the same thing:
I am running X11, and I saw some previous comments here that setting LIB_FB=1 can help, but maybe that's irrelevant now. In any case, having it set doesn't seem to hurt anything (but it doesn't help either) |
Here's a backtrace when the segfault happens when setting LIBGL_EGL to the system libGL:
I had noticed when trying to run the 'gears' demo app under tinygles that it also segfaults at the same location, looks like
|
Does es2gears or an ES1 triangle demo work? We need a baseline. Are you on the stock oldschool n900 OS? I don't have any way of testing, besides the fact I have a Pandora and it works perfectly there, so it's a userspace / X11 / libraries / configuration issue. You might need to do some or a lot of digging and experimenting to narrow this down. EGL_BAD_NATIVE_WINDOW happening with LIBGL_FB=1 is a really bad sign. Does TinyGL work? Getting TinyGLES working is a good start. The PostmarketOS folks in another issue thread here seemed like they had TinyGLES partially working, so I assume you're on stock OS. Your host libGL is Mesa, right? Your libGLES is the SGX driver, not Mesa, right? Can you run es2info to confirm? Ignore some of that, I just saw in your glxinfo output:
It is a terrible idea to run glshim into llvmpipe. Don't do that. Use TinyGLES as your backend or use all of Mesa without glshim (or use a native GLES driver). That said, TinyGLES might need a glshim branch to force the pixel formats, but that should get past glXCreateContext at least. Don't do this:
Let's confirm TinyGL, then TinyGLES, is working, and incrementally work on fixing from there. I can't help you with llvmpipe, which has a gl driver anyway (so I have no incentive to make it work with glshim). When you use TinyGLES, you should do both |
Actually, I am using postmarketOS (I filed the original issue in that other thread when trying to run Hildon, I gave up trying to do that..) After a bit of a hiatus from working on this device and PostMarketOS, I'm back to give it another go and tried to start basic with mesa-demos.
I don't think so, but I'm not sure. Is adding the location of
I'm not doing it intentionally, and have no desire to use llvmpipe at all, I'm just trying to follow what limited info that exists on running this 😄 I really do appreciate the help!! |
In that last attempt, you set the environment variables for tinygles but not for glshim library path, so it used mesa's libGL! You can probably still LD_PRELOAD=/path/to/glshim/lib/libGL.so.1 for glshim to manually target all three libraries so you don't need to muck with LD_LIBRARY_PATH at all |
Which GL do I link against when building TinyGLES? I had assumed glshim... Here's an attempt where I include glshim:
|
glshim is designed to be ABI-compatible with real libGL.so.1, so you can always swap between them (no need to be explicitly linked to glshim). That last one looks promising. What's the stacktrace? The es2_info output doesn't matter... TinyGLES is not actually fully ES1/2, as that wasn't necessary to make it work with glshim. TinyGLES is effectively designed to only work with glshim, and only to render OpenGL that has been translated to an ES subset. It was just a clever way of writing a smaller part of the software renderer. |
Oh! es2gears_x11 is wrong. Don't run any es2 commands against glshim, that's nonsensical. Use glxgears and glxinfo for testing. |
glxinfo:
glxgears:
gdb has this to say:
That last group of messages goes on forever (or at least thousands of lines or more) Setting |
That's a recursion overflow, see here where it calls itself: https://github.com/lunixbochs/tinygles/blob/unstable/src/gles/light.c#L14 Is it possible your OpenGL headers are bad? You can use the ones from the glshim repo. That recursion should only happen if |
#define GL_FRONT 0x0404 The first call is face=1028, or |
I am using the glshim/include directory (modified CMakeLists.txt to include it, as I don't know of a better way). |
Can you single step through the first glMaterialfv with You could also try building tinygles with |
Nevermind, I see the first call is from glshim and the second is from tinygles. My mistake. |
Yea I am on unstable on both of them, pulled this morning.
Yea looks like it starts out with face=1028, then it's set to 1032 (GL_FRONT_AND_BACK) and loops indefinitely. Sorry, it's very difficult to see where exactly it is set to 1032 because there are a ton of function calls and other lines being executed between glshim/src/gl/light.c's glMaterialfv and tinygles/src/gles/light.c's glMaterialfv, and I'm not familiar at all with this code to know what is/isn't important to pay attention to when stepping through :( When going through glshim/src/gl/light.c's glMaterialfv, it skips the switch. But I don't know if that's helpful for you or not. |
Can you just show me the lines taken via single steps? I might be able to figure it out. It MIGHT be LD_PRELOAD's fault (actually I'm 75% sure now, tinygles might be recursing BACK TO glshim, and glshim can only call tinygles because it manually dlopens it!), in which case try removing that and switching to LD_LIBRARY_PATH (but fix your library path to make glshim go first) |
Since the second suggestion is a quicker thing to produce for you, I called glxinfo like this, and the output shows that it's still segfaulting:
(previous version of this comment showed me using LD_LIBRARY_PATH incorrectly..sorry) |
LD_LIBRARY_PATH should point at a folder, not a library (e.g. lib/ not lib/blah.so) |
yea.. sorry about that, I just edited my comment once I realized my mistake |
Backtrace from glxinfo with LD_LIBRARY_PATH set to glshim is:
I'll get the line-by-line stepping through glxgears breaking right now.. |
Well, maybe not. glxgears now fails with this (again):
|
Try stubbing glXQueryDrawable in glshim. src/glx/glx.c, just add |
Stubbing it allows me to at least get past that and hit the infinite recursion loop glMaterialfv. Here's the output from stepping through each line: After that last message, gdb hangs (no prompt, and no output until I ctrl+c out). |
Can you try without gdb and with -fsanitize=address on both glshim and tinygles? (or with valgrind) |
As a sanity check, can you try to run glshim and tinygles with glxgears on an x86 linux desktop in the same way?
|
glxgears runs on my x86 desktop with glshim and tinygles (but colors seem off a bit: https://craftyguy.net/pub/2018-03-18_2543x1404_scrot.png). I also had to add the glXQueryDrawable stub for it to run. glxinfo still segfaults creating context (*vis is still NULLwhen glXCreateContext is called).
Attempting to use valgrind when the libs are built with asan doesn't work:
|
I honestly don't think glxinfo segfaulting on a null visual is critical, as it's not drawing anything. tinygles just needs a null check.
You don't need both asan and valgrind together, separately is enough. I'm mostly looking for how a real app like glxgears. behaves when memory checked.
|
Ok, so contentrating on glxgears. Back on the N900, running with valgrind produces this:
Which seems to suggest that the recursive infinite loop thing is happening, right? I'm not able to find libasan.so for musl, so I cannot provide that data :( |
You're on musl? This could be a linker problem! Can you try musl on desktop?
|
It might be necessary to add a flag to force use_tgl if you have both libGLES and libEGL in your library path already.
|
Awesome, after fixing some compile errors (c99 doesn't allow There are still some weird graphical artifacts, and colors are still off, but this is very promising :) |
That seems low. I hit 60fps easily on a CC Pandora. Can you run perf top? What's your X11 bit depth? Are you 100% sure it's using the NEON renderer?
The colors are definitely related to glMaterial and TinyGL's lighting mod. I may have fixed glxgears once. It doesn't affect most demos.
I'm getting a little urge to work on this more. TinyGLES is memory bound, but I can reduce the overhead by reusing glshim's structures, and I've also had some glshim optimization ideas for a while.
I also think if I can work in tiled rendering it will *fly*, as it can work from cache.
Another fun side effect is glshim+tinygles will work to provide OpenGL 1.x to emscripten.
|
Alpine Linux doesn't package this, but I can try to build it.
24
No, because I don't know how to confirm that. Do you have any suggestions?
\o/ Seriously, I and, I'm quite sure, many others would be very appreciative of any additional improvements to this project. Imagination Technologies and their select OEM partners screwed over millions with their proprietary hw accel. blobs. |
Put a print statement in the ifdef NEON part, or an #error so you know the preprocessor hit it.
I think the framebuffer copy code for 24-bit might be unoptimized! That could be pretty expensive. I might need to write you a NEON blitter.
|
This might be relevant: Alpine's So maybe @craftyguy can use the same workaround here? (One day we'll have Alpine/pmOS for armv7 too, especially if this is relevant here I'll see what I can do.) |
@ollieparanoid |
@lunixbochs if you don't mind, I will submit a PR to fix compiling of glshim/swrast branch on musl. I'll also test on x86/glibc, but I don't have a way to test armhf/armv7 w/ glibc. |
I've tried building with the flags above, and also verifying that NEON is being used (it is), but framerate is still ~38fps. |
Is ZB_copyFrameBuffer being called? |
Assuming you are referring to this instance of it, no, it does not seem to be getting called: https://github.com/lunixbochs/glshim/blob/swrast/src/tinygles/zbuffer.c#L192 I tossed in a print statement to check. |
You should run a profiler on it. perf is a good one. |
Yea unfortunately, as I've discovered in the past on other projects, Alpine Linux has a serious lacking of any profilers. Sigh. Well, even the gains here so far are better than before, at least as measured by glxgears. |
If you stub tglLightfv it fixes the colors. TinyGL definitely seems to have a buggy lighting model. Looks like GL_POSITION causes it. |
I've looked into packaging In October we had some version of |
Made some small optimizations, and the latest commit uses glshim's vectorized matrix code instead of tinygles' (unvectorized). There's some kind of regression causing a lighting glint in glxgears, but otherwise it should be faster and the lighting seems way closer to reality. |
Just tested again, and it seems performance went down for me ~6fps. I see you just pushed another commit though in the last couple of minutes so I'll give that a try right now!
|
Which commit hash caused the 6fps drop? |
Ok looks like 8c0a7f2 fixes lighting as you suggested (there's still some strangeness in the center of the gears though)
|
Can you try reverting this part (glx.c)? e3d5b6b#diff-95debcd9f74cee5ec6da1f8650e388ce |
The changes to |
Reverting that change to glx.c removed the performance regression and it's now ~2fps faster than ever!
|
I guessed that change was causing a color conversion step inside X11. |
How fast is it if you comment out the GL_LIGHTING line in tinygles/enable.c? fabrice said the lighting code was probably slow. |
Commenting out that line gives a nice bump:
I'm not near the device to be able to see if there's any visual impact to doing this though, but I suspect there would be? |
It should actually fix the glinting, which is caused by lighting bugs. Also you don't really need vertex lighting for UI.
|
So I'm back in front of my device, it looks like the gears are being rendered with no color now. Maybe that's a side effect of running without the GL_LIGHTING line? In any case, I've tried to run a UI (hildon, again), and hit the null pointer segfault I mentioned when I tried glxinfo earlier: #174 (comment) |
Ah I forgot to respond to this. You still working on it? Next step should be debugging the visual requested from X11 in glxinfo / by tinygles in glXCreateContext. I guess it shouldn’t be null? Or we should do something else when it’s null?
|
Heh, no worries. I'm not currently working on this, but maybe all this info will help someone who does pick it up again. Thanks for helping me along. |
I've been trying to get glxinfo and/or glxgears to run when using glshim (on a Nokia N900).
My ~/lib directory has tinygles in it as well, so I am explicitly setting LIBGL_GLES to system libGLES binary so that it doesn't get used in this test.
If I set LIBGL_GL, as you suggest in some other issue threads here, I get a segfault with glxinfo:
And when using glshim:
The text was updated successfully, but these errors were encountered: