GLES compile errors under Marshmallow

Since I updated to Marshmallow a lot of my previously OK shaders now give compile errors.

“Global variable initializer must be a constant expression”

Simple example shader code to trigger it is

uniform float time;

float time2=time*0.4;

Error on the second line.

Is there any quick fix to get these shaders going?

Here is the full code that works OK still under glslsandbox
glslsandbox . com / e#33548.0
(Sorry had to obfuscate the url it to get past first time post restrictions, just remove all the spaces for the url)

The error is also under a Samsung Galaxy Note 5 if that matters. I can test on some other devices later tonight.

Any help will be greatly appreciated.

The answer is simple: initialize time2 inside main, not as a global.

GLSL is not like C++; initializers outside of main don’t get executed before main. They get executed by the compiler. And the compiler cannot know the contents of time, since it’s a user-provided uniform.

[QUOTE=Alfonse Reinheart;1283057]The answer is simple: initialize time2 inside main, not as a global.

GLSL is not like C++; initializers outside of main don’t get executed before main. They get executed by the compiler. And the compiler cannot know the contents of time, since it’s a user-provided uniform.[/QUOTE]

Well that sucks. I have a lot of shader code to fix now. Some will be simple move a line of code into main, some will be more complex. A load of shader code from glslsandbox has these same issues now. So it is most likely that the previous compiler accepted this error, but the new one under marshmallow is more strict and reports an error.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.