We currently have an issue with a portion of the Vertex Shader that come up in devices using the Adreno 320.
When we combined access to an array index that is not constant and nested conditional statements, it produces an indeterminate output. Even when not nested and using separate conditional statements in the same uniform, it produces the same indeterminate results.
In some cases,
W/Adreno200-ES20( 7613): <finish_current_fbo_rendering:183>:GL_OUT_OF_MEMORY
W/Adreno200-GSL( 7613): <gsl_ldd_control:226>: ioctl code 0xc0140910 (IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS) failed: errno 35 Resource deadlock would occur W/Adreno200-EGL( 7613): <qeglDrvAPI_eglSwapBuffers:3476>: EGL_CONTEXT_LOST
comes out and OpenGL Context gets lost.
The hypothetical code should be,
if(A){
result = array[index0];
}
else if(B){
result = array[index1];
}
else{
result = array[index2];
}
Or
if(A){
result = array[index0];
}
if(B){
result = array[index1];
}
There are no problems when only using just one of the conditional statements.
We have two devices with Adreno 320 installed on them, and the issue is occurring on both devices.
The versions of android installed are 4.1.2 and 4.2.2.
Other devices with Adreno 220 and other different GPUs are not having this issue.
Is this an issue with the Adreno 320 driver?
Hi... There are some limitations with Array Indexing in GLES 2.0 . They are listed in the following document:
http://www.khronos.org/files/opengles_shading_language.pdf (Appendix A, section 5)
In general for array indexiing, if the support is not mandated, it's likely not implemented in our drivers.
Without seeing your full shader, it's hard to verify..
thanks,
mark
@rd-freeware
Did you try removing the variable ping-pong-ing ?
What I mean is call directly
VS_Material( Position,Normal, Tangent,UV_Primary ,Joint, Weight);
And if possible remove the MATERIAL_OUTPUT return and write to outputs without the temporary _ret.
On Adreno 205 I had a similar issue where the shader compiled "ok" but because I was using a ton of temporary variables and was ping-pong-ing them in temporaries, the object wasn't looking at all as it should.
@mhfeldma
Is there anything wrong with indexing a huge array from an uniform buffer in OpenGL ES 3 ? I get a compiler crash when doing that on Adreno 320 and I'm thinking this issue is related.
VS->
#version 300 es
//Inputs
in vec4 POSITION;
in vec2 TEXCOORD;
//Outputs
out vec2 TexCoordVarying;
uniform sampler2D Texture0;
uniform mat4 modelViewProjectionMatrix;
uniform vec3 ExtraTranslate;//z = Alpha
struct VertexData
{
vec4 POS;
vec4 TEX;
};
uniform VertexBufferData
{
VertexData Vertices[ 16 ];
};
uniform IndexBufferData
{
uint Indices[ 16 ];
};
uniform BaryCoordsBuffer
{
vec4 BaryCoords[ 200 ];
};
vec4 interpolate4(in vec4 v0, in vec4 v1, in vec4 v2, vec4 BaryCoord)
{
return v0 * BaryCoord.x + v1 * BaryCoord.y + v2 * BaryCoord.z;
}
void main()
{
int PolygonID = gl_VertexID / 3;
int VertexIndex = gl_VertexID % 3;
int PolygonIndices[3];
PolygonIndices[0] = PolygonID * 3 + 0;
PolygonIndices[1] = PolygonID * 3 + 1;
PolygonIndices[2] = PolygonID * 3 + 2;
vec4 Bary = BaryCoords[ VertexIndex + gl_InstanceID * 3 ];
vec4 CurrentVertex;
CurrentVertex = interpolate4( Vertices[ Indices[ PolygonIndices[ 0 ] ]].POS, Vertices[ Indices[ PolygonIndices[ 1 ] ]].POS,
Vertices[ Indices[ PolygonIndices[ 2 ] ]].POS, Bary );
vec4 CurrentTexcoord;
CurrentTexcoord = interpolate4( Vertices[ Indices[ PolygonIndices[ 0 ] ]].TEX, Vertices[ Indices[ PolygonIndices[ 1 ] ]].TEX,
Vertices[ Indices[ PolygonIndices[ 2 ] ]].TEX, Bary );
vec4 ModifiedPos = CurrentVertex;
ModifiedPos.xy += ExtraTranslate.xy;
gl_Position = modelViewProjectionMatrix * ModifiedPos;
TexCoordVarying = CurrentTexcoord.xy;
}
PS->
#version 300 es
precision highp float;
layout(location = 0) out vec4 FragColor;
//Inputs
in vec2 TexCoordVarying;
uniform sampler2D Texture0;
uniform float Time;
uniform vec4 AtlasInfo;
uniform vec4 TextureInfo;
uniform vec3 ExtraTranslate;
uniform vec4 MaterialColor;
void main()
{
vec2 FinalTexcoord = TexCoordVarying;
vec4 Texel;
Texel = texture( Texture0, FinalTexcoord );
Texel.a *= ExtraTranslate.z;
Texel.rgb *= MaterialColor.rgb;
FragColor = Texel;
}