I’m using PowerVr SDK 3.4 for Windows 7.
I compile my shaders offline and save the programs’ binaries. At runtime, I call glGetActiveUniform to get uniforms info. This generates an GL_INVALID_VALUE error.
If I compile the shaders and link the programs at run-time, everything works fine.
GLuint programID = glCreateProgram();
GLenum nFormat = GetBinaryFormat();
GLsizei nSize = GetDataSize();
void* pData = GetData();
glProgramBinary(programID, nFormat, pData, nSize);
GLint linked = 0;
glGetProgramiv(progrmID, GL_LINK_STATUS, &linked);
glGetProgramiv(programID, GL_ACTIVE_UNIFORMS, &uniformsCount) ; //uniformsCount = 7
glGetProgramiv(programID, GL_ACTIVE_UNIFORM_MAX_LENGTH, &nMaxNameSize); //nMaxNameSize is 23
char szUniformName = (char)malloc(nMaxNameSize);
for (int i=0; i<uniformsCount; i++)
glGetActiveUniform(programID, i, nMaxNameSize, NULL, &nSize, &nType, szUniformName); //nSize is 0, nType is GL_FLOAT, szUniformName is not initialized
GLenum nError = glGetError(); //nError is GL_INVALID_VALUE
Do you have any idea what’s causing this?
I compile my shaders offline and save the programs' binaries
Have you checked that the offline compiler you are using matches the graphics core and driver version running on your target? Shader binaries are not portable. We only recommend using shader binaries when targeting a fixed platform. If your application needs to be portable across different graphics cores and driver versions, you can use the OpenGL ES shader binary caching extensions to reuse binaries generated at run-time. Our SDK's BinaryShader Example demonstrates how to do this.
Thanks for your reply, Joe!
I’m aware of the fact that binaries are not portable across different platforms, and I assure you that’s not the case.
The tool that saves the binaries and the application using them run on the same system, using the same drivers; I double checked and the same binary format is used on both saving and loading, and the programs link successfully and are valid.
I just tested the code above in the SDK’s BinaryShader example for OGLES3 and I get the same error.
Although glGetUniformLocation works fine and returns the uniform’s location correctly, glGetActiveUniform generates GL_INVALID_VALUE.
Can you please try it out?
As a side note, there is no example in the SDK that calls glGetActiveUniform…
What operating system are you targeting? Have you only been able to reproduce the issue on one PowerVR platform, or have you seen it on others? Can you share the graphics driver version string with us (this FAQ item explains how to retrieve it)?
I won’t be able to look into this today, but should be able to get back to you by the end of the week.
have a look in UniformBufferObject demo
What operating system are you targeting? Have you only been able to reproduce the issue on one PowerVR platform, or have you seen it on others? Can you share the graphics driver version string with us?
I only tested this on Windows7 64 bits with Nvidia GeForce GTS 450 (driver 188.8.131.5288 - 5/19/2014).
EGL version string: 1.4(PVRVFrame 10.0 (SDK 3.4@3186613))"
OGL version string: <Failed to query OpenGL ES version> (Host: 4.4.0)
Ah, I see. I’d assumed you were trying to use shader binaries on a PowerVR platform.
I will discuss the issue with the PVRVFrame lead engineer and will get back to you.
The PVRVFrame lead has found and fixed a bug for this. The fix has been implemented for our next major release (due March 2015).
Good to know…