Integrate Aras P's GLSL Optimizer / Metal translator library

https://github.com/aras-p/glsl-optimizer

This library is able to optimise GLSL code on the CPU, into better GLSL or even Metal Shaders. Could be very useful to get the most power out of Vuo & possibly in any new dedicated Shader Node.

I’ve opened this feature request for community voting.

I tested GLSL Optimizer several months ago on one of Vuo’s toughest shaders (Shade with Frosted Glass / Frost Image) — it didn’t make a measurable performance improvement on that shader on the GPUs I tried. But maybe it could help with other shaders and other GPUs.

The thing that would make GLSL most usable, for me, would be to have a debugger in the editor. Or a built in editor at all (besides the “ShaderToy” node).

FWIW, I’ve had some OK results using shader minifier over the years. Often no difference, but sometimes there is some improvement.

http://ctrl-alt-test.fr/minifier/index

@George_Toledo

Great find with minifier! I should run a few of mine through it and see what happens!

There is a library that does validation and syntax highlighting in github- last time I saw it it was MIT and in c++. May help… I’ll see if I can find it again.

Found it: https://github.com/degarashi/GLSLChecker

And it’s MIT as well. Could be useful?
!

Thanks for the suggestions on tools to optimize GLSL code. I want to let you know that we looked into each of them, but none panned out.

We tested Aras P’s GLSL Optimizer on more of Vuo’s GLSL code to see if it would do any better than it did for the frosted glass shader (no improvement). For the noise image shader, the optimizer ended up doing the opposite of what it was intended to. The code ended up 2.5x larger and ran a bit slower. On one GPU it caused the whole system to hang. Looking into the status of GLSL Optimizer, we found that it only supports GLSL 1.20 (OpenGL 2.1), which will be a problem when Vuo moves to GLSL 1.50 (OpenGL 3.2), and Aras P has recently abandoned the project.

We checked out ctrl-alt-test Shader Minifier. Our understanding is that the main thing it does is to rename all variables and functions to a single character. This would obviously be useful for reducing the size of the GLSL source code, but (as noted in the suggestion) that doesn’t necessarily have any effect on performance. It requires .NET or Mono.

GLSLChecker is an app that compiles your GLSL vertex and fragment shaders and shows you the errors generated by the OpenGL driver. It’s not something we could use for optimizing GLSL, but some of its code could be useful for Ability to edit GLSL shader code in Vuo Editor, so thanks for the tip.

@jstrecker, very disappointing that GLSL Optimizer didn’t work out, but GLSLChecker looks like it could be fantastic in the new GLSL shader editor within Vuo. Code is so much easier to write with a checker! :-) In fact for me its much more necessary than an optimiser, (one could hand optimise by in-lining or run one of the many online optimiser if needed).

Super excited if GLSLChecker makes it way into Vuo 1.3!

1 Like