Skip to content Skip to sidebar Skip to footer

Gllinkprogram Crashes Even Though Glcompileshader Does Not Return Any Error

I am trying to make the native code from https://software.intel.com/sites/default/files/managed/79/e5/OpenGL%20ES%20Tessellation.zip work on my Samsung Galaxy S5. I have disabled T

Solution 1:

The problem can come from dynamic indexing of array in a fragment Shader which is not supported by all the implementations. (see https://www.khronos.org/files/opengles_shading_language.pdf p103. Note that it's OK in vertex shaders...)

In your code :

for(int ii=0; ii<NumLights; ++ii) {
    lightDirection = -LightDirections[ii];
    floatnDotL= max( 0.0,dot( normal, lightDirection ) );
    vec3diffuse= LightColors[ii] * nDotL * shadowAmount  * albedo;
    result.xyz += diffuse * (1.0/float(NumLights));
}

Try to debug with constant indexing. Replace all xxx[ii] by xxx[0]. If it work that way, then you're probably facing this dynamic indexing limitation.

One hackish way to bypass this issue : use float for loops and create an int var in the loop body:

floatNumLights_f=float(NumLights);
for(float ii_f=0.; ii_f<NumLights_f; ++ii_f) {
    intii=int(ii_f);
    lightDirection = -LightDirections[ii];
    floatnDotL= max( 0.0,dot( normal, lightDirection ) );
    vec3diffuse= LightColors[ii] * nDotL * shadowAmount  * albedo;
    result.xyz += diffuse * (1.0/float(NumLights));
}

For some reason, it solved my similar bug. I'm no glsl-es guru, I'm curious about WHY this work. And it may comes at the price of performance penalty... Is it because of loops unroll ? int(ii_f) is like a constant after unrolling ?

Post a Comment for "Gllinkprogram Crashes Even Though Glcompileshader Does Not Return Any Error"