Shader compilation error


This topic contains 2 replies, has 1 voice, and was last updated by  hbursk 1 year, 5 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1164

    hbursk
    Participant

    Here’s my current issue trying to use MoltenGL. This is printed in my console. Any help would be appreciated.

    [mgl-info] Converting GLSL:
    #version 100
    
    attribute  vec4    vertex;        
    attribute  vec4    color;         
    uniform  mat4      matrix;        
    varying  vec4      c;             
    void main()                            
    {                                      
        gl_Position = matrix * vertex;     
        c = color;                         
    }
    
    End GLSL
    
    [mgl-info] Converted MSL:
    #include <metal_stdlib>
    using namespace metal;
    struct xlatMtlShaderInput {
      float4 vertex [[attribute(0)]];
      float4 color [[attribute(1)]];
    };
    struct xlatMtlShaderOutput {
      float4 gl_Position [[position]];
      float4 c;
    };
    struct xlatMtlShaderUniform {
      float4x4 matrix;
    };
    vertex xlatMtlShaderOutput VertexShader5 (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]])
    {
      xlatMtlShaderOutput _mtl_o;
      _mtl_o.gl_Position = (_mtl_u.matrix * _mtl_i.vertex);
      _mtl_o.c = _mtl_i.color;
      _mtl_o.gl_Position.z = (_mtl_o.gl_Position.z + _mtl_o.gl_Position.w) / 2.0f;
      return _mtl_o;
    }
    
    End MSL
    
    Compilation failed: 
    
    program_source:4:3: warning: declaration does not declare anything
      float4 vertex [[attribute(0)]];
      ^~~~~~
    program_source:17:48: error: expected unqualified-id
      _mtl_o.gl_Position = (_mtl_u.matrix * _mtl_i.vertex);
                                                   ^
     (code 3) (null)
    
    Shader 5 could not be compiled.
    #1165

    hbursk
    Participant

    Looks like vertex was being treated as a special keyword in Metal, so I changed it to position. App is up and running now.

    #1166

    hbursk
    Participant

    Seem to be getting EXC_BAD_ACCESS crashes when calling glDrawElements(). This is using the shader I modified. Still some work to do there. Not sure why it’s crashing, and I don’t get much of a trace.

Viewing 3 posts - 1 through 3 (of 3 total)

The forum ‘MoltenGL Support’ is closed to new topics and replies.