author | Jeff Gilbert <jgilbert@mozilla.com> |
Wed, 04 Jan 2017 17:43:55 -0800 | |
changeset 456107 | eb2f9683455ac3a436ea80c916aebad23335db28 |
parent 456104 | 1216074ea5512e09898737008b75387f13e87e20 |
child 541146 | c2f1cdc006454a78e2162c3b8ff39997593d6c9e |
push id | 40404 |
push user | bmo:jgilbert@mozilla.com |
push date | Thu, 05 Jan 2017 01:46:27 +0000 |
bugs | 1328539 |
milestone | 53.0a1 |
--- a/dom/canvas/test/webgl-conf/checkout/conformance/textures/misc/00_test_list.txt +++ b/dom/canvas/test/webgl-conf/checkout/conformance/textures/misc/00_test_list.txt @@ -1,11 +1,12 @@ --max-version 1.9.9 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.4 copy-tex-sub-image-2d-partial-texture.html --min-version 1.0.4 cube-incomplete-fbo.html --min-version 1.0.3 default-texture.html --min-version 1.0.2 --max-version 1.9.9 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-uniform-binding-bugs.html
new file mode 100644 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/textures/misc/copy-tex-sub-image-2d-partial-texture.html @@ -0,0 +1,191 @@ +<!-- + +/* +** Copyright (c) 2016 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>CopyTexSubImage2D partial destination texture test</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +</head> +<body> +<div id="description"></div> +<canvas id="canvas"></canvas> +<div id="console"></div> + +<script> +"use strict"; +description("Verifies that copyTexSubImage2D redefining part of the destination texture works as expected."); + +//// + +var kWidth = 16; +var kHeight = 16; + +//// + +var wtu = WebGLTestUtils; +var canvas = document.getElementById("canvas"); + +canvas.width = kWidth; +canvas.height = kHeight; +var gl = wtu.create3DContext(canvas); + +//// + +function clearTo(color) { + gl.clearColor(color[0], color[1], color[2], color[3]); + gl.clear(gl.COLOR_BUFFER_BIT); +} + +function readInto(view) { + gl.readPixels(0, 0, kWidth, kHeight, gl.RGBA, gl.UNSIGNED_BYTE, + new Uint8Array(view.buffer)); +} + +//// + +function runTest() { + gl.enable(gl.SCISSOR_TEST); + + gl.scissor(0, 0, kWidth/2, kHeight/2); + clearTo([1,0,0,1]); + gl.scissor(kWidth/2, 0, kWidth/2, kHeight/2); + clearTo([0,1,0,1]); + gl.scissor(0, kHeight/2, kWidth/2, kHeight/2); + clearTo([0,0,1,1]); + gl.scissor(kWidth/2, kHeight/2, kWidth/2, kHeight/2); + clearTo([0,1,1,1]); + + var srcData = new Uint32Array(kWidth * kHeight); + readInto(srcData); + console.log('0x' + srcData[0].toString(16)); + + //// + + var dstTex = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, dstTex); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, kWidth, kHeight, + 0, gl.RGBA, gl.UNSIGNED_BYTE, null); // Uploads zeros. + var dstRefData = new Uint32Array(kWidth * kHeight); // Also cleared to zeros! + var dstTestData = new Uint32Array(kWidth * kHeight); + + var dstFB = gl.createFramebuffer(); + gl.bindFramebuffer(gl.FRAMEBUFFER, dstFB); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, + gl.TEXTURE_2D, dstTex, 0); + + //// + + function pixelPos(x, y) { + return y * kWidth + x; + } + + function testCmd(tuple) { + var dstX0, dstY0, srcX0, srcY0, width, height; + [dstX0, dstY0, srcX0, srcY0, width, height] = tuple + debug("copyTexSubImage2D(" + + [dstX0+','+dstY0, srcX0+','+srcY0, width+','+height].join(', ') + + ")"); + + // Test + gl.bindFramebuffer(gl.FRAMEBUFFER, null); + gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, + dstX0, dstY0, srcX0, srcY0, width, height); + + // Emulate for reference + for (var x = 0; x < width; x++) { + var srcX = srcX0 + x; + var dstX = dstX0 + x; + if (srcX < 0 || srcX >= kWidth || + dstX < 0 || dstX >= kWidth) + { + continue; + } + + for (var y = 0; y < height; y++) { + var srcY = srcY0 + y; + var dstY = dstY0 + y; + if (srcY < 0 || srcY >= kHeight || + dstY < 0 || dstY >= kHeight) + { + continue; + } + + + var srcPos = pixelPos(srcX, srcY); + var dstPos = pixelPos(dstX, dstY); + dstRefData[dstPos] = srcData[srcPos]; + } + } + + // Compare + gl.bindFramebuffer(gl.FRAMEBUFFER, dstFB); + readInto(dstTestData); + + for (var x = 0; x < kWidth; x++) { + for (var y = 0; y < kHeight; y++) { + var pos = pixelPos(x, y); + var refPixel = dstRefData[pos]; + var testPixel = dstTestData[pos]; + + //console.log([x, y].join(",") + ":", + // testPixel.toString(16), refPixel.toString(16)) + if (testPixel == refPixel) + continue; + + testFailed("Mismatch at (" + [x, y].join(", ") + "): " + + " Should be 0x" + refPixel.toString(16) + + ", was 0x" + testPixel.toString(16)); + return false; + } + } + + return true; + } + + var tests = [ + [0,0, 0,0, 2,3], + [0,0, 5,8, 2,3], + [1,0, 0,0, 2,3], + [1,7, 0,0, 2,3], + ]; + + tests.every(x => testCmd(x)); +} + +runTest(); + +debug(""); +var successfullyParsed = true; +</script> +<script src="../../../js/js-test-post.js"></script> + +</body> +</html>
--- a/dom/canvas/test/webgl-conf/generated-mochitest.ini +++ b/dom/canvas/test/webgl-conf/generated-mochitest.ini @@ -2320,16 +2320,17 @@ support-files = always-fail.html checkout/conformance/textures/image_data/tex-2d-rgb-rgb-unsigned_short_5_6_5.html checkout/conformance/textures/image_data/tex-2d-rgba-rgba-unsigned_byte.html checkout/conformance/textures/image_data/tex-2d-rgba-rgba-unsigned_short_4_4_4_4.html checkout/conformance/textures/image_data/tex-2d-rgba-rgba-unsigned_short_5_5_5_1.html checkout/conformance/textures/misc/00_test_list.txt checkout/conformance/textures/misc/compressed-tex-image.html checkout/conformance/textures/misc/copy-tex-image-2d-formats.html checkout/conformance/textures/misc/copy-tex-image-and-sub-image-2d.html + checkout/conformance/textures/misc/copy-tex-sub-image-2d-partial-texture.html checkout/conformance/textures/misc/cube-incomplete-fbo.html checkout/conformance/textures/misc/default-texture.html checkout/conformance/textures/misc/gl-get-tex-parameter.html checkout/conformance/textures/misc/gl-pixelstorei.html checkout/conformance/textures/misc/gl-teximage.html checkout/conformance/textures/misc/mipmap-fbo.html checkout/conformance/textures/misc/origin-clean-conformance.html checkout/conformance/textures/misc/tex-image-and-sub-image-2d-with-array-buffer-view.html @@ -5800,16 +5801,18 @@ skip-if = (os == 'android' || os == 'lin [generated/test_2_conformance__state__gl-initial-state.html] skip-if = (os == 'android' || os == 'linux' || (os == 'win' && os_version == '5.1')) [generated/test_2_conformance__state__state-uneffected-after-compositing.html] skip-if = (os == 'android' || os == 'linux' || (os == 'win' && os_version == '5.1')) [generated/test_2_conformance__textures__misc__copy-tex-image-2d-formats.html] skip-if = (os == 'mac') || (os == 'android' || os == 'linux' || (os == 'win' && os_version == '5.1')) [generated/test_2_conformance__textures__misc__copy-tex-image-and-sub-image-2d.html] skip-if = (os == 'android' || os == 'linux' || (os == 'win' && os_version == '5.1')) +[generated/test_2_conformance__textures__misc__copy-tex-sub-image-2d-partial-texture.html] +skip-if = (os == 'android' || os == 'linux' || (os == 'win' && os_version == '5.1')) [generated/test_2_conformance__textures__misc__cube-incomplete-fbo.html] skip-if = (os == 'win') || (os == 'android' || os == 'linux' || (os == 'win' && os_version == '5.1')) fail-if = (os == 'mac') [generated/test_2_conformance__textures__misc__default-texture.html] skip-if = (os == 'android' || os == 'linux' || (os == 'win' && os_version == '5.1')) [generated/test_2_conformance__textures__misc__gl-pixelstorei.html] skip-if = (os == 'android' || os == 'linux' || (os == 'win' && os_version == '5.1')) [generated/test_2_conformance__textures__misc__gl-teximage.html] @@ -6686,16 +6689,17 @@ skip-if = (os == 'mac') || (os == 'andro [generated/test_conformance__state__gl-getstring.html] [generated/test_conformance__state__gl-initial-state.html] [generated/test_conformance__state__gl-object-get-calls.html] [generated/test_conformance__state__state-uneffected-after-compositing.html] [generated/test_conformance__textures__misc__compressed-tex-image.html] [generated/test_conformance__textures__misc__copy-tex-image-2d-formats.html] skip-if = (os == 'win' && os_version == '5.1') [generated/test_conformance__textures__misc__copy-tex-image-and-sub-image-2d.html] +[generated/test_conformance__textures__misc__copy-tex-sub-image-2d-partial-texture.html] [generated/test_conformance__textures__misc__cube-incomplete-fbo.html] skip-if = (os == 'android') fail-if = (os == 'mac') || (os == 'linux') [generated/test_conformance__textures__misc__default-texture.html] [generated/test_conformance__textures__misc__gl-get-tex-parameter.html] [generated/test_conformance__textures__misc__gl-pixelstorei.html] [generated/test_conformance__textures__misc__gl-teximage.html] skip-if = (os == 'android')
new file mode 100644 --- /dev/null +++ b/dom/canvas/test/webgl-conf/generated/test_2_conformance__textures__misc__copy-tex-sub-image-2d-partial-texture.html @@ -0,0 +1,17 @@ +<!-- GENERATED FILE, DO NOT EDIT --> +<!DOCTYPE HTML> +<html> + <head> + <meta charset='utf-8'/> + <title> + Mochitest wrapper for WebGL Conformance Test Suite tests + </title> + <link rel='stylesheet' type='text/css' href='../iframe-passthrough.css'/> + + <script src='/tests/SimpleTest/SimpleTest.js'></script> + <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/> + </head> + <body> + <iframe src='../mochi-single.html?checkout/conformance/textures/misc/copy-tex-sub-image-2d-partial-texture.html?webglVersion=2'></iframe> + </body> +</html>
new file mode 100644 --- /dev/null +++ b/dom/canvas/test/webgl-conf/generated/test_conformance__textures__misc__copy-tex-sub-image-2d-partial-texture.html @@ -0,0 +1,17 @@ +<!-- GENERATED FILE, DO NOT EDIT --> +<!DOCTYPE HTML> +<html> + <head> + <meta charset='utf-8'/> + <title> + Mochitest wrapper for WebGL Conformance Test Suite tests + </title> + <link rel='stylesheet' type='text/css' href='../iframe-passthrough.css'/> + + <script src='/tests/SimpleTest/SimpleTest.js'></script> + <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/> + </head> + <body> + <iframe src='../mochi-single.html?checkout/conformance/textures/misc/copy-tex-sub-image-2d-partial-texture.html'></iframe> + </body> +</html>