зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1328539 - writeX/Y should be relative to x/yOffset. - r=daoshengmu
MozReview-Commit-ID: KKstUheoSrJ
This commit is contained in:
Родитель
71cc6be57d
Коммит
5724214b50
|
@ -2016,6 +2016,9 @@ DoCopyTexOrSubImage(WebGLContext* webgl, const char* funcName, bool isSubImage,
|
|||
Intersect(srcTotalWidth, xWithinSrc, dstWidth, &readX, &writeX, &rwWidth);
|
||||
Intersect(srcTotalHeight, yWithinSrc, dstHeight, &readY, &writeY, &rwHeight);
|
||||
|
||||
writeX += xOffset;
|
||||
writeY += yOffset;
|
||||
|
||||
////
|
||||
|
||||
GLenum error = 0;
|
||||
|
@ -2058,7 +2061,6 @@ DoCopyTexOrSubImage(WebGLContext* webgl, const char* funcName, bool isSubImage,
|
|||
ScopedCopyTexImageSource maybeSwizzle(webgl, funcName, srcTotalWidth,
|
||||
srcTotalHeight, srcFormat, dstUsage);
|
||||
|
||||
const uint8_t zOffset = 0;
|
||||
error = DoCopyTexSubImage(gl, target, level, writeX, writeY, zOffset, readX,
|
||||
readY, rwWidth, rwHeight);
|
||||
if (error)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
--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
|
||||
|
|
|
@ -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>
|
|
@ -2325,6 +2325,7 @@ support-files = always-fail.html
|
|||
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
|
||||
|
@ -5805,6 +5806,8 @@ skip-if = (os == 'android' || os == 'linux' || (os == 'win' && os_version == '5.
|
|||
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')
|
||||
|
@ -6691,6 +6694,7 @@ skip-if = (os == 'mac') || (os == 'android') || (os == 'win')
|
|||
[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')
|
||||
|
|
|
@ -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>
|
|
@ -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>
|
Загрузка…
Ссылка в новой задаче