Hello Mali dev forums,
We recently had a bug pop up in our user reviews regarding mangled graphics on the Galaxy Note 10.1 2014 edition which runs the Mali-T628 GPU and decided to investigate.
After much debugging and poking around, we tracked it down to this one simple fragment shader:
uniform lowp sampler2D sampler;
varying lowp vec4 blendColor;
varying mediump vec2 texCoord;
void main()
{
lowp vec4 texColor = texture2D(sampler, texCoord);
gl_FragColor = 2.0 * blendColor * texColor;
}
Which when used, would cause the output in the BAD image attached. We found that reducing the precision of texCoord from mediump to lowp, the problem went away as in the GOOD image attached.
This particular application shipped around the time the Nexus 10 came to market and is known to have worked fine on the T604 GPU. I do suspect that the fragment shader is not alone in causing this issue since the linkage with the vertex shader could also have effects, however that side of things is relatively simple (I've attached a sample vertex shader).
One thing that makes me hesitate to point at the shader compiler as a culprit is the following odd behaviour. The BAD scene actually renders correctly for 1 frame before getting into a state where the UVs are mangled.
Though we do have a workaround to the issue, I still wanted to bring this up as using lowp UVs isn't typical but only happens to work well with our texture set. Also worry that this bug could spread in various driver branches. Any possibilities that this would be Samsung specific, or do they use ARM reference drivers.
Many thanks,
Stephane
Hello Stephane,
Could you please paste the vertex shader that is used with this fragment shader?
That would help us take a look at what the driver produces for this code.
Thanks
Johan
Hi Johan,
A vertex shader, model_rigid.vsh was attached to the original message. It seems the new forum may have zipped the attachment.
Thanks!
Thanks for the report,
You have found the right workaround, preferring lowp and highp over mediump, and using the same precision in the vertex and fragment shader.
Regards
Thanks for confirming the workaround Johan. You have sufficient information on your end to resolve the issue? mediump is generally our preferred precision level for UVs especially when tiling, which thankfully wasn't the case with this application. I'd be curious as to the root cause of the issue as we have another application with much more complex shaders that doesn't exhibit this artifact but is using medium UVs in a similar fashion.
Best,