Running OGRE3D on Weston (Wayland + XWayland)

Problems building or running the engine, queries about how to use features etc.
Post Reply
psyke1
Gnoblar
Posts: 4
Joined: Wed Feb 17, 2021 12:36 am

Running OGRE3D on Weston (Wayland + XWayland)

Post by psyke1 »

Ogre Version: 1.12.11
Operating System: Linux 5.4.77
Render System: OpenGL ES 2

Hi

I have an Apalis i.MX8QM from Toradex. I am using their Linux version called TorizonCore, which uses Docker debian-based containers. So I have Weston running on a container with XWayland enabled.
I compiled OGRE3D successfully in another container, using the following Dockerfile:

Code: Select all

FROM --platform=linux/arm64 torizon/arm64v8-debian-base:buster AS base
RUN apt-get -y update && apt-get install -y --no-install-recommends \
    apt-utils \
    && apt-mark hold dash && apt-get -y upgrade && apt-mark unhold dash \
    && apt-get clean && apt-get autoremove && rm -rf /var/lib/apt/lists/*
ARG ACCEPT_FSL_EULA=1
RUN apt-get -y update && apt-get install -y --no-install-recommends \
    libwayland-client0 \
    libwayland-server0 \
    libgal-vivante1 \
    libvsc-vivante1 \
    libgbm-vivante1 \
    libegl-vivante1 \
    libgl-vivante1 \
    libglesv2-vivante1 \
    libglesv1-cm-vivante1 \
    libglslc-vivante1 \
    libegl-vivante1-dev \
    && apt-get clean && apt-get autoremove && rm -rf /var/lib/apt/lists/*

# Make sure the user can access DRM and video devices
RUN usermod -a -G video,render torizon
RUN apt-get -y update && apt-get install -y git cmake gcc g++ make libxrandr-dev libglu1-mesa-dev libzip-dev libfreeimage-dev libpoco-dev libois-dev libzzip-0-13 libzzip-dev doxygen libcgal-dev libcppunit-dev libxt-dev libxaw7-dev pkg-config
USER torizon
RUN cd /home/torizon/ && git clone https://github.com/OGRECave/ogre
RUN mkdir -p /home/torizon/ogre/bld && cd /home/torizon/ogre/bld && cmake -DOGRE_BUILD_RENDERSYSTEM_GLES2=1 -DOGRE_BUILD_SAMPLES=1 -DOGRE_CONFIG_THREADS=0 -DOGRE_INSTALL_DOCS=0 -DOGRE_BUILD_PLUGIN_CG=0 -DOGRE_INSTALL_MEDIA=1 -DOGRE_BUILD_TOOLS=0 -DOGRE_BUILD_TESTS=0 -DOGRE_INSTALL_SAMPLES=1 ../
RUN cd /home/torizon/ogre/bld && make -j4
USER root
RUN cd /home/torizon/ogre/bld && make install
The problem is that I try to run SampleBrowser but it fails. This is the ogre.log:

Code: Select all

torizon@a8507663bcc8:~/ogre/bld/bin$ ./SampleBrowser
Creating resource group General
Creating resource group OgreInternal
Creating resource group OgreAutodetect
SceneManagerFactory for type 'DefaultSceneManager' registered.
Registering ResourceManager for type Material
Registering ResourceManager for type Mesh
Registering ResourceManager for type Skeleton
MovableObjectFactory for type 'ParticleSystem' registered.
ArchiveFactory for archive type FileSystem registered.
ArchiveFactory for archive type Zip registered.
ArchiveFactory for archive type EmbeddedZip registered.
DDS codec registering
ETC codec registering
ASTC codec registering
Registering ResourceManager for type HighLevelGpuProgram
Registering ResourceManager for type Compositor
MovableObjectFactory for type 'Entity' registered.
MovableObjectFactory for type 'Light' registered.
MovableObjectFactory for type 'BillboardSet' registered.
MovableObjectFactory for type 'ManualObject' registered.
MovableObjectFactory for type 'BillboardChain' registered.
MovableObjectFactory for type 'RibbonTrail' registered.
Loading library /home/torizon/ogre/bld/lib/RenderSystem_GLES2.so.1.12.12
Installing plugin: OpenGL ES 2.0 RenderSystem
OpenGL ES 2.x Rendering Subsystem created.
Unregistering ResourceManager for type Compositor
Unregistering ResourceManager for type Skeleton
Unregistering ResourceManager for type Mesh
Unregistering ResourceManager for type HighLevelGpuProgram
Unregistering ResourceManager for type Material
Unloading library /home/torizon/ogre/bld/lib/RenderSystem_GLES2
An exception has occurred: Segmentation fault (core dumped)

Pavel pointed me that I must use XWayland in order to see something, or implement a WaylandWindow in Ogre/RenderSystems/GLSupport/src/EGL/X11/OgreX11EGLSupport.cpp. I searched through the Ogre source code and tried to understand it, but I am a bit too new to go for the WaylandWindow approach, as I don't know how to implement that. Anyways, I have XWayland running and I don't know why the SampleBrowser doesn't manage to run. I checked with xeyes app from x11-apps package and it ran, and I also have XWayland enabled in weston.ini file in /etc/xdg/weston with this content:

Code: Select all

[core]
idle-time=0
require-input=false
xwayland=true

[shell]
background-image=
background-color=0x00000000
panel-position=none
locking=false
allow-zap=false
num-workspaces=1

[keyboard]
vt-switching=false
I tried all render systems (except DirectX ones and Metal) without succeed.
I also tried calling cmake with -DOGRE_SUPPORT_USE_EGL=1 but nothing changed.

I would like to know if I am doing something wrong, or to know what I should learn in order to run OGRE3D. As I am pretty new in Linux, when I found out about the existence of Wayland, X11, EGL, GLX and all those things, I've got a little overwhelmed, and I don't know where to start.

Thank you in advance
Last edited by psyke1 on Sat Feb 20, 2021 12:47 am, edited 1 time in total.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 4668
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1002
Contact:

Re: Running OGRE3D Weston (Wayland + XWayland)

Post by dark_sylinc »

Hi!

I'm no longer familiar with this part in Ogre 1.x, so I can't help you much, but I think I spotted that this:
psyke1 wrote: Fri Feb 19, 2021 11:05 pm I also tried calling cmake with -DOGRE_SUPPORT_USE_EGL=1 but nothing changed.
Should be OGRE_GLSUPPORT_USE_EGL

Cheers
Matias
psyke1
Gnoblar
Posts: 4
Joined: Wed Feb 17, 2021 12:36 am

Re: Running OGRE3D Weston (Wayland + XWayland)

Post by psyke1 »

Hi Matias

It was a typo in my post. I compiled it with the correct keyword, OGRE_GLSUPPORT_USE_EGL, because I copied it from the Changelog posted by Pavel.

(By the way, It's nice to know there's an argentinean in Ogre's development team :D)

Cheers.
Tomás
paroj
OGRE Team Member
OGRE Team Member
Posts: 1421
Joined: Sun Mar 30, 2014 2:51 pm
x 622
Contact:

Re: Running OGRE3D on Weston (Wayland + XWayland)

Post by paroj »

psyke1 wrote: Fri Feb 19, 2021 11:05 pm The problem is that I try to run SampleBrowser but it fails. This is the ogre.log:

Code: Select all

torizon@a8507663bcc8:~/ogre/bld/bin$ ./SampleBrowser
Creating resource group General
Creating resource group OgreInternal
Creating resource group OgreAutodetect
SceneManagerFactory for type 'DefaultSceneManager' registered.
Registering ResourceManager for type Material
Registering ResourceManager for type Mesh
Registering ResourceManager for type Skeleton
MovableObjectFactory for type 'ParticleSystem' registered.
ArchiveFactory for archive type FileSystem registered.
ArchiveFactory for archive type Zip registered.
ArchiveFactory for archive type EmbeddedZip registered.
DDS codec registering
ETC codec registering
ASTC codec registering
Registering ResourceManager for type HighLevelGpuProgram
Registering ResourceManager for type Compositor
MovableObjectFactory for type 'Entity' registered.
MovableObjectFactory for type 'Light' registered.
MovableObjectFactory for type 'BillboardSet' registered.
MovableObjectFactory for type 'ManualObject' registered.
MovableObjectFactory for type 'BillboardChain' registered.
MovableObjectFactory for type 'RibbonTrail' registered.
Loading library /home/torizon/ogre/bld/lib/RenderSystem_GLES2.so.1.12.12
Installing plugin: OpenGL ES 2.0 RenderSystem
OpenGL ES 2.x Rendering Subsystem created.
Unregistering ResourceManager for type Compositor
Unregistering ResourceManager for type Skeleton
Unregistering ResourceManager for type Mesh
Unregistering ResourceManager for type HighLevelGpuProgram
Unregistering ResourceManager for type Material
Unloading library /home/torizon/ogre/bld/lib/RenderSystem_GLES2
An exception has occurred: Segmentation fault (core dumped)

that should not happen.

Can you provide a backtrace for this with gdb? I.e.

Code: Select all

gdb SampleBrowser
(wait)
r
(wait till crash)
bt
psyke1
Gnoblar
Posts: 4
Joined: Wed Feb 17, 2021 12:36 am

Re: Running OGRE3D on Weston (Wayland + XWayland)

Post by psyke1 »

Hi, this is GDB output:

Code: Select all

torizon@51ff7edd0671:~/ogre/bld/bin$ gdb SampleBrowser
GNU gdb (Debian 8.2.1-2+b3) 8.2.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "aarch64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from SampleBrowser...done.
(gdb) r
Starting program: /home/torizon/ogre/bld/bin/SampleBrowser
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".
Creating resource group General
Creating resource group OgreInternal
Creating resource group OgreAutodetect
SceneManagerFactory for type 'DefaultSceneManager' registered.
Registering ResourceManager for type Material
Registering ResourceManager for type Mesh
Registering ResourceManager for type Skeleton
MovableObjectFactory for type 'ParticleSystem' registered.
ArchiveFactory for archive type FileSystem registered.
ArchiveFactory for archive type Zip registered.
ArchiveFactory for archive type EmbeddedZip registered.
DDS codec registering
ETC codec registering
ASTC codec registering
Registering ResourceManager for type HighLevelGpuProgram
Registering ResourceManager for type Compositor
MovableObjectFactory for type 'Entity' registered.
MovableObjectFactory for type 'Light' registered.
MovableObjectFactory for type 'BillboardSet' registered.
MovableObjectFactory for type 'ManualObject' registered.
MovableObjectFactory for type 'BillboardChain' registered.
MovableObjectFactory for type 'RibbonTrail' registered.
Loading library /home/torizon/ogre/bld/lib/RenderSystem_GLES2.so.1.12.12
Installing plugin: OpenGL ES 2.0 RenderSystem
OpenGL ES 2.x Rendering Subsystem created.
Unregistering ResourceManager for type Compositor
Unregistering ResourceManager for type Skeleton
Unregistering ResourceManager for type Mesh
Unregistering ResourceManager for type HighLevelGpuProgram
Unregistering ResourceManager for type Material
Unloading library /home/torizon/ogre/bld/lib/RenderSystem_GLES2
An exception has occurred:
Program received signal SIGSEGV, Segmentation fault.
0x0000fffff74ec710 in strlen () from /lib/aarch64-linux-gnu/libc.so.6
(gdb) bt
#0  0x0000fffff74ec710 in strlen () from /lib/aarch64-linux-gnu/libc.so.6
#1  0x0000fffff7a22458 in std::char_traits<char>::length (__s=0xfffff7046ec0 <error: Cannot access memory at address 0xfffff7046ec0>) at /usr/include/c++/8/bits/char_traits.h:322
#2  std::operator<< <std::char_traits<char> > (__s=0xfffff7046ec0 <error: Cannot access memory at address 0xfffff7046ec0>, __out=...) at /usr/include/c++/8/ostream:562
#3  Ogre::Exception::getFullDescription[abi:cxx11]() const (this=0xaaaaaab00ef0) at /home/torizon/ogre/OgreMain/src/OgreException.cpp:71
#4  0x0000aaaaaaab2510 in main (argc=<optimized out>, argv=<optimized out>) at /usr/include/c++/8/bits/char_traits.h:322
Thank you
paroj
OGRE Team Member
OGRE Team Member
Posts: 1421
Joined: Sun Mar 30, 2014 2:51 pm
x 622
Contact:

Re: Running OGRE3D on Weston (Wayland + XWayland)

Post by paroj »

so it actually segfaults inside "Ogre::Exception::getFullDescription"

this seems messed up. Try doing a clean rebuild and see whether it helps.

Otherwise entering "catch throw" before "r" will break on all exceptions and you can try to find the root cause of this.
psyke1
Gnoblar
Posts: 4
Joined: Wed Feb 17, 2021 12:36 am

Re: Running OGRE3D on Weston (Wayland + XWayland)

Post by psyke1 »

Hi

I got a bit further debugging with gdb, and the next problem arose:

Code: Select all

 torizon@7f7ab3404e09:~/ogre/bld/bin$ gdb SampleBrowser
 GNU gdb (Debian 9.2-1) 9.2
 Copyright (C) 2020 Free Software Foundation, Inc.
 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
 This is free software: you are free to change and redistribute it.
 There is NO WARRANTY, to the extent permitted by law.
 Type "show copying" and "show warranty" for details.
 This GDB was configured as "aarch64-linux-gnu".
 Type "show configuration" for configuration details.
 For bug reporting instructions, please see:
 <http://www.gnu.org/software/gdb/bugs/>.
 Find the GDB manual and other documentation resources online at:
     <http://www.gnu.org/software/gdb/documentation/>.
 
 For help, type "help".
 Type "apropos word" to search for commands related to "word"...
 Reading symbols from SampleBrowser...
 (gdb) catch throw
 Catchpoint 1 (throw)
 (gdb) r
 Starting program: /home/torizon/ogre/bld/bin/SampleBrowser
 [Thread debugging using libthread_db enabled]
 Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".
 Creating resource group General
 Creating resource group OgreInternal
 Creating resource group OgreAutodetect
 SceneManagerFactory for type 'DefaultSceneManager' registered.
 Registering ResourceManager for type Material
 Registering ResourceManager for type Mesh
 Registering ResourceManager for type Skeleton
 MovableObjectFactory for type 'ParticleSystem' registered.
 ArchiveFactory for archive type FileSystem registered.
 ArchiveFactory for archive type Zip registered.
 ArchiveFactory for archive type EmbeddedZip registered.
 DDS codec registering
 ETC codec registering
 ASTC codec registering
 Registering ResourceManager for type HighLevelGpuProgram
 Registering ResourceManager for type Compositor
 MovableObjectFactory for type 'Entity' registered.
 MovableObjectFactory for type 'Light' registered.
 MovableObjectFactory for type 'BillboardSet' registered.
 MovableObjectFactory for type 'ManualObject' registered.
 MovableObjectFactory for type 'BillboardChain' registered.
 MovableObjectFactory for type 'RibbonTrail' registered.
 Loading library /home/torizon/ogre/bld/lib/RenderSystem_GLES2.so.1.12.12
 Installing plugin: OpenGL ES 2.0 RenderSystem
 OpenGL ES 2.x Rendering Subsystem created.
 Xlib:  extension "GLX" missing on display ":0.0".
 
 Program received signal SIGSEGV, Segmentation fault.
 0x0000fffff6b5aad8 in glXGetFBConfigs () from /usr/lib/aarch64-linux-gnu/libGL.so.1.2
 (gdb) bt
 #0  0x0000fffff6b5aad8 in glXGetFBConfigs () from /usr/lib/aarch64-linux-gnu/libGL.so.1.2
 #1  0x0000fffff6b5ce84 in glXChooseFBConfigSGIX () from /usr/lib/aarch64-linux-gnu/libGL.so.1.2
 #2  0x0000fffff6c62490 in Ogre::GLXGLSupport::chooseFBConfig (this=0xaaaaaab165c0, attribList=0x0, nElements=0xffffffffe8c0)
     at /home/torizon/ogre/RenderSystems/GLSupport/src/GLX/OgreGLXGLSupport.cpp:522
 #3  0x0000fffff6c61574 in Ogre::GLXGLSupport::GLXGLSupport (this=0xaaaaaab165c0, profile=4) at /home/torizon/ogre/RenderSystems/GLSupport/src/GLX/OgreGLXGLSupport.cpp:135
 #4  0x0000fffff6c61208 in Ogre::getGLSupport (profile=4) at /home/torizon/ogre/RenderSystems/GLSupport/src/GLX/OgreGLXGLSupport.cpp:64
 #5  0x0000fffff6c3e7c0 in Ogre::GLES2RenderSystem::GLES2RenderSystem (this=0xaaaaaab15bb0) at /home/torizon/ogre/RenderSystems/GLES2/src/OgreGLES2RenderSystem.cpp:178
 #6  0x0000fffff6c3e114 in Ogre::GLES2Plugin::install (this=0xaaaaaab15b30) at /home/torizon/ogre/RenderSystems/GLES2/src/OgreGLES2Plugin.cpp:48
 #7  0x0000fffff79c026c in Ogre::Root::installPlugin (this=0xaaaaaab00b20, plugin=0xaaaaaab15b30) at /home/torizon/ogre/OgreMain/src/OgreRoot.cpp:1188
 #8  0x0000fffff6c2b1c4 in Ogre::dllStartPlugin () at /home/torizon/ogre/RenderSystems/GLES2/src/OgreGLES2EngineDll.cpp:41
 #9  0x0000fffff79c064c in Ogre::Root::loadPlugin (this=0xaaaaaab00b20, pluginName="/home/torizon/ogre/bld/lib/RenderSystem_GLES2") at /home/torizon/ogre/OgreMain/src/OgreRoot.cpp:1237
 #10 0x0000fffff79bf2c4 in Ogre::Root::loadPlugins (this=0xaaaaaab00b20, pluginsfile="./plugins.cfg") at /home/torizon/ogre/OgreMain/src/OgreRoot.cpp:973
 #11 0x0000fffff79bc9ac in Ogre::Root::Root (this=0xaaaaaab00b20, pluginFileName="./plugins.cfg", configFileName="./ogre.cfg", logFileName="./ogre.log")
     at /home/torizon/ogre/OgreMain/src/OgreRoot.cpp:227
 #12 0x0000fffff7f76d9c in OgreBites::ApplicationContextBase::createRoot (this=0xfffffffff238) at /home/torizon/ogre/Components/Bites/src/OgreApplicationContextBase.cpp:191
 #13 0x0000fffff7f7669c in OgreBites::ApplicationContextBase::initApp (this=0xfffffffff238) at /home/torizon/ogre/Components/Bites/src/OgreApplicationContextBase.cpp:55
 #14 0x0000aaaaaaab6b28 in OgreBites::SampleContext::go (this=0xfffffffff238, initialSample=0x0) at /home/torizon/ogre/Samples/Common/include/SampleContext.h:143
 #15 0x0000aaaaaaab44e4 in main (argc=1, argv=0xfffffffff648) at /home/torizon/ogre/Samples/Browser/src/main.cpp:89
 
Talking with Toradex team, they told me that the i.MX8's drivers doesn't support X11, and GLX needs that. I am totally new in these topics.
My question is, is there any alternative to make this work? Otherwise, what should be added/modified in OGRE source code in order to make it work in an i.MX8, and how hard you think it is for me, considering it's my first time with these things?

Regards,
Tomás
paroj
OGRE Team Member
OGRE Team Member
Posts: 1421
Joined: Sun Mar 30, 2014 2:51 pm
x 622
Contact:

Re: Running OGRE3D on Weston (Wayland + XWayland)

Post by paroj »

psyke1 wrote: Tue Feb 23, 2021 10:31 pm I got a bit further debugging with gdb, and the next problem arose:
you lost OGRE_GLSUPPORT_USE_EGL again with this one.

anyway.. if xwayland is running, it should translate both X11 & GLX to wayland for you. So it is either not configured correctly or not running on ":0".

The alternative to the xwayland translation layer is to implement that "WaylandWindow" backend for Ogre that I mentioned previously.
Whether this is hard, depends how well you understand any of these samples:
https://www.google.com/search?q=wayland+egl+sample

if you get one of them running, you can try squeezing that into the Ogre GLSupport code.
paroj
OGRE Team Member
OGRE Team Member
Posts: 1421
Joined: Sun Mar 30, 2014 2:51 pm
x 622
Contact:

Re: Running OGRE3D on Weston (Wayland + XWayland)

Post by paroj »

paroj wrote: Sun Feb 21, 2021 8:40 pm so it actually segfaults inside "Ogre::Exception::getFullDescription"
got to use a similar Docker environment and arrived at this error too. The source is eglInitialize failing. No idea why this corrupts the exception.
Anyway.. the solution for me was using "FROM nvidia/opengl:1.2-glvnd-runtime-ubuntu20.04" instead of "FROM ubuntu:20.04"
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 4668
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1002
Contact:

Re: Running OGRE3D on Weston (Wayland + XWayland)

Post by dark_sylinc »

paroj wrote: Wed Mar 03, 2021 11:02 pm got to use a similar Docker environment and arrived at this error too. The source is eglInitialize failing. No idea why this corrupts the exception.
The most likely reason for that to happen is that at some point the error message being thrown is an std::string which was fed at some point with a nullptr C string (e.g. eglQueryString/getDisplayName returning nullptr), which will cause strlen to crash inside std::string.

This is extremely suspicious:

Code: Select all

OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
			"Couldn`t open EGLDisplay " + getDisplayName(),
			"EGLSupport::getGLDisplay");
If getDisplayName returns nullptr, the crash being reported would be explained.
paroj
OGRE Team Member
OGRE Team Member
Posts: 1421
Joined: Sun Mar 30, 2014 2:51 pm
x 622
Contact:

Re: Running OGRE3D on Weston (Wayland + XWayland)

Post by paroj »

yes, I thought about that one too - but its this one:
https://github.com/OGRECave/ogre/blob/m ... rt.cpp#L67

and the garbage content is in "typeName" and "file", while the rest is fine - go figure..

edit:
If getDisplayName returns nullptr, the crash being reported would be explained.
that would crash at throwing time, but it crashes at catching in e.what()
paroj
OGRE Team Member
OGRE Team Member
Posts: 1421
Joined: Sun Mar 30, 2014 2:51 pm
x 622
Contact:

Re: Running OGRE3D on Weston (Wayland + XWayland)

Post by paroj »

finally figured this one out!

the issue is that "Exception" defers the building error string until the "getFullDescription" call.

Now the contents of "file" come from the __FILE__ macro that has static storage duration, but puts the data inside the GLES2 Plugin. That plugin was already unloaded when we called "getFullDescription", so static does not save us anymore and we got a dangling pointer.

The solution is to build the error message right away instead of doing premature optimisations..
Post Reply