--- a/dom/canvas/test/webgl-conf/checkout/conformance/extensions/oes-vertex-array-object.html
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/extensions/oes-vertex-array-object.html
@@ -121,33 +121,33 @@ function runSupportedTest(extensionEnabl
testPassed("OES_vertex_array_object not listed as supported and getExtension failed -- this is legal");
}
}
}
function runBindingTestDisabled() {
debug("");
debug("Testing binding enum with extension disabled");
-
+
// Use the constant directly as we don't have the extension
var VERTEX_ARRAY_BINDING_OES = 0x85B5;
-
+
gl.getParameter(VERTEX_ARRAY_BINDING_OES);
wtu.glErrorShouldBe(gl, gl.INVALID_ENUM, "VERTEX_ARRAY_BINDING_OES should not be queryable if extension is disabled");
}
function runBindingTestEnabled() {
debug("");
debug("Testing binding enum with extension enabled");
-
+
shouldBe("ext.VERTEX_ARRAY_BINDING_OES", "0x85B5");
-
+
gl.getParameter(ext.VERTEX_ARRAY_BINDING_OES);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "VERTEX_ARRAY_BINDING_OES query should succeed if extension is enabled");
-
+
// Default value is null
if (gl.getParameter(ext.VERTEX_ARRAY_BINDING_OES) === null) {
testPassed("Default value of VERTEX_ARRAY_BINDING_OES is null");
} else {
testFailed("Default value of VERTEX_ARRAY_BINDING_OES is not null");
}
debug("");
@@ -174,88 +174,88 @@ function runBindingTestEnabled() {
ext.bindVertexArrayOES(null);
shouldBeNull("gl.getParameter(ext.VERTEX_ARRAY_BINDING_OES)");
ext.deleteVertexArrayOES(vao1);
}
function runObjectTest() {
debug("");
debug("Testing object creation");
-
+
vao = ext.createVertexArrayOES();
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "createVertexArrayOES should not set an error");
shouldBeNonNull("vao");
-
+
// Expect false if never bound
shouldBeFalse("ext.isVertexArrayOES(vao)");
ext.bindVertexArrayOES(vao);
shouldBeTrue("ext.isVertexArrayOES(vao)");
ext.bindVertexArrayOES(null);
shouldBeTrue("ext.isVertexArrayOES(vao)");
-
+
shouldBeFalse("ext.isVertexArrayOES(null)");
-
+
ext.deleteVertexArrayOES(vao);
vao = null;
}
function runAttributeTests() {
debug("");
debug("Testing attributes work across bindings");
-
+
var states = [];
-
+
var attrCount = gl.getParameter(gl.MAX_VERTEX_ATTRIBS);
for (var n = 0; n < attrCount; n++) {
gl.bindBuffer(gl.ARRAY_BUFFER, null);
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
-
+
var state = {};
states.push(state);
-
+
var vao = state.vao = ext.createVertexArrayOES();
ext.bindVertexArrayOES(vao);
-
+
var enableArray = (n % 2 == 0);
if (enableArray) {
gl.enableVertexAttribArray(n);
} else {
gl.disableVertexAttribArray(n);
}
-
+
if (enableArray) {
var buffer = state.buffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW);
-
+
gl.vertexAttribPointer(n, 1 + n % 4, gl.FLOAT, true, n * 4, n * 4);
}
-
+
if (enableArray) {
var elbuffer = state.elbuffer = gl.createBuffer();
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, elbuffer);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, 1024, gl.STATIC_DRAW);
}
-
+
ext.bindVertexArrayOES(null);
}
-
+
var anyMismatch = false;
for (var n = 0; n < attrCount; n++) {
var state = states[n];
-
+
ext.bindVertexArrayOES(state.vao);
-
+
var shouldBeEnabled = (n % 2 == 0);
var isEnabled = gl.getVertexAttrib(n, gl.VERTEX_ATTRIB_ARRAY_ENABLED);
if (shouldBeEnabled != isEnabled) {
testFailed("VERTEX_ATTRIB_ARRAY_ENABLED not preserved");
anyMismatch = true;
}
-
+
var buffer = gl.getVertexAttrib(n, gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING);
if (shouldBeEnabled) {
if (buffer == state.buffer) {
// Matched
if ((gl.getVertexAttrib(n, gl.VERTEX_ATTRIB_ARRAY_SIZE) == 1 + n % 4) &&
(gl.getVertexAttrib(n, gl.VERTEX_ATTRIB_ARRAY_TYPE) == gl.FLOAT) &&
(gl.getVertexAttrib(n, gl.VERTEX_ATTRIB_ARRAY_NORMALIZED) == true) &&
(gl.getVertexAttrib(n, gl.VERTEX_ATTRIB_ARRAY_STRIDE) == n * 4) &&
@@ -271,17 +271,17 @@ function runAttributeTests() {
}
} else {
// GL_CURRENT_VERTEX_ATTRIB is not preserved
if (buffer) {
testFailed("VERTEX_ATTRIB_ARRAY_BUFFER_BINDING not preserved");
anyMismatch = true;
}
}
-
+
var elbuffer = gl.getParameter(gl.ELEMENT_ARRAY_BUFFER_BINDING);
if (shouldBeEnabled) {
if (elbuffer == state.elbuffer) {
// Matched
} else {
testFailed("ELEMENT_ARRAY_BUFFER_BINDING not preserved");
anyMismatch = true;
}
@@ -293,81 +293,81 @@ function runAttributeTests() {
anyMismatch = true;
}
}
}
ext.bindVertexArrayOES(null);
if (!anyMismatch) {
testPassed("All attributes preserved across bindings");
}
-
+
for (var n = 0; n < attrCount; n++) {
var state = states[n];
ext.deleteVertexArrayOES(state.vao);
}
}
function runAttributeValueTests() {
debug("");
debug("Testing that attribute values are not attached to bindings");
-
+
var v;
var vao0 = ext.createVertexArrayOES();
var anyFailed = false;
-
+
ext.bindVertexArrayOES(null);
gl.vertexAttrib4f(0, 0, 1, 2, 3);
-
+
v = gl.getVertexAttrib(0, gl.CURRENT_VERTEX_ATTRIB);
if (!(v[0] == 0 && v[1] == 1 && v[2] == 2 && v[3] == 3)) {
testFailed("Vertex attrib value not round-tripped?");
anyFailed = true;
}
-
+
ext.bindVertexArrayOES(vao0);
-
+
v = gl.getVertexAttrib(0, gl.CURRENT_VERTEX_ATTRIB);
if (!(v[0] == 0 && v[1] == 1 && v[2] == 2 && v[3] == 3)) {
testFailed("Vertex attrib value reset across bindings");
anyFailed = true;
}
-
+
gl.vertexAttrib4f(0, 4, 5, 6, 7);
ext.bindVertexArrayOES(null);
-
+
v = gl.getVertexAttrib(0, gl.CURRENT_VERTEX_ATTRIB);
if (!(v[0] == 4 && v[1] == 5 && v[2] == 6 && v[3] == 7)) {
testFailed("Vertex attrib value bound to buffer");
anyFailed = true;
}
-
+
if (!anyFailed) {
testPassed("Vertex attribute values are not attached to bindings")
}
-
+
ext.bindVertexArrayOES(null);
ext.deleteVertexArrayOES(vao0);
}
function runDrawTests() {
debug("");
debug("Testing draws with various VAO bindings");
-
+
canvas.width = 50; canvas.height = 50;
gl.viewport(0, 0, canvas.width, canvas.height);
-
+
var vao0 = ext.createVertexArrayOES();
var vao1 = ext.createVertexArrayOES();
var vao2 = ext.createVertexArrayOES();
var positionLocation = 0;
var colorLocation = 1;
-
+
var program = wtu.setupSimpleVertexColorProgram(gl, positionLocation, colorLocation);
-
+
function setupQuad(s, colorsInArray) {
var vertexObject = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
1.0 * s, 1.0 * s, 0.0,
-1.0 * s, 1.0 * s, 0.0,
-1.0 * s, -1.0 * s, 0.0,
1.0 * s, 1.0 * s, 0.0,
@@ -388,17 +388,17 @@ function runDrawTests() {
0.0, 0.0, 0.0, 1.0,
0.0, 0.0, 0.0, 1.0]), gl.STATIC_DRAW);
gl.enableVertexAttribArray(colorLocation);
gl.vertexAttribPointer(colorLocation, 4, gl.FLOAT, false, 0, 0);
} else {
gl.disableVertexAttribArray(colorLocation);
}
};
-
+
function verifyDiagonalPixels(s, expectedInside, drawDescription) {
// Tests pixels along a diagonal running from the center of the canvas to the (0, 0) corner.
// Values on the points list indicate relative position along this diagonal.
var points = [0.0, 0.2, 0.4, 0.6, 0.8, 1.0];
for (var n = 0; n < points.length; n++) {
var expected = points[n] <= s ? expectedInside : 255;
var x = Math.round((1 - points[n]) * canvas.width / 2);
var y = Math.round((1 - points[n]) * canvas.height / 2);
@@ -406,28 +406,28 @@ function runDrawTests() {
"Drawing " + drawDescription + " should pass", 2);
}
};
function verifyDraw(drawDescription, s, colorsInArray) {
wtu.clearAndDrawUnitQuad(gl);
var expectedInside = colorsInArray ? 0 : 128;
verifyDiagonalPixels(s, expectedInside, drawDescription);
};
-
+
// Setup all bindings
setupQuad(1, true);
ext.bindVertexArrayOES(vao0);
setupQuad(0.5, true);
ext.bindVertexArrayOES(vao1);
setupQuad(0.25, true);
ext.bindVertexArrayOES(vao2);
setupQuad(0.75, false);
gl.vertexAttrib4f(colorLocation, 0.5, 0.5, 0.5, 1);
-
+
// Verify drawing
ext.bindVertexArrayOES(null);
verifyDraw("with the default VAO", 1, true);
ext.bindVertexArrayOES(vao0);
verifyDraw("with VAO #0", 0.5, true);
ext.bindVertexArrayOES(vao1);
verifyDraw("with VAO #1", 0.25, true);
ext.bindVertexArrayOES(vao2);
@@ -619,35 +619,41 @@ function runBoundDeleteTests() {
// delete the color buffers AND the position buffer, that are bound to the current VAO
for (var ii = 0; ii < vaos.length; ++ii) {
ext.bindVertexArrayOES(vaos[ii]);
gl.deleteBuffer(colorBuffer);
gl.deleteBuffer(positionBuffer);
- // The buffers should not be accessible at this point. Deleted objects that are bound
- // in the current context undergo an automatic unbinding
+ var expectRetained = (ii != 0);
+ var shouldBeStr = (expectRetained ? "retained" : "cleared");
+
var boundPositionBuffer = gl.getVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING);
- if(boundPositionBuffer == positionBuffer) {
- testFailed("Position buffer should be automatically unbound when deleted");
+ if (expectRetained != (boundPositionBuffer == positionBuffer)) {
+ testFailed("Position attrib stored buffer should be " + shouldBeStr + ".");
}
+
var boundColorBuffer = gl.getVertexAttrib(1, gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING);
- if(boundColorBuffer == colorBuffer) {
- testFailed("Color buffer should be automatically unbound when deleted");
+ if (expectRetained != (boundColorBuffer == colorBuffer)) {
+ testFailed("Color attrib stored buffer should be " + shouldBeStr + ".");
}
+ // If retained, everything should still work. If cleared, drawing should now fail.
gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_BYTE, 0);
- wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "Draw call should fail with unbound position and color buffers");
+ var expectedError = (expectRetained ? gl.NO_ERROR : gl.INVALID_OPERATION);
+ wtu.glErrorShouldBe(gl, expectedError,
+ "Draw call should " + (expectRetained ? "not " : "") + "fail.");
- var isPositionBuffer = gl.isBuffer(positionBuffer);
- var isColorBuffer = gl.isBuffer(colorBuffer);
-
- if(isPositionBuffer) testFailed("Position buffer should no longer exist after last ref removed");
- if(isColorBuffer) testFailed("Color buffer should no longer exist after last ref removed");
+ if (!gl.isBuffer(positionBuffer)) {
+ testFailed("Position buffer should count for isBuffer.");
+ }
+ if (!gl.isBuffer(colorBuffer)) {
+ testFailed("Color buffer should count for isBuffer.");
+ }
}
}
function runArrayBufferBindTests() {
debug("");
debug("Testing that buffer bindings on VAOs don't affect default VAO ARRAY_BUFFER binding.");
ext.bindVertexArrayOES(null);