summaryrefslogtreecommitdiffstats
path: root/dom/canvas/test/webgl-conf/checkout/conformance/limits
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/limits/00_test_list.txt6
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/limits/gl-line-width.html72
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/limits/gl-max-texture-dimensions.html109
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/limits/gl-min-attribs.html86
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/limits/gl-min-textures.html81
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/limits/gl-min-uniforms.html105
6 files changed, 459 insertions, 0 deletions
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/limits/00_test_list.txt b/dom/canvas/test/webgl-conf/checkout/conformance/limits/00_test_list.txt
new file mode 100644
index 0000000000..79eb84a48e
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/limits/00_test_list.txt
@@ -0,0 +1,6 @@
+--min-version 1.0.4 gl-line-width.html
+gl-min-attribs.html
+gl-max-texture-dimensions.html
+gl-min-textures.html
+gl-min-uniforms.html
+
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/limits/gl-line-width.html b/dom/canvas/test/webgl-conf/checkout/conformance/limits/gl-line-width.html
new file mode 100644
index 0000000000..e446c62a94
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/limits/gl-line-width.html
@@ -0,0 +1,72 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>Verify that line width limits are enforced.</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"> </script>
+</head>
+<body>
+<canvas id="example" width="4" height="4" style="width: 40px; height: 30px;"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+"use strict";
+description(document.title);
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+
+// Query the line width range
+var lineWidthRange = gl.getParameter(gl.ALIASED_LINE_WIDTH_RANGE);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors.");
+
+if (lineWidthRange[0] > 1 || lineWidthRange[1] < 1)
+ testFailed("Line width range must include width 1");
+
+// Zero, negative, or NaN values should cause an error and leave the value unchanged.
+var curLineWidth = gl.getParameter(gl.LINE_WIDTH);
+gl.lineWidth(0);
+wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "Should not be able to set lineWidth to zero");
+shouldBe('gl.getParameter(gl.LINE_WIDTH)', 'curLineWidth'); // Previous value should be preserved
+
+gl.lineWidth(-1);
+wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "Should not be able to set lineWidth to a negative value");
+shouldBe('gl.getParameter(gl.LINE_WIDTH)', 'curLineWidth'); // Previous value should be preserved
+
+gl.lineWidth(NaN);
+wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "Should not be able to set lineWidth to NaN");
+shouldBe('gl.getParameter(gl.LINE_WIDTH)', 'curLineWidth'); // Previous value should be preserved
+
+// Check that the line width can be set to the valid range.
+gl.lineWidth(lineWidthRange[1]);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be able to set lineWidth to the max supported value");
+shouldBe('gl.getParameter(gl.LINE_WIDTH)', 'lineWidthRange[1]');
+
+gl.lineWidth(lineWidthRange[0]);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be able to set lineWidth to the min supported value");
+shouldBe('gl.getParameter(gl.LINE_WIDTH)', 'lineWidthRange[0]');
+
+// Checks that the line width can be set outside the supported range without error,
+// and the unclamped value can be queried back.
+// Yes, this is actually what the spec says should happen.
+// See: https://www.khronos.org/opengles/sdk/docs/man3/html/glLineWidth.xhtml
+gl.lineWidth(lineWidthRange[1]+1);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be able to set lineWidth to the above max supported value");
+shouldBe('gl.getParameter(gl.LINE_WIDTH)', 'lineWidthRange[1]+1');
+
+var successfullyParsed = true;
+
+</script>
+<script src="../../js/js-test-post.js"></script>
+
+</body>
+</html>
+
+
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/limits/gl-max-texture-dimensions.html b/dom/canvas/test/webgl-conf/checkout/conformance/limits/gl-max-texture-dimensions.html
new file mode 100644
index 0000000000..a9c5850225
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/limits/gl-max-texture-dimensions.html
@@ -0,0 +1,109 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL the max advertized texture size is supported.</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"> </script>
+</head>
+<body>
+<canvas id="example" width="4" height="4" style="width: 40px; height: 30px;"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script id="vshader" type="x-shader/x-vertex">
+attribute vec4 vPosition;
+attribute vec2 texCoord0;
+varying vec2 texCoord;
+void main()
+{
+ gl_Position = vPosition;
+ texCoord = texCoord0;
+}
+</script>
+
+<script id="fshader" type="x-shader/x-fragment">
+precision mediump float;
+uniform samplerCube tex;
+varying vec2 texCoord;
+void main()
+{
+ gl_FragColor = textureCube(tex, normalize(vec3(texCoord, 1)));
+}
+</script>
+<script>
+"use strict";
+description(document.title);
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+var program = wtu.setupTexturedQuad(gl);
+
+function shouldBePowerOfTwo(n, name) {
+ var power = Math.round(Math.log(n) / Math.log(2));
+ if (Math.pow(2, power) == n) {
+ testPassed(name + ' is a power of two.');
+ } else {
+ testFailed(name + ' should be a power of two, but was ' + n);
+ }
+}
+
+// Note: It seems like a reasonable assuption that a 1xN texture size should
+// work. Even 1 by 128k is only 512k
+var maxSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);
+debug("advertised max size: " + maxSize);
+debug("verifying max size is power-of-two (implied by GLES 2.0 section 3.7.1)");
+shouldBePowerOfTwo(maxSize, 'Max size');
+var testSize = Math.min(maxSize, 128 * 1024);
+var pixels = new Uint8Array(testSize * 4);
+for (var ii = 0; ii < testSize; ++ii) {
+ var off = ii * 4;
+ pixels[off + 0] = 0;
+ pixels[off + 1] = 255;
+ pixels[off + 2] = 128;
+ pixels[off + 3] = 255;
+}
+var tex = gl.createTexture();
+gl.bindTexture(gl.TEXTURE_2D, tex);
+
+debug("test " + testSize + "x1");
+gl.texImage2D(
+ gl.TEXTURE_2D, 0, gl.RGBA, testSize, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE,
+ pixels);
+gl.generateMipmap(gl.TEXTURE_2D);
+
+wtu.clearAndDrawUnitQuad(gl);
+wtu.checkCanvas(gl, [0, 255, 128, 255],
+ "Should be 0, 255, 128, 255");
+debug("test 1x" + testSize);
+gl.texImage2D(
+ gl.TEXTURE_2D, 0, gl.RGBA, 1, testSize, 0, gl.RGBA, gl.UNSIGNED_BYTE,
+ pixels);
+gl.generateMipmap(gl.TEXTURE_2D);
+
+wtu.clearAndDrawUnitQuad(gl);
+wtu.checkCanvas(gl, [0, 255, 128, 255],
+ "Should be 0, 255, 128, 255");
+
+var program = wtu.setupProgram(
+ gl, ['vshader', 'fshader'], ['vPosition', 'texCoord0'], [0, 1]);
+
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors.");
+
+// NOTE: We can't easily test cube maps because they require width == height
+// and we might not have enough memory for maxSize by maxSize texture.
+
+var successfullyParsed = true;
+
+</script>
+<script src="../../js/js-test-post.js"></script>
+
+</body>
+</html>
+
+
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/limits/gl-min-attribs.html b/dom/canvas/test/webgl-conf/checkout/conformance/limits/gl-min-attribs.html
new file mode 100644
index 0000000000..368130306c
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/limits/gl-min-attribs.html
@@ -0,0 +1,86 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL the minimum number of attributes are supported.</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"> </script>
+</head>
+<body>
+<canvas id="example" width="4" height="4" style="width: 40px; height: 30px;"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script id="vshader" type="x-shader/x-vertex">
+attribute vec4 vPosition;
+attribute vec4 v0;
+attribute vec4 v1;
+attribute vec4 v2;
+attribute vec4 v3;
+attribute vec4 v4;
+attribute vec4 v5;
+attribute vec4 v6;
+varying vec4 color;
+void main()
+{
+ gl_Position = vPosition;
+ color = v0 + v1 + v2 + v3 + v4 + v5 + v6;
+}
+</script>
+
+<script id="fshader" type="x-shader/x-fragment">
+precision mediump float;
+varying vec4 color;
+void main()
+{
+ gl_FragColor = color;
+}
+</script>
+<script>
+"use strict";
+description(document.title);
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+var program = wtu.setupTexturedQuad(gl);
+
+var program = wtu.setupProgram(
+ gl,
+ ['vshader', 'fshader'],
+ ['vPosition', 'v0', 'v1', 'v2', 'v3', 'v4', 'v5', 'v6'],
+ [0, 1, 2, 3, 4, 5, 6, 7]);
+
+for (var ii = 0; ii < 7; ++ii) {
+ var v = (ii + 1) / 28;
+ var vertexObject = gl.createBuffer();
+ gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
+ gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
+ v, v/2, v/4, v/8,
+ v, v/2, v/4, v/8,
+ v, v/2, v/4, v/8,
+ v, v/2, v/4, v/8,
+ v, v/2, v/4, v/8,
+ v, v/2, v/4, v/8]), gl.STATIC_DRAW);
+ gl.enableVertexAttribArray(ii + 1);
+ gl.vertexAttribPointer(ii + 1, 4, gl.FLOAT, false, 0, 0);
+}
+
+wtu.clearAndDrawUnitQuad(gl);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
+wtu.checkCanvasRect(gl, 0, 0, gl.canvas.width, gl.canvas.height, [255, 127, 64, 32], "Should render 255,127,64,32 (+/-1)", 1);
+
+var successfullyParsed = true;
+
+</script>
+</body>
+<script src="../../js/js-test-post.js"></script>
+
+</body>
+</html>
+
+
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/limits/gl-min-textures.html b/dom/canvas/test/webgl-conf/checkout/conformance/limits/gl-min-textures.html
new file mode 100644
index 0000000000..33b9f1f94c
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/limits/gl-min-textures.html
@@ -0,0 +1,81 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL the minimum number of uniforms are supported.</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"> </script>
+</head>
+<body>
+<canvas id="example" width="4" height="4" style="width: 40px; height: 30px;"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script id="vshader" type="x-shader/x-vertex">
+attribute vec4 vPosition;
+void main()
+{
+ gl_Position = vPosition;
+}
+</script>
+
+<script id="fshader" type="x-shader/x-fragment">
+#define NUM_TEXTURES 8 // See spec
+precision mediump float;
+uniform sampler2D uni[NUM_TEXTURES];
+void main()
+{
+ vec4 c = vec4(0,0,0,0);
+ // The loop was manually unrolled in order to verify that this works.
+ // A separate test sampler-array-using-loop-index.html checks that
+ // loops indexing sampler arrays still work.
+ c += texture2D(uni[0], vec2(0.5, 0.5));
+ c += texture2D(uni[1], vec2(0.5, 0.5));
+ c += texture2D(uni[2], vec2(0.5, 0.5));
+ c += texture2D(uni[3], vec2(0.5, 0.5));
+ c += texture2D(uni[4], vec2(0.5, 0.5));
+ c += texture2D(uni[5], vec2(0.5, 0.5));
+ c += texture2D(uni[6], vec2(0.5, 0.5));
+ c += texture2D(uni[7], vec2(0.5, 0.5));
+ gl_FragColor = c;
+}
+</script>
+<script>
+"use strict";
+description(document.title);
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+var program = wtu.setupTexturedQuad(gl);
+
+//------------------------------------------------------------------------------
+var program = wtu.setupProgram(
+ gl, ['vshader', 'fshader'], ['vPosition'], [0]);
+
+for (var ii = 0; ii < 8; ++ii) {
+ var loc = gl.getUniformLocation(program, "uni[" + ii + "]");
+ gl.activeTexture(gl.TEXTURE0 + ii);
+ var tex = gl.createTexture();
+ wtu.fillTexture(gl, tex, 1, 1, [32, 16, 8, ii * 9], 0);
+ gl.uniform1i(loc, ii);
+}
+
+wtu.clearAndDrawUnitQuad(gl);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
+wtu.checkCanvas(gl, [255, 128, 64, 252],
+ "Should render using all texture units", 1);
+
+var successfullyParsed = true;
+
+</script>
+<script src="../../js/js-test-post.js"></script>
+
+</body>
+</html>
+
+
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/limits/gl-min-uniforms.html b/dom/canvas/test/webgl-conf/checkout/conformance/limits/gl-min-uniforms.html
new file mode 100644
index 0000000000..e4a1bf7ea4
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/limits/gl-min-uniforms.html
@@ -0,0 +1,105 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL the minimum number of uniforms are supported.</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"> </script>
+</head>
+<body>
+<canvas id="example" width="4" height="4" style="width: 40px; height: 30px;"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script id="vshader" type="x-shader/x-vertex">
+#define NUM_UNIFORMS 128 // See spec
+attribute vec4 vPosition;
+uniform vec4 uni[NUM_UNIFORMS];
+varying vec4 color;
+void main()
+{
+ gl_Position = vPosition;
+ vec4 c = vec4(0,0,0,0);
+ for (int ii = 0; ii < NUM_UNIFORMS; ++ii) {
+ c += uni[ii];
+ }
+ color = c;
+}
+</script>
+
+<script id="fshader" type="x-shader/x-fragment">
+precision mediump float;
+varying vec4 color;
+void main()
+{
+ gl_FragColor = color;
+}
+</script>
+<script id="vshader2" type="x-shader/x-vertex">
+attribute vec4 vPosition;
+void main()
+{
+ gl_Position = vPosition;
+}
+</script>
+
+<script id="fshader2" type="x-shader/x-fragment">
+precision mediump float;
+#define NUM_UNIFORMS 16 // See spec
+uniform vec4 uni[NUM_UNIFORMS];
+void main()
+{
+ vec4 c = vec4(0,0,0,0);
+ for (int ii = 0; ii < NUM_UNIFORMS; ++ii) {
+ c += uni[ii];
+ }
+ gl_FragColor = vec4(c.r, c.g, c.b, c.a / 120.0);
+}
+</script>
+<script>
+"use strict";
+description(document.title);
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+var program = wtu.setupTexturedQuad(gl);
+
+//------------------------------------------------------------------------------
+var program = wtu.setupProgram(gl, ['vshader', 'fshader'], ['vPosition'], [0]);
+
+for (var ii = 0; ii < 128; ++ii) {
+ var loc = gl.getUniformLocation(program, "uni[" + ii + "]");
+ gl.uniform4f(loc, 2/256, 2/512, 2/1024, ii/8128);
+}
+
+wtu.clearAndDrawUnitQuad(gl);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
+wtu.checkCanvasRect(gl, 0, 0, gl.canvas.width, gl.canvas.height, [255, 127, 64, 255], "Should render 255,127,64,32 (+/-1)", 1);
+
+//------------------------------------------------------------------------------
+var program = wtu.setupProgram(gl, ['vshader2', 'fshader2'], ['vPosition'], [0]);
+
+for (var ii = 0; ii < 16; ++ii) {
+ var loc = gl.getUniformLocation(program, "uni[" + ii + "]");
+ gl.uniform4f(loc, 16/2048, 16/1024, 16/512, ii);
+}
+
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
+wtu.clearAndDrawUnitQuad(gl);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
+wtu.checkCanvasRect(gl, 0, 0, gl.canvas.width, gl.canvas.height, [32, 64, 127, 255], "Should render 32,64,127,255 (+/-1)", 1);
+
+var successfullyParsed = true;
+
+</script>
+<script src="../../js/js-test-post.js"></script>
+
+</body>
+</html>
+
+