Bug 1450839 - Update webgl-conf/checkout.

MozReview-Commit-ID: LFEgeAgLn1m


--HG--
rename : dom/canvas/test/webgl-conf/checkout/conformance/textures/misc/copy-tex-sub-image-2d-partial-texture.html => dom/canvas/test/webgl-conf/checkout/conformance/textures/misc/copytexsubimage2d-subrects.html
This commit is contained in:
Jeff Gilbert 2018-04-02 18:09:34 -07:00
Родитель fe6d2e9633
Коммит 71544a10d9
2070 изменённых файлов: 57970 добавлений и 3492 удалений

Просмотреть файл

@ -3,6 +3,5 @@
conformance/00_test_list.txt
conformance/more/00_test_list.txt
// Disable deqp tests temporarily
// deqp/00_test_list.txt
deqp/00_test_list.txt
--min-version 2.0.0 conformance2/00_test_list.txt

Просмотреть файл

@ -75,5 +75,6 @@ The dates below are when work on the conformance suite version was started.
- 2012/02/23: Version 1.0.1
- 2012/03/20: Version 1.0.2
- 2013/02/14: Version 1.0.3
- 2013/10/11: Version 2.0.0 (beta)
- 2013/10/11: Version 2.0.0
- 2014/11/14: Version 1.0.4
- 2016/11/21: Version 2.0.1

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -1,13 +0,0 @@
This file "00_test_list.txt" lists which files the test harness should run.
If you add new tests you can update it with
on windows
dir /b *.html >00_test_list.txt
on OSX / Linux
ls -1 *.html >00_test_list.txt

Просмотреть файл

@ -7,6 +7,7 @@ glsl/00_test_list.txt
limits/00_test_list.txt
misc/00_test_list.txt
--min-version 1.0.2 ogles/00_test_list.txt
--min-version 1.0.4 offscreencanvas/00_test_list.txt
programs/00_test_list.txt
reading/00_test_list.txt
renderbuffers/00_test_list.txt

Просмотреть файл

@ -1,5 +1,6 @@
--min-version 1.0.3 gl-bindAttribLocation-aliasing.html
--min-version 1.0.3 gl-bindAttribLocation-matrix.html
--min-version 1.0.4 gl-bindAttribLocation-nonexistent-attribute.html
--min-version 1.0.4 gl-bindAttribLocation-repeated.html
--min-version 1.0.2 gl-disabled-vertex-attrib.html
gl-enable-vertex-attrib.html
@ -9,3 +10,4 @@ gl-vertexattribpointer.html
gl-vertexattribpointer-offsets.html
--min-version 1.0.2 gl-vertex-attrib-render.html
gl-vertex-attrib-zero-issues.html
--min-version 1.0.4 gl-vertex-attrib-unconsumed-out-of-bounds.html

Просмотреть файл

@ -1,4 +1,4 @@
<!--
<!--
/*
** Copyright (c) 2014 The Khronos Group Inc.

Просмотреть файл

@ -0,0 +1,101 @@
<!--
/*
** Copyright (c) 2017 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="../../js/js-test-pre.js"></script>
<script src="../../js/webgl-test-utils.js"></script>
<title>bindAttribLocation with nonexistent attribute name</title>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<canvas id="canvas" width="8" height="8"></canvas>
<script id="vertexShader" type="text/something-not-javascript">
precision highp float;
attribute vec4 attr;
void main() {
gl_Position = vec4(attr);
}
</script>
<script>
"use strict";
description("This test verifies that calling bindAttribLocation with a non-existent attribute location is fine.");
// OpenGL ES 2.0.25 section 2.10 page 34.
var wtu = WebGLTestUtils;
var canvas = document.getElementById("canvas");
var gl = wtu.create3DContext(canvas);
var fragmentShader = wtu.loadShader(gl, wtu.simpleColorFragmentShader, gl.FRAGMENT_SHADER);
var vertexShader = wtu.loadShaderFromScript(gl, 'vertexShader', gl.VERTEX_SHADER);
assertMsg(vertexShader != null, "Vertex shader compiled successfully.");
var checkAttribLocation = function(program, expectedLocation) {
var location = gl.getAttribLocation(program, 'attr');
if (location != expectedLocation) {
testFailed('Unexpected location for attr: ' + location);
} else {
testPassed('Location of attr is: ' + location);
}
}
var testProgramNonExistentAttributeBound = function() {
var program = gl.createProgram();
gl.bindAttribLocation(program, 0, 'attr');
gl.bindAttribLocation(program, 1, 'bogus_attr');
gl.attachShader(program, vertexShader);
gl.attachShader(program, fragmentShader);
gl.linkProgram(program);
var linkStatus = gl.getProgramParameter(program, gl.LINK_STATUS);
expectTrue(linkStatus, "Link should succeed even if a non-existent attribute is bound.");
if (linkStatus) {
checkAttribLocation(program, 0);
}
};
var testProgramNonExistentAttributeOverlap = function() {
var program = gl.createProgram();
gl.bindAttribLocation(program, 1, 'attr');
gl.bindAttribLocation(program, 1, 'bogus_attr');
gl.attachShader(program, vertexShader);
gl.attachShader(program, fragmentShader);
gl.linkProgram(program);
var linkStatus = gl.getProgramParameter(program, gl.LINK_STATUS);
expectTrue(linkStatus, "Link should succeed even if a non-existent attribute is bound to the same location as an attribute that's present in the shader text.");
if (linkStatus) {
checkAttribLocation(program, 1);
}
};
testProgramNonExistentAttributeBound();
testProgramNonExistentAttributeOverlap();
var successfullyParsed = true;
</script>
<script src="../../js/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,210 @@
<!--
/*
** Copyright (c) 2017 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 Unconsumed Vertex Attributes Out of Bounds 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>
<canvas id="example" width="50" height="50">
</canvas>
<div id="description"></div>
<div id="console"></div>
<script id="vshader" type="x-shader/x-vertex">
void main() { }
</script>
<script id="vshader_attrib" type="x-shader/x-vertex">
attribute vec4 vPosition;
void main() {
gl_Position = vPosition;
}
</script>
<script id="fshader" type="x-shader/x-fragment">
void main() { }
</script>
<script>
"use strict";
description("Test that unconsumed vertex attributes are not read out of bounds");
// Tests for http://crbug.com/756293 (driver crash on macOS)
// and a class of similar bugs that could exist on other systems.
var wtu = WebGLTestUtils;
var contextVersion = wtu.getDefault3DContextVersion();
var gl = wtu.create3DContext("example");
var g_program;
var g_attribLocation;
var numAttribs = gl.getParameter(gl.MAX_VERTEX_ATTRIBS);
var allocatedBuffer;
var indexBuffer;
function setupBuffers(numVerts) {
var vertices = new Float32Array(numVerts * 3);
allocatedBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, allocatedBuffer);
gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW);
var indices = new Uint16Array(numVerts);
for (var ii = 0; ii < numVerts; ++ii) {
indices[ii] = ii;
}
indexBuffer = gl.createBuffer();
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW);
}
var progNoAttribs = wtu.setupProgram(gl, ['vshader', 'fshader'], [], []);
var progAttrib1 = wtu.setupProgram(gl, ['vshader_attrib', 'fshader'], ['vPosition'], [1]);
var progAttrib2 = wtu.setupProgram(gl, ['vshader_attrib', 'fshader'], ['vPosition'], [2]);
setupBuffers(60000);
var unallocatedBuffer = gl.createBuffer();
var tests = [];
debug("");
debug("<u>Tests with one unconsumed attribute<u>");
tests.push({
name: "drawArrays",
errors: gl.NO_ERROR,
draw: function() { gl.drawArrays(gl.TRIANGLES, 0, 3); }
});
tests.push({
name: "drawElements",
errors: gl.NO_ERROR,
draw: function() { gl.drawElements(gl.TRIANGLES, 60000, gl.UNSIGNED_SHORT, 0); }
});
if (contextVersion >= 2) {
tests.push({
name: "drawArraysInstanced",
errors: gl.NO_ERROR,
draw: function() { gl.drawArraysInstanced(gl.TRIANGLES, 0, 3, 1); }
});
tests.push({
name: "drawElementsInstanced",
errors: gl.NO_ERROR,
draw: function() { gl.drawElementsInstanced(gl.TRIANGLES, 60000, gl.UNSIGNED_SHORT, 0, 1); }
});
tests.push({
name: "drawRangeElements",
errors: gl.NO_ERROR,
draw: function() { gl.drawRangeElements(gl.TRIANGLES, 0, 60000, 60000, gl.UNSIGNED_SHORT, 0, 1); }
});
}
// Run tests
// Bound forever
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
for (var attrib = 0; attrib < numAttribs; ++attrib) {
debug("Attrib " + attrib + " unconsumed");
for (var i = 0; i < tests.length; ++i) {
var test = tests[i];
gl.useProgram(progNoAttribs);
gl.enableVertexAttribArray(attrib);
gl.bindBuffer(gl.ARRAY_BUFFER, unallocatedBuffer);
gl.vertexAttribPointer(attrib, 3, gl.FLOAT, false, 0, 0);
test.draw();
gl.disableVertexAttribArray(attrib);
wtu.glErrorShouldBe(gl, test.errors, test.name);
}
}
debug("");
debug("<u>Tests with one consumed attribute and one unconsumed attribute<u>");
var ext = gl.getExtension("ANGLE_instanced_arrays");
if (!ext) {
debug("ANGLE_instanced_arrays not available - skipped");
} else {
tests.push({
name: "drawArraysInstancedANGLE",
errors: gl.NO_ERROR,
draw: function() {
ext.drawArraysInstancedANGLE(gl.TRIANGLES, 0, 3, 1);
}
});
tests.push({
name: "drawElementsInstancedANGLE",
errors: gl.NO_ERROR,
draw: function() {
ext.drawElementsInstancedANGLE(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0, 1);
}
});
}
// Note these don't trigger the macOS driver crash (http://crbug.com/756293)
// but they still add potentially useful coverage.
for (var attrib = 0; attrib < numAttribs; ++attrib) {
var consumedAttrib = attrib == 1 ? 2 : 1;
var prog = consumedAttrib == 1 ? progAttrib1 : progAttrib2;
debug("Attrib " + attrib +
" unconsumed (attrib " + consumedAttrib + " consumed)");
for (var i = 0; i < tests.length; ++i) {
var test = tests[i];
gl.useProgram(prog);
gl.enableVertexAttribArray(attrib);
gl.bindBuffer(gl.ARRAY_BUFFER, unallocatedBuffer);
gl.vertexAttribPointer(attrib, 3, gl.FLOAT, false, 0, 0);
// Needed because ANGLE_instanced_arrays requires at least one consumed
// attribute to have divisor=0 (which is the default, so we don't need to
// call vertexAttribDivisorANGLE here).
gl.enableVertexAttribArray(consumedAttrib);
gl.bindBuffer(gl.ARRAY_BUFFER, allocatedBuffer);
gl.vertexAttribPointer(consumedAttrib, 3, gl.FLOAT, false, 0, 0);
test.draw();
gl.disableVertexAttribArray(attrib);
gl.disableVertexAttribArray(consumedAttrib);
wtu.glErrorShouldBe(gl, test.errors, test.name);
}
}
var successfullyParsed = true;
</script>
<script src="../../js/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -128,7 +128,7 @@ for (var ii = 0; ii < 5; ++ii) {
wtu.checkCanvas(gl, [0, 255, 0, 255], "canvas should be green");
gl.disableVertexAttribArray(3);
// This second test of drawing without attrib0 unconvered a bug in chrome
// This second test of drawing without attrib0 uncovered a bug in chrome
// where after the draw without attrib0 the attrib 0 emulation code disabled
// attrib 0 and it was never re-enabled so this next draw failed.
gl.useProgram(p3);

Просмотреть файл

@ -59,14 +59,28 @@ if (!gl) {
gl.FIXED = 0x140C;
}
gl.vertexAttribPointer(0, 3, gl.FLOAT, 0, 0, 12);
wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION,
"vertexAttribPointer should fail if no buffer is bound");
var vertexObject = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(0), gl.STATIC_DRAW);
gl.bindBuffer(gl.ARRAY_BUFFER, null);
gl.vertexAttribPointer(0, 1, gl.FLOAT, false, 0, 4);
wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION,
"vertexAttribPointer should fail if no buffer is bound and `offset` is non-zero.");
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
gl.vertexAttribPointer(0, 1, gl.FLOAT, false, 0, 0);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
gl.bindBuffer(gl.ARRAY_BUFFER, null);
gl.vertexAttribPointer(0, 1, gl.FLOAT, false, 0, 0);
wtu.glErrorShouldBe(gl, gl.NO_ERROR,
"vertexAttribPointer should succeed if no buffer is bound and `offset` is zero.");
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
if (wtu.getDefault3DContextVersion() < 2) {
gl.vertexAttribPointer(0, 1, gl.INT, 0, 0, 0);
wtu.glErrorShouldBe(gl, gl.INVALID_ENUM,

Просмотреть файл

@ -56,13 +56,15 @@ context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, indexObject);
var indices = new Uint16Array([ 10000, 0, 1, 2, 3, 10000 ]);
context.bufferData(context.ELEMENT_ARRAY_BUFFER, indices, context.STATIC_DRAW);
wtu.shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2)");
wtu.shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
wtu.shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
var indexValidationError = wtu.shouldGenerateGLError(context,
[context.INVALID_OPERATION, context.NO_ERROR],
"context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
wtu.shouldGenerateGLError(context, indexValidationError, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
indices[0] = 2;
indices[5] = 1;
wtu.shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2)");
wtu.shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
wtu.shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
wtu.shouldGenerateGLError(context, indexValidationError, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
wtu.shouldGenerateGLError(context, indexValidationError, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
debug("")
var successfullyParsed = true;

Просмотреть файл

@ -58,9 +58,9 @@ var indexObject = context.createBuffer();
debug("Test out of range indices")
context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, indexObject);
context.bufferData(context.ELEMENT_ARRAY_BUFFER, new Uint16Array([ 10000, 0, 1, 2, 3, 10000 ]), context.STATIC_DRAW);
var indexValidationError = wtu.shouldGenerateGLError(context, [context.INVALID_OPERATION, context.NO_ERROR], "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
wtu.shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2)");
wtu.shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
wtu.shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
wtu.shouldGenerateGLError(context, indexValidationError, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
debug("")
var successfullyParsed = true;

Просмотреть файл

@ -110,7 +110,7 @@ gl.vertexAttribPointer(normalLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT),
gl.enableVertexAttribArray(normalLoc);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)');
wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION);
wtu.glErrorShouldBe(gl, [gl.INVALID_OPERATION, gl.NO_ERROR]);
debug("Test with enabled attribute that does not belong to current program");

Просмотреть файл

@ -10,6 +10,7 @@ drawingbuffer-test.html
--min-version 1.0.2 framebuffer-bindings-unaffected-on-resize.html
--min-version 1.0.4 framebuffer-bindings-affected-by-to-data-url.html
--min-version 1.0.3 rapid-resizing.html
--min-version 1.0.4 render-after-resize-test.html
--min-version 1.0.2 texture-bindings-unaffected-on-resize.html
--min-version 1.0.2 to-data-url-test.html
viewport-unchanged-upon-resize.html

Просмотреть файл

@ -104,11 +104,14 @@ if (!gl) {
g2d = imgData.data[offset + 1];
b2d = imgData.data[offset + 2];
a2d = imgData.data[offset + 3];
//debug('' + x + ', ' + y + "(" + offset + ") = " + r2d + ", " + g2d + ", " + b2d + ", " + a2d);
return isAboutEqualInt(r2d, r3d) &&
isAboutEqualInt(g2d, g3d) &&
isAboutEqualInt(b2d, b3d) &&
isAboutEqualInt(a2d, a3d);
var res = isAboutEqualInt(r2d, r3d) &&
isAboutEqualInt(g2d, g3d) &&
isAboutEqualInt(b2d, b3d) &&
isAboutEqualInt(a2d, a3d);
if (!res) {
bufferedLogToConsole('at ' + x + ', ' + y + " (offset " + offset + ") = " + r2d + ", " + g2d + ", " + b2d + ", " + a2d);
}
return res;
}
var checkPixels = function(r3d,g3d,b3d,a3d) {

Просмотреть файл

@ -0,0 +1,96 @@
<!--
/*
** Copyright (c) 2017 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 render after resize 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 style="width: 100px, height: 100px; border: 1px solid blue;" id="c"></canvas>
<div id="console"></div>
<script>
description("This test ensures WebGL implementations can render correctly after resizing the canvas.");
debug("");
var wtu = WebGLTestUtils;
var gl = wtu.create3DContext("c");
shouldBeTrue("gl != null");
var positionLocation = 0;
var texcoordLocation = 1;
var program = wtu.setupColorQuad(gl, positionLocation);
var colorLocation = gl.getUniformLocation(program, 'u_color');
gl.uniform4fv(colorLocation, [0.0, 1.0, 0.0, 1.0]);
const smallWidth = 300;
const smallHeight = 150;
// Changing this size to something smaller produces
// different results. Sometimes wrong, sometimes correct.
const largeWidth = 1200;
const largeHeight = 672;
function render() {
gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
gl.enable(gl.DEPTH_TEST);
gl.clearColor(1,0,0,1);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
gl.useProgram(program);
wtu.drawUnitQuad(gl);
}
function checkForQuad(ctx) {
let w = ctx.drawingBufferWidth;
let h = ctx.drawingBufferHeight;
wtu.checkCanvasRect(gl, 0, 0, w, h, [ 0, 255, 0, 255 ]);
}
gl.canvas.width = smallWidth;
gl.canvas.height = smallHeight;
render();
checkForQuad(gl); // passes
gl.canvas.width = largeWidth;
gl.canvas.height = largeHeight;
gl.canvas.width = smallWidth;
gl.canvas.height = smallHeight;
render();
checkForQuad(gl); // fails (almost all the time)
finishTest();
var successfullyParsed = true;
</script>
</body>
</html>

Просмотреть файл

@ -1,4 +1,4 @@
<!--
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.

Просмотреть файл

@ -472,7 +472,6 @@ canvas : "implementation-dependent"
// added in versions of the spec that are backward-compatible with
// this version
var ignoredProperties = [
'STENCIL_INDEX'
];
// Constants removed from the WebGL spec compared to ES 2.0

Просмотреть файл

@ -25,6 +25,7 @@
--min-version 1.0.2 --max-version 1.9.9 oes-element-index-uint.html
webgl-debug-renderer-info.html
webgl-debug-shaders.html
--min-version 1.0.4 webgl-compressed-texture-astc.html
--min-version 1.0.3 webgl-compressed-texture-atc.html
--min-version 1.0.4 webgl-compressed-texture-etc.html
--min-version 1.0.3 webgl-compressed-texture-pvrtc.html
@ -33,6 +34,8 @@ webgl-debug-shaders.html
--min-version 1.0.3 webgl-compressed-texture-size-limit.html
--min-version 1.0.2 --max-version 1.9.9 webgl-depth-texture.html
--min-version 1.0.3 --max-version 1.9.9 webgl-draw-buffers.html
--min-version 1.0.4 --max-version 1.9.9 webgl-draw-buffers-broadcast-return.html
--min-version 1.0.3 --max-version 1.9.9 webgl-draw-buffers-feedback-loop.html
--min-version 1.0.4 --max-version 1.9.9 webgl-draw-buffers-framebuffer-unsupported.html
--min-version 1.0.4 --max-version 1.9.9 webgl-draw-buffers-max-draw-buffers.html
--min-version 1.0.3 webgl-shared-resources.html

Просмотреть файл

@ -1,4 +1,4 @@
<!--
<!--
/*
** Copyright (c) 2013 The Khronos Group Inc.
@ -119,6 +119,8 @@ if (!gl) {
runDrawArraysWithOffsetTest();
runVAOInstancingInteractionTest();
runANGLECorruptionTest();
// Note that the ANGLE corruption test leaves vertex attrib divisors dirty at the moment.
// This should be cleaned up if more subtests are added after it.
}
}
@ -178,6 +180,9 @@ function runDivisorTestEnabled() {
else{
testFailed("Set value of VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE should be: 2, returned value was: " + queried_value);
}
// Reset vertex attrib divisors so they cannot affect following subtests.
ext.vertexAttribDivisorANGLE(max_vertex_attribs-1, 0);
}
function setupCanvas() {
@ -351,6 +356,10 @@ function runOutputTests() {
wtu.glErrorShouldBe(gl, gl.INVALID_ENUM, "drawElementsInstancedANGLE with QUADS should return INVALID_ENUM");
ext.drawElementsInstancedANGLE(desktopGL['POLYGON'], 6, gl.UNSIGNED_SHORT, 0, instanceCount);
wtu.glErrorShouldBe(gl, gl.INVALID_ENUM, "drawElementsInstancedANGLE with POLYGON should return INVALID_ENUM");
// Reset vertex attrib divisors so they cannot affect following subtests.
ext.vertexAttribDivisorANGLE(colorLoc, 0);
ext.vertexAttribDivisorANGLE(offsetLoc, 0);
}
function runDrawArraysTest(program, first, count, instanceCount, offset)
@ -404,6 +413,9 @@ function runDrawArraysTest(program, first, count, instanceCount, offset)
// Do the instanced draw
ext.drawArraysInstancedANGLE(gl.TRIANGLES, first, count, instanceCount);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "drawArraysInstancedANGLE should succeed");
// Reset vertex attrib divisors so they cannot affect following subtests.
ext.vertexAttribDivisorANGLE(instancePosLoc, 0);
}
function runDrawArraysWithOffsetTest()

Просмотреть файл

@ -1,4 +1,4 @@
<!--
<!--
/*
** Copyright (c) 2014 The Khronos Group Inc.

Просмотреть файл

@ -65,19 +65,24 @@ if (!gl) {
testPassed("No EXT_disjoint_timer_query support -- this is legal");
finishTest();
} else {
runSanityTests();
if (wtu.getDefault3DContextVersion() > 1) {
testFailed("EXT_disjoint_timer_query must not be advertised on WebGL 2.0 contexts");
finishTest();
} else {
runSanityTests();
// Clear disjoint value.
gl.getParameter(ext.GPU_DISJOINT_EXT);
// Clear disjoint value.
gl.getParameter(ext.GPU_DISJOINT_EXT);
runElapsedTimeTest();
timestamp_counter_bits = ext.getQueryEXT(ext.TIMESTAMP_EXT, ext.QUERY_COUNTER_BITS_EXT);
if (timestamp_counter_bits > 0) {
runTimeStampTest();
runElapsedTimeTest();
timestamp_counter_bits = ext.getQueryEXT(ext.TIMESTAMP_EXT, ext.QUERY_COUNTER_BITS_EXT);
if (timestamp_counter_bits > 0) {
runTimeStampTest();
}
verifyQueryResultsNotAvailable();
window.requestAnimationFrame(checkQueryResults);
}
verifyQueryResultsNotAvailable();
window.requestAnimationFrame(checkQueryResults);
}
}

Просмотреть файл

@ -1,4 +1,4 @@
<!--
<!--
/*
** Copyright (c) 2013 The Khronos Group Inc.

Просмотреть файл

@ -4,7 +4,6 @@
<meta charset="utf-8"/>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../js/js-test-pre.js"></script>
<script src="../../js/webgl-test.js"></script>
<script src="../../js/webgl-test-utils.js"></script>
</head>
<body>
@ -28,6 +27,27 @@ void main() {
}
</script>
<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 sampler2D tex;
varying vec2 texCoord;
void main()
{
gl_FragColor = texture2D(tex, texCoord);
}
</script>
<script>
"use strict";
@ -227,6 +247,7 @@ if (!gl) {
runFramebufferTextureConversionTest(ext.SRGB_EXT);
runFramebufferTextureConversionTest(ext.SRGB_ALPHA_EXT);
runFramebufferRenderbufferConversionTest();
runGenerateMipmapTest();
runLoadFromImageTest(function() {
finishTest();
});
@ -424,6 +445,23 @@ function runLoadFromImageTest(callback) {
});
}
function runGenerateMipmapTest()
{
debug("");
debug("GenerateMipmaps for sRGB textures is forbidden");
var tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);
gl.texImage2D(gl.TEXTURE_2D, 0, ext.SRGB_ALPHA_EXT, 2, 2, 0, ext.SRGB_ALPHA_EXT,
gl.UNSIGNED_BYTE, null);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
gl.generateMipmap(gl.TEXTURE_2D);
wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION);
gl.deleteTexture(tex);
}
var successfullyParsed = true;
</script>
</body>

Просмотреть файл

@ -1,4 +1,4 @@
<!--
<!--
/*
** Copyright (c) 2014 The Khronos Group Inc.

Просмотреть файл

@ -1,4 +1,4 @@
<!--
<!--
/*
** Copyright (c) 2012 Florian Boesch <pyalot@gmail.com>.

Просмотреть файл

@ -1,4 +1,4 @@
<!--
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.

Просмотреть файл

@ -289,8 +289,8 @@ function runIndexValidationTests(drawType) {
gl.vertexAttribPointer(normalLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), 4 * sizeInBytes(gl.FLOAT));
gl.enableVertexAttribArray(normalLoc);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_INT, 0)');
wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION);
wtu.shouldGenerateGLError(gl, [gl.INVALID_OPERATION, gl.NO_ERROR],
'gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_INT, 0)');
debug("Test with enabled attribute that does not belong to current program");
@ -330,13 +330,14 @@ function runCopiesIndicesTests(drawType) {
var indices = new Uint32Array([ 10000, 0, 1, 2, 3, 10000 ]);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, drawType);
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 4)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 0)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 8)");
var indexValidationError = wtu.shouldGenerateGLError(gl, [gl.INVALID_OPERATION, gl.NO_ERROR],
"gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 0)");
wtu.shouldGenerateGLError(gl, indexValidationError, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 8)");
indices[0] = 2;
indices[5] = 1;
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 4)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 0)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 8)");
wtu.shouldGenerateGLError(gl, indexValidationError, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 0)");
wtu.shouldGenerateGLError(gl, indexValidationError, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 8)");
}
function runResizedBufferTests(drawType) {
@ -422,8 +423,9 @@ function runVerifiesTooManyIndicesTests(drawType) {
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexObject);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint32Array([ 10000, 0, 1, 2, 3, 10000 ]), drawType);
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 4)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 0)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 8)");
var indexValidationError = wtu.shouldGenerateGLError(gl, [gl.INVALID_OPERATION, gl.NO_ERROR],
"gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 0)");
wtu.shouldGenerateGLError(gl, indexValidationError, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 8)");
}
function runCrashWithBufferSubDataTests(drawType) {

Просмотреть файл

@ -1,4 +1,4 @@
<!--
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.

Просмотреть файл

@ -82,41 +82,72 @@ var canvas = document.getElementById("canvas");
var gl = wtu.create3DContext(canvas);
if (!gl) {
testFailed("WebGL context does not exist");
testFailed("WebGL context does not exist");
} else {
testPassed("WebGL context exists");
testPassed("WebGL context exists");
var texturedShaders = [
wtu.simpleTextureVertexShader,
"testFragmentShader"
];
var testProgram =
wtu.setupProgram(gl,
texturedShaders,
['vPosition', 'texCoord0'],
[0, 1]);
var quadParameters = wtu.setupUnitQuad(gl, 0, 1);
var texturedShaders = [
wtu.simpleTextureVertexShader,
"testFragmentShader"
];
var testProgram =
wtu.setupProgram(gl,
texturedShaders,
['vPosition', 'texCoord0'],
[0, 1]);
var quadParameters = wtu.setupUnitQuad(gl, 0, 1);
// First verify that allocation of floating-point textures fails if
// the extension has not been enabled yet.
runTextureCreationTest(testProgram, false);
// First verify that allocation of floating-point textures fails if
// the extension has not been enabled yet.
runTextureCreationTest(testProgram, false);
if (!gl.getExtension("OES_texture_float")) {
testPassed("No OES_texture_float support -- this is legal");
} else {
testPassed("Successfully enabled OES_texture_float extension");
// If alpha value is missing from a texture it gets filled to 1 when sampling according to GLES2.0 table 3.12
runTextureCreationTest(testProgram, true, gl.RGBA, 4, [10000, 10000, 10000, 10000]);
runTextureCreationTest(testProgram, true, gl.RGB, 3, [10000, 10000, 10000, 1]);
runTextureCreationTest(testProgram, true, gl.LUMINANCE, 1, [10000, 10000, 10000, 1]);
runTextureCreationTest(testProgram, true, gl.ALPHA, 1, [0, 0, 0, 10000]);
runTextureCreationTest(testProgram, true, gl.LUMINANCE_ALPHA, 2, [10000, 10000, 10000, 10000]);
runRenderTargetAndReadbackTest(testProgram, gl.RGBA, 4, [10000, 10000, 10000, 10000], 0);
runRenderTargetAndReadbackTest(testProgram, gl.RGB, 3, [10000, 10000, 10000, 1], 0);
runRenderTargetAndReadbackTest(testProgram, gl.RGBA, 4, [10000, 10000, 10000, 10000], 1);
runRenderTargetAndReadbackTest(testProgram, gl.RGBA, 4, [10000, 10000, 10000, 10000], 0.5);
runUniqueObjectTest();
}
if (!gl.getExtension("OES_texture_float")) {
testPassed("No OES_texture_float support -- this is legal");
} else {
testPassed("Successfully enabled OES_texture_float extension");
// If alpha value is missing from a texture it gets filled to 1 when sampling according to GLES2.0 table 3.12
runTextureCreationTest(testProgram, true, gl.RGBA, 4, [10000, 10000, 10000, 10000]);
runTextureCreationTest(testProgram, true, gl.RGB, 3, [10000, 10000, 10000, 1]);
runTextureCreationTest(testProgram, true, gl.LUMINANCE, 1, [10000, 10000, 10000, 1]);
runTextureCreationTest(testProgram, true, gl.ALPHA, 1, [0, 0, 0, 10000]);
runTextureCreationTest(testProgram, true, gl.LUMINANCE_ALPHA, 2, [10000, 10000, 10000, 10000]);
(function() {
debug("");
var renderable = isRenderable(gl);
var renderableExtName = "WEBGL_color_buffer_float";
var supported = gl.getSupportedExtensions().includes(renderableExtName);
if (renderable && !supported) {
testFailed("RGBA/FLOAT is color renderable but " + renderableExtName + " not exposed");
} else if (supported && !renderable) {
testFailed(renderableExtName + " is exposed but RGBA/FLOAT is not color renderable");
}
if (supported) {
runRenderTargetAndReadbackTest(testProgram, gl.RGBA, 4, [10000, 10000, 10000, 10000], 0, true);
runRenderTargetAndReadbackTest(testProgram, gl.RGB, 3, [10000, 10000, 10000, 1], 0, false);
runRenderTargetAndReadbackTest(testProgram, gl.RGBA, 4, [10000, 10000, 10000, 10000], 1, true);
runRenderTargetAndReadbackTest(testProgram, gl.RGBA, 4, [10000, 10000, 10000, 10000], 0.5, true);
}
})();
runUniqueObjectTest();
}
}
function isRenderable(gl) {
var tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.FLOAT, null);
var fb = gl.createFramebuffer();
gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0);
var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
gl.deleteFramebuffer(fb);
gl.deleteTexture(tex);
return status == gl.FRAMEBUFFER_COMPLETE;
}
function allocateTexture()
@ -189,7 +220,7 @@ function arrayToString(arr, size) {
return out + "]";
}
function runRenderTargetAndReadbackTest(testProgram, format, numberOfChannels, subtractor, texSubImageCover)
function runRenderTargetAndReadbackTest(testProgram, format, numberOfChannels, subtractor, texSubImageCover, requireRenderable)
{
var formatString = wtu.glEnumToString(gl, format);
debug("");
@ -209,7 +240,10 @@ function runRenderTargetAndReadbackTest(testProgram, format, numberOfChannels, s
// It is legal for a WebGL implementation exposing the OES_texture_float extension to
// support floating-point textures but not as attachments to framebuffer objects.
if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) != gl.FRAMEBUFFER_COMPLETE) {
debug("floating-point " + formatString + " render target not supported -- this is legal");
if (requireRenderable)
testFailed("floating-point " + formatString + " render target not supported");
else
debug("floating-point " + formatString + " render target not supported -- this is legal");
return;
}

Просмотреть файл

@ -82,6 +82,7 @@ var gl = wtu.create3DContext(canvas);
var halfFloatOESEnum = 0x8D61;
var ext = null;
if (!gl) {
testFailed("WebGL context does not exists");
} else {
@ -157,8 +158,8 @@ if (!gl) {
// Next check that values outside the 0-1 range can be written.
var halfFloatTenK = 0x70E2; // Half float 10000
var uint16Formats2 = [
{ format: gl.RGBA, subtractor: [10000, 10000, 10000, 10000], },
{ format: gl.RGB, subtractor: [10000, 10000, 10000, 1], },
{ format: gl.RGBA, subtractor: [10000, 10000, 10000, 10000], requireRenderable: true},
{ format: gl.RGB, subtractor: [10000, 10000, 10000, 1], requireRenderable: false},
];
uint16Formats2.forEach(function(f) {
@ -170,20 +171,47 @@ if (!gl) {
for (var ii = 0; ii < uint16Data.length; ii++) {
uint16Data[ii] = halfFloatTenK;
}
runRenderTest(format, f.subtractor, uint16Data);
runRenderTest(format, f.subtractor, uint16Data, f.requireRenderable);
});
// Check if attaching texture as FBO target succeeds (Not mandatory)
runRenderTest(gl.RGBA, [10000, 10000, 10000, 10000], null);
runRenderTest(gl.RGB, [10000, 10000, 10000, 1], null);
runFramebufferTest();
(function() {
debug("");
var renderable = isRenderable(gl, ext);
var renderableExtName = "EXT_color_buffer_half_float";
var supported = gl.getSupportedExtensions().includes(renderableExtName);
if (renderable && !supported) {
testFailed("RGBA/HALF_FLOAT_OES is color renderable but " + renderableExtName + " not exposed");
} else if (supported && !renderable) {
testFailed(renderableExtName + " is exposed but RGBA/HALF_FLOAT_OES is not color renderable");
}
if (supported) {
runRenderTest(gl.RGBA, [10000, 10000, 10000, 10000], null, true);
runRenderTest(gl.RGB, [10000, 10000, 10000, 1], null, false);
runFramebufferTest();
}
})();
// Check of getExtension() returns same object
runUniqueObjectTest();
}
}
function isRenderable(gl, ext) {
var tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, ext.HALF_FLOAT_OES, null);
var fb = gl.createFramebuffer();
gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0);
var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
gl.deleteFramebuffer(fb);
gl.deleteTexture(tex);
return status == gl.FRAMEBUFFER_COMPLETE;
}
function getNumberOfChannels(format)
{
if (format == gl.RGBA)
@ -278,7 +306,7 @@ function checkRenderingResults()
wtu.checkCanvas(gl, [0, 255, 0, 255], "should be green");
}
function runRenderTest(format, subtractor, data)
function runRenderTest(format, subtractor, data, requireRenderable)
{
var formatString = wtu.glEnumToString(gl, format);
@ -307,7 +335,11 @@ function runRenderTest(format, subtractor, data)
// It is legal for a WebGL implementation exposing the OES_texture_half_float extension to
// support half floating point textures but not as attachments to framebuffer objects.
if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) != gl.FRAMEBUFFER_COMPLETE) {
debug("Half floating point render targets not supported -- this is legal");
if (requireRenderable) {
testFailed(formatString + " render targets not supported.");
} else {
debug(formatString + " render targets not supported -- this is legal");
}
return;
}
@ -397,16 +429,12 @@ function runFramebufferTest() {
var texture = allocateTexture();
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, ext.HALF_FLOAT_OES, null);
var fbo = gl.createFramebuffer();
gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) != gl.FRAMEBUFFER_COMPLETE) {
debug("Half floating point render targets not supported -- this is legal");
return;
}
debug("Ensure non-color-renderable formats [LUMINANCE, LUMINANCE_ALPHA, ALPHA] fail");
debug("Ensure non-color-renderable formats [LUMINANCE, LUMINANCE_ALPHA, ALPHA] fail.");
var arrayBufferFloatOutput = new Float32Array(4); // 4 color channels
[gl.LUMINANCE, gl.LUMINANCE_ALPHA, gl.ALPHA].forEach(function(badFormat) {
debug(getFormatName(badFormat) + " framebuffer");
@ -437,51 +465,49 @@ function runFramebufferTest() {
debug("");
gl.texImage2D(gl.TEXTURE_2D, 0, goodFormat, 1, 1, 0, goodFormat, ext.HALF_FLOAT_OES, arrayBufferHalfFloatInput);
shouldBe("gl.checkFramebufferStatus(gl.FRAMEBUFFER)", "gl.FRAMEBUFFER_COMPLETE");
// To avoid GPU idiosyncrasies, dispense with clearing or rendering to the texture. Go straight to readPixels.
// Per the OES_color_buffer_half_float, RGBA/FLOAT should always succeed for readPixels
verifyReadPixelsColors(
0.00, // red
0.25, // green
0.50, // blue
0.75, // alpha
1.0, // alphaRGB
goodFormat,
gl.FLOAT,
Float32Array);
var implementationColorReadFormat = gl.getParameter(gl.IMPLEMENTATION_COLOR_READ_FORMAT);
assertMsg(implementationColorReadFormat === gl.RGBA || implementationColorReadFormat === gl.RGB,
"IMPLEMENTATION_COLOR_READ_FORMAT should be color renderable: RGBA or RGB. Received: " + getFormatName(implementationColorReadFormat));
var implementationColorReadType = gl.getParameter(gl.IMPLEMENTATION_COLOR_READ_TYPE);
// There is nothing in the specifications that keeps the
// implementation color read format and type from being the
// same as the implicitly supported one. For this reason, keep
// gl.FLOAT as one of the valid options.
assertMsg(implementationColorReadType === gl.UNSIGNED_BYTE ||
implementationColorReadType === gl.FLOAT ||
implementationColorReadType === ext.HALF_FLOAT_OES ||
implementationColorReadType === gl.UNSIGNED_SHORT_4_4_4_4 ||
implementationColorReadType === gl.UNSIGNED_SHORT_5_5_5_1 ||
implementationColorReadType === gl.UNSIGNED_SHORT_5_6_5,
"IMPLEMENTATION_COLOR_READ_TYPE must be one of UNSIGNED_BYTE, UNSIGNED_SHORT_4_4_4_4, UNSIGNED_SHORT_5_5_5_1, UNSIGNED_SHORT_5_6_5, FLOAT, or HALF_FLOAT_OES. " +
"Received: " + getTypeName(implementationColorReadType));
// Test the RGBA/HALF_FLOAT_OES combination
if (implementationColorReadFormat === gl.RGBA && implementationColorReadType === ext.HALF_FLOAT_OES) {
if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) == gl.FRAMEBUFFER_COMPLETE) {
// Per the OES_color_buffer_half_float, RGBA/FLOAT should always succeed for readPixels
verifyReadPixelsColors(
0, // red
0x3400, // green
0x3800, // blue
0x3A00, // alpha
0x3C00, // alphaRGB
0.00, // red
0.25, // green
0.50, // blue
0.75, // alpha
1.0, // alphaRGB
goodFormat,
ext.HALF_FLOAT_OES,
Uint16Array);
gl.FLOAT,
Float32Array);
var implementationColorReadFormat = gl.getParameter(gl.IMPLEMENTATION_COLOR_READ_FORMAT);
assertMsg(implementationColorReadFormat === gl.RGBA || implementationColorReadFormat === gl.RGB,
"IMPLEMENTATION_COLOR_READ_FORMAT should be color renderable: RGBA or RGB. Received: " + getFormatName(implementationColorReadFormat));
var implementationColorReadType = gl.getParameter(gl.IMPLEMENTATION_COLOR_READ_TYPE);
// There is nothing in the specifications that keeps the
// implementation color read format and type from being the
// same as the implicitly supported one. For this reason, keep
// gl.FLOAT as one of the valid options.
assertMsg(implementationColorReadType === gl.UNSIGNED_BYTE ||
implementationColorReadType === gl.FLOAT ||
implementationColorReadType === ext.HALF_FLOAT_OES ||
implementationColorReadType === gl.UNSIGNED_SHORT_4_4_4_4 ||
implementationColorReadType === gl.UNSIGNED_SHORT_5_5_5_1 ||
implementationColorReadType === gl.UNSIGNED_SHORT_5_6_5,
"IMPLEMENTATION_COLOR_READ_TYPE must be one of UNSIGNED_BYTE, UNSIGNED_SHORT_4_4_4_4, UNSIGNED_SHORT_5_5_5_1, UNSIGNED_SHORT_5_6_5, FLOAT, or HALF_FLOAT_OES. " +
"Received: " + getTypeName(implementationColorReadType));
// Test the RGBA/HALF_FLOAT_OES combination
if (implementationColorReadFormat === gl.RGBA && implementationColorReadType === ext.HALF_FLOAT_OES) {
verifyReadPixelsColors(
0, // red
0x3400, // green
0x3800, // blue
0x3A00, // alpha
0x3C00, // alphaRGB
goodFormat,
ext.HALF_FLOAT_OES,
Uint16Array);
}
}
debug("");
});

Просмотреть файл

@ -1,4 +1,4 @@
<!--
<!--
/*
** Copyright (c) 2014 The Khronos Group Inc.

Просмотреть файл

@ -1,4 +1,4 @@
<!--
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
@ -624,25 +624,33 @@ function runBoundDeleteTests() {
gl.deleteBuffer(colorBuffer);
gl.deleteBuffer(positionBuffer);
// The buffers should not be accessible at this point. Deleted objects that are bound
// in the current context undergo an automatic unbinding
// After the first iteration, deleteBuffer will be a no-op, and will not unbind its matching
// bind points on the now-bound VAO like it did on the first iteration.
var expectRetained = (ii != 0);
var shouldBeStr = (expectRetained ? "retained" : "cleared");
var boundPositionBuffer = gl.getVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING);
if(boundPositionBuffer == positionBuffer) {
testFailed("Position buffer should be automatically unbound when deleted");
if (expectRetained != (boundPositionBuffer == positionBuffer)) {
testFailed("Position attrib stored buffer should be " + shouldBeStr + ".");
}
var boundColorBuffer = gl.getVertexAttrib(1, gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING);
if(boundColorBuffer == colorBuffer) {
testFailed("Color buffer should be automatically unbound when deleted");
if (expectRetained != (boundColorBuffer == colorBuffer)) {
testFailed("Color attrib stored buffer should be " + shouldBeStr + ".");
}
// If retained, everything should still work. If cleared, drawing should now fail.
gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_BYTE, 0);
wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "Draw call should fail with unbound position and color buffers");
var expectedError = (expectRetained ? gl.NO_ERROR : gl.INVALID_OPERATION);
wtu.glErrorShouldBe(gl, expectedError,
"Draw call should " + (expectRetained ? "not " : "") + "fail.");
var isPositionBuffer = gl.isBuffer(positionBuffer);
var isColorBuffer = gl.isBuffer(colorBuffer);
if(isPositionBuffer) testFailed("Position buffer should no longer exist after last ref removed");
if(isColorBuffer) testFailed("Color buffer should no longer exist after last ref removed");
if (!gl.isBuffer(positionBuffer)) {
testFailed("References from unbound VAOs keep Position buffer alive.");
}
if (!gl.isBuffer(colorBuffer)) {
testFailed("References from unbound VAOs keep Color buffer alive");
}
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,4 +1,4 @@
<!--
<!--
/*
** Copyright (c) 2013 The Khronos Group Inc.
@ -204,12 +204,8 @@ function runTestExtension() {
}
supportedFormats = gl.getParameter(gl.COMPRESSED_TEXTURE_FORMATS);
// There should be exactly 3 formats for WebGL 1.0 and 13 formats for WebGL 2.0.
if (contextVersion < 2) {
shouldBe("supportedFormats.length", "3");
} else {
shouldBe("supportedFormats.length", "13");
}
// There should be exactly 3 formats for both WebGL 1.0 and WebGL 2.0.
shouldBe("supportedFormats.length", "3");
// check that all 3 formats exist
for (var name in validFormats.length) {

Просмотреть файл

@ -61,7 +61,8 @@ var COMPRESSED_RGBA8_ETC2_EAC = 0x9278;
var COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = 0x9279;
var wtu = WebGLTestUtils;
var gl = wtu.create3DContext(undefined, undefined);
var contextVersion = wtu.getDefault3DContextVersion();
var gl = wtu.create3DContext();
var WEBGL_compressed_texture_etc;
var formats = null;
@ -89,7 +90,7 @@ function runTest() {
}
} else {
if (WEBGL_compressed_texture_etc !== null) {
testFailed("WEBGL_compressed_texture_etc listed as supported but getExtension failed");
testFailed("WEBGL_compressed_texture_etc listed as unsupported but getExtension succeeded");
return;
} else {
testPassed("No WEBGL_compressed_texture_etc support -- this is legal");
@ -138,10 +139,19 @@ function runTest() {
shouldBe("formats.length", isPositive ? "10" : "0");
debug("");
shouldThrow("gl.compressedTexImage2D(gl.TEXTURE_2D, 0, COMPRESSED_R11_EAC, 4, 4, 0, null)");
shouldThrow("gl.compressedTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, COMPRESSED_R11_EAC, null)");
shouldThrow("gl.compressedTexImage3D(gl.TEXTURE_2D_ARRAY, 0, COMPRESSED_R11_EAC, 4, 4, 4, 0, null)");
shouldThrow("gl.compressedTexSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, 0, 0, COMPRESSED_R11_EAC, null)");
if (contextVersion >= 2) {
var expectedError = isPositive ? gl.INVALID_OPERATION: [gl.INVALID_ENUM, gl.INVALID_OPERATION];
// `null` coerces into `0` for the PBO entrypoint, yielding INVALID_OP due to no PBO bound.
wtu.shouldGenerateGLError(gl, expectedError, "gl.compressedTexImage2D(gl.TEXTURE_2D, 0, COMPRESSED_R11_EAC, 4, 4, 0, 0, null)");
wtu.shouldGenerateGLError(gl, expectedError, "gl.compressedTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, COMPRESSED_R11_EAC, 0, null)");
wtu.shouldGenerateGLError(gl, expectedError, "gl.compressedTexImage3D(gl.TEXTURE_2D_ARRAY, 0, COMPRESSED_R11_EAC, 4, 4, 4, 0, 0, null)");
wtu.shouldGenerateGLError(gl, expectedError, "gl.compressedTexSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, 0, 0, COMPRESSED_R11_EAC, 0, null)");
} else {
shouldThrow("gl.compressedTexImage2D(gl.TEXTURE_2D, 0, COMPRESSED_R11_EAC, 4, 4, 0, null)");
shouldThrow("gl.compressedTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, COMPRESSED_R11_EAC, null)");
shouldThrow("gl.compressedTexImage3D(gl.TEXTURE_2D_ARRAY, 0, COMPRESSED_R11_EAC, 4, 4, 4, 0, null)");
shouldThrow("gl.compressedTexSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, 0, 0, COMPRESSED_R11_EAC, null)");
}
}
}

Просмотреть файл

@ -1,4 +1,4 @@
<!--
<!--
/*
** Copyright (c) 2013 The Khronos Group Inc.

Просмотреть файл

@ -1,4 +1,4 @@
<!--
<!--
/*
** Copyright (c) 2012-2016 The Khronos Group Inc.

Просмотреть файл

@ -1,4 +1,4 @@
<!--
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.

Просмотреть файл

@ -33,6 +33,7 @@
<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>
<script src="../../js/tests/webgl-compressed-texture-size-limit.js"></script>
</head>
<body>
<canvas id="example" width="32" height="32" style="width: 40px; height: 40px;"></canvas>
@ -42,202 +43,11 @@
"use strict";
enableJSTestPreVerboseLogging();
description("Checks size limit of the webgl compressed textures")
var canvas;
function numLevelsFromSize(size) {
var levels = 0;
while ((size >> levels) > 0) {
++levels;
}
return levels;
}
// More formats can be added here when more texture compression extensions are enabled in WebGL.
var validFormats = {
COMPRESSED_RGB_S3TC_DXT1_EXT : 0x83F0,
COMPRESSED_RGBA_S3TC_DXT1_EXT : 0x83F1,
COMPRESSED_RGBA_S3TC_DXT3_EXT : 0x83F2,
COMPRESSED_RGBA_S3TC_DXT5_EXT : 0x83F3,
};
// format specific restrictions for COMPRESSED_RGB_S3TC_DXT1_EXT and COMPRESSED_RGBA_S3TC_DXT1_EXT
// on the byteLength of the ArrayBufferView, pixels
function func1 (width, height)
{
return Math.floor((width + 3) / 4) * Math.floor((height + 3) / 4) * 8;
}
// format specific restrictions for COMPRESSED_RGBA_S3TC_DXT3_EXT and COMPRESSED_RGBA_S3TC_DXT5_EXT
// on the byteLength of the ArrayBufferView, pixels
function func2 (width, height)
{
return Math.floor((width + 3) / 4) * Math.floor((height + 3) / 4) * 16;
}
var wtu = WebGLTestUtils;
var gl = wtu.create3DContext("example");
var tests = [
// More tests can be added here when more texture compression extensions are enabled in WebGL.
// Level 0 image width and height must be a multiple of the sizeStep.
{ extension: "WEBGL_compressed_texture_s3tc", format: validFormats.COMPRESSED_RGB_S3TC_DXT1_EXT, dataType: Uint8Array, func: func1, sizeStep: 4},
{ extension: "WEBGL_compressed_texture_s3tc", format: validFormats.COMPRESSED_RGBA_S3TC_DXT1_EXT, dataType: Uint8Array, func: func1, sizeStep: 4},
{ extension: "WEBGL_compressed_texture_s3tc", format: validFormats.COMPRESSED_RGBA_S3TC_DXT3_EXT, dataType: Uint8Array, func: func2, sizeStep: 4},
{ extension: "WEBGL_compressed_texture_s3tc", format: validFormats.COMPRESSED_RGBA_S3TC_DXT5_EXT, dataType: Uint8Array, func: func2, sizeStep: 4},
];
// 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),
tex: gl.createTexture(),
targets: [gl.TEXTURE_2D]
},
{ target: gl.TEXTURE_CUBE_MAP,
maxSize: gl.getParameter(gl.MAX_CUBE_MAP_TEXTURE_SIZE),
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
]
}
];
function getSharedArrayBufferSize() {
var sharedArrayBufferSize = 0;
for (var tt = 0; tt < tests.length; ++tt) {
var test = tests[tt];
for (var trg = 0; trg < targets.length; ++trg) {
var t = targets[trg];
var bufferSizeNeeded;
if (t.target === gl.TEXTURE_CUBE_MAP) {
var positiveTestSize = Math.min(2048, t.maxSize);
bufferSizeNeeded = test.func(positiveTestSize, positiveTestSize);
} else {
bufferSizeNeeded = test.func(t.maxSize, test.sizeStep);
}
if (bufferSizeNeeded > sharedArrayBufferSize) {
sharedArrayBufferSize = bufferSizeNeeded;
}
bufferSizeNeeded = test.func(t.maxSize + test.sizeStep, t.maxSize + test.sizeStep);
// ArrayBuffers can be at most 4GB (minus 1 byte)
if (bufferSizeNeeded > sharedArrayBufferSize && bufferSizeNeeded <= 4294967295) {
sharedArrayBufferSize = bufferSizeNeeded;
}
}
}
return sharedArrayBufferSize;
}
// Share an ArrayBuffer among tests to avoid too many large allocations
var sharedArrayBuffer = new ArrayBuffer(getSharedArrayBufferSize());
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 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) {
var positiveTestSize = t.maxSize;
var positiveTestOtherDimension = test.sizeStep;
if (t.target === gl.TEXTURE_CUBE_MAP) {
// Can't always test the maximum size since that can cause OOM:
positiveTestSize = Math.min(2048, t.maxSize);
// Cube map textures need to be square:
positiveTestOtherDimension = positiveTestSize;
}
var positiveTestLevels = numLevelsFromSize(positiveTestSize);
var numLevels = numLevelsFromSize(t.maxSize);
debug("");
debug("num levels: " + numLevels + ", levels used in positive test: " + positiveTestLevels);
debug("");
// Query the extension and store globally so shouldBe can access it
var ext = wtu.getExtensionWithKnownPrefixes(gl, test.extension);
if (ext) {
testPassed("Successfully enabled " + test.extension + " extension");
for (var j = 0; j < t.targets.length; ++j) {
var target = t.targets[j];
debug("");
debug(wtu.glEnumToString(gl, target));
// positive test
var size = positiveTestSize;
var otherDimension = positiveTestOtherDimension;
for (var i = 0; i < positiveTestLevels; i++) {
var pixels = new test.dataType(sharedArrayBuffer, 0, test.func(size, otherDimension));
gl.compressedTexImage2D(target, i, test.format, size, otherDimension, 0, pixels);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "uploading compressed texture should generate NO_ERROR."
+ "level is " + i + ", size is " + size + "x" + otherDimension);
size /= 2;
otherDimension /= 2;
if (otherDimension < 1) {
otherDimension = 1;
}
}
var numLevels = numLevelsFromSize(t.maxSize);
// out of bounds tests
// width and height out of bounds
var dataSize = test.func(t.maxSize + test.sizeStep, t.maxSize + test.sizeStep);
// this check assumes that each element is 1 byte
if (dataSize > sharedArrayBuffer.byteLength) {
testPassed("Unable to test texture larger than maximum size due to ArrayBuffer size limitations -- this is legal");
} else {
var pixelsNegativeTest1 = new test.dataType(sharedArrayBuffer, 0, dataSize);
gl.compressedTexImage2D(target, 0, test.format, t.maxSize + test.sizeStep, t.maxSize + test.sizeStep, 0, pixelsNegativeTest1);
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "width or height out of bounds: should generate INVALID_VALUE."
+ " level is 0, size is " + (t.maxSize + test.sizeStep) + "x" + (t.maxSize + test.sizeStep));
}
// level out of bounds
var pixelsNegativeTest2 = new test.dataType(sharedArrayBuffer, 0, test.func(256, 256));
gl.compressedTexImage2D(target, numLevels, test.format, 256, 256, 0, pixelsNegativeTest2);
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "level out of bounds: should generate INVALID_VALUE."
+ " level is " + numLevels + ", size is 256x256");
//width and height out of bounds for specified level
gl.compressedTexImage2D(target, numLevels - 1, test.format, 256, 256, 0, pixelsNegativeTest2);
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 256x256");
}
}
else
testPassed("No " + test.extension + " extension support -- this is legal");
}
// ArrayBuffers can be at most 4GB (minus 1 byte), but any allocations larger than 1 GB are unreliable in practice. So limit allocations to 1 GB.
// Textures that are wide in just one dimension can still be used to test max TEXTURE_2D size limit even if we can't allocate space for huge square textures.
// Use a fairly conservative limit for positive test cube map size so OOM is avoided.
runCompressedTextureSizeLimitTest(Math.pow(2, 30), 2048);
var successfullyParsed = true;
</script>

Просмотреть файл

@ -1,4 +1,4 @@
<!--
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.

Просмотреть файл

@ -1,4 +1,4 @@
<!--
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.

Просмотреть файл

@ -89,7 +89,8 @@ if (!gl) {
testPassed("Successfully enabled WEBGL_depth_texture extension");
runSupportedTest(true);
runTestExtension();
runTestExtension(true);
runTestExtension(false);
}
}
@ -138,8 +139,8 @@ function dumpIt(gl, res, msg) {
debug(strs.join(" "));
}
}
function runTestExtension() {
debug("Testing WEBGL_depth_texture");
function runTestExtension(unpackFlipY) {
debug("Testing WEBGL_depth_texture. UNPACK_FLIP_Y_WEBGL: " + unpackFlipY);
var res = 8;
@ -171,6 +172,8 @@ function runTestExtension() {
gl.enableVertexAttribArray(0);
gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, unpackFlipY);
var types = [
{obj: 'gl', attachment: 'DEPTH_ATTACHMENT', format: 'DEPTH_COMPONENT', type: 'UNSIGNED_SHORT', data: 'new Uint16Array(1)', depthBits: "16"},
{obj: 'gl', attachment: 'DEPTH_ATTACHMENT', format: 'DEPTH_COMPONENT', type: 'UNSIGNED_INT', data: 'new Uint32Array(1)', depthBits: "16"},
@ -197,7 +200,7 @@ function runTestExtension() {
'TEXTURE_CUBE_MAP_NEGATIVE_Z'
];
for (var tt = 0; tt < targets.length; ++tt) {
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, 'gl.texImage2D(gl.' + targets[ii] + ', 1, gl.' + typeInfo.format + ', 1, 1, 0, gl.' + typeInfo.format + ', ' + typeStr + ', null)');
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, 'gl.texImage2D(gl.' + targets[ii] + ', 0, gl.' + typeInfo.format + ', 1, 1, 0, gl.' + typeInfo.format + ', ' + typeStr + ', null)');
}
// The WebGL_depth_texture extension supports both NEAREST and

Просмотреть файл

@ -0,0 +1,159 @@
<!--
/*
** Copyright (c) 2017 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 WEBGL_draw_buffers Conformance Tests</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>
<script src="../../js/tests/webgl-draw-buffers-utils.js"></script>
</head>
<body>
<div id="description"></div>
<canvas id="canvas" width="64" height="64"> </canvas>
<div id="console"></div>
<script id="fshaderRedWithReturn" type="x-shader/x-fragment">
#extension GL_EXT_draw_buffers : require
precision mediump float;
uniform float u_zero;
void main() {
gl_FragColor = vec4(1,0,0,1);
if (u_zero < 1.0) {
return;
}
gl_FragColor = vec4(0,0,1,1);
}
</script>
<script id="fshaderWithDiscard" type="x-shader/x-fragment">
#extension GL_EXT_draw_buffers : require
precision mediump float;
uniform float u_zero;
void main() {
gl_FragColor = vec4(1,0,0,1);
if (u_zero < 1.0) {
discard;
}
gl_FragColor = vec4(0,0,1,1);
}
</script>
<script>
"use strict";
description("This test verifies gl_FragColor being broadcasted when using WEBGL_draw_buffers extension, if it is available.");
debug("");
var wtu = WebGLTestUtils;
var canvas = document.getElementById("canvas");
var gl = wtu.create3DContext(canvas);
var ext = null;
var drawBuffersUtils;
if (!gl) {
testFailed("WebGL context does not exist");
} else {
testPassed("WebGL context exists");
// Query the extension and store globally so shouldBe can access it
ext = gl.getExtension("WEBGL_draw_buffers");
if (!ext) {
testPassed("No WEBGL_draw_buffers support -- this is legal");
} else {
testPassed("Successfully enabled WEBGL_draw_buffers extension");
drawBuffersUtils = WebGLDrawBuffersUtils(gl, ext);
runDrawTests();
}
}
function runDrawTests() {
debug("");
var fb = gl.createFramebuffer();
var maxUsable = drawBuffersUtils.getMaxUsableColorAttachments();
var bufs = drawBuffersUtils.makeColorAttachmentArray(maxUsable);
var width = 64;
var height = 64;
var attachments = [];
for (var ii = 0; ii < maxUsable; ++ii) {
var tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 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);
gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + ii, gl.TEXTURE_2D, tex, 0);
attachments.push({
texture: tex
});
}
debug("test that gl_FragColor broadcasts if extension is enabled in fragment shader and fragment shader main returns in the middle");
gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
ext.drawBuffersWEBGL(bufs);
var redProgramWithReturn = wtu.setupProgram(gl, [wtu.simpleVertexShader, "fshaderRedWithReturn"], ["vPosition"], undefined, true);
shouldBe("gl.checkFramebufferStatus(gl.FRAMEBUFFER)", "gl.FRAMEBUFFER_COMPLETE");
gl.clearColor(0, 0, 0, 0);
gl.clear(gl.COLOR_BUFFER_BIT);
gl.useProgram(redProgramWithReturn);
wtu.drawUnitQuad(gl);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after draw");
drawBuffersUtils.checkAttachmentsForColor(attachments, [255, 0, 0, 255]);
debug("test that none of the attachments are written in case the fragment shader discards");
gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
ext.drawBuffersWEBGL(bufs);
var programWithDiscard = wtu.setupProgram(gl, [wtu.simpleVertexShader, "fshaderWithDiscard"], ["vPosition"], undefined, true);
gl.clearColor(0, 0, 0, 0);
gl.clear(gl.COLOR_BUFFER_BIT);
gl.useProgram(programWithDiscard);
wtu.drawUnitQuad(gl);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after draw");
drawBuffersUtils.checkAttachmentsForColor(attachments, [0, 0, 0, 0]);
gl.bindTexture(gl.TEXTURE_2D, null);
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
gl.deleteFramebuffer(fb);
attachments.forEach(function(attachment) {
gl.deleteTexture(attachment.texture);
});
gl.deleteProgram(redProgramWithReturn);
gl.deleteProgram(programWithDiscard);
}
var successfullyParsed = true;
</script>
<script src="../../js/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,161 @@
<!--
/*
** 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>WebGL Rendering and Sampling Feedback Loop Tests For WEBGL_draw_buffers Extension</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../js/js-test-pre.js"></script>
<script src="../../js/webgl-test-utils.js"></script>
</head>
<body>
<canvas id="example" width="8" height="8"></canvas>
<div id="description"></div>
<div id="console"></div>
<script id="vshader" type="x-shader/x-vertex">
attribute vec4 aPosition;
attribute vec2 aTexCoord;
varying vec2 texCoord;
void main() {
gl_Position = aPosition;
texCoord = aTexCoord;
}
</script>
<script id="fshader" type="x-shader/x-fragment">
#extension GL_EXT_draw_buffers : require
precision mediump float;
uniform sampler2D tex;
varying vec2 texCoord;
void main() {
gl_FragData[0] = texture2D(tex, texCoord);
gl_FragData[1] = texture2D(tex, texCoord);
}
</script>
<script>
"use strict";
var wtu = WebGLTestUtils;
var canvas = document.getElementById("example");
description("This test verifies the functionality of rendering to the same texture where it samples from.");
var gl = wtu.create3DContext(canvas);
var width = 8;
var height = 8;
var tex0;
var tex1;
var fbo;
var ext;
var program;
var positionLoc;
var texCoordLoc;
if (!gl) {
testFailed("WebGL context does not exist");
} else {
testPassed("WebGL context exists");
ext = gl.getExtension("WEBGL_draw_buffers");
if (!ext) {
testPassed("No WEBGL_draw_buffers support -- this is legal");
finishTest();
} else {
testPassed("Successfully enabled WEBGL_draw_buffers extension");
init();
// The sampling texture is bound to COLOR_ATTACHMENT1 during resource allocation
allocate_resource();
rendering_sampling_feedback_loop([gl.NONE, ext.COLOR_ATTACHMENT1_WEBGL], gl.INVALID_OPERATION);
rendering_sampling_feedback_loop([gl.COLOR_ATTACHMENT0, ext.COLOR_ATTACHMENT1_WEBGL], gl.INVALID_OPERATION);
rendering_sampling_feedback_loop([gl.COLOR_ATTACHMENT0, gl.NONE], gl.NO_ERROR);
}
}
function init() {
program = wtu.setupProgram(gl, ['vshader', 'fshader'], ['aPosition', 'aTexCoord'], [0, 1]);
positionLoc = gl.getAttribLocation(program, "aPosition");
texCoordLoc = gl.getAttribLocation(program, "aTexCoord");
if (!program || positionLoc < 0 || texCoordLoc < 0) {
testFailed("Set up program failed");
return;
}
testPassed("Set up program succeeded");
wtu.setupUnitQuad(gl, 0, 1);
gl.viewport(0, 0, width, height);
}
function allocate_resource() {
tex0 = gl.createTexture();
tex1 = gl.createTexture();
fbo = gl.createFramebuffer();
wtu.fillTexture(gl, tex0, width, height, [0xff, 0x0, 0x0, 0xff], 0, gl.RGBA, gl.UNSIGNED_BYTE, gl.RGBA);
wtu.fillTexture(gl, tex1, width, height, [0x0, 0xff, 0x0, 0xff], 0, gl.RGBA, gl.UNSIGNED_BYTE, gl.RGBA);
gl.bindTexture(gl.TEXTURE_2D, tex1);
var texLoc = gl.getUniformLocation(program, "tex");
gl.uniform1i(texLoc, 0);
gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex0, 0);
gl.framebufferTexture2D(gl.FRAMEBUFFER, ext.COLOR_ATTACHMENT1_WEBGL, gl.TEXTURE_2D, tex1, 0);
}
function rendering_sampling_feedback_loop(draw_buffers, error) {
// gl.drawBuffers(draw_buffers);
ext.drawBuffersWEBGL(draw_buffers);
// Make sure framebuffer is complete before feedback loop detection
if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) != gl.FRAMEBUFFER_COMPLETE) {
testFailed("Framebuffer incomplete.");
return;
}
wtu.clearAndDrawUnitQuad(gl);
wtu.glErrorShouldBe(gl, error, "Rendering to a texture where it samples from should geneates INVALID_OPERATION. Otherwise, it should be NO_ERROR");
}
gl.bindTexture(gl.TEXTURE_2D, null);
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
gl.deleteTexture(tex0);
gl.deleteTexture(tex1);
gl.deleteFramebuffer(fbo);
var successfullyParsed = true;
</script>
<script src="../../js/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -1,4 +1,4 @@
<!--
<!--
/*
** Copyright (c) 2015 The Khronos Group Inc.

Просмотреть файл

@ -1,4 +1,4 @@
<!--
<!--
/*
** Copyright (c) 2013 The Khronos Group Inc.
@ -33,17 +33,12 @@
<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>
<script src="../../js/tests/webgl-draw-buffers-utils.js"></script>
</head>
<body>
<div id="description"></div>
<canvas id="canvas" width="64" height="64"> </canvas>
<div id="console"></div>
<script id="vshader" type="x-shader/x-vertex">
attribute vec4 a_position;
void main() {
gl_Position = a_position;
}
</script>
<script id="fshader" type="x-shader/x-fragment">
#extension GL_EXT_draw_buffers : require
precision mediump float;
@ -111,10 +106,10 @@ debug("");
var wtu = WebGLTestUtils;
var canvas = document.getElementById("canvas");
var output = document.getElementById("console");
var gl = wtu.create3DContext(canvas);
var ext = null;
var programWithMaxDrawBuffersEqualOne = null;
var drawBuffersUtils;
var extensionConstants = [
{ name: "MAX_COLOR_ATTACHMENTS_WEBGL", enum: 0x8CDF, expectedFn: function(v) { return v >= 4; }, passMsg: " should be >= 4"},
@ -177,6 +172,7 @@ if (!gl) {
} else {
testPassed("Successfully enabled WEBGL_draw_buffers extension");
drawBuffersUtils = WebGLDrawBuffersUtils(gl, ext);
runSupportedTest(true);
runEnumTestEnabled();
runShadersTestEnabled();
@ -189,7 +185,7 @@ if (!gl) {
function createExtDrawBuffersProgram(scriptId, sub) {
var fsource = wtu.getScript(scriptId);
fsource = wtu.replaceParams(fsource, sub);
return wtu.setupProgram(gl, ["vshader", fsource], ["a_position"], undefined, true);
return wtu.setupProgram(gl, [wtu.simpleVertexShader, fsource], ["vPosition"], undefined, true);
}
function runSupportedTest(extensionEnabled) {
@ -254,8 +250,8 @@ function runEnumTestEnabled() {
function testShaders(tests, sub) {
tests.forEach(function(test) {
var shaders = [wtu.getScript(test.shaders[0]), wtu.replaceParams(wtu.getScript(test.shaders[1]), sub)];
var program = wtu.setupProgram(gl, shaders, ["a_position"], undefined, true);
var shaders = [wtu.simpleVertexShader, wtu.replaceParams(wtu.getScript(test.fragmentShaderTemplate), sub)];
var program = wtu.setupProgram(gl, shaders, ["vPosition"], undefined, true);
var programLinkedSuccessfully = (program != null);
var expectedProgramToLinkSuccessfully = (test.expectFailure == true);
expectTrue(programLinkedSuccessfully != expectedProgramToLinkSuccessfully, test.msg);
@ -269,10 +265,10 @@ function runShadersTestDisabled() {
var sub = {numDrawingBuffers: 1};
testShaders([
{ shaders: ["vshader", "fshaderMacroDisabled"],
{ fragmentShaderTemplate: "fshaderMacroDisabled",
msg: "GL_EXT_draw_buffers should not be defined in GLSL",
},
{ shaders: ["vshader", "fshader"],
{ fragmentShaderTemplate: "fshader",
msg: "#extension GL_EXT_draw_buffers should not be allowed in GLSL",
expectFailure: true,
},
@ -291,11 +287,11 @@ function runShadersTestEnabled() {
var sub = {numDrawingBuffers: gl.getParameter(ext.MAX_DRAW_BUFFERS_WEBGL)};
testShaders([
{ shaders: ["vshader", "fshaderMacroEnabled"],
msg: "GL_EXT_draw_buffers should be defined as 1 in GLSL",
{ fragmentShaderTemplate: "fshaderMacroEnabled",
msg: "GL_EXT_draw_buffers should be defined as 1 in GLSL",
},
{ shaders: ["vshader", "fshader"],
msg: "fragment shader containing the #extension directive should compile",
{ fragmentShaderTemplate: "fshader",
msg: "fragment shader containing the #extension directive should compile",
},
], sub);
@ -337,14 +333,6 @@ function makeArray(size, value) {
return array;
}
function makeColorAttachmentArray(size) {
var array = []
for (var ii = 0; ii < size; ++ii) {
array.push(gl.COLOR_ATTACHMENT0 + ii);
}
return array;
}
function runAttachmentTestEnabled() {
debug("");
debug("test attachment enabled");
@ -362,7 +350,7 @@ function runAttachmentTestEnabled() {
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be able to attach to the max attachment point: gl.COLOR_ATTACHMENT0 + " + (maxColorAttachments - 1));
ext.drawBuffersWEBGL(makeArray(maxDrawingBuffers, gl.NONE));
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be able to call drawBuffersWEBGL with array NONE of size " + maxColorAttachments);
var bufs = makeColorAttachmentArray(maxDrawingBuffers);
var bufs = drawBuffersUtils.makeColorAttachmentArray(maxDrawingBuffers);
ext.drawBuffersWEBGL(bufs);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be able to call drawBuffersWEBGL with array attachments of size " + maxColorAttachments);
bufs[0] = gl.NONE;
@ -373,7 +361,7 @@ function runAttachmentTestEnabled() {
bufs[1] = ext.COLOR_ATTACHMENT0_WEBGL;
ext.drawBuffersWEBGL(bufs);
wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "should not be able to call drawBuffersWEBGL with out of order attachments of size " + maxColorAttachments);
var bufs = makeColorAttachmentArray(Math.floor(maxDrawingBuffers / 2));
var bufs = drawBuffersUtils.makeColorAttachmentArray(Math.floor(maxDrawingBuffers / 2));
ext.drawBuffersWEBGL(bufs);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be able to call drawBuffersWEBGL with short array of attachments of size " + bufs.length);
}
@ -417,11 +405,9 @@ function runDrawTests() {
var middleFB = gl.createFramebuffer();
var maxDrawingBuffers = gl.getParameter(ext.MAX_DRAW_BUFFERS_WEBGL);
var maxColorAttachments = gl.getParameter(ext.MAX_COLOR_ATTACHMENTS_WEBGL);
var maxUniformVectors = gl.getParameter(gl.MAX_FRAGMENT_UNIFORM_VECTORS);
var maxUsable = Math.min(maxDrawingBuffers, maxColorAttachments, maxUniformVectors);
var maxUsable = drawBuffersUtils.getMaxUsableColorAttachments();
var half = Math.floor(maxUsable / 2);
var bufs = makeColorAttachmentArray(maxUsable);
var bufs = drawBuffersUtils.makeColorAttachmentArray(maxUsable);
var nones = makeArray(maxUsable, gl.NONE);
[fb, fb2, halfFB1, halfFB2, endsFB, middleFB].forEach(function(fbo) {
@ -430,8 +416,8 @@ function runDrawTests() {
});
var checkProgram = wtu.setupTexturedQuad(gl);
var redProgram = wtu.setupProgram(gl, ["vshader", "fshaderRed"], ["a_position"]);
var redProgramWithExtension = wtu.setupProgram(gl, ["vshader", "fshaderRedWithExtension"], ["a_position"]);
var redProgram = wtu.setupProgram(gl, [wtu.simpleVertexShader, "fshaderRed"], ["vPosition"]);
var redProgramWithExtension = wtu.setupProgram(gl, [wtu.simpleVertexShader, "fshaderRedWithExtension"], ["vPosition"]);
var drawProgram = createExtDrawBuffersProgram("fshader", {numDrawingBuffers: maxDrawingBuffers});
var width = 64;
var height = 64;
@ -464,7 +450,6 @@ function runDrawTests() {
gl.uniform4fv(location, floatColor);
attachments.push({
texture: tex,
location: location,
color: color
});
}
@ -473,30 +458,6 @@ function runDrawTests() {
gl.bindFramebuffer(gl.FRAMEBUFFER, fb2);
shouldBe("gl.checkFramebufferStatus(gl.FRAMEBUFFER)", "gl.FRAMEBUFFER_COMPLETE");
var checkAttachmentsForColorFn = function(attachments, colorFn) {
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
gl.useProgram(checkProgram);
attachments.forEach(function(attachment, index) {
gl.bindTexture(gl.TEXTURE_2D, attachment.texture);
wtu.clearAndDrawUnitQuad(gl);
var expectedColor = colorFn(attachment, index);
var tolerance = 0;
expectedColor.forEach(function(v) {
if (v != 0 && v != 255) {
tolerance = 8;
}
});
wtu.checkCanvas(gl, expectedColor, "attachment " + index + " should be " + expectedColor.toString(), tolerance);
});
debug("");
};
var checkAttachmentsForColor = function(attachments, color) {
checkAttachmentsForColorFn(attachments, function(attachment, index) {
return color || attachment.color;
});
};
var drawAndCheckAttachments = function(testFB, msg, testFn) {
debug("test clearing " + msg);
@ -517,7 +478,7 @@ function runDrawTests() {
gl.bindFramebuffer(gl.FRAMEBUFFER, fb2);
gl.clearColor(0, 0, 0, 0);
gl.clear(gl.COLOR_BUFFER_BIT);
//checkAttachmentsForColorFn(attachments, function(attachment, index) {
//drawBuffersUtils.checkAttachmentsForColorFn(attachments, function(attachment, index) {
// return [0, 0, 0, 0];
//});
//debug("--");
@ -527,7 +488,7 @@ function runDrawTests() {
gl.clearColor(0, 1, 0, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
checkAttachmentsForColorFn(attachments, function(attachment, index) {
drawBuffersUtils.checkAttachmentsForColorFn(attachments, function(attachment, index) {
return testFn(attachment, index) ? [0, 255, 0, 255] : [0, 0, 0, 0];
});
@ -538,7 +499,7 @@ function runDrawTests() {
gl.bindFramebuffer(gl.FRAMEBUFFER, testFB);
wtu.drawUnitQuad(gl);
checkAttachmentsForColorFn(attachments, function(attachment, index) {
drawBuffersUtils.checkAttachmentsForColorFn(attachments, function(attachment, index) {
return testFn(attachment, index) ? attachment.color : [0, 0, 0, 0];
});
};
@ -553,17 +514,17 @@ function runDrawTests() {
debug("test that each texture got the correct color.");
checkAttachmentsForColor(attachments);
drawBuffersUtils.checkAttachmentsForColor(attachments);
debug("test clearing clears all the textures");
gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
gl.clearColor(0, 1, 0, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
checkAttachmentsForColor(attachments, [0, 255, 0, 255]);
drawBuffersUtils.checkAttachmentsForColor(attachments, [0, 255, 0, 255]);
debug("test a fragment shader writing to neither gl_FragColor nor gl_FragData does not touch attachments");
var noWriteProgram = wtu.setupProgram(gl, ["vshader", "fshaderNoWrite"], ["a_position"]);
var noWriteProgram = wtu.setupProgram(gl, [wtu.simpleVertexShader, "fshaderNoWrite"], ["vPosition"]);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no GL error setting up the program");
if (!noWriteProgram) {
testFailed("Setup a program where fragment shader writes nothing failed");
@ -571,7 +532,7 @@ function runDrawTests() {
gl.useProgram(noWriteProgram);
wtu.drawUnitQuad(gl);
checkAttachmentsForColor(attachments, [0, 255, 0, 255]);
drawBuffersUtils.checkAttachmentsForColor(attachments, [0, 255, 0, 255]);
gl.deleteProgram(noWriteProgram);
}
@ -581,7 +542,7 @@ function runDrawTests() {
gl.useProgram(redProgram);
wtu.clearAndDrawUnitQuad(gl);
checkAttachmentsForColor(attachments, [0, 255, 0, 255]);
drawBuffersUtils.checkAttachmentsForColor(attachments, [0, 255, 0, 255]);
debug("test that gl_FragColor does not broadcast unless extension is enabled in fragment shader");
gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
@ -589,7 +550,7 @@ function runDrawTests() {
gl.useProgram(redProgram);
wtu.drawUnitQuad(gl);
checkAttachmentsForColorFn(attachments, function(attachment, index) {
drawBuffersUtils.checkAttachmentsForColorFn(attachments, function(attachment, index) {
return (index == 0) ? [255, 0, 0, 255] : [0, 255, 0, 255];
});
@ -600,17 +561,17 @@ function runDrawTests() {
gl.useProgram(redProgramWithExtension);
wtu.drawUnitQuad(gl);
checkAttachmentsForColor(attachments, [255, 0, 0, 255]);
drawBuffersUtils.checkAttachmentsForColor(attachments, [255, 0, 0, 255]);
if (maxUsable > 1) {
// First half of color buffers disable.
var bufs1 = makeColorAttachmentArray(maxUsable);
var bufs1 = drawBuffersUtils.makeColorAttachmentArray(maxUsable);
// Second half of color buffers disable.
var bufs2 = makeColorAttachmentArray(maxUsable);
var bufs2 = drawBuffersUtils.makeColorAttachmentArray(maxUsable);
// Color buffers with even indices disabled.
var bufs3 = makeColorAttachmentArray(maxUsable);
var bufs3 = drawBuffersUtils.makeColorAttachmentArray(maxUsable);
// Color buffers with odd indices disabled.
var bufs4 = makeColorAttachmentArray(maxUsable);
var bufs4 = drawBuffersUtils.makeColorAttachmentArray(maxUsable);
for (var ii = 0; ii < maxUsable; ++ii) {
if (ii < half) {
bufs1[ii] = gl.NONE;
@ -637,7 +598,7 @@ function runDrawTests() {
gl.clearColor(0, 1, 0, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
checkAttachmentsForColorFn(attachments, function(attachment, index) {
drawBuffersUtils.checkAttachmentsForColorFn(attachments, function(attachment, index) {
return index < half ? [255, 0, 0, 255] : [0, 255, 0, 255];
});
@ -647,7 +608,7 @@ function runDrawTests() {
gl.useProgram(drawProgram);
wtu.drawUnitQuad(gl);
checkAttachmentsForColorFn(attachments, function(attachment, index) {
drawBuffersUtils.checkAttachmentsForColorFn(attachments, function(attachment, index) {
return index < half ? [255, 0, 0, 255] : attachment.color;
});
@ -661,7 +622,7 @@ function runDrawTests() {
ext.drawBuffersWEBGL(bufs2);
gl.clearColor(0, 0, 1, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
checkAttachmentsForColorFn(attachments, function(attachment, index) {
drawBuffersUtils.checkAttachmentsForColorFn(attachments, function(attachment, index) {
return index < half ? [0, 0, 255, 255] : [255, 0, 0, 255];
});
@ -671,7 +632,7 @@ function runDrawTests() {
gl.useProgram(drawProgram);
wtu.drawUnitQuad(gl);
checkAttachmentsForColorFn(attachments, function(attachment, index) {
drawBuffersUtils.checkAttachmentsForColorFn(attachments, function(attachment, index) {
return index < half ? attachment.color : [255, 0, 0, 255];
});
@ -685,7 +646,7 @@ function runDrawTests() {
gl.clearColor(1, 0, 1, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
checkAttachmentsForColorFn(attachments, function(attachment, index) {
drawBuffersUtils.checkAttachmentsForColorFn(attachments, function(attachment, index) {
return (index % 2) ? [255, 0, 0, 255] : [255, 0, 255, 255];
});
@ -699,7 +660,7 @@ function runDrawTests() {
ext.drawBuffersWEBGL(bufs4);
wtu.drawUnitQuad(gl);
checkAttachmentsForColorFn(attachments, function(attachment, index) {
drawBuffersUtils.checkAttachmentsForColorFn(attachments, function(attachment, index) {
return (index % 2 == 0) ? [0, 0, 0, 255] : attachment.color;
});
@ -747,18 +708,18 @@ function runDrawTests() {
ext.drawBuffersWEBGL(bufs);
gl.clearColor(1, 0, 0, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
checkAttachmentsForColor(attachments, [255, 0, 0, 255]);
drawBuffersUtils.checkAttachmentsForColor(attachments, [255, 0, 0, 255]);
// fb2 still has the NONE draw buffers from before, so this draw should be a no-op.
gl.bindFramebuffer(gl.FRAMEBUFFER, fb2);
gl.useProgram(drawProgram);
wtu.drawUnitQuad(gl);
checkAttachmentsForColor(attachments, [255, 0, 0, 255]);
drawBuffersUtils.checkAttachmentsForColor(attachments, [255, 0, 0, 255]);
gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
gl.useProgram(drawProgram);
wtu.drawUnitQuad(gl);
checkAttachmentsForColor(attachments);
drawBuffersUtils.checkAttachmentsForColor(attachments);
debug("test queries");
debug("check framebuffer with all attachments on");

Просмотреть файл

@ -5,6 +5,7 @@ implicit/00_test_list.txt
--min-version 1.0.2 literals/00_test_list.txt
--min-version 1.0.2 matrices/00_test_list.txt
misc/00_test_list.txt
--min-version 1.0.4 preprocessor/00_test_list.txt
reserved/00_test_list.txt
--min-version 1.0.2 samplers/00_test_list.txt
variables/00_test_list.txt

Просмотреть файл

@ -3,12 +3,14 @@
--min-version 1.0.3 angle-d3d11-compiler-error.html
--min-version 1.0.3 angle-dx-variable-bug.html
--min-version 1.0.3 array-of-struct-with-int-first-position.html
--min-version 1.0.4 assign-to-swizzled-twice-in-function.html
--min-version 1.0.4 bool-type-cast-bug-int-float.html
--min-version 1.0.3 compare-loop-index-to-uniform.html
--min-version 1.0.3 complex-glsl-does-not-crash.html
--min-version 1.0.4 compound-assignment-type-combination.html
--min-version 1.0.3 conditional-discard-in-loop.html
--min-version 1.0.3 conditional-discard-optimization.html
--min-version 1.0.4 conditional-texture-fetch.html
--min-version 1.0.3 constant-precision-qualifier.html
--min-version 1.0.3 --max-version 1.99 essl3-shaders-with-webgl1.html
--min-version 1.0.4 floor-div-cos-should-not-truncate.html
@ -16,7 +18,10 @@
--min-version 1.0.3 fragcoord-linking-bug.html
--min-version 1.0.4 gl-fragcoord-multisampling-bug.html
--min-version 1.0.4 global-invariant-does-not-leak-across-shaders.html
--min-version 1.0.4 if-return-and-elseif.html
--min-version 1.0.4 init-array-with-loop.html
--min-version 1.0.4 invariant-does-not-leak-across-shaders.html
--min-version 1.0.4 in-parameter-passed-as-inout-argument-and-global.html
--min-version 1.0.4 logic-inside-block-without-braces.html
--min-version 1.0.3 long-expressions-should-not-crash.html
--min-version 1.0.4 loop-if-loop-gradient.html
@ -29,11 +34,16 @@
--min-version 1.0.4 pow-with-constant-exponent-should-not-crash.html
--min-version 1.0.4 qualcomm-crash.html
--min-version 1.0.4 qualcomm-loop-with-continue-crash.html
--min-version 1.0.4 sampler-array-struct-function-arg.html
--min-version 1.0.3 sampler-array-using-loop-index.html
--min-version 1.0.4 sampler-struct-function-arg.html
--min-version 1.0.4 sequence-operator-evaluation-order.html
--min-version 1.0.4 sketchfab-lighting-shader-crash.html
--min-version 1.0.4 struct-constructor-highp-bug.html
--min-version 1.0.3 temp-expressions-should-not-crash.html
--min-version 1.0.4 unary-minus-operator-float-bug.html
--min-version 1.0.4 undefined-index-should-not-crash.html
--min-version 1.0.3 uniforms-should-not-lose-values.html
--min-version 1.0.4 varying-arrays-should-not-be-reversed.html
--min-version 1.0.4 vector-scalar-arithmetic-inside-loop.html
--min-version 1.0.4 vector-scalar-arithmetic-inside-loop-complex.html

Просмотреть файл

@ -53,6 +53,22 @@ void main()
gl_FragColor = foo(uv) + foo(um);
}
</script>
<script id="fshaderAmbiguousHLSLStructFunctionCall" type="x-shader/x-fragment">
precision mediump float;
uniform float u_zero;
struct S { float foo; };
struct S2 { float foo; };
float get(S s) { return s.foo + u_zero; }
float get(S2 s2) { return 0.25 + s2.foo + u_zero; }
void main()
{
S s;
s.foo = 0.5;
S2 s2;
s2.foo = 0.25;
gl_FragColor = vec4(0.0, get(s) + get(s2), 0.0, 1.0);
}
</script>
<script type="text/javascript">
"use strict";
description("Test overloaded functions with vec4 and mat2 parameters that have had issues in ANGLE. Issues were due to HLSL compiler treating float4 and float2x2 as the same type when resolving which overloaded function to call.");
@ -62,7 +78,14 @@ GLSLConformanceTester.runTests([
fShaderId: 'fshaderAmbiguousHLSLFunctionCall',
fShaderSuccess: true,
linkSuccess: true,
passMsg: "Disambiguate correctly between overloaded function calls"
passMsg: "Disambiguate correctly between overloaded function calls with 4-component float parameters"
},
{
fShaderId: 'fshaderAmbiguousHLSLStructFunctionCall',
fShaderSuccess: true,
linkSuccess: true,
passMsg: "Disambiguate correctly between overloaded function calls with struct parameters",
render: true
}
]);
</script>

Просмотреть файл

@ -0,0 +1,73 @@
<!--
/*
** Copyright (c) 2018 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>Assigning an assignment to a swizzled value inside function</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>
<script src="../../../js/glsl-conformance-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script id="fshader" type="x-shader/x-fragment">
precision mediump float;
vec2 f()
{
vec2 r = vec2(0);
r.x = r.y = 1.0;
return r;
}
void main()
{
gl_FragColor.ga = f();
}
</script>
<script type="text/javascript">
"use strict";
description();
// Minimal test case based on report at http://crbug.com/798117
GLSLConformanceTester.runRenderTests([
{
fShaderId: 'fshader',
fShaderSuccess: true,
linkSuccess: true,
passMsg: "Assigning an assignment to a swizzled value inside a user-defined function"
}
]);
</script>
</body>
</html>

Просмотреть файл

@ -33,18 +33,11 @@
<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>
<script src="../../../js/glsl-conformance-test.js"></script>
</head>
<body>
<canvas id="canvas" width="256" height="256"> </canvas>
<div id="description"></div>
<div id="console"></div>
<script id="vshader" type="x-shader/x-vertex">
attribute vec3 aPosition;
void main() {
gl_Position = vec4(aPosition, 1);
}
</script>
<script id="fshader" type="x-shader/x-fragment">
precision mediump float;
uniform int uCount;
@ -62,25 +55,16 @@ void main() {
<script type="application/javascript">
"use strict";
description("Comparing loop index to an uniform in a fragment shader should work.");
debug("");
var wtu = WebGLTestUtils;
function test() {
var gl = wtu.create3DContext("canvas");
if (!gl) {
testFailed("context does not exist");
return;
}
wtu.setupUnitQuad(gl);
var program = wtu.setupProgram(gl, ["vshader", "fshader"], ["aPosition"], undefined, true);
var uniformLoc = gl.getUniformLocation(program, 'uCount');
gl.uniform1i(uniformLoc, 5);
wtu.drawUnitQuad(gl);
wtu.checkCanvas(gl, [0, 255, 0, 255]);
};
test();
var successfullyParsed = true;
finishTest();
GLSLConformanceTester.runRenderTests([
{
fShaderId: 'fshader',
fShaderSuccess: true,
linkSuccess: true,
passMsg: 'Compare a loop index to an uniform',
uniforms: [{name: "uCount", functionName: "uniform1i", value: 5}]
}
]);
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,151 @@
<!--
/*
** Copyright (c) 2017 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>Conditional texture fetch 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>
<script src="../../../js/glsl-conformance-test.js"></script>
</head>
<body>
<canvas id="output" style="border: none;" width="64" height="64"></canvas>
<div id="description"></div>
<div id="console"></div>
<script id="vshaderConditionalTextureFetch" type="x-shader/x-vertex">
attribute vec2 a_position;
attribute vec4 a_canvasTileColor;
attribute vec2 a_texCoord;
varying vec2 texCoord;
varying vec4 canvasTileColor;
void main()
{
canvasTileColor = a_canvasTileColor;
texCoord = a_texCoord;
gl_Position = vec4(a_position, 0.0, 1.0);
}
</script>
<script id="fshaderConditionalTextureFetch" type="x-shader/x-fragment">
precision mediump float;
varying vec4 canvasTileColor;
uniform bool hasTexture;
uniform sampler2D canvasTileTexture;
varying vec2 texCoord;
uniform vec4 uvRect;
void main()
{
vec4 finalColor = canvasTileColor;
if (hasTexture) {
vec2 clampedUV = clamp(texCoord.xy, uvRect.xy, uvRect.zw);
finalColor = texture2D(canvasTileTexture, clampedUV);
}
gl_FragColor = finalColor;
}
</script>
<script type="text/javascript">
"use strict";
description();
debug("If the test passes correctly the viewport will be green.");
var wtu = WebGLTestUtils;
var canvas = document.getElementById("output");
var gl = wtu.create3DContext(canvas);
var createGreenTexture = function() {
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);
wtu.fillTexture(gl, texture, 1, 1, [0, 255, 0, 255]);
gl.bindTexture(gl.TEXTURE_2D, null);
return texture;
};
var test = function(greenTexture) {
// This is a reduced test case for a problem reported by Figma.
// Program compilation produces the following warning/error on ANGLE's
// D3D9 backend:
// [WARNING:angle_platform_impl.cc(51)] : rx::HLSLCompiler::compileToBinary(228): C:\fakepath(26,12): error X6077: texld/texldb/texldp/dsx/dsy instructions with r# as source cannot be used inside dynamic conditional 'if' blocks, dynamic conditional subroutine calls, or loop/rep with break*.
//
// All of the operations in the shader -- including the clamping of the
// texture coordinates -- seem to be needed in order to provoke this
// error.
//
// However, this doesn't seem to produce incorrect rendering results.
var program = wtu.setupProgram(
gl,
["vshaderConditionalTextureFetch",
"fshaderConditionalTextureFetch"],
["a_position", "a_canvasTileColor", "a_texCoord"],
[0, 1, 2],
true);
if (!program) {
testFailed("Shader compilation/link failed");
} else {
// Set up buffers
wtu.setupUnitQuad(gl, 0, 2);
// Set up constant color (red)
gl.vertexAttrib4f(1, 1, 0, 0, 1);
var uniformMap = wtu.getUniformMap(gl, program);
// Use texturing
gl.uniform1i(uniformMap["hasTexture"].location, 1);
// Bind texture
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(gl.TEXTURE_2D, greenTexture);
gl.uniform1i(uniformMap["canvasTileTexture"].location, 0);
// Set up (essentially no-op) clamp rectangle
gl.uniform4f(uniformMap["uvRect"].location, 0, 0, 0.25, 0.25);
// Draw
wtu.clearAndDrawUnitQuad(gl);
// Verify output
wtu.checkCanvas(gl, [0, 255, 0, 255], "should be green", 1);
}
};
if (!gl) {
testFailed("context does not exist");
} else {
var tex = createGreenTexture();
test(tex);
}
var successfullyParsed = true;
</script>
<script src="../../../js/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -33,18 +33,11 @@
<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>
<script src="../../../js/glsl-conformance-test.js"></script>
</head>
<body>
<canvas id="canvas" width="256" height="256"> </canvas>
<div id="description"></div>
<div id="console"></div>
<script id="vshader" type="x-shader/x-vertex">
attribute vec3 aPosition;
void main() {
gl_Position = vec4(aPosition, 1);
}
</script>
<script id="fshader" type="x-shader/x-fragment">
// It is assumed that uTest is set to 0. It's here to make the expression not constant.
uniform mediump float uTest;
@ -96,49 +89,48 @@ void main() {
<script type="application/javascript">
"use strict";
description();
var wtu = WebGLTestUtils;
function test() {
var gl = wtu.create3DContext("canvas");
var wtu = WebGLTestUtils;
var gl = wtu.create3DContext();
if (!gl) {
testFailed("context does not exist");
finishTest();
return;
}
if (gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT).precision == 0) {
testPassed("highp precision not supported");
finishTest();
} else {
wtu.setupUnitQuad(gl);
debug("Testing shader where the precision qualifier of a constant affects built-in function results");
var program = wtu.setupProgram(gl, ["vshader", "fshader"], ["aPosition"], undefined, true);
var uniformLoc = gl.getUniformLocation(program, 'uTest');
gl.uniform1f(uniformLoc, 0);
wtu.drawUnitQuad(gl);
wtu.checkCanvasRect(gl, 0, 0, 256, 256, [0, 255, 0, 255]);
debug("");
debug("Testing shader where the precision qualifier of a variable affects built-in function results");
program = wtu.setupProgram(gl, ["vshader", "fshaderNoConstants"], ["aPosition"], undefined, true);
uniformLoc = gl.getUniformLocation(program, 'uTest');
gl.uniform1f(uniformLoc, 0);
uniformLoc = gl.getUniformLocation(program, 'uTestHigh');
gl.uniform1f(uniformLoc, 0);
wtu.drawUnitQuad(gl);
wtu.checkCanvasRect(gl, 0, 0, 256, 256, [0, 255, 0, 255]);
debug("");
debug("Testing shader where all variables are qualified as highp");
program = wtu.setupProgram(gl, ["vshader", "fshaderAllHighp"], ["aPosition"], undefined, true);
uniformLoc = gl.getUniformLocation(program, 'uTest');
gl.uniform1f(uniformLoc, 0);
wtu.drawUnitQuad(gl);
wtu.checkCanvasRect(gl, 0, 0, 256, 256, [0, 255, 0, 255]);
GLSLConformanceTester.runRenderTests([
{
fShaderId: 'fshader',
fShaderSuccess: true,
linkSuccess: true,
passMsg: 'The precision qualifier of a constant affects built-in function results',
uniforms: [{name: "uTest", functionName: "uniform1f", value: 0}]
},
{
fShaderId: 'fshaderNoConstants',
fShaderSuccess: true,
linkSuccess: true,
passMsg: 'The precision qualifier of a variable affects built-in function results',
uniforms: [{name: "uTest", functionName: "uniform1f", value: 0},
{name: "uTestHigh", functionName: "uniform1f", value: 0}]
},
{
fShaderId: 'fshaderAllHighp',
fShaderSuccess: true,
linkSuccess: true,
passMsg: 'All variables are qualified as highp',
uniforms: [{name: "uTest", functionName: "uniform1f", value: 0}]
},
]);
}
};
test();
var successfullyParsed = true;
finishTest();
</script>
</body>
</html>

Просмотреть файл

@ -35,19 +35,19 @@
<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>
<script src="../../../js/glsl-conformance-test.js"></script>
</head>
<body>
<canvas id="repro" style="border: none;" width="256" height="256"></canvas>
<div id="description"></div>
<div id="console"></div>
<script id="shader-vs" type="x-shader/x-vertex">
attribute vec2 pos;
attribute vec4 vPosition;
uniform float divisor;
varying vec4 vColor;
void main(void) {
gl_Position = vec4(pos, 0.0, 1.0);
gl_Position = vPosition;
float index = 9.0;
// Floating point operations don't have any guaranteed precision, but they
// should at least be accurate to 1 part in 10^5.
@ -65,31 +65,26 @@ void main(void) {
</script>
<script>
"use strict";
description();
debug("");
// Reproduces bug seen on Mac OS X with AMD Radeon HD 6490 GPU
debug("If things are working correctly, then the square will be green.");
debug("If your card thinks floor(9. / 3.) is not 3 to within 1 part in 10^5, ");
debug("then the square will be red.");
var wtu = WebGLTestUtils;
var canvas = document.getElementById("repro");
var gl = wtu.create3DContext(canvas);
if (!gl) {
testFailed("context does not exist");
} else {
gl.clearColor(0.0, 0.0, 0.0, 1.0);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
wtu.setupUnitQuad(gl);
var program = wtu.setupProgram(gl, ["shader-vs", "shader-fs"], ["pos"], undefined, true);
gl.uniform1f(gl.getUniformLocation(program, "divisor"), 3);
wtu.drawUnitQuad(gl);
wtu.checkCanvasRect(gl, 128, 128, 128, 128, [ 0, 255, 0, 255 ], "should be green", 1);
GLSLConformanceTester.runRenderTests([
{
vShaderId: 'shader-vs',
vShaderSuccess: true,
fShaderId: 'shader-fs',
fShaderSuccess: true,
linkSuccess: true,
passMsg: 'Test that floor(9. / 3.) is 3 to within 1 part in 10^5',
uniforms: [{name: "divisor", functionName: "uniform1f", value: 3}]
}
]);
var successfullyParsed = true;
</script>
<script src="../../../js/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,86 @@
<!--
/*
** Copyright (c) 2018 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>If with return and else if in fragment shader</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>
<script src="../../../js/glsl-conformance-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script id="vshader" type="x-shader/x-vertex">
attribute vec4 pos;
varying vec2 vPos;
void main()
{
gl_Position = pos;
vPos = pos.xy;
}
</script>
<script id="fshader" type="x-shader/x-fragment">
precision mediump float;
varying vec2 vPos;
void main()
{
if(vPos.x < 1.0) // This colors the whole canvas green
{
gl_FragColor = vec4(0, 1, 0, 1);
return;
}
else if(vPos.x < 1.1) // This should have no effect
{
gl_FragColor = vec4(1, 0, 0, 1);
}
}
</script>
<script type="text/javascript">
"use strict";
description();
// Minimal test case based on report at http://anglebug.com/2325
GLSLConformanceTester.runRenderTests([
{
vShaderId: 'vshader',
vShaderSuccess: true,
fShaderId: 'fshader',
fShaderSuccess: true,
linkSuccess: true,
passMsg: "If and else if in fragment shader"
}
]);
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,73 @@
<!--
/*
** Copyright (c) 2017 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>Function in parameter passed as an inout argument and a global variable with the same name</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>
<script src="../../../js/glsl-conformance-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script id="fshaderParameters" type="x-shader/x-fragment">
precision mediump float;
uniform vec3 u_zero;
vec3 p;
void G(inout vec3 q) {
p += q;
}
void F(in vec3 p) {
G(p);
}
void main(){
F(u_zero + vec3(0.0, 1.0, 0.0));
gl_FragColor = vec4(p, 1.0);
}
</script>
<script type="text/javascript">
"use strict";
description();
// This is intended to test an issue seen on NVIDIA OpenGL drivers (at least up to version 388.59).
// http://crbug.com/792210
GLSLConformanceTester.runRenderTests([
{
fShaderId: 'fshaderParameters',
fShaderSuccess: true,
linkSuccess: true,
passMsg: "Function in parameter passed as an inout argument and a global variable with the same name"
}
]);
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,105 @@
<!--
/*
** Copyright (c) 2017 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>Initializing an array with a loop 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>
<script src="../../../js/glsl-conformance-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script id="fshaderInitLoop" type="x-shader/x-fragment">
precision mediump float;
void initGlobals();
uniform vec4 in0;
vec4 out0;
float func(float a[4]) {
a[0] = -1.0;
return a[0];
}
float arr[4];
bool isOk(vec4 a) {
vec4 ref = -(in0 + 1.0);
if (abs(a.x - ref.x) < 0.05 && abs(a.y - ref.y) < 0.05 && abs(a.z - ref.z) < 0.05 && abs(a.w - ref.w) < 0.05)
{
return true;
}
return false;
}
void main() {
initGlobals();
arr[0] = in0.x + 1.0;
arr[1] = in0.y + 1.0;
arr[2] = in0.z + 1.0;
arr[3] = in0.w + 1.0;
mediump float f = func(arr);
out0 = f * vec4(arr[0], arr[1], arr[2], arr[3]);
if (isOk(out0))
{
gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
}
else
{
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
}
void initGlobals() {
out0 = vec4(0.0, 0.0, 0.0, 0.0);
for (int i = 0; i < 4; ++i)
{
arr[i] = 0.0;
}
}
</script>
<script type="text/javascript">
"use strict";
description();
GLSLConformanceTester.runRenderTests([
{
fShaderId: 'fshaderInitLoop',
fShaderSuccess: true,
linkSuccess: true,
passMsg: "Initialize a global array using a for loop"
}
]);
</script>
</body>
</html>

Просмотреть файл

@ -33,18 +33,11 @@
<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>
<script src="../../../js/glsl-conformance-test.js"></script>
</head>
<body>
<canvas id="canvas" width="256" height="256"> </canvas>
<div id="description"></div>
<div id="console"></div>
<script id="vshader" type="x-shader/x-vertex">
attribute vec3 aPosition;
void main() {
gl_Position = vec4(aPosition, 1);
}
</script>
<script id="fshaderIf" type="x-shader/x-fragment">
precision mediump float;
uniform bool uFalse;
@ -92,33 +85,22 @@ void main() {
"use strict";
description("Short-circuiting logic operator with side effects inside if/for statement without braces should work.");
debug("");
var wtu = WebGLTestUtils;
function test() {
var gl = wtu.create3DContext("canvas");
if (!gl) {
testFailed("context does not exist");
return;
}
wtu.setupUnitQuad(gl);
debug("");
debug("Testing if");
var program = wtu.setupProgram(gl, ["vshader", "fshaderIf"], ["aPosition"], undefined, true);
var uniformLoc = gl.getUniformLocation(program, 'uFalse');
gl.uniform1i(uniformLoc, 0);
wtu.drawUnitQuad(gl);
wtu.checkCanvas(gl, [0, 255, 0, 255]);
debug("");
debug("Testing for");
var program = wtu.setupProgram(gl, ["vshader", "fshaderFor"], ["aPosition"], undefined, true);
wtu.drawUnitQuad(gl);
wtu.checkCanvas(gl, [0, 255, 0, 255]);
};
test();
var successfullyParsed = true;
finishTest();
GLSLConformanceTester.runRenderTests([
{
fShaderId: 'fshaderIf',
fShaderSuccess: true,
linkSuccess: true,
passMsg: 'Short-circuiting operator inside if statement without braces',
uniforms: [{name: "uFalse", functionName: "uniform1i", value: 0}]
},
{
fShaderId: 'fshaderFor',
fShaderSuccess: true,
linkSuccess: true,
passMsg: 'Short-circuiting operator inside for statement without braces'
}
]);
</script>
</body>
</html>

Просмотреть файл

@ -35,19 +35,19 @@
<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>
<script src="../../../js/glsl-conformance-test.js"></script>
</head>
<body>
<canvas id="repro" style="border: none;" width="256" height="256"></canvas>
<div id="description"></div>
<div id="console"></div>
<script id="shader-vs" type="x-shader/x-vertex">
attribute vec2 pos;
attribute vec4 vPosition;
uniform float divisor;
varying vec4 vColor;
void main(void) {
gl_Position = vec4(pos, 0.0, 1.0);
gl_Position = vPosition;
float index = 9.0;
// mod(x, y) is computed as x-y*floor(x/y). There are no guarantees on
// the precision of floating point operations in WebGL shaders, but division
@ -73,23 +73,17 @@ debug("");
debug("If things are working correctly, then the square will be green.");
debug("If your card thinks mod(9,3) is not 0, then the square will be red.");
var wtu = WebGLTestUtils;
var canvas = document.getElementById("repro");
var gl = wtu.create3DContext(canvas);
if (!gl) {
testFailed("context does not exist");
} else {
gl.clearColor(0.0, 0.0, 0.0, 1.0);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
wtu.setupUnitQuad(gl);
var program = wtu.setupProgram(gl, ["shader-vs", "shader-fs"], ["pos"], undefined, true);
gl.uniform1f(gl.getUniformLocation(program, "divisor"), 3);
wtu.drawUnitQuad(gl);
wtu.checkCanvasRect(gl, 128, 128, 128, 128, [ 0, 255, 0, 255 ], "should be green", 1);
GLSLConformanceTester.runRenderTests([
{
vShaderId: 'shader-vs',
vShaderSuccess: true,
fShaderId: 'shader-fs',
fShaderSuccess: true,
linkSuccess: true,
passMsg: 'Test that mod(9/3) is 0',
uniforms: [{name: "divisor", functionName: "uniform1f", value: 3}]
}
var successfullyParsed = true;
]);
</script>
<script src="../../../js/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -33,14 +33,10 @@
<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>
<script src="../../../js/glsl-conformance-test.js"></script>
</head>
<body>
<script id="shader-vs" type="x-shader/x-vertex">
void main(){
gl_Position = vec4(0);
}
</script>
<script id="shader-fs" type="x-shader/x-fragment">
<script id="fshader" type="x-shader/x-fragment">
precision mediump float;
uniform mat3 rot;
float foo(vec3 bar) {
@ -60,21 +56,16 @@ void main(void){
description();
debug("");
debug('Verify multiplication assignment operator compiles correctly - regression test for <a href="https://code.google.com/p/chromium/issues/detail?id=384847">Chromium bug 384847</a>');
var wtu = WebGLTestUtils;
var gl = wtu.create3DContext();
if (!gl) {
testFailed("context does not exist");
} else {
var program = wtu.setupProgram(gl, ["shader-vs", "shader-fs"], null, null, true);
if (program) {
testPassed("Program compiled and linked successfully");
} else {
testFailed("Program failed to compile and link");
}
}
var successfullyParsed = true;
GLSLConformanceTester.runTests([
{
fShaderId: 'fshader',
fShaderSuccess: true,
linkSuccess: true,
passMsg: "vec3 *= mat3 multiplication assignment operator",
}
]);
</script>
<script src="../../../js/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -1,4 +1,4 @@
<!--
<!--
/*
** Copyright (c) 2014 The Khronos Group Inc.

Просмотреть файл

@ -0,0 +1,93 @@
<!--
/*
** Copyright (c) 2017 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>GLSL struct containing an array of samplers passed into a user-defined function</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>
<script src="../../../js/glsl-conformance-test.js"></script>
</head>
<body>
<canvas id="output" style="border: none;" width="64" height="64"></canvas>
<div id="description"></div>
<div id="console"></div>
<script id="fshaderSampler" type="x-shader/x-fragment">
precision mediump float;
struct S {
sampler2D sam[2];
};
uniform S uni;
vec4 useSampler(S arg)
{
return texture2D(arg.sam[0], vec2(0.0, 0.0));
}
void main() {
gl_FragColor = vec4(useSampler(uni));
}
</script>
<script type="application/javascript">
"use strict";
description();
var wtu = WebGLTestUtils;
var canvas = document.getElementById("output");
var gl = wtu.create3DContext(canvas);
if (!gl) {
testFailed("Could not create a GL context.");
} else {
debug("Drawing with a shader that uses a sampler array in a struct passed into a function.");
var program = wtu.setupProgram(
gl, [wtu.simpleVertexShader, 'fshaderSampler'], ['a_position'], [0], true);
wtu.setupUnitQuad(gl);
var tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);
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);
wtu.fillTexture(gl, tex, 1, 1, [0, 255, 0, 255]);
wtu.clearAndDrawUnitQuad(gl);
wtu.checkCanvas(gl, [0, 255, 0, 255], "should be green");
}
var successfullyParsed = true;
</script>
<script src="../../../js/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -35,17 +35,10 @@
</head>
<body>
<canvas id="output" style="border: none;" width="256" height="256"></canvas>
<canvas id="output" style="border: none;" width="64" height="64"></canvas>
<div id="description"></div>
<div id="console"></div>
<script id="shader-vs" type="x-shader/x-vertex">
attribute vec4 a_position;
void main(){
gl_Position = a_position;
}
</script>
<script id="shader-fs" type="x-shader/x-fragment">
precision mediump float;
@ -63,35 +56,49 @@
}
</script>
<script id="shader-fs-array" type="x-shader/x-fragment">
precision mediump float;
struct SomeStruct{
sampler2D source;
};
vec4 fun(SomeStruct s[2]){
return texture2D(s[0].source, vec2(0.5));
}
uniform SomeStruct green[2];
void main(){
gl_FragColor = fun(green);
}
</script>
<script>
"use strict";
description();
debug("");
debug("If the test passes correctly the viewport will be green.");
var wtu = WebGLTestUtils;
var canvas = document.getElementById("output");
var gl = wtu.create3DContext(canvas);
if (!gl) {
testFailed("context does not exist");
} else {
var textureGreen = gl.createTexture()
gl.bindTexture(gl.TEXTURE_2D, textureGreen);
var textureGreen;
var createGreenTexture = function() {
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);
wtu.fillTexture(gl, textureGreen, 1, 1, [0, 255, 0, 255]);
wtu.fillTexture(gl, texture, 1, 1, [0, 255, 0, 255]);
gl.bindTexture(gl.TEXTURE_2D, null);
return texture;
};
// Clear complete viewport to red
gl.clearColor(1.0, 0.0, 0.0, 1.0);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
var attribBuffers = wtu.setupUnitQuad(gl, 0, 1);
var program = wtu.setupProgram(gl, ["shader-vs", "shader-fs"], ["a_position"], [0], true);
var test = function(fragShaderId, texUniformName) {
var program = wtu.setupProgram(gl, [wtu.simpleVertexShader, fragShaderId], ["a_position"], [0], true);
if (!program) {
testFailed("Shader compilation/link failed");
@ -100,14 +107,23 @@ if (!gl) {
var uniformMap = wtu.getUniformMap(gl, program);
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(gl.TEXTURE_2D, textureGreen);
gl.uniform1i(uniformMap['green.source'].location, 0);
gl.uniform1i(uniformMap[texUniformName].location, 0);
// Draw
wtu.drawUnitQuad(gl);
wtu.clearAndDrawUnitQuad(gl);
// Verify output
wtu.checkCanvasRect(gl, 0, 128, 256, 128, [0, 255,0, 255], "should be green", 1);
}
};
if (!gl) {
testFailed("context does not exist");
} else {
wtu.setupUnitQuad(gl, 0, 1);
textureGreen = createGreenTexture();
test("shader-fs", "green.source");
test("shader-fs-array", "green[0].source");
}
var successfullyParsed = true;
</script>

Просмотреть файл

@ -6,19 +6,11 @@
<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>
<script src="../../../js/glsl-conformance-test.js"></script>
</head>
<body>
<canvas id="canvas" width="256" height="256"> </canvas>
<div id="description"></div>
<div id="console"></div>
<script id="vshader" type="x-shader/x-vertex">
attribute vec4 a_position;
void main() {
gl_Position = a_position;
}
</script>
<script id="fshader" type="x-shader/x-fragment">
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
@ -42,22 +34,17 @@ void main() {
description("Struct constructors should evaluate properly.");
debug("Regression test for Three.js bug worked around in <a href='https://github.com/mrdoob/three.js/pull/7556'>https://github.com/mrdoob/three.js/pull/7556</a> that reproduced on Nexus 4 and 5 (Adreno 320 and 330).");
debug("When high precision is used in the fragment shader on these devices, bugs occur in evaluation of structs' constructors. Thanks to Mr. doob for the reduced test case.");
var wtu = WebGLTestUtils;
var gl = wtu.create3DContext("canvas");
gl.clearColor(1, 0, 0, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
var attribBuffers = wtu.setupUnitQuad(gl, 0, 1);
var program = wtu.setupProgram(gl, ['vshader', 'fshader'], ['a_position'], [0], true);
if (!program) {
testFailed("Shader compilation/link failed");
} else {
// Draw
wtu.drawUnitQuad(gl);
// Verify output
wtu.checkCanvas(gl, [0, 255, 0, 255], "should be green");
GLSLConformanceTester.runRenderTests([
{
fShaderId: 'fshader',
fShaderSuccess: true,
linkSuccess: true,
passMsg: "Struct contstructor evaluation"
}
]);
finishTest();
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,70 @@
<!--
/*
** 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>GLSL unary minus operator with float bug Tests</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>
<script src="../../../js/glsl-conformance-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script id="fshader" type="x-shader/x-fragment">
precision mediump float;
void main () {
float f = -1.0;
// atan(tan(0.5), -f) is in range [1.5707, 1.5708) on Mac OSX 10.11 with Intel GPU.
// But it should be 0.5.
gl_FragColor = vec4(atan(tan(0.5), -f), 0.0, 0.0, 1.0);
}
</script>
<script>
"use strict";
description("Test for unary minus operator with float bug on MacOSX 10.11 with Intel GPU");
debug("This is a regression test for <a href='https://bugs.chromium.org/p/chromium/issues/detail?id=308366'>Chromium Issue 308366</a>");
debug("");
GLSLConformanceTester.runRenderTests([
{
fShaderId: 'fshader',
fShaderSuccess: true,
linkSuccess: true,
passMsg: "Evaluate unary minus operator and atan(x, y)",
renderTolerance: 3,
renderColor: [127, 0, 0, 255]
}
]);
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,101 @@
<!--
/*
** Copyright (c) 2017 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>Varying arrays should not be reversed</title>
<link rel="stylesheet" href="../../../resources/js-test-style.css"/>
<script src="../../../js/js-test-pre.js"></script>
<script src="../../../js/webgl-test-utils.js"></script>
</head>
<body>
<canvas id="canvas" width="512" height="256"> </canvas>
<div id="description"></div>
<div id="console"></div>
<script id="vshader" type="x-shader/x-vertex">
varying float colors[3];
uniform vec3 testData;
attribute vec3 position;
void main(){
gl_Position = vec4(position, 1.0);
colors[0] = testData.x;
colors[1] = testData.y;
colors[2] = testData.z;
}
</script>
<script id="fshader" type="x-shader/x-fragment">
precision mediump float;
varying float colors[3];
void main() {
gl_FragColor = vec4(colors[0], colors[1], colors[2], 1.0);
}
</script>
<script>
"use strict";
description("Varying arrays should not be reversed.");
debug("This issue has been seen in Chrome on Nexus 7 2013 (Adreno 320) and Moto G3 (Adreno 306).");
debug("");
debug("If things are working correctly, the vertical stripes should be: red, green, blue, light blue, orange");
debug("");
debug("If they are not, the red and blue channels will appear to be swapped and you will see: blue, green, red, orange, light blue");
var wtu = WebGLTestUtils;
function test() {
var gl = wtu.create3DContext("canvas");
if (!gl) {
testFailed("context does not exist");
return;
}
wtu.setupUnitQuad(gl);
var program = wtu.setupProgram(gl, ["vshader", "fshader"], ["position"], undefined, true);
var loc = gl.getUniformLocation(program, 'testData');
var triples = [
[255, 0, 0],
[0, 255, 0],
[0, 0, 255],
[0, 128, 255],
[255, 128, 0]
];
for (var i = 0; i < triples.length; i++) {
var triple = triples[i];
var x = i * 64;
gl.viewport(x, 0, 64, 256);
gl.uniform3f(loc, triple[0] / 255, triple[1] / 255, triple[2] / 255);
wtu.drawUnitQuad(gl);
wtu.checkCanvasRect(gl, x, 0, 64, 256, [triple[0], triple[1], triple[2], 255]);
}
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors");
}
test();
var successfullyParsed = true;
</script>
<script src="../../../js/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,101 @@
<!--
/*
** Copyright (c) 2017 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>GLSL vector/scalar arithmetic inside a for loop (complex cases)</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>
<script src="../../../js/glsl-conformance-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script id="fShaderVectorCompoundMulAndAddInSeparateStatementsInsideForLoop" type="x-shader/x-fragment">
precision mediump float;
void main() {
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
for (int i = 0; i < 2; i++)
{
float x = gl_FragCoord.x;
float y = (x *= 2.0);
gl_FragColor = gl_FragColor + vec4(y, y, y, y);
}
if (gl_FragColor.g == gl_FragColor.r &&
gl_FragColor.b == gl_FragColor.r &&
gl_FragColor.a == gl_FragColor.r)
{
gl_FragColor = vec4(0, 1, 0, 1);
}
}
</script>
<script id="fShaderVectorCompoundMulAndAddInSeparateStatementsInsideForLoop2" type="x-shader/x-fragment">
precision mediump float;
void main() {
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
for (int i = 0; i < 2; i++)
{
float x = gl_FragCoord.x;
float y = (x *= 2.0);
gl_FragColor = gl_FragColor + vec4(x, y, x, y);
}
if (gl_FragColor.g == gl_FragColor.r &&
gl_FragColor.b == gl_FragColor.r &&
gl_FragColor.a == gl_FragColor.r)
{
gl_FragColor = vec4(0, 1, 0, 1);
}
}
</script>
<script type="text/javascript">
"use strict";
description();
// See http://crbug.com/772651
GLSLConformanceTester.runRenderTests([
{
fShaderId: 'fShaderVectorCompoundMulAndAddInSeparateStatementsInsideForLoop',
fShaderSuccess: true,
linkSuccess: true,
passMsg: "Adding a vector that's just 4 copies of a scalar to another vector inside for loop should work."
},
{
fShaderId: 'fShaderVectorCompoundMulAndAddInSeparateStatementsInsideForLoop2',
fShaderSuccess: true,
linkSuccess: true,
passMsg: "Adding a vector that's just 4 copies of a scalar stored in two different variables to another vector inside for loop should work."
}
]);
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,120 @@
<!--
/*
** Copyright (c) 2017 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>GLSL vector/scalar arithmetic inside a for loop</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>
<script src="../../../js/glsl-conformance-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script id="fShaderVectorMulAndAddInsideForLoop" type="x-shader/x-fragment">
void main(){
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
for (int i = 0; i < 2; i++)
{
gl_FragColor += (2.0 * gl_FragCoord.x);
}
if (gl_FragColor.g == gl_FragColor.r &&
gl_FragColor.b == gl_FragColor.r &&
gl_FragColor.a == gl_FragColor.r)
{
gl_FragColor = vec4(0, 1, 0, 1);
}
}
</script>
<script id="fShaderVectorCompoundMulAndAddInsideForLoop" type="x-shader/x-fragment">
precision mediump float;
void main() {
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
for (int i = 0; i < 2; i++)
{
float x = gl_FragCoord.x;
gl_FragColor = gl_FragColor + (x *= 2.0);
}
if (gl_FragColor.g == gl_FragColor.r &&
gl_FragColor.b == gl_FragColor.r &&
gl_FragColor.a == gl_FragColor.r)
{
gl_FragColor = vec4(0, 1, 0, 1);
}
}
</script>
<script id="fShaderVectorCompoundDivAndAddInsideForLoop" type="x-shader/x-fragment">
precision mediump float;
void main() {
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
for (int i = 0; i < 2; i++)
{
float x = gl_FragCoord.x;
gl_FragColor = gl_FragColor + (x /= 2.0);
}
if (gl_FragColor.g == gl_FragColor.r &&
gl_FragColor.b == gl_FragColor.r &&
gl_FragColor.a == gl_FragColor.r)
{
gl_FragColor = vec4(0, 1, 0, 1);
}
}
</script>
<script type="text/javascript">
"use strict";
description();
// See http://crbug.com/772651
GLSLConformanceTester.runRenderTests([
{
fShaderId: 'fShaderVectorMulAndAddInsideForLoop',
fShaderSuccess: true,
linkSuccess: true,
passMsg: "Adding a scalar to a vector inside for loop should work."
},
{
fShaderId: 'fShaderVectorCompoundMulAndAddInsideForLoop',
fShaderSuccess: true,
linkSuccess: true,
passMsg: "Adding a scalar (target of a compound assignment/multiplication operation) to a vector inside for loop should work."
},
{
fShaderId: 'fShaderVectorCompoundDivAndAddInsideForLoop',
fShaderSuccess: true,
linkSuccess: true,
passMsg: "Adding a scalar (target of a compound assignment/division operation) to a vector inside for loop should work."
}
]);
</script>
</body>
</html>

Просмотреть файл

@ -12,6 +12,7 @@ gl_position_unset.vert.html
glsl-function-nodes.html
--min-version 1.0.2 glsl-vertex-branch.html
glsl-long-variable-names.html
--min-version 1.0.4 local-variable-shadowing-outer-function.html
non-ascii-comments.vert.html
non-ascii.vert.html
--min-version 1.0.2 re-compile-re-link.html
@ -112,3 +113,5 @@ struct-nesting-under-maximum.html
--min-version 1.0.4 ternary-operator-on-arrays.html
--min-version 1.0.3 ternary-operators-in-global-initializers.html
--min-version 1.0.3 ternary-operators-in-initializers.html
--min-version 1.0.4 uninitialized-local-global-variables.html
--min-version 1.0.4 sampler-operand.html

Просмотреть файл

@ -210,6 +210,23 @@ void main() {
gl_FragColor = vec4(0.0, green, 0.0, 1.0);
}
</script>
<script id="builtInConstant" type="x-shader/x-fragment">
precision mediump float;
int i = gl_MaxFragmentUniformVectors;
void main() {
float green = (i > 0) ? 1.0 : 0.0;
gl_FragColor = vec4(0.0, green, 0.0, 1.0);
}
</script>
<script id="builtInNonConstant" type="x-shader/x-fragment">
precision mediump float;
vec4 v = gl_FragCoord;
void main() {
gl_FragColor = v;
}
</script>
<script type="application/javascript">
"use strict";
description();
@ -306,6 +323,19 @@ GLSLConformanceTester.runTests([
{ name: 'us.one', functionName: 'uniform1i', value: 1 }
],
passMsg: "A global struct initialized with a uniform struct should be accepted by WebGL."
},
{
fShaderId: "builtInConstant",
fShaderSuccess: true,
linkSuccess: true,
render: true,
passMsg: "Referencing a built-in constant in a global variable initializer should be accepted by WebGL."
},
{
fShaderId: "builtInNonConstant",
fShaderSuccess: false,
linkSuccess: false,
passMsg: "Referencing a built-in non-constant in a global variable initializer should not be accepted by WebGL."
}
]);
var successfullyParsed = true;

Просмотреть файл

@ -0,0 +1,80 @@
<!--
/*
** Copyright (c) 2017 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 GLSL Conformance Test - Local Variable Shadowing Outer Function</title>
<link rel="stylesheet" href="../../../resources/js-test-style.css"/>
<link rel="stylesheet" href="../../../resources/glsl-feature-tests.css"/>
<script src="../../../js/js-test-pre.js"></script>
<script src="../../../js/webgl-test-utils.js"></script>
<script src="../../../js/glsl-conformance-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script id="vertexShader" type="text/something-not-javascript">
// vertex shader must succeed
attribute vec3 vertex;
varying float interp;
void main() {
interp = vertex.x;
gl_Position = vec4(vertex, 1.0);
}
</script>
<script id="fragmentShader" type="text/something-not-javascript">
// local variable shadowing outer function definition must succeed
precision mediump float;
varying float interp;
float rsquared(float radius)
{
return radius * radius;
}
void some_computation(float radius, out float bsdf) {
bsdf = 0.0;
float rsquared = rsquared(radius);
bsdf += rsquared;
}
void main() {
float comp;
some_computation(interp, comp);
gl_FragColor = vec4(comp, 0.0, 0.0, 1.0);
}
</script>
<script>
"use strict";
GLSLConformanceTester.runTest();
var successfullyParsed = true;
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,72 @@
<!--
/*
** Copyright (c) 2017 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 GLSL Conformance Tests - sampler operands</title>
<link rel="stylesheet" href="../../../resources/js-test-style.css"/>
<link rel="stylesheet" href="../../../resources/glsl-feature-tests.css"/>
<script src="../../../js/js-test-pre.js"></script>
<script src="../../../js/webgl-test-utils.js"></script>
<script src="../../../js/glsl-conformance-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
// ESSL(1.00, 3.00, 3.10) section 4.1.7
// Except for array indexing, structure field selection, and
// parentheses, samplers are not allowed to be operands in expressions.
</script>
<script id="samplerAdding" type="x-shader/x-fragment">
// This covers an ANGLE bug.
// See https://bugs.chromium.org/p/angleproject/issues/detail?id=2028.
uniform sampler2D s1;
uniform sampler2D s2;
void main() {
s1 + s2;
}
</script>
<script>
"use strict";
GLSLConformanceTester.runTests([
{ fShaderId: 'samplerAdding',
fShaderSuccess: false,
linkSuccess: false,
passMsg: 'Adding on samplers should fail'
},
]);
var successfullyParsed = true;
</script>
</body>
</html>

Просмотреть файл

@ -1,4 +1,4 @@
<!--
<!--
/*
** Copyright (c) 2014 The Khronos Group Inc.

Просмотреть файл

@ -0,0 +1,295 @@
<!--
/*
** Copyright (c) 2017 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>Uninitialized local/global variables should be initialized</title>
<link rel="stylesheet" href="../../../resources/js-test-style.css"/>
<link rel="stylesheet" href="../../../resources/glsl-feature-tests.css"/>
<script src="../../../js/js-test-pre.js"></script>
<script src="../../../js/webgl-test-utils.js"> </script>
<script id="vs_uninit_in_frag" type="x-shader/x-vertex">
precision mediump float;
attribute vec4 a_position;
void main() {
gl_Position = a_position;
}
</script>
<!-- Uninitialized local in vertex shader -->
<script id="vs_uninit_local_in_vert" type="x-shader/x-vertex">
precision mediump float;
attribute vec4 a_position;
varying vec3 v_uninit;
void main() {
vec3 uninit; // uninitialized
v_uninit = uninit;
gl_Position = a_position;
}
</script>
<script id="fs_uninit_local_in_vert" type="x-shader/x-fragment">
precision mediump float;
varying vec3 v_uninit;
void main() {
gl_FragColor = v_uninit.xyzz;
}
</script>
<!-- Uninitialized local in fragment shader -->
<script id="fs_uninit_local_in_frag" type="x-shader/x-fragment">
precision mediump float;
void main() {
vec2 uninit; // uninitialized
gl_FragColor = uninit.xyyy;
}
</script>
<!-- Uninitialized global in vertex shader -->
<script id="vs_uninit_global_in_vert" type="x-shader/x-vertex">
precision mediump float;
attribute vec4 a_position;
varying float v_uninit;
float uninit; // uninitialized
void main() {
v_uninit = uninit;
gl_Position = a_position;
}
</script>
<script id="fs_uninit_global_in_vert" type="x-shader/x-fragment">
precision mediump float;
varying float v_uninit;
void main() {
gl_FragColor = vec4(v_uninit);
}
</script>
<!-- Uninitialized global in fragment shader -->
<script id="fs_uninit_global_in_frag" type="x-shader/x-fragment">
precision mediump float;
vec4 uninit; // uninitialized
void main() {
gl_FragColor = uninit;
}
</script>
<!-- Uninitialized local int in fragment shader -->
<script id="fs_uninit_local_int_in_frag" type="x-shader/x-fragment">
precision mediump float;
void main() {
int uninit;
gl_FragColor = vec4(uninit);
}
</script>
<!-- Uninitialized local variable and another variable in the same declaration using it as an initializer in fragment shader -->
<script id="fs_uninit_two_local_variables_in_declaration_in_frag" type="x-shader/x-fragment">
precision mediump float;
void main() {
vec2 uninit, uninit2 = uninit;
gl_FragColor = uninit2.xyyy;
}
</script>
<!-- Uninitialized local array and another variable in the same declaration using it in its initializer in fragment shader -->
<script id="fs_uninit_array_and_another_in_declaration_in_frag" type="x-shader/x-fragment">
precision mediump float;
void main() {
vec2 uninit[2], uninit2 = uninit[0];
gl_FragColor = uninit2.xyyy;
}
</script>
<!-- Uninitialized global int in fragment shader -->
<script id="fs_uninit_global_int_in_frag" type="x-shader/x-fragment">
precision mediump float;
int uninit; // uninitialized
void main() {
gl_FragColor = vec4(uninit);
}
</script>
<!-- Uninitialized local struct in fragment shader -->
<script id="fs_uninit_local_struct_in_frag" type="x-shader/x-fragment">
precision mediump float;
struct S { vec4 v; };
void main() {
S uninit; // uninitialized
gl_FragColor = uninit.v;
}
</script>
<!-- Uninitialized global struct in fragment shader -->
<script id="fs_uninit_global_struct_in_frag" type="x-shader/x-fragment">
precision mediump float;
struct S { vec4 v; };
S uninit; // uninitialized
void main() {
gl_FragColor = uninit.v;
}
</script>
<!-- Uninitialized nameless local struct in fragment shader -->
<script id="fs_uninit_nameless_local_struct_in_frag" type="x-shader/x-fragment">
precision mediump float;
void main() {
struct { vec4 v; } uninit; // uninitialized
gl_FragColor = uninit.v;
}
</script>
<!-- Uninitialized nameless global struct in fragment shader -->
<script id="fs_uninit_nameless_global_struct_in_frag" type="x-shader/x-fragment">
precision mediump float;
struct { vec4 v; } uninit; // uninitialized
void main() {
gl_FragColor = uninit.v;
}
</script>
<!-- Uninitialized local bool in fragment shader -->
<script id="fs_uninit_local_bool_in_frag" type="x-shader/x-fragment">
precision mediump float;
void main() {
bool uninit[16]; // uninitialized
bool result;
for (int i = 0; i < 16; i++) {
result = result || uninit[i];
}
gl_FragColor = result ? vec4(1, 0, 0, 1) : vec4(0);
}
</script>
<!-- Uninitialized global bool in fragment shader -->
<script id="fs_uninit_global_bool_in_frag" type="x-shader/x-fragment">
precision mediump float;
bool uninit[16]; // uninitialized
void main() {
bool result = false;
for (int i = 0; i < 16; i++) {
result = result || uninit[i];
}
gl_FragColor = result ? vec4(1, 0, 0, 1) : vec4(0);
}
</script>
</head>
<body>
<canvas id="canvas" width="50" height="50"></canvas>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
description('Uninitialized local/global variables should be initialized: http://anglebug.com/1966');
var wtu = WebGLTestUtils;
var gl = wtu.create3DContext("canvas");
wtu.setupUnitQuad(gl);
var cases = [
{
name: "Uninitialized local variable in vertex shader",
prog: ["vs_uninit_local_in_vert", "fs_uninit_local_in_vert"],
},
{
name: "Uninitialized local variable in fragment shader",
prog: ["vs_uninit_in_frag", "fs_uninit_local_in_frag"],
},
{
name: "Uninitialized global variable in vertex shader",
prog: ["vs_uninit_global_in_vert", "fs_uninit_global_in_vert"],
},
{
name: "Uninitialized global variable in fragment shader",
prog: ["vs_uninit_in_frag", "fs_uninit_global_in_frag"],
},
{
name: "Uninitialized local int variable in fragment shader",
prog: ["vs_uninit_in_frag", "fs_uninit_local_int_in_frag"],
},
{
name: "Uninitialized local variable and another variable in the same declaration using it as an initializer in fragment shader",
prog: ["vs_uninit_in_frag", "fs_uninit_two_local_variables_in_declaration_in_frag"],
},
{
name: "Uninitialized local array and another variable in the same declaration using it in its initializer in fragment shader",
prog: ["vs_uninit_in_frag", "fs_uninit_array_and_another_in_declaration_in_frag"],
},
{
name: "Uninitialized global int variable in fragment shader",
prog: ["vs_uninit_in_frag", "fs_uninit_global_int_in_frag"],
},
{
name: "Uninitialized local struct variable in fragment shader",
prog: ["vs_uninit_in_frag", "fs_uninit_local_struct_in_frag"],
},
{
name: "Uninitialized global struct variable in fragment shader",
prog: ["vs_uninit_in_frag", "fs_uninit_global_struct_in_frag"],
},
{
name: "Uninitialized nameless local struct variable in fragment shader",
prog: ["vs_uninit_in_frag", "fs_uninit_nameless_local_struct_in_frag"],
},
{
name: "Uninitialized nameless global struct variable in fragment shader",
prog: ["vs_uninit_in_frag", "fs_uninit_nameless_global_struct_in_frag"],
},
{
name: "Uninitialized local bool array variable in fragment shader",
prog: ["vs_uninit_in_frag", "fs_uninit_local_bool_in_frag"],
},
{
name: "Uninitialized global bool array variable in fragment shader",
prog: ["vs_uninit_in_frag", "fs_uninit_global_bool_in_frag"],
},
];
function runTest() {
for (var i = 0; i < cases.length; ++i) {
debug("");
debug(cases[i].name);
var program = wtu.setupProgram(gl, cases[i].prog, ["a_position"], undefined, true);
gl.clearColor(1.0, 0.0, 0.0, 1.0);
wtu.clearAndDrawUnitQuad(gl);
wtu.checkCanvas(gl, [0, 0, 0, 0]);
}
debug("");
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors");
}
runTest();
var successfullyParsed = true;
</script>
<script src="../../../js/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1 @@
--min-version 1.0.4 macro-expansion-tricky.html

Просмотреть файл

@ -0,0 +1,67 @@
<!--
/*
** 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>Tricky macro expansion</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>
<script src="../../../js/glsl-conformance-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script id="fshaderRecursiveMacroNameInsideIncompleteMacroInvocationInMacroExpansion" type="x-shader/x-fragment">
#define m(a)
#define a m((a)
a)
precision mediump float;
void main() {
gl_FragColor = vec4(0.0);
}
</script>
<script type="application/javascript">
"use strict";
description();
GLSLConformanceTester.runTests([
{
fShaderId: 'fshaderRecursiveMacroNameInsideIncompleteMacroInvocationInMacroExpansion',
fShaderSuccess: true,
linkSuccess: true,
passMsg: 'Recursive macro name inside incomplete macro invocation in macro expansion should not crash'
}
]);
</script>
</body>
</html>

Просмотреть файл

@ -13,3 +13,4 @@ shader-precision-format.html
type-conversion-test.html
uninitialized-test.html
webgl-specific.html
--min-version 1.0.4 webgl-specific-stencil-settings.html

Просмотреть файл

@ -0,0 +1,188 @@
<!--
/*
** Copyright (c) 2018 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 stencil mask/func front-state-back-state equality 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>
<div id="console"></div>
<script>
"use strict";
var wtu = WebGLTestUtils;
description("Tests that stencil mask/func are validated correctly when the front state and back state differ.");
var gl = wtu.create3DContext();
function testStencilMaskCase(mask, error) {
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.stencilMaskSeparate(gl.FRONT, " + mask[0] + ")");
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.stencilMaskSeparate(gl.BACK, " + mask[1] + ")");
// If an error is generated, it should be at draw time.
wtu.shouldGenerateGLError(gl, error, "wtu.dummySetProgramAndDrawNothing(gl)");
}
function testStencilMask(errIfMismatch) {
testStencilMaskCase([0, 256], gl.NO_ERROR);
testStencilMaskCase([1, 256], errIfMismatch);
testStencilMaskCase([1, 257], gl.NO_ERROR);
testStencilMaskCase([1, 258], errIfMismatch);
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.stencilMask(1023)", "resetting stencilMask");
}
function testStencilFuncCase(ref, mask, error) {
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.stencilFuncSeparate(gl.FRONT, gl.ALWAYS, " + ref[0] + ", " + mask[0] + ")");
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.stencilFuncSeparate(gl.BACK, gl.ALWAYS, " + ref[1] + ", " + mask[1] + ")");
// If an error is generated, it should be at draw time.
wtu.shouldGenerateGLError(gl, error, "wtu.dummySetProgramAndDrawNothing(gl)");
}
function testStencilFunc(errIfMismatch) {
testStencilFuncCase([ 256, 257], [1023, 1023], gl.NO_ERROR);
testStencilFuncCase([ 256, 254], [1023, 1023], errIfMismatch);
testStencilFuncCase([ -1, 0], [1023, 1023], gl.NO_ERROR);
testStencilFuncCase([ -1, 254], [1023, 1023], errIfMismatch);
testStencilFuncCase([ 0, 0], [ 1, 257], gl.NO_ERROR);
testStencilFuncCase([ 0, 0], [ 1, 258], errIfMismatch);
testStencilFuncCase([ 1, 1], [1024, 2048], gl.NO_ERROR);
testStencilFuncCase([ 1, 1], [2048, 1024], gl.NO_ERROR);
testStencilFuncCase([ -1, -1], [1023, 1023], gl.NO_ERROR);
testStencilFuncCase([ -1, 0], [1023, 1023], gl.NO_ERROR);
testStencilFuncCase([ 0, -1], [1023, 1023], gl.NO_ERROR);
testStencilFuncCase([ 0, 0], [1023, 1023], gl.NO_ERROR);
testStencilFuncCase([ -1, 255], [1023, 1023], errIfMismatch);
testStencilFuncCase([ 0, 256], [1023, 1023], errIfMismatch);
testStencilFuncCase([ 0, 1024], [1023, 1023], errIfMismatch);
testStencilFuncCase([ 1, 257], [1023, 1023], errIfMismatch);
testStencilFuncCase([ 255, -1], [1023, 1023], errIfMismatch);
testStencilFuncCase([ 256, 0], [1023, 1023], errIfMismatch);
testStencilFuncCase([1024, 0], [1023, 1023], errIfMismatch);
testStencilFuncCase([ 257, 1], [1023, 1023], errIfMismatch);
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.stencilFunc(gl.ALWAYS, 0, 1023)", "resetting stencilFunc");
}
const fb = gl.createFramebuffer();
gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
const colorRB = gl.createRenderbuffer();
gl.bindRenderbuffer(gl.RENDERBUFFER, colorRB);
gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 1, 1);
gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, colorRB);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "initial framebuffer setup")
function testStencilSettings(haveDepthBuffer, haveStencilBuffer, enableStencilTest, errIfMismatch) {
debug("");
debug("With depthbuffer=" + haveDepthBuffer +
", stencilbuffer=" + haveStencilBuffer +
", stencilTest=" + enableStencilTest +
", expecting error=" + wtu.glEnumToString(errIfMismatch) +
" for mismatching mask or func settings.");
let rbo = null;
let attachment;
if (haveDepthBuffer || haveStencilBuffer) {
rbo = gl.createRenderbuffer();
gl.bindRenderbuffer(gl.RENDERBUFFER, rbo);
let internalformat;
if (haveDepthBuffer && haveStencilBuffer) {
internalformat = gl.DEPTH_STENCIL;
attachment = gl.DEPTH_STENCIL_ATTACHMENT;
} else if (haveDepthBuffer) {
internalformat = gl.DEPTH_COMPONENT16;
attachment = gl.DEPTH_ATTACHMENT;
} else if (haveStencilBuffer) {
internalformat = gl.STENCIL_INDEX8;
attachment = gl.STENCIL_ATTACHMENT;
}
gl.renderbufferStorage(gl.RENDERBUFFER, internalformat, 1, 1);
gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, rbo);
}
shouldBe("gl.checkFramebufferStatus(gl.FRAMEBUFFER)", "gl.FRAMEBUFFER_COMPLETE");
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "depth/stencil renderbuffer setup")
if (enableStencilTest) {
gl.enable(gl.STENCIL_TEST);
} else {
gl.disable(gl.STENCIL_TEST);
}
// Errors should be the same for both mask and func, because stencil test
// and stencil write are always enabled/disabled in tandem.
testStencilMask(errIfMismatch);
testStencilFunc(errIfMismatch);
if (rbo) {
gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, null);
gl.bindRenderbuffer(gl.RENDERBUFFER, null);
gl.deleteRenderbuffer(rbo);
}
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "depth/stencil renderbuffer cleanup")
}
debug("");
debug("Base case checks:");
testStencilMaskCase([0, 0], gl.NO_ERROR);
testStencilFuncCase([0, 0], [1023, 1023], gl.NO_ERROR);
// haveDepthBuffer
// | haveStencilBuffer
// | | enableStencilTest
// | | | errIfMismatch
testStencilSettings(false, false, false, gl.NO_ERROR);
testStencilSettings( true, false, false, gl.NO_ERROR);
testStencilSettings(false, true, false, gl.NO_ERROR);
testStencilSettings( true, true, false, gl.NO_ERROR);
testStencilSettings(false, false, true, gl.NO_ERROR);
testStencilSettings( true, false, true, gl.NO_ERROR);
testStencilSettings(false, true, true, gl.INVALID_OPERATION);
testStencilSettings( true, true, true, gl.INVALID_OPERATION);
gl.deleteFramebuffer(fb);
gl.deleteRenderbuffer(colorRB);
var successfullyParsed = true;
</script>
<script src="../../js/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -43,7 +43,7 @@
var wtu = WebGLTestUtils;
description("Tests the few differences between WebGL and GLES2");
var gl = wtu.create3DContext(undefined, {stencil:true});
var gl = wtu.create3DContext();
var program = wtu.loadStandardProgram(gl);
gl.useProgram(program);
var vertexObject = gl.createBuffer();
@ -76,27 +76,6 @@ debug("");
debug("Verify that in depthRange zNear <= zFar");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.depthRange(20, 10)");
debug("");
debug("Verify that front/back settings should be the same for stenclMask and stencilFunc");
gl.enable(gl.STENCIL_TEST);
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.stencilMask(255)");
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.drawArrays(gl.TRIANGLES, 0, 0)");
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.stencilMaskSeparate(gl.FRONT, 1)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawArrays(gl.TRIANGLES, 0, 0)");
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.stencilMaskSeparate(gl.BACK, 1)");
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.drawArrays(gl.TRIANGLES, 0, 0)");
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.stencilFunc(gl.ALWAYS, 0, 255)");
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.drawArrays(gl.TRIANGLES, 0, 0)");
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.stencilFuncSeparate(gl.BACK, gl.ALWAYS, 1, 255)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawArrays(gl.TRIANGLES, 0, 0)");
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.stencilFuncSeparate(gl.FRONT, gl.ALWAYS, 1, 255)");
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.drawArrays(gl.TRIANGLES, 0, 0)");
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.stencilFuncSeparate(gl.BACK, gl.ALWAYS, 1, 1)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawArrays(gl.TRIANGLES, 0, 0)");
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.stencilFuncSeparate(gl.FRONT, gl.ALWAYS, 1, 1)");
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.drawArrays(gl.TRIANGLES, 0, 0)");
debug("");
debug("Verify that *LENGTH are undefined");
shouldBeUndefined(gl.INFO_LOG_LENGTH);

Просмотреть файл

@ -27,7 +27,6 @@ functions/deleteBufferBadArgs.html
functions/drawArrays.html
functions/drawArraysOutOfBounds.html
functions/drawElements.html
functions/drawElementsBadArgs.html
functions/isTests.html
--min-version 1.0.2 functions/isTestsBadArgs.html
functions/readPixels.html

Просмотреть файл

@ -1,209 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<!--
/*
** 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.
*/
-->
<link rel="stylesheet" type="text/css" href="../unit.css" />
<script type="application/javascript" src="../unit.js"></script>
<script type="application/javascript" src="../util.js"></script>
<script type="application/javascript">
// Tests.autorun = false;
// Tests.message = "Caution: May crash your browser";
var verts = [0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0];
var normals = [0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0];
var texcoords = [0.0,0.0, 1.0,0.0, 0.0,1.0];
var indices = [60000000,1,2]
Tests.startUnit = function () {
var canvas = document.getElementById('gl');
var gl = wrapGLContext(getGLContext(canvas));
var prog = new Shader(gl, 'vert', 'frag');
prog.use();
var sh = prog.shader.program;
var v = gl.getAttribLocation(sh, 'Vertex');
var n = gl.getAttribLocation(sh, 'Normal');
var t = gl.getAttribLocation(sh, 'Tex');
return [gl,prog,v,n,t];
}
Tests.setup = function(gl, prog, v,n,t) {
assert(0 == gl.getError());
return [gl, prog, v,n,t];
}
Tests.teardown = function(gl, prog, v,n,t) {
gl.disableVertexAttribArray(v);
gl.disableVertexAttribArray(n);
gl.disableVertexAttribArray(t);
}
Tests.endUnit = function(gl, prog, v,n,t) {
prog.destroy();
}
Tests.testDrawElementsVBO = function(gl, prog, v,n,t) {
var vbo = new VBO(gl,
{size:3, data:Quad.vertices},
{elements:true, data:[0,1,2,2000, 40802, 5887992]});
assertFail(function(){vbo.draw(v);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_SHORT, 5*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 5, gl.UNSIGNED_SHORT, 1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 5, gl.UNSIGNED_SHORT, 1*2);});
vbo.destroy();
assert(gl.NO_ERROR == checkError(gl, "vbo.destroy"));
}
Tests.testDrawElementsVBOByte = function(gl, prog, v,n,t) {
var vbo = new VBO(gl,
{size:3, data:Quad.vertices},
{elements:true, type:gl.UNSIGNED_BYTE, data:[0,1,2,2000, 40802, 5887992]});
assertFail(function(){vbo.draw(v);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_BYTE, 5);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_BYTE, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_BYTE, 0);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 5, gl.UNSIGNED_BYTE, 1);});
vbo.destroy();
assert(gl.NO_ERROR == checkError(gl, "vbo.destroy"));
}
Tests.testDrawElementsVBOMulti = function(gl, prog, v,n,t) {
// creates VBOs for the quad arrays, binds them with
// vertexAttribPointer and calls drawElements
// The quad has 6 vertices
var vbo = new VBO(gl,
{size:3, data:Quad.vertices},
{size:3, data:Quad.normals},
{size:2, data:Quad.texcoords},
{elements:true, data:[0,1,2,6,2000, 256]});
assertFail(function(){vbo.draw(v, n, t);});
gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0);
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_SHORT, 5*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 2, gl.UNSIGNED_SHORT, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 4, gl.UNSIGNED_SHORT, 0);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 1*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 2, gl.UNSIGNED_SHORT, 2*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_SHORT, 3*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 5, gl.UNSIGNED_SHORT, 1*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 1*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_SHORT, 6*2);});
gl.bindBuffer(gl.ARRAY_BUFFER, vbo.vbos[1]);
gl.vertexAttribPointer(n, 3, gl.FLOAT, false, 0, 0);
gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0);
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_SHORT, 5*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 5, gl.UNSIGNED_SHORT, 1*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 1*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_SHORT, 6*2);});
vbo.destroy();
assert(gl.NO_ERROR == checkError(gl, "vbo.destroy"));
}
Tests.testDrawElementsVBOMultiByte = function(gl, prog, v,n,t) {
// creates VBOs for the quad arrays, binds them with
// vertexAttribPointer and calls drawElements
// The quad has 6 vertices
var vbo = new VBO(gl,
{size:3, data:Quad.vertices},
{size:3, data:Quad.normals},
{size:2, data:Quad.texcoords},
{elements:true, type:gl.UNSIGNED_BYTE, data:[0,1,2,6,2000, 256]});
assertFail(function(){vbo.draw(v, n, t);});
gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_BYTE, 0);
assertFail(function(){gl.drawElements(gl.TRIANGLES, 4, gl.UNSIGNED_BYTE, -1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, -1, gl.UNSIGNED_BYTE, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_BYTE, 5);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_BYTE, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 2, gl.UNSIGNED_BYTE, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_BYTE, 0);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 4, gl.UNSIGNED_BYTE, 0);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_BYTE, 1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 2, gl.UNSIGNED_BYTE, 2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_BYTE, 3);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 5, gl.UNSIGNED_BYTE, 1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_BYTE, 1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_BYTE, 6);});
gl.bindBuffer(gl.ARRAY_BUFFER, vbo.vbos[1]);
gl.vertexAttribPointer(n, 3, gl.FLOAT, false, 0, 0);
gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_BYTE, 0);
assertOk(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_BYTE, 5);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_BYTE, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_BYTE, 0);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 5, gl.UNSIGNED_BYTE, 1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_BYTE, 1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_BYTE, 6);});
vbo.destroy();
assert(gl.NO_ERROR == checkError(gl, "vbo.destroy"));
}
Tests.testSharedBuffers = function(gl, prog, v,n,t) {
var vbo = gl.createBuffer();
var vertsArr = new Uint16Array([0,1,3,3,4,5,6,7,8]);
gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
gl.bufferData(gl.ARRAY_BUFFER, vertsArr, gl.STATIC_DRAW);
assertFail(function(){gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, vbo)});
gl.deleteBuffer(vbo);
}
</script>
<script id="vert" type="x-shader/x-vertex">
attribute vec3 Vertex;
attribute vec3 Normal;
attribute vec2 Tex;
varying vec4 texCoord0;
void main()
{
gl_Position = vec4(Vertex * Normal, 1.0);
texCoord0 = vec4(Tex,0.0,0.0) + gl_Position;
}
</script>
<script id="frag" type="x-shader/x-fragment">
precision mediump float;
varying vec4 texCoord0;
void main()
{
vec4 c = texCoord0;
gl_FragColor = c;
}
</script>
<style>canvas{ position:absolute; }</style>
</head><body>
<canvas id="gl" width="1" height="1"></canvas>
</body></html>

Просмотреть файл

@ -34,7 +34,7 @@
<script type="application/javascript" src="../../../js/webgl-test-utils.js"></script>
<script type="application/javascript">
var wtu = WebGLTestUtils;
var defaultImgUrl = "http://www.opengl.org/img/opengl_logo.jpg";
var defaultImgUrl = "https://get.webgl.org/conformance-resources/opengl_logo.jpg";
var localImgUrl = "../../../resources/opengl_logo.jpg";
Tests.autoinit = false; // Prevents the test from running until the image is loaded

Просмотреть файл

@ -34,7 +34,7 @@
<script type="application/javascript" src="../../../js/webgl-test-utils.js"></script>
<script type="application/javascript">
var wtu = WebGLTestUtils;
var defaultImgUrl = "http://mashable.com/wp-content/uploads/2008/08/thunderbird-logo-64x64.png";
var defaultImgUrl = "https://get.webgl.org/conformance-resources/thunderbird-logo-64x64.png";
var localImgUrl = "../../../resources/thunderbird-logo-64x64.png";
Tests.autoinit = false; // Prevents the test from running until the image is loaded

Просмотреть файл

@ -88,10 +88,10 @@ Tests.testTexImage2D = function(gl) {
assertGLError(gl, gl.INVALID_VALUE, "negative y", function(){
gl.texSubImage2D(gl.TEXTURE_2D, 0,1,-1,1,1,gl.RGBA,gl.UNSIGNED_BYTE, new Uint8Array([0,0,0,0]));
});
assertGLError(gl, gl.INVALID_ENUM, "bad format", function(){
assertGLErrorIn(gl, [gl.INVALID_OPERATION, gl.INVALID_ENUM], "bad format", function(){
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, 1,1,gl.FLOAT,gl.UNSIGNED_BYTE, new Uint8Array([0,0,0,0]));
});
assertGLError(gl, gl.INVALID_ENUM, "bad type", function(){
assertGLErrorIn(gl, [gl.INVALID_OPERATION, gl.INVALID_ENUM], "bad type", function(){
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, 1,1,gl.RGBA,gl.TEXTURE_2D, new Uint8Array([0,0,0,0]));
});
assertGLError(gl, gl.INVALID_OPERATION, "not enough data", function(){

Просмотреть файл

@ -34,7 +34,7 @@
<script type="application/javascript" src="../../../js/webgl-test-utils.js"></script>
<script type="application/javascript">
var wtu = WebGLTestUtils;
var defaultImgUrl = "http://mashable.com/wp-content/uploads/2008/08/thunderbird-logo-64x64.png";
var defaultImgUrl = "https://get.webgl.org/conformance-resources/thunderbird-logo-64x64.png";
var localImgUrl = "../../../resources/thunderbird-logo-64x64.png";
Tests.autoinit = false; // Prevents the test from running until the image is loaded

Просмотреть файл

@ -0,0 +1,11 @@
context-attribute-preserve-drawing-buffer.html
context-creation.html
context-creation-worker.html
context-lost.html
context-lost-worker.html
context-lost-restored.html
context-lost-restored-worker.html
methods.html
methods-worker.html
offscreencanvas-resize.html
--min-version 1.0.4 offscreencanvas-transfer-image-bitmap.html

Просмотреть файл

@ -0,0 +1,76 @@
<!--
/*
** Copyright (c) 2017 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>OffscreenCanavs context attribute preserveDrawingBuffer</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>
<script src="../../js/tests/canvas-tests-utils.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
description("This test checks whether OffscreenCanvas webgl context honors the preserveDrawingBuffer flag.");
function getPixelsFromOffscreenWebgl(preserveFlag) {
var canvas = document.createElement("canvas");
var offscreenCanvas = transferredOffscreenCanvasCreation(canvas, 10, 10);
var gl = offscreenCanvas.getContext("webgl", {preserveDrawingBuffer: preserveFlag});
// Draw some color on gl and commit
gl.clearColor(1, 0, 1, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
gl.commit();
var pixels = new Uint8Array(4);
gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pixels);
return pixels;
}
if (!window.OffscreenCanvas) {
testPassed("No OffscreenCanvas support");
} else {
// Test if OffscreenCanvas.webgl retains context if preserveDrawingBuffer is true.
var pixelsPreserve = getPixelsFromOffscreenWebgl(true);
shouldBe(pixelsPreserve, [255,0,255,255]);
// Test if OffscreenCanvas.webgl loses context if presereDrawingbuffer is false.
var pixelsNoPreserve = getPixelsFromOffscreenWebgl(false);
shouldBe(pixelsNoPreserve, [0,0,0,0]);
}
var successfullyParsed = true;
</script>
<script src="../../js/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,60 @@
<!--
/*
** 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>WebGL Context Creation Test for OffscreenCanvas in a worker</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>
<div id="console"></div>
<script>
description("This test ensures that the WebGL context can be created on an OffscreenCanvas.");
if (!window.OffscreenCanvas) {
testPassed("No OffscreenCanvas support");
finishTest();
} else {
var worker = new Worker('context-creation-worker.js');
worker.postMessage("Start worker");
worker.onmessage = function(e) {
if (e.data == "Test passed") {
testPassed("All tests have passed");
} else {
testFailed("Some tests failed");
}
finishTest();
}
}
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,30 @@
/*
** 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.
*/
importScripts("../../js/tests/canvas-tests-utils.js");
self.onmessage = function(e) {
if (contextCreation('webgl'))
self.postMessage("Test passed");
else
self.postMessage("Test failed");
};

Просмотреть файл

@ -0,0 +1,58 @@
<!--
/*
** 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>WebGL Context Creation Test for OffscreenCanvas</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>
<script src="../../js/tests/canvas-tests-utils.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
description("This test ensures that the WebGL context can be created on an OffscreenCanvas.");
if (!window.OffscreenCanvas) {
testPassed("No OffscreenCanvas support");
} else {
if (contextCreation('webgl')) {
testPassed("WebGL context created correctly.");
} else {
testFailed("WebGL context creation failed");
}
}
var successfullyParsed = true;
</script>
<script src="../../js/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,64 @@
<!--
/*
** 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">
<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>
<script>
function init()
{
description("Tests behavior under a restored context for OffscreenCanvas in a worker.");
if (!window.OffscreenCanvas) {
testPassed("No OffscreenCanvas support");
finishTest();
return;
}
var worker = new Worker('context-lost-restored-worker.js');
worker.postMessage("Start worker");
worker.onmessage = function(e) {
if (e.data == "Test passed") {
testPassed("All tests have passed");
} else {
testFailed("Some test failed");
}
finishTest();
return;
}
}
</script>
</head>
<body onload="init()">
<div id="description"></div>
<div id="console"></div>
</body>
</html>

Просмотреть файл

@ -0,0 +1,68 @@
/*
** 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.
*/
importScripts("../../js/tests/canvas-tests-utils.js");
self.onmessage = function(e) {
if (!setupTest())
self.postMessage("Test failed");
canvas.addEventListener("webglcontextlost", function(e) {
if (!testLostContext(e))
self.postMessage("Test failed");
// restore the context after this event has exited.
setTimeout(function() {
// we didn't call prevent default so we should not be able to restore the context
if (!compareGLError(gl.INVALID_OPERATION, "WEBGL_lose_context.restoreContext()"))
self.postMessage("Test failed");
testLosingAndRestoringContext().then(function() {
self.postMessage("Test passed");
}, function() {
self.postMessage("Test failed");
});
}, 0);
});
canvas.addEventListener("webglcontextrestored", function() {
self.postMessage("Test failed");
});
allowRestore = false;
contextLostEventFired = false;
contextRestoredEventFired = false;
if (!testOriginalContext())
self.postMessage("Test failed");
WEBGL_lose_context.loseContext();
// The context should be lost immediately.
if (!gl.isContextLost())
self.postMessage("Test failed");
if (gl.getError() != gl.CONTEXT_LOST_WEBGL)
self.postMessage("Test failed");
if (gl.getError() != gl.NO_ERROR)
self.postMessage("Test failed");
// gl methods should be no-ops
if (!compareGLError(gl.NO_ERROR, "gl.blendFunc(gl.TEXTURE_2D, gl.TEXTURE_CUBE_MAP)"))
self.postMessage("Test failed");
// but the event should not have been fired.
if (contextLostEventFired)
self.postMessage("Test failed");
}

Просмотреть файл

@ -0,0 +1,109 @@
<!--
/*
** 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">
<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>
<script src="../../js/tests/canvas-tests-utils.js"></script>
<script>
function init()
{
description("Tests behavior under a restored context for OffscreenCanvas.");
if (!window.OffscreenCanvas) {
testPassed("No OffscreenCanvas support");
finishTest();
return;
}
if (!setupTest()) {
testFailed("Cannot initialize test");
finishTest();
return;
}
canvas.addEventListener("webglcontextlost", function(e) {
if (!testLostContext(e)) {
testFailed("Some test failed");
finishTest();
return;
}
// restore the context after this event has exited.
setTimeout(function() {
// we didn't call prevent default so we should not be able to restore the context
if (!compareGLError(gl.INVALID_OPERATION, "WEBGL_lose_context.restoreContext()")) {
testFailed("Some test failed");
finishTest();
return;
}
testLosingAndRestoringContext().then(function() {
testPassed("Test passed");
finishTest();
return;
}, function() {
testFailed("Some test failed");
finishTest();
return;
});
}, 0);
});
canvas.addEventListener("webglcontextrestored", function() {
testFailed("Some test failed");
finishTest();
return;
});
allowRestore = false;
contextLostEventFired = false;
contextRestoredEventFired = false;
if (!testOriginalContext()) {
testFailed("Some test failed");
finishTest();
return;
}
WEBGL_lose_context.loseContext();
// The context should be lost immediately.
shouldBeTrue("gl.isContextLost()");
shouldBe("gl.getError()", "gl.CONTEXT_LOST_WEBGL");
shouldBe("gl.getError()", "gl.NO_ERROR");
// gl methods should be no-ops
shouldBeTrue(compareGLError(gl.NO_ERROR, "gl.blendFunc(gl.TEXTURE_2D, gl.TEXTURE_CUBE_MAP)"));
// but the event should not have been fired.
shouldBeFalse("contextLostEventFired");
}
</script>
</head>
<body onload="init()">
<div id="description"></div>
<div id="console"></div>
</body>
</html>

Просмотреть файл

@ -0,0 +1,64 @@
<!--
/*
** 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">
<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>
<script>
function init()
{
description("Tests behavior under a lost context for OffscreenCanvas in a worker");
if (!window.OffscreenCanvas) {
testPassed("No OffscreenCanvas support");
finishTest();
return;
}
var worker = new Worker('context-lost-worker.js');
worker.postMessage("Start worker");
worker.onmessage = function(e) {
if (e.data == "Test passed") {
testPassed("All tests have passed");
} else {
testFailed("Some tests failed");
}
finishTest();
return;
}
}
</script>
</head>
<body onload="init()">
<div id="description"></div>
<div id="console"></div>
</body>
</html>

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше