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 different GLSL versions #168

Closed
revmischa opened this issue Mar 3, 2019 · 26 comments
Closed

Support different GLSL versions #168

revmischa opened this issue Mar 3, 2019 · 26 comments

Comments

@revmischa
Copy link
Collaborator

revmischa commented Mar 3, 2019

Problem: different systems and drivers have support for different versions of GLSL. ProjectM will not run unless the shader language matches the supported driver version.

As an example, my raspberry pi outputs:

INFO: GL_VERSION: OpenGL ES 2.0 Mesa 13.0.6
INFO: GL_SHADING_LANGUAGE_VERSION: OpenGL ES GLSL ES 1.0.16
INFO: GL_VENDOR: Broadcom
Failed to compile shader 'Vertex: v2f_c4f'. Error: 0:2(1): error: syntax error, unexpected NEW_IDENTIFIER
Failed to compile shader 'Fragment: v2f_c4f'. Error: 0:3(1): error: `in' qualifier in declaration of `fragment_color' only valid for function parameters in GLSL ES 1.00
0:4(1): error: `out' qualifier in declaration of `color' only valid for function parameters in GLSL ES 1.00

And @servimo reports the error:
error: GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, and 3.00 ES
And again in #101

How can we support multiple versions of GLSL, ES and non-ES?

Also important: detect if GLES is needed automatically in configure.ac so that users don't have to do --enable-gles manually. A decent number of issues on here are related to people not specifying that they need GLES.

More info: #115 #101

@deltaoscarmike could really use your help here

@champagj
Copy link

champagj commented Mar 3, 2019

Thank you @revmischa for the new thread.

Trying to run ProjectM on pi 3 and finding it difficult with my limited programming skills.. Back to linux after many years.

Looks like it may be possible to run via QT but also difficult to install/config to run ProjectM.

If you need an "intermediate" tester, I'm here.

@peak3d
Copy link
Contributor

peak3d commented Mar 3, 2019

@revmischa gl version is usuallly detected during runtime and not compile time.
But for my GLSL 100 (GLES 2.0) devices there are more changes in shaders needed to get it working

The easiest thing is the version ( 5 minutes work) and the in / out (what is not supported by GLSL 100)
Mor interesting are the layout statements (IIRC) which are not part of GLSL 100

@revmischa
Copy link
Collaborator Author

Yes, i agree it would be great if it could detect the right shader code to load at runtime rather than compile time.

@sergiomb2
Copy link
Contributor

can we run applications without GLSL ? and lib to use in other apps need "compile shader" ?
or can we build projectM without GLSL ?

Thanks

@revmischa
Copy link
Collaborator Author

GLSL is pretty integral now, so you can't build without it.
There is just a quite small amount of work that someone who knows what they are doing needs to do to make the default shaders compile on different GLSL versions.

@sergiomb2
Copy link
Contributor

sergiomb2 commented Mar 15, 2019

OK thanks for clarify and about projectM as lib (libprojectM)? libprojectM need GSSL support (GLSL 3.30) ? or apps that use libprojectM render itself ? apps like kodi, clementine or VLC .

@sergiomb2
Copy link
Contributor

Hi,
I have a report saying that libprojectM plugin for kodi is working
"I can confirm that 3.1.1 rc3 works with the latest Kodi projectM visualization plugin 2.2.0" [1]

Thanks,

[1]
https://bugzilla.redhat.com/show_bug.cgi?id=1685314#c2

@ghost
Copy link

ghost commented Mar 25, 2019

Is it possible to support OpenGL ES GLSL ES 1.00?
image

@revmischa
Copy link
Collaborator Author

Probably?

@ghost
Copy link

ghost commented Mar 26, 2019

The sdl projectm builds into a binary linked with opengles, but when executed I see the error messages above. “Unsupported shader version”. Any thoughts?

@ghost
Copy link

ghost commented Mar 27, 2019

I am guessing that the unsupported shader version is due to my system, which only supports GLSL #version 100 (#define GLSL_VERSION "300 es" doesn't operate) I noticed that the ver and frag sources contain references to layout, in/out, ect that are not supported by GLSL ES 1.00? Are there any plans to support the older spec (raspberry pi, ect) ?

https://github.com/mattdesl/lwjgl-basics/wiki/GLSL-Versions

@revmischa
Copy link
Collaborator Author

It's totally possible I think to support multiple GLSL versions. I don't know how far back it can go. Partly it depends on the HLSL->GLSL transpiler which may emit code that depends on a certain version. Some small amount of coding needs to be done. I don't know what to do, @deltaoscarmike may know, someone else surely does.

@ghost
Copy link

ghost commented Mar 28, 2019 via email

@deltaoscarmike
Copy link
Collaborator

Converting to GLSL 1.0 / Opengl ES 2 is not trivial, it requires to:

  • remove "layout(location = x)" shader directives and fetch attributes location with glGetAttribLocation
  • replace shader keywords: "in" becomes "attribute" and "out" becomes "varying" (roughly)
  • replace texture samplers (glGenSamplers not implemented in opengl es 2) with texture copy. Or alternatively simplify texture wrap and filter parameters handling (eg: parameters are overwritten thus only last ones are applied)
  • replace VAO's (not implemented in opengl es 2) but only one is required for opengl 3. Or alternatively use OES_vertex_array_object extension
  • replace 3D noise textures with a combination of a flat 3D textures and a shader function to access it. Or alternatively use OES_texture_3D extension

Extensions usage will reduce hardware compatibility but these are available on raspberry pi.

