summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures')
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/00_test_list.txt60
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/compressed-tex-image.html84
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/copy-tex-image-2d-formats.html196
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/copy-tex-image-and-sub-image-2d.html156
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/default-texture.html65
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/gl-get-tex-parameter.html136
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/gl-pixelstorei.html119
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/gl-teximage.html424
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/mipmap-fbo.html89
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/origin-clean-conformance.html151
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-array-buffer-view.html260
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-canvas-rgb565.html50
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-canvas-rgba4444.html50
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-canvas-rgba5551.html50
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-canvas.html50
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-image-data-rgb565.html51
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-image-data-rgba4444.html51
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-image-data-rgba5551.html51
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-image-data.html51
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-image-rgb565.html50
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-image-rgba4444.html50
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-image-rgba5551.html50
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-image.html50
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-svg-image.html50
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-video-rgb565.html50
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-video-rgba4444.html50
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-video-rgba5551.html50
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-video.html50
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-webgl-canvas-rgb565.html50
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-webgl-canvas-rgba4444.html50
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-webgl-canvas-rgba5551.html50
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-webgl-canvas.html50
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-uniform-binding-bugs.html65
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-canvas-corruption.html74
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-webgl.html101
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-with-format-and-type.html745
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-with-invalid-data.html147
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-input-validation.html385
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-sub-image-2d-bad-args.html94
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-sub-image-2d.html124
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texparameter-test.html207
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-active-bind-2.html233
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-active-bind.html143
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-attachment-formats.html200
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-clear.html66
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-complete.html87
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-copying-feedback-loops.html105
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-draw-with-2d-and-cube.html127
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-fakeblack.html119
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-formats-test.html292
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-hd-dpi.html141
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-mips.html320
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-npot-video.html163
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-npot.html329
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-size-cube-maps.html356
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-size-limit.html175
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-size.html238
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-sub-image-cube-maps.html338
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-transparent-pixels-initialized.html108
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-upload-cube-maps.html75
-rw-r--r--testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-upload-size.html172
61 files changed, 8523 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/00_test_list.txt b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/00_test_list.txt
new file mode 100644
index 000000000..0bd628195
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/00_test_list.txt
@@ -0,0 +1,60 @@
+compressed-tex-image.html
+copy-tex-image-and-sub-image-2d.html
+--min-version 1.0.2 copy-tex-image-2d-formats.html
+--min-version 1.0.3 default-texture.html
+--min-version 1.0.2 gl-get-tex-parameter.html
+gl-pixelstorei.html
+gl-teximage.html
+origin-clean-conformance.html
+tex-image-and-sub-image-2d-with-array-buffer-view.html
+tex-image-and-sub-image-2d-with-canvas.html
+tex-image-and-sub-image-2d-with-canvas-rgb565.html
+tex-image-and-sub-image-2d-with-canvas-rgba4444.html
+tex-image-and-sub-image-2d-with-canvas-rgba5551.html
+tex-image-and-sub-image-2d-with-image-data.html
+tex-image-and-sub-image-2d-with-image-data-rgb565.html
+tex-image-and-sub-image-2d-with-image-data-rgba4444.html
+tex-image-and-sub-image-2d-with-image-data-rgba5551.html
+tex-image-and-sub-image-2d-with-image.html
+tex-image-and-sub-image-2d-with-image-rgb565.html
+tex-image-and-sub-image-2d-with-image-rgba4444.html
+tex-image-and-sub-image-2d-with-image-rgba5551.html
+--min-version 1.0.3 tex-image-and-sub-image-2d-with-svg-image.html
+tex-image-and-sub-image-2d-with-video.html
+tex-image-and-sub-image-2d-with-video-rgb565.html
+tex-image-and-sub-image-2d-with-video-rgba4444.html
+tex-image-and-sub-image-2d-with-video-rgba5551.html
+tex-image-and-sub-image-2d-with-webgl-canvas.html
+tex-image-and-sub-image-2d-with-webgl-canvas-rgb565.html
+tex-image-and-sub-image-2d-with-webgl-canvas-rgba4444.html
+tex-image-and-sub-image-2d-with-webgl-canvas-rgba5551.html
+tex-image-and-uniform-binding-bugs.html
+--min-version 1.0.3 tex-image-canvas-corruption.html
+--min-version 1.0.2 tex-image-webgl.html
+tex-image-with-format-and-type.html
+tex-image-with-invalid-data.html
+tex-input-validation.html
+tex-sub-image-2d-bad-args.html
+tex-sub-image-2d.html
+texparameter-test.html
+texture-active-bind-2.html
+texture-active-bind.html
+--min-version 1.0.2 texture-attachment-formats.html
+--min-version 1.0.2 texture-clear.html
+texture-complete.html
+--min-version 1.0.3 texture-copying-feedback-loops.html
+--min-version 1.0.2 texture-hd-dpi.html
+--min-version 1.0.2 texture-formats-test.html
+texture-mips.html
+texture-npot-video.html
+--max-version 1.9.9 texture-npot.html
+texture-size.html
+texture-size-cube-maps.html
+--min-version 1.0.2 texture-size-limit.html
+--min-version 1.0.2 texture-sub-image-cube-maps.html
+texture-transparent-pixels-initialized.html
+--min-version 1.0.2 texture-upload-cube-maps.html
+--min-version 1.0.3 texture-upload-size.html
+--min-version 1.0.2 mipmap-fbo.html
+--min-version 1.0.3 texture-fakeblack.html
+--min-version 1.0.3 texture-draw-with-2d-and-cube.html
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/compressed-tex-image.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/compressed-tex-image.html
new file mode 100644
index 000000000..d99f54af1
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/compressed-tex-image.html
@@ -0,0 +1,84 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL CompressedTexImage and CompressedTexSubImage Tests</title>
+<LINK rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+"use strict";
+description("This test ensures WebGL implementations correctly implement compressedTexImage2D and compressedTexSubImage2D.");
+
+debug("");
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext();
+
+var COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0;
+var COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1;
+var COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3;
+var ETC1_RGB8_OES = 0x8D64;
+var COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00;
+var COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02;
+
+var formats = null;
+
+if (!gl) {
+ testFailed("context does not exist");
+} else {
+ testPassed("context exists");
+
+ var tex = gl.createTexture();
+ gl.bindTexture(gl.TEXTURE_2D, tex);
+
+ wtu.shouldGenerateGLError(gl, gl.INVALID_ENUM, "gl.compressedTexImage2D(gl.TEXTURE_2D, 0, COMPRESSED_RGB_S3TC_DXT1_EXT, 4, 4, 0, new Uint8Array(8))");
+ wtu.shouldGenerateGLError(gl, gl.INVALID_ENUM, "gl.compressedTexImage2D(gl.TEXTURE_2D, 0, COMPRESSED_RGBA_S3TC_DXT1_EXT, 4, 4, 0, new Uint8Array(8))");
+ wtu.shouldGenerateGLError(gl, gl.INVALID_ENUM, "gl.compressedTexImage2D(gl.TEXTURE_2D, 0, COMPRESSED_RGBA_S3TC_DXT5_EXT, 4, 4, 0, new Uint8Array(16))");
+ wtu.shouldGenerateGLError(gl, gl.INVALID_ENUM, "gl.compressedTexImage2D(gl.TEXTURE_2D, 0, ETC1_RGB8_OES, 4, 4, 0, new Uint8Array(8))");
+ wtu.shouldGenerateGLError(gl, gl.INVALID_ENUM, "gl.compressedTexImage2D(gl.TEXTURE_2D, 0, COMPRESSED_RGB_PVRTC_4BPPV1_IMG, 8, 8, 0, new Uint8Array(8))");
+ wtu.shouldGenerateGLError(gl, gl.INVALID_ENUM, "gl.compressedTexImage2D(gl.TEXTURE_2D, 0, COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, 8, 8, 0, new Uint8Array(8))");
+
+ wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "formats = gl.getParameter(gl.COMPRESSED_TEXTURE_FORMATS)");
+ shouldBeNonNull("formats");
+ shouldBe("formats.length", "0");
+}
+
+var successfullyParsed = true;
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/copy-tex-image-2d-formats.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/copy-tex-image-2d-formats.html
new file mode 100644
index 000000000..270652623
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/copy-tex-image-2d-formats.html
@@ -0,0 +1,196 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<title>Verify copyTexImage2D follows format restictions</title>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<canvas id="canvas" width="2" height="2"></canvas>
+<canvas id="canvasNoAlpha" width="2" height="2"></canvas>
+<div id="console"></div>
+<script>
+"use strict";
+
+function getChannelsFromFormat(format) {
+ switch (gl[format]) {
+ case gl.ALPHA:
+ return 0x0001;
+ case gl.LUMINANCE:
+ case gl.RGB:
+ return 0x1110;
+ case gl.LUMINANCE_ALPHA:
+ case gl.RGBA:
+ return 0x1111;
+ default:
+ return 0;
+ }
+}
+
+var formats = [
+ 'ALPHA',
+ 'LUMINANCE',
+ 'LUMINANCE_ALPHA',
+ 'RGB',
+ 'RGBA'
+];
+
+var isRenderable = {
+ 'ALPHA': false,
+ 'LUMINANCE': false,
+ 'LUMINANCE_ALPHA': false,
+ 'RGB': true,
+ 'RGBA': true
+};
+
+var gl = null;
+var wtu = WebGLTestUtils;
+
+description();
+
+var canvas = document.getElementById("canvas");
+var canvasNoAlpha = document.getElementById("canvasNoAlpha");
+var gl = wtu.create3DContext(canvas, {alpha:true});
+var glNoAlpha = wtu.create3DContext(canvasNoAlpha, {alpha:false});
+
+debug("test with an RGBA backbuffer");
+var program = wtu.setupTexturedQuad(gl);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "During Initialization");
+testFormats('RGBA');
+
+testBackbufferFormats();
+
+debug("test with an RGB backbuffer");
+var gl = glNoAlpha;
+var program = wtu.setupTexturedQuad(gl);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "During Initialization");
+testFormats('RGB');
+
+function testBackbufferFormats() {
+ var fbo = gl.createFramebuffer();
+ gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
+
+ for (var ii = 0; ii < formats.length; ++ii) {
+ var backFormat = formats[ii];
+
+ var tex = gl.createTexture();
+ gl.bindTexture(gl.TEXTURE_2D, tex);
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl[backFormat], 2, 2, 0, gl[backFormat], gl.UNSIGNED_BYTE, null);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
+
+ gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0);
+ var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
+
+ debug('');
+ if (status == gl.FRAMEBUFFER_COMPLETE) {
+ if (!isRenderable[backFormat]) {
+ testFailed('Creating framebuffer from ' + backFormat + ' texture succeeded even though it is not a renderable format');
+ } else {
+ debug('test with ' + backFormat + ' fbo');
+ testFormats(backFormat);
+ }
+ } else {
+ debug(backFormat + ' not supported as a renderbuffer attachment');
+ }
+ }
+}
+
+function testFormats(backFormat) {
+ for (var ii = 0; ii < formats.length; ++ii) {
+ testCopyTexImage2D(backFormat, formats[ii]);
+ }
+}
+
+function toChannels(value) {
+ return ((value & 0x1000) ? 'R' : '_') +
+ ((value & 0x0100) ? 'G' : '_') +
+ ((value & 0x0010) ? 'B' : '_') +
+ ((value & 0x0001) ? 'A' : '_');
+}
+
+function testCopyTexImage2D(backFormat, texFormat) {
+ var need = getChannelsFromFormat(texFormat);
+ var have = getChannelsFromFormat(backFormat);
+ var shouldPass = (need & have) == need;
+
+ //debug("need: " + toChannels(need));
+ //debug("have: " + toChannels(have));
+ //debug("both: " + toChannels(have & need));
+
+ // clear backbuffer
+ gl.clearColor(0.25, 1, 0.75, 0.5);
+ gl.clear(gl.COLOR_BUFFER_BIT);
+
+ var texture = gl.createTexture();
+ // Bind the texture to texture unit 0
+ gl.bindTexture(gl.TEXTURE_2D, texture);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
+
+ gl.copyTexImage2D(gl.TEXTURE_2D, 0, gl[texFormat], 0, 0, 2, 2, 0);
+ if (!shouldPass) {
+ wtu.glErrorShouldBe(
+ gl, gl.INVALID_OPERATION,
+ "should not be able to copyTexImage2D " + texFormat + " from " + backFormat);
+ return;
+ }
+
+ wtu.glErrorShouldBe(
+ gl, gl.NO_ERROR,
+ "should be able to copyTexImage2D " + texFormat + " from " + backFormat);
+
+ // Draw
+ wtu.clearAndDrawUnitQuad(gl);
+
+ var expectedColors = {
+ 'ALPHA': [0, 0, 0, 127],
+ 'LUMINANCE': [64, 64, 64, 255],
+ 'LUMINANCE_ALPHA': [64, 64, 64, 127],
+ 'RGB': [64, 255, 191, 255],
+ 'RGBA': [64, 255, 191, 127]
+ };
+
+ var color = expectedColors[texFormat];
+
+ wtu.checkCanvas(gl, color, "should be " + color, 16);
+
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be no errors");
+}
+var successfullyParsed = true;
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/copy-tex-image-and-sub-image-2d.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/copy-tex-image-and-sub-image-2d.html
new file mode 100644
index 000000000..63280be93
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/copy-tex-image-and-sub-image-2d.html
@@ -0,0 +1,156 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+
+<script>
+"use strict";
+var successfullyParsed = false;
+
+function init()
+{
+ description('Verify copyTexImage2D and copyTexSubImage2D');
+
+ runTest();
+}
+
+var gl = null;
+var wtu = WebGLTestUtils;
+
+function runTestIteration(antialias)
+{
+ var canvas = document.getElementById(
+ antialias ? "antialiasOn" : "antialiasOff");
+ var attribs = antialias ? { antialias: true } : { antialias: false };
+ gl = wtu.create3DContext(canvas, attribs);
+ var program = wtu.setupTexturedQuad(gl);
+ var textureLoc = gl.getUniformLocation(program, "tex");
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "During Initialization");
+
+ gl.colorMask(1, 1, 1, 1);
+ gl.disable(gl.BLEND);
+ debug('Testing copyTexImage2D');
+
+ // Red canvas
+ gl.clearColor(1, 0, 0, 1);
+ gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+
+ var texture = gl.createTexture();
+ // Bind the texture to texture unit 0
+ gl.bindTexture(gl.TEXTURE_2D, texture);
+ // Set up texture
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 2, 2, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
+ gl.uniform1i(textureLoc, 0);
+
+ var colors = [
+ [1, 0, 0, 1],
+ [0, 1, 0, 1],
+ [0, 0, 1, 1],
+ [0.5, 0.5, 0.5, 0.5],
+ ];
+ var count = 0;
+ for (var yy = -2; yy <= 2; ++yy) {
+ for (var xx = -2; xx <= 2; ++xx) {
+ for (var ii = 0; ii < 2; ++ii) {
+ var texColor = colors[count];
+ var clearColor = colors[(count + 1) % colors.length];
+ // clear to some color
+ gl.clearColor(texColor[0], texColor[1], texColor[2], texColor[3]);
+ gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+
+ // copy that color to the texture.
+ switch (ii) {
+ case 0:
+ gl.copyTexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, xx, yy, 2, 2, 0);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR,
+ "using copyTexImage2D: x = " + xx + ", y = " + yy);
+ break;
+ case 1:
+ gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, xx, yy, 2, 2);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR,
+ "using copyTexSubImage2D: x = " + xx + ", y = " + yy);
+ break;
+ }
+
+ // clear to some other color.
+ gl.clearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]);
+ gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+
+ // Draw the triangles
+ wtu.clearAndDrawUnitQuad(gl);
+
+ // check the rendering results
+ for (var iy = 0; iy < 2; ++iy) {
+ for (var ix = 0; ix < 2; ++ix) {
+ var x = xx + ix;
+ var y = yy + iy;
+ var expectedColor = (x < 0 || y < 0 || x >= 2 || y >= 2) ?
+ [0,0,0,0] :
+ [Math.floor(255 * texColor[0]),
+ Math.floor(255 * texColor[1]),
+ Math.floor(255 * texColor[2]),
+ Math.floor(255 * texColor[3])];
+ wtu.checkCanvasRect(gl, ix, iy, 1, 1, expectedColor,
+ "" + ix + ", " + iy + " should render " + expectedColor + " (+/-1)", 1);
+ }
+ }
+ count = (count + 1) % colors.length;
+ }
+ }
+ }
+
+ debug("");
+}
+
+function runTest(antialias)
+{
+ debug("Testing with antialias on");
+ runTestIteration(true);
+ debug("Testing with antialias off");
+ runTestIteration(false);
+
+ finishTest();
+}
+</script>
+</head>
+<body onload="init()">
+<canvas id="antialiasOn" width="2" height="2"></canvas>
+<canvas id="antialiasOff" width="2" height="2"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/default-texture.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/default-texture.html
new file mode 100644
index 000000000..fb83dce24
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/default-texture.html
@@ -0,0 +1,65 @@
+<!--
+
+/*
+** Copyright (c) 2014 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>Tests texture access with no texture bound</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"> </script>
+</head>
+<body>
+<canvas id="example" width="24" height="24"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+"use strict";
+
+var wtu = WebGLTestUtils;
+description();
+
+var gl = wtu.create3DContext("example");
+var program = wtu.setupTexturedQuad(gl);
+
+gl.drawArrays(gl.TRIANGLES, 0, 6);
+
+// When no texture is bound, it is considered an incomplete texture,
+// therefore, [0, 0, 0, 1] should be returned.
+// See OpenGL ES spec 2.0.25, section F.3.5.
+wtu.checkCanvas(gl, [0, 0, 0, 255]);
+
+var successfullyParsed = true;
+</script>
+<script src="../../resources/js-test-post.js"></script>
+
+</body>
+</html>
+
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/gl-get-tex-parameter.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/gl-get-tex-parameter.html
new file mode 100644
index 000000000..e9db9e6c2
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/gl-get-tex-parameter.html
@@ -0,0 +1,136 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL getTexParameter test</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/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();
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+
+// NOTE: We explicitly do this in a funky order
+// to hopefully find subtle bugs.
+
+var targets = [
+ 'TEXTURE_2D',
+ 'TEXTURE_2D',
+ 'TEXTURE_CUBE_MAP',
+ 'TEXTURE_CUBE_MAP'
+];
+// Create textures on different active textures.
+for (var ii = 0; ii < targets.length; ++ii) {
+ var target = targets[ii];
+ var tex = gl.createTexture();
+ gl.activeTexture(gl.TEXTURE0 + ii);
+ gl.bindTexture(gl[target], tex);
+}
+
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be no errors");
+
+var states = [
+ { state:'TEXTURE_WRAP_S', default: 'REPEAT', value1: 'CLAMP_TO_EDGE', value2: 'REPEAT' },
+ { state:'TEXTURE_WRAP_T', default: 'REPEAT', value1: 'CLAMP_TO_EDGE', value2: 'REPEAT' },
+ { state:'TEXTURE_MAG_FILTER', default: 'LINEAR', value1: 'NEAREST', value2: 'LINEAR' },
+ { state:'TEXTURE_MIN_FILTER', default: 'NEAREST_MIPMAP_LINEAR', value1: 'LINEAR_MIPMAP_LINEAR', value2: 'NEAREST' }
+];
+
+function applyStates(fn) {
+ for (var ss = 0; ss < states.length; ++ss) {
+ var stateInfo = states[ss];
+ for (var ii = 0; ii < targets.length; ++ii) {
+ var target = targets[ii];
+ gl.activeTexture(gl.TEXTURE0 + ii);
+ fn(target, stateInfo);
+ }
+ }
+}
+
+// test the default state.
+applyStates(function(target, stateInfo) {
+ var a = 'gl.getTexParameter(gl["' + target + '"], gl["' + stateInfo.state + '"])';
+ var b = 'gl["' + stateInfo.default + '"]';
+ shouldBe(a, b);
+});
+
+// test new state
+applyStates(function(target, stateInfo) {
+ gl.texParameteri(gl[target], gl[stateInfo.state], gl[stateInfo.value1]);
+});
+
+applyStates(function(target, stateInfo) {
+ var a = 'gl.getTexParameter(gl["' + target + '"], gl["' + stateInfo.state + '"])';
+ var b = 'gl["' + stateInfo.value1 + '"]';
+ shouldBe(a, b);
+});
+
+// test different states on each target.
+function getStateValue(count, stateInfo) {
+ return (count % 2) ? stateInfo.value2 : stateInfo.value1;
+}
+
+applyStates(function() {
+ var count = 0;
+ return function(target, stateInfo) {
+ gl.texParameteri(gl[target], gl[stateInfo.state], gl[getStateValue(count, stateInfo)]);
+ ++count;
+ }
+}());
+
+applyStates(function() {
+ var count = 0;
+ return function(target, stateInfo) {
+ var a = 'gl.getTexParameter(gl["' + target + '"], gl["' + stateInfo.state + '"])';
+ var b = 'gl["' + getStateValue(count, stateInfo) + '"]';
+ shouldBe(a, b);
+ ++count;
+ };
+}());
+
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be no errors");
+
+var successfullyParsed = true;
+</script>
+<script src="../../resources/js-test-post.js"></script>
+
+</body>
+</html>
+
+
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/gl-pixelstorei.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/gl-pixelstorei.html
new file mode 100644
index 000000000..103f3d923
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/gl-pixelstorei.html
@@ -0,0 +1,119 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL pixelStorei Test</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"> </script>
+</head>
+<body>
+<canvas id="example" width="50" height="50"></canvas>
+<canvas id="2d00" width="50" height="50"></canvas>
+<canvas id="2d01" width="50" height="50"></canvas>
+<canvas id="2d02" width="50" height="50"></canvas>
+<canvas id="2d03" width="50" height="50"></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">
+void main() {
+ gl_FragColor = vec4(1.0,0.0,0.0,1.0);
+}
+</script>
+
+<script>
+"use strict";
+function init() {
+ description("This test checks that drawImage and readPixels are not effected by gl.Pixelstorei(gl.PACK_ALIGNMENT) and visa versa");
+
+ debug("There should be 5 red triangles on 5 black squares above");
+ debug("");
+
+ var wtu = WebGLTestUtils;
+ var canvas3d = document.getElementById("example");
+ var gl = wtu.create3DContext("example");
+ var program = wtu.setupProgram(gl, ["vshader", "fshader"], ["vPosition"]);
+
+ var vertexObject = gl.createBuffer();
+ gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
+ gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ 0,0.5,0, -0.5,-0.5,0, 0.5,-0.5,0 ]), gl.STATIC_DRAW);
+ gl.enableVertexAttribArray(0);
+ gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
+
+ gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+ gl.drawArrays(gl.TRIANGLES, 0, 3);
+
+ function checkData(ctx, name) {
+ // Test several locations
+ // First line should be all black
+ wtu.checkCanvasRect(ctx, 0, 0, 50, 1, [0, 0, 0, 0]);
+
+ // Line 25 should be red for at least 6 red pixels starting 22 pixels in
+ wtu.checkCanvasRect(ctx, 22, 25, 6, 1, [255, 0, 0, 255]);
+
+ // Last line should be all black
+ wtu.checkCanvasRect(ctx, 0, 49, 50, 1, [0, 0, 0, 0]);
+ }
+
+ var ctx2d;
+
+ function checkColors() {
+ checkData(gl, "3d context");
+ checkData(ctx2d, "2d context");
+ }
+
+ var table = [1, 2, 4, 8];
+ for (var ii = 0; ii < table.length; ++ii) {
+ gl.pixelStorei(gl.PACK_ALIGNMENT, table[ii]);
+ ctx2d = document.getElementById("2d0" + ii).getContext("2d");
+ ctx2d.globalCompositeOperation = 'copy';
+ ctx2d.drawImage(canvas3d, 0, 0);
+ checkColors();
+ assertMsg(gl.getParameter(gl.PACK_ALIGNMENT) == table[ii],
+ "PACK_ALIGNMENT is " + table[ii]);
+ }
+}
+
+init();
+var successfullyParsed = true;
+</script>
+<script src="../../resources/js-test-post.js"></script>
+
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/gl-teximage.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/gl-teximage.html
new file mode 100644
index 000000000..26e46e7cc
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/gl-teximage.html
@@ -0,0 +1,424 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL texImage2D conformance test.</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"> </script>
+</head>
+<body>
+<canvas id="example" width="256" height="16" style="width: 256px; height: 48px;"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+"use strict";
+enableJSTestPreVerboseLogging();
+description("Test texImage2D conversions.");
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+gl.disable(gl.DITHER);
+var program = wtu.setupTexturedQuad(gl);
+var successfullyParsed;
+
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
+
+var imgURLs = [
+ '../resources/1-channel.jpg',
+ '../resources/gray-ramp-256-with-128-alpha.png',
+ '../resources/gray-ramp-256.png',
+ '../resources/gray-ramp-default-gamma.png',
+ '../resources/gray-ramp-gamma0.1.png',
+ '../resources/gray-ramp-gamma1.0.png',
+ '../resources/gray-ramp-gamma2.0.png',
+ '../resources/gray-ramp-gamma4.0.png',
+ '../resources/gray-ramp-gamma9.0.png',
+ '../resources/gray-ramp.png',
+ '../resources/zero-alpha.png',
+ '../resources/3x3.png',
+ '../resources/blue-1x1.jpg',
+ '../resources/red-indexed.png',
+ '../resources/transparent-on-left-indexed.png',
+ '../resources/green-2x2-16bit.png',
+ '../resources/small-square-with-colorspin-profile.jpg',
+ '../resources/small-square-with-colorspin-profile.png',
+ '../resources/small-square-with-cie-rgb-profile.png',
+ '../resources/small-square-with-colormatch-profile.png',
+ '../resources/small-square-with-e-srgb-profile.png',
+ '../resources/small-square-with-smpte-c-profile.png',
+ '../resources/small-square-with-srgb-iec61966-2.1-profile.png'];
+
+
+wtu.loadImagesAsync(imgURLs, runTests);
+
+function runTests(imgs) {
+ var loc = gl.getUniformLocation(program, "tex");
+ gl.uniform1i(loc, 0);
+
+ gl.disable(gl.BLEND);
+ gl.disable(gl.DEPTH_TEST);
+
+ var width = gl.canvas.width;
+ var height = gl.canvas.height;
+
+ function checkPixel(x, y, color) {
+ wtu.checkCanvasRect(gl, x, y, 1, 1, color);
+ }
+
+ function checkPixelRange(x, y, color, allowedRange) {
+ var msg = "pixel " + x + ", " + y + " should be within " +
+ allowedRange + " units of " +
+ color[0] + ", " +
+ color[1] + ", " +
+ color[2] + ", " +
+ color[3];
+ wtu.checkCanvasRect(gl, x, y, 1, 1, color, msg, allowedRange);
+ }
+
+ var tex = gl.createTexture();
+ gl.bindTexture(gl.TEXTURE_2D, tex);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
+
+ var buf = new Uint8Array(width * height * 4);
+
+ debug("");
+ debug("check pixels are NOT pre-multiplied");
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE,
+ imgs['../resources/zero-alpha.png']);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup");
+ wtu.clearAndDrawUnitQuad(gl);
+
+ var left = 0;
+ var middle = Math.floor(width / 2);
+ var right = width - 1;
+ var bottom = 0;
+ var center = Math.floor(height / 2);
+ var top = height - 1;
+ checkPixel(left, top, [ 0, 0, 0, 255]);
+ checkPixel(middle, top, [255, 0, 255, 255]);
+ checkPixel(right, top, [ 0, 0, 255, 255]);
+ checkPixel(left, center, [128, 128, 128, 255]);
+ checkPixel(middle, center, [255, 255, 255, 255]);
+ checkPixel(right, center, [ 0, 255, 255, 255]);
+ checkPixel(left, bottom, [255, 0, 0, 255]);
+ checkPixel(middle, bottom, [255, 255, 0, 255]);
+ checkPixel(right, bottom, [ 0, 255, 0, 255]);
+
+ debug("");
+ debug("check quantization");
+ var quantInfo = [
+ {format: gl.RGBA, type: gl.UNSIGNED_BYTE, counts: [256, 256, 256, 256]},
+ {format: gl.RGBA, type: gl.UNSIGNED_SHORT_4_4_4_4, counts: [ 16, 16, 16, 16]},
+ {format: gl.RGB, type: gl.UNSIGNED_SHORT_5_6_5, counts: [ 32, 64, 32, 1]},
+ {format: gl.RGBA, type: gl.UNSIGNED_SHORT_5_5_5_1, counts: [ 32, 32, 32, 2]}];
+ for (var qq = 0; qq < quantInfo.length; ++qq) {
+ var info = quantInfo[qq];
+ gl.texImage2D(
+ gl.TEXTURE_2D, 0, info.format, info.format, info.type,
+ imgs['../resources/gray-ramp-256.png']);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
+ wtu.clearAndDrawUnitQuad(gl);
+ gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, buf);
+ var counts = [{ }, { }, { }, { }];
+ var numUniqueValues = [0, 0, 0, 0];
+ // Count the number of unique values in each channel.
+ for (var ii = 0; ii < width * height * 4; ii += 4) {
+ for (var jj = 0; jj < 4; ++jj) {
+ var v = buf[ii + jj];
+ if (!counts[jj][v]) {
+ counts[jj][v] = 1;
+ ++numUniqueValues[jj];
+ } else {
+ ++counts[jj][v];
+ }
+ }
+ }
+ for (var ii = 0; ii < 4; ++ii) {
+ assertMsg(numUniqueValues[ii] == info.counts[ii],
+ "There should be " + info.counts[ii] +
+ " unique values in channel " + ii + ". Found " +
+ numUniqueValues[ii]);
+ }
+ }
+
+ debug("");
+ debug("Check that gamma settings don't effect 8bit pngs");
+ gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, gl.NONE);
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE,
+ imgs['../resources/gray-ramp-default-gamma.png']);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
+ wtu.clearAndDrawUnitQuad(gl);
+ var ref = new Uint8Array(width * height * 4);
+ gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, ref);
+
+ var gammaImages = [
+ '../resources/gray-ramp-gamma0.1.png',
+ '../resources/gray-ramp-gamma1.0.png',
+ '../resources/gray-ramp-gamma2.0.png',
+ '../resources/gray-ramp-gamma4.0.png',
+ '../resources/gray-ramp-gamma9.0.png'];
+ for (var ii = 0; ii < gammaImages.length; ++ii) {
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE,
+ imgs[gammaImages[ii]]);
+ wtu.clearAndDrawUnitQuad(gl);
+ gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, buf);
+ var same = true;
+ for (var jj = 0; jj < width * height * 4; ++jj) {
+ if (buf[jj] != ref[jj]) {
+ same = false;
+ break;
+ }
+ }
+ assertMsg(same, "pixels should be same regardless of gamma settings.");
+ }
+
+ debug("");
+ debug("check pixels are UN pre-multiplied");
+ for (var ii = 0; ii < 2; ++ii) {
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
+ if (ii == 0) {
+ var canvas2d = document.createElement("canvas");
+ canvas2d.width = 256;
+ canvas2d.height = 1;
+ var ctx = canvas2d.getContext("2d");
+ ctx.drawImage(imgs['../resources/gray-ramp-256-with-128-alpha.png'], 0, 0);
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE, canvas2d);
+ } else {
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE,
+ imgs['../resources/gray-ramp-256-with-128-alpha.png']);
+ }
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
+ wtu.clearAndDrawUnitQuad(gl);
+ var buf = new Uint8Array(width * height * 4);
+ gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, buf);
+ var lt128Count = [0, 0, 0];
+ var ge128Count = [0, 0, 0];
+ for (var jj = 0; jj < width; ++jj) {
+ var off = jj * 4;
+ for (var cc = 0; cc < 3; ++cc) {
+ if (buf[off + cc] < 128) {
+ ++lt128Count[cc];
+ } else {
+ ++ge128Count[cc];
+ }
+ }
+ }
+ // Not sure the exact count here because gamma does effect drawing into the
+ // canvas but it should be close to 50% so I'll pass 45%
+ for (var jj = 0; jj < 3; ++jj) {
+ assertMsg(ge128Count[jj] > 256 * 0.45,
+ "Half the pixels in channel " + jj +
+ " should be >= 128,128,128. found " +
+ ((ge128Count[jj] / 256) * 100).toFixed() + "%");
+ assertMsg(lt128Count[jj] > 256 * 0.45,
+ "Half the pixels in channel " + jj +
+ " should be < 128,128,128. found " +
+ ((lt128Count[jj] / 256) * 100).toFixed() + "%");
+ }
+ }
+
+ debug("");
+ debug("check canvas pixels are UN pre-multiplied");
+ var canvas2d = document.createElement("canvas");
+ canvas2d.width = 1;
+ canvas2d.height = 1;
+ var ctx = canvas2d.getContext("2d");
+ ctx.fillStyle ="rgba(255,255,255,0.5)";
+ ctx.fillRect(0, 0, 256, 1);
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas2d);
+ wtu.clearAndDrawUnitQuad(gl);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
+ checkPixelRange(0, 0, [255, 255, 255, 127], 4);
+
+ debug("");
+ debug("check canvas pixels are pre-multiplied");
+ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas2d);
+ wtu.clearAndDrawUnitQuad(gl);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
+ checkPixelRange(0, 0, [127, 127, 127, 127], 4);
+
+
+ debug("");
+ debug("check pixels are pre-multiplied");
+ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
+ // TODO(gman): use different texture that won't pass on failure
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE,
+ imgs['../resources/zero-alpha.png']);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup");
+ wtu.clearAndDrawUnitQuad(gl);
+ gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, buf);
+
+ var same = true;
+ for (var jj = 0; jj < width * height * 4; ++jj) {
+ if (buf[jj] != 0) {
+ same = false;
+ break;
+ }
+ }
+ assertMsg(same, "pixels should all be 0.");
+
+ debug("");
+ debug("check pixels are flipped");
+ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE,
+ imgs['../resources/3x3.png']);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup");
+ wtu.clearAndDrawUnitQuad(gl);
+
+ checkPixel(left, top, [255, 0, 0, 255]);
+ checkPixel(middle, top, [255, 255, 0, 255]);
+ checkPixel(right, top, [255, 0, 0, 255]);
+ checkPixel(left, center, [255, 0, 255, 255]);
+ checkPixel(middle, center, [255, 0, 0, 255]);
+ checkPixel(right, center, [ 0, 255, 0, 255]);
+ checkPixel(left, bottom, [ 0, 0, 0, 255]);
+ checkPixel(middle, bottom, [ 0, 0, 255, 255]);
+ checkPixel(right, bottom, [255, 0, 0, 255]);
+
+ debug("");
+ debug("check uploading of images with no alpha channel works");
+ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE,
+ imgs['../resources/blue-1x1.jpg']);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup");
+ wtu.clearAndDrawUnitQuad(gl);
+ checkPixelRange(middle, center, [ 0, 0, 255, 255], 10);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors");
+
+ debug("");
+ debug("check uploading of 16-bit images");
+ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE,
+ imgs['../resources/green-2x2-16bit.png']);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup");
+ wtu.clearAndDrawUnitQuad(gl);
+ checkPixelRange(middle, center, [ 15, 121, 0, 255], 10);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors");
+
+ debug("");
+ debug("check uploading of images with ICC profiles");
+ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
+ gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, gl.NONE);
+
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE,
+ imgs['../resources/small-square-with-colorspin-profile.jpg']);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup");
+ wtu.clearAndDrawUnitQuad(gl);
+ // The image is red. However, if we ignore the color profile, it is blue.
+ checkPixelRange(middle, center, [ 0, 0, 255, 255], 10);
+
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE,
+ imgs['../resources/small-square-with-colorspin-profile.png']);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup");
+ wtu.clearAndDrawUnitQuad(gl);
+ // The image is red. However, if we ignore the color profile, it is blue.
+ checkPixelRange(middle, center, [ 0, 0, 255, 255], 10);
+
+ var iccPNGs = [
+ '../resources/small-square-with-cie-rgb-profile.png',
+ '../resources/small-square-with-colormatch-profile.png',
+ '../resources/small-square-with-e-srgb-profile.png',
+ '../resources/small-square-with-smpte-c-profile.png',
+ '../resources/small-square-with-srgb-iec61966-2.1-profile.png'];
+ gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, buf);
+ for (var ii = 0; ii < iccPNGs.length; ++ii) {
+ var buf2 = new Uint8Array(width * height * 4);
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE,
+ imgs[iccPNGs[ii]]);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup");
+ wtu.clearAndDrawUnitQuad(gl);
+ gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, buf2);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors");
+ var same = true;
+ for (var jj = 0; jj < buf.length; ++jj) {
+ if (buf[jj] != buf2[jj]) {
+ same = false;
+ break;
+ }
+ }
+ assertMsg(same, "uploading PNGs with same data but various ICC profiles should generate the same results");
+ }
+
+ debug("");
+ debug("check uploading of indexed PNG images");
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE,
+ imgs['../resources/red-indexed.png']);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup");
+ wtu.clearAndDrawUnitQuad(gl);
+ // The image should be red.
+ checkPixelRange(middle, center, [ 255, 0, 0, 255 ], 10);
+
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup");
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE,
+ imgs['../resources/transparent-on-left-indexed.png']);
+ wtu.clearAndDrawUnitQuad(gl);
+ wtu.checkCanvasRect(gl, 0, 0, 128, 16, [255, 0, 255, 0], "should be transparent purple");
+ wtu.checkCanvasRect(gl, 128, 0,128, 16, [255, 255, 0, 255], "should be yellow");
+
+ debug("");
+ debug("check uploading of 1-channel JPG images");
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE,
+ imgs['../resources/1-channel.jpg']);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup");
+ wtu.clearAndDrawUnitQuad(gl);
+ // The image should be gray.
+ checkPixelRange(middle, center, [ 128, 128, 128, 255 ], 28);
+
+ debug("")
+ debug("check calling texImage2D with NULL clears the texture");
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB,
+ imgs['../resources/red-indexed.png'].width,
+ imgs['../resources/red-indexed.png'].height,
+ 0, gl.RGB, gl.UNSIGNED_BYTE, null);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup");
+ wtu.clearAndDrawUnitQuad(gl);
+ // The image should be white.
+ checkPixelRange(middle, center, [ 0, 0, 0, 255 ], 10);
+
+ debug("");
+ successfullyParsed = true;
+ shouldBeTrue("successfullyParsed");
+ debug('<br /><span class="pass">TEST COMPLETE</span>');
+ notifyFinishedToHarness();
+}
+</script>
+</body>
+</html>
+
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/mipmap-fbo.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/mipmap-fbo.html
new file mode 100644
index 000000000..b44f5eee3
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/mipmap-fbo.html
@@ -0,0 +1,89 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+ <head>
+<meta charset="utf-8">
+ <title>Tests if mipmap generation on a texture filled by an FBO works correctly</title>
+ <link rel="stylesheet" href="../../resources/js-test-style.css"/>
+ <script src=/resources/testharness.js></script>
+ <script src=/resources/testharnessreport.js></script>
+ <script src="../../resources/js-test-pre.js"></script>
+ <script src="../resources/webgl-test-utils.js"> </script>
+</head>
+<body>
+<canvas id="example" width="24" height="24"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+"use strict";
+function init(){
+ var wtu = WebGLTestUtils;
+ description();
+
+ var gl = wtu.create3DContext("example");
+ var program = wtu.setupTexturedQuad(gl);
+
+ // setup render target texture //
+ var texture = gl.createTexture();
+ gl.bindTexture(gl.TEXTURE_2D, texture);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 2, 2, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
+ gl.bindTexture(gl.TEXTURE_2D, null);
+
+ // setup framebuffer //
+ var fbo = gl.createFramebuffer();
+ gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
+ gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
+ gl.bindFramebuffer(gl.FRAMEBUFFER, null);
+
+ // fill the framebuffer //
+ gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
+ gl.clearColor(1, 0, 1, 1);
+ gl.clear(gl.COLOR_BUFFER_BIT);
+ gl.bindFramebuffer(gl.FRAMEBUFFER, null);
+
+ // generate mipmap //
+ gl.bindTexture(gl.TEXTURE_2D, texture);
+ gl.generateMipmap(gl.TEXTURE_2D);
+
+ gl.drawArrays(gl.TRIANGLES, 0, 6);
+
+ // readback //
+ wtu.checkCanvas(gl, [255, 0, 255, 255]);
+}
+
+init();
+var successfullyParsed = true;
+</script>
+<script src="../../resources/js-test-post.js"></script>
+
+</body>
+</html>
+
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/origin-clean-conformance.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/origin-clean-conformance.html
new file mode 100644
index 000000000..1e33a24d2
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/origin-clean-conformance.html
@@ -0,0 +1,151 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL Origin Restrictions Conformance Tests</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+<script>
+"use strict";
+var wtu = WebGLTestUtils;
+
+// Checks if function throws an exception.
+function causedException(func) {
+ var hadException = false;
+ try {
+ func();
+ } catch(e) {
+ hadException = true;
+ }
+ return hadException;
+}
+
+var defaultImgUrl = "http://www.opengl.org/img/opengl_logo.jpg";
+var localImgUrl = "../resources/opengl_logo.jpg";
+
+var imgDomain;
+var pageDomain;
+var successfullyParsed;
+
+function imageLoaded() {
+ description("This test ensures WebGL implementations follow proper same-origin restrictions.");
+ var img = this;
+
+ assertMsg(img.width > 0 && img.height > 0, "img was loaded");
+ imgDomain = wtu.getBaseDomain(wtu.getHost(img.src));
+ pageDomain = wtu.getBaseDomain(window.location.host);
+ assertMsg(imgDomain != pageDomain,
+ "img domain (" + imgDomain + ") and page domain (" + pageDomain + ") are not the same.");
+
+ function makeTexImage2D(gl, src) {
+ return function() {
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, src);
+ };
+ }
+
+ function makeTexSubImage2D(gl, src) {
+ return function() {
+ gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, src);
+ };
+ }
+
+ function makeReadPixels(gl) {
+ return function() {
+ var buf = new Uint8Array(4);
+ gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, buf);
+ };
+ }
+
+ function makeToDataURL(canvas) {
+ return function() {
+ var data = canvas.toDataURL();
+ }
+ }
+
+ var canvas1 = document.getElementById("canvas1");
+ var gl = wtu.create3DContext(canvas1);
+
+ debug("");
+ debug("check that an attempt to upload an image from another origin throws an exception.");
+ var tex = gl.createTexture();
+ gl.bindTexture(gl.TEXTURE_2D, tex);
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 256, 256, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
+ assertMsg(causedException(makeTexImage2D(gl, img)),
+ "texImage2D with cross-origin image should throw exception.");
+ assertMsg(causedException(makeTexSubImage2D(gl, img)),
+ "texSubImage2D with cross-origin image should throw exception.");
+
+ debug("check that readPixels and toDataURL continue to work against this canvas.");
+ assertMsg(!causedException(makeReadPixels(gl)),
+ "readPixels should never throw exception -- not possible to dirty origin of WebGL canvas.");
+ assertMsg(!causedException(makeToDataURL(canvas1)),
+ "should not throw exception by toDataURL for WebGL canvas, which should stay origin clean.");
+
+ debug("check that an attempt to upload a tainted canvas throws an exception.");
+ var canvas2 = document.getElementById("canvas2");
+ var ctx2d = canvas2.getContext("2d");
+ ctx2d.drawImage(img, 0, 0);
+ assertMsg(causedException(makeToDataURL(canvas2)),
+ "should throw exception by toDataURL for NON origin clean canvas.");
+ assertMsg(causedException(makeTexImage2D(gl, canvas2)),
+ "texImage2D with NON origin clean canvas should throw exception.");
+ assertMsg(causedException(makeTexSubImage2D(gl, canvas2)),
+ "texSubImage2D with NON origin clean canvas should throw exception.");
+
+ debug("check that readPixels and toDataURL continue to work against this canvas.");
+ assertMsg(!causedException(makeReadPixels(gl)),
+ "readPixels should never throw exception -- not possible to dirty origin of WebGL canvas.");
+ assertMsg(!causedException(makeToDataURL(canvas1)),
+ "should not throw exception by toDataURL for WebGL canvas, which should stay origin clean.");
+
+ // TODO: Should check video.
+ // TODO: Should check CORS support.
+
+ debug("");
+ successfullyParsed = true;
+ shouldBeTrue("successfullyParsed");
+ debug('<br /><span class="pass">TEST COMPLETE</span>');
+ notifyFinishedToHarness();
+}
+
+wtu.setupImageForCrossOriginTest("#img", defaultImgUrl, localImgUrl, imageLoaded);
+</script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="canvas1"></canvas>
+<canvas id="canvas2"></canvas>
+<img id="img" style="display:none;">
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-array-buffer-view.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-array-buffer-view.html
new file mode 100644
index 000000000..a21f2de5e
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-array-buffer-view.html
@@ -0,0 +1,260 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+</head>
+<body>
+<canvas id="example" width="16" height="16"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+"use strict";
+description('Verifies texImage2D and texSubImage2D code paths taking ArrayBufferView');
+
+var wtu = WebGLTestUtils;
+var gl = null;
+var textureLoc = null;
+var successfullyParsed = false;
+
+function roundUpToAlignment(value, alignment) {
+ return Math.floor((value + alignment - 1) / alignment) * alignment;
+}
+
+function generateRGBAData(type, unpackAlignment, sourceData, width, height)
+{
+ var numColors = sourceData.length / 4;
+ var colorOffset = function(y) {
+ return 4 * Math.floor(y * numColors / height);
+ };
+
+ switch (type) {
+ case gl.UNSIGNED_BYTE: {
+ var rowWidth = roundUpToAlignment(width * 4, unpackAlignment);
+ var data = new Uint8Array(height * rowWidth);
+ for (var y = 0; y < height; ++y) {
+ var index = y * rowWidth;
+ var offset = colorOffset(y);
+ for (var element = 0; element < width * 4; ++element) {
+ data[index + element] = sourceData[offset + element % 4];
+ }
+ }
+ return data;
+ }
+ case gl.UNSIGNED_SHORT_4_4_4_4: {
+ var rowWidth = roundUpToAlignment(width * 2, unpackAlignment) / 2;
+ var data = new Uint16Array(height * rowWidth);
+ for (var y = 0; y < height; ++y) {
+ var offset = colorOffset(y);
+ for (var x = 0; x < width; ++x) {
+ var index = y * rowWidth + x;
+ data[index] = (((sourceData[offset + 0] & 0xF0) << 8)
+ | ((sourceData[offset + 1] & 0xF0) << 4)
+ | ((sourceData[offset + 2] & 0xF0) >> 0)
+ | ((sourceData[offset + 3] & 0xF0) >> 4));
+ }
+ }
+ return data;
+ }
+ case gl.UNSIGNED_SHORT_5_5_5_1: {
+ var rowWidth = roundUpToAlignment(width * 2, unpackAlignment) / 2;
+ var data = new Uint16Array(height * rowWidth);
+ for (var y = 0; y < height; ++y) {
+ var offset = colorOffset(y);
+ for (var x = 0; x < width; ++x) {
+ var index = y * rowWidth + x;
+ data[index] = (((sourceData[offset + 0] & 0xF8) << 8)
+ | ((sourceData[offset + 1] & 0xF8) << 3)
+ | ((sourceData[offset + 2] & 0xF8) >> 2)
+ | ((sourceData[offset + 3] & 0x80) >> 7));
+ }
+ }
+ return data;
+ }
+ }
+}
+
+function typeToString(type)
+{
+ switch (type) {
+ case gl.UNSIGNED_BYTE: return 'UNSIGNED_BYTE';
+ case gl.UNSIGNED_SHORT_5_5_5_1: return 'UNSIGNED_SHORT_5_5_5_1';
+ case gl.UNSIGNED_SHORT_4_4_4_4: return 'UNSIGNED_SHORT_4_4_4_4';
+ }
+ return 'Unknown type ' + type;
+}
+
+function runOneIteration(useTexSubImage2D, type, unpackAlignment, flipY, premultiplyAlpha, topColor, bottomColor, extraColor)
+{
+ debug('Testing ' + (useTexSubImage2D ? 'texSubImage2D' : 'texImage2D') +
+ ' with type=' + typeToString(type) +
+ ', unpackAlignment=' + unpackAlignment +
+ ', flipY=' + flipY + ', premultiplyAlpha=' + premultiplyAlpha);
+ gl.colorMask(true, true, true, true);
+ gl.clearColor(0, 0, 0, 1.0);
+ gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+ // Enable writes to the RGB channels
+ gl.colorMask(true, true, true, false);
+ var texture = gl.createTexture();
+ // Bind the texture to texture unit 0
+ gl.bindTexture(gl.TEXTURE_2D, texture);
+ // Set up texture parameters
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
+ // Set up pixel store parameters
+ gl.pixelStorei(gl.UNPACK_ALIGNMENT, unpackAlignment);
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipY);
+ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, premultiplyAlpha);
+ // Generate the data
+ var sourceData = [ 255, 0, 0, 255,
+ 0, 255, 0, 0 ];
+ var texWidth = 5; // this must be mod 4 + 1 to test unpackAlignment
+ var texHeight = 16;
+ var data = generateRGBAData(type, unpackAlignment, sourceData, texWidth, texHeight);
+ if (gl.getError() != gl.NO_ERROR)
+ testFailed("GL error before texture upload");
+ // Upload the image into the texture
+ if (useTexSubImage2D) {
+ // Initialize the texture to black first
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, texWidth, texHeight, 0,
+ gl.RGBA, type, null);
+ if (gl.getError() != gl.NO_ERROR)
+ testFailed("GL error after texImage2D(null)");
+ gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, texWidth, texHeight, gl.RGBA, type, data);
+ if (gl.getError() != gl.NO_ERROR)
+ testFailed("GL error after texSubImage2D");
+ } else {
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, texWidth, texHeight, 0, gl.RGBA, type, data);
+ if (gl.getError() != gl.NO_ERROR)
+ testFailed("GL error after texImage2D");
+ }
+
+ // Point the uniform sampler to texture unit 0
+ gl.uniform1i(textureLoc, 0);
+ // Draw the triangles
+ wtu.clearAndDrawUnitQuad(gl, [0, 0, 0, 255]);
+
+ // Check the top pixel and bottom pixel and make sure they have
+ // the right color.
+ var testWidth = gl.drawingBufferWidth;
+ var testHeight = gl.drawingBufferHeight / 2;
+ wtu.checkCanvasRect(gl, 0, 0, testWidth, testHeight, bottomColor, "bottom pixel should be " + bottomColor);
+ wtu.checkCanvasRect(gl, 0, testHeight, testWidth, testHeight, topColor, "top pixel should be " + topColor);
+
+ // Change part of the texture.
+ var partWidth = 8;
+ var partHeight = 16;
+ // make texture double res of part.
+ var data = generateRGBAData(type, unpackAlignment, sourceData, partWidth * 2, partHeight * 2);
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, partWidth * 2, partHeight * 2, 0, gl.RGBA, type, data);
+ // set part.
+ var extraData = [
+ 255, 0, 0, 255,
+ 0, 0, 255, 0
+ ];
+ var data = generateRGBAData(type, unpackAlignment, extraData, partWidth, partHeight);
+ gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, partWidth, partHeight, gl.RGBA, type, data);
+ wtu.clearAndDrawUnitQuad(gl, [0, 0, 0, 255]);
+ var halfWidth = gl.drawingBufferWidth / 2;
+ var halfHeight = gl.drawingBufferHeight / 2;
+ var quarterHeight = gl.drawingBufferHeight / 4;
+ var red = [255, 0, 0, 255];
+ var tcolor0 = flipY ? extraColor : red;
+ var tcolor1 = flipY ? red : extraColor;
+ wtu.checkCanvasRect(gl, 0, 0, halfWidth, quarterHeight, tcolor0, "bottom left bottom pixels should be " + tcolor0);
+ wtu.checkCanvasRect(gl, 0, quarterHeight, halfWidth, quarterHeight, tcolor1, "bottom left top pixels should be " + tcolor1);
+ wtu.checkCanvasRect(gl, halfWidth, 0, halfWidth, halfHeight, bottomColor, "bottom right pixels should be " + bottomColor);
+ wtu.checkCanvasRect(gl, 0, halfHeight, testWidth, halfHeight, topColor, "top pixels should be " + topColor);
+ // set far corner.
+ gl.texSubImage2D(gl.TEXTURE_2D, 0, partWidth, partHeight, partWidth, partHeight, gl.RGBA, type, data);
+ wtu.clearAndDrawUnitQuad(gl, [0, 0, 0, 255]);
+ wtu.checkCanvasRect(gl, 0, 0, halfWidth, quarterHeight, tcolor0, "bottom left bottom pixels should be " + tcolor0);
+ wtu.checkCanvasRect(gl, 0, quarterHeight, halfWidth, quarterHeight, tcolor1, "bottom left top pixels should be " + tcolor1);
+ wtu.checkCanvasRect(gl, halfWidth, 0, halfWidth, halfHeight, bottomColor, "bottom left pixels should be " + bottomColor);
+ wtu.checkCanvasRect(gl, 0, halfHeight, halfWidth, halfHeight, topColor, "top right pixels should be " + topColor);
+ wtu.checkCanvasRect(gl, halfWidth, halfHeight, halfWidth, quarterHeight, tcolor0, "top right bottom pixels should be " + tcolor0);
+ wtu.checkCanvasRect(gl, halfWidth, halfHeight + quarterHeight, halfWidth, quarterHeight, tcolor1, "top right top pixels should be " + tcolor1);
+}
+
+function runTest()
+{
+ var red = [255, 0, 0, 255];
+ var green = [0, 255, 0, 255];
+ var blue = [0, 0, 255, 255];
+ var redPremultiplyAlpha = [255, 0, 0, 255];
+ var greenPremultiplyAlpha = [0, 0, 0, 255];
+ var bluePremultiplyAlpha = [0, 0, 0, 255];
+
+ var types = [ gl.UNSIGNED_BYTE, gl.UNSIGNED_SHORT_5_5_5_1, gl.UNSIGNED_SHORT_4_4_4_4 ];
+ var unpackAlignments = [ 1, 2, 4, 8 ];
+
+ for (var i = 0; i < types.length; ++i) {
+ var type = types[i];
+ for (var j = 0; j < unpackAlignments.length; ++j) {
+ var unpackAlignment = unpackAlignments[j];
+ runOneIteration(false, type, unpackAlignment, true, false,
+ red, green, blue);
+ runOneIteration(false, type, unpackAlignment, false, false,
+ green, red, blue);
+ runOneIteration(false, type, unpackAlignment, true, true,
+ redPremultiplyAlpha, greenPremultiplyAlpha, bluePremultiplyAlpha);
+ runOneIteration(false, type, unpackAlignment, false, true,
+ greenPremultiplyAlpha, redPremultiplyAlpha, bluePremultiplyAlpha);
+ runOneIteration(true, type, unpackAlignment, true, false,
+ red, green, blue);
+ runOneIteration(true, type, unpackAlignment, false, false,
+ green, red, blue);
+ runOneIteration(true, type, unpackAlignment, true, true,
+ redPremultiplyAlpha, greenPremultiplyAlpha, bluePremultiplyAlpha);
+ runOneIteration(true, type, unpackAlignment, false, true,
+ greenPremultiplyAlpha, redPremultiplyAlpha, bluePremultiplyAlpha);
+ }
+ }
+
+}
+
+var gl = wtu.create3DContext("example");
+var program = wtu.setupTexturedQuad(gl);
+
+textureLoc = gl.getUniformLocation(program, "tex");
+
+runTest();
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be no errors");
+var successfullyParsed = true;
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-canvas-rgb565.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-canvas-rgb565.html
new file mode 100644
index 000000000..82c4c5eac
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-canvas-rgb565.html
@@ -0,0 +1,50 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+<script src="../resources/tex-image-and-sub-image-2d-with-canvas.js"></script>
+<script>
+"use strict";
+function testPrologue(gl) {
+ return true;
+}
+</script>
+</head>
+<body onload='generateTest("RGB", "UNSIGNED_SHORT_5_6_5", testPrologue)()'>
+<canvas id="example" width="32" height="32"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-canvas-rgba4444.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-canvas-rgba4444.html
new file mode 100644
index 000000000..e6f506032
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-canvas-rgba4444.html
@@ -0,0 +1,50 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+<script src="../resources/tex-image-and-sub-image-2d-with-canvas.js"></script>
+<script>
+"use strict";
+function testPrologue(gl) {
+ return true;
+}
+</script>
+</head>
+<body onload='generateTest("RGBA", "UNSIGNED_SHORT_4_4_4_4", testPrologue)()'>
+<canvas id="example" width="32" height="32"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-canvas-rgba5551.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-canvas-rgba5551.html
new file mode 100644
index 000000000..e1f546c2f
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-canvas-rgba5551.html
@@ -0,0 +1,50 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+<script src="../resources/tex-image-and-sub-image-2d-with-canvas.js"></script>
+<script>
+"use strict";
+function testPrologue(gl) {
+ return true;
+}
+</script>
+</head>
+<body onload='generateTest("RGBA", "UNSIGNED_SHORT_5_5_5_1", testPrologue)()'>
+<canvas id="example" width="32" height="32"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-canvas.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-canvas.html
new file mode 100644
index 000000000..be6e2e0a0
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-canvas.html
@@ -0,0 +1,50 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+<script src="../resources/tex-image-and-sub-image-2d-with-canvas.js"></script>
+<script>
+"use strict";
+function testPrologue(gl) {
+ return true;
+}
+</script>
+</head>
+<body onload='generateTest("RGBA", "UNSIGNED_BYTE", testPrologue)()'>
+<canvas id="example" width="32" height="32"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-image-data-rgb565.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-image-data-rgb565.html
new file mode 100644
index 000000000..240a40728
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-image-data-rgb565.html
@@ -0,0 +1,51 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+<script src="../resources/tex-image-and-sub-image-2d-with-image-data.js"></script>
+<script>
+"use strict";
+function testPrologue(gl) {
+ return true;
+}
+</script>
+</head>
+<body onload='generateTest("RGB", "UNSIGNED_SHORT_5_6_5", testPrologue)()'>
+<canvas id="texcanvas" width="1" height="2"></canvas>
+<canvas id="example" width="1" height="2"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-image-data-rgba4444.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-image-data-rgba4444.html
new file mode 100644
index 000000000..11d5f9112
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-image-data-rgba4444.html
@@ -0,0 +1,51 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+<script src="../resources/tex-image-and-sub-image-2d-with-image-data.js"></script>
+<script>
+"use strict";
+function testPrologue(gl) {
+ return true;
+}
+</script>
+</head>
+<body onload='generateTest("RGBA", "UNSIGNED_SHORT_4_4_4_4", testPrologue)()'>
+<canvas id="texcanvas" width="1" height="2"></canvas>
+<canvas id="example" width="1" height="2"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-image-data-rgba5551.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-image-data-rgba5551.html
new file mode 100644
index 000000000..c154ed682
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-image-data-rgba5551.html
@@ -0,0 +1,51 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+<script src="../resources/tex-image-and-sub-image-2d-with-image-data.js"></script>
+<script>
+"use strict";
+function testPrologue(gl) {
+ return true;
+}
+</script>
+</head>
+<body onload='generateTest("RGBA", "UNSIGNED_SHORT_5_5_5_1", testPrologue)()'>
+<canvas id="texcanvas" width="1" height="2"></canvas>
+<canvas id="example" width="1" height="2"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-image-data.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-image-data.html
new file mode 100644
index 000000000..ca3c77c47
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-image-data.html
@@ -0,0 +1,51 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+<script src="../resources/tex-image-and-sub-image-2d-with-image-data.js"></script>
+<script>
+"use strict";
+function testPrologue(gl) {
+ return true;
+}
+</script>
+</head>
+<body onload='generateTest("RGBA", "UNSIGNED_BYTE", testPrologue)()'>
+<canvas id="texcanvas" width="1" height="2"></canvas>
+<canvas id="example" width="1" height="2"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-image-rgb565.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-image-rgb565.html
new file mode 100644
index 000000000..09f13c2c5
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-image-rgb565.html
@@ -0,0 +1,50 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+<script src="../resources/tex-image-and-sub-image-2d-with-image.js"></script>
+<script>
+"use strict";
+function testPrologue(gl) {
+ return true;
+}
+</script>
+</head>
+<body onload='generateTest("RGB", "UNSIGNED_SHORT_5_6_5", "..", testPrologue)()'>
+<canvas id="example" width="32" height="32"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-image-rgba4444.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-image-rgba4444.html
new file mode 100644
index 000000000..c72824ba1
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-image-rgba4444.html
@@ -0,0 +1,50 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+<script src="../resources/tex-image-and-sub-image-2d-with-image.js"></script>
+<script>
+"use strict";
+function testPrologue(gl) {
+ return true;
+}
+</script>
+</head>
+<body onload='generateTest("RGBA", "UNSIGNED_SHORT_4_4_4_4", "..", testPrologue)()'>
+<canvas id="example" width="32" height="32"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-image-rgba5551.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-image-rgba5551.html
new file mode 100644
index 000000000..d238fe92b
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-image-rgba5551.html
@@ -0,0 +1,50 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+<script src="../resources/tex-image-and-sub-image-2d-with-image.js"></script>
+<script>
+"use strict";
+function testPrologue(gl) {
+ return true;
+}
+</script>
+</head>
+<body onload='generateTest("RGBA", "UNSIGNED_SHORT_5_5_5_1", "..", testPrologue)()'>
+<canvas id="example" width="32" height="32"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-image.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-image.html
new file mode 100644
index 000000000..27ebfe851
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-image.html
@@ -0,0 +1,50 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+<script src="../resources/tex-image-and-sub-image-2d-with-image.js"></script>
+<script>
+"use strict";
+function testPrologue(gl) {
+ return true;
+}
+</script>
+</head>
+<body onload='generateTest("RGBA", "UNSIGNED_BYTE", "..", testPrologue)()'>
+<canvas id="example" width="32" height="32"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-svg-image.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-svg-image.html
new file mode 100644
index 000000000..21cd65185
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-svg-image.html
@@ -0,0 +1,50 @@
+<!--
+
+/*
+** Copyright (c) 2013 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+<script src="../resources/tex-image-and-sub-image-2d-with-svg-image.js"></script>
+<script>
+"use strict";
+function testPrologue(gl) {
+ return true;
+}
+</script>
+</head>
+<body onload='generateTest("RGBA", "UNSIGNED_BYTE", "..", testPrologue)()'>
+<canvas id="example" width="32" height="32"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-video-rgb565.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-video-rgb565.html
new file mode 100644
index 000000000..73a7e5cdc
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-video-rgb565.html
@@ -0,0 +1,50 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+<script src="../resources/tex-image-and-sub-image-2d-with-video.js"></script>
+<script>
+"use strict";
+function testPrologue(gl) {
+ return true;
+}
+</script>
+</head>
+<body onload='generateTest("RGB", "UNSIGNED_SHORT_5_6_5", testPrologue)()'>
+<canvas id="example" width="32" height="32"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-video-rgba4444.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-video-rgba4444.html
new file mode 100644
index 000000000..e6fdf95de
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-video-rgba4444.html
@@ -0,0 +1,50 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+<script src="../resources/tex-image-and-sub-image-2d-with-video.js"></script>
+<script>
+"use strict";
+function testPrologue(gl) {
+ return true;
+}
+</script>
+</head>
+<body onload='generateTest("RGBA", "UNSIGNED_SHORT_4_4_4_4", testPrologue)()'>
+<canvas id="example" width="32" height="32"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-video-rgba5551.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-video-rgba5551.html
new file mode 100644
index 000000000..ded4438aa
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-video-rgba5551.html
@@ -0,0 +1,50 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+<script src="../resources/tex-image-and-sub-image-2d-with-video.js"></script>
+<script>
+"use strict";
+function testPrologue(gl) {
+ return true;
+}
+</script>
+</head>
+<body onload='generateTest("RGBA", "UNSIGNED_SHORT_5_5_5_1", testPrologue)()'>
+<canvas id="example" width="32" height="32"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-video.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-video.html
new file mode 100644
index 000000000..261c069a6
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-video.html
@@ -0,0 +1,50 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+<script src="../resources/tex-image-and-sub-image-2d-with-video.js"></script>
+<script>
+"use strict";
+function testPrologue(gl) {
+ return true;
+}
+</script>
+</head>
+<body onload='generateTest("RGBA", "UNSIGNED_BYTE", testPrologue)()'>
+<canvas id="example" width="32" height="32"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-webgl-canvas-rgb565.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-webgl-canvas-rgb565.html
new file mode 100644
index 000000000..21e6a872c
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-webgl-canvas-rgb565.html
@@ -0,0 +1,50 @@
+<!--
+
+/*
+** Copyright (c) 2014 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+<script src="../resources/tex-image-and-sub-image-2d-with-webgl-canvas.js"></script>
+<script>
+"use strict";
+function testPrologue(gl) {
+ return true;
+}
+</script>
+</head>
+<body onload='generateTest("RGB", "UNSIGNED_SHORT_5_6_5", testPrologue)()'>
+<canvas id="example" width="32" height="32"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-webgl-canvas-rgba4444.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-webgl-canvas-rgba4444.html
new file mode 100644
index 000000000..e8fdb8752
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-webgl-canvas-rgba4444.html
@@ -0,0 +1,50 @@
+<!--
+
+/*
+** Copyright (c) 2014 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+<script src="../resources/tex-image-and-sub-image-2d-with-webgl-canvas.js"></script>
+<script>
+"use strict";
+function testPrologue(gl) {
+ return true;
+}
+</script>
+</head>
+<body onload='generateTest("RGBA", "UNSIGNED_SHORT_4_4_4_4", testPrologue)()'>
+<canvas id="example" width="32" height="32"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-webgl-canvas-rgba5551.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-webgl-canvas-rgba5551.html
new file mode 100644
index 000000000..0b60cf8f0
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-webgl-canvas-rgba5551.html
@@ -0,0 +1,50 @@
+<!--
+
+/*
+** Copyright (c) 2014 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+<script src="../resources/tex-image-and-sub-image-2d-with-webgl-canvas.js"></script>
+<script>
+"use strict";
+function testPrologue(gl) {
+ return true;
+}
+</script>
+</head>
+<body onload='generateTest("RGBA", "UNSIGNED_SHORT_5_5_5_1", testPrologue)()'>
+<canvas id="example" width="32" height="32"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-webgl-canvas.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-webgl-canvas.html
new file mode 100644
index 000000000..1e7138315
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-webgl-canvas.html
@@ -0,0 +1,50 @@
+<!--
+
+/*
+** Copyright (c) 2014 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+<script src="../resources/tex-image-and-sub-image-2d-with-webgl-canvas.js"></script>
+<script>
+"use strict";
+function testPrologue(gl) {
+ return true;
+}
+</script>
+</head>
+<body onload='generateTest("RGBA", "UNSIGNED_BYTE", testPrologue)()'>
+<canvas id="example" width="32" height="32"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-uniform-binding-bugs.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-uniform-binding-bugs.html
new file mode 100644
index 000000000..ff1a44710
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-and-uniform-binding-bugs.html
@@ -0,0 +1,65 @@
+<!--
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+-->
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+
+<script>
+"use strict";
+
+description('Tests passing a vec4 to a uniform and a canvas to texImage2D');
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext();
+var floatProgram = wtu.loadProgramFromFile(gl, "../resources/floatUniformShader.vert", "../resources/noopUniformShader.frag");
+shouldBeUndefined("gl.useProgram(floatProgram)");
+var fval4Loc = gl.getUniformLocation(floatProgram, "fval4");
+wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+shouldBeUndefined("gl.uniform4fv(fval4Loc, new Float32Array([0.1, 0.2, 0.4, 1.0]));");
+
+var tmpcanvas = document.createElement("canvas");
+tmpcanvas.width = 2;
+tmpcanvas.height = 2;
+var texture = gl.createTexture();
+shouldBeUndefined("gl.bindTexture(gl.TEXTURE_2D, texture)");
+shouldBeUndefined("gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, tmpcanvas)");
+
+var successfullyParsed = true;
+
+</script>
+<script src="../../resources/js-test-post.js"></script>
+
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-canvas-corruption.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-canvas-corruption.html
new file mode 100644
index 000000000..28bce9f39
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-canvas-corruption.html
@@ -0,0 +1,74 @@
+<!--
+
+/*
+** Copyright (c) 2014 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>Testing 3D canvas is usable after being used as texImage2D source</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+</head>
+<body>
+<canvas id="example" width="512" height="512"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+"use strict";
+// Regression test for http://crbug.com/368582
+description();
+var wtu = WebGLTestUtils;
+var canvas = document.getElementById("example");
+var ctx = canvas.getContext("2d");
+
+var gl = wtu.create3DContext();
+var texture = gl.createTexture();
+
+var image = wtu.makeImage('../resources/blue-1x1.jpg', function() {
+ renderToCanvas();
+ renderToCanvas();
+ wtu.checkCanvas(ctx, [0, 0, 255, 255], "All pixels should be blue", 2);
+ finishTest();
+});
+
+function renderToCanvas() {
+ // Clear the 2d canvas then draw the image to it (a blue pixel)
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
+
+ // Upload the results to a WebGL texture
+ gl.bindTexture(gl.TEXTURE_2D, texture);
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas);
+}
+
+var successfullyParsed = true;
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-webgl.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-webgl.html
new file mode 100644
index 000000000..e24822bd2
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-webgl.html
@@ -0,0 +1,101 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL texImage2D from WebGL conformance test.</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"> </script>
+</head>
+<body>
+<canvas id="example" width="256" height="16" style="width: 256px; height: 48px;"></canvas>
+<canvas id="source" width="256" height="16" style="width: 256px; height: 48px;"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+"use strict";
+description("Test texImage2D from a webgl canvas.");
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+gl.disable(gl.DITHER);
+var program = wtu.setupTexturedQuad(gl);
+var gl1 = wtu.create3DContext("source");
+gl1.disable(gl.DITHER);
+gl1.disable(gl.BLEND);
+gl1.disable(gl.DEPTH_TEST);
+
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
+wtu.glErrorShouldBe(gl1, gl1.NO_ERROR, "Should be no errors from setup.");
+
+gl.disable(gl.BLEND);
+gl.disable(gl.DEPTH_TEST);
+
+gl1.clearColor(1.0, 0.0, 0.0, 1.0);
+gl1.clear(gl1.COLOR_BUFFER_BIT);
+
+var tex = gl.createTexture();
+gl.bindTexture(gl.TEXTURE_2D, tex);
+gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE, gl1.canvas);
+gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
+gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
+gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
+gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
+wtu.clearAndDrawUnitQuad(gl);
+
+wtu.checkCanvas(gl, [255, 0, 0, 255], "Canvas should be red");
+
+gl1.clearColor(0.0, 1.0, 0.0, 1.0);
+gl1.clear(gl1.COLOR_BUFFER_BIT);
+
+var program1 = wtu.setupTexturedQuad(gl1);
+var tex1 = gl1.createTexture();
+gl1.bindTexture(gl.TEXTURE_2D, tex1);
+gl1.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, 1, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, new Uint8Array([0, 0, 255]));
+
+gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE, gl1.canvas);
+wtu.clearAndDrawUnitQuad(gl);
+
+wtu.checkCanvas(gl, [0, 255, 0, 255], "Canvas should be green");
+
+// Test a scenario from Chrome where a WebGL context would lose its active texture binding when its
+// canvas was used as the texture source for another WebGL context.
+wtu.clearAndDrawUnitQuad(gl1);
+
+wtu.checkCanvas(gl1, [0, 0, 255, 255], "Canvas should be blue");
+
+debug("");
+var successfullyParsed = true;
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
+
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-with-format-and-type.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-with-format-and-type.html
new file mode 100644
index 000000000..84e690423
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-with-format-and-type.html
@@ -0,0 +1,745 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/pnglib.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+
+<script>
+"use strict";
+var wtu = WebGLTestUtils;
+var gl = null;
+var textureLoc = null;
+var successfullyParsed = false;
+
+//----------------------------------------------------------------------
+// Harness
+
+var testCases = [];
+
+var DataMode = {
+ IMAGE: 0,
+ IMAGE_DATA: 1,
+
+ NUM_HTML_MODES: 2,
+
+ RAW_DATA: 2,
+
+ // This must remain the last mode.
+ NUM_MODES: 3
+};
+
+function init()
+{
+ description('Verify texImage2D and texSubImage2D code paths taking both HTML and user-specified data with all format/type combinations');
+
+ var canvas = document.getElementById("example");
+ gl = wtu.create3DContext(canvas);
+ gl.disable(gl.DITHER);
+ var program = wtu.setupTexturedQuad(gl);
+
+ gl.clearColor(0,0,0,1);
+ gl.clearDepth(1);
+ gl.disable(gl.BLEND);
+
+ textureLoc = gl.getUniformLocation(program, "tex");
+
+ initializeTests();
+}
+
+function initializeTests()
+{
+ // Verify that uploading to packed pixel formats performs the
+ // required conversion and associated loss of precision.
+ for (var dataMode = 0; dataMode < DataMode.NUM_HTML_MODES; ++dataMode) {
+ for (var useTexSubImage2D = 0; useTexSubImage2D < 2; ++useTexSubImage2D) {
+ testCases.push({
+ dataMode: dataMode,
+ useTexSubImage2D: !!useTexSubImage2D,
+ width: 256,
+ height: 1,
+ generator: generateOpaqueGrayscaleRamp,
+ premultiplyAlpha: false,
+ format: gl.RGBA,
+ type: gl.UNSIGNED_BYTE,
+ verifier: allChannelsIncreaseByNoMoreThan,
+ threshold: 1,
+ numOccurrences: 1,
+ description: "RGBA/UNSIGNED_BYTE should maintain full precision of data"
+ });
+ testCases.push({
+ dataMode: dataMode,
+ useTexSubImage2D: !!useTexSubImage2D,
+ width: 256,
+ height: 1,
+ generator: generateOpaqueGrayscaleRamp,
+ premultiplyAlpha: false,
+ format: gl.RGBA,
+ type: gl.UNSIGNED_SHORT_4_4_4_4,
+ verifier: allChannelsIncreaseByAtLeast,
+ threshold: 15,
+ numOccurrences: 10,
+ description: "RGBA/UNSIGNED_SHORT_4_4_4_4 must drop low four bits of precision"
+ });
+ testCases.push({
+ dataMode: dataMode,
+ useTexSubImage2D: !!useTexSubImage2D,
+ width: 256,
+ height: 1,
+ generator: generateOpaqueGrayscaleRamp,
+ premultiplyAlpha: false,
+ format: gl.RGBA,
+ type: gl.UNSIGNED_SHORT_5_5_5_1,
+ verifier: allChannelsIncreaseByAtLeast,
+ threshold: 7,
+ numOccurrences: 20,
+ description: "RGBA/UNSIGNED_SHORT_5_5_5_1 must drop low three bits of precision"
+ });
+ testCases.push({
+ dataMode: dataMode,
+ useTexSubImage2D: !!useTexSubImage2D,
+ width: 256,
+ height: 1,
+ generator: generateOpaqueGrayscaleRamp,
+ premultiplyAlpha: false,
+ format: gl.RGB,
+ type: gl.UNSIGNED_BYTE,
+ verifier: allChannelsIncreaseByNoMoreThan,
+ threshold: 1,
+ numOccurrences: 1,
+ description: "RGB/UNSIGNED_BYTE should maintain full precision of data"
+ });
+ testCases.push({
+ dataMode: dataMode,
+ useTexSubImage2D: !!useTexSubImage2D,
+ width: 256,
+ height: 1,
+ generator: generateOpaqueGrayscaleRamp,
+ premultiplyAlpha: false,
+ format: gl.RGB,
+ type: gl.UNSIGNED_SHORT_5_6_5,
+ verifier: allChannelsIncreaseByAtLeast,
+ threshold: 3,
+ numOccurrences: 20,
+ description: "RGB/UNSIGNED_SHORT_5_6_5 must drop low two or three bits of precision"
+ });
+ testCases.push({
+ dataMode: dataMode,
+ useTexSubImage2D: !!useTexSubImage2D,
+ width: 256,
+ height: 1,
+ generator: generateTranslucentGrayscaleRamp,
+ premultiplyAlpha: false,
+ format: gl.ALPHA,
+ type: gl.UNSIGNED_BYTE,
+ verifier: alphaChannelIncreasesByNoMoreThan,
+ threshold: 1,
+ numOccurrences: 1,
+ description: "ALPHA/UNSIGNED_BYTE should maintain full precision of data"
+ });
+ testCases.push({
+ dataMode: dataMode,
+ useTexSubImage2D: !!useTexSubImage2D,
+ width: 256,
+ height: 1,
+ generator: generateOpaqueGrayscaleRamp,
+ premultiplyAlpha: false,
+ format: gl.LUMINANCE,
+ type: gl.UNSIGNED_BYTE,
+ verifier: allChannelsIncreaseByNoMoreThan,
+ threshold: 1,
+ numOccurrences: 1,
+ description: "LUMINANCE/UNSIGNED_BYTE should maintain full precision of data"
+ });
+ testCases.push({
+ dataMode: dataMode,
+ useTexSubImage2D: !!useTexSubImage2D,
+ width: 256,
+ height: 1,
+ generator: generateOpaqueGrayscaleRamp,
+ premultiplyAlpha: false,
+ format: gl.LUMINANCE_ALPHA,
+ type: gl.UNSIGNED_BYTE,
+ verifier: allChannelsIncreaseByNoMoreThan,
+ threshold: 1,
+ numOccurrences: 1,
+ description: "LUMINANCE_ALPHA/UNSIGNED_BYTE should maintain full precision of data"
+ });
+ }
+ }
+
+ // Verify that setting the UNPACK_PREMULTIPLY_ALPHA_WEBGL pixel
+ // store parameter and sending down a zero alpha causes the color
+ // channels to go to zero.
+ for (var dataMode = 0; dataMode < DataMode.NUM_MODES; ++dataMode) {
+ for (var useTexSubImage2D = 0; useTexSubImage2D < 2; ++useTexSubImage2D) {
+ testCases.push({
+ dataMode: dataMode,
+ useTexSubImage2D: !!useTexSubImage2D,
+ width: 256,
+ height: 1,
+ generator: generateTransparentGrayscaleRamp,
+ premultiplyAlpha: true,
+ format: gl.RGBA,
+ type: gl.UNSIGNED_BYTE,
+ verifier: colorChannelsAreZero,
+ description: "UNPACK_PREMULTIPLY_ALPHA_WEBGL with RGBA/UNSIGNED_BYTE"
+ });
+ testCases.push({
+ dataMode: dataMode,
+ useTexSubImage2D: !!useTexSubImage2D,
+ width: 256,
+ height: 1,
+ generator: generateTransparentGrayscaleRamp,
+ premultiplyAlpha: true,
+ format: gl.RGBA,
+ type: gl.UNSIGNED_SHORT_4_4_4_4,
+ verifier: colorChannelsAreZero,
+ description: "UNPACK_PREMULTIPLY_ALPHA_WEBGL with RGBA/UNSIGNED_SHORT_4_4_4_4"
+ });
+ testCases.push({
+ dataMode: dataMode,
+ useTexSubImage2D: !!useTexSubImage2D,
+ width: 256,
+ height: 1,
+ generator: generateTransparentGrayscaleRamp,
+ premultiplyAlpha: true,
+ format: gl.RGBA,
+ type: gl.UNSIGNED_SHORT_5_5_5_1,
+ verifier: colorChannelsAreZero,
+ description: "UNPACK_PREMULTIPLY_ALPHA_WEBGL with RGBA/UNSIGNED_SHORT_5_5_5_1"
+ });
+ // The following few tests are invalid for the raw data
+ // mode because there is either no alpha channel or no
+ // separate alpha channel.
+ if (dataMode != DataMode.RAW_DATA) {
+ testCases.push({
+ dataMode: dataMode,
+ useTexSubImage2D: !!useTexSubImage2D,
+ width: 256,
+ height: 1,
+ generator: generateTransparentGrayscaleRamp,
+ premultiplyAlpha: true,
+ format: gl.RGB,
+ type: gl.UNSIGNED_BYTE,
+ verifier: colorChannelsAreZero,
+ description: "UNPACK_PREMULTIPLY_ALPHA_WEBGL with RGB/UNSIGNED_BYTE"
+ });
+ testCases.push({
+ dataMode: dataMode,
+ useTexSubImage2D: !!useTexSubImage2D,
+ width: 256,
+ height: 1,
+ generator: generateTransparentGrayscaleRamp,
+ premultiplyAlpha: true,
+ format: gl.RGB,
+ type: gl.UNSIGNED_SHORT_5_6_5,
+ verifier: colorChannelsAreZero,
+ description: "UNPACK_PREMULTIPLY_ALPHA_WEBGL with RGB/UNSIGNED_SHORT_5_6_5"
+ });
+ testCases.push({
+ dataMode: dataMode,
+ useTexSubImage2D: !!useTexSubImage2D,
+ width: 256,
+ height: 1,
+ generator: generateTransparentGrayscaleRamp,
+ premultiplyAlpha: true,
+ format: gl.ALPHA,
+ type: gl.UNSIGNED_BYTE,
+ verifier: colorChannelsAreZero,
+ description: "UNPACK_PREMULTIPLY_ALPHA_WEBGL with ALPHA/UNSIGNED_BYTE"
+ });
+ testCases.push({
+ dataMode: dataMode,
+ useTexSubImage2D: !!useTexSubImage2D,
+ width: 256,
+ height: 1,
+ generator: generateTransparentGrayscaleRamp,
+ premultiplyAlpha: true,
+ format: gl.LUMINANCE,
+ type: gl.UNSIGNED_BYTE,
+ verifier: colorChannelsAreZero,
+ description: "UNPACK_PREMULTIPLY_ALPHA_WEBGL with LUMINANCE/UNSIGNED_BYTE"
+ });
+ }
+ testCases.push({
+ dataMode: dataMode,
+ useTexSubImage2D: !!useTexSubImage2D,
+ width: 256,
+ height: 1,
+ generator: generateTransparentGrayscaleRamp,
+ premultiplyAlpha: true,
+ format: gl.LUMINANCE_ALPHA,
+ type: gl.UNSIGNED_BYTE,
+ verifier: colorChannelsAreZero,
+ description: "UNPACK_PREMULTIPLY_ALPHA_WEBGL with LUMINANCE_ALPHA/UNSIGNED_BYTE"
+ });
+ }
+ }
+
+ // Produce data for all testcases. Because we load images, some of
+ // these may generate their data asynchronously.
+ generateTestData();
+}
+
+function generateTestData()
+{
+ for (var i = 0; i < testCases.length; i++) {
+ var testCase = testCases[i];
+ var wrapper = null;
+ switch (testCase.dataMode) {
+ case DataMode.IMAGE:
+ wrapper = new ImageWrapper(testCase.width, testCase.height);
+ break;
+ case DataMode.IMAGE_DATA:
+ wrapper = new ImageDataWrapper(testCase.width, testCase.height);
+ break;
+ case DataMode.RAW_DATA:
+ switch (testCase.type) {
+ case gl.UNSIGNED_BYTE:
+ switch (testCase.format) {
+ case gl.RGBA:
+ wrapper = new RGBA8DataWrapper(testCase.width, testCase.height);
+ break;
+ case gl.RGB:
+ wrapper = new RGB8DataWrapper(testCase.width, testCase.height);
+ break;
+ case gl.ALPHA:
+ wrapper = new A8DataWrapper(testCase.width, testCase.height);
+ break;
+ case gl.LUMINANCE:
+ wrapper = new L8DataWrapper(testCase.width, testCase.height);
+ break;
+ case gl.LUMINANCE_ALPHA:
+ wrapper = new LA8DataWrapper(testCase.width, testCase.height);
+ break;
+ }
+ break;
+ case gl.UNSIGNED_SHORT_4_4_4_4:
+ wrapper = new RGBA4444DataWrapper(testCase.width, testCase.height);
+ break;
+ case gl.UNSIGNED_SHORT_5_5_5_1:
+ wrapper = new RGBA5551DataWrapper(testCase.width, testCase.height);
+ break;
+ case gl.UNSIGNED_SHORT_5_6_5:
+ wrapper = new RGB565DataWrapper(testCase.width, testCase.height);
+ break;
+ }
+ }
+ testCase.wrapper = wrapper;
+ testCase.generator(wrapper);
+ testCase.wrapper.generateData();
+ }
+
+ // See whether we need to run the tests, in case all of them
+ // generated their results synchronously.
+ maybeRunTests();
+}
+
+var ranTests = false;
+
+function maybeRunTests()
+{
+ if (!ranTests)
+ for (var i = 0; i < testCases.length; ++i)
+ if (!testCases[i].wrapper || !testCases[i].wrapper.data)
+ return;
+
+ ranTests = true;
+
+ for (var i = 0; i < testCases.length; ++i)
+ runOneTest(testCases[i]);
+
+ finishTest();
+}
+
+function testCaseToString(testCase)
+{
+ var mode;
+ switch (testCase.dataMode) {
+ case DataMode.IMAGE:
+ mode = "Image";
+ break;
+ case DataMode.IMAGE_DATA:
+ mode = "ImageData";
+ break;
+ case DataMode.RAW_DATA:
+ mode = "raw data";
+ break;
+ }
+ return (testCase.useTexSubImage2D ? "texSubImage2D" : "texImage2D") +
+ " with " + mode + " at " + testCase.width + "x" + testCase.height;
+}
+
+function runOneTest(testCase)
+{
+ debug("Testing " + testCaseToString(testCase));
+ var data = testCase.wrapper.data;
+ gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+ var texture = gl.createTexture();
+ // Bind the texture to texture unit 0.
+ gl.bindTexture(gl.TEXTURE_2D, texture);
+ // Set up texture parameters.
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
+ // Set up pixel store parameters.
+ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, testCase.premultiplyAlpha);
+ // Upload the image into the texture.
+ if (testCase.useTexSubImage2D) {
+ // Initialize the texture to black first.
+ gl.texImage2D(gl.TEXTURE_2D, 0, testCase.format, testCase.width, testCase.height, 0,
+ testCase.format, testCase.type, null);
+ }
+ switch (testCase.dataMode) {
+ case DataMode.IMAGE:
+ case DataMode.IMAGE_DATA:
+ if (testCase.useTexSubImage2D)
+ gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, testCase.format, testCase.type, data);
+ else
+ gl.texImage2D(gl.TEXTURE_2D, 0, testCase.format, testCase.format, testCase.type, data);
+ break;
+ case DataMode.RAW_DATA:
+ if (testCase.useTexSubImage2D)
+ gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, testCase.width, testCase.height, testCase.format, testCase.type, data);
+ else
+ gl.texImage2D(gl.TEXTURE_2D, 0, testCase.format, testCase.width, testCase.height, 0, testCase.format, testCase.type, data);
+ break;
+ }
+ // Point the uniform sampler to texture unit 0.
+ gl.uniform1i(textureLoc, 0);
+ // Draw the triangles.
+ gl.drawArrays(gl.TRIANGLES, 0, 6);
+ // Clean up the texture.
+ gl.deleteTexture(texture);
+
+ // Read back the rendering results.
+ var buf = new Uint8Array(testCase.width * testCase.height * 4);
+ gl.readPixels(0, 0, testCase.width, testCase.height, gl.RGBA, gl.UNSIGNED_BYTE, buf);
+ // Run the verification routine.
+ if (testCase.verifier(buf, testCase.threshold, testCase.numOccurrences))
+ testPassed(testCase.description);
+ else
+ testFailed(testCase.description);
+}
+
+//----------------------------------------------------------------------
+// Wrappers for programmatic construction of Image, ImageData and raw texture data
+//
+
+function ImageWrapper(width, height)
+{
+ this.pngBuilder_ = new PNGlib(width, height, 256);
+}
+
+ImageWrapper.prototype.getWidth = function() {
+ return this.pngBuilder_.width;
+};
+
+ImageWrapper.prototype.getHeight = function() {
+ return this.pngBuilder_.height;
+};
+
+ImageWrapper.prototype.setPixel = function(x, y, r, g, b, a) {
+ this.pngBuilder_.buffer[this.pngBuilder_.index(x, y)] = this.pngBuilder_.color(r, g, b, a);
+};
+
+// Generates data into "data" property, possibly asynchronously.
+ImageWrapper.prototype.generateData = function() {
+ var that = this;
+ var url = "data:image/png;base64," + this.pngBuilder_.getBase64();
+ var img = wtu.makeImage(url, function() {
+ that.data = img;
+ maybeRunTests();
+ });
+};
+
+function ImageDataWrapper(width, height)
+{
+ if (!ImageDataWrapper.tempCanvas) {
+ ImageDataWrapper.tempCanvas = document.createElement("canvas");
+ }
+ this.imageData_ = ImageDataWrapper.tempCanvas.getContext("2d").createImageData(width, height);
+}
+
+ImageDataWrapper.tempCanvas = null;
+
+ImageDataWrapper.prototype.getWidth = function() {
+ return this.imageData_.width;
+};
+
+ImageDataWrapper.prototype.getHeight = function() {
+ return this.imageData_.height;
+};
+
+ImageDataWrapper.prototype.setPixel = function(x, y, r, g, b, a) {
+ var index = 4 * (this.imageData_.width * y + x);
+ this.imageData_.data[index] = r;
+ this.imageData_.data[index + 1] = g;
+ this.imageData_.data[index + 2] = b;
+ this.imageData_.data[index + 3] = a;
+};
+
+ImageDataWrapper.prototype.generateData = function() {
+ this.data = this.imageData_;
+ maybeRunTests();
+};
+
+function TextureDataWrapper(width, height)
+{
+ this.width_ = width;
+ this.height_ = height;
+}
+
+TextureDataWrapper.prototype.getWidth = function() {
+ return this.width_;
+};
+
+TextureDataWrapper.prototype.getHeight = function() {
+ return this.height_;
+};
+
+TextureDataWrapper.prototype.generateData = function() {
+ this.data = this.data_;
+ maybeRunTests();
+};
+
+function RGBA8DataWrapper(width, height)
+{
+ TextureDataWrapper.call(this, width, height);
+ this.data_ = new Uint8Array(4 * width * height);
+}
+
+RGBA8DataWrapper.prototype = new TextureDataWrapper;
+
+RGBA8DataWrapper.prototype.setPixel = function(x, y, r, g, b, a) {
+ var index = 4 * (this.width_ * y + x);
+ this.data_[index] = r;
+ this.data_[index + 1] = g;
+ this.data_[index + 2] = b;
+ this.data_[index + 3] = a;
+};
+
+function RGBA5551DataWrapper(width, height)
+{
+ TextureDataWrapper.call(this, width, height);
+ this.data_ = new Uint16Array(width * height);
+}
+
+RGBA5551DataWrapper.prototype = new TextureDataWrapper;
+
+RGBA5551DataWrapper.prototype.setPixel = function(x, y, r, g, b, a) {
+ var value = (((r & 0xF8) << 8)
+ | ((g & 0xF8) << 3)
+ | ((b & 0xF8) >> 2)
+ | (a >> 7));
+ this.data_[this.width_ * y + x] = value;
+};
+
+function RGBA4444DataWrapper(width, height)
+{
+ TextureDataWrapper.call(this, width, height);
+ this.data_ = new Uint16Array(width * height);
+}
+
+RGBA4444DataWrapper.prototype = new TextureDataWrapper;
+
+RGBA4444DataWrapper.prototype.setPixel = function(x, y, r, g, b, a) {
+ var value = (((r & 0xF0) << 8)
+ | ((g & 0xF0) << 4)
+ | (b & 0xF0)
+ | (a >> 4));
+ this.data_[this.width_ * y + x] = value;
+};
+
+function RGB8DataWrapper(width, height)
+{
+ TextureDataWrapper.call(this, width, height);
+ this.data_ = new Uint8Array(3 * width * height);
+}
+
+RGB8DataWrapper.prototype = new TextureDataWrapper;
+
+RGB8DataWrapper.prototype.setPixel = function(x, y, r, g, b, a) {
+ var index = 3 * (this.width_ * y + x);
+ this.data_[index] = r;
+ this.data_[index + 1] = g;
+ this.data_[index + 2] = b;
+};
+
+function RGB565DataWrapper(width, height)
+{
+ TextureDataWrapper.call(this, width, height);
+ this.data_ = new Uint16Array(width * height);
+}
+
+RGB565DataWrapper.prototype = new TextureDataWrapper;
+
+RGB565DataWrapper.prototype.setPixel = function(x, y, r, g, b, a) {
+ var value = (((r & 0xF8) << 8)
+ | ((g & 0xFC) << 3)
+ | ((b & 0xF8) >> 3));
+ this.data_[this.width_ * y + x] = value;
+};
+
+function A8DataWrapper(width, height)
+{
+ TextureDataWrapper.call(this, width, height);
+ this.data_ = new Uint8Array(width * height);
+}
+
+A8DataWrapper.prototype = new TextureDataWrapper;
+
+A8DataWrapper.prototype.setPixel = function(x, y, r, g, b, a) {
+ this.data_[this.width_ * y + x] = a;
+};
+
+function L8DataWrapper(width, height)
+{
+ TextureDataWrapper.call(this, width, height);
+ this.data_ = new Uint8Array(width * height);
+}
+
+L8DataWrapper.prototype = new TextureDataWrapper;
+
+L8DataWrapper.prototype.setPixel = function(x, y, r, g, b, a) {
+ this.data_[this.width_ * y + x] = r;
+};
+
+function LA8DataWrapper(width, height)
+{
+ TextureDataWrapper.call(this, width, height);
+ this.data_ = new Uint8Array(2 * width * height);
+}
+
+LA8DataWrapper.prototype = new TextureDataWrapper;
+
+LA8DataWrapper.prototype.setPixel = function(x, y, r, g, b, a) {
+ var index = 2 * (this.width_ * y + x);
+ this.data_[index] = r;
+ this.data_[index + 1] = a;
+};
+
+//----------------------------------------------------------------------
+// Color ramp generation functions
+//
+
+function generateOpaqueGrayscaleRamp(wrapper)
+{
+ var width = wrapper.getWidth();
+ var height = wrapper.getHeight();
+ for (var x = 0; x < width; ++x) {
+ var value = Math.round(255.0 * x / width);
+ for (var y = 0; y < height; ++y)
+ wrapper.setPixel(x, y, value, value, value, 255);
+ }
+}
+
+function generateTranslucentGrayscaleRamp(wrapper)
+{
+ var width = wrapper.getWidth();
+ var height = wrapper.getHeight();
+ for (var x = 0; x < width; ++x) {
+ var value = Math.round(255.0 * x / width);
+ for (var y = 0; y < height; ++y)
+ wrapper.setPixel(x, y, value, value, value, value);
+ }
+}
+
+function generateTransparentGrayscaleRamp(wrapper)
+{
+ var width = wrapper.getWidth();
+ var height = wrapper.getHeight();
+ for (var x = 0; x < width; ++x) {
+ var value = Math.round(255.0 * x / width);
+ for (var y = 0; y < height; ++y)
+ wrapper.setPixel(x, y, value, value, value, 0);
+ }
+}
+
+//----------------------------------------------------------------------
+// Verification routines
+//
+
+function allChannelsIncreaseByNoMoreThan(array, threshold, numOccurrences) {
+ var numFound = 0;
+ for (var i = 4; i < array.length; i += 4)
+ for (var j = 0; j < 4; j++)
+ if (array[i + j] - array[i + j - 4] > threshold)
+ ++numFound;
+
+ return numFound < numOccurrences;
+}
+
+function alphaChannelIncreasesByNoMoreThan(array, threshold, numOccurrences) {
+ var numFound = 0;
+ for (var i = 7; i < array.length; i += 4)
+ if (array[i] - array[i - 4] > threshold)
+ ++numFound;
+
+ return numFound < numOccurrences;
+}
+
+function allChannelsIncreaseByAtLeast(array, threshold, numOccurrences) {
+ var numFound = 0;
+ for (var i = 4; i < array.length; i += 4)
+ for (var j = 0; j < 4; ++j)
+ if (array[i + j] - array[i + j - 4] > threshold)
+ ++numFound;
+
+ return numFound > numOccurrences;
+}
+
+function colorChannelsAreZero(array, threshold, numOccurrences) {
+ var passed = true;
+ var numFailures = 0;
+
+ for (var i = 4; i < array.length; i += 4)
+ for (var j = 0; j < 3; ++j)
+ if (array[i + j] != 0) {
+ passed = false;
+ if (++numFailures <= 5)
+ debug(" array[" + (i + j) + "] should have been 0, was " + array[i + j]);
+ }
+
+ return passed;
+}
+
+</script>
+</head>
+<body onload="init()">
+<canvas id="example" width="256" height="1"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-with-invalid-data.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-with-invalid-data.html
new file mode 100644
index 000000000..a025b3be0
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-image-with-invalid-data.html
@@ -0,0 +1,147 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+ <title>texImage2D and texSubImage2D tests with invalid data</title>
+ <link rel="stylesheet" href="../../resources/js-test-style.css"/>
+ <script src=/resources/testharness.js></script>
+ <script src=/resources/testharnessreport.js></script>
+ <script src="../../resources/js-test-pre.js"></script>
+ <script src="../resources/webgl-test-utils.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="canvas" width="2" height="2"> </canvas>
+<script type="text/javascript">
+description("texImage2D and texSubImage2D tests with invalid data");
+
+var wtu = WebGLTestUtils;
+var canvas = document.getElementById("canvas");
+var gl = wtu.create3DContext(canvas);
+if (!gl)
+ testFailed("Context created.");
+else
+ testPassed("Context created.");
+
+var tex;
+
+function setup() {
+ tex = gl.createTexture();
+ gl.bindTexture(gl.TEXTURE_2D, tex);
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 64, 64, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
+}
+
+function teardown() {
+ gl.deleteTexture(tex);
+}
+
+function test(desc, func, expected) {
+ debug(desc);
+
+ var exc = null;
+ try {
+ func();
+ } catch (x) {
+ exc = x;
+ }
+
+ if (expected == gl.INVALID_OPERATION) {
+ wtu.glErrorShouldBe(gl, expected);
+ } else if (expected == "exception") {
+ if (exc) {
+ testPassed("threw exception");
+ } else {
+ testFailed("did not throw exception");
+ }
+ }
+}
+
+test("Calling texImage2D with no WebGLTexture bound generates INVALID_OPERATION",
+ function () {
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 64, 64, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
+ },
+ gl.INVALID_OPERATION);
+
+test("Calling texSubImage2D with no WebGLTexture bound generates INVALID_OPERATION",
+ function () {
+ var buffer = new Uint8Array(4);
+ gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, buffer);
+ },
+ gl.INVALID_OPERATION);
+
+setup();
+
+test("Passing a buffer not large enough to texImage2D should generate an INVALID_OPERATION",
+ function () {
+ var tooSmall = new Uint8Array(64);
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 64, 64, 0, gl.RGBA, gl.UNSIGNED_BYTE, tooSmall);
+ },
+ gl.INVALID_OPERATION);
+
+test("Passing texImage2D parameter data of Number type should throw an exception",
+ function () {
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 64, 64, 0, gl.RGBA, gl.UNSIGNED_BYTE, 42);
+ },
+ "exception");
+
+test("Passing texImage2D parameter data of String type should throw a TypeError",
+ function () {
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 64, 64, 0, gl.RGBA, gl.UNSIGNED_BYTE, "not a buffer");
+ },
+ "exception");
+test("Passing a buffer not large enough to texSubImage2D should generate an INVALID_OPERATION",
+ function () {
+ var tooSmall = new Uint8Array(64);
+ gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 64, 64, gl.RGBA, gl.UNSIGNED_BYTE, tooSmall);
+ },
+ gl.INVALID_OPERATION);
+
+test("Passing texSubImage2D parameter data of Number type should throw a TypeError",
+ function () {
+ gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 64, 64, gl.RGBA, gl.UNSIGNED_BYTE, 42);
+ },
+ "exception");
+
+test("Passing texSubImage2D parameter data of String type should throw a TypeError",
+ function () {
+ gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 64, 64, gl.RGBA, gl.UNSIGNED_BYTE, "not a buffer");
+ },
+ "exception");
+
+teardown();
+
+debug("");
+var successfullyParsed = true;
+</script>
+<script src="../../resources/js-test-post.js"></script>
+
+</body>
+</html>
+
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-input-validation.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-input-validation.html
new file mode 100644
index 000000000..4d7a54892
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-input-validation.html
@@ -0,0 +1,385 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+
+<script>
+"use strict";
+var wtu = WebGLTestUtils;
+var gl = null;
+var tex = null;
+var error = 0;
+
+function enumToString(value) {
+ return wtu.glEnumToString(gl, value);
+}
+
+function testTexImage2D(testCase)
+{
+ var level = 0;
+ var width = 16;
+ var height = 16;
+ var msg = "" +
+ " internalFormat: " + enumToString(testCase.internalFormat) +
+ " target: " + enumToString(testCase.target) +
+ " format: " + enumToString(testCase.format) +
+ " type: " + enumToString(testCase.type) +
+ " border: " + testCase.border;
+
+ gl.texImage2D(testCase.target, level, testCase.internalFormat, width, height, testCase.border, testCase.format, testCase.type, null);
+ error = testCase.expectedError;
+ wtu.glErrorShouldBe(gl, error, msg);
+}
+
+function testTexSubImage2D(testCase)
+{
+ var level = 0;
+ var xoffset = 0;
+ var yoffset = 0;
+ var width = 16;
+ var height = 16;
+ var msg = ""+
+ " format: " + enumToString(testCase.format) +
+ " type: " + enumToString(testCase.type);
+ var array = new Uint8Array(width * height * 4);
+ gl.texSubImage2D(testCase.target, level, xoffset, yoffset, width, height, testCase.format, testCase.type, array);
+ error = testCase.expectedError;
+ wtu.glErrorShouldBe(gl, error, msg);
+}
+
+function testTexParameter(testCase)
+{
+ var msg = "paramName: " + enumToString(testCase.pname);
+ error = testCase.expectedError;
+ gl.texParameteri(testCase.target, testCase.pname, testCase.param);
+ wtu.glErrorShouldBe(gl, error, msg);
+ gl.texParameterf(testCase.target, testCase.pname, testCase.param);
+ wtu.glErrorShouldBe(gl, error, msg);
+}
+
+function testGetTexParameter(testCase)
+{
+ var msg = "paramName: " + enumToString(testCase.pname);
+ error = testCase.expectedError;
+ gl.getTexParameter(testCase.target, testCase.pname);
+ wtu.glErrorShouldBe(gl, error, msg);
+}
+
+function testCopyTexImage2D(testCase)
+{
+ var level = 0;
+ var x = 0;
+ var y = 0;
+ var width = 16;
+ var height = 16;
+
+ var msg = "" +
+ " colorBufferFormat: " + enumToString(testCase.colorBufferFormat) +
+ " internalFormat: " + enumToString(testCase.internalFormat) +
+ " target: " + enumToString(testCase.target) +
+ " border: " + testCase.border;
+
+ gl.renderbufferStorage(gl.RENDERBUFFER, testCase.colorBufferFormat, width, height);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+ shouldBe("gl.checkFramebufferStatus(gl.FRAMEBUFFER)", "gl.FRAMEBUFFER_COMPLETE");
+
+ gl.copyTexImage2D(testCase.target, level, testCase.internalFormat, x, y, width, height, testCase.border);
+ error = testCase.expectedError;
+ wtu.glErrorShouldBe(gl, error, msg);
+}
+
+function testCopyTexSubImage2D(testCase)
+{
+ var level = 0;
+ var x = 0;
+ var y = 0;
+ var width = 16;
+ var height = 16;
+ var xoffset = 0;
+ var yoffset = 0;
+ var border = 0;
+ var type = gl.UNSIGNED_BYTE;
+ var msg = "" +
+ " colorBufferFormat: " + enumToString(testCase.colorBufferFormat) +
+ " internalFormat: " + enumToString(testCase.internalFormat) +
+ " target: " + enumToString(testCase.target);
+
+ gl.renderbufferStorage(gl.RENDERBUFFER, testCase.colorBufferFormat, width, height);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+ shouldBe("gl.checkFramebufferStatus(gl.FRAMEBUFFER)", "gl.FRAMEBUFFER_COMPLETE");
+
+ gl.texImage2D(testCase.target, level, testCase.internalFormat, xoffset + width, yoffset + height, border, testCase.internalFormat, type, null);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+
+ gl.copyTexSubImage2D(testCase.target, level, xoffset, yoffset, x, y, width, height);
+ error = testCase.expectedError;
+ wtu.glErrorShouldBe(gl, error, msg);
+}
+
+function testCopyFromInternalFBO(testCase)
+{
+ var target = gl.TEXTURE_2D;
+ var level = 0;
+ var x = 0;
+ var y = 0;
+ var width = 16;
+ var height = 16;
+ var xoffset = 0;
+ var yoffset = 0;
+ var border = 0;
+ var type = gl.UNSIGNED_BYTE;
+ var msg = "" +
+ " colorBufferFormat: " + enumToString(testCase.contextAlpha ? gl.RGBA : gl.RGB) +
+ " internalFormat: " + enumToString(testCase.internalFormat);
+
+ if (testCase.contextAlpha)
+ gl = wtu.create3DContext(null, { alpha: true });
+ else
+ gl = wtu.create3DContext(null, { alpha: false });
+ shouldBeNonNull("gl");
+ shouldBeNonNull("tex = gl.createTexture()");
+ gl.bindTexture(target, tex);
+ if (testCase.subImage) {
+ gl.texImage2D(target, level, testCase.internalFormat, xoffset + width, yoffset + height, border, testCase.internalFormat, type, null);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+ gl.copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
+ } else {
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+ gl.copyTexImage2D(target, level, testCase.internalFormat, x, y, width, height, border);
+ }
+ error = testCase.expectedError;
+ wtu.glErrorShouldBe(gl, error, msg);
+}
+
+description("Validate tex functions input parameters");
+
+shouldBeNonNull("gl = wtu.create3DContext()");
+shouldBeNonNull("tex = gl.createTexture()");
+gl.bindTexture(gl.TEXTURE_2D, tex);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+
+debug("");
+debug("Checking TexImage2D: a set of inputs that are valid in GL but invalid in GLES2");
+
+var testCases =
+ [ {target: 0x8064, // GL_PROXY_TEXTURE_2D
+ internalFormat: gl.RGBA,
+ border: 0,
+ format: gl.RGBA,
+ type: gl.UNSIGNED_BYTE,
+ expectedError: gl.INVALID_ENUM},
+ {target: gl.TEXTURE_2D,
+ internalFormat: 0x1903, // GL_RED
+ border: 0,
+ format: 0x1903, // GL_RED
+ type: gl.UNSIGNED_BYTE,
+ expectedError: [gl.INVALID_ENUM, gl.INVALID_VALUE] },
+ {target: gl.TEXTURE_2D,
+ internalFormat: gl.RGBA,
+ border: 1,
+ format: gl.RGBA,
+ type: gl.UNSIGNED_BYTE,
+ expectedError: gl.INVALID_VALUE},
+ {target: gl.TEXTURE_2D,
+ internalFormat: gl.RGBA,
+ border: 0,
+ format: gl.RGB,
+ type: gl.UNSIGNED_BYTE,
+ expectedError: gl.INVALID_OPERATION},
+ {target: gl.TEXTURE_2D,
+ internalFormat: gl.RGBA,
+ border: 0,
+ format: gl.RGBA,
+ type: gl.BYTE,
+ expectedError: gl.INVALID_ENUM},
+ {target: gl.TEXTURE_2D,
+ internalFormat: gl.RGBA,
+ border: 0,
+ format: gl.RGBA,
+ type: gl.UNSIGNED_BYTE,
+ expectedError: gl.NO_ERROR} ];
+
+for (var ii = 0; ii < testCases.length; ++ii)
+ testTexImage2D(testCases[ii]);
+
+debug("");
+debug("Checking TexSubImage2D: a set of inputs that are valid in GL but invalid in GLES2");
+
+testCases =
+ [ {target: gl.TEXTURE_2D,
+ format: 0x1903, // GL_RED
+ type: gl.UNSIGNED_BYTE,
+ expectedError: gl.INVALID_ENUM},
+ {target: gl.TEXTURE_2D,
+ format: gl.RGBA,
+ type: gl.BYTE,
+ expectedError: gl.INVALID_ENUM},
+ {target: gl.TEXTURE_2D,
+ format: gl.RGBA,
+ type: gl.UNSIGNED_BYTE,
+ expectedError: gl.NO_ERROR} ];
+
+for (var ii = 0; ii < testCases.length; ++ii)
+ testTexSubImage2D(testCases[ii]);
+
+debug("");
+debug("Checking TexParameter: a set of inputs that are valid in GL but invalid in GLES2");
+
+testCases =
+ [ {target: 0x0DE0, // GL_TEXTURE_1D
+ pname: gl.TEXTURE_WRAP_T,
+ param: gl.REPEAT,
+ expectedError: gl.INVALID_ENUM},
+ {target: gl.TEXTURE_2D,
+ pname: 0x813A, // GL_TEXTURE_MIN_LOD
+ param: 0,
+ expectedError: gl.INVALID_ENUM},
+ {target: gl.TEXTURE_2D,
+ pname: gl.TEXTURE_WRAP_T,
+ param: 0x2900, // GL_CLAMP
+ expectedError: gl.INVALID_ENUM},
+ {target: gl.TEXTURE_2D,
+ pname: gl.TEXTURE_WRAP_T,
+ param: gl.REPEAT,
+ expectedError: gl.NO_ERROR} ];
+
+for (var ii = 0; ii < testCases.length; ++ii)
+ testTexParameter(testCases[ii]);
+
+debug("");
+debug("Checking GetTexParameter: a set of inputs that are valid in GL but invalid in GLES2");
+
+testCases =
+ [ {target: 0x0DE0, // GL_TEXTURE_1D
+ pname: gl.TEXTURE_WRAP_T,
+ expectedError: gl.INVALID_ENUM},
+ {target: gl.TEXTURE_2D,
+ pname: 0x813A, // GL_TEXTURE_MIN_LOD
+ expectedError: gl.INVALID_ENUM},
+ {target: gl.TEXTURE_2D,
+ pname: gl.TEXTURE_WRAP_T,
+ expectedError: gl.NO_ERROR} ];
+
+for (var ii = 0; ii < testCases.length; ++ii)
+ testGetTexParameter(testCases[ii]);
+
+debug("");
+debug("Checking CopyTexImage2D: a set of inputs that are valid in GL but invalid in GLES2");
+
+var colorBuffer = null;
+var fbo = null;
+
+shouldBeNonNull("fbo = gl.createFramebuffer()");
+gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
+shouldBeNonNull("colorBuffer = gl.createRenderbuffer()");
+gl.bindRenderbuffer(gl.RENDERBUFFER, colorBuffer);
+gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, colorBuffer);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+
+testCases =
+ [ {target: gl.TEXTURE_2D,
+ colorBufferFormat: gl.RGB565,
+ internalFormat: 0x8054, // GL_RGB16
+ border: 0,
+ expectedError: gl.INVALID_ENUM},
+ {target: gl.TEXTURE_2D,
+ colorBufferFormat: gl.RGB565,
+ internalFormat: gl.RGBA,
+ border: 1,
+ expectedError: gl.INVALID_VALUE},
+ {target: gl.TEXTURE_2D,
+ colorBufferFormat: gl.RGB565,
+ internalFormat: gl.RGBA,
+ border: 0,
+ expectedError: gl.INVALID_OPERATION},
+ {target: gl.TEXTURE_2D,
+ colorBufferFormat: gl.RGB565,
+ internalFormat: gl.RGB,
+ border: 0,
+ expectedError: gl.NO_ERROR} ];
+
+for (var ii = 0; ii < testCases.length; ++ii)
+ testCopyTexImage2D(testCases[ii]);
+
+debug("");
+debug("Checking CopyTexSubImage2D: a set of inputs that are valid in GL but invalid in GLES2");
+
+testCases =
+ [ {target: gl.TEXTURE_2D,
+ colorBufferFormat: gl.RGB5_A1,
+ internalFormat: gl.RGBA,
+ expectedError: gl.NO_ERROR},
+ {target: gl.TEXTURE_2D,
+ colorBufferFormat: gl.RGB565,
+ internalFormat: gl.RGBA,
+ expectedError: gl.INVALID_OPERATION} ];
+
+for (var ii = 0; ii < testCases.length; ++ii)
+ testCopyTexSubImage2D(testCases[ii]);
+
+debug("");
+debug("Checking CopyTex{Sub}Image2D: copy from WebGL internal framebuffer");
+
+testCases =
+ [ {contextAlpha: true,
+ internalFormat: gl.RGBA,
+ subImage: false,
+ expectedError: gl.NO_ERROR},
+ {contextAlpha: false,
+ internalFormat: gl.RGBA,
+ subImage: false,
+ expectedError: gl.INVALID_OPERATION},
+ {contextAlpha: true,
+ internalFormat: gl.RGBA,
+ subImage: true,
+ expectedError: gl.NO_ERROR},
+ {contextAlpha: false,
+ internalFormat: gl.RGBA,
+ subImage: true,
+ expectedError: gl.INVALID_OPERATION} ];
+
+for (var ii = 0; ii < testCases.length; ++ii)
+ testCopyFromInternalFBO(testCases[ii]);
+
+var successfullyParsed = true;
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-sub-image-2d-bad-args.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-sub-image-2d-bad-args.html
new file mode 100644
index 000000000..df8865d8c
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-sub-image-2d-bad-args.html
@@ -0,0 +1,94 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+</head>
+<body>
+<canvas id="testbed" width="16" height="16"></canvas>
+<canvas id="c" width="16" height="16"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+"use strict";
+description('Tests texSubImage2D with bad arguments');
+
+var wtu = WebGLTestUtils;
+var c = document.getElementById("c");
+
+var gl = wtu.create3DContext("testbed");
+var tex = gl.createTexture();
+gl.bindTexture(gl.TEXTURE_2D, tex);
+gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, c);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Setup should succeed");
+
+gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 1, gl.RGBA, gl.UNSIGNED_BYTE, c);
+wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "y + height > texture height");
+gl.texSubImage2D(gl.TEXTURE_2D, 0, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, c);
+wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "x + width > texture width");
+gl.texSubImage2D(gl.TEXTURE_2D, 0, -1, 0, gl.RGBA, gl.UNSIGNED_BYTE, c);
+wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "negative x");
+gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, -1, gl.RGBA, gl.UNSIGNED_BYTE, c);
+wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "negative y");
+gl.texSubImage2D(gl.TEXTURE_2D, -1, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, c);
+wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "negative level");
+gl.texSubImage2D(gl.FLOAT, 0, 0,0, gl.RGBA, gl.UNSIGNED_BYTE, c);
+wtu.glErrorShouldBe(gl, gl.INVALID_ENUM, "bad target");
+gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, c);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "good args");
+gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGB, gl.UNSIGNED_BYTE, c);
+wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "format not same as original");
+gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGBA, gl.UNSIGNED_SHORT_4_4_4_4, c);
+wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type not same as original");
+gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE, c);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "make texture RGB");
+gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGB, gl.UNSIGNED_BYTE, c);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "format same as original RGB");
+gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGBA, gl.UNSIGNED_BYTE, c);
+wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "format not same as original RGB");
+gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGB, gl.UNSIGNED_SHORT_5_6_5, c);
+wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type not same as original RGB");
+gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_SHORT_4_4_4_4, c);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "make texture RGBA 4_4_4_4");
+gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGBA, gl.UNSIGNED_SHORT_4_4_4_4, c);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "format same as original RGBA 4_4_4_4");
+gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGB, gl.UNSIGNED_BYTE, c);
+wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "format not same as original RGBA 4_4_4_4");
+gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGBA, gl.UNSIGNED_BYTE, c);
+wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type not same as original RGBA 4_4_4_4");
+
+var successfullyParsed = true;
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-sub-image-2d.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-sub-image-2d.html
new file mode 100644
index 000000000..e5f825d54
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/tex-sub-image-2d.html
@@ -0,0 +1,124 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+<script id="fshader" type="x-shader/x-fragment">
+precision mediump float;
+
+uniform sampler2D tex;
+varying vec2 texCoord;
+
+void main()
+{
+ float intensity = texture2D(tex, texCoord).a;
+ gl_FragColor = vec4(intensity, intensity, intensity, 1.0);
+}
+</script>
+
+</head>
+<body>
+<canvas id="example" width="256" height="1"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+"use strict";
+description('Tests texSubImage2D upload path from Uint8Array');
+
+var wtu = WebGLTestUtils;
+var canvas = document.getElementById("example");
+var gl = wtu.create3DContext(canvas);
+gl.disable(gl.DITHER);
+var program = wtu.setupProgram(
+ gl,
+ [wtu.setupSimpleTextureVertexShader(gl), "fshader"],
+ ['vPosition', 'texCoord0']);
+wtu.setupUnitQuad(gl);
+var textureWidth = 256;
+var textureHeight = 1;
+
+var textureLoc = gl.getUniformLocation(program, "tex");
+
+var texture = gl.createTexture();
+gl.bindTexture(gl.TEXTURE_2D, texture);
+gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
+gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
+gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
+gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
+// Allocate the texture object
+gl.texImage2D(gl.TEXTURE_2D, 0, gl.ALPHA, textureWidth, textureHeight, 0, gl.ALPHA, gl.UNSIGNED_BYTE, null);
+// Prepare the image data
+var array = new Uint8Array(textureWidth);
+for (var i = 0; i < textureWidth; i++)
+ array[i] = i;
+// Fill the texture object with data -- this is actually the code path being tested
+gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, textureWidth, textureHeight, gl.ALPHA, gl.UNSIGNED_BYTE, array);
+
+// Clear and set up
+gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+gl.bindTexture(gl.TEXTURE_2D, texture);
+gl.useProgram(program);
+gl.uniform1i(textureLoc, 0);
+// Draw the texture to the frame buffer
+gl.drawArrays(gl.TRIANGLES, 0, 6);
+
+// Read back the frame buffer
+var buf = new Uint8Array(textureWidth * textureHeight * 4);
+gl.readPixels(0, 0, textureWidth, textureHeight, gl.RGBA, gl.UNSIGNED_BYTE, buf);
+
+// Verify the frame buffer's contents
+var passed = true;
+for (var i = 0; i < textureWidth; i++) {
+ var val = i;
+ if (buf[4 * i + 0] != val ||
+ buf[4 * i + 1] != val ||
+ buf[4 * i + 2] != val) {
+ testFailed("pixel at (" + i + ", 0) was (" +
+ buf[4 * i + 0] + ", " +
+ buf[4 * i + 1] + ", " +
+ buf[4 * i + 2] + "), should be (" +
+ val + ", " + val + ", " + val + ")");
+ passed = false;
+ break;
+ }
+}
+
+if (passed)
+ testPassed("");
+
+var successfullyParsed = true;
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texparameter-test.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texparameter-test.html
new file mode 100644
index 000000000..c719e6501
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texparameter-test.html
@@ -0,0 +1,207 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+ <head>
+<meta charset="utf-8">
+ <title>WebGL TexParameter conformance test.</title>
+ <link rel="stylesheet" href="../../resources/js-test-style.css"/>
+ <script src=/resources/testharness.js></script>
+ <script src=/resources/testharnessreport.js></script>
+ <script src="../../resources/js-test-pre.js"></script>
+ <script src="../resources/webgl-test-utils.js"> </script>
+</head>
+<body>
+<canvas id="example" width="24" height="24"></canvas>
+<canvas id="canvas2d" width="2" height="2"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script id="vshader" type="x-shader/x-vertex">
+uniform mat4 world;
+attribute vec3 vPosition;
+attribute vec2 texCoord0;
+varying vec2 texCoord;
+void main()
+{
+ gl_Position = world * vec4(vPosition, 1);
+ texCoord = texCoord0;
+}
+</script>
+
+<script id="fshader" type="x-shader/x-fragment">
+precision mediump float;
+
+uniform sampler2D tex;
+varying vec2 texCoord;
+void main()
+{
+ gl_FragColor = texture2D(tex, texCoord);
+}
+</script>
+
+<script>
+"use strict";
+function init()
+{
+ description("Tests TexParameter works as expected");
+ debug("");
+
+ var canvas2d = document.getElementById("canvas2d");
+ var ctx2d = canvas2d.getContext("2d");
+
+ var wtu = WebGLTestUtils;
+ var gl = wtu.create3DContext("example");
+ var program = wtu.setupProgram(gl, ["vshader", "fshader"], ["vPosition", "texCoord0"]);
+
+ var vertexObject = gl.createBuffer();
+ gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
+ gl.bufferData(
+ gl.ARRAY_BUFFER,
+ new Float32Array([-1, 1,0, 1,1,0, -1,-1,0,
+ -1,-1,0, 1,1,0, 1,-1,0]),
+ gl.STATIC_DRAW);
+ gl.enableVertexAttribArray(0);
+ gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
+
+ var vertexObject = gl.createBuffer();
+ gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
+ gl.bufferData(
+ gl.ARRAY_BUFFER,
+ new Float32Array([ -2.5,-2.5, 3.5,-2.5, -2.5,3.5,
+ -2.5,3.5, 3.5,-2.5, 3.5,3.5]),
+ gl.STATIC_DRAW);
+ gl.enableVertexAttribArray(1);
+ gl.vertexAttribPointer(1, 2, gl.FLOAT, false, 0, 0);
+
+ var colors = [
+ [0,255,128,255],
+ [128,64,255,255],
+ [192,255,64,255],
+ [200,0,255,255]];
+ var texParam = [
+ gl.REPEAT,
+ gl.CLAMP_TO_EDGE,
+ gl.MIRRORED_REPEAT,
+ gl.REPEAT];
+
+ // Make textures setting the texture parameters differently each time..
+ // This verifies both that the render correct AND that texture parameters
+ // are associated with the textures, not with the texture-units.
+ var textures = [];
+ for (var ii = 0; ii < colors.length; ++ii) {
+ var c = colors[ii];
+ ctx2d.fillStyle =
+ "rgba(" + c[0] + "," + c[1] + "," + c[2] + "," + c[3] + ")";
+ ctx2d.fillRect(0, 0, 1, 1);
+ var tex = gl.createTexture();
+ gl.bindTexture(gl.TEXTURE_2D, tex);
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas2d);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, texParam[ii]);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, texParam[ii]);
+ textures[ii] = tex;
+ }
+
+ var textureLoc = gl.getUniformLocation(program, "tex");
+ var worldLoc = gl.getUniformLocation(program, "world");
+
+ gl.clearColor(1,1,1,1);
+ gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+
+ for (var ii = 0; ii < colors.length; ++ii) {
+ var x = ii % 2;
+ var y = Math.floor(ii / 2);
+ gl.bindTexture(gl.TEXTURE_2D, textures[ii]);
+ gl.uniformMatrix4fv(
+ worldLoc, false,
+ [0.5, 0, 0, 0,
+ 0, 0.5, 0, 0,
+ 0, 0, 1, 0,
+ -0.5 + x, -0.5 + y, 0, 1]);
+ gl.drawArrays(gl.TRIANGLES, 0, 6);
+ }
+
+ var buf = new Uint8Array(24 * 24 * 4);
+ gl.readPixels(0, 0, 24, 24, gl.RGBA, gl.UNSIGNED_BYTE, buf);
+ var passed = true;
+ for (var ii = 0; ii < colors.length; ++ii) {
+ var x = ii % 2;
+ var y = Math.floor(ii / 2);
+ var c = colors[ii];
+ for (var yy = 0; yy < 12; ++yy) {
+ for (var xx = 0; xx < 12; ++xx) {
+ var ec = [0,0,0,0];
+ switch (texParam[ii]) {
+ case gl.REPEAT:
+ if (xx % 2 == 1 && yy % 2 == 0) {
+ ec = c;
+ }
+ break;
+ case gl.CLAMP_TO_EDGE:
+ if (xx < 6 && yy >= 6) {
+ ec = c;
+ }
+ break;
+ case gl.MIRRORED_REPEAT:
+ if (xx % 4 < 2 && yy % 4 >= 2) {
+ ec = c;
+ }
+ break;
+ }
+ var off = ((y * 12 + yy) * 24 + x * 12 + xx) * 4;
+ if (buf[off + 0] != ec[0] ||
+ buf[off + 1] != ec[1] ||
+ buf[off + 2] != ec[2] ||
+ buf[off + 3] != ec[3]) {
+ var msg = 'at (' + (x * 12 + xx) + ', ' + (y * 12 + yy) +
+ ') expected: ' +
+ ec[0] + ', ' + ec[1] + ', ' + ec[2] + ', ' + ec[3] + ' found: ' +
+ buf[off + 0] + ', ' +
+ buf[off + 1] + ', ' +
+ buf[off + 2] + ', ' +
+ buf[off + 3];
+ testFailed(msg);
+ passed = false;
+ }
+ }
+ }
+ }
+ if (passed) {
+ testPassed("rendered as expected");
+ }
+}
+
+init();
+var successfullyParsed = true;
+</script>
+<script src="../../resources/js-test-post.js"></script>
+
+</body>
+</html>
+
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-active-bind-2.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-active-bind-2.html
new file mode 100644
index 000000000..44452b0ac
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-active-bind-2.html
@@ -0,0 +1,233 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+ <head>
+<meta charset="utf-8">
+ <title>WebGL ActiveTexture BindTexture conformance test #2</title>
+ <link rel="stylesheet" href="../../resources/js-test-style.css"/>
+ <script src=/resources/testharness.js></script>
+ <script src=/resources/testharnessreport.js></script>
+ <script src="../../resources/js-test-pre.js"></script>
+ <script src="../resources/webgl-test-utils.js"> </script>
+</head>
+<body>
+<canvas id="example" width="2" height="2" style="width: 40px; height: 40px;"></canvas>
+<canvas id="canvas2d" width="1" height="1" style="width: 40px; height: 40px;"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script id="vshader" type="x-shader/x-vertex">
+uniform mat4 world;
+attribute vec3 vPosition;
+attribute vec2 texCoord0;
+varying vec2 texCoord;
+void main()
+{
+ gl_Position = world * vec4(vPosition, 1);
+ texCoord = texCoord0;
+}
+</script>
+<script id="fshader2d" type="x-shader/x-fragment">
+precision mediump float;
+
+uniform sampler2D tex2d;
+varying vec2 texCoord;
+void main()
+{
+ gl_FragColor = texture2D(tex2d, texCoord);
+}
+</script>
+<script id="fshaderCube" type="x-shader/x-fragment">
+precision mediump float;
+
+uniform samplerCube texCube;
+void main()
+{
+ gl_FragColor = textureCube(texCube, vec3(0,1,0));
+}
+</script>
+
+<script>
+"use strict";
+function init()
+{
+ description(
+ "Tests that binding both TEXTURE_2D and TEXTURE_CUBE_MAP to the same " +
+ "active texture unit works as long as they are not used " +
+ "simultaneously in the same shader program.");
+
+ var canvas2d = document.getElementById("canvas2d");
+ var ctx2d = canvas2d.getContext("2d");
+ ctx2d.globalCompositeOperation = "copy";
+
+ var wtu = WebGLTestUtils;
+ var gl = wtu.create3DContext("example");
+ var program = wtu.setupProgram(
+ gl, ["vshader", "fshader2d"], ["vPosition", "texCoord0"]);
+
+ var program2d = program;
+ var programCube = wtu.setupProgram(
+ gl, ["vshader", "fshaderCube"], ["vPosition", "texCoord0"]);
+
+ var vertexObject = gl.createBuffer();
+ gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
+ gl.bufferData(
+ gl.ARRAY_BUFFER,
+ new Float32Array([-1, 1,0, 1,1,0, -1,-1,0,
+ -1,-1,0, 1,1,0, 1,-1,0]),
+ gl.STATIC_DRAW);
+ gl.enableVertexAttribArray(0);
+ gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
+
+ var vertexObject = gl.createBuffer();
+ gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
+ gl.bufferData(
+ gl.ARRAY_BUFFER,
+ new Float32Array([ 0,0, 1,0, 0,1,
+ 0,1, 1,0, 1,1]),
+ gl.STATIC_DRAW);
+ gl.enableVertexAttribArray(1);
+ gl.vertexAttribPointer(1, 2, gl.FLOAT, false, 0, 0);
+
+ // Make texture unit 1 active.
+ gl.activeTexture(gl.TEXTURE1);
+
+ // Make a 2d texture
+ var tex2d = gl.createTexture();
+ gl.bindTexture(gl.TEXTURE_2D, tex2d);
+ ctx2d.fillStyle = "rgba(0, 0, 255, 255)";
+ ctx2d.fillRect(0, 0, 1, 1);
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas2d);
+
+ // make a cube texture
+ var texCube = gl.createTexture();
+ gl.bindTexture(gl.TEXTURE_CUBE_MAP, texCube);
+ ctx2d.fillStyle = "rgba(255, 0, 255, 255)";
+ ctx2d.fillRect(0, 0, 1, 1);
+ var targets = [
+ gl.TEXTURE_CUBE_MAP_POSITIVE_X,
+ gl.TEXTURE_CUBE_MAP_NEGATIVE_X,
+ gl.TEXTURE_CUBE_MAP_POSITIVE_Y,
+ gl.TEXTURE_CUBE_MAP_NEGATIVE_Y,
+ gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
+ gl.TEXTURE_CUBE_MAP_NEGATIVE_Z];
+ for (var ii = 0; ii < targets.length; ++ii) {
+ gl.texImage2D(targets[ii], 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas2d);
+ }
+
+ // Setup program2d and programCube
+ var tex2dLoc = gl.getUniformLocation(program2d, "tex2d");
+ var world2dLoc = gl.getUniformLocation(program2d, "world");
+ var texCubeLoc = gl.getUniformLocation(programCube, "texCube");
+ var worldCubeLoc = gl.getUniformLocation(programCube, "world");
+
+ gl.useProgram(program2d);
+ gl.uniform1i(tex2dLoc, 1);
+ gl.useProgram(programCube);
+ gl.uniform1i(texCubeLoc, 1);
+
+ gl.clearColor(1,0,0,1);
+ gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+
+ var programs = [program2d, programCube];
+ var worldLocs = [world2dLoc, worldCubeLoc];
+ for (var ii = 0; ii < 4; ++ii) {
+ var x = ii % 2;
+ var y = Math.floor(ii / 2);
+ gl.useProgram(programs[x]);
+ gl.uniformMatrix4fv(
+ worldLocs[x], false,
+ [0.5, 0, 0, 0,
+ 0, 0.5, 0, 0,
+ 0, 0, 1, 0,
+ -0.5 + x, -0.5 + y, 0, 1]);
+ gl.drawArrays(gl.TRIANGLES, 0, 6);
+ }
+
+ var colors = [
+ [0,0,255,255],
+ [255,0,255,255],
+ [0,0,255,255],
+ [255,0,255,255]];
+
+ for (var ii = 0; ii < colors.length; ++ii) {
+ var c = colors[ii];
+ var x = ii % 2;
+ var y = Math.floor(ii / 2);
+ wtu.checkCanvasRect(gl, x, y, 1, 1, c);
+ }
+
+ // Test that binding to one target does not affect the other
+ debug("");
+ debug("Testing texture target binding/unbinding");
+
+ var worldMatrix = [
+ 1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1];
+
+ gl.activeTexture(gl.TEXTURE2);
+
+ // Unbinding the TEXTURE_CUBE_MAP target should not affect the TEXTURE_2D target
+ gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+
+ gl.bindTexture(gl.TEXTURE_2D, tex2d);
+ gl.bindTexture(gl.TEXTURE_CUBE_MAP, texCube);
+ gl.bindTexture(gl.TEXTURE_CUBE_MAP, null);
+
+ gl.useProgram(program2d);
+ gl.uniform1i(tex2dLoc, 2);
+ gl.uniformMatrix4fv(world2dLoc, false, worldMatrix);
+ gl.drawArrays(gl.TRIANGLES, 0, 6);
+
+ wtu.checkCanvasRect(gl, 0, 0, 2, 2, [0,0,255,255]);
+
+ // Unbinding the TEXTURE_2D target should not affect the TEXTURE_CUBE_MAP target
+ gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+
+ gl.bindTexture(gl.TEXTURE_CUBE_MAP, texCube);
+ gl.bindTexture(gl.TEXTURE_2D, tex2d);
+ gl.bindTexture(gl.TEXTURE_2D, null);
+
+ gl.useProgram(programCube);
+ gl.uniform1i(texCubeLoc, 2);
+ gl.uniformMatrix4fv(worldCubeLoc, false, worldMatrix);
+ gl.drawArrays(gl.TRIANGLES, 0, 6);
+
+ wtu.checkCanvasRect(gl, 0, 0, 2, 2, [255,0,255,255]);
+}
+
+init();
+var successfullyParsed = true;
+</script>
+<script src="../../resources/js-test-post.js"></script>
+
+</body>
+</html>
+
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-active-bind.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-active-bind.html
new file mode 100644
index 000000000..31c1eb79b
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-active-bind.html
@@ -0,0 +1,143 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL ActiveTexture BindTexture conformance test.</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+</head>
+<body>
+<canvas id="example" width="2" height="2" style="width: 40px; height: 40px;"></canvas>
+<canvas id="canvas2d" width="1" height="1" style="width: 40px; height: 40px;"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script id="vshader" type="x-shader/x-vertex">
+uniform mat4 world;
+attribute vec3 vPosition;
+attribute vec2 texCoord0;
+varying vec2 texCoord;
+void main()
+{
+ gl_Position = world * vec4(vPosition, 1);
+ texCoord = texCoord0;
+}
+</script>
+<script>
+"use strict";
+var gl;
+
+function init()
+{
+ description(
+ "Tests that glActiveTexture and glBindTexture work as expected" +
+ "Specifically texture targets are per active texture unit.");
+
+ var canvas2d = document.getElementById("canvas2d");
+ var ctx2d = canvas2d.getContext("2d");
+
+ var wtu = WebGLTestUtils;
+ gl = wtu.create3DContext("example");
+ var program = wtu.setupProgram(
+ gl,
+ ["vshader", wtu.setupSimpleTextureFragmentShader(gl)],
+ ['vPosition', 'texCoord0']);
+ wtu.setupUnitQuad(gl);
+ gl.disable(gl.DEPTH_TEST);
+ gl.disable(gl.BLEND);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+
+ var colors = [
+ [0,192,128,255],
+ [128,64,255,255],
+ [192,255,64,255],
+ [200,0,255,255]];
+
+ // Make 4 textures by using 4 active texture units if available.
+ var texunits = Math.min(colors.length, gl.getParameter(gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS))
+ var textures = [];
+ for (var ii = 0; ii < texunits; ++ii) {
+ var tex = gl.createTexture();
+ gl.activeTexture(gl.TEXTURE0 + ii);
+ gl.bindTexture(gl.TEXTURE_2D, tex);
+ textures[ii] = tex;
+ }
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+
+ // now use each texture unit to write into the textures,
+ for (var ii = 0; ii < texunits; ++ii) {
+ var c = colors[ii];
+ ctx2d.fillStyle =
+ "rgba(" + c[0] + "," + c[1] + "," + c[2] + "," + c[3] + ")";
+ ctx2d.fillRect(0, 0, 1, 1);
+ gl.activeTexture(gl.TEXTURE0 + ii);
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas2d);
+ }
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+
+ var textureLoc = gl.getUniformLocation(program, "tex");
+ var worldLoc = gl.getUniformLocation(program, "world");
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+
+ gl.clearColor(1,0,0,1);
+ gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+
+ for (var ii = 0; ii < texunits; ++ii) {
+ var x = ii % 2;
+ var y = Math.floor(ii / 2);
+ gl.uniform1i(textureLoc, ii);
+ gl.uniformMatrix4fv(
+ worldLoc, false,
+ [0.5, 0, 0, 0,
+ 0, 0.5, 0, 0,
+ 0, 0, 1, 0,
+ -0.5 + x, -0.5 + y, 0, 1]);
+ gl.drawArrays(gl.TRIANGLES, 0, 6);
+ }
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+
+ for (var ii = 0; ii < texunits; ++ii) {
+ var x = ii % 2;
+ var y = Math.floor(ii / 2);
+ wtu.checkCanvasRect(gl, x, y, 1, 1, colors[ii]);
+ }
+}
+
+init();
+var successfullyParsed = true;
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+
+</body>
+</html>
+
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-attachment-formats.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-attachment-formats.html
new file mode 100644
index 000000000..f171839b5
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-attachment-formats.html
@@ -0,0 +1,200 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL Texture Attachment Format Conformance Tests</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="canvas" width="2" height="2" style="width: 100px; height:100px; border: 1px solid black;"> </canvas>
+<script>
+"use strict";
+description();
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("canvas");
+if (!gl) {
+ testFailed("context does not exist");
+} else {
+ testPassed("context exists");
+
+ debug("");
+ debug("Checking texture formats.");
+
+ var numValidFormats = 0;
+ var clearColor = [0.25, 0.5, 0.75, 0.25];
+
+ var floatToBits = function(value, bits) {
+ var range = (1 << bits) - 1;
+ var result = 0;
+ if (range > 0) {
+ result = Math.floor(Math.floor(value * range) * 255 / range);
+ }
+
+ //debug("v = " + value + ", bits = " + bits + ", range = " + range + ", result = " + result);
+ return result;
+ }
+
+ var testFormat = function(info) {
+ debug("");
+ debug("testing: " + info.format + ", " + info.type);
+
+ var format = gl[info.format];
+ var type = gl[info.type];
+
+ gl.texImage2D(gl.TEXTURE_2D,
+ 0, // level
+ format, // internalFormat
+ 16, // width
+ 16, // height
+ 0, // border
+ format, // format
+ type, // type
+ null); // data
+ var fbStatus = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
+ debug(wtu.glEnumToString(gl, fbStatus));
+ if (fbStatus != gl.FRAMEBUFFER_COMPLETE) {
+ debug("format unsupported");
+ if (info.mustBeFramebufferComplete) {
+ testFailed(info.format + " must be FRAMEBUFFER_COMPLETE");
+ }
+ return;
+ }
+
+ ++numValidFormats;
+
+ var startExpected = [0, 0, 0, info.channels[3] < 0 ? 255 : 0];
+
+ var expected = [];
+ var tolerance = [];
+ for (var ii = 0; ii < 4; ++ii) {
+ var color = 0;
+ var channel = info.channels[ii];
+ if (channel < 0) {
+ color = ii < 3 ? 0 : 255
+ } else {
+ color = floatToBits(clearColor[channel], info.bits[ii]);
+ }
+ expected.push(color);
+ tolerance.push(channel < 0 ? 0 : (1 + (1 << (8 - info.bits[ii]))));
+ }
+
+ wtu.checkCanvas(gl, startExpected, "should be " + startExpected);
+ gl.clear(gl.COLOR_BUFFER_BIT);
+ wtu.checkCanvas(gl, expected, "should be " + expected + " with tolerance " + tolerance, tolerance);
+ }
+
+ var validFormats = [
+ { format: 'RGBA',
+ type: 'UNSIGNED_BYTE',
+ channels: [0, 1, 2, 3],
+ bits: [8, 8, 8, 8],
+ mustBeFramebufferComplete: true
+ },
+ { format: 'ALPHA',
+ type: 'UNSIGNED_BYTE',
+ channels: [-1, -1, -1, 3],
+ bits: [0, 0, 0, 8],
+ mustBeFramebufferComplete: false
+ },
+ { format: 'RGB',
+ type: 'UNSIGNED_BYTE',
+ channels: [0, 1, 2, -1],
+ bits: [8, 8, 8, 0],
+ mustBeFramebufferComplete: false
+ },
+ { format: 'RGB',
+ type: 'UNSIGNED_SHORT_5_6_5',
+ channels: [0, 1, 2, -1],
+ bits: [5, 6, 5, 0],
+ mustBeFramebufferComplete: false
+ },
+ { format: 'RGBA',
+ type: 'UNSIGNED_SHORT_5_5_5_1',
+ channels: [0, 1, 2, 3],
+ bits: [5, 5, 5, 1],
+ mustBeFramebufferComplete: false
+ },
+ { format: 'RGBA',
+ type: 'UNSIGNED_SHORT_4_4_4_4',
+ channels: [0, 1, 2, 3],
+ bits: [4, 4, 4, 4],
+ mustBeFramebufferComplete: false
+ },
+ { format: 'LUMINANCE',
+ type: 'UNSIGNED_BYTE',
+ channels: [0, 0, 0, -1],
+ bits: [8, 8, 8, -1],
+ mustBeFramebufferComplete: false
+ },
+ { format: 'LUMINANCE_ALPHA',
+ type: 'UNSIGNED_BYTE',
+ channels: [0, 0, 0, 3],
+ bits: [8, 8, 8, 8],
+ mustBeFramebufferComplete: false
+ }
+ ];
+
+ gl.clearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]);
+ var fbo = gl.createFramebuffer();
+ gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
+ var tex = gl.createTexture();
+ gl.bindTexture(gl.TEXTURE_2D, tex);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
+ gl.framebufferTexture2D(
+ gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0);
+
+ for (var ii = 0; ii < validFormats.length; ++ii) {
+ var info = validFormats[ii];
+ testFormat(info);
+ }
+
+ debug("");
+ shouldBeTrue("numValidFormats > 0");
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors");
+}
+
+debug("");
+var successfullyParsed = true;
+
+</script>
+<script src="../../resources/js-test-post.js"></script>
+
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-clear.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-clear.html
new file mode 100644
index 000000000..06282aa91
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-clear.html
@@ -0,0 +1,66 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL texture clear conformance test.</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/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");
+var program = wtu.setupTexturedQuad(gl);
+
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
+
+var tex = gl.createTexture();
+gl.bindTexture(gl.TEXTURE_2D, tex);
+gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
+gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array([0,255,0,255]));
+wtu.clearAndDrawUnitQuad(gl);
+wtu.checkCanvas(
+ gl, [0, 255, 0, 255], "should be green");
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
+var successfullyParsed = true;
+</script>
+<script src="../../resources/js-test-post.js"></script>
+
+</body>
+</html>
+
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-complete.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-complete.html
new file mode 100644
index 000000000..d9f0767af
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-complete.html
@@ -0,0 +1,87 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL "Texture Complete" texture conformance test.</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+</head>
+<body>
+<canvas id="example" width="40" height="40" style="width: 40px; height: 40px;"></canvas>
+<canvas id="canvas2d" width="16" height="16" style="width: 40px; height: 40px;"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+"use strict";
+function init()
+{
+ description(
+ "Checks that a texture that is not -texture-complete- does not draw if"+
+ " filtering needs mips");
+
+ var canvas2d = document.getElementById("canvas2d");
+ var ctx2d = canvas2d.getContext("2d");
+ ctx2d.fillStyle = "rgba(0,192,128,1)";
+ ctx2d.fillRect(0, 0, 16, 16);
+
+ var wtu = WebGLTestUtils;
+ var canvas = document.getElementById("example");
+ var gl = wtu.create3DContext(canvas);
+ var program = wtu.setupTexturedQuad(gl);
+
+ gl.disable(gl.DEPTH_TEST);
+ gl.disable(gl.BLEND);
+
+ var tex = gl.createTexture();
+ gl.bindTexture(gl.TEXTURE_2D, tex);
+ // 16x16 texture no mips
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas2d);
+
+ var loc = gl.getUniformLocation(program, "tex");
+ gl.uniform1i(loc, 0);
+
+ wtu.clearAndDrawUnitQuad(gl);
+ wtu.checkCanvas(gl, [0,0,0,255],
+ "texture that is not -texture-complete- when " +
+ "TEXTURE_MIN_FILTER not NEAREST or LINEAR should draw with 0,0,0,255");
+}
+
+init();
+var successfullyParsed = true;
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+
+</body>
+</html>
+
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-copying-feedback-loops.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-copying-feedback-loops.html
new file mode 100644
index 000000000..5ee7a47d1
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-copying-feedback-loops.html
@@ -0,0 +1,105 @@
+<!--
+
+/*
+** Copyright (c) 2014 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL Texture Copying Feedback Loops Test</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"> </script>
+</head>
+<body>
+<canvas id="example" width="1" height="1" style="width: 40px; height: 40px;"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+
+<script>
+"use strict";
+description("Checks that texture copying feedback loops fail correctly.");
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+
+var texture = gl.createTexture();
+gl.bindTexture(gl.TEXTURE_2D, texture);
+gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 2, 2, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
+gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
+gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
+gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
+gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
+
+var texture2 = gl.createTexture();
+gl.bindTexture(gl.TEXTURE_2D, texture2);
+gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 2, 2, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
+gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
+gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
+gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
+gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
+
+var framebuffer = gl.createFramebuffer();
+gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
+gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
+assertMsg(gl.checkFramebufferStatus(gl.FRAMEBUFFER) == gl.FRAMEBUFFER_COMPLETE,
+ "framebuffer should be FRAMEBUFFER_COMPLETE.");
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after setup");
+
+debug("");
+debug("testing copyTexImage2D");
+gl.bindTexture(gl.TEXTURE_2D, texture);
+gl.copyTexImage2D(gl.TEXTURE_2D, 1, gl.RGBA, 0, 0, 2, 2, 0);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR,
+ "after copyTexImage2D to same texture but different level");
+gl.copyTexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 0, 0, 2, 2, 0);
+wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION,
+ "after copyTexImage2D to same texture same level, invalid feedback loop");
+gl.bindTexture(gl.TEXTURE_2D, texture2);
+gl.copyTexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 0, 0, 2, 2, 0);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR,
+ "after copyTexImage2D to different texture");
+
+debug("");
+debug("testing copyTexSubImage2D");
+gl.bindTexture(gl.TEXTURE_2D, texture);
+gl.copyTexSubImage2D(gl.TEXTURE_2D, 1, 0, 0, 0, 0, 1, 1);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR,
+ "after copyTexSubImage2D to same texture but different level");
+gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, 1, 1);
+wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION,
+ "after copyTexSubImage2D to same texture same level, invalid feedback loop");
+gl.bindTexture(gl.TEXTURE_2D, texture2);
+gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, 1, 1);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR,
+ "after copyTexSubImage2D to different texture");
+var successfullyParsed = true;
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-draw-with-2d-and-cube.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-draw-with-2d-and-cube.html
new file mode 100644
index 000000000..0002dce99
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-draw-with-2d-and-cube.html
@@ -0,0 +1,127 @@
+<!--
+
+/*
+** Copyright (c) 2014 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL ActiveTexture BindTexture conformance test.</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+</head>
+<body>
+<canvas id="example" width="2" height="2" style="width: 40px; height: 40px;"></canvas>
+<canvas id="canvas2d" width="1" height="1" style="width: 40px; height: 40px;"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script id="vshader" type="x-shader/x-vertex">
+attribute vec3 vPosition;
+attribute vec2 texCoord0;
+varying vec2 texCoord;
+void main()
+{
+ gl_Position = vec4(vPosition, 1);
+ texCoord = texCoord0;
+}
+</script>
+<script id="fshader" type="x-shader/x-fragment">
+precision mediump float;
+varying vec2 texCoord;
+uniform sampler2D tex2D;
+uniform samplerCube texCube;
+void main()
+{
+ gl_FragColor = texture2D(tex2D, texCoord);
+ gl_FragColor += textureCube(texCube, vec3(texCoord, 0));
+}
+</script>
+<script>
+"use strict";
+var gl;
+
+function init()
+{
+ description(
+ "Tests drawing with two textures of different type. " +
+ "This test covers an ANGLE validation bug. See http://crbug.com/390412.");
+
+ var canvas2d = document.getElementById("canvas2d");
+ var ctx2d = canvas2d.getContext("2d");
+
+ var wtu = WebGLTestUtils;
+ gl = wtu.create3DContext("example");
+ var program = wtu.setupProgram(
+ gl,
+ ["vshader", "fshader"],
+ ['vPosition', 'texCoord0']);
+ wtu.setupUnitQuad(gl);
+ gl.disable(gl.DEPTH_TEST);
+ gl.disable(gl.BLEND);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+
+ var texture2D = gl.createTexture();
+ gl.activeTexture(gl.TEXTURE0);
+ gl.bindTexture(gl.TEXTURE_2D, texture2D);
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+
+ var textureCube = gl.createTexture();
+ gl.activeTexture(gl.TEXTURE1);
+ gl.bindTexture(gl.TEXTURE_CUBE_MAP, textureCube);
+ gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
+ gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
+ gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
+ gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
+ gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
+ gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+
+ var texture2DLoc = gl.getUniformLocation(program, "tex2D");
+ var textureCubeLoc = gl.getUniformLocation(program, "texCube");
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+
+ gl.clearColor(1,0,0,1);
+ gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+
+ gl.uniform1i(texture2DLoc, 0);
+ gl.uniform1i(textureCubeLoc, 1);
+ gl.drawArrays(gl.TRIANGLES, 0, 6);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+}
+
+init();
+var successfullyParsed = true;
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+
+</body>
+</html>
+
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-fakeblack.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-fakeblack.html
new file mode 100644
index 000000000..883886a94
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-fakeblack.html
@@ -0,0 +1,119 @@
+<!--
+
+/*
+** Copyright (c) 2013 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+ <head>
+<meta charset="utf-8">
+ <title>Tests if fake black textures are corectly implemented on desktops</title>
+ <link rel="stylesheet" href="../../resources/js-test-style.css"/>
+ <script src=/resources/testharness.js></script>
+ <script src=/resources/testharnessreport.js></script>
+ <script src="../../resources/js-test-pre.js"></script>
+ <script src="../resources/webgl-test-utils.js"> </script>
+</head>
+<body>
+<canvas id="example" width="24" height="24"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+"use strict";
+
+function createTexture(gl,r,g,b,a) {
+ // setup render target texture //
+
+ var texture = gl.createTexture();
+ gl.bindTexture(gl.TEXTURE_2D, texture);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, 3, 3, 0, gl.RGB, gl.UNSIGNED_BYTE, null);
+ gl.bindTexture(gl.TEXTURE_2D, null);
+
+ // setup framebuffer //
+ var fbo = gl.createFramebuffer();
+ gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
+ gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
+ gl.bindFramebuffer(gl.FRAMEBUFFER, null);
+
+ // fill the framebuffer //
+ gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
+ gl.clearColor(r, g, b, a);
+ gl.clear(gl.COLOR_BUFFER_BIT);
+ gl.bindFramebuffer(gl.FRAMEBUFFER, null);
+
+ gl.deleteFramebuffer(fbo);
+
+ return texture;
+}
+
+function init(){
+ /*
+ * This test has been written due to a bug found in firefox's code
+ * and fixed in the following patch :
+ * https://bugzilla.mozilla.org/show_bug.cgi?id=879952#c5
+ */
+ var wtu = WebGLTestUtils;
+ description();
+
+ var gl = wtu.create3DContext("example");
+ var program = wtu.setupTexturedQuad(gl);
+
+ var texture0 = createTexture(gl,1,0,0,1);
+ var texture1 = createTexture(gl,0,1,0,1);
+
+ gl.bindTexture(gl.TEXTURE_2D, texture0);
+ gl.drawArrays(gl.TRIANGLES, 0, 6);
+ wtu.checkCanvas(gl, [255, 0, 0, 255]);
+
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT);
+ gl.drawArrays(gl.TRIANGLES, 0, 6);
+ wtu.checkCanvas(gl, [0, 0, 0, 255]);
+
+ gl.bindTexture(gl.TEXTURE_2D, texture1);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
+ gl.drawArrays(gl.TRIANGLES, 0, 6);
+ wtu.checkCanvas(gl, [0, 255, 0, 255]);
+
+ gl.bindTexture(gl.TEXTURE_2D, texture0);
+ gl.drawArrays(gl.TRIANGLES, 0, 6);
+ wtu.checkCanvas(gl, [0, 0, 0, 255]);
+
+
+}
+
+init();
+var successfullyParsed = true;
+</script>
+<script src="../../resources/js-test-post.js"></script>
+
+</body>
+</html>
+
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-formats-test.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-formats-test.html
new file mode 100644
index 000000000..80adad6c6
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-formats-test.html
@@ -0,0 +1,292 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL Texture Format Conformance Tests</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/desktop-gl-constants.js" type="text/javascript"></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="canvas2d" width="2" height="2" style="width: 50px; height: 50px; border: 1px solid black;"></canvas>
+<canvas id="canvas" width="2" height="2" style="width: 100px; height:100px; border: 1px solid black;"> </canvas>
+<script>
+"use strict";
+description("This test ensures WebGL implementations allow the OpenGL ES 2.0 texture formats and do not allow DesktopGL texture formats.");
+
+debug("");
+debug("Canvas.getContext");
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("canvas");
+if (!gl) {
+ testFailed("context does not exist");
+} else {
+ testPassed("context exists");
+
+ debug("");
+ debug("Checking texture formats.");
+
+ var createTexture = function(internalFormat, format, opt_border) {
+ var border = (opt_border === undefined) ? 0 : opt_border;
+ var tex = gl.createTexture();
+ gl.bindTexture(gl.TEXTURE_2D, tex);
+ gl.texImage2D(gl.TEXTURE_2D,
+ 0, // level
+ internalFormat, // internalFormat
+ 16, // width
+ 16, // height
+ border, // border
+ format, // format
+ gl.UNSIGNED_BYTE, // type
+ null); // data
+ }
+
+ var testValidFormat = function(internalFormat, formatName) {
+ createTexture(internalFormat, internalFormat);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR,
+ "was able to create texture of " + formatName);
+ }
+
+ var testInvalidFormat = function(internalFormat, formatName) {
+ createTexture(internalFormat, internalFormat);
+ var err = gl.getError();
+ if (err == gl.NO_ERROR) {
+ testFailed("should NOT be able to create texture of type " + formatName);
+ } else if (err == gl.INVALID_OPERATION) {
+ testFailed("should return gl.INVALID_ENUM for type " + formatName);
+ } else if (err == gl.INVALID_ENUM) {
+ testPassed("not able to create invalid format: " + formatName);
+ }
+ }
+
+ var invalidEnums = [
+ '1',
+ '2',
+ '3',
+ '4',
+ 'RGB4',
+ 'RGB5',
+ 'RGB8',
+ 'RGB10',
+ 'RGB12',
+ 'RGB16',
+ 'RGBA2',
+ 'RGBA4',
+ 'RGB5_A1',
+ 'RGBA8',
+ 'RGB10_A2',
+ 'RGBA12',
+ 'RGBA16',
+ 'BGR',
+ 'BGRA',
+ 'ALPHA4_EXT',
+ 'ALPHA8_EXT',
+ 'ALPHA12_EXT',
+ 'ALPHA16_EXT',
+ 'COMPRESSED_ALPHA',
+ 'COMPRESSED_LUMINANCE',
+ 'COMPRESSED_LUMINANCE_ALPHA',
+ 'COMPRESSED_INTENSITY',
+ 'COMPRESSED_RGB',
+ 'COMPRESSED_RGBA',
+ 'DEPTH_COMPONENT16',
+ 'DEPTH_COMPONENT24',
+ 'DEPTH_COMPONENT32',
+ 'LUMINANCE4_EXT',
+ 'LUMINANCE8_EXT',
+ 'LUMINANCE12_EXT',
+ 'LUMINANCE16_EXT',
+ 'LUMINANCE4_ALPHA4_EXT',
+ 'LUMINANCE6_ALPHA2_EXT',
+ 'LUMINANCE8_ALPHA8_EXT',
+ 'LUMINANCE12_ALPHA4_EXT',
+ 'LUMINANCE12_ALPHA12_EXT',
+ 'LUMINANCE16_ALPHA16_EXT',
+ 'INTENSITY_EXT',
+ 'INTENSITY4_EXT',
+ 'INTENSITY8_EXT',
+ 'INTENSITY12_EXT',
+ 'INTENSITY16_EXT',
+ 'RGB4_EXT',
+ 'RGB5_EXT',
+ 'RGB8_EXT',
+ 'RGB10_EXT',
+ 'RGB12_EXT',
+ 'RGB16_EXT',
+ 'RGBA2_EXT',
+ 'RGBA4_EXT',
+ 'RGB5_A1_EXT',
+ 'RGBA8_EXT',
+ 'RGB10_A2_EXT',
+ 'RGBA12_EXT',
+ 'RGBA16_EXT',
+ 'SLUMINANCE_EXT',
+ 'SLUMINANCE8_EXT',
+ 'SLUMINANCE_ALPHA_EXT',
+ 'SLUMINANCE8_ALPHA8_EXT',
+ 'SRGB_EXT',
+ 'SRGB8_EXT',
+ 'SRGB_ALPHA_EXT',
+ 'SRGB8_ALPHA8'
+ ];
+
+ for (var ii = 0; ii < invalidEnums.length; ++ii) {
+ var formatName = invalidEnums[ii]
+ if (desktopGL[formatName] === undefined) {
+ debug("bad format" + formatName)
+ } else {
+ testInvalidFormat(desktopGL[formatName], "GL_" + formatName);
+ }
+ }
+
+ var validEnums = [
+ 'ALPHA',
+ 'RGB',
+ 'RGBA',
+ 'LUMINANCE',
+ 'LUMINANCE_ALPHA'
+ ];
+
+ for (var ii = 0; ii < validEnums.length; ++ii) {
+ var formatName = validEnums[ii]
+ testValidFormat(gl[formatName], "gl." + formatName);
+ }
+
+ debug("");
+ debug("checking non 0 border parameter to gl.TexImage2D");
+ createTexture(gl['RGBA'], gl['RGBA'], 1);
+ wtu.glErrorShouldBe(gl, gl.INVALID_VALUE,
+ "non 0 border to gl.TexImage2D should return INVALID_VALUE");
+
+
+ var checkTypes = function() {
+ var tex = gl.createTexture();
+ gl.bindTexture(gl.TEXTURE_2D, tex);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
+
+ var loc = gl.getUniformLocation(program, "tex");
+ gl.uniform1i(loc, 0);
+
+ var checkType = function(r, g, b, a, type, format, buf) {
+ var typeName = wtu.glEnumToString(gl, type);
+ var formatName = wtu.glEnumToString(gl, format);
+ var desc = "format: " + formatName + ", type: " + typeName;
+ debug("");
+ debug("checking gl.texImage2D with " + desc);
+ gl.texImage2D(gl.TEXTURE_2D,
+ 0, // level
+ format, // internalFormat
+ 2, // width
+ 2, // height
+ 0, // border
+ format, // format
+ type, // type
+ buf); // data
+
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR,
+ "gl.texImage2D with " + desc + " should generate NO_ERROR");
+
+ wtu.clearAndDrawUnitQuad(gl, [255, 0, 0, 255]);
+ wtu.checkCanvas(gl, [r,g,b,a],
+ "texture " + desc + " should draw with " +
+ r + ", " + g + ", " + b + ", " + a);
+
+ }
+ checkType(
+ 0, 255, 0, 255, gl.UNSIGNED_BYTE, gl.RGBA,
+ new Uint8Array(
+ [ 0, 255, 0, 255,
+ 0, 255, 0, 255,
+ 0, 255, 0, 255,
+ 0, 255, 0, 255]));
+ checkType(
+ 0, 0, 255, 255, gl.UNSIGNED_SHORT_4_4_4_4, gl.RGBA,
+ new Uint16Array(
+ [ 255, 255,
+ 255, 255,
+ 255, 255,
+ 255, 255]));
+ checkType(
+ 0, 255, 0, 255, gl.UNSIGNED_SHORT_5_6_5, gl.RGB,
+ new Uint16Array(
+ [ 2016, 2016,
+ 2016, 2016,
+ 2016, 2016,
+ 2016, 2016]));
+ checkType(
+ 0, 0, 255, 255, gl.UNSIGNED_SHORT_5_5_5_1, gl.RGBA,
+ new Uint16Array(
+ [ 63, 63,
+ 63, 63,
+ 63, 63,
+ 63, 63]));
+ checkType(
+ 255, 255, 255, 255, gl.UNSIGNED_BYTE, gl.LUMINANCE,
+ new Uint8Array([
+ 255,
+ 255,
+ 255,
+ 255]));
+ checkType(
+ 0, 0, 0, 128, gl.UNSIGNED_BYTE, gl.ALPHA,
+ new Uint8Array([
+ 128,
+ 128,
+ 128,
+ 128]));
+ checkType(
+ 128, 128, 128, 192, gl.UNSIGNED_BYTE, gl.LUMINANCE_ALPHA,
+ new Uint8Array([
+ 128, 192,
+ 128, 192,
+ 128, 192,
+ 128, 192]));
+ }
+ var program = wtu.setupTexturedQuad(gl);
+ gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
+ checkTypes();
+}
+
+debug("");
+var successfullyParsed = true;
+
+</script>
+<script src="../../resources/js-test-post.js"></script>
+
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-hd-dpi.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-hd-dpi.html
new file mode 100644
index 000000000..9fe480bef
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-hd-dpi.html
@@ -0,0 +1,141 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL HD-DPI issues texture conformance test.</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/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();
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+var program = wtu.setupTexturedQuad(gl);
+
+function fillInMips(gl, size) {
+ // fill in the mips
+ var level = 1;
+ for (;;) {
+ size /= 2;
+ if (size < 1) {
+ break;
+ }
+ var numBytes = size * size * 4;
+ var pixels = new Uint8Array(numBytes);
+ for (var jj = 0; jj < numBytes; jj += 4) {
+ pixels[jj + 0] = 0;
+ pixels[jj + 1] = 255;
+ pixels[jj + 2] = 0;
+ pixels[jj + 3] = 255;
+ }
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, size, size, 0, gl.RGBA, gl.UNSIGNED_BYTE, pixels);
+ }
+}
+
+function testCanvas(size) {
+ debug("");
+ debug("testing 2D canvas size " + size + ", " + size);
+
+ var canvas = document.createElement("canvas");
+ canvas.width = size;
+ canvas.height = size;
+ var ctx = canvas.getContext("2d");
+ ctx.fillStyle = "rgb(0,255,0)";
+ ctx.fillRect(0, 0, size, size);
+
+ var tex = gl.createTexture();
+ gl.bindTexture(gl.TEXTURE_2D, tex);
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas);
+
+ fillInMips(gl, size);
+
+ // Draw. If this an HD-DPI device and the 2d canvas is double res or larger
+ // the implementation must scale to CSS pixels (ie, canvas.width, canvas.height)(
+ // when doing the copy in texImage2D. If it has not scaled and instead done
+ // a direct copy of the larger texture this test will not have created enough mips
+ // and will therefore not be "texture complete" and will render in black.
+ wtu.clearAndDrawUnitQuad(gl);
+ wtu.checkCanvas(gl, [0, 255, 0, 255], "should be green");
+}
+
+function testWebGL(size) {
+ debug("");
+ debug("testing WebGL canvas size " + size + ", " + size);
+
+ var canvas = document.createElement("canvas");
+ canvas.width = size;
+ canvas.height = size;
+ var gl2 = wtu.create3DContext(canvas);
+ gl2.clearColor(0,1,0,1);
+ gl2.clear(gl.COLOR_BUFFER_BIT);
+
+ var tex = gl.createTexture();
+ gl.bindTexture(gl.TEXTURE_2D, tex);
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas);
+
+ fillInMips(gl, size);
+
+ // Draw. If this an HD-DPI device check for 2 possible bugs.
+ //
+ // 1) the WebGL canvas is double res or larger. That's just a bug period and
+ // is checked for in another test but would also fail here.
+ //
+ // 2) the WebGL canvas is single res but the code the scales a double res
+ // 2d canvas also mistakenly scales a single res WebGL canvas.
+ //
+ // If it has been scaled then we'll have the wrong kind of mips chain here.
+ // Level 0 will be half resolution. Level 1 will be the same resolution
+ // and will therefore not be "texture complete" and will render in black.
+ wtu.clearAndDrawUnitQuad(gl);
+ wtu.checkCanvas(gl, [0, 255, 0, 255], "should be green");
+}
+
+testCanvas(4);
+testCanvas(512);
+testWebGL(4);
+testWebGL(512);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors");
+
+var successfullyParsed = true;
+
+</script>
+<script src="../../resources/js-test-post.js"></script>
+
+</body>
+</html>
+
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-mips.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-mips.html
new file mode 100644
index 000000000..d435f90e0
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-mips.html
@@ -0,0 +1,320 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL texture mips conformance test.</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+</head>
+<body>
+<canvas id="example" width="2" height="2" style="width: 40px; height: 40px;"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script id="vshader" type="x-shader/x-vertex">
+uniform vec4 uMult;
+attribute vec4 vPosition;
+attribute vec2 texCoord0;
+varying vec2 texCoord;
+void main()
+{
+ gl_Position = vPosition * uMult;
+ texCoord = texCoord0;
+}
+</script>
+
+<script id="fshader" type="x-shader/x-fragment">
+precision mediump float;
+uniform sampler2D tex;
+varying vec2 texCoord;
+void main()
+{
+ gl_FragColor = texture2D(tex, texCoord);
+}
+</script>
+<script>
+"use strict";
+var canvas;
+var wtu = WebGLTestUtils;
+function init()
+{
+ description("Checks mip issues");
+
+ canvas = document.getElementById("example");
+ shouldBe("canvas.width", "2");
+ shouldBe("canvas.height", "2");
+
+ var gl = wtu.create3DContext(canvas);
+
+ var tex = gl.createTexture();
+ gl.bindTexture(gl.TEXTURE_2D, tex);
+ gl.generateMipmap(gl.TEXTURE_2D);
+ wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "for generateMipmap with mip 0 is 0x0");
+ gl.texImage2D(
+ gl.TEXTURE_2D, 1, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE,
+ new Uint8Array(4));
+ gl.generateMipmap(gl.TEXTURE_2D);
+ wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "for generateMipmap with mip 0 is 0x0");
+
+ tex = gl.createTexture();
+ gl.bindTexture(gl.TEXTURE_CUBE_MAP, tex);
+ gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
+ wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "for generateMipmap with mip 0 is 0x0");
+
+ var faces = [
+ gl.TEXTURE_CUBE_MAP_POSITIVE_X,
+ gl.TEXTURE_CUBE_MAP_NEGATIVE_X,
+ gl.TEXTURE_CUBE_MAP_POSITIVE_Y,
+ gl.TEXTURE_CUBE_MAP_NEGATIVE_Y,
+ gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
+ gl.TEXTURE_CUBE_MAP_NEGATIVE_Z
+ ];
+ for (var ii = 0; ii < faces.length; ++ii) {
+ gl.texImage2D(
+ faces[ii], 0, gl.RGBA, 2, 2, 0, gl.RGBA, gl.UNSIGNED_BYTE,
+ new Uint8Array(4 * 2 * 2));
+ gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
+ wtu.glErrorShouldBe(gl, ii == 5 ? gl.NO_ERROR : gl.INVALID_OPERATION, "for generateMipmap with " + (ii + 1) + " faces");
+ }
+
+ wtu.setupUnitQuad(gl, 0, 1);
+ var program = wtu.setupProgram(
+ gl, ['vshader', 'fshader'], ['vPosition', 'texCoord0'], [0, 1]);
+
+ gl.disable(gl.DEPTH_TEST);
+ gl.disable(gl.BLEND);
+
+ var colors = {
+ blue: [0, 0, 255, 255],
+ red: [255, 0, 0, 255],
+ green: [0, 255, 0, 255],
+ cyan: [128, 255, 255, 255],
+ black: [0, 0, 0, 255],
+ blank: [0, 0, 0, 0]
+ };
+
+ var mips = [
+ ];
+
+ var texLoc = gl.getUniformLocation(program, "tex");
+ gl.uniform1i(texLoc, 0);
+ var multLoc = gl.getUniformLocation(program, "uMult");
+
+ // ----------------------------------------------------
+ var clearTex = createTexture();
+ gl.uniform4f(multLoc, 1, 1, 1, 1);
+ gl.bindTexture(gl.TEXTURE_2D, clearTex);
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 16, 16, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
+ debug('gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 16, 16, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);');
+ setMipData(0, 16, 'blank');
+ makeDivMipChain();
+ generateMipmap();
+ check('blank', "texture created with null that has all mips");
+
+ // ----------------------------------------------------
+ var tex = createTexture();
+ gl.uniform4f(multLoc, 1, 1, 1, 1);
+
+ gl.bindTexture(gl.TEXTURE_2D, tex);
+ // 16x16 texture no mips
+ fillLevel(tex, 0, 16, 'cyan');
+
+ check('black',
+ "texture that is missing mips when TEXTURE_MIN_FILTER not NEAREST or LINEAR");
+
+ generateMipmap();
+
+ check('cyan', "texture that has all mips");
+
+ // Fill in the bottom 2 mips with a different color.
+ fillLevel(tex, 4, 1, 'green');
+ fillLevel(tex, 3, 2, 'green');
+
+ // Choose the nearest mip
+ texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_NEAREST);
+
+ check('green', "texture that is only using the smallest 2 mips");
+
+ gl.uniform4f(multLoc, 16, 16, 1, 1);
+
+ check('cyan', "texture that is using only the largest 2 mips");
+
+ // Set the top level
+ fillLevel(tex, 0, 1, 'red');
+ check('red',
+ "texture that is only using the top level even though other levels are defined");
+
+ // Set the top 2 levels using generateMipmap
+ fillLevel(tex, 0, 2, 'blue');
+ generateMipmap();
+
+ check('blue',
+ "texture that is only using the top 2 levels even though other levels are defined");
+
+ // Set the top 2 levels back to sizes that end up using levels 2, 3, and 4 again.
+ fillLevel(tex, 0, 16, 'blue');
+ fillLevel(tex, 1, 8, 'blue');
+ check('blue', "texture that is only using the largest 2 mips");
+ gl.uniform4f(multLoc, 1, 1, 1, 1);
+ check('green', "texture that is only using the smallest 2 mips");
+
+ // ----------------------------------------------------
+ var tex = createTexture();
+ gl.uniform4f(multLoc, 1, 1, 1, 1);
+ fillLevel(tex, 0, 8, 'cyan');
+ generateMipmap();
+ check('cyan', "texture that has 3 mips");
+
+ fillLevel(tex, 0, 16, 'blue');
+ texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
+ check('blue', "texture that is only using top mips");
+
+ fillLevel(tex, 0, 8, 'red');
+ texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_NEAREST);
+ check('cyan', "texture that is only using smallest mips");
+
+ gl.uniform4f(multLoc, 16, 16, 1, 1);
+ check('red', "texture that is using only the largest mip");
+
+ // ----------------------------------------------------
+ var tex = createTexture();
+ gl.uniform4f(multLoc, 1, 1, 1, 1);
+ fillLevel(tex, 2, 1, 'green');
+ fillLevel(tex, 1, 2, 'green');
+ fillLevel(tex, 0, 4, 'green');
+ check('green', "texture that was built smallest mip first");
+
+ // ----------------------------------------------------
+ var tex = createTexture();
+ gl.uniform4f(multLoc, 1, 1, 1, 1);
+ fillLevel(tex, 0, 16, 'red');
+ generateMipmap();
+ check('red', "texture with 1 genmipmaps");
+ fillLevel(tex, 0, 16, 'blue');
+ generateMipmap();
+ fillLevel(tex, 0, 16, 'green');
+ generateMipmap();
+ check('green', "texture with 2 genmipmaps");
+
+ // ----------------------------------------------------
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors.");
+
+ function createTexture() {
+ debug("<hr/>gl.createTexture()");
+ mips = [];
+ makeDivMipChain();
+ return gl.createTexture();
+ }
+
+ function texParameteri(target, pname, value) {
+ debug("gl.texParameteri(" +
+ wtu.glEnumToString(gl, target) + ", " +
+ wtu.glEnumToString(gl, pname) + ", " +
+ wtu.glEnumToString(gl, value) + ")")
+ gl.texParameteri(target, pname, value);
+ }
+
+ function generateMipmap() {
+ debug("gl.generateMipmap(gl.TEXTURE_2D)");
+ gl.generateMipmap(gl.TEXTURE_2D);
+ var mip0 = mips[0];
+ var size = mip0.size;
+ var level = 1;
+ for(;;) {
+ size = Math.floor(size / 2);
+ if (!size) {
+ break;
+ }
+ setMipData(level, size, mip0.color);
+ ++level;
+ }
+ makeDivMipChain();
+ }
+
+ function check(color, msg) {
+ wtu.clearAndDrawUnitQuad(gl);
+ wtu.checkCanvas(gl, colors[color], msg + " should draw with " + color);
+ }
+
+ function fillLevel(tex, level, size, color) {
+ setMipData(level, size, color);
+ debug("gl.texImage2D(gl.TEXTURE_2D, " + level + ", gl.RGBA, " + size + ", " + size +
+ ", 0, gl.RGBA, gl.UNSIGNED_BYTE, " + color + ");");
+ wtu.fillTexture(gl, tex, size, size, colors[color], level);
+ makeDivMipChain();
+ }
+
+ function setMipData(level, size, color) {
+ mips[level] = {
+ size: size,
+ color: color
+ };
+ }
+
+ function makeDivMipChain(color) {
+ var html = [
+ '<div style="height: 68px; margin-top: 5px">',
+ '<div style="float:left;">mips: </div>'];
+ for (var ii = 0; ii < 5; ++ii) {
+ var mip = mips[ii];
+ if (mip) {
+ html.push(makeDivSquare(mip.size, mip.color));
+ } else {
+ html.push(makeDivSquare(16, undefined));
+ }
+ }
+ html.push("</div>");
+ debug(html.join(""));
+ }
+
+ function makeDivSquare(size, color) {
+ size *= 4;
+ var c = color ? colors[color] : [255,255,255];
+ var border = color ? 'solid' : 'dashed';
+ return '<div style="float:left; width: ' + size + 'px; height: ' + size +
+ 'px; background-color: ' + rgb(c) +
+ '; border: 1px ' + border + ' black; margin-right: 3px;"></div>';
+ }
+
+ function rgb(c) {
+ return 'rgb(' + c[0] + ',' + c[1] + ',' + c[2] +')';
+ }
+}
+
+init();
+var successfullyParsed = true;
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
+
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-npot-video.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-npot-video.html
new file mode 100644
index 000000000..87973b63c
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-npot-video.html
@@ -0,0 +1,163 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+<script>
+"use strict";
+var wtu = WebGLTestUtils;
+var gl = null;
+var textureLoc = null;
+var successfullyParsed = false;
+
+initTestingHarness();
+
+function init()
+{
+ description('Verify npot video');
+
+ var canvas = document.getElementById("example");
+ gl = wtu.create3DContext(canvas);
+ var program = wtu.setupTexturedQuad(gl);
+
+ gl.clearColor(0,0,0,1);
+ gl.clearDepth(1);
+ gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+ // Disable any writes to the alpha channel
+ gl.colorMask(1, 1, 1, 0);
+
+ textureLoc = gl.getUniformLocation(program, "tex");
+
+ var video = document.getElementById("vid");
+ wtu.startPlayingAndWaitForVideo(video, runTest);
+}
+
+function runOneIteration(videoElement, useTexSubImage2D, flipY, topColor, bottomColor, badMinFilter, badClamp, genMips)
+{
+ debug('Testing ' + (useTexSubImage2D ? 'texSubImage2D' : 'texImage2D') +
+ ' with flipY=' + flipY);
+ var texture = gl.createTexture();
+ // Bind the texture to texture unit 0
+ gl.bindTexture(gl.TEXTURE_2D, texture);
+ // Set up pixel store parameters
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipY);
+ // Upload the videoElement into the texture
+ debug("size: " + videoElement.videoWidth + "x" + videoElement.videoHeight);
+ if (useTexSubImage2D) {
+ // Initialize the texture to black first
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA,
+ videoElement.videoWidth, videoElement.videoHeight, 0,
+ gl.RGBA, gl.UNSIGNED_BYTE, null);
+ gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, videoElement);
+ } else {
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, videoElement);
+ }
+
+ // Set up texture parameters
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
+ if (badMinFilter) {
+ debug("bad min filter");
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_NEAREST);
+ } else {
+ debug("good min filter");
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
+ }
+ if (badClamp) {
+ debug("bad clamp");
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT);
+ } else {
+ debug("good clamp");
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
+ }
+ if (genMips) {
+ debug("generate mips");
+ gl.generateMipmap(gl.TEXTURE_2D);
+ wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "should be INVALID_OPERATION");
+ }
+
+// var c = document.createElement("canvas");
+// c.width = 16;
+// c.height = 16;
+// c.style.border = "1px solid black";
+// var ctx = c.getContext("2d");
+// ctx.drawImage(videoElement, 0, 0, 16, 16);
+// document.body.appendChild(c);
+
+ // Point the uniform sampler to texture unit 0
+ gl.uniform1i(textureLoc, 0);
+ // Draw the triangles
+ wtu.clearAndDrawUnitQuad(gl, [0, 0, 0, 255]);
+ // Check a few pixels near the top and bottom and make sure they have
+ // the right color.
+ var tolerance = 5;
+ debug("Checking lower left corner");
+ wtu.checkCanvasRect(gl, 4, 4, 2, 2, bottomColor,
+ "shouldBe " + bottomColor, tolerance);
+ debug("Checking upper left corner");
+ wtu.checkCanvasRect(gl, 4, gl.canvas.height - 8, 2, 2, topColor,
+ "shouldBe " + topColor, tolerance);
+ debug("");
+}
+
+function runTest(videoElement)
+{
+ var red = [255, 0, 0];
+ var green = [0, 255, 0];
+ var black = [0, 0, 0];
+ runOneIteration(videoElement, false, true, black, black, true, true, true);
+ runOneIteration(videoElement, false, true, black, black, true, false, false);
+ runOneIteration(videoElement, false, true, black, black, false, true, false);
+ runOneIteration(videoElement, false, true, black, black, true, true, false);
+ runOneIteration(videoElement, false, true, green, red, false, false, false);
+ runOneIteration(videoElement, false, false, red, green, false, false, false);
+ runOneIteration(videoElement, true, true, green, red, false, false, false);
+ runOneIteration(videoElement, true, false, red, green, false, false, false);
+
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be no errors");
+ finishTest();
+}
+</script>
+</head>
+<body onload="init()">
+<canvas id="example" width="64" height="48"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<video id="vid" style="display:none;">
+ <source src="../resources/npot-video.mp4" type='video/mp4; codecs="avc1.42E01E"' />
+ <source src="../resources/npot-video.webmvp8.webm" type='video/webm; codecs="vp8"' />
+ <source src="../resources/npot-video.theora.ogv" type='video/ogg; codecs="theora"' />
+</video>
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-npot.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-npot.html
new file mode 100644
index 000000000..c19d1bbde
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-npot.html
@@ -0,0 +1,329 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL Non-Power of 2 texture conformance test.</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/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);
+
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
+
+var tests = [
+ { format: gl.RGBA,
+ type: gl.UNSIGNED_BYTE,
+ color: [192, 0, 128, 64],
+ expected: [192, 0, 128, 64],
+ tolerance: 0,
+ },
+ { format: gl.RGB,
+ type: gl.UNSIGNED_BYTE,
+ color: [192, 0, 128],
+ expected: [192, 0, 128, 255],
+ tolerance: 0,
+ },
+ { format: gl.LUMINANCE,
+ type: gl.UNSIGNED_BYTE,
+ color: [192],
+ expected: [192, 192, 192, 255],
+ tolerance: 0,
+ },
+ { format: gl.ALPHA,
+ type: gl.UNSIGNED_BYTE,
+ color: [64],
+ expected: [0, 0, 0, 64],
+ tolerance: 0,
+ },
+ { format: gl.LUMINANCE_ALPHA,
+ type: gl.UNSIGNED_BYTE,
+ color: [192, 64],
+ expected: [192, 192, 192, 64],
+ tolerance: 0,
+ },
+ // { format: gl.RGBA,
+ // type: gl.UNSIGNED_SHORT_4_4_4_4,
+ // color: [0x48FC],
+ // expected: [0x44, 0x88, 0xFF, 0xCC],
+ // tolerance: 16,
+ // },
+ // { format: gl.RGBA,
+ // type: gl.UNSIGNED_SHORT_5_5_5_1,
+ // color: [0x8309], // 10000 01000 00100 1
+ // expected: [128, 64, 32, 255],
+ // tolerance: 16,
+ // },
+ // { format: gl.RGB,
+ // type: gl.UNSIGNED_SHORT_5_6_5,
+ // color: [0x8404], // 10000 010000 00100
+ // expected: [128, 64, 32],
+ // tolerance: 16,
+ // },
+];
+
+tests.forEach(function(test) {
+ debug("");
+ debug("test " + wtu.glEnumToString(gl, test.format) + "/" + wtu.glEnumToString(gl, test.type));
+ var tex = gl.createTexture();
+
+ // Check that an NPOT texture not on level 0 generates INVALID_VALUE
+ wtu.fillTexture(gl, tex, 5, 3, test.color, 1, test.format, test.type);
+ wtu.glErrorShouldBe(gl, gl.INVALID_VALUE,
+ "gl.texImage2D with NPOT texture with level > 0 should return INVALID_VALUE");
+
+ // Check that an NPOT texture on level 0 succeeds
+ wtu.fillTexture(gl, tex, 5, 3, test.color, 0, test.format, test.type);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR,
+ "gl.texImage2D with NPOT texture at level 0 should succeed");
+
+ // Check that generateMipmap fails on NPOT
+ gl.generateMipmap(gl.TEXTURE_2D);
+ wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION,
+ "gl.generateMipmap with NPOT texture should return INVALID_OPERATION");
+
+ // Check that nothing is drawn if filtering is not correct for NPOT
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT);
+
+ wtu.clearAndDrawUnitQuad(gl);
+ wtu.checkCanvas(
+ gl, [0, 0, 0, 255],
+ "NPOT texture with TEXTURE_WRAP set to REPEAT should draw with 0,0,0,255");
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
+
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST_MIPMAP_LINEAR);
+
+ wtu.clearAndDrawUnitQuad(gl);
+ wtu.checkCanvas(
+ gl, [0, 0, 0, 255],
+ "NPOT texture with TEXTURE_MIN_FILTER not NEAREST or LINEAR should draw with 0,0,0,255");
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
+
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
+
+ wtu.clearAndDrawUnitQuad(gl);
+ wtu.checkCanvas(
+ gl, test.expected,
+ "NPOT texture with TEXTURE_MIN_FILTER set to LINEAR should draw.");
+
+ gl.copyTexImage2D(gl.TEXTURE_2D, 1, test.format, 0, 0, 5, 3, 0);
+ wtu.glErrorShouldBe(gl, gl.INVALID_VALUE,
+ "copyTexImage2D with NPOT texture with level > 0 should return INVALID_VALUE.");
+
+ // Check that generateMipmap for an POT texture succeeds
+ wtu.fillTexture(gl, tex, 4, 4, test.color, 0, test.format);
+ gl.generateMipmap(gl.TEXTURE_2D);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR,
+ "gl.texImage2D and gl.generateMipmap with POT texture at level 0 should succeed");
+
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT);
+
+ wtu.clearAndDrawUnitQuad(gl);
+ wtu.checkCanvas(
+ gl, test.expected,
+ "POT texture with TEXTURE_MIN_FILTER set to LINEAR_MIPMAP_LINEAR should draw.");
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
+});
+
+var testCubemap = function(switchTextureUnitBeforeDraw) {
+ debug("");
+ var title = "check using cubemap";
+ if (switchTextureUnitBeforeDraw) {
+ title += " and switch texture unit before draw to check for Chromium bug";
+ }
+ debug(title);
+ var program = wtu.setupProgram(
+ gl, ['vshader', 'fshader'], ['vPosition', 'texCoord0'], [0, 1]);
+ var tex = gl.createTexture();
+
+ // Check that an NPOT texture not on level 0 generates INVALID_VALUE
+ fillCubeTexture(gl, tex, 5, 3, [0, 192, 128, 255], 1);
+ wtu.glErrorShouldBe(gl, gl.INVALID_VALUE,
+ "gl.texImage2D with NPOT texture with level > 0 should return INVALID_VALUE");
+
+ // Check that an NPOT texture on level 0 succeeds
+ fillCubeTexture(gl, tex, 5, 5, [0, 192, 128, 255]);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR,
+ "gl.texImage2D with NPOT texture at level 0 should succeed");
+
+ // Check that generateMipmap fails on NPOT
+ gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
+ wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION,
+ "gl.generateMipmap with NPOT texture should return INVALID_OPERATION");
+
+ var loc = gl.getUniformLocation(program, "tex");
+ gl.uniform1i(loc, 0);
+
+ // Check that nothing is drawn if filtering is not correct for NPOT
+ gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
+ gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
+ gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.REPEAT);
+ gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.REPEAT);
+
+ if (switchTextureUnitBeforeDraw) {
+ debug("Switching active texture unit to gl.TEXTURE1");
+ // Test for http://crbug.com/390514
+ gl.activeTexture(gl.TEXTURE1);
+ }
+
+ wtu.clearAndDrawUnitQuad(gl);
+ wtu.checkCanvas(
+ gl, [0, 0, 0, 255],
+ "NPOT cubemap with TEXTURE_WRAP set to REPEAT should draw with 0,0,0,255");
+
+ if (switchTextureUnitBeforeDraw) {
+ var error = gl.getError();
+ if (error === gl.NO_ERROR) {
+ testPassed("getError was expected value: NO_ERROR : Should be no errors from draw.");
+ } else if (error === gl.INVALID_ENUM) {
+ testFailed("getError returned INVALID_ENUM. Possibly Chromium bug where texture unit is set to 0 instead of GL_TEXTURE0.");
+ } else {
+ testFailed("Drawing resulted in error: " + wtu.glEnumToString(gl, error));
+ }
+ gl.activeTexture(gl.TEXTURE0);
+ } else {
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from draw.");
+ }
+
+ gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
+ gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
+ gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.NEAREST_MIPMAP_LINEAR);
+
+ wtu.clearAndDrawUnitQuad(gl);
+ wtu.checkCanvas(
+ gl, [0, 0, 0, 255],
+ "NPOT cubemap with TEXTURE_MIN_FILTER not NEAREST or LINEAR should draw with 0,0,0,255");
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
+
+ gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
+
+ wtu.clearAndDrawUnitQuad(gl);
+ wtu.checkCanvas(
+ gl, [0, 192, 128, 255],
+ "NPOT cubemap with TEXTURE_MIN_FILTER set to LINEAR should draw.");
+
+ // Check that an POT texture on level 0 succeeds
+ fillCubeTexture(gl, tex, 4, 4, [0, 192, 128, 255]);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR,
+ "gl.texImage2D with POT texture at level 0 should succeed");
+
+ gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);
+ gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
+ gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.REPEAT);
+ gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.REPEAT);
+
+ wtu.clearAndDrawUnitQuad(gl);
+ wtu.checkCanvas(
+ gl, [0, 0, 0, 255],
+ "POT cubemap with TEXTURE_MIN_FILTER set to LINEAR_MIPMAP_LINEAR but no mips draw with 0,0,0,255");
+
+ // Check that generateMipmap succeeds on POT
+ gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR,
+ "gl.generateMipmap with POT texture should return succeed");
+
+ wtu.clearAndDrawUnitQuad(gl);
+ wtu.checkCanvas(
+ gl, [0, 192, 128, 255],
+ "POT cubemap with TEXTURE_MIN_FILTER set to LINEAR_MIPMAP_LINEAR should draw.");
+};
+
+testCubemap(false);
+testCubemap(true);
+
+var successfullyParsed = true;
+
+function fillCubeTexture(gl, tex, width, height, color, opt_level) {
+ opt_level = opt_level || 0;
+ var canvas = document.createElement('canvas');
+ canvas.width = width;
+ canvas.height = height;
+ var ctx2d = canvas.getContext('2d');
+ ctx2d.fillStyle = "rgba(" + color[0] + "," + color[1] + "," + color[2] + "," + color[3] + ")";
+ ctx2d.fillRect(0, 0, width, height);
+ gl.bindTexture(gl.TEXTURE_CUBE_MAP, tex);
+ var targets = [
+ gl.TEXTURE_CUBE_MAP_POSITIVE_X,
+ gl.TEXTURE_CUBE_MAP_NEGATIVE_X,
+ gl.TEXTURE_CUBE_MAP_POSITIVE_Y,
+ gl.TEXTURE_CUBE_MAP_NEGATIVE_Y,
+ gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
+ gl.TEXTURE_CUBE_MAP_NEGATIVE_Z];
+ for (var tt = 0; tt < targets.length; ++tt) {
+ gl.texImage2D(
+ targets[tt], opt_level, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas);
+ }
+};
+
+</script>
+<script src="../../resources/js-test-post.js"></script>
+
+</body>
+</html>
+
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-size-cube-maps.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-size-cube-maps.html
new file mode 100644
index 000000000..c04d571c4
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-size-cube-maps.html
@@ -0,0 +1,356 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL texture size cube map conformance test.</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+</head>
+<body>
+<canvas id="example" width="256" height="256" style="width: 40px; height: 40px;"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script id="vshader" type="x-shader/x-vertex">
+attribute vec4 vPosition;
+uniform mat4 rotation;
+varying vec3 texCoord;
+void main()
+{
+ gl_Position = vPosition;
+ vec4 direction = vec4(vPosition.x * 0.5, vPosition.y * 0.5, 1, 1);
+ texCoord = normalize((rotation * direction).xyz);
+}
+</script>
+
+<script id="fshader" type="x-shader/x-fragment">
+precision mediump float;
+uniform samplerCube tex;
+varying vec3 texCoord;
+void main()
+{
+ gl_FragColor = textureCube(tex, normalize(texCoord));
+}
+</script>
+<script>
+"use strict";
+var canvas;
+description("Checks issues with size of cube map textures");
+debug("");
+
+var wtu = WebGLTestUtils;
+var canvas = document.getElementById("example");
+
+var gl = wtu.create3DContext(canvas);
+wtu.setupUnitQuad(gl, 0, 1);
+var program = wtu.setupProgram(
+ gl,
+ ['vshader', 'fshader'],
+ ['vPosition', 'texCoord0'], [0, 1]);
+var rotLoc = gl.getUniformLocation(program, "rotation");
+
+gl.disable(gl.DEPTH_TEST);
+gl.disable(gl.BLEND);
+
+var maxSize = gl.getParameter(gl.MAX_CUBE_MAP_TEXTURE_SIZE);
+debug("max cube map size: " + maxSize);
+maxSize = Math.min(512, maxSize);
+
+// a cube map of 512x512 takes 6meg. I'm assuming it's not
+// unreasonable to expect to be able to allocate a 6meg texture
+
+var colors = [
+ {name: 'red', color: [255, 0, 0, 255]},
+ {name: 'green', color: [ 0, 255, 0, 255]},
+ {name: 'blue', color: [ 0, 0, 255, 255]},
+ {name: 'yellow', color: [255, 255, 0, 255]},
+ {name: 'cyan', color: [ 0, 255, 255, 255]},
+ {name: 'magenta', color: [255, 0, 255, 255]}
+];
+
+var targets = [
+ gl.TEXTURE_CUBE_MAP_POSITIVE_X,
+ gl.TEXTURE_CUBE_MAP_NEGATIVE_X,
+ gl.TEXTURE_CUBE_MAP_POSITIVE_Y,
+ gl.TEXTURE_CUBE_MAP_NEGATIVE_Y,
+ gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
+ gl.TEXTURE_CUBE_MAP_NEGATIVE_Z];
+
+var rotations = [
+ {axis: [0, 1, 0], angle: Math.PI / 2},
+ {axis: [0, 1, 0], angle: -Math.PI / 2},
+ {axis: [1, 0, 0], angle: -Math.PI / 2},
+ {axis: [1, 0, 0], angle: Math.PI / 2},
+ {axis: [0, 1, 0], angle: 0},
+ {axis: [0, 1, 0], angle: Math.PI},
+];
+
+var halfRotations = [
+ {colors: [3, 4], rotations: [{axis: [1, 0, 0], angle: Math.PI / 4}]},
+ {colors: [4, 2], rotations: [{axis: [1, 0, 0], angle: -Math.PI / 4}]},
+ {colors: [5, 3], rotations: [{axis: [1, 0, 0], angle: Math.PI / 4 * 3}]},
+ {colors: [2, 5], rotations: [{axis: [1, 0, 0], angle: -Math.PI / 4 * 3}]},
+ {colors: [3, 0], rotations: [{axis: [0, 1, 0], angle: Math.PI / 2},
+ {axis: [1, 0, 0], angle: Math.PI / 4}]},
+ {colors: [0, 2], rotations: [{axis: [0, 1, 0], angle: Math.PI / 2},
+ {axis: [1, 0, 0], angle: -Math.PI / 4}]},
+];
+
+var count = 0;
+var sizeCount = 0;
+
+test();
+
+function test() {
+ var size = Math.pow(2, sizeCount);
+ if (size > maxSize || !testSize(size)) {
+ finishTest();
+ } else {
+ ++sizeCount;
+ setTimeout(test, 0);
+ }
+}
+
+function testSize(size) {
+ debug("");
+ debug("testing size: " + size);
+ var canvasSize = Math.max(size / 4, 2);
+ canvas.width = canvasSize;
+ canvas.height = canvasSize;
+ gl.viewport(0, 0, canvasSize, canvasSize);
+ var tex = gl.createTexture();
+ gl.bindTexture(gl.TEXTURE_CUBE_MAP, tex);
+
+ // Seems like I should be using LINEAR here with some other math
+ // to make sure I get more mip coverage but that's easier said
+ // than done.
+
+ gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
+ gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
+
+ for (var jj = 0; jj < 2; ++jj) {
+ for (var tt = 0; tt < targets.length; ++tt) {
+ var color = colors[(tt + count) % colors.length];
+ fillLevel(targets[tt], 0, size, color.color);
+ }
+ if (jj == 1) {
+ debug("use mipmap");
+ gl.texParameteri(
+ gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER,
+ gl.NEAREST_MIPMAP_NEAREST);
+ gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
+ }
+
+ var err = gl.getError();
+ if (err == gl.OUT_OF_MEMORY) {
+ debug("out of memory");
+ return false;
+ }
+ if (err != gl.NO_ERROR) {
+ testFailed("unexpected gl error: " + wtu.glEnumToString(gl, err));
+ }
+
+
+ for (var rr = 0; rr < rotations.length; ++rr) {
+ var rot = rotations[rr];
+ var color = colors[(rr + count) % colors.length];
+ var rotMat = axisRotation(rot.axis, rot.angle);
+ gl.uniformMatrix4fv(rotLoc, false, rotMat);
+ wtu.clearAndDrawUnitQuad(gl);
+ wtu.checkCanvas(
+ gl, color.color,
+ wtu.glEnumToString(gl, targets[rr]) + " should be " + color.name);
+ }
+
+ for (var rr = 0; rr < halfRotations.length; ++rr) {
+ var h = halfRotations[rr];
+ var rots = h.rotations;
+ var rotMat = axisRotation(rots[0].axis, rots[0].angle);
+ for (var ii = 1; ii < rots.length; ++ii) {
+ var tmpMat = axisRotation(rots[ii].axis, rots[ii].angle);
+ var rotMat = mulMatrix(tmpMat, rotMat);
+ }
+ gl.uniformMatrix4fv(rotLoc, false, rotMat);
+ wtu.clearAndDrawUnitQuad(gl);
+
+ for (var ii = 0; ii < 2; ++ii) {
+ checkRect(
+ 0,
+ canvasSize / 2 * ii,
+ canvasSize,
+ canvasSize / 2,
+ colors[(h.colors[ii] + count) % colors.length]);
+ }
+ }
+ ++count;
+ }
+
+ gl.deleteTexture(tex);
+ return true;
+}
+
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors.");
+
+function checkRect(x, y, width, height, color) {
+ wtu.checkCanvasRect(
+ gl,
+ x,
+ y,
+ width,
+ height,
+ color.color,
+ "" + x + ", " + y + ", " + width + ", " + height +
+ " should be " + color.name);
+}
+
+function fillLevel(target, level, size, color) {
+ var numPixels = size * size;
+ var pixels = new Uint8Array(numPixels * 4);
+ var pixelRow = new Uint8Array(size * 4);
+ for (var jj = 0; jj < size; ++jj) {
+ var off = jj * 4;
+ pixelRow[off + 0] = color[0];
+ pixelRow[off + 1] = color[1];
+ pixelRow[off + 2] = color[2];
+ pixelRow[off + 3] = color[3];
+ }
+ for (var jj = 0; jj < size; ++jj) {
+ var off = jj * size * 4;
+ pixels.set(pixelRow, off);
+ }
+ gl.texImage2D(
+ target, level, gl.RGBA, size, size, 0, gl.RGBA, gl.UNSIGNED_BYTE,
+ pixels);
+}
+
+function printMat(mat) {
+ debug("" + mat[0] + ", " + mat[1] + ", " + mat[2] + ", " + mat[3] + ", ");
+ debug("" + mat[4] + ", " + mat[5] + ", " + mat[6] + ", " + mat[7] + ", ");
+ debug("" + mat[8] + ", " + mat[9] + ", " + mat[10] + ", " + mat[11] + ", ");
+ debug("" + mat[12] + ", " + mat[13] + ", " + mat[14] + ", " + mat[15] + ", ");
+}
+
+function axisRotation(axis, angle) {
+ var dst = new Float32Array(16);
+ var x = axis[0];
+ var y = axis[1];
+ var z = axis[2];
+ var n = Math.sqrt(x * x + y * y + z * z);
+ x /= n;
+ y /= n;
+ z /= n;
+ var xx = x * x;
+ var yy = y * y;
+ var zz = z * z;
+ var c = Math.cos(angle);
+ var s = Math.sin(angle);
+ var oneMinusCosine = 1 - c;
+
+ dst[ 0] = xx + (1 - xx) * c;
+ dst[ 1] = x * y * oneMinusCosine + z * s;
+ dst[ 2] = x * z * oneMinusCosine - y * s;
+ dst[ 3] = 0;
+ dst[ 4] = x * y * oneMinusCosine - z * s;
+ dst[ 5] = yy + (1 - yy) * c;
+ dst[ 6] = y * z * oneMinusCosine + x * s;
+ dst[ 7] = 0;
+ dst[ 8] = x * z * oneMinusCosine + y * s;
+ dst[ 9] = y * z * oneMinusCosine - x * s;
+ dst[10] = zz + (1 - zz) * c;
+ dst[11] = 0;
+ dst[12] = 0;
+ dst[13] = 0;
+ dst[14] = 0;
+ dst[15] = 1;
+
+ return dst;
+};
+
+function mulMatrix(a, b) {
+ var dst = new Float32Array(16);
+ var a00 = a[0];
+ var a01 = a[1];
+ var a02 = a[2];
+ var a03 = a[3];
+ var a10 = a[ 4 + 0];
+ var a11 = a[ 4 + 1];
+ var a12 = a[ 4 + 2];
+ var a13 = a[ 4 + 3];
+ var a20 = a[ 8 + 0];
+ var a21 = a[ 8 + 1];
+ var a22 = a[ 8 + 2];
+ var a23 = a[ 8 + 3];
+ var a30 = a[12 + 0];
+ var a31 = a[12 + 1];
+ var a32 = a[12 + 2];
+ var a33 = a[12 + 3];
+ var b00 = b[0];
+ var b01 = b[1];
+ var b02 = b[2];
+ var b03 = b[3];
+ var b10 = b[ 4 + 0];
+ var b11 = b[ 4 + 1];
+ var b12 = b[ 4 + 2];
+ var b13 = b[ 4 + 3];
+ var b20 = b[ 8 + 0];
+ var b21 = b[ 8 + 1];
+ var b22 = b[ 8 + 2];
+ var b23 = b[ 8 + 3];
+ var b30 = b[12 + 0];
+ var b31 = b[12 + 1];
+ var b32 = b[12 + 2];
+ var b33 = b[12 + 3];
+ dst[ 0] = a00 * b00 + a01 * b10 + a02 * b20 + a03 * b30;
+ dst[ 1] = a00 * b01 + a01 * b11 + a02 * b21 + a03 * b31;
+ dst[ 2] = a00 * b02 + a01 * b12 + a02 * b22 + a03 * b32;
+ dst[ 3] = a00 * b03 + a01 * b13 + a02 * b23 + a03 * b33;
+ dst[ 4] = a10 * b00 + a11 * b10 + a12 * b20 + a13 * b30;
+ dst[ 5] = a10 * b01 + a11 * b11 + a12 * b21 + a13 * b31;
+ dst[ 6] = a10 * b02 + a11 * b12 + a12 * b22 + a13 * b32;
+ dst[ 7] = a10 * b03 + a11 * b13 + a12 * b23 + a13 * b33;
+ dst[ 8] = a20 * b00 + a21 * b10 + a22 * b20 + a23 * b30;
+ dst[ 9] = a20 * b01 + a21 * b11 + a22 * b21 + a23 * b31;
+ dst[10] = a20 * b02 + a21 * b12 + a22 * b22 + a23 * b32;
+ dst[11] = a20 * b03 + a21 * b13 + a22 * b23 + a23 * b33;
+ dst[12] = a30 * b00 + a31 * b10 + a32 * b20 + a33 * b30;
+ dst[13] = a30 * b01 + a31 * b11 + a32 * b21 + a33 * b31;
+ dst[14] = a30 * b02 + a31 * b12 + a32 * b22 + a33 * b32;
+ dst[15] = a30 * b03 + a31 * b13 + a32 * b23 + a33 * b33;
+ return dst;
+};
+
+var successfullyParsed = true;
+</script>
+</body>
+</html>
+
+
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-size-limit.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-size-limit.html
new file mode 100644
index 000000000..176e1ce96
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-size-limit.html
@@ -0,0 +1,175 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL texture size limit conformance test.</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+</head>
+<body>
+<canvas id="example" width="32" height="32" style="width: 40px; height: 40px;"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+"use strict";
+description("Checks various size limits of textures")
+var canvas;
+
+function numLevelsFromSize(size) {
+ var levels = 0;
+ while ((size >> levels) > 0) {
+ ++levels;
+ }
+ return levels;
+}
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+var tests = [
+ { format: gl.ALPHA, type: gl.UNSIGNED_BYTE, size: 1, dataType: Uint8Array },
+ { format: gl.LUMINANCE, type: gl.UNSIGNED_BYTE, size: 1, dataType: Uint8Array },
+ { format: gl.LUMINANCE_ALPHA, type: gl.UNSIGNED_BYTE, size: 2, dataType: Uint8Array },
+ { format: gl.RGB, type: gl.UNSIGNED_BYTE, size: 3, dataType: Uint8Array },
+ { format: gl.RGB, type: gl.UNSIGNED_SHORT_5_6_5, size: 1, dataType: Uint16Array },
+ { format: gl.RGBA, type: gl.UNSIGNED_BYTE, size: 4, dataType: Uint8Array },
+ { format: gl.RGBA, type: gl.UNSIGNED_SHORT_4_4_4_4, size: 1, dataType: Uint16Array },
+ { format: gl.RGBA, type: gl.UNSIGNED_SHORT_5_5_5_1, size: 1, dataType: Uint16Array }
+];
+
+// Note: We expressly only use 2 textures because first a texture will be defined
+// using all mip levels of 1 format, then for a moment it will have mixed formats which
+// may uncover bugs.
+var targets = [
+ { target: gl.TEXTURE_2D,
+ maxSize: gl.getParameter(gl.MAX_TEXTURE_SIZE),
+ maxLevel: 1000,
+ tex: gl.createTexture(),
+ targets: [gl.TEXTURE_2D]
+ },
+ { target: gl.TEXTURE_CUBE_MAP,
+ maxSize: gl.getParameter(gl.MAX_CUBE_MAP_TEXTURE_SIZE),
+ maxLevel: 5,
+ tex: gl.createTexture(),
+ targets: [
+ gl.TEXTURE_CUBE_MAP_POSITIVE_X,
+ gl.TEXTURE_CUBE_MAP_NEGATIVE_X,
+ gl.TEXTURE_CUBE_MAP_POSITIVE_Y,
+ gl.TEXTURE_CUBE_MAP_NEGATIVE_Y,
+ gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
+ gl.TEXTURE_CUBE_MAP_NEGATIVE_Z
+ ]
+ }
+];
+
+gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
+
+var trg = 0;
+var tt = 0;
+runNextTest();
+
+function runNextTest() {
+ var t = targets[trg];
+
+ if (tt == 0) {
+ var tex = t.tex;
+ gl.bindTexture(t.target, tex);
+
+ debug("");
+ debug("max size for " + wtu.glEnumToString(gl, t.target) + ": " + t.maxSize);
+ var numLevels = numLevelsFromSize(t.maxSize);
+ debug("num levels " + numLevels);
+ }
+
+ var test = tests[tt];
+ testFormatType(t, test);
+ ++tt;
+ if (tt == tests.length) {
+ tt = 0;
+ ++trg;
+ if (trg == targets.length) {
+ finishTest();
+ return;
+ }
+ }
+ wtu.waitForComposite(runNextTest)
+}
+
+function testFormatType(t, test) {
+ debug("");
+ debug("testing: " + wtu.glEnumToString(gl, test.format) + ", " + wtu.glEnumToString(gl, test.type));
+ for (var j = 0; j < t.targets.length; ++j) {
+ var target = t.targets[j];
+ debug("");
+ debug(wtu.glEnumToString(gl, target));
+ var numLevels = numLevelsFromSize(t.maxSize);
+ var numTestLevels = Math.min(numLevels, t.maxLevel);
+
+ // out of bounds tests
+ // level out of bounds
+ gl.texImage2D(target, numLevels, test.format, 1, 1, 0, test.format, test.type, null);
+ wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "level out of bounds: should generate INVALID_VALUE: level is: "
+ + numLevels + ", size is 1x1.");
+ // width and height out of bounds
+ gl.texImage2D(target, 0, test.format, t.maxSize + 1, t.maxSize + 1, 0, test.format, test.type, null);
+ wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "width or height out of bounds: should generate INVALID_VALUE: level is 0, size is "
+ + (t.maxSize + 1) + "x" + (t.maxSize + 1));
+ // width and height out of bounds for specified level
+ gl.texImage2D(target, (numLevels - 1), test.format, 4, 4, 0, test.format, test.type, null);
+ wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "width or height out of bounds for specified level: should generate INVALID_VALUE: level is "
+ + (numLevels - 1) + ", size is 4x4.");
+
+ for (var l = 0; l < numTestLevels; ++l) {
+ // Do bottom levels first;
+ var size = 1 << l;
+ var level = numLevels - l - 1;
+ var otherDimension = t.target == gl.TEXTURE_2D ? 1 : size;
+ var badSize = size * 2;
+ var badOtherDimension = t.target == gl.TEXTURE_2D ? 1 : badSize;
+ var pixels = new test.dataType(badSize * badOtherDimension * test.size);
+ gl.texImage2D(target, level, test.format, size, otherDimension, 0, test.format, test.type, pixels);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no error for level: " + level + " " + size + "x" + otherDimension);
+ gl.texImage2D(target, level, test.format, otherDimension, size, 0, test.format, test.type, pixels);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no error for level: " + level + " " + otherDimension + "x" + size);
+ gl.texImage2D(target, level, test.format, badSize, badOtherDimension, 0, test.format, test.type, pixels);
+ wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "should generate INVALID_VALUE for level: " + level + " " + badSize + "x" + badOtherDimension);
+ gl.texImage2D(target, level, test.format, badOtherDimension, badSize, 0, test.format, test.type, pixels);
+ wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "should generate INVALID_VALUE for level: " + level + " " + badOtherDimension + "x" + badSize);
+ }
+ }
+}
+
+var successfullyParsed = true;
+</script>
+</body>
+</html>
+
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-size.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-size.html
new file mode 100644
index 000000000..659be1fba
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-size.html
@@ -0,0 +1,238 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL texture size conformance test.</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+</head>
+<body>
+<canvas id="example" width="32" height="32" style="width: 40px; height: 40px;"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script id="vshader" type="x-shader/x-vertex">
+attribute vec4 vPosition;
+attribute vec3 texCoord0;
+varying vec3 texCoord;
+void main()
+{
+ gl_Position = vPosition;
+ texCoord = texCoord0;
+}
+</script>
+
+<script id="fshader" type="x-shader/x-fragment">
+precision mediump float;
+uniform samplerCube tex;
+varying vec3 texCoord;
+void main()
+{
+ gl_FragColor = textureCube(tex, normalize(texCoord));
+}
+</script>
+<script>
+"use strict";
+description("Checks that various sizes of textures render")
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+var program2D = wtu.setupTexturedQuad(gl);
+var programCubeMap = wtu.setupProgram(
+ gl, ['vshader', 'fshader'], ['vPosition', 'texCoord0'], [0, 1]);
+gl.disable(gl.DEPTH_TEST);
+gl.disable(gl.BLEND);
+var tex = gl.createTexture();
+var max2DSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);
+var maxCubeMapSize = gl.getParameter(gl.MAX_CUBE_MAP_TEXTURE_SIZE);
+debug("MAX_TEXTURE_SIZE:" + max2DSize);
+debug("MAX_CUBE_MAP_TEXTURE_SIZE:" + maxCubeMapSize);
+// Assuming 2048x2048xRGBA (22meg with mips) will run on all WebGL platforms
+var max2DSquareSize = Math.min(max2DSize, 2048);
+// I'd prefer this to be 2048 but that's 16meg x 6 faces or 128meg (with mips)
+// 1024 is 33.5 meg (with mips)
+var maxCubeMapSize = Math.min(maxCubeMapSize, 1024);
+
+var colors = [
+ { name: "green", rgba: [0, 0, 255, 255] },
+ { name: "red", rgba: [255, 0, 0, 255] },
+ { name: "blue", rgba: [0, 255, 0, 255] },
+ { name: "yellow", rgba: [255, 255, 0, 255] },
+ { name: "magenta", rgba: [255, 0, 255, 255] },
+ { name: "cyan", rgba: [0, 255, 255, 255] }
+];
+
+var count = 0;
+var power = 0;
+runTest();
+
+function runTest() {
+ function doTest() {
+ var size = Math.pow(2, power);
+ if (size > max2DSize) {
+ return false;
+ }
+ gl.useProgram(program2D);
+ if (!checkTexture(size, 1, false)) return false;
+ if (!checkTexture(1, size, false)) return false;
+ if (size <= max2DSquareSize) {
+ if (!checkTexture(size, size, false)) {
+ return false;
+ }
+ }
+ if (size <= maxCubeMapSize) {
+ gl.useProgram(programCubeMap);
+ if (!checkTexture(size, size, true)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ if (doTest()) {
+ ++power;
+ setTimeout(runTest, 0);
+ } else {
+ finishTest();
+ }
+}
+
+function checkTexture(width, height, cubeMap) {
+ debug("");
+ count = (count + 1) % colors.length;
+ var color = colors[count];
+ var tex = gl.createTexture();
+ var target = cubeMap ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
+ var type = cubeMap ? "cube map" : "2D texture";
+ debug("check " + width + ", " + height + " " + type);
+ gl.bindTexture(target, tex);
+ gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
+ gl.texParameteri(target, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
+ gl.texParameteri(target, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
+ fillLevel(0, width, height, color.rgba, cubeMap);
+ var err = gl.getError();
+ if (err == gl.OUT_OF_MEMORY) {
+ debug("out of memory");
+ return false;
+ }
+ if (err != gl.NO_ERROR) {
+ testFailed("unexpected gl error: " + wtu.glEnumToString(gl, err));
+ }
+ wtu.clearAndDrawUnitQuad(gl);
+ wtu.checkCanvas(gl, color.rgba,
+ type + " of size " + width + "x" + height + " with no mips should draw with " + color.name);
+ count = (count + 1) % colors.length;
+ color = colors[count];
+ fillLevel(0, width, height, color.rgba, cubeMap);
+ gl.generateMipmap(target);
+ var err = gl.getError();
+ if (err == gl.OUT_OF_MEMORY) {
+ debug("out of memory");
+ return false;
+ }
+ if (err != gl.NO_ERROR) {
+ testFailed("unexpected gl error: " + wtu.glEnumToString(gl, err));
+ }
+ gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_NEAREST);
+ wtu.clearAndDrawUnitQuad(gl);
+ wtu.checkCanvas(gl, color.rgba,
+ type + " of size " + width + "x" + height + " with mips should draw with " + color.name);
+
+ count = (count + 1) % colors.length;
+ color = colors[count];
+ fillLevel(0, width, height, color.rgba, cubeMap, true);
+ gl.generateMipmap(target);
+
+ wtu.clearAndDrawUnitQuad(gl);
+ wtu.checkCanvas(gl, color.rgba,
+ type + " of size " + width + "x" + height + " with mips should draw with " + color.name);
+
+ gl.deleteTexture(tex);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors.");
+ return true;
+}
+
+function fillLevel(level, width, height, color, opt_cubemap, opt_subTex) {
+ var numPixels = width * height;
+ var pixels = null;
+ var largeDim = Math.max(width, height);
+ var smallDim = Math.min(width, height);
+
+ var pixelRow = new Uint8Array(largeDim * 4);
+ for (var jj = 0; jj < largeDim; ++jj) {
+ var off = jj * 4;
+ pixelRow[off + 0] = color[0];
+ pixelRow[off + 1] = color[1];
+ pixelRow[off + 2] = color[2];
+ pixelRow[off + 3] = color[3];
+ }
+
+ if (largeDim == numPixels) {
+ pixels = pixelRow;
+ } else {
+ var pixels = new Uint8Array(numPixels * 4);
+ for (var jj = 0; jj < smallDim; ++jj) {
+ var off = jj * largeDim * 4;
+ pixels.set(pixelRow, off);
+ }
+ }
+
+ var targets = opt_cubemap ? [
+ gl.TEXTURE_CUBE_MAP_POSITIVE_X,
+ gl.TEXTURE_CUBE_MAP_NEGATIVE_X,
+ gl.TEXTURE_CUBE_MAP_POSITIVE_Y,
+ gl.TEXTURE_CUBE_MAP_NEGATIVE_Y,
+ gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
+ gl.TEXTURE_CUBE_MAP_NEGATIVE_Z] :
+ [gl.TEXTURE_2D];
+
+ for (var ii = 0; ii < targets.length; ++ii) {
+ // debug(wtu.glEnumToString(gl, targets[ii]));
+ var index = (ii + power) % targets.length;
+ var target = targets[index];
+ if (opt_subTex) {
+ gl.texSubImage2D(
+ target, level, 0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE,
+ pixels);
+ } else {
+ gl.texImage2D(
+ target, level, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE,
+ pixels);
+ }
+ }
+}
+
+var successfullyParsed = true;
+</script>
+</body>
+</html>
+
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-sub-image-cube-maps.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-sub-image-cube-maps.html
new file mode 100644
index 000000000..d4d860671
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-sub-image-cube-maps.html
@@ -0,0 +1,338 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL texture texSubImage2Ds cube map conformance test.</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+</head>
+<body>
+<canvas id="example" width="256" height="256" style="width: 40px; height: 40px;"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script id="vshader" type="x-shader/x-vertex">
+attribute vec4 vPosition;
+uniform mat4 rotation;
+varying vec3 texCoord;
+void main()
+{
+ gl_Position = vPosition;
+ vec4 direction = vec4(vPosition.x * 0.5, vPosition.y * 0.5, 1, 1);
+ texCoord = normalize((rotation * direction).xyz);
+}
+</script>
+
+<script id="fshader" type="x-shader/x-fragment">
+precision mediump float;
+uniform samplerCube tex;
+varying vec3 texCoord;
+void main()
+{
+ gl_FragColor = textureCube(tex, normalize(texCoord));
+}
+</script>
+<script>
+"use strict";
+var canvas;
+description("Checks issues with size of cube map textures");
+debug("");
+
+var wtu = WebGLTestUtils;
+var canvas = document.getElementById("example");
+
+var gl = wtu.create3DContext(canvas);
+wtu.setupUnitQuad(gl, 0, 1);
+var program = wtu.setupProgram(
+ gl,
+ ['vshader', 'fshader'],
+ ['vPosition', 'texCoord0'], [0, 1]);
+var rotLoc = gl.getUniformLocation(program, "rotation");
+
+var size = 16;
+
+var colors = [
+ {name: 'red', color: [255, 0, 0, 255]},
+ {name: 'green', color: [ 0, 255, 0, 255]},
+ {name: 'blue', color: [ 0, 0, 255, 255]},
+ {name: 'yellow', color: [255, 255, 0, 255]},
+ {name: 'cyan', color: [ 0, 255, 255, 255]},
+ {name: 'magenta', color: [255, 0, 255, 255]}
+];
+
+var targets = [
+ gl.TEXTURE_CUBE_MAP_POSITIVE_X,
+ gl.TEXTURE_CUBE_MAP_NEGATIVE_X,
+ gl.TEXTURE_CUBE_MAP_POSITIVE_Y,
+ gl.TEXTURE_CUBE_MAP_NEGATIVE_Y,
+ gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
+ gl.TEXTURE_CUBE_MAP_NEGATIVE_Z];
+
+var rotations = [
+ {axis: [0, 1, 0], angle: Math.PI / 2},
+ {axis: [0, 1, 0], angle: -Math.PI / 2},
+ {axis: [1, 0, 0], angle: -Math.PI / 2},
+ {axis: [1, 0, 0], angle: Math.PI / 2},
+ {axis: [0, 1, 0], angle: 0},
+ {axis: [0, 1, 0], angle: Math.PI},
+];
+
+var halfRotations = [
+ {colors: [3, 4], rotations: [{axis: [1, 0, 0], angle: Math.PI / 4}]},
+ {colors: [4, 2], rotations: [{axis: [1, 0, 0], angle: -Math.PI / 4}]},
+ {colors: [5, 3], rotations: [{axis: [1, 0, 0], angle: Math.PI / 4 * 3}]},
+ {colors: [2, 5], rotations: [{axis: [1, 0, 0], angle: -Math.PI / 4 * 3}]},
+ {colors: [3, 0], rotations: [{axis: [0, 1, 0], angle: Math.PI / 2},
+ {axis: [1, 0, 0], angle: Math.PI / 4}]},
+ {colors: [0, 2], rotations: [{axis: [0, 1, 0], angle: Math.PI / 2},
+ {axis: [1, 0, 0], angle: -Math.PI / 4}]},
+];
+
+var count = 0;
+testSize(size);
+
+function testSize(size) {
+ debug("");
+ debug("testing size: " + size);
+ var canvasSize = Math.max(size / 4, 2);
+ canvas.width = canvasSize;
+ canvas.height = canvasSize;
+ gl.viewport(0, 0, canvasSize, canvasSize);
+ var tex = gl.createTexture();
+ gl.bindTexture(gl.TEXTURE_CUBE_MAP, tex);
+
+ // Seems like I should be using LINEAR here with some other math
+ // to make sure I get more mip coverage but that's easier said
+ // than done.
+
+ gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
+ gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
+
+ for (var jj = 0; jj < 2; ++jj) {
+ for (var tt = 0; tt < targets.length; ++tt) {
+ var color = colors[(tt + count) % colors.length];
+ fillLevel(targets[tt], 0, size, color.color);
+ }
+ if (jj == 1) {
+ debug("use mipmap");
+ gl.texParameteri(
+ gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER,
+ gl.NEAREST_MIPMAP_NEAREST);
+ gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
+ }
+
+ var err = gl.getError();
+ if (err == gl.OUT_OF_MEMORY) {
+ debug("out of memory");
+ return false;
+ }
+ if (err != gl.NO_ERROR) {
+ testFailed("unexpected gl error: " + wtu.glEnumToString(gl, err));
+ }
+
+
+ for (var rr = 0; rr < rotations.length; ++rr) {
+ var rot = rotations[rr];
+ var color = colors[(rr + count) % colors.length];
+ var rotMat = axisRotation(rot.axis, rot.angle);
+ gl.uniformMatrix4fv(rotLoc, false, rotMat);
+ wtu.clearAndDrawUnitQuad(gl);
+ wtu.checkCanvas(
+ gl, color.color,
+ wtu.glEnumToString(gl, targets[rr]) + " should be " + color.name);
+ }
+
+ for (var rr = 0; rr < halfRotations.length; ++rr) {
+ var h = halfRotations[rr];
+ var rots = h.rotations;
+ var rotMat = axisRotation(rots[0].axis, rots[0].angle);
+ for (var ii = 1; ii < rots.length; ++ii) {
+ var tmpMat = axisRotation(rots[ii].axis, rots[ii].angle);
+ var rotMat = mulMatrix(tmpMat, rotMat);
+ }
+ gl.uniformMatrix4fv(rotLoc, false, rotMat);
+ wtu.clearAndDrawUnitQuad(gl);
+
+ for (var ii = 0; ii < 2; ++ii) {
+ checkRect(
+ 0,
+ canvasSize / 2 * ii,
+ canvasSize,
+ canvasSize / 2,
+ colors[(h.colors[ii] + count) % colors.length]);
+ }
+ }
+ ++count;
+ }
+
+ gl.deleteTexture(tex);
+ return true;
+}
+
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors.");
+
+function checkRect(x, y, width, height, color) {
+ wtu.checkCanvasRect(
+ gl,
+ x,
+ y,
+ width,
+ height,
+ color.color,
+ "" + x + ", " + y + ", " + width + ", " + height +
+ " should be " + color.name);
+}
+
+function fillLevel(target, level, size, color) {
+ var numPixels = size * size;
+ var halfPixelRow = new Uint8Array(size * 2);
+ for (var jj = 0; jj < size; ++jj) {
+ var off = jj * 4;
+ halfPixelRow[off + 0] = color[0];
+ halfPixelRow[off + 1] = color[1];
+ halfPixelRow[off + 2] = color[2];
+ halfPixelRow[off + 3] = color[3];
+ }
+ gl.texImage2D(
+ target, level, gl.RGBA, size, size, 0, gl.RGBA, gl.UNSIGNED_BYTE,
+ null);
+ for (var jj = 0; jj < size; ++jj) {
+ gl.texSubImage2D(
+ target, level, 0, jj, size / 2, 1, gl.RGBA, gl.UNSIGNED_BYTE, halfPixelRow);
+ gl.texSubImage2D(
+ target, level, size / 2, jj, size / 2, 1, gl.RGBA, gl.UNSIGNED_BYTE, halfPixelRow);
+ }
+}
+
+function printMat(mat) {
+ debug("" + mat[0] + ", " + mat[1] + ", " + mat[2] + ", " + mat[3] + ", ");
+ debug("" + mat[4] + ", " + mat[5] + ", " + mat[6] + ", " + mat[7] + ", ");
+ debug("" + mat[8] + ", " + mat[9] + ", " + mat[10] + ", " + mat[11] + ", ");
+ debug("" + mat[12] + ", " + mat[13] + ", " + mat[14] + ", " + mat[15] + ", ");
+}
+
+function axisRotation(axis, angle) {
+ var dst = new Float32Array(16);
+ var x = axis[0];
+ var y = axis[1];
+ var z = axis[2];
+ var n = Math.sqrt(x * x + y * y + z * z);
+ x /= n;
+ y /= n;
+ z /= n;
+ var xx = x * x;
+ var yy = y * y;
+ var zz = z * z;
+ var c = Math.cos(angle);
+ var s = Math.sin(angle);
+ var oneMinusCosine = 1 - c;
+
+ dst[ 0] = xx + (1 - xx) * c;
+ dst[ 1] = x * y * oneMinusCosine + z * s;
+ dst[ 2] = x * z * oneMinusCosine - y * s;
+ dst[ 3] = 0;
+ dst[ 4] = x * y * oneMinusCosine - z * s;
+ dst[ 5] = yy + (1 - yy) * c;
+ dst[ 6] = y * z * oneMinusCosine + x * s;
+ dst[ 7] = 0;
+ dst[ 8] = x * z * oneMinusCosine + y * s;
+ dst[ 9] = y * z * oneMinusCosine - x * s;
+ dst[10] = zz + (1 - zz) * c;
+ dst[11] = 0;
+ dst[12] = 0;
+ dst[13] = 0;
+ dst[14] = 0;
+ dst[15] = 1;
+
+ return dst;
+};
+
+function mulMatrix(a, b) {
+ var dst = new Float32Array(16);
+ var a00 = a[0];
+ var a01 = a[1];
+ var a02 = a[2];
+ var a03 = a[3];
+ var a10 = a[ 4 + 0];
+ var a11 = a[ 4 + 1];
+ var a12 = a[ 4 + 2];
+ var a13 = a[ 4 + 3];
+ var a20 = a[ 8 + 0];
+ var a21 = a[ 8 + 1];
+ var a22 = a[ 8 + 2];
+ var a23 = a[ 8 + 3];
+ var a30 = a[12 + 0];
+ var a31 = a[12 + 1];
+ var a32 = a[12 + 2];
+ var a33 = a[12 + 3];
+ var b00 = b[0];
+ var b01 = b[1];
+ var b02 = b[2];
+ var b03 = b[3];
+ var b10 = b[ 4 + 0];
+ var b11 = b[ 4 + 1];
+ var b12 = b[ 4 + 2];
+ var b13 = b[ 4 + 3];
+ var b20 = b[ 8 + 0];
+ var b21 = b[ 8 + 1];
+ var b22 = b[ 8 + 2];
+ var b23 = b[ 8 + 3];
+ var b30 = b[12 + 0];
+ var b31 = b[12 + 1];
+ var b32 = b[12 + 2];
+ var b33 = b[12 + 3];
+ dst[ 0] = a00 * b00 + a01 * b10 + a02 * b20 + a03 * b30;
+ dst[ 1] = a00 * b01 + a01 * b11 + a02 * b21 + a03 * b31;
+ dst[ 2] = a00 * b02 + a01 * b12 + a02 * b22 + a03 * b32;
+ dst[ 3] = a00 * b03 + a01 * b13 + a02 * b23 + a03 * b33;
+ dst[ 4] = a10 * b00 + a11 * b10 + a12 * b20 + a13 * b30;
+ dst[ 5] = a10 * b01 + a11 * b11 + a12 * b21 + a13 * b31;
+ dst[ 6] = a10 * b02 + a11 * b12 + a12 * b22 + a13 * b32;
+ dst[ 7] = a10 * b03 + a11 * b13 + a12 * b23 + a13 * b33;
+ dst[ 8] = a20 * b00 + a21 * b10 + a22 * b20 + a23 * b30;
+ dst[ 9] = a20 * b01 + a21 * b11 + a22 * b21 + a23 * b31;
+ dst[10] = a20 * b02 + a21 * b12 + a22 * b22 + a23 * b32;
+ dst[11] = a20 * b03 + a21 * b13 + a22 * b23 + a23 * b33;
+ dst[12] = a30 * b00 + a31 * b10 + a32 * b20 + a33 * b30;
+ dst[13] = a30 * b01 + a31 * b11 + a32 * b21 + a33 * b31;
+ dst[14] = a30 * b02 + a31 * b12 + a32 * b22 + a33 * b32;
+ dst[15] = a30 * b03 + a31 * b13 + a32 * b23 + a33 * b33;
+ return dst;
+};
+
+var successfullyParsed = true;
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
+
+
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-transparent-pixels-initialized.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-transparent-pixels-initialized.html
new file mode 100644
index 000000000..f64b95be3
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-transparent-pixels-initialized.html
@@ -0,0 +1,108 @@
+<!--
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+-->
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+<script>
+"use strict";
+var wtu = WebGLTestUtils;
+var gl = null;
+var texture;
+var textureLoc = null;
+var successfullyParsed = false;
+
+function init()
+{
+ description('Tests there is no garbage in transparent regions of images uploaded as textures');
+
+ wtu = WebGLTestUtils;
+ gl = wtu.create3DContext("example");
+ var program = wtu.setupTexturedQuad(gl);
+ gl.clearColor(0.5,0.5,0.5,1);
+ gl.clearDepth(1);
+
+ textureLoc = gl.getUniformLocation(program, "tex");
+
+ // The input texture has 8 characters; take the leftmost one
+ var coeff = 1.0 / 8.0;
+ var texCoords = new Float32Array([
+ coeff, 1.0,
+ 0.0, 1.0,
+ 0.0, 0.0,
+ coeff, 1.0,
+ 0.0, 0.0,
+ coeff, 0.0]);
+
+ var vbo = gl.createBuffer();
+ gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
+ gl.bufferData(gl.ARRAY_BUFFER, texCoords, gl.STATIC_DRAW);
+ gl.enableVertexAttribArray(1);
+ gl.vertexAttribPointer(1, 2, gl.FLOAT, false, 0, 0);
+
+ texture = wtu.loadTexture(gl, "../resources/bug-32888-texture.png", runTest);
+}
+
+// These two declarations need to be global for "shouldBe" to see them
+var buf = null;
+var idx = 0;
+
+function runTest()
+{
+ gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+ gl.enable(gl.BLEND);
+ gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
+ // Bind the texture to texture unit 0
+ gl.bindTexture(gl.TEXTURE_2D, texture);
+ // Point the uniform sampler to texture unit 0
+ gl.uniform1i(textureLoc, 0);
+ // Draw the triangles
+ wtu.clearAndDrawUnitQuad(gl, [0, 0, 0, 255]);
+
+ // Spot check a couple of 2x2 regions in the upper and lower left
+ // corners; they should be the rgb values in the texture.
+ var color = [0, 0, 0];
+ debug("Checking lower left corner");
+ wtu.checkCanvasRect(gl, 1, gl.canvas.height - 3, 2, 2, color,
+ "shouldBe " + color);
+ debug("Checking upper left corner");
+ wtu.checkCanvasRect(gl, 1, 1, 2, 2, color,
+ "shouldBe " + color);
+
+ finishTest();
+}
+</script>
+</head>
+<body onload="init()">
+<canvas id="example" width="32" height="32"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-upload-cube-maps.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-upload-cube-maps.html
new file mode 100644
index 000000000..831e318dd
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-upload-cube-maps.html
@@ -0,0 +1,75 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+</head>
+<body>
+<canvas id="example" width="2" height="2"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+"use strict";
+description('Tests texImage2D and texSubImage2D upload path for TEXTURE_CUBE_MAP');
+
+var wtu = WebGLTestUtils;
+var canvas = document.getElementById("example");
+var gl = wtu.create3DContext(canvas);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
+
+function testOneTarget(target, width, height) {
+ var tex = gl.createTexture();
+ gl.bindTexture(gl.TEXTURE_CUBE_MAP, tex);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from bindTexture(TEXTURE_CUBE_MAP).");
+
+ gl.texImage2D(target, 0, gl.RGB, width, height, 0, gl.RGB, gl.UNSIGNED_BYTE, null);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from texImage2D.");
+
+ var buf = new Uint8Array(width * height * 3);
+ gl.texSubImage2D(target, 0, 0, 0, width, height, gl.RGB, gl.UNSIGNED_BYTE, buf);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from texSubImage2D.");
+}
+
+testOneTarget(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 16, 16);
+testOneTarget(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 16, 16);
+testOneTarget(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 16, 16);
+testOneTarget(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 16, 16);
+testOneTarget(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 16, 16);
+testOneTarget(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 16, 16);
+
+var successfullyParsed = true;
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-upload-size.html b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-upload-size.html
new file mode 100644
index 000000000..78ff5ef4f
--- /dev/null
+++ b/testing/web-platform/tests/webgl/conformance-1.0.3/conformance/textures/texture-upload-size.html
@@ -0,0 +1,172 @@
+<!--
+
+/*
+** Copyright (c) 2014 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL texture upload size conformance test</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+</head>
+<body>
+<canvas id="canvas"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+"use strict";
+enableJSTestPreVerboseLogging();
+description("Checks that the size of a texture uploaded from an element is set correctly.");
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("canvas");
+
+var tex = gl.createTexture();
+gl.bindTexture(gl.TEXTURE_2D, tex);
+
+var testUpload = function(upload, expectedWidth, expectedHeight) {
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, upload);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "when calling texImage2D");
+ wtu.checkTextureSize(gl, expectedWidth, expectedHeight);
+ gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, upload);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "when calling texSubImage2D with the same texture upload");
+ gl.texSubImage2D(gl.TEXTURE_2D, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, upload);
+ wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "when calling texSubImage2D with the same texture upload with offset 1, 1");
+};
+
+var testImage = function(test, img) {
+ var width = img.width;
+ var height = img.height;
+ testUpload(img, width, height);
+
+ debug("Testing changing the width and height attributes of the image");
+ img.width *= 2;
+ img.height *= 2;
+ if (test.isSVG) {
+ testUpload(img, img.width, img.height);
+ } else {
+ testUpload(img, width, height);
+ }
+};
+
+var testVideo = function(test, video) {
+ // Assuming that the video is not anamorphic, nor has clean aperture data
+ // that would make the frame size in pixels different.
+ var width = video.videoWidth;
+ var height = video.videoHeight;
+ testUpload(video, width, height);
+
+ debug("Testing changing the width and height attributes of the video");
+ video.width *= 2;
+ video.height *= 2;
+ testUpload(video, width, height);
+};
+
+var createCanvas2DContext = function(width, height) {
+ var canvas = document.createElement("canvas");
+ canvas.width = width;
+ canvas.height = height;
+ var ctx = canvas.getContext("2d");
+ ctx.fillRect(0, 0, width, height);
+ return ctx;
+};
+
+var testImageData = function(test) {
+ var ctx = createCanvas2DContext(test.width, test.height);
+ var imageData = ctx.getImageData(0, 0, test.width, test.height);
+ testUpload(imageData, test.width, test.height);
+};
+
+var testCanvas = function(test) {
+ var ctx = createCanvas2DContext(test.width, test.height);
+ testUpload(ctx.canvas, test.width, test.height);
+
+ debug("Testing changing the dimensions of the same canvas");
+ ctx.canvas.width = test.width + 1;
+ ctx.canvas.height = test.height + 1;
+ testUpload(ctx.canvas, ctx.canvas.width, ctx.canvas.height);
+};
+
+var tests = [
+ {type: "ImageData", width: 123, height: 456},
+ {type: "canvas", width: 123, height: 456},
+ {type: "img", isSVG: false, src: "../resources/red-green.png"},
+ {type: "img", isSVG: true, src: "../resources/red-green.svg"},
+ {type: "video", src: "../resources/red-green.mp4", videoType: 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"'},
+ {type: "video", src: "../resources/red-green.webmvp8.webm", videoType: 'video/webm; codecs="vp8, vorbis"'},
+ {type: "video", src: "../resources/red-green.theora.ogv", videoType: 'video/ogg; codecs="theora, vorbis"'},
+];
+
+var testIndex = 0;
+
+var runNextTest = function() {
+ if (testIndex < tests.length) {
+ debug("");
+ var test = tests[testIndex];
+ ++testIndex;
+ if (test.type == "img") {
+ debug("HTMLImageElement" + (test.isSVG ? " (SVG)" : ""));
+ var img = wtu.makeImage(test.src, function() {
+ testImage(test, img);
+ setTimeout(runNextTest, 0);
+ });
+ } else if (test.type == "video") {
+ debug("HTMLVideoElement (" + test.videoType + ")");
+ var video = wtu.makeVideo(test.src);
+ if(!video.canPlayType(test.videoType).replace(/no/, '')) {
+ debug(test.videoType + " unsupported");
+ setTimeout(runNextTest, 0);
+ return;
+ }
+ wtu.startPlayingAndWaitForVideo(video, function() {
+ testVideo(test, video);
+ setTimeout(runNextTest, 0);
+ });
+ } else if (test.type == "ImageData") {
+ debug("ImageData");
+ testImageData(test);
+ setTimeout(runNextTest, 0);
+ } else if (test.type == "canvas") {
+ debug("HTMLCanvasElement");
+ testCanvas(test);
+ setTimeout(runNextTest, 0);
+ }
+ } else {
+ finishTest();
+ }
+};
+
+runNextTest();
+
+var successfullyParsed = true;
+</script>
+</body>
+</html>
+