Important: Please read the Qt Code of Conduct -

QOpenGLShader compile error on Haswell

  • I get the following error when I run my app on a PC running Ubuntu 14.10 with a Haswell GPU (Intel HD 4600):

    @QOpenGLShader::compile(Vertex): 0:4(1): error: syntax error, unexpected NEW_IDENTIFIER

    *** Problematic Vertex shader source code ***
    #define lowp
    #define mediump
    #define highp
    precision highp float;

    uniform mat4 u_Matrix;

    attribute vec4 a_Vertex;
    attribute vec2 a_TexCoord;

    varying mediump vec2 v_TexCoord;

    void main(void)
    gl_Position = u_Matrix * a_Vertex;
    v_TexCoord = a_TexCoord;

    Does anyone know what the problem might be ("unexpected NEW_IDENTIFIER" is not very helpful)? This code works fine on every other GPU I've tried (including phones).

    Thanks for any help.

  • It turns out that the offending line is "precision highp float;".

  • Because it's not valid GLSL. Do not confuse with GLSL ES where it is valid. And anyway, even with ES it is not necessary to declare the float precision in vertex shaders like that because it defaults to high (unlike in fragment shaders).

    If you are only targetting desktop OpenGL, then just forget about that line. If you are targetting both OpenGL and OpenGL ES, then the portable way is to include the precision qualifiers in the source, instead of relying on the precision keyword.

  • Thanks for the reply. Once I discovered that the culprit is the "precision" keyword then I removed it and added the qualifiers in the body of the source. This is a project that is targeting mobile devices but I do most of the testing on desktop.

Log in to reply