I have a shader that is giving me a hard time on Adreno GPUs, while working fine on others (tried on Mali-400 MP and PowerVR SGX 540). I have access to three Adreno devices:
1. Samsung Galaxy S (GT-I9000), Android 2.3.3, GL_RENDERER: Adreno (TM) 220, GL_VERSION: OpenGL ES 2.0 1566933
2. Samsung Galaxy Tab 8.9 AT&T (SGH-I957), Android 3.1, GL_RENDERER: Adreno (TM) 220, OpenGL ES 2.0 1566933
3. LG Nexus 4, Android 4.2.2, GL_RENDERER: Adreno (TM) 320, OpenGL ES 2.0 [email protected] AU@ (CL@2961380)
on 1), the shader compiles and links, but draws garbage (I didn't investigate that any further)
on 2), the shader compiles but doesn't link. The error message contains nothing but
--From Fragment Shader:
--From Vertex Shader:
on 3), the glLinkProgram call crashes: (see crashdump.txt)
I discovered that indexing of arrays is causing the problem, but only under certain circumstances that i wasn't able to understand so far.
I am willing to privately send the shader that causes the problem.
I managed to fix the crash on the Nexus 4 by (very strictly) following the GLSL ES spec, Appendix A.
In detail, i re-wrote the shader to only use for loops with constant bounds and increments, and access arrays only with constant expressions or expressions composed of loop indices and constant expressions.
In Addition to that, i discovered that the shader linker doesn't like expressions where you index arrays on both the left and the right side: "lines[i] = points[i+1]-points[i];" crashes, but "vec2 start = points[i]; vec2 end = points[i+1]; vec2 line = end-start; lines[i] = line;" doesn't.
I really think that the driver should emit a compiler error when language features are used that are not enforced by the spec and not supported by the compiler. Or, if it must be in the Linker, it should emit an error there, and not just crash, which took me almost a week of work to fix. With a proper log saying that i cannot use dynamic array indices, it would have been a matter of a few hours at most.
Oh and by the way, the issues on the Galaxy S and the Samsung tablet still persist....