Forums - Shader uniform issue

4 posts / 0 new
Last post
Shader uniform issue
Sonicadvance1
Join Date: 2 Nov 12
Posts: 51
Posted: Sun, 2013-05-26 22:16

When building a shader with a uniform array, say vec4 Array[4];

If you try setting it with a offset of offset % 4 != 0 so glUniform4fv(glGetUniformLocation(progID, "Array") + 3, 4, floatArray); The driver won't pick it up, fails out with a 

W/Adreno200-ES20( 8930): <__load_uniform_float:800>: GL_INVALID_OPERATION

I was expecting that accessing arrays of vec4 arrays at "strange" offsets would work since it works on all desktop drivers.

Hopefully you guys can get this working without much trouble.

  • Up0
  • Down0
mhfeldma Moderator
Join Date: 29 Nov 12
Posts: 310
Posted: Tue, 2013-05-28 07:43

Hi..

Agree that the behavior is different on desktop drivers.  This has come up before and we investigated and concluded that according to the GLSL spec (https://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1....) for ES2.0 (and ES3.0) support for indexing sampler arrays with a constant-index-expression is mandated, but support for indexing with other values in not mandated.

Hopefully you can work around this in your shader.

 

  • Up0
  • Down0
Sonicadvance1
Join Date: 2 Nov 12
Posts: 51
Posted: Fri, 2013-05-31 07:18

Sad that supporting it won't be the route to go to instead. Would make it a lot easier to test my non-UBO path.

Chalk it up to another thing I've got to add vendor specific workarounds for.

  • Up0
  • Down0
mhfeldma Moderator
Join Date: 29 Nov 12
Posts: 310
Posted: Fri, 2013-05-31 11:34

I actually misinterrupted the issue, though the result is the same...It looks like you are asking about loading values to array of uniforms, using a location where no variable name exists.

The OpenGL ES Spec https://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf specifically disallows this and requires the ES driver to return an error: If any of the following conditions occur, an INVALID_OPERATION error is generated by the Uniform* commands, and no uniform values are changed:

if the size indicated in the name of the Uniform* command used does not match the size of the uniform declared in the shader,

if the uniform declared in the shader is not of type boolean and the type indicated in the name of the Uniform* command used does not match the type of the uniform,

  • if count is greater than one, and the uniform declared in the shader is not an array variable,
  •  
  • if no variable with a location of location exists in the program object currently in use and location is not -1, or
  • if there is no program object currently in use.
  •  

Note that similar language is present in the OpenGL Desktop specs, so if other desktop implementations are not enforcing this, it would appear they are not conformant to the GL spec.

 

 

  • 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.