glob3mobile / g3m

The multiplatform advanced visualization framework
http://www.glob3mobile.com/
Other
117 stars 56 forks source link

Error while compiling program in GPUProgram.createProgram() #71

Closed ztreer closed 9 years ago

ztreer commented 10 years ago

Hi!

We've seen an 'Error while compiling program' rarely but regularly for a while now, i've added logging the name of the program, and now it turned out which program fails to compile in GPUProgram.createProgram()

Error while compiling program: FlatColorMesh_DirectionLight

vertexSource:

    attribute vec4 aPosition; 
    attribute vec3 aNormal; 
    uniform mat4 uModelview; 
    uniform mat4 uModel; 
    uniform float uPointSize; 
    uniform vec3 uAmbientLightColor; 
    uniform vec3 uDiffuseLightColor; 
    uniform vec3 uDiffuseLightDirection; //We must normalize 
    varying vec3 lightColor; 
    void main() { 
        vec3 normalInModel = normalize( vec3(uModel * vec4(aNormal, 0.0) )); 
        vec3 lightDirNormalized = normalize( uDiffuseLightDirection ); 
        float diffuseLightIntensity = max(dot(normalInModel, lightDirNormalized), 0.0); 
        gl_Position = uModelview * aPosition; 
        gl_PointSize = uPointSize; 
        lightColor = uAmbientLightColor + uDiffuseLightColor * diffuseLightIntensity; 
        lightColor.x = min(lightColor.x, 1.0); 
        lightColor.y = min(lightColor.y, 1.0); 
        lightColor.z = min(lightColor.z, 1.0); 
    } 

fragmentSource:

    precision highp float; 
    uniform lowp vec4 uFlatColor; 
    varying vec3 lightColor; 
    void main() { 
        gl_FragColor.r = uFlatColor.r * lightColor.r; 
        gl_FragColor.g = uFlatColor.g * lightColor.r; 
        gl_FragColor.b = uFlatColor.b * lightColor.r; 
        gl_FragColor.a = uFlatColor.a; 
    } 

Running on GT-N7100, Android 4.3

Do you have any ideas why this is failing?

Thank you!

ztreer commented 10 years ago

Actually the vertexSource/fragmentSource may be all right, because they would fail earlier, and compileShader() succeeds for both (at least the return value signals a success). But later gl.getError() will be checked and that returns a failure - but only an integer error code, which is : 1281

**GL_INVALID_VALUE​, 0x0501**
Given when a value parameter is not a legal value for that function. This is only given for local problems; if the spec allows the value in certain circumstances, where other parameters or state dictate those circumstances, then GL_INVALID_OPERATION is the result instead.

well that's not much help, as it will not tell us about what value was invalid in which operation ....