Skip to content
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

Support for GL (Full KMS) or GL (Fake KMS) on RaspberryPi #135

Closed
evanmtp opened this issue May 6, 2019 · 25 comments
Closed

Support for GL (Full KMS) or GL (Fake KMS) on RaspberryPi #135

evanmtp opened this issue May 6, 2019 · 25 comments

Comments

@evanmtp
Copy link

evanmtp commented May 6, 2019

When attempting to run glslViewer on a Raspberry Pi 3 B+ running Raspbian 9 (stretch), it throws the following error:

glslViewer: src/app.cpp:493: glm::ivec2 getScreenSize(): Assertion `success >= 0' failed.
Aborted

At least one other user experienced this issue back in 2017, as reported here: https://www.raspberrypi.org/forums/viewtopic.php?t=179373

@patriciogonzalezvivo
Copy link
Owner

What version of GlslViewer are you running? It's compiled by source? are you in master?

@evanmtp
Copy link
Author

evanmtp commented May 6, 2019

This result came from GlslViewer version 1.5, which I installed via

sudo apt-get install glslviewer

I also tried building it from source, but make threw an error - seemed to be unhappy about the use of abs in main.cpp, if I remember correctly... I can post the output in a second.

@patriciogonzalezvivo
Copy link
Owner

Seams you are running an old version. I have to get in touch w the people of Raspbian. In the mid time I can help you to compile by source. Just send me the error message.

@evanmtp
Copy link
Author

evanmtp commented May 6, 2019

Amazing, thank you! Here's what I get in the console after cloning the repo and running make in ~/glslViewer:

pi@raspberrypi:~/glslViewer $ make
Platform Raspbian GNU/Linux 9 (stretch)
src/window.o
g++ -Wall -O3 -std=c++11 -fpermissive -DGLM_FORCE_CXX98 -DPLATFORM_RPI -Isrc/ -Iinclude/ -I/opt/vc/include/ -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux -g -c src/window.cpp -o src/window.o -Wno-deprecated-declarations
src/main.o
g++ -Wall -O3 -std=c++11 -fpermissive -DGLM_FORCE_CXX98 -DPLATFORM_RPI -Isrc/ -Iinclude/ -I/opt/vc/include/ -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux -g -c src/main.cpp -o src/main.o -Wno-deprecated-declarations
src/sandbox.o
g++ -Wall -O3 -std=c++11 -fpermissive -DGLM_FORCE_CXX98 -DPLATFORM_RPI -Isrc/ -Iinclude/ -I/opt/vc/include/ -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux -g -c src/sandbox.cpp -o src/sandbox.o -Wno-deprecated-declarations
src/sandbox.cpp: In member function ‘void Sandbox::onMouseDrag(float, float, int)’:
src/sandbox.cpp:1004:22: error: call of overloaded ‘abs(float&)’ is ambiguous
         if (abs(vel_x) < 50.0 && abs(vel_y) < 50.0) {
                      ^
In file included from /usr/include/c++/6/cstdlib:75:0,
                 from /usr/include/c++/6/ext/string_conversions.h:41,
                 from /usr/include/c++/6/bits/basic_string.h:5417,
                 from /usr/include/c++/6/string:52,
                 from src/gl/shader.h:3,
                 from src/sandbox.h:3,
                 from src/sandbox.cpp:1:
/usr/include/stdlib.h:735:12: note: candidate: int abs(int)
 extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
            ^~~
In file included from /usr/include/c++/6/ext/string_conversions.h:41:0,
                 from /usr/include/c++/6/bits/basic_string.h:5417,
                 from /usr/include/c++/6/string:52,
                 from src/gl/shader.h:3,
                 from src/sandbox.h:3,
                 from src/sandbox.cpp:1:
/usr/include/c++/6/cstdlib:180:3: note: candidate: long long int std::abs(long long int)
   abs(long long __x) { return __builtin_llabs (__x); }
   ^~~
/usr/include/c++/6/cstdlib:172:3: note: candidate: long int std::abs(long int)
   abs(long __i) { return __builtin_labs(__i); }
   ^~~
src/sandbox.cpp:1004:43: error: call of overloaded ‘abs(float&)’ is ambiguous
         if (abs(vel_x) < 50.0 && abs(vel_y) < 50.0) {
                                           ^
In file included from /usr/include/c++/6/cstdlib:75:0,
                 from /usr/include/c++/6/ext/string_conversions.h:41,
                 from /usr/include/c++/6/bits/basic_string.h:5417,
                 from /usr/include/c++/6/string:52,
                 from src/gl/shader.h:3,
                 from src/sandbox.h:3,
                 from src/sandbox.cpp:1:
/usr/include/stdlib.h:735:12: note: candidate: int abs(int)
 extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
            ^~~
In file included from /usr/include/c++/6/ext/string_conversions.h:41:0,
                 from /usr/include/c++/6/bits/basic_string.h:5417,
                 from /usr/include/c++/6/string:52,
                 from src/gl/shader.h:3,
                 from src/sandbox.h:3,
                 from src/sandbox.cpp:1:
/usr/include/c++/6/cstdlib:180:3: note: candidate: long long int std::abs(long long int)
   abs(long long __x) { return __builtin_llabs (__x); }
   ^~~
/usr/include/c++/6/cstdlib:172:3: note: candidate: long int std::abs(long int)
   abs(long __i) { return __builtin_labs(__i); }
   ^~~
Makefile:60: recipe for target 'src/sandbox.o' failed
make: *** [src/sandbox.o] Error 1

Edit: as you can see, turns out the issue was in sandbox.cpp, not main.cpp.

@patriciogonzalezvivo
Copy link
Owner

Oh wow... that's weird... abs() it's pretty standard. can you do make clean and then make again

@evanmtp
Copy link
Author

evanmtp commented May 6, 2019

Yes, it does seem strange. I'm afraid that even after make clean I'm getting the same errors.

Not sure if it's a clue, but I see that it's complaining that abs() is overloaded:

src/sandbox.cpp:1004:22: error: call of overloaded ‘abs(float&)’ is ambiguous

@evanmtp
Copy link
Author

evanmtp commented May 6, 2019

I looked into this a bit more, and the issue seems to be with the GL driver, as set in raspi-config. When the driver is set to GL (Full KMS), glslViewer fails to launch with the error I posted above. When it's set to GL (Fake KMS), glslViewer fails to launch with the following error: * failed to add service - already in use?. Using the Legacy driver, glslViewer launches succesfully.

raspi_gl_config

@markusobi
Copy link

@patriciogonzalezvivo Will there be support for GL (Full KMS) or GL (Fake KMS) ?

@patriciogonzalezvivo
Copy link
Owner

Not for the moment.

@patriciogonzalezvivo patriciogonzalezvivo changed the title Unable to launch on Raspberry Pi 3 B+ - getScreenSize() error Support for GL (Full KMS) or GL (Fake KMS) on RaspberryPi Aug 27, 2019
@willstall
Copy link

https://www.raspberrypi.org/forums/viewtopic.php?t=222264

Just leaving this thread in case it helps at all.

@patriciogonzalezvivo
Copy link
Owner

I just finish implementing a GBM/DRM for raspberry pi, wonder if this issue is solve by compiling the lastest master version using:

make DRIVERS=gbm

More information here: https://github.com/patriciogonzalezvivo/glslViewer/wiki/Compiling-GlslViewer

@patriciogonzalezvivo
Copy link
Owner

@evanmtp do you mind confirming that this solve the issue? I would like to close it

@evanmtp
Copy link
Author

evanmtp commented Jun 13, 2020

I would love to, but unfortunately don't have access to my Pi at the moment. Next time I have it on hand, I'll give it a try. Thanks for the patch!

@wraybowling
Copy link

I'm putting a Pi Zero through the paces. I can so far confirm that I got the success >= 0' error when building 809ea22 on Raspbian Stretch. Switching to the Legacy driver via raspi-config works.

@markusobi
Copy link

I tried compiling and running on a Raspberry Pi 3B+ with GL (Fake KMS) OpenGL.
I got several compile errors regarding missing header files so I installed the following packages:
sudo apt install libgbm-dev libdrm-dev libegl-dev libgles2-mesa-dev

I compiled via make DRIVER=gbm. It did compile, but crashed at runtime:

$ ./bin/glslViewer
Unable to get DRM resources
Unable to get DRM resources
Failed to create EGL surface! Error: A NativeWindowType argument does not refer to a valid native window.
Segmentation fault

I noticed that the makefile defines -DPLATFORM_RPI4 when compiling with DRIVER=gbm, so I tried again with -DPLATFORM_RPI instead, but this had the same result.

@patriciogonzalezvivo
Copy link
Owner

patriciogonzalezvivo commented Aug 24, 2020

I think you forgot to read this and make sure on your /boot/config.txt you have the following lines present and uncommented:

dtoverlay=vc4-fkms-v3d
max_framebuffers=2
hdmi_force_hotplug=1

@markusobi
Copy link

markusobi commented Aug 24, 2020

I think you forgot to read this and make sure on your /boot/config.txt you have the following lines present and uncommented:

dtoverlay=vc4-fkms-v3d
max_framebuffers=2
hdmi_force_hotplug=1

I did add this to /boot/config.txt (I discovered the compile instructions just before writing my above post).
My goal is to make a fully configurable video source with a raspberry pi. I already got the resolution change (without reboot) going using xrandr, but xrandr needs the vc4-fkms-v3d driver. I also want to use the awesome glslViewer, which I currently only got to work with the legacy driver on the raspberry pi.
I have quite some experience in C++ - if there is anything that I can do to help (i.e. providing information or debugging), let me know.

@patriciogonzalezvivo
Copy link
Owner

By reading your last message seams you are trying to run GlslViewer from a X11 windows manager. is that right?

@markusobi
Copy link

markusobi commented Feb 13, 2021

By reading your last message seams you are trying to run GlslViewer from a X11 windows manager. is that right?

Well yes, but isn't X11 the default window manager on raspberry pi? I'm using the default setup from raspbian, which is LXDE+OpenBox+X11 from what I've read. All I changed was graphics driver to vc4-fkms-v3d (Fake KMS graphics driver).
Is the glslViewer that works with the legacy driver bypassing X11?

@patriciogonzalezvivo
Copy link
Owner

There is two ways to compile GlslViewer for Raspberry Pi. For X11 or with out X11. The first one use GLFW drivers. That libs takes care of everything. For non-X11 there is legacy (pre RaspberryPi 4 or legacy) both ways runs GlslViewer directly from the console. If X11 is running that produce the error message you were describing.

Here you can find more documentation about it: https://github.com/patriciogonzalezvivo/glslViewer/wiki/Compiling

I'm going to close this issue. I have tried it on Rpi4 and Rpi3 with and without X11 and the three versions seams to compile and work correctly.

If you have other issues or questions you can open this issue again or create a new one. All the best!

Patricio

@VinaiRachakonda
Copy link

VinaiRachakonda commented Apr 4, 2021

Hi! Apologies for opening up an old issue. I recently tried all the compilation methods on my Rpi 4 and I get the same error as above. Any help would be greatly appreciated.

$ ./bin/glslViewer
Unable to get DRM resources
Unable to get DRM resources
Failed to create EGL surface! Error: A NativeWindowType argument does not refer to a valid native window.
Segmentation fault

@patriciogonzalezvivo
Copy link
Owner

Hi @VinaiRachakonda, do you mind sharing a bit of context? Like:

  • OS
  • Hardware
  • And if you are running glslViewer directly from the console or inside a window manager?

Thanks

@VinaiRachakonda
Copy link

Hi @patriciogonzalezvivo

I am on a Raspberry Pi 4 with Raspbian GNU/Linux 10 installed.

I am running glslViewer from the console directly with the fake kms driver installed. I am not quite sure how to use glslViewer from a window manager.

@VinaiRachakonda
Copy link

Hi just wanted to update this. I read this issue #198 and I better understand the terms. I currently compiled with fakekms drivers and now ran glslViewer in headless mode. Now when I try to run the ./bin/ I get the following

Unable to get DRM resources
Unable to get DRM resources
* failed to add service - already in use.

In fact, when I compile with glfw and run with X11 I get the same error as well. Any ideas on what to do? I have added all necessary config variables per the compilation instructions.

Thank you for your time!

@VinaiRachakonda
Copy link

For reference, I am running glslViewer with the Openframe project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants