Shader fails on iOS only

Hi

I have a simple shader that works in the shader playground, Android, WIndows and Mac but not iOS.

The error is

An error occurred in the fragment kernel Qualification of arguments in redeclared function 'FragmentKernel' differs from previous declaration ERROR: One or more attached shaders not successfully compiled

The shader is

&nbsp; highp vec2 getWaveSource(int ws) { &nbsp; &nbsp; highp vec2 outp; &nbsp; &nbsp; if (ws == 0) &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; outp = vec2(-100,-100); &nbsp; &nbsp; } &nbsp; &nbsp; else if (ws == 1) &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; outp = vec2(-100,500); &nbsp; &nbsp; } &nbsp; &nbsp; else &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; outp = vec2(400,-500); &nbsp; &nbsp; } &nbsp; &nbsp; return outp; &nbsp; } &nbsp; highp float distanceSq(highp vec2 a, highp vec2 b) { &nbsp; &nbsp; highp vec2 diff = a - b; &nbsp; &nbsp; return dot(diff, diff); &nbsp; }&nbsp; &nbsp; &nbsp; highp vec4 FragmentKernel( highp vec2 uv) { &nbsp; &nbsp; const int wsCount = 3; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; highp float wavePower = 0.0; &nbsp; &nbsp; for(int i=0; i\<wsCount; i++) &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; highp vec2 src = getWaveSource(i); &nbsp; &nbsp; &nbsp; highp float dist = distanceSq(src, uv) / 200.0; &nbsp; &nbsp; &nbsp; wavePower += sin((dist + CoronaTotalTime)); &nbsp; &nbsp; } &nbsp; &nbsp; return vec4( &nbsp; &nbsp; &nbsp; 0.5 + 0.5 \* sin(wavePower), &nbsp; &nbsp; &nbsp; 0.5 + 0.5 \* cos(wavePower), &nbsp; &nbsp; &nbsp; 0.5 + 0.5 \* sin(CoronaTotalTime), &nbsp; &nbsp; &nbsp; 1 &nbsp; &nbsp; ); &nbsp; }

I am checking for system.getInfo( “gpuSupportsHighPrecisionFragmentShaders” ) == true before running the shader.

Any ideas?

“Qualification of arguments in redeclared function ‘FragmentKernel’ differs from previous declaration” sounds like there must be a line like

P\_COLOR vec4 FragmentKernel (P\_UV vec2 uv);

prepended to every shader, and in the case of iOS it’s asserting this more strongly. Try replacing those two highp s and see if you have better luck.

Thanks that works… but performance degrades too much on many devices :frowning:

Literally can just watch the fps drop a frame or 2 every 10 seconds.  Not sure why this would be?

Good link to peruse: https://developer.apple.com/library/content/documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/BestPracticesforShaders/BestPracticesforShaders.html

“Qualification of arguments in redeclared function ‘FragmentKernel’ differs from previous declaration” sounds like there must be a line like

P\_COLOR vec4 FragmentKernel (P\_UV vec2 uv);

prepended to every shader, and in the case of iOS it’s asserting this more strongly. Try replacing those two highp s and see if you have better luck.

Thanks that works… but performance degrades too much on many devices :frowning:

Literally can just watch the fps drop a frame or 2 every 10 seconds.  Not sure why this would be?

Good link to peruse: https://developer.apple.com/library/content/documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/BestPracticesforShaders/BestPracticesforShaders.html