Forums - Arrays of structures are broken in GLSL

2 posts / 0 new
Last post
Arrays of structures are broken in GLSL
SiPlus
Profile picture
Join Date: 9 May 14
Posts: 1
Posted: Wed, 2014-08-27 02:45

On Adreno 320 (Sony Xperia ZL, driver [email protected]), there's a bug with arrays of structures.

If you access a structure from an array with a variable index, all fields of the structure point to the first field.

Here's example code:

glUniform3f(glGetUniformLocation(p, "u_Colors[0].Color1"), 0.2f, 0.0f, 0.0f);

glUniform3f(glGetUniformLocation(p, "u_Colors[0].Color2"), 0.0f, 1.0f, 0.0f);

glUniform3f(glGetUniformLocation(p, "u_Colors[0].Color3"), 0.0f, 0.0f, 1.0f);

struct Colors { vec3 Color1, Color2, Color3; };

uniform Colors u_Colors[1];

void main() {

    vec3 color = vec3(0.0);

    for (int i = 0; i < 1; ++i)

        color += u_Colors[i].Color1 + u_Colors[i].Color2 + u_Colors[i].Color3;

    gl_FragColor = vec4(color, 1.0);

}

This should produce light-cyan-colored pixels (0.2, 1.0, 1.0). However, it gives (0.6, 0.0, 0.0), because Color1, Color2 and Color3 point to Color1.

It works correctly if you index the array with a constant number, however.

  • Up0
  • Down0
mhfeldma Moderator
Join Date: 29 Nov 12
Posts: 310
Posted: Wed, 2014-08-27 09:40

Hi..

This sounds similar to other array indexing issues that have been reported.  We believe they've been fixed in drivers for later Adreno hardware, but not sure about the Sony Xperia Z.    Is the build you have installed the latest one available for Sony Xperia Z?

If you have a sample apk we can try running on a few devices to confirm the specific problem has been fixed.

 

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.