This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Possible OpenGL ES 2 shader compiler bug on Mali-G71 on Galaxy S8/S8+

Hi everyone,

I have been digging into an issue we've seen in one of our apps that only occurs on the Galaxy S8 and the Galaxy S8+.

I'm posting here because I've narrowed it down to a small shader that breaks in mysterious ways that I can't explain and hoping someone would either be able to point out what I'm doing wrong or this can turn into a bug report.

Originally the breaking shader was a 2 pass gaussian blur with a 10x10 kernel. I have simplified it greatly while maintaining the problem. It now just blurs 3 pixels together.

I have an app (I attached the small Android project to reproduce, you need Android Studio and a fairly recent Android SDK) which blurs a picture of an Android using a shader in the Y dimension and draws it. It uses 1 very simple shader:

This shader runs properly (I get a slightly blurred android) on every device I have tried except the Galaxy S8 and the Galaxy S8+.

uniform highp sampler2D inImage;
uniform highp float inSigma;

varying highp vec4 varPosition;

#define PI 3.1415926535
#define STEPSIZE vec2(0.0, 1.0 / 50.0)

void main() {
    highp vec4 texCoords = varPosition;
    texCoords.t *= -1.0;
    texCoords += 0.5;

	highp vec4 g;
	g.x = 1.0/ (sqrt(2.0 * PI) * inSigma);
	g.y = exp(-0.5 / (inSigma * inSigma));
	g.z = g.y * g.y;
	g.q = 1.0;
	highp vec4 center = texture2D(inImage, texCoords.st);
	highp vec4 sum = g.x * center;
	highp float norm = g.x;
	g.xy *= g.yz;

	highp vec4 sam1  = texture2D(inImage, texCoords.st + STEPSIZE);
	highp vec4 sam2 = texture2D(inImage, texCoords.st - STEPSIZE);
 	sum += g.x * sam1;
	sum += g.x * sam2;
	norm += 2.0 * g.x;

	highp vec3 result = (sum/norm).rgb;

	gl_FragColor = vec4(result, 1.0);
}

However, if I change "highp vec4 g;" to "mediump vec4 g;", it works on the S8 as well. Furthermore, if I change the uniform "inSigma" to be a #define instead so it is constant, it also runs properly. So I think I'm getting some weird shader compiler behavior because it doesn't seem to be related to the code logic or the values. Please let me know if there's any more information I can provide.

Am I no following the spec in some way or is this a bug in the shader compiler or something else?

Project:

0211.GLES20_ShaderIssue.zip

Thanks!

-Alex

Parents Reply Children