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

can't have #version 300 es shaders

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Out of scope
    • Icon: P2: Important P2: Important
    • None
    • 5.12.2
    • Quick: SceneGraph
    • None
    • arm, mali
    • Linux/Other display system

      I am currently writing a custom QSGNode. Since I need to import extensions which are just available in glsl 3.00 I need to use this version. This is possible for the fragment shader, but not for the vertex shader, since qt adds some more code into the shader which is incompatible with version 3.0.

      This is the original vertex shader (special features are required in the fragment shader):

          static const char *shader =
                  "#version 320 es                                    \n"
                  "uniform highp mat4 qt_Matrix;                      \n"
                  "in highp vec4 qt_VertexPosition;                   \n"
                  "in highp vec2 qt_VertexTexCoord;                   \n"
                  "out highp vec2 qt_TexCoord;                        \n"
                  "void main() {                                      \n"
                  "    qt_TexCoord = qt_VertexTexCoord;               \n"
                  "    gl_Position = qt_Matrix * qt_VertexPosition;   \n"
                  "}";
      

      When running it on the target I get the following error:

      QOpenGLShaderProgram::uniformLocation(qt_Matrix): shader program is not linked
      QOpenGLShaderProgram::uniformLocation(texture0): shader program is not linked
      QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
      QOpenGLShaderProgram::uniformLocation(transparencyEnabled): shader program is not linked
      QOpenGLShader::compile(Vertex): 2:4: L0003: Keyword 'attribute' is reserved
      *** Problematic Vertex shader source code ***
      #version 320 es                                    
      #line 1
      uniform highp mat4 qt_Matrix;                      
      in highp vec4 qt_VertexPosition;                   
      in highp vec2 qt_VertexTexCoord;                   
      out highp vec2 qt_TexCoord;                        
      attribute highp float _qt_order;
      uniform highp float _qt_zRange;
      void main() {                                      
          qt_TexCoord = qt_VertexTexCoord;               
          gl_Position = qt_Matrix * qt_VertexPosition;   
          gl_Position.z = (gl_Position.z * _qt_zRange + _qt_order) * gl_Position.w;
      }
      ***
      shader compilation failed: 
      "2:4: L0003: Keyword 'attribute' is reserved"
      QOpenGLShader::compile(Vertex): 2:4: L0003: Keyword 'attribute' is reserved
      

      As you can see Qt adds incompatilbe statement:

      attribute highp float _qt_order;
      

      This can be tracked to: qtdeclarative/src/quick/scenegraph/coreapi/qsgshaderrewriter.cpp .

      Small sidenote: when running with QSG_NO_DEPTH_BUFFER=1 the shader works.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            lagocs Laszlo Agocs
            georgleugner Georg Leugner
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes