Closed Bug 924264 Opened 11 years ago Closed 11 years ago

webgl glUniform*fv() on a location pointing to a nonzero array index of an uniform array fails.

Categories

(Core :: Graphics: CanvasWebGL, defect)

x86
Windows 8
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla27

People

(Reporter: jujjyl, Assigned: jujjyl)

References

(Blocks 1 open bug)

Details

(Whiteboard: [games] webgl-conformance webgl-test-needed)

Attachments

(1 file, 1 obsolete file)

Tested on 32-bit Firefox browser on 64-bit Windows 8:

Visit page http://clb.demon.fi/dump/bugs/uniform_arrays_bug.html

Expected: should get an orange triangle.
Firefox result: a red triangle is rendered instead.

The example application tests arrays of uniforms in GLSL shaders. Consider

vec3 colors[3];

You should be able to do gl.getUniformLocation(program, "colors[1]"); to get the location of the second index of the array, and then be able to call gl.uniform3fv(loc, [ 0,0.7,0, 0,0,0.3, 1,1,1 ] ); to set the values.

Another test case, visit http://clb.demon.fi/dump/bugs/uniform_arrays_bug_emscripten.html :

It should print "OK: Case i passed." for i in [0,1,2,3]. Instead, Firefox fails to run cases 2 and 3.

Noting that issue https://bugzilla.mozilla.org/show_bug.cgi?id=812164 is about the same kind of issue, but different OS and possibly a narrower test case.
Whiteboard: [games]
Interesting. I wonder if that is the same bug as whatever is making us fail (apparently, throw an exception) in

  https://www.khronos.org/registry/webgl/sdk/tests/conformance/uniforms/gl-uniform-arrays.html

In any case, flagging this webgl-conformance - please use that flag for all webgl conformance bugs. See https://wiki.mozilla.org/Platform/GFX/WebGL/Resources#Bug_tracking
Whiteboard: [games] → [games] webgl-conformance
Thanks, will do.

When running that conformance test URL in Firefox and Chrome, I see the same output, and both browsers report having run the same set of tests (that I could see), give green PASS on all tests, and no FAIL messages, and report green TEST COMPLETE. I do not get an exception being thrown.

In web console of Firefox, I do see similar kind of errors than in my testcases, i.e. "Error: WebGL: Uniform3fv: expected an array of length a multiple of 3, got an array of length 10 @ https://www.khronos.org/registry/webgl/sdk/tests/conformance/uniforms/gl-uniform-arrays.html:255". The full web console in Firefox is:

[05:48:10.485] "requestAnimationFrame"
[05:48:10.485] "cancelAnimationFrame"
[05:48:10.502] Error: WebGL: Uniform1fv: no program is currently bound @ https://www.khronos.org/registry/webgl/sdk/tests/conformance/uniforms/gl-uniform-arrays.html:246
[05:48:10.503] Error: WebGL: Uniform1fv: expected an array of length a multiple of 1, got an array of length 0 @ https://www.khronos.org/registry/webgl/sdk/tests/conformance/uniforms/gl-uniform-arrays.html:251
[05:48:10.503] Error: WebGL: Uniform2fv: this function expected a uniform of element size 2, got a uniform of element size 1 @ https://www.khronos.org/registry/webgl/sdk/tests/conformance/uniforms/gl-uniform-arrays.html:92
[05:48:10.510] Error: WebGL: Uniform2fv: no program is currently bound @ https://www.khronos.org/registry/webgl/sdk/tests/conformance/uniforms/gl-uniform-arrays.html:246
[05:48:10.510] Error: WebGL: Uniform2fv: expected an array of length a multiple of 2, got an array of length 1 @ https://www.khronos.org/registry/webgl/sdk/tests/conformance/uniforms/gl-uniform-arrays.html:251
[05:48:10.510] Error: WebGL: Uniform2fv: expected an array of length a multiple of 2, got an array of length 7 @ https://www.khronos.org/registry/webgl/sdk/tests/conformance/uniforms/gl-uniform-arrays.html:255
[05:48:10.511] Error: WebGL: Uniform1fv: this function expected a uniform of element size 1, got a uniform of element size 2 @ https://www.khronos.org/registry/webgl/sdk/tests/conformance/uniforms/gl-uniform-arrays.html:118
[05:48:10.518] Error: WebGL: Uniform3fv: no program is currently bound @ https://www.khronos.org/registry/webgl/sdk/tests/conformance/uniforms/gl-uniform-arrays.html:246
[05:48:10.518] Error: WebGL: Uniform3fv: expected an array of length a multiple of 3, got an array of length 2 @ https://www.khronos.org/registry/webgl/sdk/tests/conformance/uniforms/gl-uniform-arrays.html:251
[05:48:10.519] Error: WebGL: Uniform3fv: expected an array of length a multiple of 3, got an array of length 10 @ https://www.khronos.org/registry/webgl/sdk/tests/conformance/uniforms/gl-uniform-arrays.html:255
[05:48:10.519] Error: WebGL: Uniform1fv: this function expected a uniform of element size 1, got a uniform of element size 3 @ https://www.khronos.org/registry/webgl/sdk/tests/conformance/uniforms/gl-uniform-arrays.html:152
[05:48:10.526] Error: WebGL: Uniform4fv: no program is currently bound @ https://www.khronos.org/registry/webgl/sdk/tests/conformance/uniforms/gl-uniform-arrays.html:246
[05:48:10.526] Error: WebGL: Uniform4fv: expected an array of length a multiple of 4, got an array of length 3 @ https://www.khronos.org/registry/webgl/sdk/tests/conformance/uniforms/gl-uniform-arrays.html:251
[05:48:10.526] Error: WebGL: Uniform4fv: expected an array of length a multiple of 4, got an array of length 13 @ https://www.khronos.org/registry/webgl/sdk/tests/conformance/uniforms/gl-uniform-arrays.html:255
[05:48:10.527] Error: WebGL: Uniform1fv: this function expected a uniform of element size 1, got a uniform of element size 4 @ https://www.khronos.org/registry/webgl/sdk/tests/conformance/uniforms/gl-uniform-arrays.html:189

Although Chrome does report similar kind of messages in its web console:

requestAnimationFrame webgl-test-utils.js:2072
cancelAnimationFrame webgl-test-utils.js:2072
WebGL: INVALID_OPERATION: uniform1fv: location is not from current program gl-uniform-arrays.html:1
WebGL: INVALID_VALUE: uniform1fv: invalid size gl-uniform-arrays.html:1
WebGL: INVALID_OPERATION: uniform2fv: location is not from current program gl-uniform-arrays.html:1
2
WebGL: INVALID_VALUE: uniform2fv: invalid size gl-uniform-arrays.html:1
WebGL: INVALID_OPERATION: uniform3fv: location is not from current program gl-uniform-arrays.html:1
2
WebGL: INVALID_VALUE: uniform3fv: invalid size gl-uniform-arrays.html:1
WebGL: INVALID_OPERATION: uniform4fv: location is not from current program gl-uniform-arrays.html:1
2
WebGL: INVALID_VALUE: uniform4fv: invalid size gl-uniform-arrays.html:1
[.WebGLRenderingContext]GL ERROR :GL_INVALID_OPERATION : glUniform2fv: wrong uniform function for type gl-uniform-arrays.html:1
3
[.WebGLRenderingContext]GL ERROR :GL_INVALID_OPERATION : glUniform1fv: wrong uniform function for type gl-uniform-arrays.html:1
Rereading with fresh eyes today, I think I wrote the title of the bug a bit silly. In the bug, calling glGetUniformLocation with a nonzero index is not the call that actually fails, but trying to use the location with glUniform*fv is the place where the failure occurs.
Summary: webgl getUniformLocation() for a nonzero array index fails. → webgl glUniform*fv() on a location pointing to a nonzero array index of an uniform array fails.
(fwiw, many of the errors in the console from the conformance test are expected -- it's testing that INVALID_OPERATION is generated, we just happen to report when that happens as well)
This patch was written by jukka 'over the phone'. It removes a code block for which I do not remember the justification; it makes his testcase work; and it does not regress relevant WebGL 1.0.3 conformance tests. So, r+ from me.
Attachment #814528 - Flags: review+
Refreshed with Jukka's identity and a commit message. Ready for landing once we have green tryserver results.
Attachment #814528 - Attachment is obsolete: true
Attachment #814535 - Flags: review+
It is a bit scary that this wasn't caught by any conformance test. Putting webgl-test-needed bug so we don't forget it. Note: bugzilla search links here:

https://wiki.mozilla.org/Platform/GFX/WebGL/Resources#Bug_tracking
Whiteboard: [games] webgl-conformance → [games] webgl-conformance webgl-test-needed
https://hg.mozilla.org/mozilla-central/rev/a1c2b374bc94
Assignee: nobody → jujjyl
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla27
Blocks: gecko-games
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: