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

Fix GLSL 1.50 for Mesa #1725

Draft
wants to merge 7 commits into
base: noetic-devel
Choose a base branch
from

Conversation

rhaschke
Copy link
Contributor

As pointed out in #1721, Mesa doesn't correctly render PointCloud geoms other than points with GLSL 150, while NVIDIA renders them fine.
The problem is that Mesa uses are more strict GLSL compiler than NVIDIA, thus rejecting the existing scripts. Essentially, Mesa doesn't support the compatibility profile. Further, it's not allowed to redefine gl_PerVertex or use the gl_ prefix for user variables (#1721 (comment)).

I was able to fix most syntax issues, such that glslangValidator doesn't complain anymore.
However, the compatibility issue remains. Using the compatibility profile, color values can be passed from CPU to GPU as packed values (uint):

root->convertColourValue(p.color, &color);

and be read in GLSL via gl_Color - as a vec4:
gl_FrontColor = gl_Color;

However, when dropping compatibility profile, we need to unpack the color ourselves:

in vec3 position;
in uint packed_color;

But, I have no idea, how to accomplish that... I'm stuck here.

@simonschmeisser
Copy link
Contributor

I have a vague memory that there was something about being able to explicitly request a compatibility OpenGL context and this fixing something a long time ago ... will ask a collegue tomorrow. Then of course I have no idea how to do that in Ogre

@paroj
Copy link

paroj commented Mar 18, 2022

and be read in GLSL via gl_Color - as a vec4

that will be in vec4 color; see
https://ogrecave.github.io/ogre/api/latest/_high-level-_programs.html#Binding-vertex-attributes

@rhaschke
Copy link
Contributor Author

Thanks a lot for this hint, @paroj! This allowed me to drop the compatibility mode and it works with NVIDIA again 😄
However, Mesa still crashes with the following backtrace:

[Unknown/Just-In-Time compiled code] (Unknown Source:0)
RenderSystem_GL.so.1.9.0!Ogre::GLSL::GLSLLinkProgram::compileAndLink() (Unknown Source:0)
RenderSystem_GL.so.1.9.0!Ogre::GLSL::GLSLLinkProgram::activate() (Unknown Source:0)
RenderSystem_GL.so.1.9.0!Ogre::GLSL::GLSLLinkProgramManager::getActiveLinkProgram() (Unknown Source:0)
RenderSystem_GL.so.1.9.0!Ogre::GLSL::GLSLGpuProgram::bindProgramParameters(Ogre::SharedPtr<Ogre::GpuProgramParameters>, unsigned short) (Unknown Source:0)
RenderSystem_GL.so.1.9.0!Ogre::GLRenderSystem::bindGpuProgramParameters(Ogre::GpuProgramType, Ogre::SharedPtr<Ogre::GpuProgramParameters>, unsigned short) (Unknown Source:0)
libOgreMain.so.1.9.0!Ogre::SceneManager::updateGpuProgramParameters(Ogre::Pass const*) (Unknown Source:0)
libOgreMain.so.1.9.0!Ogre::SceneManager::renderSingleObject(Ogre::Renderable*, Ogre::Pass const*, bool, bool, Ogre::HashedVector<Ogre::Light*> const*) (Unknown Source:0)
...

Probably, we shouldn't mix GLSL150 and GLSL120 shaders as we do right now:

vertex_program_ref rviz/glsl150/pass_pos_color.vert {}
geometry_program_ref rviz/glsl150/box.geom(with_depth) {}
fragment_program_ref rviz/glsl120/depth.frag {}

@rhaschke
Copy link
Contributor Author

One more question, @paroj:
Currently, we explicitly pack Ogre::ColourValues into an uint. I guess that Ogre unpacks those values (on CPU) to bind them to GL vertex attributes as described above. If so, it would make more sense to skip the packing/unpacking and directly pass RGBA values, doesn't it?

@paroj
Copy link

paroj commented Mar 18, 2022

I guess that Ogre unpacks those values (on CPU)

no, those are unpacked by the GPU in hardware

@simonschmeisser
Copy link
Contributor

Crashes here as well it seems

@paroj
Copy link

paroj commented Mar 18, 2022

Probably, we shouldn't mix GLSL150 and GLSL120 shaders as we do right now:

this should typically work. Maybe ancient Ogre 1.9.0 is doing something strange there.

@simonschmeisser
Copy link
Contributor

Thanks for your very valuable input already @paroj Is there some way to catch shader compiler errors and print them?

@rhaschke
Copy link
Contributor Author

@simonschmeisser, do you have a more recent Ogre installation laying around to test this PR against?

@simonschmeisser
Copy link
Contributor

It's more a matter of compilation time ... sudo apt install ogre-1.12-dev or https://launchpad.net/~s-schmeisser/+archive/ubuntu/ogre-1.12 for ogre 1.12.10 or https://salsa.debian.org/games-team/ogre/-/merge_requests/6

will test in the evening/night

@paroj
Copy link

paroj commented Mar 18, 2022

Is there some way to catch shader compiler errors and print them?

recent ogre does that by default.

@simonschmeisser
Copy link
Contributor

1.12.13 is not that helpful, propably not recent enough by Pavels standards, gives the following for "flat square":

[ERROR] [1647802086.438742611]: No techniques available for material [PointCloudMaterial0Sphere]
[ERROR] [1647802086.438813404]: No techniques available for material [PointCloudMaterial0FlatSquare]
[ERROR] [1647802086.504043820]: No techniques available for material [PointCloudMaterial1Sphere]
[ERROR] [1647802086.504105445]: No techniques available for material [PointCloudMaterial1FlatSquare]
[ERROR] [1647802086.603254417]: No techniques available for material [PointCloudMaterial2Sphere]
[ERROR] [1647802086.603320961]: No techniques available for material [PointCloudMaterial2FlatSquare]
[ERROR] [1647802086.727694727]: No techniques available for material [PointCloudMaterial3Sphere]
[ERROR] [1647802086.727765239]: No techniques available for material [PointCloudMaterial3FlatSquare]
[ERROR] [1647802086.822543865]: No techniques available for material [PointCloudMaterial4Sphere]
[ERROR] [1647802086.822607505]: No techniques available for material [PointCloudMaterial4FlatSquare]
....

"points" works but still gives the error about

[ERROR] [1647802086.438742611]: No techniques available for material [PointCloudMaterial0Sphere]

"box", the one updated here gives:

[ERROR] [1647802254.022949258]: No techniques available for material [PointCloudMaterial234Sphere]
[ERROR] [1647802254.023028847]: No techniques available for material [PointCloudMaterial234Box]
[ERROR] [1647802254.119379415]: No techniques available for material [PointCloudMaterial235Sphere]
[ERROR] [1647802254.119457631]: No techniques available for material [PointCloudMaterial235Box]
...

@paroj
Copy link

paroj commented Mar 20, 2022

no, 1.12.13 is fine. That errors are generated by your own logging. They are follow-ups by Ogre marking the material as unavailable by error. The Ogre logging for this looks like: https://github.com/OGRECave/ogre/runs/5611960759?check_suite_focus=true#step:5:948

@simonschmeisser
Copy link
Contributor

It's surprising how long it took me to find out how to enable debug output ... rosrun rviz rviz -l --log-level-debug

Anyway, with 1.12.13 it claims that my hardware does not support geometry shaders:

[ INFO] [1648154435.618437845]: RenderSystem Name: OpenGL Rendering Subsystem
[ INFO] [1648154435.618464972]: GPU Vendor: amd
[ INFO] [1648154435.618494464]: Device Name: AMD RENOIR (DRM 3.41.0, 5.13.0-37-generic, LLVM 12.0.0)
[ INFO] [1648154435.618529955]: Driver Version: 4.6.0.0
[ INFO] [1648154435.618567701]:  * Fixed function pipeline: yes
[ INFO] [1648154435.618606167]:  * 32-bit index buffers: yes
[ INFO] [1648154435.618645796]:  * Hardware stencil buffer: yes
[ INFO] [1648154435.618763129]:    - Stencil depth: 8
[ INFO] [1648154435.618816121]:    - Two sided stencil support: yes
[ INFO] [1648154435.618838330]:    - Wrap stencil values: yes
[ INFO] [1648154435.618864094]:  * Vertex programs: yes
[ INFO] [1648154435.618890490]:    - Number of floating-point constants: 2048
[ INFO] [1648154435.618913410]:    - Number of integer constants: 0
[ INFO] [1648154435.618937421]:    - Number of boolean constants: 0
[ INFO] [1648154435.618964238]:  * Fragment programs: yes
[ INFO] [1648154435.618991285]:    - Number of floating-point constants: 2048
[ INFO] [1648154435.619017230]:    - Number of integer constants: 0
[ INFO] [1648154435.619040460]:    - Number of boolean constants: 0
[ INFO] [1648154435.619066896]:  * Geometry programs: no
[ INFO] [1648154435.619090567]:  * Tessellation Hull programs: no
[ INFO] [1648154435.619114198]:  * Tessellation Domain programs: no
[ INFO] [1648154435.619137468]:  * Compute programs: no
[ INFO] [1648154435.619190119]:  * Supported Shader Profiles: arbfp1 arbvp1 glsl glsl100 glsl110 glsl120 ps_1_1 ps_1_2 ps_1_3 ps_1_4
[ INFO] [1648154435.619217978]:  * Read-back compiled shader: yes
[ INFO] [1648154435.619240647]:  * Number of vertex attributes: 16
[ INFO] [1648154435.619266171]:  * Textures
[ INFO] [1648154435.619289942]:    - Number of texture units: 16
[ INFO] [1648154435.619312542]:    - Floating point: yes
[ INFO] [1648154435.619336483]:    - Non-power-of-two: yes
[ INFO] [1648154435.619359553]:    - 1D textures: yes
[ INFO] [1648154435.619382272]:    - 2D array textures: yes
[ INFO] [1648154435.619405312]:    - 3D textures: yes
[ INFO] [1648154435.619435405]:    - Anisotropic filtering: yes
[ INFO] [1648154435.619469784]:  * Texture Compression: yes
[ INFO] [1648154435.619592867]:    - DXT: yes
[ INFO] [1648154435.619633077]:    - VTC: no
[ INFO] [1648154435.619656588]:    - PVRTC: no
[ INFO] [1648154435.619678285]:    - ATC: no
[ INFO] [1648154435.619700083]:    - ETC1: no
[ INFO] [1648154435.619722672]:    - ETC2: no
[ INFO] [1648154435.619745592]:    - BC4/BC5: no
[ INFO] [1648154435.619768542]:    - BC6H/BC7: no
[ INFO] [1648154435.619791642]:    - ASTC: no
[ INFO] [1648154435.619813810]:    - Automatic mipmap generation: yes
[ INFO] [1648154435.619837592]:  * Vertex Buffers
[ INFO] [1648154435.619863006]:    - VET_UBYTE4 element type: yes
[ INFO] [1648154435.619887138]:    - Render to Vertex Buffer: no
[ INFO] [1648154435.619910778]:    - Instance Data: yes
[ INFO] [1648154435.619933638]:    - Primitive Restart: no
[ INFO] [1648154435.619960114]:  * Vertex texture fetch: yes
[ INFO] [1648154435.619985598]:    - Max vertex textures: 32
[ INFO] [1648154435.620013707]:    - Vertex textures shared: yes
[ INFO] [1648154435.620037418]:  * Read/Write Buffers: no
[ INFO] [1648154435.620061259]:  * Hardware Occlusion Query: yes
[ INFO] [1648154435.620084760]:  * User clip planes: yes
[ INFO] [1648154435.620107680]:  * Infinite far plane projection: yes
[ INFO] [1648154435.620131471]:  * Depth clamping: no
[ INFO] [1648154435.620153860]:  * Hardware render-to-texture: yes
[ INFO] [1648154435.620176780]:    - Multiple Render Targets: 8
[ INFO] [1648154435.620200671]:    - With different bit depths: yes
[ INFO] [1648154435.620225073]:  * Point Sprites: yes
[ INFO] [1648154435.620248073]:    - Extended parameters: yes
[ INFO] [1648154435.620282533]:    - Max Size: 2048
[ INFO] [1648154435.620306234]:  * Wide Lines: yes
[ INFO] [1648154435.620329404]:  * Hardware Gamma: yes
[ INFO] [1648154435.620355369]:  * PBuffer support: yes
[ INFO] [1648154435.620451576]:  * Vertex Array Objects: no
[ INFO] [1648154435.620565453]:  * Separate shader objects: no
[ INFO] [1648154435.620604070]:    - redeclare GLSL interface block: no
[ INFO] [1648154435.620638330]:  * Debugging/ profiling events: no
[ INFO] [1648154435.620669474]:  * Map buffer storage: yes

full startup log: https://gist.github.com/simonschmeisser/aad15e2e91e05260d4e49cccacf4219e

Upon receiving a point cloud which is supposed to be rendered using the box geometry shader I get this:

[DEBUG] [1648154849.874271692]: MessageFilter [target=map ]: Added message in frame map at time 1648154849,852, count now 0
[ WARN] [1648154849.906164763]: Warning: material PointCloudMaterial0Square has no supportable Techniques and will be blank. Explanation: 
Pass 0: geometry program rviz/glsl150/billboard.geom cannot be used - not supported.                                                                                                                                                                                          
Pass 0: geometry program rviz/glsl150/billboard.geom(with_depth) cannot be used - not supported.                                                                                                                                                                              
Pass 0: geometry program rviz/glsl150/billboard.geom cannot be used - not supported.                                                                                                                                                                                          
Pass 0: geometry program rviz/glsl150/billboard.geom cannot be used - not supported.                                                                                                                                                                                          

[ WARN] [1648154849.906294385]: Warning: material PointCloudMaterial0FlatSquare has no supportable Techniques and will be blank. Explanation: 
Pass 0: geometry program rviz/glsl150/billboard.geom cannot be used - not supported.                                                                                                                                                                                          
Pass 0: geometry program rviz/glsl150/billboard.geom(with_depth) cannot be used - not supported.                                                                                                                                                                              
Pass 0: geometry program rviz/glsl150/billboard.geom cannot be used - not supported.                                                                                                                                                                                          
Pass 0: geometry program rviz/glsl150/billboard.geom cannot be used - not supported.                                                                                                                                                                                          

[ WARN] [1648154849.906380960]: Warning: material PointCloudMaterial0Sphere has no supportable Techniques and will be blank. Explanation: 
Pass 0: geometry program rviz/glsl150/billboard.geom cannot be used - not supported.                                                                                                                                                                                          
Pass 0: geometry program rviz/glsl150/billboard.geom(with_depth) cannot be used - not supported.                                                                                                                                                                              
Pass 0: geometry program rviz/glsl150/billboard.geom cannot be used - not supported.                                                                                                                                                                                          
Pass 0: geometry program rviz/glsl150/billboard.geom cannot be used - not supported.                                                                                                                                                                                          

[ WARN] [1648154849.906523328]: Warning: material PointCloudMaterial0Box has no supportable Techniques and will be blank. Explanation: 
Pass 0: geometry program rviz/glsl150/box.geom(with_lighting) cannot be used - not supported.                                                                                                                                                                                 
Pass 0: geometry program rviz/glsl150/box.geom(with_depth) cannot be used - not supported.                                                                                                                                                                                    
Pass 0: geometry program rviz/glsl150/box.geom cannot be used - not supported.                                                                                                                                                                                                
Pass 0: geometry program rviz/glsl150/box.geom cannot be used - not supported.                                                                                                                                                                                                

[ERROR] [1648154849.906624703]: No techniques available for material [PointCloudMaterial0Sphere]
[ERROR] [1648154849.906803995]: No techniques available for material [PointCloudMaterial0Box]

@rhaschke
Copy link
Contributor Author

Indeed it is strange that max. glsl120 is listed:

[ INFO] [1648154435.619190119]: * Supported Shader Profiles: arbfp1 arbvp1 glsl glsl100 glsl110 glsl120 ps_1_1 ps_1_2 ps_1_3 ps_1_4

However, for me (with an Intel UHD Graphics, CML GT2) only glsl is listed and non-rviz GP shaders work.

@paroj
Copy link

paroj commented Mar 24, 2022

The legacy GL RenderSystem checks for EXT_geometry_shader4 to enable geometry shaders
https://github.com/OGRECave/ogre/blob/v1.12.13/RenderSystems/GL/src/OgreGLRenderSystem.cpp#L551-L552

unfortunately that variant is quite different than what got into GL3.2 and your GPU driver probably did not bother implementing the EXT variant.

The legacy GL RenderSystem main goal is to provide fixed-function support. As such it merely targets max GL2. It does not advertise glsl > 120, as it is often used to filter out shaders targeting GL3+, like:
https://github.com/OGRECave/ogre/blob/be8c2a225ecae636c8e669a12129b603db6b0e3c/Samples/Media/materials/scripts/ParticleGS.material#L85

If the implemented GL compatibility profile is GL3.2+, you can use the standard geometry shaders as you currently do.

Pass 0: geometry program rviz/glsl150/billboard.geom cannot be used - not supported.

this is to be expected then

@simonschmeisser
Copy link
Contributor

Enabling the GL3+ backend is one of my long term goals, but is there a short term solution? I'm unfortunately not able to come up with the next step from your detailed answer (thanks for that!)

@paroj
Copy link

paroj commented Mar 24, 2022

@simonschmeisser
Copy link
Contributor

simonschmeisser commented Mar 24, 2022

We (as in the ROS community, not as in my day job) are unfortunately stuck with a released ancient version of 1.9, so we would basically need to find a way to hack this into the RenderSystemCapabilities after they have been discovered. But I'll build a patched version to test tomorrow.

Sounds like enabling GL3+ would be the easier way after all. I think I got stuck on the shader changes last time I tried but we should have those available with this PR now

@paroj
Copy link

paroj commented Mar 24, 2022

so we would basically need to find a way to hack this

you should be able to do this using
https://ogrecave.github.io/ogre/api/latest/class_ogre_1_1_render_system.html#ab0aa0cedf1898f8cc70e290703b428c7
after you check https://ogrecave.github.io/ogre/api/latest/class_ogre_1_1_render_system_capabilities.html#a8fd951ef5aa2b48b18ca65419cfb2c46

Sounds like enabling GL3+ would be the easier way after all

I am afraid GL3+ is not in a good shape in 1.9 either..

@simonschmeisser
Copy link
Contributor

That sounds very doable, I'll try to implement that. Thanks!

Meanwhile one the patched 1.12.13 I get the following further parsing errors which suggest that we need to fix some more shaders:

[ INFO] [1648194064.589809384]: Parsing script glsl150.program
[ERROR] [1648194064.592568485]: Program 'rviz/glsl150/billboard.geom' is not supported: 'billboard.geom' 0:25(3): error: redeclaration of gl_PerVertex must be a subset of the built-in members of gl_PerVertex
0:27(1): error: identifier `gl_TexCoord' uses reserved `gl_' prefix                                                                                                                                                                                                           
0:38(2): error: `gl_FrontColor' undeclared                                                                                                                                                                                                                                    
0:38(2): error: value of type vec4 cannot be assigned to variable of type error                                                                                                                                                                                               

[ERROR] [1648194064.593092938]: Error: ScriptCompiler - invalid parameters in glsl150.program(11): Named constants have not been initialised, perhaps a compile error
[ERROR] [1648194064.593152603]: Error: ScriptCompiler - invalid parameters in glsl150.program(12): Named constants have not been initialised, perhaps a compile error
[ERROR] [1648194064.593200935]: Error: ScriptCompiler - invalid parameters in glsl150.program(13): Named constants have not been initialised, perhaps a compile error
[ERROR] [1648194064.593281920]: Error: ScriptCompiler - invalid parameters in glsl150.program(14): Named constants have not been initialised, perhaps a compile error
[ERROR] [1648194064.594482688]: Program 'rviz/glsl150/billboard.geom(with_depth)' is not supported: 'billboard.geom' 0:25(3): error: redeclaration of gl_PerVertex must be a subset of the built-in members of gl_PerVertex
0:27(1): error: identifier `gl_TexCoord' uses reserved `gl_' prefix                                                                                                                                                                                                           
0:38(2): error: `gl_FrontColor' undeclared                                                                                                                                                                                                                                    
0:38(2): error: value of type vec4 cannot be assigned to variable of type error                                                                                                                                                                                               

[ERROR] [1648194064.594630421]: Error: ScriptCompiler - invalid parameters in glsl150.program(26): Named constants have not been initialised, perhaps a compile error
[ERROR] [1648194064.594689214]: Error: ScriptCompiler - invalid parameters in glsl150.program(27): Named constants have not been initialised, perhaps a compile error
[ERROR] [1648194064.594740492]: Error: ScriptCompiler - invalid parameters in glsl150.program(28): Named constants have not been initialised, perhaps a compile error
[ERROR] [1648194064.594785548]: Error: ScriptCompiler - invalid parameters in glsl150.program(29): Named constants have not been initialised, perhaps a compile error
[ERROR] [1648194064.594831766]: Error: ScriptCompiler - invalid parameters in glsl150.program(30): Named constants have not been initialised, perhaps a compile error

I opened rhaschke#3 for that but now it still crashes once it tries to use the shader

@simonschmeisser

This comment was marked as outdated.

@paroj

This comment was marked as outdated.

@simonschmeisser
Copy link
Contributor

sorry, new try:

#0  0x0000000000000000 in ?? ()
#1  0x00007f857c07e228 in Ogre::GLSL::GLSLLinkProgram::compileAndLink (this=0x562f9c232390) at ./RenderSystems/GL/src/GLSL/src/OgreGLSLLinkProgram.cpp:43
#2  0x00007f857c07ddd4 in Ogre::GLSL::GLSLLinkProgram::activate (this=0x562f9c232390) at ./RenderSystems/GL/src/GLSL/src/OgreGLSLLinkProgram.cpp:119
#3  0x00007f857c07f30e in Ogre::GLSL::GLSLLinkProgramManager::getActiveLinkProgram (this=0x562f9b603670) at ./RenderSystems/GL/src/GLSL/src/OgreGLSLLinkProgramManager.cpp:94
#4  0x00007f857c0808a1 in Ogre::GLSL::GLSLProgram::bindProgramParameters (this=0x562f9bb9fbd0, params=..., mask=<optimized out>) at ./RenderSystems/GL/src/GLSL/src/OgreGLSLProgram.cpp:393
#5  0x00007f857c0b635c in Ogre::GLRenderSystem::bindGpuProgramParameters (this=this@entry=0x562f9b280740, gptype=gptype@entry=Ogre::GPT_VERTEX_PROGRAM, params=..., mask=mask@entry=65535) at /usr/include/c++/9/ext/atomicity.h:96
#6  0x00007f85a1617ad9 in Ogre::SceneManager::updateGpuProgramParameters (this=this@entry=0x562f9bd2eb50, pass=pass@entry=0x562f9c206980) at ./OgreMain/src/OgreSceneManager.cpp:4053
#7  0x00007f85a1617b30 in Ogre::SceneManager::_issueRenderOp (this=this@entry=0x562f9bd2eb50, rend=rend@entry=0x562f9bc7ae98, pass=pass@entry=0x562f9c206980) at ./OgreMain/src/OgreSceneManager.cpp:4073
#8  0x00007f85a1622330 in Ogre::SceneManager::issueRenderWithLights (this=0x562f9bd2eb50, rend=0x562f9bc7ae98, pass=0x562f9c206980, pLightListToUse=<optimized out>, lightScissoringClipping=<optimized out>) at ./OgreMain/src/OgreSceneManager.cpp:1925
#9  0x00007f85a16227e7 in Ogre::SceneManager::renderSingleObject (this=0x562f9bd2eb50, rend=rend@entry=0x562f9bc7ae98, pass=0x562f9c206980, lightScissoringClipping=true, doLightIteration=<optimized out>, manualLightList=<optimized out>)
    at ./OgreMain/src/OgreSceneManager.cpp:2204
#10 0x00007f85a1623045 in Ogre::SceneManager::SceneMgrQueuedRenderableVisitor::visit (rs=..., p=<optimized out>, this=0x562f9bd2f350) at ./OgreMain/src/OgreSceneManager.cpp:1725
#11 Ogre::SceneManager::SceneMgrQueuedRenderableVisitor::visit (this=0x562f9bd2f350, p=<optimized out>, rs=...) at ./OgreMain/src/OgreSceneManager.cpp:1709
#12 0x00007f85a15cfffb in Ogre::QueuedRenderableCollection::acceptVisitorGrouped (this=0x562f9bfd9c90, visitor=0x562f9bd2f350) at ./OgreMain/src/OgreRenderQueueSortingGrouping.cpp:411
#13 0x00007f85a15d010c in Ogre::QueuedRenderableCollection::acceptVisitor (this=this@entry=0x562f9bfd9c90, visitor=<optimized out>, om=<optimized out>, om@entry=Ogre::QueuedRenderableCollection::OM_PASS_GROUP) at ./OgreMain/src/OgreRenderQueueSortingGrouping.cpp:389
#14 0x00007f85a1615649 in Ogre::SceneManager::renderObjects (this=this@entry=0x562f9bd2eb50, objs=..., om=om@entry=Ogre::QueuedRenderableCollection::OM_PASS_GROUP, lightScissoringClipping=lightScissoringClipping@entry=true, 
    doLightIteration=doLightIteration@entry=true, manualLightList=manualLightList@entry=0x0, transparentShadowCastersMode=false) at ./OgreMain/src/OgreSceneManager.cpp:1814
#15 0x00007f85a16156bf in Ogre::SceneManager::renderBasicQueueGroupObjects (this=0x562f9bd2eb50, pGroup=0x562f9bfdfde0, om=Ogre::QueuedRenderableCollection::OM_PASS_GROUP) at ./OgreMain/include/OgreRenderQueueSortingGrouping.h:357
#16 0x00007f85a1615d60 in Ogre::SceneManager::renderVisibleObjectsDefaultSequence (this=this@entry=0x562f9bd2eb50) at ./OgreMain/src/OgreSceneManager.cpp:1686
#17 0x00007f85a1615deb in Ogre::SceneManager::_renderVisibleObjects (this=this@entry=0x562f9bd2eb50) at ./OgreMain/src/OgreSceneManager.cpp:1603
#18 0x00007f85a161cdce in Ogre::SceneManager::_renderScene (this=0x562f9bd2eb50, camera=0x562f9bdd75b0, vp=<optimized out>, includeOverlays=<optimized out>) at ./OgreMain/src/OgreSceneManager.cpp:1366
#19 0x00007f85a14ad700 in Ogre::Camera::_renderScene (this=0x562f9bdd75b0, vp=0x562f9bccdc60) at ./OgreMain/src/OgreCamera.cpp:496
#20 0x00007f85a16cbab5 in Ogre::Viewport::update (this=this@entry=0x562f9bccdc60) at ./OgreMain/src/OgreViewport.cpp:218
#21 0x00007f85a15eb4a5 in Ogre::RenderTarget::_updateViewport (this=0x562f9b639cc0, viewport=0x562f9bccdc60, updateStatistics=<optimized out>) at ./OgreMain/src/OgreRenderTarget.cpp:203
--Type <RET> for more, q to quit, c to continue without paging--
#22 0x00007f85a15eb252 in Ogre::RenderTarget::_updateAutoUpdatedViewports (this=0x562f9b639cc0, updateStatistics=true) at ./OgreMain/src/OgreRenderTarget.cpp:181
#23 0x00007f85a15eb083 in Ogre::RenderTarget::updateImpl (this=0x562f9b639cc0) at ./OgreMain/src/OgreRenderTarget.cpp:158
#24 0x00007f85a15eb848 in Ogre::RenderTarget::update (this=0x562f9b639cc0, swap=<optimized out>) at ./OgreMain/src/OgreRenderTarget.cpp:565
#25 0x00007f85a15d372f in Ogre::RenderSystem::_updateAllRenderTargets (this=0x562f9b280740, swapBuffers=false) at ./OgreMain/src/OgreRenderSystem.cpp:265
#26 0x00007f85a160b3da in Ogre::Root::_updateAllRenderTargets (this=this@entry=0x562f9af66810) at ./OgreMain/src/OgreRoot.cpp:1296
#27 0x00007f85a160b4c0 in Ogre::Root::renderOneFrame (this=0x562f9af66810) at ./OgreMain/src/OgreRoot.cpp:868
#28 Ogre::Root::renderOneFrame (this=0x562f9af66810) at ./OgreMain/src/OgreRoot.cpp:863
#29 0x00007f85a465319f in rviz::VisualizationManager::onUpdate() () from /home/sis/experimente/rviz_ogre1.12/devel/lib/librviz.so
#30 0x00007f85a44fdd74 in rviz::VisualizationManager::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) () from /home/sis/experimente/rviz_ogre1.12/devel/lib/librviz.so
#31 0x00007f85a38971d0 in QMetaObject::activate (sender=0x562f9bd4f4b0, signalOffset=<optimized out>, local_signal_index=<optimized out>, argv=<optimized out>) at kernel/qobject.cpp:3804
#32 0x00007f85a38a43ee in QTimer::timeout (this=<optimized out>, _t1=...) at .moc/moc_qtimer.cpp:204
#33 0x00007f85a3897bc5 in QObject::event (this=0x562f9bd4f4b0, e=<optimized out>) at kernel/qobject.cpp:1283
#34 0x00007f85a3c98a66 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#35 0x00007f85a3ca20f0 in QApplication::notify(QObject*, QEvent*) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#36 0x00007f85a386b80a in QCoreApplication::notifyInternal2 (receiver=0x562f9bd4f4b0, event=0x7ffee9be3920) at ../../include/QtCore/../../src/corelib/kernel/qobject.h:142
#37 0x00007f85a38c2780 in QTimerInfoList::activateTimers (this=0x562f9a9f0730) at kernel/qtimerinfo_unix.cpp:643
#38 0x00007f85a38c306c in timerSourceDispatch (source=<optimized out>) at kernel/qeventdispatcher_glib.cpp:182
#39 0x00007f85a0ba117d in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#40 0x00007f85a0ba1400 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#41 0x00007f85a0ba14a3 in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#42 0x00007f85a38c3435 in QEventDispatcherGlib::processEvents (this=0x562f9aa624c0, flags=...) at kernel/qeventdispatcher_glib.cpp:422
#43 0x00007f85a386a3ab in QEventLoop::exec (this=this@entry=0x7ffee9be3b60, flags=..., flags@entry=...) at ../../include/QtCore/../../src/corelib/global/qflags.h:140
#44 0x00007f85a3872116 in QCoreApplication::exec () at ../../include/QtCore/../../src/corelib/global/qflags.h:120
#45 0x0000562f98e786e5 in main ()

@paroj
Copy link

paroj commented Mar 25, 2022

it says it crashes here: https://github.com/OGRECave/ogre/blob/v1.12.13/RenderSystems/GL/src/GLSL/src/OgreGLSLLinkProgram.cpp#L43

my best guess would be, that this method got inlined and the actual problem is that glProgramParameteriEXT is NULL, as it is part of EXT_geometry_shader4, which your driver does not support.

Try commenting out the glProgramParameteriEXT calls - they are not needed with GL3.2 style shaders.

@rhaschke
Copy link
Contributor Author

rhaschke commented Mar 26, 2022

Disabling all calls to glProgramParameteriEXT() indeed fixes the segfault on my Intel GPU and all shaders work as expected with this PR!
@paroj, do you have an idea why those functions are NULL for the Mesa driver, but not the NVIDIA driver?
As far as I understand, EXT_geometry_shader4 is obsolete in GLSL 1.5 as GPs became part of the core. So, shouldn't it be NULL for both drivers?

@simonschmeisser, I would expect that this works on AMD Renoir as well. Essentially, they use the same Mesa driver, don't they? Regarding Ogre, I cannot see a difference: For my Intel GPU, Ogre reports that the RSC_GEOMETRY_PROGRAM capability is not available as well:
[ INFO] ros.rviz: * Geometry programs: no
Nevertheless, it works!

Is there any chance to get this running with existing binary releases of OGRE 1.9.0, e.g. by setting some RenderSystem flags?

@rhaschke rhaschke marked this pull request as ready for review March 26, 2022 01:31
@rhaschke rhaschke marked this pull request as draft March 26, 2022 10:24
@rhaschke
Copy link
Contributor Author

rhaschke commented Mar 26, 2022

Open TODOs:

- Drop compatibility mode, which is not supported by Mesa
- Don't use gl_ prefixes for user-declared variables
- Don't redeclare gl_PerVertex
@paroj
Copy link

paroj commented Mar 26, 2022

I switched to GL3Plus rendering system and I now see white objects moving!

note, that with GL3+, you can use RenderDoc to debug stuff

do you have an idea why those functions are NULL for the Mesa driver, but not the NVIDIA driver?

NVIDIA implements EXT_geometry_shader4, but Mesa does not.

Is there any chance to get this running with existing binary releases of OGRE 1.9.0

no

applied the changes from this discussion to Ogre 13.3 OGRECave/ogre#2417

@rhaschke
Copy link
Contributor Author

Thanks for this fix, @paroj!
Can we backport this to some Ogre version that is released into Ubuntu 20.04, i.e. 1.12?
@simonschmeisser, are you still in charge of the release process?
I am still puzzled why GPs actually did work in Ogre 1.9 although the capability was not set. (I just disabled glProgramParameteriEXT but I did not enable the GP capability.)

@paroj
Copy link

paroj commented Mar 26, 2022

Can we backport this to some Ogre version that is released into Ubuntu 20.04, i.e. 1.12?

yes

I am still puzzled why GPs actually did work in Ogre 1.9 although the capability was not set.

the respective check was only added in Ogre 1.10

@simonschmeisser
Copy link
Contributor

Can we backport this to some Ogre version that is released into Ubuntu 20.04, i.e. 1.12?
@simonschmeisser, are you still in charge of the release process?

"In charge" is too strong, I don't have any Debian or Ubuntu privileges, I just updated the packages and try to get them uploaded into Debian from where they are snapshoted for Ubuntu.

Getting a patch into 20.04 for 1.12 might work or it might fail (fail means no reaction from anybody ever). But would it help? ROS Noetic sticks to 1.9 so we would need to patch that right? For 1.12 and newer we could also switch to GL3+ rendering system to circumvent the issue.

@rhaschke
Copy link
Contributor Author

ROS Noetic sticks to 1.9 so we would need to patch that right?

That's true. Do you see any chance to do so?

For 1.12 and newer we could also switch to GL3+ rendering system to circumvent the issue.

Where do you see the benefit of switching to GL 3+? This will exclude older hardware, right?

@simonschmeisser
Copy link
Contributor

Where do you see the benefit of switching to GL 3+?

Well it detects and uses the newer GS correctly so it doesn't need any patching.

This will exclude older hardware, right?

GL rendering system without GS would still be available as a fallback but I also don't think much of that old hardware is still alive. It's more a question of drivers (mobile/embedded) but I think even the "weaker" ones should be sufficient.

@simonschmeisser
Copy link
Contributor

We would need to slightly adapt the patch by @paroj because GLEW was used in 1.9 to check for extensions instead of GLAD. Then we should have no problems getting this into Debian unstable. Maybe we can even get Ubuntu to pull the patched version into 22.04 (freeze exception etc). Then we can open a bug with a patch/debdiff for stable releases like 20.04. Maybe we can also do those things in parallel. Maybe we should also open a debian bug. @jspricke does that sound reasonable?

@peci1
Copy link
Contributor

peci1 commented Mar 27, 2022

Thanks everybody for working on a fix for this! If you need me to test something on AMD Renoir, I can be of help (both Noetic and Melodic).

@simonschmeisser
Copy link
Contributor

One of my colleagues has the amdgpu driver running on 18.04 with mesa 20.3 and encounters the same crashes on Ogre 1.9 due to EXT_geometry_shader4 not being available but also not being checked. (It's a RENOIR just like mine).

I'll try backporting OGRECave/ogre#2417 to 1.9 tomorrow

@simonschmeisser
Copy link
Contributor

I uploaded a fixed version of ogre-1.9 for focal to my ubuntu PPA: https://launchpad.net/~s-schmeisser/+archive/ubuntu/ogre-1.9-focal seems to work well with this branch on AMD Renoir but please confirm. I can then try filing bug reports and patches

@peci1
Copy link
Contributor

peci1 commented Apr 5, 2022

@simonschmeisser I've tried your OGRE 1.9 build on 18.04 (from the bionic PPA) and it did not help.

@peci1
Copy link
Contributor

peci1 commented Apr 5, 2022

Ah, my bad, I didn't have this PR in the tested Melodic rviz. I cherry-picked all the commits and it works now!

@peci1
Copy link
Contributor

peci1 commented Apr 5, 2022

I also tested a more complicated scene with robot model comprised of both primitive shapes and meshes. Everything seems to work!
rviz_screenshot_2022_04_05-03_18_17

@simonschmeisser
Copy link
Contributor

@simonschmeisser I've tried your OGRE 1.9 build on 18.04 (from the bionic PPA) and it did not help.

Did it still crash or did you still see white points only? There seem to be multiple levels of problems around ...

I tested the modified ogre-1.9 on nvidia yesterday and will now start trying to get this fix into Debian/Ubuntu

@simonschmeisser
Copy link
Contributor

@jspricke
Copy link
Contributor

jspricke commented Apr 6, 2022

The process for Debian is detailed here:
https://lists.debian.org/debian-devel-announce/2019/08/msg00000.html
and for Ubuntu here:
https://wiki.ubuntu.com/StableReleaseUpdates

I think this needs analysis: what will change for existing users?, could it break current setups/workarounds?..
Once that is done I could help with the Debian update, though I guess the Ubuntu one is more important.

@peci1
Copy link
Contributor

peci1 commented Apr 6, 2022

@simonschmeisser I've tried your OGRE 1.9 build on 18.04 (from the bionic PPA) and it did not help.

Did it still crash or did you still see white points only? There seem to be multiple levels of problems around ...

I tested the modified ogre-1.9 on nvidia yesterday and will now start trying to get this fix into Debian/Ubuntu

First, I had updated OGRE and not pulled the changes from this PR. The result was that rviz ran but had the same bug with white/gray dots.

Then I reverted OGRE to the stock version and installed the rviz update from this PR. That resulted in a hang of rviz on startup (I was directly launching a config for the pointcloud test, so not sure if that would happen with empty rviz). And it was a hang and not a crash.

Finally, with both OGRE and rviz patched, it works as a charm.

So it seems the rviz fix release definitely needs to wait for the OGRE release. Or it needs to be somehow better protected for the case OGRE is not patched.

@simonschmeisser
Copy link
Contributor

I tested this again today on a patched 1.12.13 (will test with 13.6.4 later):
no crashes but unfortunately it's not perfect either:

  • octomap from PlanningSceneDisplay: without color, all dark grey
  • PointCloud2:
    • Flat Squares: nothing displayed at all
    • Points: works as expected, including colors (axis color)
    • Squares: nothing
    • Spheres: nothing
    • Boxes: dark grey

The log of rviz -l is unfortunately not very informative:

https://gist.github.com/simonschmeisser/524366304851f6fb70d7102b1e153b57

@simonschmeisser
Copy link
Contributor

I tested with ogre 13.6.4 which unfortunately shows grey blocks as well. It's still WIP but I'll open a PR for compatibility of course

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

Successfully merging this pull request may close these issues.

5 participants