The OpenGL ES specification 2.0.25 on p37 states "There will be only one active uniform reported by the GL per uniform array." However with the Adreno OpenGL ES 2.0 with the following shaders, the code has the incorrect results shown below. This has been observed on multiple Adreno devices (and no others) including the Android Nexus One.
static const char gVertexShader1[] =
"attribute vec4 erp_texcoord0;\n"
"varying vec4 erp_var_texcoord0;\n"
"attribute vec4 erp_texcoord1;\n"
"varying vec4 erp_var_texcoord1;\n"
"uniform mat4 erp_matrix[7];\n"
"attribute vec4 erp_position;\n"
"void main() {\n"
"gl_Position = erp_matrix[0] * erp_position;\n"
"erp_var_texcoord0 = erp_matrix[5] * erp_texcoord0;\n"
"erp_var_texcoord1 = erp_matrix[6] * erp_texcoord1;\n"
"}\n";
static const char gFragmentShader1[] =
"precision mediump float;\n"
"varying vec4 erp_var_texcoord0;\n"
"varying vec4 erp_var_texcoord1;\n"
"uniform sampler2D erp_texture[2];\n"
"uniform vec4 erp_materialColor[5];\n"
"void main() {\n"
"gl_FragColor = erp_materialColor[0];\n"
"vec4 col;\n"
"col = texture2D(erp_texture[0], erp_var_texcoord0.st);\n"
"gl_FragColor = col;\n"
"col = texture2D(erp_texture[1], erp_var_texcoord1.st);\n"
"gl_FragColor = vec4(mix(gl_FragColor.rgb, col.rgb, col.a), gl_FragColor.a);\n"
"}\n";
glGetProgramiv(programId, GL_ACTIVE_UNIFORMS, &vnum);
→vnum == 4
It should be 3. Adreno is obviously reporting a uniform for each slot of the erp_texture array that is used.
glGetActiveUniform(programId, 0, MCE_MAX_UNIFORM_NAME_LENGTH + 5, &length, &size, &type, name);
→name == "erp_materialColor[0]"
glGetActiveUniform(programId, 1, MCE_MAX_UNIFORM_NAME_LENGTH + 5, &length, &size, &type, name);
→name == "erp_matrix[0]"
glGetActiveUniform(programId, 2, MCE_MAX_UNIFORM_NAME_LENGTH + 5, &length, &size, &type, name);
→name == "erp_texture[0]"
glGetActiveUniform(programId, 3, MCE_MAX_UNIFORM_NAME_LENGTH + 5, &length, &size, &type, name);
→name == "erp_texture[1]"
If vnum was returning 3, then this should raise an INVALID_VALUE error. If vnum == 4 was allowed, this would still be wrong. According to the spec. on p36 "If the active uniform is an array, the uniform name returned in name will always be the name of the uniform array appended with "[0]".
It would sure be nice if you had a proper bug reporting system we could put this kind of issue in.
Hi Mark -
I had discussed this with our driver team and after some investigation, we've made a change to our sampler array logic in the current driver code and it is now reporting the correct number of uniforms as you pointed out. This will be propogated out into future releases of the driver.
Many thanks for bringing this to our attention!
-mark f.
Compatible with Microsoft Office, it allows you to select from a variety of report formats and gives you control access to information displayed. With this SAP Business One ERP, you can save time and money on third-party reporting and tailor forms and queries to meet your business requirements.