OpenGL crashes when linking program, LG Nexus 4

5

I'm having another OpenGL ES driver error. This time I'm trying to compile the following lines:

precision mediump float; 
varying highp vec2 textureCoordinate; 


void main() { 
 highp vec4 color = texture2D(input0, textureCoordinate); 


vec3 color3 = color.rgb;

vec2 tc = (2.0 * textureCoordinate) - 1.0;
float d = dot(tc, tc);
vec2 lookup = vec2(d, color3.r);

..   
..
}

but I'm getting after the line:

GLES20.glLinkProgram(program);

native crash : "Fatal signal 11(SIGDEV) at 0x00000060(code = 1), thread 1231 " I'm guessing that it happens because LG nexus 4 uses GPU Adreno, and it also crashes for me with error code 14 on a different crash - using too many macros.

android
opengl-es
opengl-es-2.0
shader
fragment-shader
asked on Stack Overflow Oct 6, 2013 by Nativ • edited May 29, 2014 by Nativ

2 Answers

2

After you compile the shader, using glGetShaderiv get the status of the shader compilation. Like:

GLint compiled;
glGetShaderiv(index, GL_COMPILE_STATUS, &compiled);  //index is the shader value

Then, if compiled is returned as zero, get the info length first, and then the error message as follows:

GLint infoLen = 0;
glGetShaderiv(index, GL_INFO_LOG_LENGTH, &infoLen);

if(infoLen > 1)
{
    char* infoLog = new char(infoLen);
    glGetShaderInfoLog(index, infoLen, NULL, infoLog);
}

Check infoLog finally to see the error message that returned from shader compilation. Segmentation fault message in your original post does not give anything useful to solve the problem.

answered on Stack Overflow Oct 7, 2013 by eozgonul • edited Oct 7, 2013 by eozgonul
1

As far as I can see from your short code excerpt in your fragment shader you haven't specified float precision. In ES 2.0 you must explicitly specify float precision.

precision mediump float;

Please read about this in specs, p. 4.5.3 Default Precision Qualifiers. Shader may work without specifying float precision on certain OpenGL ES drivers and may fail to compile on another ones.

However, full source code is needed to find out exact cause of your issue.

I'd suggest you to start commenting out parts of shader code until it starts compiling correctly. This way you will narrow down a problematic line (I believe even faster than waiting for answer here on SO).

answered on Stack Overflow Oct 7, 2013 by keaukraine

User contributions licensed under CC BY-SA 3.0