Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-75680

Shader compilation error in the hellogles3 example on macOS

    XMLWordPrintable

Details

    • macOS
    • 45aa3c73f78c6c06874d0f826e1f112976cd522d (qt/qtbase/5.12)

    Description

      When I try to run the hellogles3 example on Mac 10.13.6, I do not see the expected behavior. I get a shader compilation error at runtime indicating that 'version 330' is not supported. Below is my complete error output: 

      Requesting 3.3 compatibility context
      QOpenGLShader::compile(Vertex): ERROR: 0:1: '' :  version '330' is not supported
      ERROR: 0:2: 'layout' : syntax error: syntax error
      
      
      *** Problematic Vertex shader source code ***
      #version 330
      #define lowp
      #define mediump
      #define highp
      #line 1
      layout(location = 0) in vec4 vertex;
      layout(location = 1) in vec3 normal;
      out vec3 vert;
      out vec3 vertNormal;
      out vec3 color;
      uniform mat4 projMatrix;
      uniform mat4 camMatrix;
      uniform mat4 worldMatrix;
      uniform mat4 myMatrix;
      uniform sampler2D sampler;
      void main() {
         ivec2 pos = ivec2(gl_InstanceID % 32, gl_InstanceID / 32);
         vec2 t = vec2(float(-16 + pos.x) * 0.8, float(-18 + pos.y) * 0.6);
         float val = 2.0 * length(texelFetch(sampler, pos, 0).rgb);
         mat4 wm = myMatrix * mat4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, t.x, t.y, val, 1) * worldMatrix;
         color = texelFetch(sampler, pos, 0).rgb * vec3(0.4, 1.0, 0.0);
         vert = vec3(wm * vertex);
         vertNormal = mat3(transpose(inverse(wm))) * normal;
         gl_Position = projMatrix * camMatrix * wm * vertex;
      }
      
      
      ***
      QOpenGLShader::compile(Fragment): ERROR: 0:1: '' :  version '330' is not supported
      
      
      *** Problematic Fragment shader source code ***
      #version 330
      #ifdef GL_KHR_blend_equation_advanced
      #extension GL_ARB_fragment_coord_conventions : enable
      #extension GL_KHR_blend_equation_advanced : enable
      #endif
      #define lowp
      #define mediump
      #define highp
      #line 1
      in highp vec3 vert;
      in highp vec3 vertNormal;
      in highp vec3 color;
      out highp vec4 fragColor;
      uniform highp vec3 lightPos;
      void main() {
         highp vec3 L = normalize(lightPos - vert);
         highp float NL = max(dot(normalize(vertNormal), L), 0.0);
         highp vec3 col = clamp(color * 0.2 + color * 0.8 * NL, 0.0, 1.0);
         fragColor = vec4(col, 1.0);
      }
      
      
      ***

      The example's description implies that it should work the same on desktop and mobile/embedded (from https://doc.qt.io/qt-5/qtopengl-hellogles3-example.html): 

      The Hello GLES3 example demonstrates easy, cross-platform usage of OpenGL ES 3.0 functions via QOpenGLExtraFunctions in an application that works identically on desktop platforms with OpenGL 3.3 and mobile/embedded devices with OpenGL ES 3.0.
      
      The code is always the same, with the exception of two places:
      - The OpenGL context creation has to have a sufficiently high version number for the features that are in use.
      - The shader code's version directive is different.

      The shader version is dynamically set by GLWindow::versionedShaderCode().

      Attachments

        For Gerrit Dashboard: QTBUG-75680
        # Subject Branch Project Status CR V

        Activity

          People

            lagocs Laszlo Agocs
            tomhrabchak Tom Hrabchak
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes