- August 22, 2012 at 12:48 pm #30953
Hi,I have been having a hard crash when I run my application on device but not on PC.I have found the source of the problem to be with “glGetActiveUniform”I use this function to get the array size of the uniform from the shader and allocate memory on the CPU side.GLsizei lengthWrittenTonamef; GLint arrsize; GLenum datatype;glGetActiveUniform(m_uiProgram, location,256, &lengthWrittenTonamef, &arrsize, &datatype, uniformname);Now on PC , calling glGetActiveUniform will return “
uniformname ” for the “location” value I pass in.When I pass this “
uniformname ” to “glGetUniformLocation”, I get back the exact “location” value.While on device (on Android galaxy S1 -GTI9000) these values are not the same. Basically “glGetActiveUniform ” is not returning the same uniform information of the “location” I am asking for. I use CPVRTPFXEffect.Load to load my pfx and as said, this works flawlessly on the PC.This is causing wrong allocation to another uniform and thus I am crossing array size of a uniform and leading to a crash.My basic need is to query for the array size of a uniform. Could you help me understand how to implement my above functionality correctly if I am doing something wrong ?[ADDITIONAL OBSERVATION]for my uniform in shader like thisuniform lowp vec4 texToUseForFace;glGetActiveUniform is returning “texToUseForFace” on the PC while its returning “texToUseForFace” on the device (please do note that your SPVRTPFXParserEffect.psUniform.pszName= “texTouseForFace” in both PC and device thus leading to more confusion) . This is core reason for my crash. hard coding to replace the excess “” solved my crash. Please confirm the source of this difference in the string.Thanks,Madan
mkandula 2012-08-22 20:32:01September 25, 2012 at 12:40 pm #36093
This is actually down to a spec bug in OpenGL ES. The behaviour of this case for arrays was highly underspecified in the original GL ES specification, but has been recently changed to clarify the point. Subsequently, whether a particular platform can query with or without the  is unfortunately platform dependent. Regardless, an incorrect query should return -1, so I will look into the codebase for the PFX loading code to see if there’s some way we can modify the behaviour to handle this properly. I’ll let you know as soon as we have some sort of fix.
Tobias2012-09-25 12:50:13September 25, 2012 at 1:02 pm #36094
Ok I’ve looked at the code with one of my colleagues, and we came to the
conclusion that the simplest fix is to check if the uniform locations found are
-1, and try again with the value with  appended. There’s currently no way to
track if a uniform is an array value in the PFX code, but it’s something we’ll
look into adding specifically for a future release, which will allow us to do
this a bit more selectively.
To do the same fix in the tools on your end, you’ll need to look at the file
“PVRTPFXParserAPI.cpp”, lines 815 and 518. Add the following code and
it should just work:
// Check for array.
Workaround for some OpenGL:ES implementations which require array element
appended to uniform name
// in order to
return the correct location.
if(nLocation == -1)
nLocation = glGetUniformLocation(m_uiProgram, szTmpUniformName);
also need to do the same if you choose to get uniform locations manually. Hope
/* Style Definitions */
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-bidi-font-family:”Times New Roman”;