Imagination PowerVR SDK Blog

[BUG][GLSL]PowerVR G6200 on Meizu MX4 MSAA with discard in GLSL breaks rendering


GL Version = OpenGL ES 3.1 build 1.4@3443629
The bug can be reproduced on this sample project, which is basically a combo of Google’s ndk+ogl sample from here and MSAA sample from here .
The bug is triggered by rendering to MSAA framebuffer with a shader that has discard (and the discard has to be executed at least once), which is “heavy enough” (in our case, execution of several math-heavy functions like pow or sin triggers it). Minimum changes in the shader inside that sample project make bug disapper The bug, when manifested, results in nothing being rendered to MSAA-enabled framebuffer. No Opengl errors are reported by driver.
Any suggestions to work this around?



I have built your app (with the ‘broken’ shader and ‘working’ shader) and installed it on a Nexus player, both versions of the application seemed to work fine for me (see attached screenshots), could you possibly try building / running the application with the shader precision set to highp just in case you are overflowing the variables (quite likely as you are multiplying a power in a for loop) which would result in undefined behavior.



Thanks for suggestion, but that’s not the problem (and in original code there’s no overflow); it’s just that code with ‘+’ gets optimized by compiler, so I’ve rewritten it a bit
[scode lang=“glsl”]
precision highp float;
uniform sampler2D texture;
varying vec2 texCoord;
void main() {
float sum = 1.0;
for (int i = 0; i < 30; i++) {
sum += pow((gl_FragCoord.x
+ float(i) //breaks
) / 2000.0, 2.0);
gl_FragColor = vec4(0.0, 1.0, sum , 1.0);
if (gl_FragCoord.x < 400.0)
The bug is very device-specific (and probably driver-specific too), we don’t have other devices with PVR G6200 at the moment, but gonna give it a test once we have one.
I’ve attached what I see on affected device



It seems likely (as you suggested) that this is a driver bug as I am unable to reproduce it on any of my devices which are running a newer driver, unfortunately we do not distribute driver updates, this is up to the platform manufacturer. In the meantime I can only suggest that you do not use the discard statement in your fragment shader in combination with a MSAA buffer.

Kind Regards,