@mancoast Windows headers expose only opengl 1.1 api, but graphics drivers may support newer versions. glad allows to circumvent windows limitation.

@lgbaldoni
Copy link
Contributor

@deltaoscarmike what about GLSL 3.30?

@PeterMalkin PeterMalkin mentioned this issue Apr 9, 2019
@sergiomb2
Copy link
Contributor

Hi,
I followed a tip from Stellarium/stellarium#663 , which is run :

MESA_GLSL_VERSION_OVERRIDE=130 /usr/bin/projectM-pulseaudio

but still saying Failed to compile shader 'Vertex: v2f_c4f'. Error: 0:1(10): error: GLSL ES 3.00 is not supported. Supported versions are: 1.10, 1.20, 1.30, and 1.00 ES

but surprisingly my default glxinfo says:

OpenGL version string: 2.1 Mesa 18.0.5
OpenGL shading language version string: 1.20
OpenGL ES profile version string: OpenGL ES 2.0 Mesa 18.0.5
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 1.0.16

@ghost
Copy link

ghost commented Apr 11, 2019 via email

@sergiomb2
Copy link
Contributor

ah! I misread the error, my video card just have low GLSL (shadow languague) 1.10, 1.20, 1.30, and 1.00 ES when it is required GLSL ES 3.00 ...
Hum let me check in a computer in better video card .
Thanks.
Thanks,

@sergiomb2
Copy link
Contributor

ah! I misread the error, my video card just have low GLSL (shadow language) 1.10, 1.20, 1.30, and 1.00 ES when it is required GLSL ES 3.00 ...
Hum let me check in a computer in better video card .

Ya , with one video card that supports OpenGL ES 3.0., it works. So maybe, at least, if we can check OpenGL ES version and if < 3, popup one warning that will fail runs the apps ... and we need at least OpenGL ES 3.0

Thanks

@ghost ghost added this to the 3.1.2 milestone May 31, 2019
@anoadragon453
Copy link

anoadragon453 commented Feb 25, 2020

I'm running a card that supports up to GLSL 3.20. Any chance we could make this only slightly older version work?

➜  ~ glxinfo | grep -i "version"
server glx version string: 1.4
client glx version string: 1.4
GLX version: 1.4
    Version: 18.3.6
    Max core profile version: 4.5
    Max compat profile version: 3.0
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.2
OpenGL core profile version string: 4.5 (Core Profile) Mesa 18.3.6
OpenGL core profile shading language version string: 4.50
OpenGL version string: 3.0 Mesa 18.3.6
OpenGL shading language version string: 1.30
OpenGL ES profile version string: OpenGL ES 3.2 Mesa 18.3.6
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
➜  ~ projectM-pulseaudio                   
Default config: /usr/local/share/projectM/config.inp
reading /home/user/.projectM/config.inp 
[projectM] config file: /home/user/.projectM/config.inp
Failed to compile shader 'Vertex: v2f_c4f'. Error: 0:1(10): error: GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, 3.00 ES, 3.10 ES, and 3.20 ES

Failed to compile shader 'Fragment: v2f_c4f'. Error: 0:1(10): error: GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, 3.00 ES, 3.10 ES, and 3.20 ES

Failed to link program: error: linking with uncompiled/unspecialized shadererror: linking with uncompiled/unspecialized shader
Failed to compile shader 'Vertex: v2f_c4f_t2f'. Error: 0:1(10): error: GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, 3.00 ES, 3.10 ES, and 3.20 ES

Failed to compile shader 'Fragment: v2f_c4f_t2f'. Error: 0:1(10): error: GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, 3.00 ES, 3.10 ES, and 3.20 ES

Compiled with ./configure --enable-qt --enable--gles or ./configure --enable-qt. No difference.

@fughilli
Copy link
Collaborator

I modified ShaderEngine.cpp to rewrite the shaders in such a way that they can be compiled for GLSL 1.20 and successfully ran an SDL-based libprojectm wrapper with these modifications on a Raspberry Pi 3 with VideoCore IV. My modifications are in this repo if anyone is interested in trying them out. I can also put together a PR for this repo.

@swrobel
Copy link

swrobel commented Aug 4, 2020

@fughilli any luck getting this into a PR?

@fughilli
Copy link
Collaborator

fughilli commented Aug 5, 2020

@fughilli any luck getting this into a PR?

Tada! #399

I got sidetracked working on overhauling the HLSL->GLSL translation and shader compilation to support async compilation, since that's currently the major blocker to getting nice smooth performance on SBCs like the Raspberry Pi. Blocking the render thread on translation/compilation is maybe acceptable on desktop/laptop hardware, but is a complete show-stopper for underpowered CPUs.

If anyone has spare cycles for that, I can share some more details, perhaps in a different feature request.

@revmischa
Copy link
Collaborator Author

Yeah blocking on shader compilation is a real issue, even on desktop

@fughilli
Copy link
Collaborator

fughilli commented Sep 2, 2020

Just merged the backported shader implementations. Without the async fixes, preset transitions are still painfully slow in some cases on my RPi 3a+. I'm working on getting those fixes rolled up, you can follow along on #402.

@kblaschke
Copy link
Member

Currently, GLES 3.0 shaders and OpenGL shader language level 3.0 are supported. There's no real way to support lower GLSL levels as they lack texture samplers, and going higher would probably require a rewrite of the HLSL transpiler due to a different syntax for uniforms in the latest shader language levels.

I'm going to close this ticket for now. If there's any specific problem with the shader versions, please open a new issue and provide examples.

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

10 participants