-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[request] Add Raspberry Pi accelerated Open GL output (8$) #748
Comments
I have not experimented problems with OpenGL ES 2 in a Raspberry Pi 3. Just make sure that you compile against the Broadcom libraries in /opt (if you are using Raspbian). You can use pkg-config to ensure: $ PKG_CONFIG_PATH=/opt/vc/lib/pkgconfig/ pkg-config --cflags bcm_host brcmglesv2 I hope it helps! |
@alvaropg It've compiled SDL2 OpenGL ES 2 with the following command line: $ cc main.c -std=c99 -pedantic -O2 -o bin/demo `PKG_CONFIG_PATH=/opt/vc/lib/pkgconfig/ pkg-config --cflags --libs bcm_host brcmglesv2` -lSDL2 -lm ldd demo:
And running the app:
The lines 115-116 are: glGetShaderiv(dev->vert_shdr, GL_COMPILE_STATUS, &status);
assert(status == GL_TRUE); So, the application is not able to compile the shaders. Do you have the same issue? Or demo just works for you?
|
@DeXP That is very strange. I did not have the same issue, and I was able to get the demo to work on my Raspberry Pi Zero. But I also noticed that the GLES2 demo does not have full error reporting. I added error reporting in a branch so please try that and see if it mentions what problems it was having with the shader compilation. |
@cyclopsian, I have Raspberry Pi 3, most updated raspbian: $ ./bin/demo
[GL]: failed to compile vertex shader:
demo: nuklear_sdl_gles2.h:125: nk_sdl_device_create: Assertion `status == GL_TRUE' failed.
Aborted |
@DeXP That is strange, the error message is coming up blank. You may want to try and see if you can run some other OpenGL programs such as the hello_triangle one in the demo directory (see instructions here). If those work then it's possible the issue is with your version of SDL. |
@cyclopsian Yep, hello_triangle just works: shows spinnig textured cube, no additional info in the console. I've installed SD2 development package form apt, official repos (just typed something like |
@DeXP Upon inspection it looks like the version of SDL2 in the raspbian repo is not properly compiled with Raspberry Pi Support. I was able to get it to work, but I compiled my own SDL2. If you do that it should automatically build the RPI video driver. |
@cyclopsian I did it, mostly according to https://choccyhobnob.com/raspberry-pi/sdl2-2-0-8-on-raspberry-pi/ : SDL2 Configure Summary:
Building Shared Libraries
Building Static Libraries
Enabled modules : atomic audio video render events joystick haptic sensor power filesystem threads timers file loadso cpuinfo assembly
Assembly Math :
Audio drivers : disk dummy oss alsa(dynamic) nas(dynamic)
Video drivers : dummy rpi x11(dynamic) opengl opengl_es1 opengl_es2 vulkan
X11 libraries : xcursor xdbe xinerama xinput2 xinput2_multitouch xrandr xscrnsaver xshape xvidmode
Input drivers : linuxev linuxkd
Using libsamplerate : NO
Using libudev : YES
Using dbus : NO
Using ime : YES
Using ibus : NO
Using fcitx : NO Then compiled demo with usage of SDL2 from $ cc main.c -std=c99 -pedantic -O2 -o bin/demo `PKG_CONFIG_PATH=/opt/vc/lib/pkgconfig/ pkg-config --cflags --libs bcm_host brcmglesv2` -L/usr/local/lib -lSDL2 -lm -Wl,-rpath=/usr/local/lib
$ ldd bin/demo
linux-vdso.so.1 (0x7ed41000)
/usr/lib/arm-linux-gnueabihf/libarmmem.so (0x76ed9000)
libbrcmGLESv2.so => /opt/vc/lib/libbrcmGLESv2.so (0x76e9c000)
libbcm_host.so => /opt/vc/lib/libbcm_host.so (0x76e75000)
libvcos.so => /opt/vc/lib/libvcos.so (0x76e5b000)
libvchiq_arm.so => /opt/vc/lib/libvchiq_arm.so (0x76e45000)
libSDL2-2.0.so.0 => /usr/local/lib/libSDL2-2.0.so.0 (0x76d2d000)
libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0x76cae000)
libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0x76c85000)
libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76b46000)
libbrcmEGL.so => /opt/vc/lib/libbrcmEGL.so (0x76b0d000)
libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0x76afa000)
librt.so.1 => /lib/arm-linux-gnueabihf/librt.so.1 (0x76ae3000)
/lib/ld-linux-armhf.so.3 (0x76eef000) The result is the same:
|
I get it working, finally! Yep, the problem was in a SDL's videodriver. And yes, default version in a Raspbian's repo do not supports However, default
@cyclopsian you gived me the key to solve the issue. Can you claim fixed the issue on BountySource? Otherwise I will move the funds to Mac Request. |
@DeXP Thanks so much, glad to hear it worked! I started a solution on BountySource, I believe that means you can close the issue now and I will be assigned the bounty. |
Yep, solved |
Hey guys, sorry to revive a dead topic like this but does anyone here know why my instance is fairly laggy? I am measuring it takes around 36ms per render cycle to show on the screen. This is worse than 30fps. Any help would be greatly appreciated! |
FYI I have narrowed down the problematic lines. They are as follows:
Those two lines take 10ms and 24ms respectively. If anyone who knows a lot of Opengles2 it would be great if you could chime in as I really want to bring the FPS closer to 60 if possible. |
@ktb92677 If you want to know more about the topic, emscripten has some docs on optimizing GLES (WebGL is an implementation of the GLES API). Particularly this section which is relevant: https://emscripten.org/docs/optimizing/Optimizing-WebGL.html#gpu-driver-friendly-memory-access-behavior
This may or may not help depending on the device & driver you're using. |
For anyone else stumbling across this sometime in the future here was the solution: Adjusting these lines:
To this:
Solved the performance issues and now the FPS is sitting comfortably at 60FPS. |
@cyclopsian any chance you can help me with this issue: What I would like to do is within the same instance of the program fully initialize and delete an SDL+GLES instance twice within the run time of the same program. I have adapted the code base posted above to simply call the contents of main() twice with a slight pause in between. However on the second run the following assert fails:
I used the following code to print the error:
maxLength is zero after glGetShaderiv returns. Also if I manually set maxLength to a larger number glGetShaderInfoLog doesn't even touch infoLog. It leaves it completely empty. Any help would be greatly appreciated |
#define MAX_VERTEX_MEMORY 128 * 1024
#define MAX_ELEMENT_MEMORY 32 * 1024 I think this deserves PR - will you make one? |
sdl_opengles2 already supports Open GL ES 2 and Web GL. It can be compiled on Raspberry Pi (Raspbian Linux), but gives black square only. Please fix it to have an ability to have accelerated Open GL ES output on Raspberry Pi.
8$ bounty
The text was updated successfully, but these errors were encountered: