Skip to content

Shaders not compiling on GLES #143

@matej-mikus

Description

@matej-mikus

Program output of graph1_pi:

$ ./graph1_pi 
#version 310 es
#extension GL_EXT_shader_io_blocks : enable
precision mediump float;
uniform mat4 m_matrix;
uniform mat4 v_matrix;
uniform mat4 p_matrix;
uniform float alpha;
uniform mat4 s_matrix;
uniform int instance_count = 0;
uniform int instance_start = -1;
uniform int instparam_count = 0;
layout(location = 0) in vec4 position;
layout(location = 1) in vec4 normalin;
layout(location = 2) in vec3 color;
layout (std430, binding = 1) buffer InstPos { float ipos[]; };
layout (std430, binding = 2) buffer InstParam { float iparam[]; };
out VERTEX
{
    vec4 normal;
    vec4 color;
    vec3 fragpos;
} vertex;
void main()
{
    if (instance_count > 0) {
        int ipos_i = instance_start * 3 + gl_InstanceID * 3;
        vec4 iposv = { ipos[ipos_i], ipos[ipos_i + 1], ipos[ipos_i + 2], 0 };
        if (instparam_count > 0) {
            int idx = gl_InstanceID % instparam_count;
            int ippos_i = instance_start * 5;
            float s = iparam[ippos_i + idx * 5 + 4];
            vec3 p_three = vec3(position) * s;
            vec4 p_scaled = vec4(p_three, 1.0);
            gl_Position = (p_matrix * v_matrix * m_matrix * ((s_matrix * p_scaled) + iposv));
            vertex.color = vec4(iparam[ippos_i + idx * 5], iparam[ippos_i + idx * 5 + 1], iparam[ippos_i + idx * 5 + 2], iparam[ippos_i + idx * 5 + 3]);
            vertex.fragpos = vec3(m_matrix * p_scaled);
        } else {
            gl_Position = (p_matrix * v_matrix * m_matrix * (position + iposv));
            vertex.color = vec4(color, alpha);
            vertex.fragpos = vec3(m_matrix * position);
        }
    } else {
        gl_Position = (p_matrix * v_matrix * m_matrix * position);
        vertex.color = vec4(color, alpha);
        vertex.fragpos = vec3(m_matrix * position);
    }
    vertex.normal = normalin;
}


--------------------------
0:9(30): error: cannot initialize uniform instance_count in GLSL ES 3.10 (GLSL 1.20 required)
0:10(30): error: cannot initialize uniform instance_start in GLSL ES 3.10 (GLSL 1.20 required)
0:11(31): error: cannot initialize uniform instparam_count in GLSL ES 3.10 (GLSL 1.20 required)
0:27(17): error: C-style initialization requires the GL_ARB_shading_language_420pack extension
0:34(75): warning: `iposv' used uninitialized
0:38(62): warning: `iposv' used uninitialized

Exiting.

The culprit seems to be shaders/Visual_instancing.vert.glsl, which uses non ES compatible features.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions