Hi,
I have a vertex shader that uses 2 array uniforms, and a for loop to iterate them:
}
This shader runs flawless on a variety of devices, except "some" (mostly Galaxy S4 / ACE, the common factor is being adreno 200/320 GPU) where the line with pt[i] gives error during compile/link:
1. In some cases there is no error message text at-all
2. In other cases there is error text "SEMANTIC-20 (line 33) Indexing with an integral constant expression greater than declared size"
3. (this seems to be the exception rather than the rule) on some S4 models it runs without issue (maybe a driver difference); which is a pitty, since I am unable to reproduct the issue on Samsung Remote Test labs device (hampering my effort to find a workaround).
OpenGL ES 2.0 shader language spec says that for Uniforms, array indexes can be "Any integer"; the for loop also is within spec AFAIK.
Please advice on how to work around this? (willing to share entire shader code if so required)
Thank you in advance, any help would be greatly appreciated.
[EDIT:
Worked around issue by unrolling the loop manually, eliminating the 'for' construct; so far no more reports of the issue.
]
Hi..I believe this is the problem you are encountering.
The GLES shading language spec says that uniform arrays need to be indexed with constant integral expressions (not variables).
http://www.khronos.org/files/opengles_shading_language.pdf p 103
-mark
Hi,
Tank you for responding,
This is only for fragment shader (granted, the spec is being non-specific enough in chapter 4.1.9 Arrays, but very clear in chapter 12, appendix A section 5)
See (same PDF link):
[Quote end]
Also see the table at page 103.
That explains (to me at least) why it works on each and every gpu (except aforementioned cases...)
I too am facing this issue, on an Adreno 330 (Nexus 5) with an OpenGL ES 3.0 context. I am doing GPU skinning and need to reference bone matrices with a bone index vector attribute.
...
uniform mat4 boneMatrices[30];
...
in vec3 boneWeights;
in ivec4 boneIndices;
...
GPU skinning should work..
1) Could you confirm exactly what message you're getting?
2) It could be that the number of uniforms is not large enough to store the bone matrices.. (try reducing the count and see if it works).
3) Take a look at our Adreno SDK. We have two complex gpu skinning examples in the OpenGLES2 section.
https://developer.qualcomm.com/mobile-development/mobile-technologies/ga...
I've also hit this exact issue with Adreno 320, Android GLES20. I'm happy to provide a simple repro APK
On the system detailed below, the bug results in a hard app death on calling glLinkProgram() with the problematic vertex shader. There are no exceptions, no gl errors or gl log information, and no messages through logcat. If I remove the vertex shader line that indexes a uniform by an int variable in a loop, everything renders as expected.
I've been runnning the code that indexes a uniform without any trouble on a Nexus 7 with Tegra.
My big concern with this is that, in my case, the whole app is taken down with no indicators and no information through the GLES API. If your implementation does not support indexing by variable (which GPU vertex shader programs have supported since GeForce3 / NV20 in 2001), then you should fail with a gl error from glCompileShader, set the proper values for glGetShaderiv( .. GL_COMPILE_STATUS), and put something visible from glGetShaderInfoLog.
I have not seen this debug spew line that DevDot mentioned, but I think it leads to an important clue:
"2. In other cases there is error text "SEMANTIC-20 (line 33) Indexing with an integral constant expression greater than declared size""
There migth be a problem with the array declaration in the compiled assembly, specifically in the header for the assembly if your implementation goes the old arb program route.
Android version 4.4
kernel version 3.4.0-gdb0eacf3
[email protected] #1
Wed Oct 23 17.41.58 PDT 2013
build number KRT16S
EglContextClientVersion 2
GL_VERSION OpenGL ES 3.0 [email protected] AU@ (CL@3776187)
GL_VENDOR Qualcomm
GL_RENDERER Adreno (TM) 320
GL_VERSION OpenGL ES 3.0 [email protected] AU@ (CL@3776187)
GL_SHADING_LANGUAGE_VERSION OpenGL ES GLSL ES 3.00
Thanks mhfeldma for pointing me to the SDK, that solved my issues :) In the end I used a uniform array of vec4s as is done in the SDK, however I still think that the spec should be followed and a uniform array of any type be indexable with a non-constant integer. Will we perhaps see this implemented in future driver versions?
my 2 cents: the linked spec is not even the latest version. if you browse through the khronos pages (OpenGL ES -> Specs & Headers -> OpenGL ES 2.0 Specifications) you end up with this version, which is revision 17, compared to revision 14, in the first link. From revision 16 to 17, allowed array indexing has changed significantly: indexing with loop indices and expressions of loop indices and constants is now explicitly allowed for all kinds of arrays (p. 110).
Is there any information about which GPUs/Drivers implement which revision of the spec? Is there any way to find out programmatically (except for trying to compile and retry with a simpler shader)?
If you do have an apk that reproduces the glLinkProgram crash, that would be great to have to both verify the existing problem on Adreno 320, and make sure it's fixed in current drivers.. Addtionally if you have the shader source code, that would be valueable to look at.
I stumbled on a same as this one suing matrix palettes, as a fallback I use
mat4 mx = m[index.x];
p = mx * ws * vec;
instead of
p = m[index.x] * ws * vec;
and it works beautifully, it woulkd be better if the bug is fixed :)