PASS 1 uniform found
PASS uniform name is 'color[0]' not 'color' as per OpenGL ES 2.0.24 section 2.10
PASS should fail if there is no current program
+PASS should fail with insufficient array size with gl.uniform1fv
PASS can set an array of uniforms with gl.uniform1fv
PASS can call gl.getUniform
PASS gl.getUniform returns the correct type.
PASS 1 uniform found
PASS uniform name is 'color[0]' not 'color' as per OpenGL ES 2.0.24 section 2.10
PASS should fail if there is no current program
+PASS should fail with insufficient array size with gl.uniform2fv
PASS can set an array of uniforms with gl.uniform2fv
PASS can call gl.getUniform
PASS gl.getUniform returns the correct type.
PASS 1 uniform found
PASS uniform name is 'color[0]' not 'color' as per OpenGL ES 2.0.24 section 2.10
PASS should fail if there is no current program
+PASS should fail with insufficient array size with gl.uniform3fv
PASS can set an array of uniforms with gl.uniform3fv
PASS can call gl.getUniform
PASS gl.getUniform returns the correct type.
PASS value put in ([13, 12, 11]) matches value pulled out ([13, 12, 11])
PASS can get location of element 2 of array from gl.getUniformLocation
PASS can get value of element 2 of array from gl.getUniform
-PASS value put in ([10, 11, 9]) matches value pulled out ([10, 11, 9])
+PASS value put in ([10, 9, 8]) matches value pulled out ([10, 9, 8])
PASS using the wrong size of gl.Uniform fails
PASS can call gl.useProgram(null)
PASS 1 uniform found
PASS uniform name is 'color[0]' not 'color' as per OpenGL ES 2.0.24 section 2.10
PASS should fail if there is no current program
+PASS should fail with insufficient array size with gl.uniform4fv
PASS can set an array of uniforms with gl.uniform4fv
PASS can call gl.getUniform
PASS gl.getUniform returns the correct type.
PASS value put in ([16, 15, 14, 13]) matches value pulled out ([16, 15, 14, 13])
PASS can get location of element 1 of array from gl.getUniformLocation
PASS can get value of element 1 of array from gl.getUniform
-PASS value put in ([12, 11, 10, 11]) matches value pulled out ([12, 11, 10, 11])
+PASS value put in ([12, 11, 10, 9]) matches value pulled out ([12, 11, 10, 9])
PASS can get location of element 2 of array from gl.getUniformLocation
PASS can get value of element 2 of array from gl.getUniform
-PASS value put in ([9, 8, 7, 6]) matches value pulled out ([9, 8, 7, 6])
+PASS value put in ([8, 7, 6, 5]) matches value pulled out ([8, 7, 6, 5])
PASS using the wrong size of gl.Uniform fails
PASS can call gl.useProgram(null)
checkValue: function(typeInfo, index, value) {
return typeInfo.srcValues[index] == value;
},
- srcValues: [16, 15, 14]
+ srcValues: [16, 15, 14],
+ srcValuesBad: [],
},
{ type: 'vec2',
jsTypeOf: 'Float32Array',
typeInfo.srcValues[index * 2 + 1] == value[1];
},
srcValues: [16, 15, 14, 13, 12, 11],
+ srcValuesBad: [16],
},
{ type: 'vec3',
jsTypeOf: 'Float32Array',
typeInfo.srcValues[index * 3 + 1] == value[1] &&
typeInfo.srcValues[index * 3 + 2] == value[2];
},
- srcValues: [16, 15, 14, 13, 12, 11, 10, 11, 9],
+ srcValues: [16, 15, 14, 13, 12, 11, 10, 9, 8],
+ srcValuesBad: [16, 15],
},
{ type: 'vec4',
jsTypeOf: 'Float32Array',
typeInfo.srcValues[index * 4 + 2] == value[2] &&
typeInfo.srcValues[index * 4 + 3] == value[3];
},
- srcValues: [16, 15, 14, 13, 12, 11, 10, 11, 9, 8, 7, 6, 5],
+ srcValues: [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5],
+ srcValuesBad: [16, 15, 14],
}
];
"uniform name is 'color[0]' not 'color' as per OpenGL ES 2.0.24 section 2.10");
var loc = gl.getUniformLocation(program, "color");
var srcValues = typeInfo.srcValues;
+ var srcValuesBad = typeInfo.srcValuesBad;
// Try setting the value before using the program
gl[typeInfo.setter](loc, srcValues);
"should fail if there is no current program");
gl.useProgram(program);
+ gl[typeInfo.setter](loc, srcValuesBad);
+ assertMsg(gl.getError() == gl.INVALID_VALUE,
+ "should fail with insufficient array size with gl." + typeInfo.setter);
gl[typeInfo.setter](loc, srcValues);
assertMsg(gl.getError() == gl.NO_ERROR,
"can set an array of uniforms with gl." + typeInfo.setter);
void WebGLRenderingContext::uniform1fv(const WebGLUniformLocation* location, Float32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location)
- return;
-
- if (location->program() != m_currentProgram) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+ if (!validateUniformParameters(location, v, 1))
return;
- }
- if (!v) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
- }
m_context->uniform1fv(location->location(), v->data(), v->length());
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniform1fv(const WebGLUniformLocation* location, float* v, int size, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location)
- return;
-
- if (location->program() != m_currentProgram) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+ if (!validateUniformParameters(location, v, size, 1))
return;
- }
- if (!v) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
- }
m_context->uniform1fv(location->location(), v, size);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniform1iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location)
+ if (!validateUniformParameters(location, v, 1))
return;
- if (location->program() != m_currentProgram) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
- return;
- }
-
- if (!v) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
- }
m_context->uniform1iv(location->location(), v->data(), v->length());
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniform1iv(const WebGLUniformLocation* location, int* v, int size, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location)
- return;
-
- if (location->program() != m_currentProgram) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+ if (!validateUniformParameters(location, v, size, 1))
return;
- }
- if (!v) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
- }
m_context->uniform1iv(location->location(), v, size);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniform2fv(const WebGLUniformLocation* location, Float32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location)
+ if (!validateUniformParameters(location, v, 2))
return;
- if (location->program() != m_currentProgram) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
- return;
- }
-
- if (!v) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
- }
- // FIXME: length needs to be a multiple of 2
m_context->uniform2fv(location->location(), v->data(), v->length() / 2);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniform2fv(const WebGLUniformLocation* location, float* v, int size, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location)
- return;
-
- if (location->program() != m_currentProgram) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+ if (!validateUniformParameters(location, v, size, 2))
return;
- }
- if (!v) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
- }
- // FIXME: length needs to be a multiple of 2
m_context->uniform2fv(location->location(), v, size / 2);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniform2iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location)
- return;
-
- if (location->program() != m_currentProgram) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+ if (!validateUniformParameters(location, v, 2))
return;
- }
- if (!v) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
- }
- // FIXME: length needs to be a multiple of 2
m_context->uniform2iv(location->location(), v->data(), v->length() / 2);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniform2iv(const WebGLUniformLocation* location, int* v, int size, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location)
+ if (!validateUniformParameters(location, v, size, 2))
return;
- if (location->program() != m_currentProgram) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
- return;
- }
-
- if (!v) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
- }
- // FIXME: length needs to be a multiple of 2
m_context->uniform2iv(location->location(), v, size / 2);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniform3fv(const WebGLUniformLocation* location, Float32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location)
+ if (!validateUniformParameters(location, v, 3))
return;
- if (location->program() != m_currentProgram) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
- return;
- }
-
- if (!v) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
- }
- // FIXME: length needs to be a multiple of 3
m_context->uniform3fv(location->location(), v->data(), v->length() / 3);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniform3fv(const WebGLUniformLocation* location, float* v, int size, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location)
+ if (!validateUniformParameters(location, v, size, 3))
return;
- if (location->program() != m_currentProgram) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
- return;
- }
-
- if (!v) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
- }
- // FIXME: length needs to be a multiple of 3
m_context->uniform3fv(location->location(), v, size / 3);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniform3iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location)
- return;
-
- if (location->program() != m_currentProgram) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+ if (!validateUniformParameters(location, v, 3))
return;
- }
- if (!v) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
- }
- // FIXME: length needs to be a multiple of 3
m_context->uniform3iv(location->location(), v->data(), v->length() / 3);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniform3iv(const WebGLUniformLocation* location, int* v, int size, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location)
- return;
-
- if (location->program() != m_currentProgram) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+ if (!validateUniformParameters(location, v, size, 3))
return;
- }
- if (!v) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
- }
- // FIXME: length needs to be a multiple of 3
m_context->uniform3iv(location->location(), v, size / 3);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniform4fv(const WebGLUniformLocation* location, Float32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location)
- return;
-
- if (location->program() != m_currentProgram) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+ if (!validateUniformParameters(location, v, 4))
return;
- }
- if (!v) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
- }
- // FIXME: length needs to be a multiple of 4
m_context->uniform4fv(location->location(), v->data(), v->length() / 4);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniform4fv(const WebGLUniformLocation* location, float* v, int size, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location)
- return;
-
- if (location->program() != m_currentProgram) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+ if (!validateUniformParameters(location, v, size, 4))
return;
- }
- if (!v) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
- }
- // FIXME: length needs to be a multiple of 4
m_context->uniform4fv(location->location(), v, size / 4);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniform4iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location)
+ if (!validateUniformParameters(location, v, 4))
return;
- if (location->program() != m_currentProgram) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
- return;
- }
-
- if (!v) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
- }
- // FIXME: length needs to be a multiple of 4
m_context->uniform4iv(location->location(), v->data(), v->length() / 4);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniform4iv(const WebGLUniformLocation* location, int* v, int size, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location)
+ if (!validateUniformParameters(location, v, size, 4))
return;
- if (location->program() != m_currentProgram) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
- return;
- }
-
- if (!v) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
- }
- // FIXME: length needs to be a multiple of 4
m_context->uniform4iv(location->location(), v, size / 4);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniformMatrix2fv(const WebGLUniformLocation* location, bool transpose, Float32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!validateUniformMatrixParameters(location, transpose, v))
+ if (!validateUniformMatrixParameters(location, transpose, v, 4))
return;
- // FIXME: length needs to be a multiple of 4
m_context->uniformMatrix2fv(location->location(), transpose, v->data(), v->length() / 4);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniformMatrix2fv(const WebGLUniformLocation* location, bool transpose, float* v, int size, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!validateUniformMatrixParameters(location, transpose, v))
+ if (!validateUniformMatrixParameters(location, transpose, v, size, 4))
return;
- // FIXME: length needs to be a multiple of 4
m_context->uniformMatrix2fv(location->location(), transpose, v, size / 4);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniformMatrix3fv(const WebGLUniformLocation* location, bool transpose, Float32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!validateUniformMatrixParameters(location, transpose, v))
+ if (!validateUniformMatrixParameters(location, transpose, v, 9))
return;
- // FIXME: length needs to be a multiple of 9
m_context->uniformMatrix3fv(location->location(), transpose, v->data(), v->length() / 9);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniformMatrix3fv(const WebGLUniformLocation* location, bool transpose, float* v, int size, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!validateUniformMatrixParameters(location, transpose, v))
+ if (!validateUniformMatrixParameters(location, transpose, v, size, 9))
return;
- // FIXME: length needs to be a multiple of 9
m_context->uniformMatrix3fv(location->location(), transpose, v, size / 9);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniformMatrix4fv(const WebGLUniformLocation* location, bool transpose, Float32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!validateUniformMatrixParameters(location, transpose, v))
+ if (!validateUniformMatrixParameters(location, transpose, v, 16))
return;
- // FIXME: length needs to be a multiple of 16
m_context->uniformMatrix4fv(location->location(), transpose, v->data(), v->length() / 16);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::uniformMatrix4fv(const WebGLUniformLocation* location, bool transpose, float* v, int size, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!validateUniformMatrixParameters(location, transpose, v))
+ if (!validateUniformMatrixParameters(location, transpose, v, size, 16))
return;
- // FIXME: length needs to be a multiple of 16
m_context->uniformMatrix4fv(location->location(), transpose, v, size / 16);
cleanupAfterGraphicsCall(false);
}
}
}
-bool WebGLRenderingContext::validateUniformMatrixParameters(const WebGLUniformLocation* location, bool transpose, void* v)
+bool WebGLRenderingContext::validateUniformParameters(const WebGLUniformLocation* location, Float32Array* v, int requiredMinSize)
+{
+ if (!v) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ return false;
+ }
+ return validateUniformMatrixParameters(location, false, v->data(), v->length(), requiredMinSize);
+}
+
+bool WebGLRenderingContext::validateUniformParameters(const WebGLUniformLocation* location, Int32Array* v, int requiredMinSize)
+{
+ if (!v) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ return false;
+ }
+ return validateUniformMatrixParameters(location, false, v->data(), v->length(), requiredMinSize);
+}
+
+bool WebGLRenderingContext::validateUniformParameters(const WebGLUniformLocation* location, void* v, int size, int requiredMinSize)
+{
+ return validateUniformMatrixParameters(location, false, v, size, requiredMinSize);
+}
+
+bool WebGLRenderingContext::validateUniformMatrixParameters(const WebGLUniformLocation* location, bool transpose, Float32Array* v, int requiredMinSize)
+{
+ if (!v) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ return false;
+ }
+ return validateUniformMatrixParameters(location, transpose, v->data(), v->length(), requiredMinSize);
+}
+
+bool WebGLRenderingContext::validateUniformMatrixParameters(const WebGLUniformLocation* location, bool transpose, void* v, int size, int requiredMinSize)
{
if (!location)
return false;
m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
return false;
}
+ if (size < requiredMinSize) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ return false;
+ }
return true;
}