Commit a7059008 authored by zmo@google.com's avatar zmo@google.com

2011-01-28 Zhenyao Mo <zmo@google.com>

        Reviewed by Kenneth Russell.

        uniformN*v should generate INVALID_VALUE of the array size is not a multiple of N
        https://bugs.webkit.org/show_bug.cgi?id=53306

        * html/canvas/WebGLRenderingContext.cpp:
        (WebCore::WebGLRenderingContext::validateUniformMatrixParameters):
2011-01-28  Zhenyao Mo  <zmo@google.com>

        Reviewed by Kenneth Russell.

        uniformN*v should generate INVALID_VALUE of the array size is not a multiple of N
        https://bugs.webkit.org/show_bug.cgi?id=53306

        * fast/canvas/webgl/gl-uniform-arrays-expected.txt:
        * fast/canvas/webgl/gl-uniform-arrays.html:
        * fast/canvas/webgl/gl-uniformmatrix4fv-expected.txt:
        * fast/canvas/webgl/gl-uniformmatrix4fv.html:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76988 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 21a74964
2011-01-28 Zhenyao Mo <zmo@google.com>
Reviewed by Kenneth Russell.
uniformN*v should generate INVALID_VALUE of the array size is not a multiple of N
https://bugs.webkit.org/show_bug.cgi?id=53306
* fast/canvas/webgl/gl-uniform-arrays-expected.txt:
* fast/canvas/webgl/gl-uniform-arrays.html:
* fast/canvas/webgl/gl-uniformmatrix4fv-expected.txt:
* fast/canvas/webgl/gl-uniformmatrix4fv.html:
2011-01-28 Tom Sepez <tsepez@chromium.org>
Reviewed by Eric Seidel.
......@@ -29,6 +29,7 @@ PASS 1 uniform found
PASS uniform name is 'color[0]' not 'color' as per OpenGL ES 2.0.24 section 2.10
PASS getError was expected value: INVALID_OPERATION : should fail if there is no current program
PASS getError was expected value: INVALID_VALUE : should fail with insufficient array size with gl.uniform2fv
PASS getError was expected value: INVALID_VALUE : should fail with non-multiple array size with gl.uniform2fv
PASS getError was expected value: NO_ERROR : can set an array of uniforms with gl.uniform2fv
PASS getError was expected value: NO_ERROR : can call gl.getUniform
PASS gl.getUniform returns the correct type.
......@@ -50,6 +51,7 @@ PASS 1 uniform found
PASS uniform name is 'color[0]' not 'color' as per OpenGL ES 2.0.24 section 2.10
PASS getError was expected value: INVALID_OPERATION : should fail if there is no current program
PASS getError was expected value: INVALID_VALUE : should fail with insufficient array size with gl.uniform3fv
PASS getError was expected value: INVALID_VALUE : should fail with non-multiple array size with gl.uniform3fv
PASS getError was expected value: NO_ERROR : can set an array of uniforms with gl.uniform3fv
PASS getError was expected value: NO_ERROR : can call gl.getUniform
PASS gl.getUniform returns the correct type.
......@@ -71,6 +73,7 @@ PASS 1 uniform found
PASS uniform name is 'color[0]' not 'color' as per OpenGL ES 2.0.24 section 2.10
PASS getError was expected value: INVALID_OPERATION : should fail if there is no current program
PASS getError was expected value: INVALID_VALUE : should fail with insufficient array size with gl.uniform4fv
PASS getError was expected value: INVALID_VALUE : should fail with non-multiple array size with gl.uniform4fv
PASS getError was expected value: NO_ERROR : can set an array of uniforms with gl.uniform4fv
PASS getError was expected value: NO_ERROR : can call gl.getUniform
PASS gl.getUniform returns the correct type.
......
......@@ -109,7 +109,8 @@ var typeInfos = [
return typeInfo.srcValues[index] == value;
},
srcValues: [16, 15, 14],
srcValuesBad: [],
srcValuesLess: [],
srcValuesNonMultiple: null,
},
{ type: 'vec2',
jsTypeOf: 'Float32Array',
......@@ -140,7 +141,8 @@ var typeInfos = [
typeInfo.srcValues[index * 2 + 1] == value[1];
},
srcValues: [16, 15, 14, 13, 12, 11],
srcValuesBad: [16],
srcValuesLess: [16],
srcValuesNonMultiple: [16, 15, 14, 13, 12, 11, 10],
},
{ type: 'vec3',
jsTypeOf: 'Float32Array',
......@@ -174,7 +176,8 @@ var typeInfos = [
typeInfo.srcValues[index * 3 + 2] == value[2];
},
srcValues: [16, 15, 14, 13, 12, 11, 10, 9, 8],
srcValuesBad: [16, 15],
srcValuesLess: [16, 15],
srcValuesNonMultiple: [16, 15, 14, 13, 12, 11, 10, 9, 8, 7],
},
{ type: 'vec4',
jsTypeOf: 'Float32Array',
......@@ -211,7 +214,8 @@ var typeInfos = [
typeInfo.srcValues[index * 4 + 3] == value[3];
},
srcValues: [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5],
srcValuesBad: [16, 15, 14],
srcValuesLess: [16, 15, 14],
srcValuesNonMultiple: [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4],
}
];
......@@ -231,33 +235,39 @@ for (var tt = 0; tt < typeInfos.length; ++tt) {
"uniform name is 'color[0]' not 'color' as per OpenGL ES 2.0.24 section 2.10");
var loc = gl.getUniformLocation(program, "color[0]");
var srcValues = typeInfo.srcValues;
var srcValuesBad = typeInfo.srcValuesBad;
var srcValuesLess = typeInfo.srcValuesLess;
var srcValuesNonMultiple = typeInfo.srcValuesNonMultiple;
// Try setting the value before using the program
gl[typeInfo.setter](loc, srcValues);
glErrorShouldBe(gl, gl.INVALID_OPERATION,
"should fail if there is no current program");
"should fail if there is no current program");
gl.useProgram(program);
gl[typeInfo.setter](loc, srcValuesBad);
gl[typeInfo.setter](loc, srcValuesLess);
glErrorShouldBe(gl, gl.INVALID_VALUE,
"should fail with insufficient array size with gl." + typeInfo.setter);
"should fail with insufficient array size with gl." + typeInfo.setter);
if (srcValuesNonMultiple) {
gl[typeInfo.setter](loc, srcValuesNonMultiple);
glErrorShouldBe(gl, gl.INVALID_VALUE,
"should fail with non-multiple array size with gl." + typeInfo.setter);
}
gl[typeInfo.setter](loc, srcValues);
glErrorShouldBe(gl, gl.NO_ERROR,
"can set an array of uniforms with gl." + typeInfo.setter);
"can set an array of uniforms with gl." + typeInfo.setter);
var values = gl.getUniform(program, loc);
glErrorShouldBe(gl, gl.NO_ERROR,
"can call gl.getUniform");
"can call gl.getUniform");
assertMsg(typeInfo.checkType(values),
"gl.getUniform returns the correct type.");
for (var ii = 0; ii < typeInfo.numSrcValues; ++ii) {
var elemLoc = gl.getUniformLocation(program, "color[" + ii + "]");
glErrorShouldBe(gl, gl.NO_ERROR,
"can get location of element " + ii +
" of array from gl.getUniformLocation");
"can get location of element " + ii +
" of array from gl.getUniformLocation");
var value = gl.getUniform(program, elemLoc);
glErrorShouldBe(gl, gl.NO_ERROR,
"can get value of element " + ii + " of array from gl.getUniform");
"can get value of element " + ii + " of array from gl.getUniform");
assertMsg(typeInfo.checkValue(typeInfo, ii, value),
"value put in (" + typeInfo.srcValueAsString(ii, srcValues) +
") matches value pulled out (" +
......@@ -265,7 +275,7 @@ for (var tt = 0; tt < typeInfos.length; ++tt) {
}
typeInfo.invalidSet(loc);
glErrorShouldBe(gl, gl.INVALID_OPERATION,
"using the wrong size of gl.Uniform fails");
"using the wrong size of gl.Uniform fails");
var exceptionCaught = false;
if (typeInfo.illegalSet) {
try {
......@@ -278,7 +288,7 @@ for (var tt = 0; tt < typeInfos.length; ++tt) {
gl.useProgram(null);
glErrorShouldBe(gl, gl.NO_ERROR,
"can call gl.useProgram(null)");
"can call gl.useProgram(null)");
}
debug("");
successfullyParsed = true;
......
......@@ -4,15 +4,21 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
Checking gl.uniformMatrix.
PASS should fail with insufficient array size for uniformMatrix2fv
PASS can call uniformMatrix2fvwith transpose = false
PASS uniformMatrix2fv should return INVALID_VALUE with transpose = true
PASS should fail with insufficient array size for uniformMatrix3fv
PASS can call uniformMatrix3fvwith transpose = false
PASS uniformMatrix3fv should return INVALID_VALUE with transpose = true
PASS should fail with insufficient array size for uniformMatrix4fv
PASS can call uniformMatrix4fvwith transpose = false
PASS uniformMatrix4fv should return INVALID_VALUE with transpose = true
PASS getError was expected value: INVALID_VALUE : should fail with insufficient array size for uniformMatrix2fv
PASS getError was expected value: NO_ERROR : should succeed with correct array size for uniformMatrix2fv
PASS getError was expected value: INVALID_VALUE : should fail with more than 1 array size for uniformMatrix2fv
PASS getError was expected value: NO_ERROR : can call uniformMatrix2fvwith transpose = false
PASS getError was expected value: INVALID_VALUE : uniformMatrix2fv should return INVALID_VALUE with transpose = true
PASS getError was expected value: INVALID_VALUE : should fail with insufficient array size for uniformMatrix3fv
PASS getError was expected value: NO_ERROR : should succeed with correct array size for uniformMatrix3fv
PASS getError was expected value: INVALID_VALUE : should fail with more than 1 array size for uniformMatrix3fv
PASS getError was expected value: NO_ERROR : can call uniformMatrix3fvwith transpose = false
PASS getError was expected value: INVALID_VALUE : uniformMatrix3fv should return INVALID_VALUE with transpose = true
PASS getError was expected value: INVALID_VALUE : should fail with insufficient array size for uniformMatrix4fv
PASS getError was expected value: NO_ERROR : should succeed with correct array size for uniformMatrix4fv
PASS getError was expected value: INVALID_VALUE : should fail with more than 1 array size for uniformMatrix4fv
PASS getError was expected value: NO_ERROR : can call uniformMatrix4fvwith transpose = false
PASS getError was expected value: INVALID_VALUE : uniformMatrix4fv should return INVALID_VALUE with transpose = true
PASS successfullyParsed is true
......
......@@ -40,22 +40,29 @@ debug("Checking gl.uniformMatrix.");
gl = initWebGL("example", "vshader", "fshader", [ "vPosition"], [ 0, 0, 0, 1 ], 1);
for (var ii = 2; ii <= 4; ++ii) {
var loc = gl.getUniformLocation(gl.program, "world" + ii);
var mat = [];
var matLess = [];
for (var jj = 0; jj < ii; ++jj) {
for (var ll = 0; ll < ii; ++ll) {
if (jj == ii - 1 && ll == ii - 1)
continue;
mat[jj * ii + ll] = (jj == ll) ? 1 : 0;
matLess[jj * ii + ll] = (jj == ll) ? 1 : 0;
}
}
var mat = matLess.concat([1]);
var matMore = mat.concat([1]);
name = "uniformMatrix" + ii + "fv";
gl[name](loc, false, matLess);
glErrorShouldBe(gl, gl.INVALID_VALUE, "should fail with insufficient array size for " + name);
gl[name](loc, false, mat);
assertMsg(gl.getError() == gl.INVALID_VALUE, "should fail with insufficient array size for " + name);
glErrorShouldBe(gl, gl.NO_ERROR, "should succeed with correct array size for " + name);
gl[name](loc, false, matMore);
glErrorShouldBe(gl, gl.INVALID_VALUE, "should fail with more than 1 array size for " + name);
mat[ii * ii - 1] = 1;
gl[name](loc, false, mat);
assertMsg(gl.getError() == gl.NO_ERROR, "can call " + name + "with transpose = false");
glErrorShouldBe(gl, gl.NO_ERROR, "can call " + name + "with transpose = false");
gl[name](loc, true, mat);
assertMsg(gl.getError() == gl.INVALID_VALUE, name + " should return INVALID_VALUE with transpose = true");
glErrorShouldBe(gl, gl.INVALID_VALUE, name + " should return INVALID_VALUE with transpose = true");
}
debug("");
......
2011-01-28 Zhenyao Mo <zmo@google.com>
Reviewed by Kenneth Russell.
uniformN*v should generate INVALID_VALUE of the array size is not a multiple of N
https://bugs.webkit.org/show_bug.cgi?id=53306
* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::validateUniformMatrixParameters):
2011-01-28 Tom Sepez <tsepez@chromium.org>
Reviewed by Eric Seidel.
......@@ -4390,7 +4390,7 @@ bool WebGLRenderingContext::validateUniformMatrixParameters(const WebGLUniformLo
m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
return false;
}
if (size < requiredMinSize) {
if (size < requiredMinSize || (size % requiredMinSize)) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
return false;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment