diff options
Diffstat (limited to 'dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc')
117 files changed, 12782 insertions, 0 deletions
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/00_test_list.txt b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/00_test_list.txt new file mode 100644 index 000000000..5b2a97a00 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/00_test_list.txt @@ -0,0 +1,114 @@ +--max-version 1.9.9 attrib-location-length-limits.html +--min-version 1.0.3 boolean_precision.html +--min-version 1.0.4 const-variable-initialization.html +embedded-struct-definitions-forbidden.html +--min-version 1.0.4 empty-declaration.html +empty_main.vert.html +--min-version 1.0.3 expression-list-in-declarator-initializer.html +gl_position_unset.vert.html +--min-version 1.0.4 global-variable-init.html +# this test is intentionally disabled as it is too strict and to hard to simulate +# glsl-2types-of-textures-on-same-unit.html +glsl-function-nodes.html +--min-version 1.0.2 glsl-vertex-branch.html +glsl-long-variable-names.html +non-ascii-comments.vert.html +non-ascii.vert.html +--min-version 1.0.2 re-compile-re-link.html +--min-version 1.0.4 sequence-operator-returns-constant.html +--min-version 1.0.3 shader-precision-format-obeyed.html +--min-version 1.0.3 shader-struct-scope.html +--min-version 1.0.2 shader-uniform-packing-restrictions.html +--min-version 1.0.2 shader-varying-packing-restrictions.html +--min-version 1.0.2 shader-with-256-character-define.html +shader-with-256-character-identifier.frag.html +--min-version 1.0.2 --max-version 1.9.9 shader-with-257-character-define.html +--max-version 1.9.9 shader-with-257-character-identifier.frag.html +shader-with-_webgl-identifier.vert.html +shader-with-arbitrary-indexing.frag.html +shader-with-arbitrary-indexing.vert.html +--min-version 1.0.2 shader-with-array-of-structs-containing-arrays.html +--min-version 1.0.2 shader-with-array-of-structs-uniform.html +shader-with-attrib-array.vert.html +shader-with-attrib-struct.vert.html +shader-with-clipvertex.vert.html +--min-version 1.0.2 shader-with-conditional-scoping.html +--min-version 1.0.2 shader-with-conditional-scoping-negative.html +shader-with-default-precision.frag.html +shader-with-default-precision.vert.html +shader-with-define-line-continuation.frag.html +shader-with-dfdx-no-ext.frag.html +shader-with-dfdx.frag.html +--min-version 1.0.2 shader-with-do-loop.html +shader-with-error-directive.html +shader-with-explicit-int-cast.vert.html +shader-with-float-return-value.frag.html +--min-version 1.0.2 shader-with-for-scoping.html +--min-version 1.0.2 shader-with-for-loop.html +shader-with-frag-depth.frag.html +shader-with-function-recursion.frag.html +--min-version 1.0.2 shader-with-function-scoped-struct.html +--min-version 1.0.2 shader-with-functional-scoping.html +--min-version 1.0.2 shader-with-comma-assignment.html +--min-version 1.0.2 shader-with-comma-conditional-assignment.html +--min-version 1.0.4 shader-with-comma-separated-variable-declarations.html +shader-with-glcolor.vert.html +shader-with-gles-1.frag.html +shader-with-gles-symbol.frag.html +shader-with-glprojectionmatrix.vert.html +shader-with-implicit-vec3-to-vec4-cast.vert.html +shader-with-include.vert.html +shader-with-int-return-value.frag.html +shader-with-invalid-identifier.frag.html +shader-with-ivec2-return-value.frag.html +shader-with-ivec3-return-value.frag.html +shader-with-ivec4-return-value.frag.html +shader-with-limited-indexing.frag.html +--min-version 1.0.2 shader-with-hex-int-constant-macro.html +shader-with-long-line.html +shader-with-non-ascii-error.frag.html +--min-version 1.0.2 shader-with-non-reserved-words.html +shader-with-precision.frag.html +--min-version 1.0.3 shader-with-preprocessor-whitespace.html +shader-with-quoted-error.frag.html +--min-version 1.0.2 shader-with-reserved-words.html +--min-version 1.0.2 shader-with-similar-uniform-array-names.html +--min-version 1.0.2 shader-with-too-many-uniforms.html +--min-version 1.0.4 shader-with-two-initializer-types.html +shader-with-undefined-preprocessor-symbol.frag.html +shader-with-uniform-in-loop-condition.vert.html +shader-with-vec2-return-value.frag.html +shader-with-vec3-return-value.frag.html +shader-with-vec4-return-value.frag.html +--min-version 1.0.2 shader-with-vec4-vec3-vec4-conditional.html +shader-with-version-100.frag.html +shader-with-version-100.vert.html +shader-with-version-120.vert.html +shader-with-version-130.vert.html +shader-with-webgl-identifier.vert.html +--min-version 1.0.2 shader-with-while-loop.html +shader-without-precision.frag.html +--min-version 1.0.3 shaders-with-constant-expression-loop-conditions.html +--min-version 1.0.3 shaders-with-invariance.html +--min-version 1.0.3 shaders-with-name-conflicts.html +--min-version 1.0.2 shaders-with-mis-matching-uniforms.html +--min-version 1.0.2 shaders-with-mis-matching-varyings.html +--min-version 1.0.2 shaders-with-missing-varyings.html +--min-version 1.0.3 shaders-with-uniform-structs.html +--min-version 1.0.2 shaders-with-varyings.html +shared.html +struct-nesting-exceeds-maximum.html +struct-nesting-under-maximum.html +--max-version 1.9.9 uniform-location-length-limits.html +--min-version 1.0.2 shader-with-short-circuiting-operators.html +--min-version 1.0.2 shader-with-global-variable-precision-mismatch.html +--min-version 1.0.2 large-loop-compile.html +--min-version 1.0.3 struct-equals.html +--min-version 1.0.4 struct-assign.html +--min-version 1.0.3 struct-mixed-array-declarators.html +--min-version 1.0.3 struct-nesting-of-variable-names.html +--min-version 1.0.3 struct-specifiers-in-uniforms.html +--min-version 1.0.3 struct-unary-operators.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 diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/attrib-location-length-limits.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/attrib-location-length-limits.html new file mode 100644 index 000000000..f63844d42 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/attrib-location-length-limits.html @@ -0,0 +1,110 @@ +<!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. +*/ + +--> +<title>WebGL attrib location length tests</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> +</head> +<body> +<canvas id="example" width="50" height="50"> +There is supposed to be an example drawing here, but it's not important. +</canvas> +<div id="description">Verify limits on the lengths of attribute locations per WebGL spec, "Maximum Uniform and Attribute Location Lengths".</div> +<div id="console"></div> +<script id="goodVertexShader" type="x-shader/x-vertex"> +// A vertex shader where the needed attrib location is exactly 256 characters. +attribute vec4 vPosition0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456; + +void main() +{ + gl_Position = vPosition0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456; +} +</script> +<script id="badVertexShader" type="x-shader/x-vertex"> +// A vertex shader where the needed attrib location is 257 characters. +attribute vec4 vPosition01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567; + +void main() +{ + gl_Position = vPosition01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567; +} +</script> +<script id="fragmentShader" type="x-shader/x-fragment"> +precision mediump float; + +void main() { + gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); +} +</script> +<script> +"use strict"; +description("test attrib location length limit"); + +var wtu = WebGLTestUtils; +var gl = wtu.create3DContext("example"); + +debug("Test attrib location underneath the length limit"); +var program = wtu.loadProgramFromScript(gl, "goodVertexShader", "fragmentShader"); +shouldBe('gl.getProgramParameter(program, gl.LINK_STATUS)', 'true'); +var attrib256Name = "vPosition0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456"; +gl.bindAttribLocation(program, 0, attrib256Name); +wtu.glErrorShouldBe(gl, gl.NONE); +var attribLoc = gl.getAttribLocation(program, attrib256Name); +if (attribLoc == -1) { + testFailed("attrib location was -1, should not be"); +} else { + testPassed("attrib location should not be -1"); +} +wtu.glErrorShouldBe(gl, gl.NONE); + +debug("Test attrib location over the length limit"); +var attrib257Name = attrib256Name + "7"; + +debug("Shader compilation or link should fail"); +shouldBe('wtu.loadProgramFromScriptExpectError(gl, "badVertexShader", "fragmentShader")', 'null'); +wtu.glErrorShouldBe(gl, gl.NONE); + +debug("Attempt to bind too-long attrib location should produce error"); +program = gl.createProgram(); +gl.bindAttribLocation(program, 0, attrib257Name); +wtu.glErrorShouldBe(gl, gl.INVALID_VALUE); + +debug("Attempt to fetch too-long attrib location should produce error"); +program = wtu.loadStandardProgram(gl); +shouldBe('gl.getAttribLocation(program, attrib257Name)', '-1'); +wtu.glErrorShouldBe(gl, gl.INVALID_VALUE); + +var successfullyParsed = true; +</script> +<script src="../../../js/js-test-post.js"></script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/boolean_precision.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/boolean_precision.html new file mode 100644 index 000000000..121301054 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/boolean_precision.html @@ -0,0 +1,93 @@ +<!-- + +/* +** Copyright (c) 2014 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="vertexTest" type="text/something-not-javascript"> +// parsing boolean variables with precision should fail +void main() { + mediump $(type) fail = $(initializer); + gl_Position = vec4(0.0, 0.0, 0.0, 1.0); +} +</script> +<script id="fragmentTest" type="text/something-not-javascript"> +// parsing boolean variables with precision should fail +void main() { + mediump $(type) fail = $(initializer); + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); +} +</script> +<script> +"use strict"; +var wtu = WebGLTestUtils; + +var types = ['bool', 'bvec2', 'bvec3', 'bvec4']; +var tests = []; +var vTestSource = wtu.getScript("vertexTest"); +var fTestSource = wtu.getScript("fragmentTest"); + +for (var i = 0; i < types.length; ++i) { + var initializer = 'true'; + if (types[i] !== 'bool') { + initializer = types[i] + "(true"; + for (var j = 0; j < i; ++j) { + initializer += ", true"; + } + initializer += ")"; + } + var subs = {type: types[i], initializer: initializer}; + tests.push({ + vShaderSource: wtu.replaceParams(vTestSource, subs), + vShaderSuccess: false, + passMsg: "vertex shader with a " + types[i] + " variable with precision should fail." + }); + tests.push({ + fShaderSource: wtu.replaceParams(fTestSource, subs), + fShaderSuccess: false, + passMsg: "fragment shader with a " + types[i] + " variable with precision should fail." + }); +} +GLSLConformanceTester.runTests(tests); + +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/const-variable-initialization.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/const-variable-initialization.html new file mode 100644 index 000000000..4f771779d --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/const-variable-initialization.html @@ -0,0 +1,265 @@ +<!-- + +/* +** Copyright (c) 2014 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>All valid constant expressions should be allowed in the initialization of const variables</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> +<script id="VertexTemplate" type="x-shader/x-vertex"> +precision mediump float; + +$(init) + +void main() { + const $(constType) c = $(constantExpression); + gl_Position = vec4(float(c$(constTypeToScalar))); +} +</script> +<script id="FragmentTemplate" type="x-shader/x-fragment"> +precision mediump float; + +$(init) + +void main() { + const $(constType) c = $(constantExpression); + gl_FragColor = vec4(float(c$(constTypeToScalar))); +} +</script> +</head> +<body onload="runTest()"> +<div id="description"></div> +<div id="console"></div> +<script type="application/javascript"> +"use strict"; +description(); + +var wtu = WebGLTestUtils; + +// ESSL 1.00 spec section 4.3.2. +// Initializers for const declarations must be a constant expression. + +// ESSL 1.00 spec section 5.10. +// A constant expression is one of +// * a literal value (e.g., 5 or true) +// * a global or local variable qualified as const excluding function parameters +// * an expression formed by an operator on operands that are constant expressions, including getting +// an element of a constant vector or a constant matrix, or a field of a constant structure +// * a constructor whose arguments are all constant expressions +// * a built-in function call whose arguments are all constant expressions, with the exception of the +// texture lookup functions. + +var binaryOpsGenTypeRValuesToGenType = [ + '+', + '-', + '*', + '/' +]; + +var binaryOpsScalarsToBool = [ + '<', + '>', + '<=', + '>=' +]; + +var binaryOpsRValuesToBool = [ + '==', + '!=' +]; + +var binaryOpsBoolsToBool = [ + '&&', + '^^', + '||' +]; + +var builtInsGenTypeToGenType = [ + 'radians', + 'degrees', + 'sin', + 'cos', + 'tan', + 'asin', + 'acos', + 'atan', + 'exp', + 'log', + 'exp2', + 'log2', + 'sqrt', + 'inversesqrt', + 'abs', + 'sign', + 'floor', + 'ceil', + 'fract' +]; + +var builtIns2VecToBvec = [ + 'lessThan', + 'lessThanEqual', + 'greaterThan', + 'greaterThanEqual', + 'equal', + 'notEqual' +]; + +var builtIns2GenTypeToGenType = [ + 'atan', + 'pow', + 'mod', + 'min', + 'max', + 'step' +]; + +var runTest = function() { + var vsTemplate = document.getElementById('VertexTemplate').text; + var fsTemplate = document.getElementById('FragmentTemplate').text; + + var tests = []; + var i; + var op; + var builtIn; + + var pushTest = function(constType, constantExpression, expectSuccess, opt_init) { + if (opt_init === undefined) { + opt_init = ''; + } + var constTypeToScalar = ''; + if (constType.substring(0, 3) == 'vec' || constType.substring(1, 4) == 'vec') { + constTypeToScalar = '.x'; + } else if (constType.substring(0, 3) == 'mat') { + constTypeToScalar = '[0].x'; + } else if (constType == 'my_struct') { + constTypeToScalar = '.field'; + } + var vs = wtu.replaceParams(vsTemplate, {constType: constType, constantExpression: constantExpression, constTypeToScalar: constTypeToScalar, init: opt_init}); + var fs = wtu.replaceParams(fsTemplate, {constType: constType, constantExpression: constantExpression, constTypeToScalar: constTypeToScalar, init: opt_init}); + tests.push({ + vShaderSource: vs, + vShaderSuccess: expectSuccess, + linkSuccess: expectSuccess, + passMsg: "Assigning " + constantExpression + " to a const in a vertex shader should " + (expectSuccess ? "compile." : "fail compilation.") + }); + tests.push({ + fShaderSource: fs, + fShaderSuccess: expectSuccess, + linkSuccess: expectSuccess, + passMsg: "Assigning " + constantExpression + " to a const in a fragment shader should " + (expectSuccess ? "compile." : "fail compilation.") + }); + } + + // Handle some one of a kind cases first + pushTest('float', 'vec4(0.5).x', true); + pushTest('float', 'vec4(0.5)[0]', true); + pushTest('float', 'true ? 0.5 : 0.2', true); + pushTest('my_struct', 'my_struct(0.5, 0.2)', true, 'struct my_struct { float field; float field2; };'); + pushTest('float', '(0.2, 0.5)', true); + + pushTest('float', 'clamp(0.2, 0.3, 0.4)', true); + pushTest('float', 'mix(0.2, 0.3, 0.4)', true); + pushTest('float', 'smoothstep(0.2, 0.3, 0.4)', true); + pushTest('float', 'length(vec4(0.5))', true); + pushTest('float', 'distance(vec4(0.5), vec4(0.2))', true); + pushTest('float', 'dot(vec4(0.5), vec4(0.2))', true); + pushTest('vec3', 'cross(vec3(0.5), vec3(0.2))', true); + pushTest('vec4', 'normalize(vec4(0.5))', true); + pushTest('vec4', 'faceforward(vec4(0.2), vec4(0.3), vec4(0.4))', true); + pushTest('vec4', 'reflect(vec4(0.2), vec4(0.5))', true); + pushTest('vec4', 'refract(vec4(0.2), vec4(0.3), 0.4)', true); + pushTest('mat4', 'matrixCompMult(mat4(0.2), mat4(0.5))', true); + + // Handle built-in constructors + for (i = 2; i <= 4; ++i) { + var vecType = 'vec' + i; + pushTest(vecType, vecType + '(0.5)', true); + pushTest('i' + vecType, 'i' + vecType + '(1)', true); + pushTest('b' + vecType, 'b' + vecType + '(true)', true); + pushTest('mat' + i, 'mat' + i + '(0.5)', true); + } + + // Handle ops + for (i = 0; i < binaryOpsGenTypeRValuesToGenType.length; ++i) { + var op = binaryOpsGenTypeRValuesToGenType[i]; + pushTest('float', '0.2 ' + op + ' 0.5', true); + pushTest('vec4', 'vec4(0.2) ' + op + ' vec4(0.5)', true); + pushTest('mat4', 'mat4(0.2) ' + op + ' mat4(0.5)', true); + } + + for (i = 0; i < binaryOpsScalarsToBool.length; ++i) { + var op = binaryOpsScalarsToBool[i]; + pushTest('bool', '0.2 ' + op + ' 0.5', true); + } + + for (i = 0; i < binaryOpsRValuesToBool.length; ++i) { + var op = binaryOpsRValuesToBool[i]; + pushTest('bool', '0.2 ' + op + ' 0.5', true); + pushTest('bool', 'vec4(0.2) ' + op + ' vec4(0.5)', true); + } + + for (i = 0; i < binaryOpsBoolsToBool.length; ++i) { + var op = binaryOpsBoolsToBool[i]; + pushTest('bool', 'false ' + op + ' true', true); + } + + // Handle allowed built-ins + for (i = 0; i < builtInsGenTypeToGenType.length; ++i) { + builtIn = builtInsGenTypeToGenType[i]; + pushTest('float', builtIn + '(0.5)', true); + pushTest('vec4', builtIn + '(vec4(0.5))', true); + } + + for (i = 0; i < builtIns2VecToBvec.length; ++i) { + builtIn = builtIns2VecToBvec[i]; + pushTest('bvec4', builtIn + '(vec4(0.2), vec4(0.5))', true); + } + + for (i = 0; i < builtIns2GenTypeToGenType.length; ++i) { + builtIn = builtIns2GenTypeToGenType[i]; + pushTest('float', builtIn + '(0.2, 0.5)', true); + pushTest('vec4', builtIn + '(vec4(0.2), vec4(0.5))', true); + } + + // Include some expressions with a constant variable reference + pushTest('float', 'cc', true, 'const float cc = 0.5;'); + pushTest('float', 'cc + cc2', true, 'const float cc = 0.5; const float cc2 = 0.2;'); + pushTest('float', 'sqrt(cc)', true, 'const float cc = 0.5;'); + + GLSLConformanceTester.runTests(tests); +} + +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/embedded-struct-definitions-forbidden.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/embedded-struct-definitions-forbidden.html new file mode 100644 index 000000000..449d306a9 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/embedded-struct-definitions-forbidden.html @@ -0,0 +1,62 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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"> +// embedded structure definitions are forbidden per GLSL ES section 4.1.8, "Structures", and should fail +struct nesting1 { + struct nesting2 { + vec4 vector; + } field2; +}; + +uniform nesting1 uniform1; +void main() +{ + gl_Position = uniform1.field2.vector; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/empty-declaration.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/empty-declaration.html new file mode 100644 index 000000000..720f88816 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/empty-declaration.html @@ -0,0 +1,132 @@ +<!-- + +/* +** Copyright (c) 2015 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 - empty declarations</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="vertexEmptyDeclaration" type="text/something-not-javascript"> +// Vertex shader with an empty declaration should succeed. +// See shading language grammar rules init_declarator_list and single_declaration +// in ESSL specs. +// Empty declarations are a side effect of how grammar for structs is defined. +void main() { + float; + gl_Position = vec4(0.0); +} +</script> +<script id="vertexEmptyDeclarationPlus" type="text/something-not-javascript"> +// Vertex shader with an empty declaration followed by declarator should succeed. +// See shading language grammar rules init_declarator_list and single_declaration +// in ESSL specs. +void main() { + float, a = 0.0; + gl_Position = vec4(a); +} +</script> +<script id="vertexEmptyStructDeclarationPlus" type="text/something-not-javascript"> +// Vertex shader with an empty declaration followed by declarator should succeed. +// See shading language grammar rules init_declarator_list and single_declaration +// in ESSL specs. + +struct S { + float member; +}, a; + +void main() { + a.member = 0.0; + gl_Position = vec4(a.member); +} +</script> +<script id="vertexEmptyDeclarationInStruct" type="text/something-not-javascript"> +// Vertex shader with an empty declaration inside struct should fail. +// In-struct declarations have different grammar from declarations outside structs. +struct S { + float; + float a; +}; + +void main() { + gl_Position = vec4(0.0); +} +</script> +<script id="vertexEmptyDeclarationPlusInStruct" type="text/something-not-javascript"> +// Vertex shader with an empty declaration inside struct should fail. +// In-struct declarations have different grammar from declarations outside structs. +struct S { + float, a; + float b; +}; + +void main() { + gl_Position = vec4(0.0); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTests([ + { vShaderId: 'vertexEmptyDeclaration', + vShaderSuccess: true, + linkSuccess: true, + passMsg: 'Vertex shader with an empty declaration should succeed' + }, + { vShaderId: 'vertexEmptyDeclarationPlus', + vShaderSuccess: true, + linkSuccess: true, + passMsg: 'Vertex shader with an empty declaration followed by declarator should succeed' + }, + { vShaderId: 'vertexEmptyStructDeclarationPlus', + vShaderSuccess: true, + linkSuccess: true, + passMsg: 'Vertex shader with an empty struct declaration followed by declarator should succeed' + }, + { vShaderId: 'vertexEmptyDeclarationInStruct', + vShaderSuccess: false, + linkSuccess: false, + passMsg: 'Vertex shader with an empty declaration in a struct should fail' + }, + { vShaderId: 'vertexEmptyDeclarationPlusInStruct', + vShaderSuccess: false, + linkSuccess: false, + passMsg: 'Vertex shader with an empty declaration followed by declarator in a struct should fail' + } +]); + +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/empty_main.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/empty_main.vert.html new file mode 100644 index 000000000..80d1a14ca --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/empty_main.vert.html @@ -0,0 +1,54 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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 with an empty main() should succeed +void main() { } +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/expression-list-in-declarator-initializer.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/expression-list-in-declarator-initializer.html new file mode 100644 index 000000000..4cea555a3 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/expression-list-in-declarator-initializer.html @@ -0,0 +1,87 @@ +<!-- +/* +** Copyright (c) 2014 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ +--> +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<link rel="stylesheet" href="../../../resources/js-test-style.css" /> +<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> +<title></title> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script id="fragmentShader" type="text/something-not-javascript"> +precision mediump float; +void main() { + $(type) a, b; + $(type) c = (b = $(initializer), a = b); + gl_FragColor = $(asVec4); +} +</script> +<script> +"use strict"; +description("Verifies expression lists in declarator initializers work correctly."); +var tests = []; +var wtu = WebGLTestUtils; +var typeInfos = [ + { type: 'float', initializer: '1.0', asVec4: 'vec4(0.0,$(var),0.0,1.0)' }, + { type: 'vec2', initializer: 'vec2(0.0, 1.0)', asVec4: 'vec4($(var),0.0,1.0)' }, + { type: 'vec3', initializer: 'vec3(0.0, 1.0, 0.0)', asVec4: 'vec4($(var),1.0)' }, + { type: 'vec4', initializer: 'vec4(0.0, 1.0, 0.0, 1.0)', asVec4: '$(var)' }, + { type: 'int', initializer: '1', asVec4: 'vec4(0.0,$(var),0.0,1.0)' }, + { type: 'ivec2', initializer: 'ivec2(0, 1)', asVec4: 'vec4($(var),0.0,1.0)' }, + { type: 'ivec3', initializer: 'ivec3(0, 1, 0)', asVec4: 'vec4($(var),1.0)' }, + { type: 'ivec4', initializer: 'ivec4(0, 1, 0, 1)', asVec4: 'vec4($(var))' }, + { type: 'bool', initializer: 'true', asVec4: 'vec4(0.0,$(var),0.0,1.0)' }, + { type: 'bvec2', initializer: 'bvec2(false, true)', asVec4: 'vec4($(var),0.0,1.0)' }, + { type: 'bvec3', initializer: 'bvec3(false, true, false)', asVec4: 'vec4($(var),1.0)' }, + { type: 'bvec4', initializer: 'bvec4(false,true,false,true)',asVec4: 'vec4($(var))' }, +]; +// Ensure that each variable is properly initialized to green, not just c. +['a', 'b', 'c'].forEach(function(varName) { + typeInfos.forEach(function (typeInfo) { + var replaceParams = { + type: typeInfo.type, + initializer: typeInfo.initializer, + asVec4: wtu.replaceParams(typeInfo.asVec4, {var: varName}), + }; + tests.push({ + fShaderSource: wtu.replaceParams(wtu.getScript('fragmentShader'), replaceParams), + passMsg: typeInfo.type + ' with contents of ' + varName + ' rendered', + fShaderSuccess: true, + linkSuccess: true, + render:true + }); + }); +}); +GLSLConformanceTester.runTests(tests); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/gl_position_unset.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/gl_position_unset.vert.html new file mode 100644 index 000000000..3ee953d40 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/gl_position_unset.vert.html @@ -0,0 +1,58 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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 without gl_Position being written should succeed +void main() { + vec4 a = vec4(0.0, 0.0, 0.0, 1.0); + float f = a.x; + a.y = f; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/global-variable-init.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/global-variable-init.html new file mode 100644 index 000000000..c102c3c3c --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/global-variable-init.html @@ -0,0 +1,314 @@ +<!-- + +/* +** Copyright (c) 2015 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>Global variable initializer restrictions</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="constGlobalShader" type="x-shader/x-vertex"> +precision mediump float; +attribute vec4 aPosition; +varying float v; + +const float c = 1.0; +float f = c; + +void main() { + v = f; + gl_Position = aPosition; +} +</script> +<script id="globalShader" type="x-shader/x-vertex"> +precision mediump float; +attribute vec4 aPosition; +varying float v; + +float c = 1.0; +float f = c; + +void main() { + v = f; + gl_Position = aPosition; +} +</script> +<script id="uniformShader" type="x-shader/x-vertex"> +precision mediump float; +attribute vec4 aPosition; +varying float v; + +uniform float u; +float f = u; + +void main() { + v = f; + gl_Position = aPosition; +} +</script> +<script id="builtinFunctionShader" type="x-shader/x-vertex"> +precision mediump float; +attribute vec4 aPosition; +varying float v; + +float c = 1.0; +float f = sin(c); + +void main() { + v = f; + gl_Position = aPosition; +} +</script> +<script id="builtinTextureFunctionShader" type="x-shader/x-vertex"> +precision mediump float; +attribute vec4 aPosition; +varying float v; + +uniform sampler2D s; +float f = texture2DLod(s, vec2(0.5, 0.5), 0.0).x; + +void main() { + v = f; + gl_Position = aPosition; +} +</script> +<script id="attributeShader" type="x-shader/x-vertex"> +precision mediump float; +attribute vec4 aPosition; +varying float v; + +float f = aPosition.x; + +void main() { + v = f; + gl_Position = aPosition; +} +</script> +<script id="userDefinedFunctionShader" type="x-shader/x-vertex"> +precision mediump float; +attribute vec4 aPosition; +varying float v; + +float foo() { + return 1.0; +} +float f = foo(); + +void main() { + v = f; + gl_Position = aPosition; +} +</script> +<script id="varyingShader" type="x-shader/x-fragment"> +precision mediump float; +varying float v; +float f = v; + +void main() { + gl_FragColor = vec4(f); +} +</script> +<script id="globalLValueShader" type="x-shader/x-vertex"> +precision mediump float; +attribute vec4 aPosition; +varying float v; + +float c = 1.0; +float f = (c = 0.0); + +void main() { + v = f; + gl_Position = aPosition; +} +</script> +<script id="globalLValueShader2" type="x-shader/x-vertex"> +precision mediump float; +attribute vec4 aPosition; +varying float v; + +float c = 1.0; +float f = (c++); + +void main() { + v = f; + gl_Position = aPosition; +} +</script> +<script id="globalNonConstTernary" type="x-shader/x-fragment"> +precision mediump float; +float green = 1.0; +float black = 0.0; +float f = true ? green : black; + +void main() { + gl_FragColor = vec4(0.0, f, 0.0, 1.0); +} +</script> +<script id="globalUniformTernary" type="x-shader/x-fragment"> +precision mediump float; +uniform float u_zero; +float green = 1.0 + u_zero; +float f = true ? green : u_zero; + +void main() { + gl_FragColor = vec4(0.0, f, 0.0, 1.0); +} +</script> +<script id="globalUniformTernary2" type="x-shader/x-fragment"> +precision mediump float; +uniform float u_zero; +float green = 1.0; +float f = (u_zero < 0.1) ? green : 0.0; + +void main() { + gl_FragColor = vec4(0.0, f, 0.0, 1.0); +} +</script> +<script id="globalUniformStruct" type="x-shader/x-fragment"> +precision mediump float; +struct S { + float zero; + int one; +}; +uniform S us; +S s = us; + +void main() { + float green = (s.one == 1) ? 1.0 : 0.0; + gl_FragColor = vec4(0.0, green, 0.0, 1.0); +} +</script> +<script type="application/javascript"> +"use strict"; +description(); +GLSLConformanceTester.runTests([ + { + vShaderId: "constGlobalShader", + vShaderSuccess: true, + linkSuccess: true, + passMsg: "A const global in a global variable initializer should be accepted by WebGL." + }, + { + vShaderId: "globalShader", + vShaderSuccess: true, + linkSuccess: true, + passMsg: "Another global in a global variable initializer should be accepted by WebGL." + }, + { + vShaderId: "uniformShader", + vShaderSuccess: true, + linkSuccess: true, + passMsg: "A uniform in a global variable initializer should be accepted by WebGL." + }, + { + vShaderId: "builtinFunctionShader", + vShaderSuccess: true, + linkSuccess: true, + passMsg: "A built-in math function in a global variable initializer should be accepted by WebGL." + }, + { + vShaderId: "builtinTextureFunctionShader", + vShaderSuccess: false, + linkSuccess: false, + passMsg: "A texture lookup function in a global variable initializer should not be accepted by WebGL." + }, + { + vShaderId: "attributeShader", + vShaderSuccess: false, + linkSuccess: false, + passMsg: "An attribute in a global variable initializer should not be accepted by WebGL." + }, + { + vShaderId: "userDefinedFunctionShader", + vShaderSuccess: false, + linkSuccess: false, + passMsg: "A user-defined function call in a global variable initializer should not be accepted by WebGL." + }, + { + vShaderId: "constGlobalShader", + vShaderSuccess: true, + fShaderId: "varyingShader", + fShaderSuccess: false, + linkSuccess: false, + passMsg: "A varying in a global variable initializer should not be accepted by WebGL." + }, + { + vShaderId: "globalLValueShader", + vShaderSuccess: false, + linkSuccess: false, + passMsg: "Another global as an l-value in a global variable initializer should not be accepted by WebGL." + }, + { + vShaderId: "globalLValueShader2", + vShaderSuccess: false, + linkSuccess: false, + passMsg: "Another global as an l-value (parameter of ++) in a global variable initializer should not be accepted by WebGL." + }, + { + fShaderId: "globalNonConstTernary", + fShaderSuccess: true, + linkSuccess: true, + render: true, + passMsg: "Non-const global variables as operands for a ternary operator in a global variable initializer should be accepted by WebGL." + }, + { + fShaderId: "globalUniformTernary", + fShaderSuccess: true, + linkSuccess: true, + render: true, + passMsg: "A uniform as the second operand for a ternary operator in a global variable initializer should be accepted by WebGL." + }, + { + fShaderId: "globalUniformTernary2", + fShaderSuccess: true, + linkSuccess: true, + render: true, + passMsg: "Referencing a uniform inside the first operand for a ternary operator in a global variable initializer should be accepted by WebGL." + }, + { + fShaderId: "globalUniformStruct", + fShaderSuccess: true, + linkSuccess: true, + render: true, + uniforms: [ + { name: 'us.one', functionName: 'uniform1i', value: 1 } + ], + passMsg: "A global struct initialized with a uniform struct should be accepted by WebGL." + } +]); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/glsl-2types-of-textures-on-same-unit.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/glsl-2types-of-textures-on-same-unit.html new file mode 100644 index 000000000..11573e9c2 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/glsl-2types-of-textures-on-same-unit.html @@ -0,0 +1,153 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> + <head> +<meta charset="utf-8"> + <title>WebGL GLSL 2 types of textures on same unit conformance 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="2" height="2" style="width: 40px; height: 40px;"></canvas> +<canvas id="canvas2d" width="1" height="1" style="width: 40px; height: 40px;"></canvas> +<div id="description"></div> +<div id="console"></div> +<script id="vshader" type="x-shader/x-vertex"> +attribute 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 tex2d; +uniform samplerCube texCube; +varying vec2 texCoord; +void main() +{ + gl_FragColor = texture2D(tex2d, texCoord) + + textureCube(texCube, vec3(0,1,0)); +} +</script> + + <script> + "use strict"; +function init() +{ + description( + "Tests that using 2 types of textures on the same texture unit" + + "and referencing them both in the same program fails as per" + + "OpenGL ES 2.0.24 spec section 2.10.4, Samplers subsection."); + + var canvas2d = document.getElementById("canvas2d"); + var ctx2d = canvas2d.getContext("2d"); + + var wtu = WebGLTestUtils; + var gl = wtu.create3DContext("example"); + var program = wtu.setupProgram(gl, ["vshader", "fshader"], ["vPosition", "texCoord0"]); + + var vertexObject = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject); + gl.bufferData( + gl.ARRAY_BUFFER, + new Float32Array([ + -1, 1,0, 1,1,0, -1,-1,0, + -1,-1,0, 1,1,0, 1,-1,0]), + gl.STATIC_DRAW); + gl.enableVertexAttribArray(0); + gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0); + + var vertexObject = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject); + gl.bufferData( + gl.ARRAY_BUFFER, + new Float32Array([ + 0,0, 1,0, 0,1, + 0,1, 1,0, 1,1]), + gl.STATIC_DRAW); + gl.enableVertexAttribArray(1); + gl.vertexAttribPointer(1, 2, gl.FLOAT, false, 0, 0); + + // Make texture unit 1 active. + gl.activeTexture(gl.TEXTURE1); + + // Make a 2d texture + var tex2d = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, tex2d); + ctx2d.fillStyle = "rgba(0, 0, 255, 255)"; + ctx2d.fillRect(0, 0, 1, 1); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas2d); + + // make a cube texture + var texCube = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_CUBE_MAP, texCube); + ctx2d.fillStyle = "rgba(0, 255, 0, 64)"; + ctx2d.fillRect(0, 0, 1, 1); + var targets = [ + gl.TEXTURE_CUBE_MAP_POSITIVE_X, + gl.TEXTURE_CUBE_MAP_NEGATIVE_X, + gl.TEXTURE_CUBE_MAP_POSITIVE_Y, + gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, + gl.TEXTURE_CUBE_MAP_POSITIVE_Z, + gl.TEXTURE_CUBE_MAP_NEGATIVE_Z]; + for (var ii = 0; ii < targets.length; ++ii) { + gl.texImage2D(targets[ii], 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas2d); + } + + var tex2dLoc = gl.getUniformLocation(program, "tex2d"); + var texCubeLoc = gl.getUniformLocation(program, "texCube"); + gl.uniform1i(tex2dLoc, 1); + gl.uniform1i(texCubeLoc, 1); + + gl.clearColor(1,0,0,1); + gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); + + for (var ii = 0; ii < 4; ++ii) { + var x = ii % 2; + var y = Math.floor(ii / 2); + gl.drawArrays(gl.TRIANGLES, 0, 6); + wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, + "drawing with 2 different targets on the same texture unit should generate INVALID_VALUE"); + } +} + +init(); +var successfullyParsed = true; +</script> +<script src="../../../js/js-test-post.js"></script> + +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/glsl-function-nodes.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/glsl-function-nodes.html new file mode 100644 index 000000000..fd1be0495 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/glsl-function-nodes.html @@ -0,0 +1,155 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL function nodes Test</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="vshaderFunction" type="x-shader/x-vertex"> +attribute vec4 aPosition; +varying vec4 vColor; + +float sign_emu(float value) { + if (value == 0.0) return 0.0; + return value > 0.0 ? 1.0 : -1.0; +} + +void main() +{ + gl_Position = aPosition; + vec2 texcoord = vec2(aPosition.xy * 0.5 + vec2(0.5, 0.5)); + vec4 color = vec4( + texcoord, + texcoord.x * texcoord.y, + (1.0 - texcoord.x) * texcoord.y * 0.5 + 0.5); + vColor = vec4( + sign_emu(color.x * 2.0 - 1.0) * 0.5 + 0.5, + sign_emu(color.y * 2.0 - 1.0) * 0.5 + 0.5, + 0, + 1); +} +</script> + +<script id="vshaderMacro" type="x-shader/x-vertex"> +attribute vec4 aPosition; +varying vec4 vColor; + +#define sign_emu(value) ((value) == 0.0 ? 0.0 : ((value) > 0.0 ? 1.0 : -1.0)) + +void main() +{ + gl_Position = aPosition; + vec2 texcoord = vec2(aPosition.xy * 0.5 + vec2(0.5, 0.5)); + vec4 color = vec4( + texcoord, + texcoord.x * texcoord.y, + (1.0 - texcoord.x) * texcoord.y * 0.5 + 0.5); + vColor = vec4( + sign_emu(color.x * 2.0 - 1.0) * 0.5 + 0.5, + sign_emu(color.y * 2.0 - 1.0) * 0.5 + 0.5, + 0, + 1); +} +</script> + +<script id="fshader" type="x-shader/x-fragment"> +precision mediump float; +varying vec4 vColor; +void main() +{ + gl_FragColor = vColor; +} +</script> +</head> +<body> +<canvas id="canvasFunction" width="50" height="50"></canvas> +<canvas id="canvasMacro" width="50" height="50"></canvas> +<div id="description">This tests against a Mac driver bug related to function calls.</div> +<div id="console"></div> +<script> +"use strict"; +var width = 50; +var height = 50; +var wtu = WebGLTestUtils; + +function drawAndRead(canvasID, vshaderID, buffer) +{ + var gl = wtu.create3DContext(canvasID); + var program = wtu.setupProgram(gl, [vshaderID, "fshader"], ["aPosition"]); + var vertexObject = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ 0,0.5,0, -0.5,-0.5,0, 0.5,-0.5,0 ]), gl.STATIC_DRAW); + gl.enableVertexAttribArray(0); + gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0); + + gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); + gl.drawArrays(gl.TRIANGLES, 0, 3); + gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, buffer); + if (gl.getError() != gl.NO_ERROR) + return false; + return true; +} + +function compareRendering(buffer1, buffer2, tol) +{ + for (var i = 0; i < width * height * 4; ++i) { + if (Math.abs(buffer1[i] - buffer2[i]) > tol) + return false; + } + return true; +} + +function init() +{ + description("tests function nodes"); + + var bufFunction = new Uint8Array(width * height * 4); + var bufMacro = new Uint8Array(width * height * 4); + + if (drawAndRead("canvasFunction", "vshaderFunction", bufFunction) == false || + drawAndRead("canvasMacro", "vshaderMacro", bufMacro) == false) { + testFailed("Setup failed"); + } else { + if (compareRendering(bufFunction, bufMacro, 4) == false) + testFailed("Rendering results are different"); + else + testPassed("Rendering results are the same"); + } +} + +init(); +var successfullyParsed = true; +</script> +<script src="../../../js/js-test-post.js"></script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/glsl-long-variable-names.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/glsl-long-variable-names.html new file mode 100644 index 000000000..631e3182c --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/glsl-long-variable-names.html @@ -0,0 +1,248 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>glsl long variable name mapping 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> +</head> +<body> +<canvas id="example" width="50" height="50"> +There is supposed to be an example drawing here, but it's not important. +</canvas> +<div id="description"></div> +<div id="console"></div> +<script id="vshader_shared_uniform" type="x-shader/x-vertex"> +attribute vec3 vPosition; +uniform mediump float value01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890; +void main() +{ + gl_Position = vec4(vPosition, value01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890); +} +</script> + +<script id="fshader_shared_uniform" type="x-shader/x-fragment"> +precision mediump float; +uniform float value01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890; +void main() +{ + gl_FragColor = vec4(1.0, 0.0, value01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890, 1.0); +} +</script> + +<script id="vshader_uniform_array" type="x-shader/x-vertex"> +attribute vec3 vPosition; +void main() +{ + gl_Position = vec4(vPosition, 1.0); +} +</script> + +<script id="fshader_uniform_array" type="x-shader/x-fragment"> +precision mediump float; +uniform float color01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567[2]; +void main() +{ + gl_FragColor = vec4(color01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567[0], color01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567[1], 1.0, 1.0); +} +</script> + +<script id="vshader_varying" type="x-shader/x-vertex"> +attribute vec3 vPosition; +varying float value01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890; +void main() +{ + value01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 = 1.0; + gl_Position = vec4(vPosition, 1.0); +} +</script> + +<script id="fshader_varying" type="x-shader/x-fragment"> +precision mediump float; +varying float value01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890; +void main() +{ + gl_FragColor = vec4(value01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890, 0.0, 1.0, 1.0); +} +</script> + +<script id="vshader_local" type="x-shader/x-vertex"> +attribute vec3 vPosition; +void main() +{ + for (int i012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234 = 0; i012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234 < 1; ++i012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234) + { + gl_Position = vec4(vPosition, 1.0); + } +} +</script> + +<script id="fshader_local" type="x-shader/x-fragment"> +precision mediump float; +void main() +{ + for (int i012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234 = 0; i012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234 < 1; ++i012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234) + { + gl_FragColor = vec4(1.0, 0.0, 1.0, 1.0); + } +} +</script> + +<script id="vshader_attrib" type="x-shader/x-vertex"> +attribute vec3 vPosition0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456; +void main() +{ + gl_Position = vec4(vPosition0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456, 1.0); +} +</script> + +<script id="fshader_attrib" type="x-shader/x-fragment"> +precision mediump float; +void main() +{ + gl_FragColor = vec4(1.0, 0.0, 1.0, 1.0); +} +</script> + +<script> +"use strict"; +description("Verify that shader long variable names works fine if they are within 256 characters."); + +debug("Test same long uniform name in both vertex shader and fragment shader"); +var wtu = WebGLTestUtils; +var gl = wtu.create3DContext("example"); +var program = wtu.setupProgram(gl, ["vshader_shared_uniform", "fshader_shared_uniform"], ["vPosition"]); +shouldBeNonNull("gl"); +shouldBe("gl.getError()", "gl.NO_ERROR"); +var prog = gl.getParameter(gl.CURRENT_PROGRAM); +shouldBeNonNull("prog"); +var valueLoc = gl.getUniformLocation(prog, "value01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"); +shouldBeNonNull("valueLoc"); +shouldBe("gl.getProgramParameter(prog, gl.ACTIVE_UNIFORMS)", "1"); +var activeUniform = gl.getActiveUniform(prog, 0); +shouldBeNonNull("activeUniform"); +shouldBe("activeUniform.type", "gl.FLOAT"); +shouldBe("activeUniform.size", "1"); +shouldBe("activeUniform.name", "'value01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'"); +gl.uniform1f(valueLoc, 1.0); +drawAndCheckPixels(gl); +shouldBe("gl.getError()", "gl.NO_ERROR"); +debug(""); + +debug("Test long uniform array name"); +var gl = wtu.create3DContext("example"); +var program = wtu.setupProgram(gl, ["vshader_uniform_array", "fshader_uniform_array"], ["vPosition"]); +shouldBeNonNull("gl"); +shouldBe("gl.getError()", "gl.NO_ERROR"); +var prog = gl.getParameter(gl.CURRENT_PROGRAM); +shouldBeNonNull("prog"); +var redLoc = gl.getUniformLocation(prog, "color01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567[0]"); +shouldBeNonNull("redLoc"); +var greenLoc = gl.getUniformLocation(prog, "color01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567[1]"); +shouldBeNonNull("greenLoc"); +shouldBe("gl.getProgramParameter(prog, gl.ACTIVE_UNIFORMS)", "1"); +var activeUniform = gl.getActiveUniform(prog, 0); +shouldBeNonNull("activeUniform"); +shouldBe("activeUniform.type", "gl.FLOAT"); +shouldBe("activeUniform.size", "2"); +shouldBe("activeUniform.name", "'color01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567[0]'"); +gl.uniform1f(redLoc, 1.0); +gl.uniform1f(greenLoc, 0.0); +drawAndCheckPixels(gl); +shouldBe("gl.getError()", "gl.NO_ERROR"); +debug(""); + +debug("Test long varying name"); +var gl = wtu.create3DContext("example"); +var program = wtu.setupProgram(gl, ["vshader_varying", "fshader_varying"], ["vPosition"]); +shouldBeNonNull("gl"); +shouldBe("gl.getError()", "gl.NO_ERROR"); +var prog = gl.getParameter(gl.CURRENT_PROGRAM); +shouldBeNonNull("prog"); +drawAndCheckPixels(gl); +shouldBe("gl.getError()", "gl.NO_ERROR"); +debug(""); + +debug("Test long local variable name"); +var gl = wtu.create3DContext("example"); +var program = wtu.setupProgram(gl, ["vshader_varying", "fshader_varying"], ["vPosition"]); +shouldBeNonNull("gl"); +shouldBe("gl.getError()", "gl.NO_ERROR"); +var prog = gl.getParameter(gl.CURRENT_PROGRAM); +shouldBeNonNull("prog"); +drawAndCheckPixels(gl); +shouldBe("gl.getError()", "gl.NO_ERROR"); +debug(""); + +debug("Test long attribute name"); +var gl = wtu.create3DContext("example"); +var program = wtu.setupProgram(gl, ["vshader_attrib", "fshader_attrib"], ["vPosition0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456"]); +shouldBeNonNull("gl"); +shouldBe("gl.getError()", "gl.NO_ERROR"); +var prog = gl.getParameter(gl.CURRENT_PROGRAM); +shouldBeNonNull("prog"); +shouldBe("gl.getProgramParameter(prog, gl.ACTIVE_ATTRIBUTES)", "1"); +var activeAttrib = gl.getActiveAttrib(prog, 0); +shouldBeNonNull("activeAttrib"); +shouldBe("activeAttrib.size", "1"); +shouldBe("activeAttrib.type", "gl.FLOAT_VEC3"); +shouldBe("activeAttrib.name", "'vPosition0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456'"); +drawAndCheckPixels(gl); +shouldBe("gl.getError()", "gl.NO_ERROR"); +debug(""); + +function drawAndCheckPixels(gl) +{ + var vertexObject = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ 0,0.5,0, -0.5,-0.5,0, 0.5,-0.5,0 ]), gl.STATIC_DRAW); + gl.enableVertexAttribArray(0); + gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0); + + gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); + gl.drawArrays(gl.TRIANGLES, 0, 3); + + // Test several locations + // First line should be all black + wtu.checkCanvasRect(gl, 0, 0, 50, 1, [0, 0, 0, 0]); + + // Line 15 should be magenta for at least 10 pixels starting 20 pixels in + wtu.checkCanvasRect(gl, 20, 15, 10, 1, [255, 0, 255, 255]); + + // Last line should be all black + wtu.checkCanvasRect(gl, 0, 49, 50, 1, [0, 0, 0, 0]); +} + +var successfullyParsed = true; +</script> +<script src="../../../js/js-test-post.js"></script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/glsl-vertex-branch.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/glsl-vertex-branch.html new file mode 100644 index 000000000..b790a89b2 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/glsl-vertex-branch.html @@ -0,0 +1,149 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL function nodes Test</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="vshaderNoBranch" type="x-shader/x-vertex"> +attribute vec3 aPosition; +uniform float redIntensity; + +varying vec4 vColor; + +float MADBug(float paramValue) { + float localVar = 1.0; + return 0.25 * ceil(localVar) + paramValue; +} + +void main(void) { + gl_Position = vec4(aPosition, 1.0); + vColor = vec4(MADBug(redIntensity), 0., 0., 1.); +} +</script> + +<script id="vshaderBranch" type="x-shader/x-vertex"> +attribute vec3 aPosition; +uniform float redIntensity; + +varying vec4 vColor; + +float MADBug(float paramValue) { + float localVar = 1.0; + return 0.25 * ceil(localVar) + paramValue; +} + +void main(void) { + float condition = 42.; + if (condition == 0.) {} + gl_Position = vec4(aPosition, 1.0); + vColor = vec4(MADBug(redIntensity), 0., 0., 1.); +} +</script> + +<script id="fshader" type="x-shader/x-fragment"> +precision mediump float; + +varying vec4 vColor; +void main() +{ + gl_FragColor = vColor; +} +</script> +</head> +<body> +<canvas id="canvasNoBranch" width="50" height="50"></canvas> +<canvas id="canvasBranch" width="50" height="50"></canvas> +<div id="description">This tests against a Mac driver bug related to branches + inside of Vertex Shaders.</div> +<div id="console"></div> +<script> +"use strict"; +var width = 50; +var height = 50; +var wtu = WebGLTestUtils; + +function drawAndRead(canvasID, vshaderID, buffer) +{ + var gl = wtu.create3DContext(canvasID); + var program = wtu.setupProgram(gl, [vshaderID, "fshader"], ["aPosition"]); + var vertexObject = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ 0,0.5,0, -1,-1,0, 1,-1,0 ]), gl.STATIC_DRAW); + gl.enableVertexAttribArray(0); + gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0); + + var loc = gl.getUniformLocation(program, "redIntensity"); + gl.uniform1f(loc, 0.75); + gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); + gl.drawArrays(gl.TRIANGLES, 0, 3); + gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, buffer); + if (gl.getError() != gl.NO_ERROR) + return false; + return true; +} + +function compareRendering(buffer1, buffer2, tol) +{ + for (var i = 0; i < width * height * 4; ++i) { + if (Math.abs(buffer1[i] - buffer2[i]) > tol) + return false; + } + return true; +} + +function init() +{ + description("tests vertex shader with branch"); + + var bufBranch = new Uint8Array(width * height * 4); + var bufNoBranch = new Uint8Array(width * height * 4); + + if (drawAndRead("canvasBranch", "vshaderBranch", bufBranch) == false || + drawAndRead("canvasNoBranch", "vshaderNoBranch", bufNoBranch) == false) { + testFailed("Setup failed"); + } else { + if (compareRendering(bufBranch, bufNoBranch, 4) == false) + testFailed("Rendering results are different"); + else + testPassed("Rendering results are the same"); + } +} + +init(); +var successfullyParsed = true; +</script> +<script src="../../../js/js-test-post.js"></script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/include.vs b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/include.vs new file mode 100644 index 000000000..50970e6cc --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/include.vs @@ -0,0 +1,4 @@ +// Do not delete! +// Needed to help glsl-conformance tests. + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/large-loop-compile.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/large-loop-compile.html new file mode 100644 index 000000000..f264b08a4 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/large-loop-compile.html @@ -0,0 +1,193 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script id="vertexShader" type="text/something-not-javascript"> +attribute vec2 position; + +void main(){ + gl_Position = vec4(position, 0.0, 1.0); +} +</script> +<script id="fragmentShader" type="text/something-not-javascript"> +precision mediump float; +uniform sampler2D source; + +mat3 front = mat3( + 1.0, 0.0, 0.0, + 0.0, 1.0, 0.0, + 0.0, 0.0, 1.0 +); + +mat3 back = mat3( + -1.0, 0.0, 0.0, + 0.0, 1.0, 0.0, + 0.0, 0.0, -1.0 +); + +mat3 left = mat3( + 0.0, 0.0, -1.0, + 0.0, 1.0, 0.0, + 1.0, 0.0, 0.0 +); + +mat3 right = mat3( + 0.0, 0.0, 1.0, + 0.0, 1.0, 0.0, + -1.0, 0.0, 0.0 +); + +mat3 up = mat3( + 1.0, 0.0, 0.0, + 0.0, 0.0, 1.0, + 0.0, -1.0, 0.0 +); + +mat3 down = mat3( + 1.0, 0.0, 0.0, + 0.0, 0.0, -1.0, + 0.0, 1.0, 0.0 +); + +float coefficient(vec3 normal){ + int index = int(gl_FragCoord.x); + float x = normal.x; + float y = normal.y; + float z = normal.z; + + if(index==0){ + return 1.0; + } + else if(index==1){ + return y; + } + else if(index==2){ + return z; + } + else if(index==3){ + return x; + } + else if(index==4){ + return x*y; + } + else if(index==5){ + return y*z; + } + else if(index==6){ + return 3.0*z*z - 1.0; + } + else if(index==7){ + return x*z; + } + else{ + return x*x - y*y; + } +} + +vec3 sample(float cidx, mat3 side){ + vec3 result = vec3(0.0); + float divider = 0.0; + + for(int i=0; i<256; i++){ + float x = mod(float(i), 16.0); + float y = float(i/16); + vec2 texcoord = (vec2(x+cidx*16.0, y+floor(gl_FragCoord.y)*16.0)+0.5)/6.0; + vec2 sidecoord = ((vec2(x,y)+vec2(0.5, 0.5))/vec2(16.0))*2.0-1.0; + vec3 normal = normalize(vec3(sidecoord, -1.0)); + vec3 texel = texture2D(source, texcoord).rgb; + result += coefficient(side*normal) * texel * -normal.z; + divider += -normal.z; + } + return result/divider; +} + +void main(){ + vec3 result = ( + //sample(0.0, front) + + //sample(1.0, back) + + sample(2.0, left) + + sample(3.0, right) + + sample(4.0, up) + + sample(5.0, down) + )/6.0; + gl_FragColor = vec4(result, 1.0); +} +</script> +<script> +"use strict"; +var receivedContextLost = false; +description("Ensures that compilation of a large loop completes in a reasonable period of time and does not cause the WebGL context to be lost"); +var wtu = WebGLTestUtils; +var canvas = document.createElement('canvas'); +canvas.width = 32; +canvas.height = 32; +canvas.addEventListener("webglcontextlost", function(e) { + testFailed("context was lost during shader compilation or linking"); + receivedContextLost = true; +}); +var gl = wtu.create3DContext(canvas); +if (!gl) { + testFailed("context does not exist"); + finishTest(); +} else { + var startTime = Date.now(); + wtu.setupProgram(gl, ["vertexShader", "fragmentShader"], undefined, undefined, true); + gl.clearColor(0.0, 1.0, 0.0, 1.0); + gl.clear(gl.COLOR_BUFFER_BIT); + wtu.checkCanvas(gl, [0, 255, 0, 255], "should be green", 0); + var endTime = Date.now(); + + // Delay for some period to increase chances that context lost event will be delivered. + setTimeout(function() { + if (!receivedContextLost) { + testPassed("Large loop compiled and linked without terminating the WebGL context"); + if (endTime - startTime < 5000) { + testPassed("Shader compilation completed in a reasonable amount of time"); + } else { + testFailed("Shader compilation took an unreasonably long time"); + } + } + finishTest(); + }, 500); +} +var successfullyParsed = true; +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/non-ascii-comments.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/non-ascii-comments.vert.html new file mode 100644 index 000000000..a817654f5 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/non-ascii-comments.vert.html @@ -0,0 +1,59 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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"> +// Non ascii comments in source should succeed +// ‚±‚ê‚Í‚`‚r‚b‚h‚h‚Å‚Í‚È‚¢‚Å‚·B +// ‚s‚ˆ‚‰‚“@‚h‚“@‚m‚‚”@‚`‚r‚b‚h‚h +/* + * ‚s‚ˆ‚‰‚“@‚h‚“@‚m‚‚”@‚`‚r‚b‚h‚h + */ +void main() { + gl_Position = vec4(1,1,1,1); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/non-ascii.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/non-ascii.vert.html new file mode 100644 index 000000000..61428b0cb --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/non-ascii.vert.html @@ -0,0 +1,58 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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"> +// Non ascii data in source should fail +// See GLSL ES Spec 1.0.17 section 3.1 and 3.2 +// ‚±‚ê‚Í‚`‚r‚b‚h‚h‚Å‚Í‚È‚¢‚Å‚·B +// ‚s‚ˆ‚‰‚“@‚h‚“@‚m‚‚”@‚`‚r‚b‚h‚h +uniform mat4 ‚m‚‚”‚`‚r‚b‚h‚h; +void main() { + gl_Position = vec4(1,1,1,1); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/re-compile-re-link.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/re-compile-re-link.html new file mode 100644 index 000000000..aa131a671 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/re-compile-re-link.html @@ -0,0 +1,171 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL Re-Compile and Re-link Shader conformance 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="4" height="4" style="width: 40px; height: 30px;"></canvas> +<div id="description"></div> +<div id="console"></div> +<script id="vshader" type="x-shader/x-vertex"> +attribute float column; +attribute float height; +uniform float position; +void main() { + gl_Position = vec4(mod(column - position, 1.0) * 2.0 - 1.0, height, 0, 1); +} +</script> + +<script id="fshader1" type="x-shader/x-fragment"> +precision mediump float; +void main() { + gl_FragColor = vec4(1,0,0,1); +} +</script> +<script id="fshader2" type="x-shader/x-fragment"> +precision mediump float; +uniform float foobar; +void main() { + gl_FragColor = vec4(1,0,foobar,1); +} +</script> +<script id="vshaderB" type="not-js"> +attribute vec2 position; +varying vec2 v_texCoord; +void main() { + gl_Position = vec4(position, 0, 1); + v_texCoord = vec2(position * 0.5 + 0.5); +} +</script> +<script id="fshaderB" type="not-js"> +precision mediump float; +varying vec2 v_texCoord; +uniform sampler2D tex; +void main() { + gl_FragColor = texture2D(tex, v_texCoord); +} +</script> + +<script> +"use strict"; +description(document.title); +var wtu = WebGLTestUtils; +var gl = wtu.create3DContext("example"); + +var vsSource = document.getElementById("vshader").text; +var fs1Source = document.getElementById("fshader1").text; +var fs2Source = document.getElementById("fshader2").text; + +var vsSourceB = document.getElementById("vshaderB").text; +var fsSourceB = document.getElementById("fshaderB").text; + +var vShader = gl.createShader(gl.VERTEX_SHADER); +var fShader = gl.createShader(gl.FRAGMENT_SHADER); + +var vShaderB = gl.createShader(gl.VERTEX_SHADER); +var fShaderB = gl.createShader(gl.FRAGMENT_SHADER); + +var program = gl.createProgram(); +var programB = gl.createProgram(); + +gl.attachShader(program, vShader); +gl.attachShader(program, fShader); + +gl.attachShader(programB, vShaderB); +gl.attachShader(programB, fShaderB); + +var success; +var shader; + +function checkShaderStatus(s) { + shader = s; + shouldBeTrue("success = gl.getShaderParameter(shader, gl.COMPILE_STATUS)"); + if (!success) { + debug("error: " + gl.getShaderInfoLog()); + } +} + +var prg; +function checkProgramStatus(p) { + prg = p; + shouldBeTrue("success = gl.getProgramParameter(prg, gl.LINK_STATUS)"); + if (!success) { + debug("error: " + gl.getProgramInfoLog(prg)); + } +} + +for (var i = 0; i < 10; ++i) { + gl.shaderSource(vShader, vsSource); + gl.compileShader(vShader); + checkShaderStatus(vShader) + gl.shaderSource(fShader, fs1Source); + gl.compileShader(fShader); + checkShaderStatus(fShader) + + gl.linkProgram(program); + checkProgramStatus(program) + gl.useProgram(program); + + gl.shaderSource(vShaderB, vsSourceB); + gl.compileShader(vShaderB); + checkShaderStatus(vShaderB) + gl.shaderSource(fShaderB, fsSourceB); + gl.compileShader(fShaderB); + checkShaderStatus(fShaderB) + + gl.linkProgram(programB); + checkProgramStatus(programB) + + gl.useProgram(programB); +} + +for (var i = 0; i < 10; ++i) { + // Now change the fragment shader + gl.shaderSource(fShader, fs2Source); + gl.compileShader(fShader); + checkShaderStatus(fShader) + + // And re-link + gl.linkProgram(program); + checkProgramStatus(program) +} + +wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors"); + +var successfullyParsed = true; +</script> +<script src="../../../js/js-test-post.js"></script> + +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/sequence-operator-returns-constant.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/sequence-operator-returns-constant.html new file mode 100644 index 000000000..bd73f224a --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/sequence-operator-returns-constant.html @@ -0,0 +1,81 @@ +<!-- + +/* +** Copyright (c) 2015 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>Sequence operator returns constant test</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="fshader-const-expression" type="x-shader/x-fragment"> +precision mediump float; +void main() +{ + // RHS should be a constant expression (a compile-time constants) stated in section 4.3.2 from GLESSL 1.0.17 + const float a = (0.0, 1.0); +} +</script> +<script id="fshader-non-const-expression" type="x-shader/x-fragment"> +precision mediump float; +void main() +{ + float a[(2, 3)]; +} +</script> +<script> +"use strict"; +description("Checks sequence operators returning constants and can be used as an array size."); + +var wtu = WebGLTestUtils; +var gl = wtu.create3DContext(); + +GLSLConformanceTester.runTests([ +{ fShaderId: 'fshader-const-expression', + fShaderSuccess: true, + linkSuccess: true, + passMsg: "Sequence operator can return a constant expression", +}, +{ fShaderId: 'fshader-non-const-expression', + fShaderSuccess: true, + linkSuccess: true, + passMsg: "Sequence operator return value can be used as array size", +}, +]); + +debug(""); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-precision-format-obeyed.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-precision-format-obeyed.html new file mode 100644 index 000000000..dbfdd3c7d --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-precision-format-obeyed.html @@ -0,0 +1,104 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fshaderWithHighPrecision" type="text/something-not-javascript"> +precision highp float; +uniform vec4 constantColor; + +void main() +{ + gl_FragColor = constantColor; +} +</script> +<script id="fshaderWhichCompilesWithHighp" type="text/something-not-javascript"> +#ifdef GL_FRAGMENT_PRECISION_HIGH +// Something which compiles +#else +somethingWhichDoesNotCompile(); +#endif + +void main() +{ + gl_FragColor = vec4(0, 0, 0, 1); +} +</script> +<script id="fshaderWhichCompilesWithoutHighp" type="text/something-not-javascript"> +#ifndef GL_FRAGMENT_PRECISION_HIGH +// Something which compiles +#else +somethingWhichDoesNotCompile(); +#endif + +void main() +{ + gl_FragColor = vec4(0, 0, 0, 1); +} +</script> +<script> +"use strict"; +description("Checks that getShaderPrecisionFormat's return value matches whether highp is supported in fragment shaders."); + +var wtu = WebGLTestUtils; +var gl = wtu.create3DContext(); +var precision = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT); +var highpSupported = (precision.rangeMin >= 62 && precision.rangeMax >= 62 && precision.precision >= 16); +debug("highp is" + (highpSupported ? "" : " not") + " supported in fragment shaders"); + +GLSLConformanceTester.runTests([ +{ + fShaderId: 'fshaderWithHighPrecision', + fShaderSuccess: highpSupported, + linkSuccess: highpSupported, + passMsg: "getShaderPrecisionFormat's results agree with highp support in fragment shaders", +}, +{ + fShaderId: highpSupported ? 'fshaderWhichCompilesWithHighp' : 'fshaderWhichCompilesWithoutHighp', + fShaderSuccess: true, + linkSuccess: true, + passMsg: "getShaderPrecisionFormat's results agree with definition of GL_FRAGMENT_PRECISION_HIGH", +}, +]); + +debug(""); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-struct-scope.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-struct-scope.html new file mode 100644 index 000000000..37340c5a1 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-struct-scope.html @@ -0,0 +1,252 @@ +<!-- + +/* +** Copyright (c) 2014 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!-- author: Jamie Madill (jmadill at chromium) --> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Struct Scope Test</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="shader-vs-1" type="x-shader/x-vertex"> +void main(void) { + + gl_Position = vec4(0.0, 0.0, 0.0, 1.0); + + { + struct T { + int v1; + }; + + T x; + gl_Position.x += float(x.v1); + } + + { + struct T { + float v2; + }; + + T x; + gl_Position.x += x.v2; + } + +} +</script> + +<script id="shader-vs-2" type="x-shader/x-vertex"> +void main(void) { + + gl_Position = vec4(0.0, 0.0, 0.0, 1.0); + + struct T { + int v1; + }; + + T x; + gl_Position.x += float(x.v1); + + { + struct T { + float v2; + }; + + T x; + gl_Position.x += x.v2; + } + +} +</script> + +<script id="shader-vs-3" type="x-shader/x-vertex"> +void main(void) { + + gl_Position = vec4(0.0, 0.0, 0.0, 1.0); + + { + struct T { + int v1; + }; + + T x; + gl_Position.x += float(x.v1); + } + + struct T { + float v2; + }; + + T x; + gl_Position.x += x.v2; +} +</script> + +<script id="shader-vs-bad" type="x-shader/x-vertex"> +void main(void) { + + gl_Position = vec4(0.0, 0.0, 0.0, 1.0); + + struct T { + int v1; + }; + + T x; + gl_Position.x += float(x.v1); + + struct T { + float v2; + }; + + T y; + gl_Position.x += y.v2; +} +</script> + +<script id="shader-vs-anglebug" type="x-shader/x-vertex"> + +struct T_0 { + int v1; +}; + +void main(void) { + + gl_Position = vec4(0.0, 0.0, 0.0, 1.0); + + struct T { + float v2; + }; + + T_0 x; + gl_Position.x += float(x.v1); + + T y; + gl_Position.x += y.v2; +} +</script> + +<script id="shader-vs-masked-struct-variable" type="x-shader/x-vertex"> + +struct T { + float f; +}; + +void main(void) { + + T a; + + gl_Position = vec4(0.0, 0.0, 0.0, 1.0); + + struct T { + float q; + }; + + gl_Position.x += a.f; + + T b; + gl_Position.x += b.q; +} +</script> + +<script id="shader-fs" type="x-shader/x-fragment"> +precision mediump float; +void main(void) { + gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); +} +</script> + +<script> +"use strict"; +description("Testing struct definition scope"); + +var wtu = WebGLTestUtils; +GLSLConformanceTester.runTests([ + { + vShaderId: "shader-vs-1", + vShaderSuccess: true, + fShaderId: "shader-fs", + fShaderSuccess: true, + linkSuccess: true, + passMsg: "Two structs defined within non-overlapping scopes should be able to use the same name", + }, + { + vShaderId: "shader-vs-2", + vShaderSuccess: true, + fShaderId: "shader-fs", + fShaderSuccess: true, + linkSuccess: true, + passMsg: "A struct defined inside a scope overrides a struct defined in a outer scope with the same name", + }, + { + vShaderId: "shader-vs-3", + vShaderSuccess: true, + fShaderId: "shader-fs", + fShaderSuccess: true, + linkSuccess: true, + passMsg: "A struct can use the same name of another out-of-scope struct", + }, + { + vShaderId: "shader-vs-bad", + vShaderSuccess: false, + fShaderId: "shader-fs", + fShaderSuccess: true, + linkSuccess: false, + passMsg: "A struct can't be defined with the same name as another struct defined in the same scope", + }, + { + vShaderId: "shader-vs-anglebug", + vShaderSuccess: true, + fShaderId: "shader-fs", + fShaderSuccess: true, + linkSuccess: true, + passMsg: "Structs with appended underscored numbers don't cause link errors (ANGLE bug)", + }, + { + vShaderId: "shader-vs-masked-struct-variable", + vShaderSuccess: true, + fShaderId: "shader-fs", + fShaderSuccess: true, + linkSuccess: true, + passMsg: "Variables of masked outer scope struct work with inner scope struct", + }, +]); + +debug(""); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-uniform-packing-restrictions.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-uniform-packing-restrictions.html new file mode 100644 index 000000000..87d44927f --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-uniform-packing-restrictions.html @@ -0,0 +1,272 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL uniform packing restrctions Conformance Test</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> +<canvas id="example" width="2" height="2"> </canvas> +<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-vertex"> +precision mediump float; +varying vec4 v_varying; +void main() +{ + gl_FragColor = v_varying; +} +</script> +<script id="vshaderArrayTest" type="x-shader/x-vertex"> +attribute vec4 a_position; +varying vec4 v_varying; +uniform $(type) u_uniform[$(numTestType)]; +void main() +{ + v_varying = $(result); + gl_Position = a_position; +} +</script> +<script id="fshaderArrayTest" type="x-shader/x-fragment"> +precision mediump float; +uniform $(type) u_uniform[$(numTestType)]; +void main() +{ + gl_FragColor = $(result); +} +</script> +<script id="vshaderUniformTest" type="x-shader/x-fragment"> +attribute vec4 a_position; +varying vec4 v_varying; +$(uniforms) +void main() +{ + $(code) + v_varying = $(result); + gl_Position = a_position; +} +</script> +<script id="fshaderUniformTest" type="x-shader/x-fragment"> +precision mediump float; +$(uniforms) +void main() +{ + $(code) + gl_FragColor = $(result); +} +</script> +<script> +"use strict"; +description(); +debug(""); +var wtu = WebGLTestUtils; +var gl = wtu.create3DContext("example"); + +var uniformTypes = [ + { type: "bool", componentsPerRow: 1, rows: 1, fType: "float", uniToF: "float(u_uniform$(id)$(index))", fToVec4: "vec4($(f), 0, 0, 0)"}, + { type: "float", componentsPerRow: 1, rows: 1, fType: "float", uniToF: "u_uniform$(id)$(index)", fToVec4: "vec4($(f), 0, 0, 0)"}, + { type: "int", componentsPerRow: 1, rows: 1, fType: "float", uniToF: "float(u_uniform$(id)$(index))", fToVec4: "vec4($(f), 0, 0, 0)"}, + { type: "vec2", componentsPerRow: 2, rows: 1, fType: "vec2", uniToF: "u_uniform$(id)$(index)", fToVec4: "vec4($(f), 0, 0)"}, + { type: "ivec2", componentsPerRow: 2, rows: 1, fType: "vec2", uniToF: "vec2(u_uniform$(id)$(index))", fToVec4: "vec4($(f), 0, 0)"}, + { type: "bvec2", componentsPerRow: 2, rows: 1, fType: "vec2", uniToF: "vec2(u_uniform$(id)$(index))", fToVec4: "vec4($(f), 0, 0)"}, + { type: "vec3", componentsPerRow: 3, rows: 1, fType: "vec3", uniToF: "u_uniform$(id)$(index)", fToVec4: "vec4($(f), 0)"}, + { type: "ivec3", componentsPerRow: 3, rows: 1, fType: "vec3", uniToF: "vec3(u_uniform$(id)$(index))", fToVec4: "vec4($(f), 0)"}, + { type: "bvec3", componentsPerRow: 3, rows: 1, fType: "vec3", uniToF: "vec3(u_uniform$(id)$(index))", fToVec4: "vec4($(f), 0)"}, + { type: "vec4", componentsPerRow: 4, rows: 1, fType: "vec4", uniToF: "u_uniform$(id)$(index)", fToVec4: "$(f)"}, + { type: "ivec4", componentsPerRow: 4, rows: 1, fType: "vec4", uniToF: "vec4(u_uniform$(id)$(index))", fToVec4: "$(f)"}, + { type: "bvec4", componentsPerRow: 4, rows: 1, fType: "vec4", uniToF: "vec4(u_uniform$(id)$(index))", fToVec4: "$(f)"}, +// Yes, the spec says mat2 takes 4 columns, 2 rows. + { type: "mat2", componentsPerRow: 4, rows: 2, fType: "vec2", uniToF: "vec2(u_uniform$(id)$(index)[0])", fToVec4: "vec4($(f), 0, 0)"}, + { type: "mat3", componentsPerRow: 3, rows: 3, fType: "vec3", uniToF: "vec3(u_uniform$(id)$(index)[0])", fToVec4: "vec4($(f), 0)"}, + { type: "mat4", componentsPerRow: 4, rows: 4, fType: "vec4", uniToF: "vec4(u_uniform$(id)$(index)[0])", fToVec4: "$(f)"}, +// Samplers generally have more restrictive limits. +// { type: "sampler2D", componentsPerRow: 1, rows: 1, code: "vec4(texture2D(u_uniform[$(index)], vec2(0, 0)))", }, +// { type: "samplerCube", componentsPerRow: 1, rows: 1, code: "vec4(textureCube(u_uniform[$(index)], vec3(0, 0, 0)))", }, +]; + +var vBaseSource = wtu.getScript("vshader"); +var fBaseSource = wtu.getScript("fshader"); +var vArrayTestSource = wtu.getScript("vshaderArrayTest"); +var fArrayTestSource = wtu.getScript("fshaderArrayTest"); +var vUniformTestSource = wtu.getScript("vshaderUniformTest"); +var fUniformTestSource = wtu.getScript("fshaderUniformTest"); + +var tests = []; +var shaderTypes = [ + { type: "vertex", + // For tests that expect failure which shader might fail. + vertExpectation: false, + fragExpectation: true, + vertArrayTest: vArrayTestSource, + fragArrayTest: fBaseSource, + vertUniformTest: vUniformTestSource, + fragUniformTest: fBaseSource, + maxVectors: gl.getParameter(gl.MAX_VERTEX_UNIFORM_VECTORS), + minVectors: 127, // GLSL ES 1.0.17 Appendix A.7 and A.8. Reserve one row for constants in the code, hence 128 - 1. + }, + { type: "fragment", + // For tests that expect failure which shader might fail. + vertExpectation: true, + fragExpectation: false, + vertArrayTest: vBaseSource, + fragArrayTest: fArrayTestSource, + vertUniformTest: vBaseSource, + fragUniformTest: fUniformTestSource, + maxVectors: gl.getParameter(gl.MAX_FRAGMENT_UNIFORM_VECTORS), + minVectors: 15, // GLSL ES 1.0.17 Appendix A.8 - minimum value of gl_maxFragmentUniformVectors is 16. Again, reserve a row for constants. + }, +]; +for (var ss = 0; ss < shaderTypes.length; ++ss) { + var shaderType = shaderTypes[ss]; + debug("max " + shaderType.type + ": " + shaderType.maxVectors); + for (var ii = 0; ii < uniformTypes.length; ++ii) { + var info = uniformTypes[ii]; + wtu.log("checking: " + info.type); + // Compute the maximum amount of this type allowed in a single array. + var maxInArray = Math.floor(shaderType.maxVectors / info.rows); + // Compute the minimum required to work in a single array. + var minVars = Math.floor(shaderType.minVectors / info.rows); + // Compute the maximum allowed as single elements + var maxPerRow = Math.floor(4 / info.componentsPerRow); + var maxPacked = Math.floor(shaderType.maxVectors * maxPerRow / info.rows); + + // Test array[1] of the type + var uniToF = wtu.replaceParams(info.uniToF, {id: "", index: "[0]"}); + var vec4 = wtu.replaceParams(info.fToVec4, {f: uniToF}); + tests.push({ + vShaderSource: wtu.replaceParams(shaderType.vertArrayTest, {numTestType: 1, result: vec4}, info), + vShaderSuccess: true, + fShaderSource: wtu.replaceParams(shaderType.fragArrayTest, {numTestType: 1, result: vec4}, info), + fShaderSuccess: true, + linkSuccess: true, + passMsg: shaderType.type + " shader with uniform array of " + info.type + " with 1 element should succeed", + }); + + // Note: We can't test an array filling all uniform space as actual GL drivers are + // only required to be able to do the minimum number. After that it can fail for + // multiple reasons, including uniform registers being reserved for the implementation's + // own use. Constants also take up uniform registers. + + // Test required number of uniforms + var uniToF = wtu.replaceParams(info.uniToF, {id: "", index: "[" + (minVars - 1) + "]"}); + var vec4 = wtu.replaceParams(info.fToVec4, {f: uniToF}); + tests.push({ + vShaderSource: wtu.replaceParams(shaderType.vertArrayTest, {numTestType: minVars, result: vec4}, info), + vShaderSuccess: true, + fShaderSource: wtu.replaceParams(shaderType.fragArrayTest, {numTestType: minVars, result: vec4}, info), + fShaderSuccess: true, + linkSuccess: true, + passMsg: shaderType.type + " shader with uniform array of " + info.type + " with " + minVars + " elements (the minimum required) should succeed", + }); + + // Test array[max + 1] accessing last element. WebGL requires this to fail. + var uniToF = wtu.replaceParams(info.uniToF, {id: "", index: "[" + maxInArray + "]"}); + var vec4 = wtu.replaceParams(info.fToVec4, {f: uniToF}); + tests.push({ + vShaderSource: wtu.replaceParams(shaderType.vertArrayTest, {numTestType: maxInArray + 1, result: vec4}, info), + vShaderSuccess: shaderType.vertExpectation, + fShaderSource: wtu.replaceParams(shaderType.fragArrayTest, {numTestType: maxInArray + 1, result: vec4}, info), + fShaderSuccess: shaderType.fragExpectation, + linkSuccess: false, + passMsg: shaderType.type + " shader with uniform array of " + info.type + " with " + (maxInArray + 1) + " elements (one past maximum) accessing last element should fail", + }); + + // Test array[max + 1] accessing first element. WebGL requires this to fail but ES allows truncating array. + var uniToF = wtu.replaceParams(info.uniToF, {id: "", index: "[0]"}); + var vec4 = wtu.replaceParams(info.fToVec4, {f: uniToF}); + tests.push({ + vShaderSource: wtu.replaceParams(shaderType.vertArrayTest, {numTestType: maxInArray + 1, result: vec4}, info), + vShaderSuccess: shaderType.vertExpectation, + fShaderSource: wtu.replaceParams(shaderType.fragArrayTest, {numTestType: maxInArray + 1, result: vec4}, info), + fShaderSuccess: shaderType.fragExpectation, + linkSuccess: false, + passMsg: shaderType.type + " shader with uniform array of " + info.type + " with " + (maxInArray + 1) + " elements (one past maximum) accessing first element should fail", + }); + + // Note: We can't test max uniforms as actual GL drivers are only required to be able + // to do the minimum number. After that it can fail for multiple reasons, including + // uniform registers being reserved for the implementation's own use or also instruction + // space limitations. Strictly speaking, guaranteed supported length of a shader + // executable is defined by the GLES2 conformance tests according to GLSL ES 1.0.17 + // Appendix A.2. This does not give us an exact limit: this test only aims to fit within + // instruction space limits imposed by existing GLES2 compliant hardware. + + var generateCode = function(numVars) { + var uniforms = []; + var sumTerms = []; + for (var uu = 0; uu < numVars; ++uu) { + uniforms.push(" uniform " + info.type + " u_uniform" + uu + ";"); + sumTerms.push(wtu.replaceParams(info.uniToF, {id: uu, index: ""})); + } + return { + uniforms: uniforms.join("\n"), + code: info.fType + " sum = " + sumTerms.join(" + \n ") + ";", + result: wtu.replaceParams(info.fToVec4, {f: 'sum'}) + }; + }; + + // Test max+1 uniforms of type. + tests.push({ + vShaderSource: wtu.replaceParams(shaderType.vertUniformTest, generateCode(maxPacked + 1), info), + vShaderSuccess: shaderType.vertExpectation, + fShaderSource: wtu.replaceParams(shaderType.fragUniformTest, generateCode(maxPacked + 1), info), + fShaderSuccess: shaderType.fragExpectation, + linkSuccess: false, + passMsg: shaderType.type + " shader with " + (maxPacked + 1) + " uniforms of " + info.type + " (one past maximum) should fail", + }); + + // Test required uniforms of type. + tests.push({ + vShaderSource: wtu.replaceParams(shaderType.vertUniformTest, generateCode(minVars), info), + vShaderSuccess: true, + fShaderSource: wtu.replaceParams(shaderType.fragUniformTest, generateCode(minVars), info), + fShaderSuccess: true, + linkSuccess: true, + passMsg: shaderType.type + " shader with " + minVars + " uniforms of " + info.type + " (the minimum required) should succeed", + }); + } +} +GLSLConformanceTester.runTests(tests); +var successfullyParsed = true; +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-varying-packing-restrictions.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-varying-packing-restrictions.html new file mode 100644 index 000000000..24cf0f0e2 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-varying-packing-restrictions.html @@ -0,0 +1,209 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL varying packing restrictions Conformance Test</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> +<canvas id="example" width="2" height="2"> </canvas> +<script id="vshaderArrayTest" type="x-shader/x-vertex"> +attribute vec4 a_position; +varying $(type) v_varying[$(numTestType)]; +void main() +{ + gl_Position = a_position; + $(vcode) +} +</script> +<script id="fshaderArrayTest" type="x-shader/x-fragment"> +precision mediump float; +varying $(type) v_varying[$(numTestType)]; +void main() +{ + gl_FragColor = $(fcode); +} +</script> +<script id="vshaderVaryingTest" type="x-shader/x-fragment"> +attribute vec4 a_position; +$(varyings) +void main() +{ + gl_Position = a_position; + $(vcode) +} +</script> +<script id="fshaderVaryingTest" type="x-shader/x-fragment"> +precision mediump float; +$(varyings) +void main() +{ + gl_FragColor = $(fcode); +} +</script> +<script> +"use strict"; +description(); +debug(""); +var wtu = WebGLTestUtils; +var gl = wtu.create3DContext("example"); + +var varyingTypes = [ + { type: "float", componentsPerRow: 1, rows: 1, vcode: "v_varying$(id)$(index) = 1.0;", fcode: "vec4(v_varying$(id)$(index), 0, 0, 0)", }, + { type: "vec2", componentsPerRow: 2, rows: 1, vcode: "v_varying$(id)$(index) = vec2(0, 0);", fcode: "vec4(v_varying$(id)$(index), 0, 0)", }, + { type: "vec3", componentsPerRow: 3, rows: 1, vcode: "v_varying$(id)$(index) = vec3(0, 0, 0);", fcode: "vec4(v_varying$(id)$(index), 0)", }, + { type: "vec4", componentsPerRow: 4, rows: 1, vcode: "v_varying$(id)$(index) = vec4(0, 0, 0, 0);", fcode: "vec4(v_varying$(id)$(index))", }, +// Yes, the spec says mat2 takes 4 columns, 2 rows. + { type: "mat2", componentsPerRow: 4, rows: 2, vcode: "v_varying$(id)$(index) = mat2(1.0);", fcode: "vec4(v_varying$(id)$(index)[0], 0, 0)", }, + { type: "mat3", componentsPerRow: 3, rows: 3, vcode: "v_varying$(id)$(index) = mat3(1.0);", fcode: "vec4(v_varying$(id)$(index)[0], 0)", }, + { type: "mat4", componentsPerRow: 4, rows: 4, vcode: "v_varying$(id)$(index) = mat4(1.0);", fcode: "vec4(v_varying$(id)$(index)[0])", }, +]; + +var vArrayTestSource = wtu.getScript("vshaderArrayTest"); +var fArrayTestSource = wtu.getScript("fshaderArrayTest"); +var vVaryingTestSource = wtu.getScript("vshaderVaryingTest"); +var fVaryingTestSource = wtu.getScript("fshaderVaryingTest"); + +var minVaryingVectors = 8; +var maxVaryingVectors = gl.getParameter(gl.MAX_VARYING_VECTORS); +var tests = []; + +for (var ii = 0; ii < varyingTypes.length; ++ii) { + var info = varyingTypes[ii]; + wtu.log("checking: " + info.type); + // Compute the maximum amount of this type allowed in a single array. + var numVars = Math.floor(maxVaryingVectors / info.rows); + // Compute the minimum required to work in a single array. + var minVars = Math.floor(minVaryingVectors / info.rows); + // Compute the maximum allowed as single elements + var numPerRow = Math.floor(4 / info.componentsPerRow); + var numMax = Math.floor(maxVaryingVectors * numPerRow / info.rows); + + // Test array[1] of the type + var vcode = wtu.replaceParams(info.vcode, {id: "", index: "[0]"}); + var fcode = wtu.replaceParams(info.fcode, {id: "", index: "[0]"}); + tests.push({ + vShaderSource: wtu.replaceParams(vArrayTestSource, {numTestType: 1, vcode: vcode}, info), + vShaderSuccess: true, + fShaderSource: wtu.replaceParams(fArrayTestSource, {numTestType: 1, fcode: fcode}, info), + fShaderSuccess: true, + linkSuccess: true, + passMsg: "shaders with varying array of " + info.type + " with 1 element should succeed", + }); + + // Test required number of varyings + var vcode = wtu.replaceParams(info.vcode, {id: "", index: "[" + (minVars - 1) + "]"}); + var fcode = wtu.replaceParams(info.fcode, {id: "", index: "[" + (minVars - 1) + "]"}); + tests.push({ + vShaderSource: wtu.replaceParams(vArrayTestSource, {numTestType: minVars, vcode: vcode}, info), + vShaderSuccess: true, + fShaderSource: wtu.replaceParams(fArrayTestSource, {numTestType: minVars, fcode: fcode}, info), + fShaderSuccess: true, + linkSuccess: true, + passMsg: "shaders with varying array of " + info.type + " with " + minVars + " elements (the minimum required) should succeed", + }); + + // Test array[max + 1] accessing last element. WebGL requires this to fail. + var vcode = wtu.replaceParams(info.vcode, {id: "", index: "[" + numVars + "]"}); + var fcode = wtu.replaceParams(info.fcode, {id: "", index: "[" + numVars + "]"}); + tests.push({ + vShaderSource: wtu.replaceParams(vArrayTestSource, {numTestType: numVars + 1, vcode: vcode}, info), + vShaderSuccess: false, + fShaderSource: wtu.replaceParams(fArrayTestSource, {numTestType: numVars + 1, fcode: fcode}, info), + fShaderSuccess: false, + linkSuccess: false, + passMsg: "shaders with varying array of " + info.type + " with " + (numVars + 1) + " elements (one past maximum) accessing last element should fail", + }); + + // Test array[max + 1] accessing first element. WebGL requires this to fail but ES allows truncating array. + var vcode = wtu.replaceParams(info.vcode, {id: "", index: "[0]"}); + var fcode = wtu.replaceParams(info.fcode, {id: "", index: "[0]"}); + tests.push({ + vShaderSource: wtu.replaceParams(vArrayTestSource, {numTestType: numVars + 1, vcode: vcode}, info), + vShaderSuccess: false, + fShaderSource: wtu.replaceParams(fArrayTestSource, {numTestType: numVars + 1, fcode: fcode}, info), + fShaderSuccess: false, + linkSuccess: false, + passMsg: "shaders with varying array of " + info.type + " with " + (numVars + 1) + " elements (one past maximum) accessing first element should fail", + }); + + // Note: We can't test max varyings as actual GL drivers are only required to be able to + // do the minimum number. After that it can fail for any reason, for example running out of + // instruction space. + + var generateCode = function(numVars) { + var varyings = []; + var vcodes = []; + var fcodes = []; + for (var uu = 0; uu < numVars; ++uu) { + varyings.push(" varying " + info.type + " v_varying" + uu + ";"); + vcodes.push(wtu.replaceParams(info.vcode, {id: uu, index: ""})); + fcodes.push(wtu.replaceParams(info.fcode, {id: uu, index: ""})); + } + return { + varyings: varyings.join("\n"), + vcode: vcodes.join("\n "), + fcode: fcodes.join(" + \n "), + }; + }; + + // Test max+1 varyings of type. + tests.push({ + vShaderSource: wtu.replaceParams(vVaryingTestSource, generateCode(numMax + 1), info), + vShaderSuccess: false, + fShaderSource: wtu.replaceParams(fVaryingTestSource, generateCode(numMax + 1), info), + fShaderSuccess: false, + linkSuccess: false, + passMsg: "shaders with " + (numMax + 1) + " varyings of " + info.type + " (one past maximum) should fail", + }); + + // Test required varyings of type. + tests.push({ + vShaderSource: wtu.replaceParams(vVaryingTestSource, generateCode(minVars), info), + vShaderSuccess: true, + fShaderSource: wtu.replaceParams(fVaryingTestSource, generateCode(minVars), info), + fShaderSuccess: true, + linkSuccess: true, + passMsg: "shaders with " + minVars + " varyings of " + info.type + " (the minimum required) should succeed", + }); +} + +GLSLConformanceTester.runTests(tests); +var successfullyParsed = true; +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-256-character-define.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-256-character-define.html new file mode 100644 index 000000000..9d8a4ff19 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-256-character-define.html @@ -0,0 +1,57 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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 that uses 256 character token in #define should succeed +#define LEN_256_OK XxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxX + +void main() +{ + gl_Position = vec4(1.0, 0.0, 0.0, 1.0); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-256-character-identifier.frag.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-256-character-identifier.frag.html new file mode 100644 index 000000000..9d3892f23 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-256-character-identifier.frag.html @@ -0,0 +1,126 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader256" type="text/something-not-javascript"> +// shader that uses 256 character identifier should succeed +precision mediump float; +uniform float a123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345; +void main() +{ + gl_FragColor = vec4(a123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345,0.0,0.0,1.0); +} +</script> +<script id="fragmentShader_before" type="text/something-not-javascript"> +// shader that uses 256 character identifier that starts with underscore should succeed +precision mediump float; +uniform float _a12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234; +void main() +{ + gl_FragColor = vec4(_a12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234,0.0,0.0,1.0); +} +</script> +<script id="fragmentShader_after" type="text/something-not-javascript"> +// shader that uses 256 character identifier that ends with underscore should succeed +precision mediump float; +uniform float a12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234_; +void main() +{ + gl_FragColor = vec4(a12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234_,0.0,0.0,1.0); +} +</script> +<script id="fragmentShader256_odd" type="text/something-not-javascript"> +// shader that uses 256 character identifier with odd characters as underscores should succeed +precision mediump float; +uniform float a_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_; +void main() +{ + gl_FragColor = vec4(a_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_6_8_0_2_4_,0.0,0.0,1.0); +} +</script> +<script id="fragmentShader256_even" type="text/something-not-javascript"> +// shader that uses 256 character identifier with even characters as underscores should succeed +precision mediump float; +uniform float a1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5; +void main() +{ + gl_FragColor = vec4(a1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5_7_9_1_3_5,0.0,0.0,1.0); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTests([ + { + fShaderId: 'fragmentShader256', + fShaderSuccess: true, + linkSuccess: true, + passMsg: 'shader with 256 character identifier should succeed' + }, + { + fShaderId: 'fragmentShader_before', + fShaderSuccess: true, + linkSuccess: true, + passMsg: 'shader with 256 character identifier that starts with underscore should succeed' + }, + { + fShaderId: 'fragmentShader_after', + fShaderSuccess: true, + linkSuccess: true, + passMsg: 'shader with 256 character identifier that ends with underscore should succeed' + }, + { + fShaderId: 'fragmentShader256_odd', + fShaderSuccess: true, + linkSuccess: true, + passMsg: 'shader with 256 character identifier with odd characters as underscores should succeed' + }, + { + fShaderId: 'fragmentShader256_even', + fShaderSuccess: true, + linkSuccess: true, + passMsg: 'shader with 256 character identifier with even characters as underscores should succeed' + } +]); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-257-character-define.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-257-character-define.html new file mode 100644 index 000000000..203547e96 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-257-character-define.html @@ -0,0 +1,57 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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 that uses 257 character token in #define should fail +#define LEN_257_BAD XxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxX + +void main() +{ + gl_Position = vec4(1.0, 0.0, 0.0, 1.0); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-257-character-identifier.frag.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-257-character-identifier.frag.html new file mode 100644 index 000000000..a0ac931bb --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-257-character-identifier.frag.html @@ -0,0 +1,57 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// shader that uses 257 character identifier should fail +precision mediump float; +uniform float a1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456; +void main() +{ + gl_FragColor = vec4(a1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456,0.0,0.0,1.0); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-_webgl-identifier.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-_webgl-identifier.vert.html new file mode 100644 index 000000000..2e1c468b9 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-_webgl-identifier.vert.html @@ -0,0 +1,58 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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 that uses _webgl identifier should fail +attribute vec4 _webgl_vPosition; +void main() +{ + gl_Position = _webgl_vPosition; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-arbitrary-indexing.frag.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-arbitrary-indexing.frag.html new file mode 100644 index 000000000..f681fd668 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-arbitrary-indexing.frag.html @@ -0,0 +1,62 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// fragment shader with arbitrary indexing expression should fail +// http://www.khronos.org/registry/webgl/specs/latest/#SUPPORTED_GLSL_CONSTRUCTS +precision mediump float; + +uniform vec4 u_colors[8]; +varying float a_index; + +void main() +{ + int index = int(floor(a_index)); + gl_FragColor = u_colors[index]; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-arbitrary-indexing.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-arbitrary-indexing.vert.html new file mode 100644 index 000000000..d604ded46 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-arbitrary-indexing.vert.html @@ -0,0 +1,61 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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 with arbitrary indexing expression should succeed +// http://www.khronos.org/registry/webgl/specs/latest/#SUPPORTED_GLSL_CONSTRUCTS +uniform mat4 u_matrices[8]; +attribute vec4 a_vertex; +attribute float a_index; + +void main() +{ + int index = int(floor(a_index)); + gl_Position = u_matrices[index] * a_vertex; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-array-of-structs-containing-arrays.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-array-of-structs-containing-arrays.html new file mode 100644 index 000000000..a74da59e3 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-array-of-structs-containing-arrays.html @@ -0,0 +1,154 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL Array of Structs Containing Arrays</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="vshader" type="x-shader/x-vertex"> +attribute vec4 a_position; +void main(void) { + gl_Position = a_position; +} +</script> +<script id="fshader0" type="x-shader/x-fragment"> +precision mediump float; +struct my_struct { + vec4 color[2]; +}; +uniform my_struct u_colors[2]; +void main(void) { + gl_FragColor = u_colors[0].color[0]; +} +</script> +<script id="fshader1" type="x-shader/x-fragment"> +precision mediump float; +struct my_struct { + vec4 color[2]; +}; +uniform my_struct u_colors[2]; +void main(void) { + gl_FragColor = u_colors[0].color[1]; +} +</script> +<script id="fshader-with-one-element-arrays" type="x-shader/x-fragment"> +precision mediump float; +struct my_struct { + vec4 color[1]; +}; +uniform my_struct u_colors[1]; +void main(void) { + gl_FragColor = u_colors[0].color[0]; +} +</script> +<script id="fshader3" type="x-shader/x-fragment"> +precision mediump float; +struct my_struct { + vec4 color1[2]; + vec4 color2[2]; +}; +uniform my_struct u_colors[2]; +void main(void) { + gl_FragColor = u_colors[0].color1[0] + u_colors[0].color2[0] + u_colors[1].color1[1] +u_colors[1].color2[1]; +} +</script> +</head> +<body> +<canvas id="canvas" width="50" height="50"></canvas> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +description(); + +var wtu = WebGLTestUtils; +var gl = wtu.create3DContext("canvas"); +wtu.setupUnitQuad(gl); + +for (var ii = 0; ii < 2; ++ii) { + var program = wtu.setupProgram(gl, ["vshader", "fshader" + ii], ["a_position"]); + var red_loc = gl.getUniformLocation(program, "u_colors[0].color[" + ii + "]"); + var green_loc = gl.getUniformLocation(program, "u_colors[0].color[" + (1 - ii) + "]"); + gl.uniform4fv(red_loc, [1, 0, 0, 1]); + gl.uniform4fv(green_loc, [0, 1, 0, 1]); + wtu.clearAndDrawUnitQuad(gl); + wtu.checkCanvas(gl, [255, 0, 0, 255], "Should be red"); +} + +var program = wtu.setupProgram(gl, ["vshader", "fshader-with-one-element-arrays"], ["a_position"]); +var green_loc = gl.getUniformLocation(program, "u_colors[0].color[0]"); +gl.uniform4fv(green_loc, [0, 1, 0, 1]); +wtu.clearAndDrawUnitQuad(gl); +wtu.checkCanvas(gl, [0, 255, 0, 255], "Should be green"); + +var program = wtu.setupProgram(gl, ["vshader", "fshader3"], ["a_position"]); +var numUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS); +shouldBe("numUniforms", "4"); +var uniforms = [] +for (var ii = 0; ii < numUniforms; ++ii) { + uniforms.push(gl.getActiveUniform(program, ii).name); +} +uniforms.sort(); +shouldBe("uniforms[0]", '"u_colors[0].color1[0]"'); +shouldBe("uniforms[1]", '"u_colors[0].color2[0]"'); +shouldBe("uniforms[2]", '"u_colors[1].color1[0]"'); +shouldBe("uniforms[3]", '"u_colors[1].color2[0]"'); +var loc00 = gl.getUniformLocation(program, "u_colors[0].color1"); +var loc01 = gl.getUniformLocation(program, "u_colors[0].color2"); +var loc10 = gl.getUniformLocation(program, "u_colors[1].color1"); +var loc11 = gl.getUniformLocation(program, "u_colors[1].color2"); +shouldBeTrue("loc00 != undefined"); +shouldBeTrue("loc01 != undefined"); +shouldBeTrue("loc10 != undefined"); +shouldBeTrue("loc11 != undefined"); +gl.uniform4fv(loc00, [1, 0, 0, 0]); +gl.uniform4fv(loc01, [0, 1, 0, 0]); +gl.uniform4fv(loc10, [0, 0, 0, 0, 0, 0, 1, 0]); +gl.uniform4fv(loc11, [0, 0, 0, 0, 0, 0, 0, 1]); +var loc101 = gl.getUniformLocation(program, "u_colors[1].color1[1]"); +var loc111 = gl.getUniformLocation(program, "u_colors[1].color2[1]"); +shouldBeTrue("loc101 != undefined"); +shouldBeTrue("loc111 != undefined"); +wtu.clearAndDrawUnitQuad(gl, [0, 0, 0, 0]); +gl.uniform4fv(loc101, [0, 0, 0, 0]); +gl.uniform4fv(loc111, [0, 0, 0, 0]); +wtu.clearAndDrawUnitQuad(gl, [0, 0, 0, 0]); +wtu.checkCanvas(gl, [255, 255, 0, 0], "Should be yellow"); + +wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors"); + +var successfullyParsed = true; +</script> +<script src="../../../js/js-test-post.js"></script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-array-of-structs-uniform.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-array-of-structs-uniform.html new file mode 100644 index 000000000..026e8d586 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-array-of-structs-uniform.html @@ -0,0 +1,166 @@ + +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL Array of Structs Uniform</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="vshader" type="x-shader/x-vertex"> +attribute vec4 a_position; +void main(void) { + gl_Position = a_position; +} +</script> +<script id="fshader0" type="x-shader/x-fragment"> +precision mediump float; +struct my_struct { + vec4 color; +}; +uniform my_struct u_colors[2]; +void main(void) { + gl_FragColor = u_colors[0].color; +} +</script> +<script id="fshader1" type="x-shader/x-fragment"> +precision mediump float; +struct my_struct { + vec4 color; +}; +uniform my_struct u_colors[2]; +void main(void) { + gl_FragColor = u_colors[1].color; +} +</script> +<script id="fshader2" type="x-shader/x-fragment"> +precision mediump float; +struct my_struct { + vec4 color1; + vec4 color2; +}; +uniform my_struct u_colors[2]; +void main(void) { + gl_FragColor = u_colors[0].color1 + u_colors[0].color2 + u_colors[1].color1 +u_colors[1].color2; +} +</script> +<script id="fshader3" type="x-shader/x-fragment"> +precision mediump float; +struct my_struct { + float r; + float g; + float b; + float a; +}; +uniform my_struct u_colors[2]; +void main(void) { + gl_FragColor = vec4(u_colors[0].r, u_colors[0].g, u_colors[1].b, u_colors[1].a); +} +</script> +</head> +<body> +<canvas id="canvas" width="50" height="50"></canvas> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +description(); + +var wtu = WebGLTestUtils; +var gl = wtu.create3DContext("canvas"); +wtu.setupUnitQuad(gl); + +for (var ii = 0; ii < 2; ++ii) { + var program = wtu.setupProgram(gl, ["vshader", "fshader" + ii], ["a_position"]); + var red_loc = gl.getUniformLocation(program, "u_colors[" + ii + "].color"); + var green_loc = gl.getUniformLocation(program, "u_colors[" + (1 - ii) + "].color"); + gl.uniform4fv(red_loc, [1, 0, 0, 1]); + gl.uniform4fv(green_loc, [0, 1, 0, 1]); + wtu.clearAndDrawUnitQuad(gl); + wtu.checkCanvas(gl, [255, 0, 0, 255], "Should be red"); +} + +var program = wtu.setupProgram(gl, ["vshader", "fshader2"], ["a_position"]); +var numUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS); +shouldBe("numUniforms", "4"); +var uniforms = [] +for (var ii = 0; ii < numUniforms; ++ii) { + uniforms.push(gl.getActiveUniform(program, ii).name); +} +uniforms.sort(); +shouldBe("uniforms[0]", '"u_colors[0].color1"'); +shouldBe("uniforms[1]", '"u_colors[0].color2"'); +shouldBe("uniforms[2]", '"u_colors[1].color1"'); +shouldBe("uniforms[3]", '"u_colors[1].color2"'); +var loc00 = gl.getUniformLocation(program, "u_colors[0].color1"); +var loc01 = gl.getUniformLocation(program, "u_colors[0].color2"); +var loc10 = gl.getUniformLocation(program, "u_colors[1].color1"); +var loc11 = gl.getUniformLocation(program, "u_colors[1].color2"); +shouldBeTrue("loc00 != undefined"); +shouldBeTrue("loc01 != undefined"); +shouldBeTrue("loc10 != undefined"); +shouldBeTrue("loc11 != undefined"); +gl.uniform4fv(loc00, [1, 0, 0, 0]); +gl.uniform4fv(loc01, [0, 1, 0, 0]); +gl.uniform4fv(loc10, [0, 0, 1, 0]); +gl.uniform4fv(loc11, [0, 0, 0, 1]); +wtu.clearAndDrawUnitQuad(gl, [0, 0, 0, 0]); +wtu.checkCanvas(gl, [255, 255, 255, 255], "Should be white"); + +program = wtu.setupProgram(gl, ["vshader", "fshader3"], ["a_position"]); +var loc0r = gl.getUniformLocation(program, "u_colors[0].r"); +var loc0g = gl.getUniformLocation(program, "u_colors[0].g"); +var loc0b = gl.getUniformLocation(program, "u_colors[0].b"); +var loc0a = gl.getUniformLocation(program, "u_colors[0].a"); +var loc1r = gl.getUniformLocation(program, "u_colors[1].r"); +var loc1g = gl.getUniformLocation(program, "u_colors[1].g"); +var loc1b = gl.getUniformLocation(program, "u_colors[1].b"); +var loc1a = gl.getUniformLocation(program, "u_colors[1].a"); +shouldBeTrue("loc0r != undefined"); +shouldBeTrue("loc0g != undefined"); +shouldBeTrue("loc1b != undefined"); +shouldBeTrue("loc1a != undefined"); +gl.uniform1f(loc0r, 1); +gl.uniform1f(loc0g, 1); +gl.uniform1f(loc1b, 1); +gl.uniform1f(loc1a, 1); +wtu.clearAndDrawUnitQuad(gl, [0, 0, 0, 0]); +wtu.checkCanvas(gl, [255, 255, 255, 255], "Should be white"); + +wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors"); + +var successfullyParsed = true; +</script> +<script src="../../../js/js-test-post.js"></script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-attrib-array.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-attrib-array.vert.html new file mode 100644 index 000000000..0d4f78726 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-attrib-array.vert.html @@ -0,0 +1,58 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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 that uses attribute array should fail as per GLSL page 110, appendix A, section 5 +attribute vec4 vPosition[2]; +void main() +{ + gl_Position = vPosition[0] + vPosition[1]; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-attrib-struct.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-attrib-struct.vert.html new file mode 100644 index 000000000..80a1c609c --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-attrib-struct.vert.html @@ -0,0 +1,60 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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 that uses attribute struct should fail per GLSL ES section 4.4.3, "Attribute", p. 30 +struct UserType { + attribute vec4 position; +}; + +attribute UserType userAttr; +void main() +{ + gl_Position = userAttr.position; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-clipvertex.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-clipvertex.vert.html new file mode 100644 index 000000000..5e5e8ba50 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-clipvertex.vert.html @@ -0,0 +1,57 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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 that uses gl_ClipVertex should fail +attribute vec4 vPosition; +void main() +{ + gl_Position = vPosition; + gl_ClipVertex = vPosition; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-comma-assignment.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-comma-assignment.html new file mode 100644 index 000000000..9a49db126 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-comma-assignment.html @@ -0,0 +1,62 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// fragment shader with comma assignment should succeed +precision mediump float; +void main() { + float a = 0.0; + float b = 0.0; + float c = 0.0; + float d = 0.0; + a = 1.1, b = 3.1; + c = 2.1, d = 4.1; + // Output green if successful, red if not. + gl_FragColor = ((a + b + c + d > 10.0) ? vec4(0,1,0,1) : vec4(1,0,0,1)); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runRenderTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-comma-conditional-assignment.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-comma-conditional-assignment.html new file mode 100644 index 000000000..8606e0bb8 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-comma-conditional-assignment.html @@ -0,0 +1,213 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShaderAGreaterThanBCheckR" type="text/something-not-javascript"> +// fragment shader with for scoping should succeed +precision mediump float; +void main() { + float a = 3.0; + float b = 2.0; + float r = 0.0; + float r0 = 0.5; + float r1 = 1.0; + float ab = a > b ? (r = r0, a) : (r = r1, b); + // Output green if successful, red if not. + gl_FragColor = ((r == r0) ? vec4(0,1,0,1) : vec4(1,0,0,1)); +} +</script> +<script id="fragmentShaderAGreaterThanBCheckAB" type="text/something-not-javascript"> +// fragment shader with for scoping should succeed +precision mediump float; +void main() { + float a = 3.0; + float b = 2.0; + float r = 0.0; + float r0 = 0.5; + float r1 = 1.0; + float ab = a > b ? (r = r0, a) : (r = r1, b); + // Output green if successful, red if not. + gl_FragColor = ((ab == a) ? vec4(0,1,0,1) : vec4(1,0,0,1)); +} +</script> +<script id="fragmentShaderAGreaterThanBCheckT0" type="text/something-not-javascript"> +// fragment shader with for scoping should succeed +precision mediump float; +void main() { + float a = 3.0; + float b = 2.0; + float t0 = 0.0; + float t1 = 0.0; + float r0 = 0.5; + float r1 = 1.0; + float ab = a > b ? (t0 = r0, a) : (t1 = r1, b); + // Output green if successful, red if not. + gl_FragColor = ((t0 == r0) ? vec4(0,1,0,1) : vec4(1,0,0,1)); +} +</script> +<script id="fragmentShaderAGreaterThanBCheckT1" type="text/something-not-javascript"> +// fragment shader with for scoping should succeed +precision mediump float; +void main() { + float a = 3.0; + float b = 2.0; + float t0 = 0.0; + float t1 = 0.0; + float r0 = 0.5; + float r1 = 1.0; + float ab = a > b ? (t0 = r0, a) : (t1 = r1, b); + // Output green if successful, red if not. + gl_FragColor = ((t1 == 0.0) ? vec4(0,1,0,1) : vec4(1,0,0,1)); +} +</script> +<script id="fragmentShaderBGreaterThanACheckR" type="text/something-not-javascript"> +// fragment shader with for scoping should succeed +precision mediump float; +void main() { + float a = 2.0; + float b = 3.0; + float r = 0.0; + float r0 = 0.5; + float r1 = 1.0; + float ab = a > b ? (r = r0, a) : (r = r1, b); + // Output green if successful, red if not. + gl_FragColor = ((r == r1) ? vec4(0,1,0,1) : vec4(1,0,0,1)); +} +</script> +<script id="fragmentShaderBGreaterThanACheckAB" type="text/something-not-javascript"> +// fragment shader with for scoping should succeed +precision mediump float; +void main() { + float a = 2.0; + float b = 3.0; + float r = 0.0; + float r0 = 0.5; + float r1 = 1.0; + float ab = a > b ? (r = r0, a) : (r = r1, b); + // Output green if successful, red if not. + gl_FragColor = ((ab == b) ? vec4(0,1,0,1) : vec4(1,0,0,1)); +} +</script> +<script id="fragmentShaderBGreaterThanACheckT0" type="text/something-not-javascript"> +// fragment shader with for scoping should succeed +precision mediump float; +void main() { + float a = 2.0; + float b = 3.0; + float t0 = 0.0; + float t1 = 0.0; + float r0 = 0.5; + float r1 = 1.0; + float ab = a > b ? (t0 = r0, a) : (t1 = r1, b); + // Output green if successful, red if not. + gl_FragColor = ((t0 == 0.0) ? vec4(0,1,0,1) : vec4(1,0,0,1)); +} +</script> +<script id="fragmentShaderBGreaterThanACheckT1" type="text/something-not-javascript"> +// fragment shader with for scoping should succeed +precision mediump float; +void main() { + float a = 2.0; + float b = 3.0; + float t0 = 0.0; + float t1 = 0.0; + float r0 = 0.5; + float r1 = 1.0; + float ab = a > b ? (t0 = r0, a) : (t1 = r1, b); + // Output green if successful, red if not. + gl_FragColor = ((t1 == r1) ? vec4(0,1,0,1) : vec4(1,0,0,1)); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runRenderTests([ +{ + fShaderId: 'fragmentShaderAGreaterThanBCheckR', + fShaderSuccess: true, + linkSuccess: true, + passMsg: "comma based conditional assignment works", +}, +{ + fShaderId: 'fragmentShaderAGreaterThanBCheckAB', + fShaderSuccess: true, + linkSuccess: true, + passMsg: "comma based conditional assignment works", +}, +{ + fShaderId: 'fragmentShaderAGreaterThanBCheckT0', + fShaderSuccess: true, + linkSuccess: true, + passMsg: "comma based conditional assignment works", +}, +{ + fShaderId: 'fragmentShaderAGreaterThanBCheckT1', + fShaderSuccess: true, + linkSuccess: true, + passMsg: "comma based conditional assignment works", +}, +{ + fShaderId: 'fragmentShaderBGreaterThanACheckR', + fShaderSuccess: true, + linkSuccess: true, + passMsg: "comma based conditional assignment works", +}, +{ + fShaderId: 'fragmentShaderBGreaterThanACheckAB', + fShaderSuccess: true, + linkSuccess: true, + passMsg: "comma based conditional assignment works", +}, +{ + fShaderId: 'fragmentShaderBGreaterThanACheckT0', + fShaderSuccess: true, + linkSuccess: true, + passMsg: "comma based conditional assignment works", +}, +{ + fShaderId: 'fragmentShaderBGreaterThanACheckT1', + fShaderSuccess: true, + linkSuccess: true, + passMsg: "comma based conditional assignment works", +} +]); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-comma-separated-variable-declarations.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-comma-separated-variable-declarations.html new file mode 100644 index 000000000..ad9a76c2d --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-comma-separated-variable-declarations.html @@ -0,0 +1,58 @@ +<!-- + +/* +** Copyright (c) 2015 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</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="fragmentShader" type="text/something-not-javascript"> +// shader with comma separated uniform variable declarations should succeed +precision mediump float; + +uniform float x, y; + +void main() { + gl_FragColor = vec4(x, y, 0.0, 1.0); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-conditional-scoping-negative.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-conditional-scoping-negative.html new file mode 100644 index 000000000..9b46e97fd --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-conditional-scoping-negative.html @@ -0,0 +1,63 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// fragment shader with illegal references to conditionally scoped variables should fail +precision mediump float; +void main() { + int k = 3; + + if (true) int g = k = 4; + else int q = k = 5; + + g = 3; // should error + q = 4; // should error + + gl_FragColor = vec4(1.); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-conditional-scoping.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-conditional-scoping.html new file mode 100644 index 000000000..17651c63e --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-conditional-scoping.html @@ -0,0 +1,66 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// fragment shader with conditional scoping should succeed +precision mediump float; +void main() { + int k = 3; + + if (true) int g = k = 4; + else int q = k = 5; + + if (true) int g = 4; + else int k = 10; + + if (true) { int g = 10; } + else { int k = 20; } + + gl_FragColor = vec4(1.); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-default-precision.frag.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-default-precision.frag.html new file mode 100644 index 000000000..ca8c10cb5 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-default-precision.frag.html @@ -0,0 +1,59 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// fragment shader with default precision should succeed +precision mediump float; +precision mediump int; +precision lowp sampler2D; +precision lowp samplerCube; +void main() +{ + gl_FragColor = vec4(1.0,0.0,0.0,1.0); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-default-precision.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-default-precision.vert.html new file mode 100644 index 000000000..a0001ca6a --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-default-precision.vert.html @@ -0,0 +1,60 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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 with default precision should succeed +precision mediump float; +precision mediump int; +precision lowp sampler2D; +precision lowp samplerCube; +attribute vec4 vPosition; +void main() +{ + gl_Position = vPosition; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-define-line-continuation.frag.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-define-line-continuation.frag.html new file mode 100644 index 000000000..73f6bb6d1 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-define-line-continuation.frag.html @@ -0,0 +1,58 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// fragment shader that uses line continuation macro should fail +#define foo this \ + is a test +precision mediump float; +void main() +{ + gl_FragColor = vec4(0.0,0.0,0.0,1.0); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-dfdx-no-ext.frag.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-dfdx-no-ext.frag.html new file mode 100644 index 000000000..2040d7565 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-dfdx-no-ext.frag.html @@ -0,0 +1,58 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// fragment shader that uses dFdx without #extension should fail +precision mediump float; +void main() +{ + gl_FragColor = vec4(dFdx(0.5),0.0,0.0,1.0); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-dfdx.frag.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-dfdx.frag.html new file mode 100644 index 000000000..7445f9569 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-dfdx.frag.html @@ -0,0 +1,57 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// fragment shader that uses dFdx should fail +#extension GL_OES_standard_derivatives:enable +precision mediump float; +void main() +{ + gl_FragColor = vec4(dFdx(0.5),0.0,0.0,1.0); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-do-loop.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-do-loop.html new file mode 100644 index 000000000..c5e02d958 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-do-loop.html @@ -0,0 +1,61 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// fragment shader with do loop should fail +precision mediump float; +void main() { + int k = 0; + do { + k++; + } while (k < 5); + gl_FragColor = vec4(float(k)); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-error-directive.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-error-directive.html new file mode 100644 index 000000000..45c1818e8 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-error-directive.html @@ -0,0 +1,72 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fshaderWithErrorDirective" type="text/something-not-javascript"> +#error testing123 testing123 +void main() +{ + gl_FragColor = vec4(0,0,0,0); +} +</script> +<script> +"use strict"; +description("Checks shader with error directive"); + +var wtu = WebGLTestUtils; +GLSLConformanceTester.runTests([ +{ vShaderId: undefined, + vShaderSuccess: true, + fShaderId: 'fshaderWithErrorDirective', + fShaderSuccess: false, + // We can't test for the actual error message as + // GLSL 1.0.17 11 says the messages are implementation dependant. + //fShaderTest: (function() { + // return wtu.getLastError().indexOf("testing123 testing123") >= 0; }), + linkSuccess: false, + passMsg: "error directive causes error", +}, +]); + +debug(""); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-explicit-int-cast.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-explicit-int-cast.vert.html new file mode 100644 index 000000000..52d990cca --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-explicit-int-cast.vert.html @@ -0,0 +1,59 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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 that explicit int to float cast should succeed +attribute vec4 vPosition; +void main() +{ + int k = 123; + gl_Position = vec4(vPosition.x, vPosition.y, vPosition.z, float(k)); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-float-return-value.frag.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-float-return-value.frag.html new file mode 100644 index 000000000..cf4db0a0a --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-float-return-value.frag.html @@ -0,0 +1,67 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// Shader with float return value from function call should succeed +precision mediump float; + +float functionResult(); + +void main() +{ + float r = functionResult(); + gl_FragColor = vec4(r, r, r, r); +} + +float functionResult() +{ + return 1.0; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-for-loop.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-for-loop.html new file mode 100644 index 000000000..79b134132 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-for-loop.html @@ -0,0 +1,104 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// fragment shader with for loop should succeed + +// TODO(gman): trim to min size to test bug. +precision mediump float; +uniform float time; +uniform vec2 resolution; + +// Saw-tooth function that is synced with the demo music (128bpm) +float gBeat; + +// Calculate the surface color +vec3 surfColor(vec2 p) +{ + vec2 q=vec2(sin(.08*p.x),4.*p.y); + vec3 c=vec3(0); + for(float i=0.;i<15.;i++) + c+=(1.+sin(i*sin(time)+vec3(0.,1.3,2.2)))*.2/length(q-vec2(sin(i),12.*sin(.3*time+i))); + return c+vec3(mix(mod(floor(p.x*.2)+floor(p.y*2.2),2.),.2,gBeat)); +} + +// Ray trace (cylinder) +vec3 trace(vec3 o,vec3 d) +{ + d.y*=.65+.1*sin(.5*time); + float D=1./(d.y*d.y+d.z*d.z), + a=(o.y*d.y+o.z*d.z)*D, + b=(o.y*o.y+o.z*o.z-36.)*D, + t=-a-sqrt(a*a-b); + o+=t*d; + return surfColor(vec2(o.x,atan(o.y,o.z)))*(1.+.01*t); +} + +void main() +{ + gBeat=fract(time*3.2/3.); + // Screen setup + vec2 p=(2.*gl_FragCoord.xy-resolution)/resolution.y, + q=2.*gl_FragCoord.xy/resolution-1.; + + // Camera setup + vec3 cp=vec3(-time*20.+1.,1.6*sin(time*1.2),2.+2.*cos(time*.3)), + ct=cp+vec3(1.,.3*cos(time),-.2), + cd=normalize(ct-cp), + cr=normalize(cross(cd,vec3(.5*cos(.3*time),0.,1.))), + cu=cross(cr,cd), + rd=normalize(2.*cd+cr*p.x+cu*p.y); + + // Trace! (+some funky lens/raster effects) + vec3 c=trace(cp,rd)* + min(1.,1.8-dot(q,q))* + (.9+.1*sin(3.*sin(gBeat)*gl_FragCoord.y)); + + gl_FragColor=vec4(c,1); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-for-scoping.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-for-scoping.html new file mode 100644 index 000000000..127b62ac1 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-for-scoping.html @@ -0,0 +1,59 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// fragment shader with illegal for scoping should fail +precision mediump float; +void main() { + int k = 0; + for (int i = 0; i < 10; i++) { int i = k+i; } // not a nested scope, in i's scope, nesting already happened + gl_FragColor = vec4(float(k)); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-frag-depth.frag.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-frag-depth.frag.html new file mode 100644 index 000000000..85cb0872e --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-frag-depth.frag.html @@ -0,0 +1,59 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// fragment shader that uses gl_FragDepth should fail +precision mediump float; +void main() +{ + gl_FragColor = vec4(0.0,0.0,0.0,1.0); + gl_FragDepth = 1.0; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-function-recursion.frag.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-function-recursion.frag.html new file mode 100644 index 000000000..0bb6ed79c --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-function-recursion.frag.html @@ -0,0 +1,66 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// shader with recursive function calls should fail +void a(); +void b(); +void main() +{ + a(); + gl_FragColor = vec4(0,0,0,0); +} +void a() +{ + b(); +} +void b() +{ + a(); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-function-scoped-struct.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-function-scoped-struct.html new file mode 100644 index 000000000..41c12acd1 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-function-scoped-struct.html @@ -0,0 +1,63 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// fragment shader with private function scoped struct should fail. +precision mediump float; +int fun2(struct s { int m; } g) { return g.m; } + +s a; + +void main() { + int e = fun2(s(3)); + + gl_FragColor = vec4(1.0); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-functional-scoping.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-functional-scoping.html new file mode 100644 index 000000000..4221414b1 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-functional-scoping.html @@ -0,0 +1,60 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// fragment shader with invalid functional scoping should fail +precision mediump float; +int f(int k) { + int k = k + 3; + return k; +} + +void main() { + gl_FragColor = vec4(f(100)); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-glcolor.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-glcolor.vert.html new file mode 100644 index 000000000..68fc74126 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-glcolor.vert.html @@ -0,0 +1,56 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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 that uses gl_Color should fail +attribute vec4 vPosition; +void main() +{ + gl_Position = gl_Color; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-gles-1.frag.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-gles-1.frag.html new file mode 100644 index 000000000..3930dfcb0 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-gles-1.frag.html @@ -0,0 +1,60 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// fragment shader that expects GL_ES == 1 should succeed +#if GL_ES == 1 + precision mediump float; + void main() + { + gl_FragColor = vec4(0.0,0.0,0.0,1.0); + } +#else + foo +#endif +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-gles-symbol.frag.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-gles-symbol.frag.html new file mode 100644 index 000000000..d3a376107 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-gles-symbol.frag.html @@ -0,0 +1,60 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// fragment shader that uses GL_ES preprocessor symbol should succeed +#if defined(GL_ES) + precision mediump float; + void main() + { + gl_FragColor = vec4(0.0,0.0,0.0,1.0); + } +#else + foo +#endif +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-global-variable-precision-mismatch.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-global-variable-precision-mismatch.html new file mode 100644 index 000000000..8b7fd4acc --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-global-variable-precision-mismatch.html @@ -0,0 +1,149 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fshaderWithMediumpGlobal" type="text/something-not-javascript"> +// There is no default float precision in fragment shaders, so specify mediump. +precision mediump float; + +uniform vec4 foo; + +void main() +{ + gl_FragColor = foo; +} +</script> +<script id="fshaderWithMediumpGlobalInt" type="text/something-not-javascript"> +// Default precision for int in fragment shaders is mediump. +uniform int foo; + +void main() +{ + gl_FragColor = vec4(foo, 0, 0, 1); +} +</script> +<script id="fshaderWithMediumpGlobalStruct" type="text/something-not-javascript"> +// There is no default float precision in fragment shaders, so specify mediump. +precision mediump float; + +struct foo +{ + vec4 bar; +}; + +uniform foo baz; + +void main() +{ + gl_FragColor = baz.bar; +} +</script> +<script id="vshaderWithHighpGlobal" type="x-shader/x-vertex"> +// Default precision for vertex shaders is highp. +uniform vec4 foo; + +void main() { + gl_Position = foo; +} +</script> +<script id="vshaderWithHighpGlobalInt" type="x-shader/x-vertex"> +// Default precision for int in vertex shaders is highp. +uniform int foo; + +void main() { + gl_Position = vec4(foo, 0, 0, 1); +} +</script> +<script id="vshaderWithHighpGlobalStruct" type="x-shader/x-vertex"> +// Default precision for vertex shaders is highp. +struct foo +{ + vec4 bar; +}; + +uniform foo baz; + +void main() +{ + gl_Position = baz.bar; +} +</script> +<script> +"use strict"; +description("Checks shaders with global variables and precision qualifier mismatch."); + +var wtu = WebGLTestUtils; + +var glslTests = []; + +glslTests.push({ + vShaderId: 'vshaderWithHighpGlobal', + vShaderSuccess: true, + fShaderId: 'fshaderWithMediumpGlobal', + fShaderSuccess: true, + linkSuccess: false, + passMsg: "mismatching precision for uniforms causes link error (as expected)", +}); + +glslTests.push({ + vShaderId: 'vshaderWithHighpGlobalInt', + vShaderSuccess: true, + fShaderId: 'fshaderWithMediumpGlobalInt', + fShaderSuccess: true, + linkSuccess: false, + passMsg: "mismatching precision for int uniforms with default precision causes link error (as expected)", +}); + +glslTests.push({ + vShaderId: 'vshaderWithHighpGlobalStruct', + vShaderSuccess: true, + fShaderId: 'fshaderWithMediumpGlobalStruct', + fShaderSuccess: true, + linkSuccess: false, + passMsg: "mismatching precision for structure uniforms causes link error (as expected)", +}); + +GLSLConformanceTester.runTests(glslTests); + +debug(""); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-glprojectionmatrix.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-glprojectionmatrix.vert.html new file mode 100644 index 000000000..add81bcc1 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-glprojectionmatrix.vert.html @@ -0,0 +1,56 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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 that uses gl_ProjectionMatrix should fail +attribute vec4 vPosition; +void main() +{ + gl_Position = vPosition * gl_ProjectionMatrix; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-hex-int-constant-macro.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-hex-int-constant-macro.html new file mode 100644 index 000000000..08022e493 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-hex-int-constant-macro.html @@ -0,0 +1,59 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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 uses the long integer constant should succeed +attribute vec4 vPosition; +void main() +{ + #define TEST 0x1F + int a = TEST; + + gl_Position = vPosition; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-illegal-default-precision.frag.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-illegal-default-precision.frag.html new file mode 100644 index 000000000..9bfcaeee5 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-illegal-default-precision.frag.html @@ -0,0 +1,259 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShaderVoid" type="text/something-not-javascript"> +// fragment shader with default precision for illegal type should fail +precision mediump void; +void main() +{ + mediump vec4 color = vec4(1.0, 0.0, 0.0, 1.0); + gl_FragColor = color; +} +</script> +<script id="fragmentShaderBool" type="text/something-not-javascript"> +// fragment shader with default precision for illegal type should fail +precision mediump bool; +void main() +{ + mediump vec4 color = vec4(1.0, 0.0, 0.0, 1.0); + gl_FragColor = color; +} +</script> +<script id="fragmentShaderVec2" type="text/something-not-javascript"> +// fragment shader with default precision for illegal type should fail +precision mediump vec2; +void main() +{ + mediump vec4 color = vec4(1.0, 0.0, 0.0, 1.0); + gl_FragColor = color; +} +</script> +<script id="fragmentShaderVec3" type="text/something-not-javascript"> +// fragment shader with default precision for illegal type should fail +precision mediump vec3; +void main() +{ + mediump vec4 color = vec4(1.0, 0.0, 0.0, 1.0); + gl_FragColor = color; +} +</script> +<script id="fragmentShaderVec4" type="text/something-not-javascript"> +// fragment shader with default precision for illegal type should fail +precision mediump vec4; +void main() +{ + mediump vec4 color = vec4(1.0, 0.0, 0.0, 1.0); + gl_FragColor = color; +} +</script> +<script id="fragmentShaderBvec2" type="text/something-not-javascript"> +// fragment shader with default precision for illegal type should fail +precision mediump bvec2; +void main() +{ + mediump vec4 color = vec4(1.0, 0.0, 0.0, 1.0); + gl_FragColor = color; +} +</script> +<script id="fragmentShaderBvec3" type="text/something-not-javascript"> +// fragment shader with default precision for illegal type should fail +precision mediump bvec3; +void main() +{ + mediump vec4 color = vec4(1.0, 0.0, 0.0, 1.0); + gl_FragColor = color; +} +</script> +<script id="fragmentShaderBvec4" type="text/something-not-javascript"> +// fragment shader with default precision for illegal type should fail +precision mediump bvec4; +void main() +{ + mediump vec4 color = vec4(1.0, 0.0, 0.0, 1.0); + gl_FragColor = color; +} +</script> +<script id="fragmentShaderIvec2" type="text/something-not-javascript"> +// fragment shader with default precision for illegal type should fail +precision mediump ivec2; +void main() +{ + mediump vec4 color = vec4(1.0, 0.0, 0.0, 1.0); + gl_FragColor = color; +} +</script> +<script id="fragmentShaderIvec3" type="text/something-not-javascript"> +// fragment shader with default precision for illegal type should fail +precision mediump ivec3; +void main() +{ + mediump vec4 color = vec4(1.0, 0.0, 0.0, 1.0); + gl_FragColor = color; +} +</script> +<script id="fragmentShaderIvec4" type="text/something-not-javascript"> +// fragment shader with default precision for illegal type should fail +precision mediump ivec4; +void main() +{ + mediump vec4 color = vec4(1.0, 0.0, 0.0, 1.0); + gl_FragColor = color; +} +</script> +<script id="fragmentShaderMat2" type="text/something-not-javascript"> +// fragment shader with default precision for illegal type should fail +precision mediump mat2; +void main() +{ + mediump vec4 color = vec4(1.0, 0.0, 0.0, 1.0); + gl_FragColor = color; +} +</script> +<script id="fragmentShaderMat3" type="text/something-not-javascript"> +// fragment shader with default precision for illegal type should fail +precision mediump mat3; +void main() +{ + mediump vec4 color = vec4(1.0, 0.0, 0.0, 1.0); + gl_FragColor = color; +} +</script> +<script id="fragmentShaderMat4" type="text/something-not-javascript"> +// fragment shader with default precision for illegal type should fail +precision mediump mat4; +void main() +{ + mediump vec4 color = vec4(1.0, 0.0, 0.0, 1.0); + gl_FragColor = color; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTests([ + { + fShaderId: 'fragmentShaderVoid', + fShaderSuccess: false, + linkSuccess: false, + passMsg: 'shader with default precision for void should fail' + }, + { + fShaderId: 'fragmentShaderBool', + fShaderSuccess: false, + linkSuccess: false, + passMsg: 'shader with default precision for bool should fail' + }, + { + fShaderId: 'fragmentShaderVec2', + fShaderSuccess: false, + linkSuccess: false, + passMsg: 'shader with default precision for vec2 should fail' + }, + { + fShaderId: 'fragmentShaderVec3', + fShaderSuccess: false, + linkSuccess: false, + passMsg: 'shader with default precision for vec3 should fail' + }, + { + fShaderId: 'fragmentShaderVec4', + fShaderSuccess: false, + linkSuccess: false, + passMsg: 'shader with default precision for vec4 should fail' + }, + { + fShaderId: 'fragmentShaderBvec2', + fShaderSuccess: false, + linkSuccess: false, + passMsg: 'shader with default precision for bvec2 should fail' + }, + { + fShaderId: 'fragmentShaderBvec3', + fShaderSuccess: false, + linkSuccess: false, + passMsg: 'shader with default precision for bvec3 should fail' + }, + { + fShaderId: 'fragmentShaderBvec4', + fShaderSuccess: false, + linkSuccess: false, + passMsg: 'shader with default precision for bvec4 should fail' + }, + { + fShaderId: 'fragmentShaderIvec2', + fShaderSuccess: false, + linkSuccess: false, + passMsg: 'shader with default precision for ivec2 should fail' + }, + { + fShaderId: 'fragmentShaderIvec3', + fShaderSuccess: false, + linkSuccess: false, + passMsg: 'shader with default precision for ivec3 should fail' + }, + { + fShaderId: 'fragmentShaderIvec4', + fShaderSuccess: false, + linkSuccess: false, + passMsg: 'shader with default precision for ivec4 should fail' + }, + { + fShaderId: 'fragmentShaderMat2', + fShaderSuccess: false, + linkSuccess: false, + passMsg: 'shader with default precision for mat2 should fail' + }, + { + fShaderId: 'fragmentShaderMat3', + fShaderSuccess: false, + linkSuccess: false, + passMsg: 'shader with default precision for mat3 should fail' + }, + { + fShaderId: 'fragmentShaderMat4', + fShaderSuccess: false, + linkSuccess: false, + passMsg: 'shader with default precision for mat4 should fail' + } +]); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-illegal-default-precision.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-illegal-default-precision.vert.html new file mode 100644 index 000000000..c3e082460 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-illegal-default-precision.vert.html @@ -0,0 +1,245 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="vertexShaderVoid" type="text/something-not-javascript"> +// vertex shader with default precision for illegal type should fail +precision mediump void; +attribute vec4 vPosition; +void main() +{ + gl_Position = vPosition; +} +</script> +<script id="vertexShaderBool" type="text/something-not-javascript"> +// vertex shader with default precision for illegal type should fail +precision mediump bool; +attribute vec4 vPosition; +void main() +{ + gl_Position = vPosition; +} +</script> +<script id="vertexShaderVec2" type="text/something-not-javascript"> +// vertex shader with default precision for illegal type should fail +precision mediump vec2; +attribute vec4 vPosition; +void main() +{ + gl_Position = vPosition; +} +</script> +<script id="vertexShaderVec3" type="text/something-not-javascript"> +// vertex shader with default precision for illegal type should fail +precision mediump vec3; +attribute vec4 vPosition; +void main() +{ + gl_Position = vPosition; +} +</script> +<script id="vertexShaderVec4" type="text/something-not-javascript"> +// vertex shader with default precision for illegal type should fail +precision mediump vec4; +attribute vec4 vPosition; +void main() +{ + gl_Position = vPosition; +} +</script> +<script id="vertexShaderBvec2" type="text/something-not-javascript"> +// vertex shader with default precision for illegal type should fail +precision mediump bvec2; +attribute vec4 vPosition; +void main() +{ + gl_Position = vPosition; +} +</script> +<script id="vertexShaderBvec3" type="text/something-not-javascript"> +// vertex shader with default precision for illegal type should fail +precision mediump bvec3; +attribute vec4 vPosition; +void main() +{ + gl_Position = vPosition; +} +</script> +<script id="vertexShaderBvec4" type="text/something-not-javascript"> +// vertex shader with default precision for illegal type should fail +precision mediump bvec4; +attribute vec4 vPosition; +void main() +{ + gl_Position = vPosition; +} +</script> +<script id="vertexShaderIvec2" type="text/something-not-javascript"> +// vertex shader with default precision for illegal type should fail +precision mediump ivec2; +attribute vec4 vPosition; +void main() +{ + gl_Position = vPosition; +} +</script> +<script id="vertexShaderIvec3" type="text/something-not-javascript"> +// vertex shader with default precision for illegal type should fail +precision mediump ivec3; +attribute vec4 vPosition; +void main() +{ + gl_Position = vPosition; +} +</script> +<script id="vertexShaderIvec4" type="text/something-not-javascript"> +// vertex shader with default precision for illegal type should fail +precision mediump ivec4; +attribute vec4 vPosition; +void main() +{ + gl_Position = vPosition; +} +</script> +<script id="vertexShaderMat2" type="text/something-not-javascript"> +// vertex shader with default precision for illegal type should fail +precision mediump mat2; +attribute vec4 vPosition; +void main() +{ + gl_Position = vPosition; +} +</script> +<script id="vertexShaderMat3" type="text/something-not-javascript"> +// vertex shader with default precision for illegal type should fail +precision mediump mat3; +attribute vec4 vPosition; +void main() +{ + gl_Position = vPosition; +} +</script> +<script id="vertexShaderMat4" type="text/something-not-javascript"> +// vertex shader with default precision for illegal type should fail +precision mediump mat4; +attribute vec4 vPosition; +void main() +{ + gl_Position = vPosition; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTests([ + { vShaderId: 'vertexShaderVoid', + vShaderSuccess: false, + linkSuccess: false, + passMsg: 'shader with default precision for void should fail' + }, + { vShaderId: 'vertexShaderBool', + vShaderSuccess: false, + linkSuccess: false, + passMsg: 'shader with default precision for bool should fail' + }, + { vShaderId: 'vertexShaderVec2', + vShaderSuccess: false, + linkSuccess: false, + passMsg: 'shader with default precision for vec2 should fail' + }, + { vShaderId: 'vertexShaderVec3', + vShaderSuccess: false, + linkSuccess: false, + passMsg: 'shader with default precision for vec3 should fail' + }, + { vShaderId: 'vertexShaderVec4', + vShaderSuccess: false, + linkSuccess: false, + passMsg: 'shader with default precision for vec4 should fail' + }, + { vShaderId: 'vertexShaderBvec2', + vShaderSuccess: false, + linkSuccess: false, + passMsg: 'shader with default precision for bvec2 should fail' + }, + { vShaderId: 'vertexShaderBvec3', + vShaderSuccess: false, + linkSuccess: false, + passMsg: 'shader with default precision for bvec3 should fail' + }, + { vShaderId: 'vertexShaderBvec4', + vShaderSuccess: false, + linkSuccess: false, + passMsg: 'shader with default precision for bvec4 should fail' + }, + { vShaderId: 'vertexShaderIvec2', + vShaderSuccess: false, + linkSuccess: false, + passMsg: 'shader with default precision for ivec2 should fail' + }, + { vShaderId: 'vertexShaderIvec3', + vShaderSuccess: false, + linkSuccess: false, + passMsg: 'shader with default precision for ivec3 should fail' + }, + { vShaderId: 'vertexShaderIvec4', + vShaderSuccess: false, + linkSuccess: false, + passMsg: 'shader with default precision for ivec4 should fail' + }, + { vShaderId: 'vertexShaderMat2', + vShaderSuccess: false, + linkSuccess: false, + passMsg: 'shader with default precision for mat2 should fail' + }, + { vShaderId: 'vertexShaderMat3', + vShaderSuccess: false, + linkSuccess: false, + passMsg: 'shader with default precision for mat3 should fail' + }, + { vShaderId: 'vertexShaderMat4', + vShaderSuccess: false, + linkSuccess: false, + passMsg: 'shader with default precision for mat4 should fail' + } +]); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-implicit-vec3-to-vec4-cast.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-implicit-vec3-to-vec4-cast.vert.html new file mode 100644 index 000000000..aa1b1336b --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-implicit-vec3-to-vec4-cast.vert.html @@ -0,0 +1,59 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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 that implicit vec3 to vec4 cast should fail +attribute vec4 vPosition; +void main() +{ + mediump vec3 k = vec3(1, 2, 3); + gl_Position = k; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-include.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-include.vert.html new file mode 100644 index 000000000..565b66a2f --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-include.vert.html @@ -0,0 +1,60 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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 uses #include should fail + +// Sadly I can not force the current path so this could fail beacuse include.vs +// does not exist, not because #include is disallowed. +#include "include.vs" +attribute vec4 vPosition; +void main() +{ + gl_Position = vPosition; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-int-return-value.frag.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-int-return-value.frag.html new file mode 100644 index 000000000..231d51393 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-int-return-value.frag.html @@ -0,0 +1,63 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// Shader with int return value from function call should succeed +int functionResult(); + +void main() +{ + int r = functionResult(); + gl_FragColor = vec4(r, r, r, r); +} + +int functionResult() +{ + return 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-invalid-identifier.frag.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-invalid-identifier.frag.html new file mode 100644 index 000000000..e0e7cfbc1 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-invalid-identifier.frag.html @@ -0,0 +1,57 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// fragment shader with gl_ identifier should fail +precision mediump float; +uniform float gl_foo; +void main() +{ + gl_FragColor = vec4(gl_foo,0.0,0.0,1.0); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-ivec2-return-value.frag.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-ivec2-return-value.frag.html new file mode 100644 index 000000000..e8f0eb91f --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-ivec2-return-value.frag.html @@ -0,0 +1,63 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// Shader with ivec2 return value from function call should succeed +ivec2 functionResult(); + +void main() +{ + ivec2 r = functionResult(); + gl_FragColor = vec4(r.x, r.y, r.x, r.y); +} + +ivec2 functionResult() +{ + return ivec2(1, 1); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-ivec3-return-value.frag.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-ivec3-return-value.frag.html new file mode 100644 index 000000000..f36e32513 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-ivec3-return-value.frag.html @@ -0,0 +1,63 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// Shader with ivec3 return value from function call should succeed +ivec3 functionResult(); + +void main() +{ + ivec3 r = functionResult(); + gl_FragColor = vec4(r.x, r.y, r.z, r.x); +} + +ivec3 functionResult() +{ + return ivec3(1, 1, 1); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-ivec4-return-value.frag.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-ivec4-return-value.frag.html new file mode 100644 index 000000000..8528515c1 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-ivec4-return-value.frag.html @@ -0,0 +1,63 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// Shader with ivec4 return value from function call should succeed +ivec4 functionResult(); + +void main() +{ + ivec4 r = functionResult(); + gl_FragColor = vec4(r.x, r.y, r.z, r.w); +} + +ivec4 functionResult() +{ + return ivec4(1, 1, 1, 1); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-limited-indexing.frag.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-limited-indexing.frag.html new file mode 100644 index 000000000..a1be2f2bd --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-limited-indexing.frag.html @@ -0,0 +1,75 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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 should succeed +attribute vec4 a_weights; +varying vec4 v_weights; + +void main() { + v_weights = a_weights; + gl_Position = vec4(0.0, 0.0, 0.0, 1.0); +} +</script> +<script id="fragmentShader" type="text/something-not-javascript"> +// fragment shader with appropriately limited indexing expression should succeed +// http://www.khronos.org/registry/webgl/specs/latest/#SUPPORTED_GLSL_CONSTRUCTS +precision mediump float; + +uniform vec4 u_colors[8]; +varying vec4 v_weights; + +void main() +{ + vec4 color = vec4(0.0, 0.0, 0.0, 0.0); + for (int i = 0; i < 4; i++) { + color += u_colors[i] * v_weights[i]; + } + gl_FragColor = color; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-long-line.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-long-line.html new file mode 100644 index 000000000..126ab107c --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-long-line.html @@ -0,0 +1,88 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fshaderWithLongLine" type="text/something-not-javascript"> +precision mediump float; +uniform float fooo; +#if defined(someSymbolNotDefined) +#error long +#endif +void main() +{ + gl_FragColor = vec4(fooo+fooo+fooo+fooo, fooo+fooo+fooo+fooo, fooo+fooo+fooo+fooo, 1.0); +} +</script> +<script> +"use strict"; +description("checks shader with long line succeeds"); + +var wtu = WebGLTestUtils; +GLSLConformanceTester.runTests([ + { + fShaderId: 'fshaderWithLongLine', + fShaderSuccess: true, + fShaderPrep: function(str) { + function expand(str, re, replacement, count) { + for (var ii = 0; ii < count; ++ii) { + str = str.replace(re, replacement); + } + return str; + } + str = expand(str, new RegExp(" ", 'g'), " ", 12); + var manyZeros = expand("0", new RegExp("0", 'g'), "00", 8).substring(2); + str = expand(str, new RegExp("0", 'g'), manyZeros, 1); + str = expand(str, new RegExp("fooo", 'g'), "fooofooo", 6); + str = expand(str, new RegExp("long", 'g'), "longlong", 6); + //debug("len:" + str.length); + //debug(str); + return str; + }, + linkSuccess: true, + passMsg: 'shader that uses long lines should succeed', + } + ]); + +debug(""); +var successfullyParsed = true; + +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-non-ascii-error.frag.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-non-ascii-error.frag.html new file mode 100644 index 000000000..5dcae8863 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-non-ascii-error.frag.html @@ -0,0 +1,58 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// shader with error directive using characters outside of allowed set fails +#error // will return INVALID_VALUE. See WebGL 6.18 +void main() +{ + gl_FragColor = vec4(0,0,0,0); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-non-reserved-words.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-non-reserved-words.html new file mode 100644 index 000000000..a48fdd9af --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-non-reserved-words.html @@ -0,0 +1,716 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests - Non Reserved Words</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> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script id="vertexShader0" type="text/something-not-javascript"> +struct $replaceMe { + vec4 $replaceMe; +}; +struct Foo { + $replaceMe $replaceMe; +}; +attribute vec4 position; +void main() +{ + Foo f; + f.$replaceMe.$replaceMe = position; + gl_Position = f.$replaceMe.$replaceMe; +} +</script> +<script id="fragmentShader0" type="text/something-not-javascript"> +precision mediump float; +vec4 $replaceMe() { + return vec4(0,1,0,1); +} +void main() +{ + gl_FragColor = $replaceMe(); +} +</script> +<script id="vertexShader1" type="text/something-not-javascript"> +attribute vec4 $replaceMe; +void main() +{ + gl_Position = $replaceMe; +} +</script> +<script id="fragmentShader1" type="text/something-not-javascript"> +precision mediump float; +vec4 foo(vec4 $replaceMe) { + return $replaceMe; +} +void main() +{ + gl_FragColor = foo(vec4(1,0,1,1)); +} +</script> +<script id="vertexShader2" type="text/something-not-javascript"> +varying vec4 $replaceMe; +attribute vec4 position; +void main() +{ + gl_Position = position; + $replaceMe = position; +} +</script> +<script id="fragmentShader2" type="text/something-not-javascript"> +precision mediump float; +varying vec4 $replaceMe; +void main() +{ + gl_FragColor = $replaceMe; +} +</script> +<script id="vertexShader3" type="text/something-not-javascript"> +attribute vec4 position; +void main() +{ + gl_Position = position; +} +</script> +<script id="fragmentShader3" type="text/something-not-javascript"> +precision mediump float; +uniform vec4 $replaceMe; +void main() +{ + gl_FragColor = $replaceMe; +} +</script> +<script> +"use strict"; +var DXWords = [ + "Buffer", + "double", + "uint", + "half", + "dword", + "string", + "texture", + "pixelshader", + "vertexshader", + "switch", + "min16float", + "min10float", + "min16int", + "min12int", + "min16uint", + "vector", + "matrix", + "float2", + "float3", + "float4", + "float1x1", + "float1x2", + "float1x3", + "float1x4", + "float2x1", + "float2x2", + "float2x3", + "float2x4", + "float3x1", + "float3x2", + "float3x3", + "float3x4", + "float4x1", + "float4x2", + "float4x3", + "float4x4", + "int1x1", + "int1x2", + "int1x3", + "int1x4", + "int2x1", + "int2x2", + "int2x3", + "int2x4", + "int3x1", + "int3x2", + "int3x3", + "int3x4", + "int4x1", + "int4x2", + "int4x3", + "int4x4", + "double1x1", + "double1x2", + "double1x3", + "double1x4", + "double2x1", + "double2x2", + "double2x3", + "double2x4", + "double3x1", + "double3x2", + "double3x3", + "double3x4", + "double4x1", + "double4x2", + "double4x3", + "double4x4", + "abort", + "abs", + "acos", + "all", + "AllMemoryBarrier", + "AllMemoryBarrierWithGroupSync", + "any", + "asdouble", + "asfloat", + "asin", + "asint", + "asint", + "asuint", + "asuint", + "atan", + "atan2", + "ceil", + "clamp", + "clip", + "cos", + "cosh", + "countbits", + "cross", + "D3DCOLORtoUBYTE4", + "ddx", + "ddx_coarse", + "ddx_fine", + "ddy", + "ddy_coarse", + "ddy_fine", + "degrees", + "determinant", + "DeviceMemoryBarrier", + "DeviceMemoryBarrierWithGroupSync", + "distance", + "dot", + "dst", + "errorf", + "EvaluateAttributeAtCentroid", + "EvaluateAttributeAtSample", + "EvaluateAttributeSnapped", + "exp", + "exp2", + "f16tof32", + "f32tof16", + "faceforward", + "firstbithigh", + "firstbitlow", + "floor", + "fma", + "fmod", + "frac", + "frexp", + "fwidth", + "GetRenderTargetSampleCount", + "GetRenderTargetSamplePosition", + "GroupMemoryBarrier", + "GroupMemoryBarrierWithGroupSync", + "InterlockedAdd", + "InterlockedAnd", + "InterlockedCompareExchange", + "InterlockedCompareStore", + "InterlockedExchange", + "InterlockedMax", + "InterlockedMin", + "InterlockedOr", + "InterlockedXor", + "isfinite", + "isinf", + "isnan", + "ldexp", + "length", + "lerp", + "lit", + "log", + "log10", + "log2", + "mad", + "max", + "min", + "modf", + "msad4", + "mul", + "noise", + "normalize", + "pow", + "printf", + "Process2DQuadTessFactorsAvg", + "Process2DQuadTessFactorsMax", + "Process2DQuadTessFactorsMin", + "ProcessIsolineTessFactors", + "ProcessQuadTessFactorsAvg", + "ProcessQuadTessFactorsMax", + "ProcessQuadTessFactorsMin", + "ProcessTriTessFactorsAvg", + "ProcessTriTessFactorsMax", + "ProcessTriTessFactorsMin", + "radians", + "rcp", + "reflect", + "refract", + "reversebits", + "round", + "rsqrt", + "saturate", + "sign", + "sin", + "sincos", + "sinh", + "smoothstep", + "sqrt", + "step", + "tan", + "tanh", + "tex1D", + "tex1D", + "tex1Dbias", + "tex1Dgrad", + "tex1Dlod", + "tex1Dproj", + "tex2D", + "tex2D", + "tex2Dbias", + "tex2Dgrad", + "tex2Dlod", + "tex2Dproj", + "tex3D", + "tex3D", + "tex3Dbias", + "tex3Dgrad", + "tex3Dlod", + "tex3Dproj", + "texCUBE", + "texCUBE", + "texCUBEbias", + "texCUBEgrad", + "texCUBElod", + "texCUBEproj", + "transpose", + "trunc" +]; + +var GLSL_4_20_11_words = [ + "attribute", + "const", + "uniform", + "varying", + "coherent", + "volatile", + "restrict", + "readonly", + "writeonly", + "atomic_uint", + "layout", + "centroid", + "flat", + "smooth", + "noperspective", + "patch", + "sample", + "break", + "continue", + "do", + "for", + "while", + "switch", + "case", + "default", + "if", + "else", + "subroutine", + "in", + "out", + "inout", + "float", + "double", + "int", + "void", + "bool", + "true", + "false", + "invariant", + "discard", + "return", + "mat2", + "mat3", + "mat4", + "dmat2", + "dmat3", + "dmat4", + "mat2x2", + "mat2x3", + "mat2x4", + "dmat2x2", + "dmat2x3", + "dmat2x4", + "mat3x2", + "mat3x3", + "mat3x4", + "dmat3x2", + "dmat3x3", + "dmat3x4", + "mat4x2", + "mat4x3", + "mat4x4", + "dmat4x2", + "dmat4x3", + "dmat4x4", + "vec2", + "vec3", + "vec4", + "ivec2", + "ivec3", + "ivec4", + "bvec2", + "bvec3", + "bvec4", + "dvec2", + "dvec3", + "dvec4", + "uint", + "uvec2", + "uvec3", + "uvec4", + "lowp", + "mediump", + "highp", + "precision", + "sampler1D", + "sampler2D", + "sampler3D", + "samplerCube", + "sampler1DShadow", + "sampler2DShadow", + "samplerCubeShadow", + "sampler1DArray", + "sampler2DArray", + "sampler1DArrayShadow", + "sampler2DArrayShadow", + "isampler1D", + "isampler2D", + "isampler3D", + "isamplerCube", + "isampler1DArray", + "isampler2DArray", + "usampler1D", + "usampler2D", + "usampler3D", + "usamplerCube", + "usampler1DArray", + "usampler2DArray", + "sampler2DRect", + "sampler2DRectShadow", + "isampler2DRect", + "usampler2DRect", + "samplerBuffer", + "isamplerBuffer", + "usamplerBuffer", + "sampler2DMS", + "isampler2DMS", + "usampler2DMS", + "sampler2DMSArray", + "isampler2DMSArray", + "usampler2DMSArray", + "samplerCubeArray", + "samplerCubeArrayShadow", + "isamplerCubeArray", + "usamplerCubeArray", + "image1D", + "iimage1D", + "uimage1D", + "image2D", + "iimage2D", + "uimage2D", + "image3D", + "iimage3D", + "uimage3D", + "image2DRect", + "iimage2DRect", + "uimage2DRect", + "imageCube", + "iimageCube", + "uimageCube", + "imageBuffer", + "iimageBuffer", + "uimageBuffer", + "image1DArray", + "iimage1DArray", + "uimage1DArray", + "image2DArray", + "iimage2DArray", + "uimage2DArray", + "imageCubeArray", + "iimageCubeArray", + "uimageCubeArray", + "image2DMS", + "iimage2DMS", + "uimage2DMS", + "image2DMSArray", + "iimage2DMSArray", + "uimage2DMSArray", + "struct" +]; + +var GLSL_4_20_11_future_words = [ + "common", + "partition", + "active", + "asm", + "class", + "union", + "enum", + "typedef", + "template", + "this", + "packed", + "resource", + "goto", + "inline", + "noinline", + "public", + "static", + "extern", + "external", + "interface", + "long", + "short", + "half", + "fixed", + "unsigned", + "superp", + "input", + "output", + "hvec2", + "hvec3", + "hvec4", + "fvec2", + "fvec3", + "fvec4", + "sampler3DRect", + "filter", + "sizeof", + "cast", + "namespace", + "using", + "row_major" +]; + +var GLSL_1_0_17_words = [ + "attribute", + "const", + "uniform", + "varying", + "break", + "continue", + "do", + "for", + "while", + "if", + "else", + "in", + "out", + "inout", + "float", + "int", + "void", + "bool", + "true", + "false", + "lowp", + "mediump", + "highp", + "precision", + "invariant", + "discard", + "return", + "mat2", + "mat3", + "mat4", + "vec2", + "vec3", + "vec4", + "ivec2", + "ivec3", + "ivec4", + "bvec2", + "bvec3", + "bvec4", + "sampler2D", + "samplerCube", + "struct" +] + +var GLSL_1_0_17_FutureWords = [ + "asm", + "class", + "union", + "enum", + "typedef", + "template", + "this", + "packed", + "goto", + "switch", + "default", + "inline", + "noinline", + "volatile", + "public", + "static", + "extern", + "external", + "interface", + "flat", + "long", + "short", + "double", + "half", + "fixed", + "unsigned", + "superp", + "input", + "output", + "hvec2", + "hvec3", + "hvec4", + "dvec2", + "dvec3", + "dvec4", + "fvec2", + "fvec3", + "fvec4", + "sampler1D", + "sampler3D", + "sampler1DShadow", + "sampler2DShadow", + "sampler2DRect", + "sampler3DRect", + "sampler2DRectShadow", + "sizeof", + "cast", + "namespace", + "using" +]; + +description(); + +var wtu = WebGLTestUtils; +var gl = wtu.create3DContext(); + +var badWords = [ + { words: DXWords }, + { words: GLSL_4_20_11_words, }, + { words: GLSL_4_20_11_future_words, } +]; + +var reservedWordsLists = [ + GLSL_1_0_17_words, + GLSL_1_0_17_FutureWords +]; + +var reservedWords = { }; +for (var ii = 0; ii < reservedWordsLists.length; ++ii) { + var list = reservedWordsLists[ii]; + for (var jj = 0; jj < list.length; ++jj) { + reservedWords[list[jj]] = true; + } +} + +var checkedWords = {}; + +var src = []; +for (var ii = 0; ii < 4; ++ii) { + var vsrc = document.getElementById("vertexShader" + ii).text; + var fsrc = document.getElementById("fragmentShader" + ii).text; + src.push({vsrc: vsrc, fsrc: fsrc}); +} + +var badWordNdx = 0; +var listNdx = 0; + +function testNextWord() { + var list = badWords[badWordNdx].words; + if (listNdx >= list.length) { + ++badWordNdx; + if (badWordNdx >= badWords.length) { + finishTest(); + return; + } + listNdx = 0; + list = badWords[badWordNdx].words; + } + testWord(list[listNdx]); + ++listNdx; + setTimeout(testNextWord, 0); +} +testNextWord(); + +function testWord(word) { + if (word in reservedWords || word in checkedWords) { + return; + } + checkedWords[word] = true; + debug(""); + debug("testing: " + word); + + for (var ii = 0; ii < src.length; ++ii) { + var vs = src[ii].vsrc.replace(/\$replaceMe/g, word); + var fs = src[ii].fsrc.replace(/\$replaceMe/g, word); + + var success = true; + var program = wtu.loadProgram(gl, vs, fs, function(msg) { + debug(msg); + success = false; + }, true); + if (success) { + testPassed("shader with: '" + word + "' compiled"); + } else { + testFailed("shader with: '" + word + "' failed to compile"); + } + if (program) { + gl.deleteProgram(program); + } + wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be no GL errors"); + } +} + +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-precision.frag.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-precision.frag.html new file mode 100644 index 000000000..bca81f6ef --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-precision.frag.html @@ -0,0 +1,58 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// fragment shader with precision should succeed +void main() +{ + mediump vec4 color = vec4(1.0, 0.0, 0.0, 1.0); + gl_FragColor = color; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-preprocessor-whitespace.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-preprocessor-whitespace.html new file mode 100644 index 000000000..593f505a7 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-preprocessor-whitespace.html @@ -0,0 +1,83 @@ +<!-- + +/* +** Copyright (c) 2014 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="vertexWhitespace" type="text/something-not-javascript"> +// GLSL ES spec section 3.4 + # ifdef GL_ES +attribute vec4 v_Position; +void main() +{ + gl_Position = v_Position; +} +#endif +</script> +<script id="fragmentWhitespace" type="text/something-not-javascript"> +// GLSL ES spec section 3.4 + # ifdef GL_ES +precision mediump float; +void main() +{ + gl_FragColor = vec4(0.0,0.0,0.0,1.0); +} +#endif +</script> +<script> +"use strict"; +GLSLConformanceTester.runTests([ + { + vShaderId: 'vertexWhitespace', + vShaderSuccess: true, + linkSuccess: true, + passMsg: 'Vertex shader using space and tab characters around # should succeed' + }, + { + fShaderId: 'fragmentWhitespace', + fShaderSuccess: true, + linkSuccess: true, + passMsg: 'Fragment shader using space and tab characters around # should succeed' + } +]); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-quoted-error.frag.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-quoted-error.frag.html new file mode 100644 index 000000000..1f6867010 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-quoted-error.frag.html @@ -0,0 +1,58 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// shader with error directive using quotes will fail +#error "testing123 testing123" // will return INVALID_VALUE. See WebGL 6.18 +void main() +{ + gl_FragColor = vec4(0,0,0,0); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-reserved-words.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-reserved-words.html new file mode 100644 index 000000000..3eda25bf5 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-reserved-words.html @@ -0,0 +1,284 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests - Reserved Words</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> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script id="vertexShader0" type="text/something-not-javascript"> +struct $replaceMe { + vec4 $replaceMe; +}; +struct Foo { + $replaceMe $replaceMe; +}; +attribute vec4 position; +void main() +{ + Foo f; + f.$replaceMe.$replaceMe = position; + gl_Position = f.$replaceMe.$replaceMe; +} +</script> +<script id="fragmentShader0" type="text/something-not-javascript"> +precision mediump float; +vec4 $replaceMe() { + return vec4(0,1,0,1); +} +void main() +{ + gl_FragColor = $replaceMe(); +} +</script> +<script id="vertexShader1" type="text/something-not-javascript"> +attribute vec4 $replaceMe; +void main() +{ + gl_Position = $replaceMe; +} +</script> +<script id="fragmentShader1" type="text/something-not-javascript"> +precision mediump float; +vec4 foo(vec4 $replaceMe) { + return $replaceMe; +} +void main() +{ + gl_FragColor = foo(vec4(1,0,1,1)); +} +</script> +<script id="vertexShader2" type="text/something-not-javascript"> +varying vec4 $replaceMe; +attribute vec4 position; +void main() +{ + gl_Position = position; + $replaceMe = position; +} +</script> +<script id="fragmentShader2" type="text/something-not-javascript"> +precision mediump float; +varying vec4 $replaceMe; +void main() +{ + gl_FragColor = $replaceMe; +} +</script> +<script id="vertexShader3" type="text/something-not-javascript"> +attribute vec4 position; +void main() +{ + gl_Position = position; +} +</script> +<script id="fragmentShader3" type="text/something-not-javascript"> +precision mediump float; +uniform vec4 $replaceMe; +void main() +{ + gl_FragColor = $replaceMe; +} +</script> +<script> +"use strict"; +var GLSL_1_0_17_words = [ + "attribute", + "const", + "uniform", + "varying", + "break", + "continue", + "do", + "for", + "while", + "if", + "else", + "in", + "out", + "inout", + "float", + "int", + "void", + "bool", + "true", + "false", + "lowp", + "mediump", + "highp", + "precision", + "invariant", + "discard", + "return", + "mat2", + "mat3", + "mat4", + "vec2", + "vec3", + "vec4", + "ivec2", + "ivec3", + "ivec4", + "bvec2", + "bvec3", + "bvec4", + "sampler2D", + "samplerCube", + "struct" +] + +var GLSL_1_0_17_FutureWords = [ + "asm", + "class", + "union", + "enum", + "typedef", + "template", + "this", + "packed", + "goto", + "switch", + "default", + "inline", + "noinline", + "volatile", + "public", + "static", + "extern", + "external", + "interface", + "flat", + "long", + "short", + "double", + "half", + "fixed", + "unsigned", + "superp", + "input", + "output", + "hvec2", + "hvec3", + "hvec4", + "dvec2", + "dvec3", + "dvec4", + "fvec2", + "fvec3", + "fvec4", + "sampler1D", + "sampler3D", + "sampler1DShadow", + "sampler2DShadow", + "sampler2DRect", + "sampler3DRect", + "sampler2DRectShadow", + "sizeof", + "cast", + "namespace", + "using", + "__foo", // something that has 2 underscores + "foo__bar", // something that has 2 underscores + "gl_foo", // something that starts with gl_ + "webgl_foo" // something that starts with webgl_ +]; + +description(); + +var wtu = WebGLTestUtils; +var gl = wtu.create3DContext(); + +var reservedWordsLists = [ + GLSL_1_0_17_words, + GLSL_1_0_17_FutureWords +]; + +var reservedWords = []; +for (var ii = 0; ii < reservedWordsLists.length; ++ii) { + var list = reservedWordsLists[ii]; + for (var jj = 0; jj < list.length; ++jj) { + reservedWords.push(list[jj]); + } +} + +var src = []; +for (var ii = 0; ii < 4; ++ii) { + var vsrc = document.getElementById("vertexShader" + ii).text; + var fsrc = document.getElementById("fragmentShader" + ii).text; + src.push({vsrc: vsrc, fsrc: fsrc}); +} + +var wordNdx = 0; + +function testNextWord() { + if (wordNdx >= reservedWords.length) { + finishTest(); + return; + } + testWord(reservedWords[wordNdx]); + ++wordNdx; + setTimeout(testNextWord, 0); +} +testNextWord(); + +function testWord(word) { + debug(""); + debug("testing: " + word); + + for (var ii = 0; ii < src.length; ++ii) { + var vs = src[ii].vsrc.replace(/\$replaceMe/g, word); + var fs = src[ii].fsrc.replace(/\$replaceMe/g, word); + + var success = true; + var program = wtu.loadProgram(gl, vs, fs, function(msg) { + //debug(msg); + success = false; + }, true); + if (success) { + testFailed("shader with: '" + word + "' compiled even though it should not"); + } else { + testPassed("shader with: '" + word + "' correctly failed to compile"); + } + if (program) { + gl.deleteProgram(program); + } + wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be no GL errors"); + } +} + +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-short-circuiting-operators.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-short-circuiting-operators.html new file mode 100644 index 000000000..202966f68 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-short-circuiting-operators.html @@ -0,0 +1,177 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL short-circuit evaluation</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> +<canvas id="example" width="2" height="2"> </canvas> + +<!------------------------------------- + WebGL Shaders +----------------------------------------> +<!-- Pass through Shaders --> +<script id="vshader0" type="x-shader/x-vertex"> +/* PASS-THROUGH VERTEX SHADER */ +attribute vec4 vPosition; + +void main() +{ + gl_Position = vPosition; +} +</script> + +<script id="fshader0" type="x-shader/x-fragment"> +/* PASS-THROUGH FRAGMENT SHADER */ +precision mediump float; +varying vec4 vPassThrough; + +void main() +{ + gl_FragColor = vPassThrough; +} +</script> + +<!-- basic conditonal short circuit Shaders --> +<script id="vshader1" type="x-shader/x-vertex"> +attribute vec4 vPosition; +varying vec4 vPassThrough; + +void main() +{ + int x = 1; + $(variables) + + if ($(condition)) + { /*do nothing*/ } + + /* if x was unmodified return green, else return red */ + vPassThrough = (x == 1) ? vec4(0, 1, 0, 1) : vec4(1, 0, 0, 1); + gl_Position = vPosition; +} +</script> + +<script id="fshader1" type="x-shader/x-fragment"> +precision mediump float; + +void main() +{ + int x = 1; + $(variables) + + if ($(condition)) + { /*do nothing*/ } + + gl_FragColor = (x == 1) ? vec4(0, 1, 0, 1) : vec4(1, 0, 0, 1); +} +</script> + +<!-- Main body of the Webgl program --> +<script> +"use strict"; +description(); + +var wtu = WebGLTestUtils; +var gl = wtu.create3DContext(); + +wtu.setupUnitQuad(gl, [0, 1]); + +var shaderTemplates = [ + { vs: "vshader1", fs: "fshader0" }, // basic vertex short-circuit test + { vs: "vshader0", fs: "fshader1" }, // basic fragment short-circuit test +]; + +/* replace the names of the shaders in the tempate variables with + * the shaders themselves */ +for (var ii = 0; ii < shaderTemplates.length; ++ii) { + var template = shaderTemplates[ii]; + template.vs = wtu.getScript(template.vs); + template.fs = wtu.getScript(template.fs); +} + +/* define the conditon that will be used in the shaders. If additional + * variables are needed that are not present i the shader they my be + * defined in the variables variable */ +var tests = [ + { condition: "true || (x = 0) == 1", variables: "" }, /* test basic 'or' short circuit */ + { condition: "false && (x = 0) == 1", variables: "" }, /* test basic 'and' short circuit */ + { condition: "(j == 3 && j == k) || (j > (x = 0))", variables: "int j = 3;\nint k = 3;" }, /* test basic 'or' short circuit with actual condition */ + { condition: "(j == 3 && j == k) && (j > (x = 0))", variables: "int j = 3;\nint k = 4;" }, /* test basic 'and' short circuit with actual condition */ + { condition: "(j + 3 > k && ((j < 10) || (x + 5 > j + (x = 0))) || ( x = 0 ) == 7)", variables: "int j = 5;\nint k = 3;" }, /* complex test */ + { condition: "j + 1 == 6 ? x == 1 || j > (x = 0) : (x = 0) == 1 && (x = 0) <= 1", variables: "int j = 5;" }, /* nested with ternary operator */ + { condition: "true && (true || (x = 0) == 1)", variables: "" }, /* test unfold short circuit update order correctness */ +]; + +function testShortCircuit(test) { + debug(""); + debug("testing short circuit condition: " + test.condition); + + /* Setting clear color to blue */ + gl.clearColor(0.0, 0.0, 1.0, 1.0); + + for (var ii = 0; ii < shaderTemplates.length; ++ii) { + + /* clear the screen so that subsequent tests don't conflict */ + gl.clear(gl.COLOR_BUFFER_BIT); + var template = shaderTemplates[ii]; + + var vs = wtu.replaceParams(template.vs, test); + var fs = wtu.replaceParams(template.fs, test); + + var program = wtu.setupProgram(gl, [vs, fs], ['vPosition'], undefined, true); + + wtu.clearAndDrawUnitQuad(gl); + wtu.checkCanvas(gl, [0, 255, 0, 255], "should be green", 0); + + gl.deleteProgram(program); + + wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be no GL errors"); + } +} + +var testNdx = 0; +function runNextTest() { + testShortCircuit(tests[testNdx++]); + if (testNdx >= tests.length) { + finishTest(); + } else { + setTimeout(runNextTest, 0); + } +} + +runNextTest(); +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-similar-uniform-array-names.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-similar-uniform-array-names.html new file mode 100644 index 000000000..8b6a95f10 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-similar-uniform-array-names.html @@ -0,0 +1,130 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL similar names issue</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="vshader" type="x-shader/x-vertex"> +attribute vec4 a_position; +void main(void) { + gl_Position = a_position; +} +</script> +<script id="fshader1" type="x-shader/x-fragment"> +precision mediump float; +uniform vec4 u_nameCollision[2]; +uniform vec4 u_nameCollision2[2]; +uniform vec4 u_name[2]; +void main(void) { + gl_FragColor = u_nameCollision[0] + u_nameCollision2[0] + u_name[0]; +} +</script> +<script id="fshader2" type="x-shader/x-fragment"> +precision mediump float; +uniform vec4 u_nameCollision2[2]; +uniform vec4 u_nameCollision[2]; +uniform vec4 u_name[2]; +void main(void) { + gl_FragColor = u_nameCollision2[0] + u_nameCollision[0] + u_name[0]; +} +</script> +<script id="fshader3" type="x-shader/x-fragment"> +precision mediump float; +uniform vec4 u_nameCollision[2]; +uniform vec4 u_name[2]; +uniform vec4 u_nameCollision2[2]; +void main(void) { + gl_FragColor = u_nameCollision[0] + u_name[0] + u_nameCollision2[0]; +} +</script> +<script id="fshader4" type="x-shader/x-fragment"> +precision mediump float; +uniform vec4 u_nameCollision2[2]; +uniform vec4 u_name[2]; +uniform vec4 u_nameCollision[2]; +void main(void) { + gl_FragColor = u_nameCollision2[0] + u_name[0] + u_nameCollision[0]; +} +</script> +<script id="fshader5" type="x-shader/x-fragment"> +precision mediump float; +uniform vec4 u_name[2]; +uniform vec4 u_nameCollision[2]; +uniform vec4 u_nameCollision2[2]; +void main(void) { + gl_FragColor = u_name[0] + u_nameCollision[0] + u_nameCollision2[0]; +} +</script> +<script id="fshader6" type="x-shader/x-fragment"> +precision mediump float; +uniform vec4 u_name[2]; +uniform vec4 u_nameCollision2[2]; +uniform vec4 u_nameCollision[2]; +void main(void) { + gl_FragColor = u_name[0] + u_nameCollision2[0] + u_nameCollision[0]; +} +</script> +</head> +<body> +<canvas id="canvas" width="50" height="50"></canvas> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +description(); + +var wtu = WebGLTestUtils; +var gl = wtu.create3DContext("canvas"); +wtu.setupUnitQuad(gl); + +for (var ii = 0; ii < 6; ++ii) { + var program = wtu.setupProgram(gl, ["vshader", "fshader" + (ii + 1)], ["a_position"]); + var loc1 = gl.getUniformLocation(program, "u_name[0]"); + var loc2 = gl.getUniformLocation(program, "u_nameCollision[0]"); + var loc3 = gl.getUniformLocation(program, "u_nameCollision2[0]"); + gl.uniform4fv(loc1, [1, 0, 0, 0]); + gl.uniform4fv(loc2, [0, 1, 0, 0]); + gl.uniform4fv(loc3, [0, 0, 0, 1]); + wtu.clearAndDrawUnitQuad(gl); + wtu.checkCanvas(gl, [255, 255, 0, 255], "Should be yellow"); +} + +wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors"); + +var successfullyParsed = true; +</script> +<script src="../../../js/js-test-post.js"></script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-too-many-uniforms.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-too-many-uniforms.html new file mode 100644 index 000000000..c6f9c896a --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-too-many-uniforms.html @@ -0,0 +1,144 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="vshader" type="x-shader/x-vertex"> +attribute vec4 a_position; +void main() +{ + gl_Position = a_position; +} +</script> +<script id="vshader-max" type="x-shader/x-vertex"> +attribute vec4 a_position; +uniform vec4 u_color[$(maxUniformVectors)]; +void main() +{ + vec4 v = vec4(0, 0, 0, 0); + for (int i = 0; i < $(maxUniformVectors); ++i) { + v = v + vec4(u_color[i]); + } + gl_Position = a_position + v; +} +</script> +<script id="fshader" type="x-shader/x-fragment"> +precision mediump float; +void main() +{ + gl_FragColor = vec4(0, 1, 0, 1); +} +</script> +<script id="fshader-max" type="x-shader/x-fragment"> +precision mediump float; +uniform vec4 u_color[$(maxUniformVectors)]; +void main() +{ + vec4 v = vec4(0, 0, 0, 0); + for (int i = 0; i < $(maxUniformVectors); ++i) { + v = v + vec4(u_color[i]); + } + gl_FragColor = v; +} +</script> +<script> +"use strict"; +description("checks shader with too many uniforms fails"); + +var wtu = WebGLTestUtils; +var gl = wtu.create3DContext(); +var maxFragmentUniformVectors = gl.getParameter(gl.MAX_FRAGMENT_UNIFORM_VECTORS); +var maxVertexUniformVectors = gl.getParameter(gl.MAX_VERTEX_UNIFORM_VECTORS); + +// Up to 2 uniform vector registers may be spent for literal constants in +// vshader-max or fshader-max code. One vector row is used for the vec4, and +// another may be used for integer constants that are allowed to be treated +// internally as floats and are packable to the space of one row. This is +// according to the GLSL ES variable packing algorithm detailed in Section 7 of +// Appendix A of the GLSL ES Specification 10.0.17. +var maxVectorStorageUsedForLiterals = 2; + +var tests = [ + { desc: "using all uniforms in vertex shader should succeed", + maxUniformVectors: maxVertexUniformVectors - maxVectorStorageUsedForLiterals, + vShader: "vshader-max", + fShader: "fshader", + success: true, + }, + { desc: "using too many uniforms in vertex shader should fail", + maxUniformVectors: maxVertexUniformVectors + 1, + vShader: "vshader-max", + fShader: "fshader", + color: [0, 1, 0, 1], + success: false, + }, + { desc: "using all uniforms in fragment shader should succeed", + maxUniformVectors: maxFragmentUniformVectors - maxVectorStorageUsedForLiterals, + vShader: "vshader", + fShader: "fshader-max", + success: true, + }, + { desc: "using too many uniforms in fragment shader should fail", + maxUniformVectors: maxFragmentUniformVectors + 1, + vShader: "vshader", + fShader: "fshader-max", + color: [0, 1, 0, 1], + success: false, + }, +]; + +var glslTests = []; + +for (var ii = 0; ii < tests.length; ++ii) { + var test = tests[ii]; + var vSrc = wtu.replaceParams(wtu.getScript(test.vShader), test); + var fSrc = wtu.replaceParams(wtu.getScript(test.fShader), test); + glslTests.push({ + vShaderSource: vSrc, + fShaderSource: fSrc, + linkSuccess: test.success, + passMsg: 'shader ' + test.desc, + }); +} + +GLSLConformanceTester.runTests(glslTests); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-two-initializer-types.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-two-initializer-types.html new file mode 100644 index 000000000..d56ebd138 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-two-initializer-types.html @@ -0,0 +1,57 @@ +<!-- + +/* +** Copyright (c) 2015 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</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="fragmentShader" type="text/something-not-javascript"> +// fragment shader with different initializer types should succeed +precision mediump float; + +void main() { + float test1[4], test2; + gl_FragColor = vec4(0.0,1.0,0.0,1.0); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-undefined-preprocessor-symbol.frag.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-undefined-preprocessor-symbol.frag.html new file mode 100644 index 000000000..2ba3e8e27 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-undefined-preprocessor-symbol.frag.html @@ -0,0 +1,60 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// fragment shader (3.4) undefined preprocessor symbol should fail +#if UNDEFINED_FOO + // according to ES GLSL spec 3.4 undefined symbols should fail. +#else + precision mediump float; + void main() + { + gl_FragColor = vec4(0.0,0.0,0.0,1.0); + } +#endif +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-uniform-in-loop-condition.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-uniform-in-loop-condition.vert.html new file mode 100644 index 000000000..5731662c1 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-uniform-in-loop-condition.vert.html @@ -0,0 +1,63 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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 with uniform variable in loop condition should fail +// http://www.khronos.org/registry/webgl/specs/latest/#SUPPORTED_GLSL_CONSTRUCTS +uniform int u_numIterations; +attribute vec4 a_position; + +void main() +{ + float count = 0.0; + for (int i = 0; i < u_numIterations; i++) { + count += 1.0; + } + gl_Position = a_position + vec4(count, count, count, count); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-vec2-return-value.frag.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-vec2-return-value.frag.html new file mode 100644 index 000000000..ae453acff --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-vec2-return-value.frag.html @@ -0,0 +1,65 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// Shader with vec2 return value from function call should succeed +precision mediump float; + +vec2 functionResult(); + +void main() +{ + vec2 r = functionResult(); + gl_FragColor = vec4(r.x, r.y, r.x, r.y); +} + +vec2 functionResult() +{ + return vec2(1.0, 1.0); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-vec3-return-value.frag.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-vec3-return-value.frag.html new file mode 100644 index 000000000..400c346f9 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-vec3-return-value.frag.html @@ -0,0 +1,65 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// Shader with vec3 return value from function call should succeed +precision mediump float; + +vec3 functionResult(); + +void main() +{ + vec3 r = functionResult(); + gl_FragColor = vec4(r.x, r.y, r.z, r.x); +} + +vec3 functionResult() +{ + return vec3(1.0, 1.0, 1.0); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-vec4-return-value.frag.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-vec4-return-value.frag.html new file mode 100644 index 000000000..b9ba890ab --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-vec4-return-value.frag.html @@ -0,0 +1,65 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// Shader with vec4 return value from function call should succeed +precision mediump float; + +vec4 functionResult(); + +void main() +{ + vec4 r = functionResult(); + gl_FragColor = vec4(r.x, r.y, r.z, r.w); +} + +vec4 functionResult() +{ + return vec4(1.0, 1.0, 1.0, 1.0); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-vec4-vec3-vec4-conditional.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-vec4-vec3-vec4-conditional.html new file mode 100644 index 000000000..943672426 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-vec4-vec3-vec4-conditional.html @@ -0,0 +1,57 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// fragment shader that vec4->vec3->vec4 conditional should succeed +precision mediump float; +uniform float x; +void main() +{ + gl_FragColor = vec4((x > 0.0 ? vec4(1.0, 1.0, 1.0, 0.0) : vec4(0.1, 0.1, 0.1, 0.0)).xyz, 1.0); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-version-100.frag.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-version-100.frag.html new file mode 100644 index 000000000..19307ca19 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-version-100.frag.html @@ -0,0 +1,62 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// fragment shader that uses __VERSION__==100 should succeed +#if __VERSION__ == 100 + precision mediump float; + void main() + { + gl_FragColor = vec4(0.0,0.0,0.0,1.0); + } +#else + foo +#endif +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-version-100.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-version-100.vert.html new file mode 100644 index 000000000..8576b9070 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-version-100.vert.html @@ -0,0 +1,59 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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 uses the #version 100 directive should succeed +#version 100 +attribute vec4 vPosition; +void main() +{ + gl_Position = vPosition; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-version-120.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-version-120.vert.html new file mode 100644 index 000000000..71408de12 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-version-120.vert.html @@ -0,0 +1,59 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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 uses the #version not 100 directive should fail +#version 120 +attribute vec4 vPosition; +void main() +{ + gl_Position = vPosition; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-version-130.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-version-130.vert.html new file mode 100644 index 000000000..a0f006b80 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-version-130.vert.html @@ -0,0 +1,59 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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 uses the #version not 100 directive should fail +#version 130 +attribute vec4 vPosition; +void main() +{ + gl_Position = vPosition; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-webgl-identifier.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-webgl-identifier.vert.html new file mode 100644 index 000000000..b516e6607 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-webgl-identifier.vert.html @@ -0,0 +1,58 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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 that uses webgl identifier should fail +attribute vec4 webgl_vPosition; +void main() +{ + gl_Position = webgl_vPosition; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-while-loop.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-while-loop.html new file mode 100644 index 000000000..5a349d075 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-while-loop.html @@ -0,0 +1,59 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// fragment shader with while loop should fail +precision mediump float; +void main() { + int k = 0; + while (k < 5) { + k++; + } + gl_FragColor = vec4(float(k)); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-without-precision.frag.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-without-precision.frag.html new file mode 100644 index 000000000..d16f39b58 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-without-precision.frag.html @@ -0,0 +1,58 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// fragment shader without precision should fail +uniform vec4 color; +void main() +{ + gl_FragColor = color; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shaders-with-constant-expression-loop-conditions.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shaders-with-constant-expression-loop-conditions.html new file mode 100644 index 000000000..5e67435df --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shaders-with-constant-expression-loop-conditions.html @@ -0,0 +1,136 @@ +<!-- + +/* +** Copyright (c) 2014 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="vertexShaderLiteralLoopCondition" type="text/something-not-javascript"> +attribute vec4 a_position; +void main() +{ + for (int i = 0; i < 5 + 5; i++) { } + gl_Position = a_position; +} +</script> +<script id="fragmentShaderLiteralLoopCondition" type="text/something-not-javascript"> +void main() +{ + for (int i = 0; i < 5 + 5; i++) { } + gl_FragColor = vec4(1.0); +} +</script> +<script id="vertexShaderConstVarLoopCondition" type="text/something-not-javascript"> +attribute vec4 a_position; +void main() +{ + // Explicitly constant variables can be part of a constant expression + const int constVar = 5; + for (int i = 0; i < 5 + constVar; i++) { } + gl_Position = a_position; +} +</script> +<script id="fragmentShaderConstVarLoopCondition" type="text/something-not-javascript"> +void main() +{ + // Explicitly constant variables can be part of a constant expression + const int constVar = 5; + for (int i = 0; i < constVar + 5; i++) { } + gl_FragColor = vec4(1.0); +} +</script> +<script id="vertexShaderNonConstVarLoopCondition" type="text/something-not-javascript"> +attribute vec4 a_position; +void main() +{ + // Despite assigning a constant and not modifying it, nonConstVar is not semantically a constant expression + int nonConstVar = 10; + for (int i = 0; i < nonConstVar; i++) { } + gl_Position = a_position; +} +</script> +<script id="fragmentShaderNonConstVarLoopCondition" type="text/something-not-javascript"> +void main() +{ + // Despite assigning a constant and not modifying it, nonConstVar is not semantically a constant expression + int nonConstVar = 10; + for (int i = 0; i < nonConstVar; i++) { } + gl_FragColor = vec4(1.0); +} +</script> +<script> +"use strict"; +var wtu = WebGLTestUtils; + +var tests = []; +tests.push({ + vShaderSource: wtu.getScript("vertexShaderLiteralLoopCondition"), + vShaderSuccess: true, + fShaderSource: wtu.getScript("fragmentShaderLiteralLoopCondition"), + fShaderSuccess: true, + linkSuccess: true, + passMsg: "Shaders with literals in the loop condition should compile and link.", +}); +tests.push({ + vShaderSource: wtu.getScript("vertexShaderConstVarLoopCondition"), + vShaderSuccess: true, + fShaderSource: wtu.getScript("fragmentShaderConstVarLoopCondition"), + fShaderSuccess: true, + linkSuccess: true, + passMsg: "Shaders with constant variables in the loop condition should compile and link.", +}); +tests.push({ + vShaderSource: wtu.getScript("vertexShaderNonConstVarLoopCondition"), + vShaderSuccess: false, + fShaderSource: wtu.getScript("fragmentShaderLiteralLoopCondition"), + fShaderSuccess: true, + linkSuccess: false, + passMsg: "Vertex shader with non-const variable in the loop condition should fail.", +}); +tests.push({ + vShaderSource: wtu.getScript("vertexShaderLiteralLoopCondition"), + vShaderSuccess: true, + fShaderSource: wtu.getScript("fragmentShaderNonConstVarLoopCondition"), + fShaderSuccess: false, + linkSuccess: false, + passMsg: "Fragment shader with non-const variable in the loop condition should fail.", +}); + +GLSLConformanceTester.runTests(tests); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shaders-with-invariance.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shaders-with-invariance.html new file mode 100644 index 000000000..b7e5edf55 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shaders-with-invariance.html @@ -0,0 +1,353 @@ +<!-- + +/* +** Copyright (c) 2014 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="vertexShaderVariant" type="text/something-not-javascript"> +varying vec4 v_varying; + +void main() +{ + gl_PointSize = 1.0; + gl_Position = v_varying; +} +</script> +<script id="vertexShaderInvariant" type="text/something-not-javascript"> +invariant varying vec4 v_varying; + +void main() +{ + gl_Position = v_varying; +} +</script> +<script id="vertexShaderSeparateInvariant" type="text/something-not-javascript"> +varying vec4 v_varying; +invariant v_varying; + +void main() +{ + gl_Position = v_varying; +} +</script> +<script id="vertexShaderSeparateInvariantWrongOrder" type="text/something-not-javascript"> +invariant v_varying; +varying vec4 v_varying; + +void main() +{ + gl_Position = v_varying; +} +</script> +<script id="vertexShaderGlobalInvariant" type="text/something-not-javascript"> +#pragma STDGL invariant(all) +varying vec4 v_varying; + +void main() +{ + gl_Position = v_varying; +} +</script> +<script id="vertexShaderInvariantGlPosition" type="text/something-not-javascript"> +invariant gl_Position; + +void main() +{ + gl_Position = vec4(0, 0, 0, 0); +} +</script> +<script id="vertexShaderInvariantGlPointSize" type="text/something-not-javascript"> +invariant gl_PointSize; + +void main() +{ + gl_PointSize = 1.0; + gl_Position = vec4(0, 0, 0, 0); +} +</script> +<script id="fragmentShaderVariant" type="text/something-not-javascript"> +precision mediump float; + +varying vec4 v_varying; + +void main() +{ + gl_FragColor = v_varying; +} +</script> +<script id="fragmentShaderInvariant" type="text/something-not-javascript"> +precision mediump float; + +invariant varying vec4 v_varying; + +void main() +{ + gl_FragColor = v_varying; +} +</script> +<script id="fragmentShaderSeparateInvariant" type="text/something-not-javascript"> +precision mediump float; + +varying vec4 v_varying; +invariant v_varying; + +void main() +{ + gl_FragColor = v_varying; +} +</script> +<script id="fragmentShaderSeparateInvariantWrongOrder" type="text/something-not-javascript"> +precision mediump float; + +invariant v_varying; +varying vec4 v_varying; + +void main() +{ + gl_FragColor = v_varying; +} +</script> +<script id="fragmentShaderGlobalInvariant" type="text/something-not-javascript"> +#pragma STDGL invariant(all) +precision mediump float; + +varying vec4 v_varying; + +void main() +{ + gl_FragColor = v_varying; +} +</script> +<script id="fragmentShaderInvariantGlFragCoord" type="text/something-not-javascript"> +invariant gl_FragCoord; + +void main() +{ + gl_FragColor = gl_FragCoord; +} +</script> +<script id="fragmentShaderVariantGlFragCoord" type="text/something-not-javascript"> +void main() +{ + gl_FragColor = gl_FragCoord; +} +</script> +<script id="fragmentShaderInvariantGlPointCoord" type="text/something-not-javascript"> +invariant gl_PointCoord; + +void main() +{ + gl_FragColor = vec4(gl_PointCoord, 0.0, 0.0); +} +</script> +<script id="fragmentShaderVariantGlPointCoord" type="text/something-not-javascript"> +void main() +{ + gl_FragColor = vec4(gl_PointCoord, 0.0, 0.0); +} +</script> +<script id="fragmentShaderInvariantGlFrontFacing" type="text/something-not-javascript"> +invariant gl_FrontFacing; + +void main() +{ + gl_FragColor = gl_FrontFacing ? vec4(1, 1, 1, 1) : vec4(0, 0, 0, 1); +} +</script> +<script id="fragmentShaderVariantGlFrontFacing" type="text/something-not-javascript"> +void main() +{ + gl_FragColor = gl_FrontFacing ? vec4(1, 1, 1, 1) : vec4(0, 0, 0, 1); +} +</script> +<script> +// GLSL 1.0.17 4.3.5 +"use strict"; +// See GLSL ES spec 1.0.17 section 4.6.4 "Invariance and linkage". +var cases = [ + { + vShaderId: "vertexShaderVariant", + vShaderSuccess: true, + fShaderId: "fragmentShaderInvariant", + fShaderSuccess: true, + linkSuccess: false, + passMsg: "vertex shader with variant varying and fragment shader with invariant varying must fail", + }, + { + vShaderId: "vertexShaderInvariant", + vShaderSuccess: true, + fShaderId: "fragmentShaderVariant", + fShaderSuccess: true, + linkSuccess: false, + passMsg: "vertex shader with invariant varying and fragment shader with variant varying must fail", + }, + { + vShaderId: "vertexShaderGlobalInvariant", + vShaderSuccess: true, + fShaderId: "fragmentShaderVariant", + fShaderSuccess: true, + linkSuccess: false, + passMsg: "vertex shader with invariant (global setting) varying and fragment shader with variant varying must fail", + }, + { + vShaderId: "vertexShaderGlobalInvariant", + vShaderSuccess: true, + fShaderId: "fragmentShaderInvariant", + fShaderSuccess: true, + linkSuccess: true, + passMsg: "vertex shader with invariant (global setting) varying and fragment shader with invariant varying must succeed", + }, + { + vShaderId: "vertexShaderSeparateInvariant", + vShaderSuccess: true, + fShaderId: "fragmentShaderInvariant", + fShaderSuccess: true, + linkSuccess: true, + passMsg: "vertex shader with invariant (separately set) varying and fragment shader with invariant varying must succeed", + }, + { + vShaderId: "vertexShaderInvariant", + vShaderSuccess: true, + fShaderId: "fragmentShaderSeparateInvariant", + fShaderSuccess: true, + linkSuccess: true, + passMsg: "vertex shader with invariant varying and fragment shader with invariant (separately set) varying must succeed", + }, + { + vShaderId: "vertexShaderSeparateInvariantWrongOrder", + vShaderSuccess: false, + fShaderId: "fragmentShaderInvariant", + fShaderSuccess: true, + linkSuccess: false, + passMsg: "vertex shader with invariant (separately set in wrong order) varying must fail", + }, + { + vShaderId: "vertexShaderInvariant", + vShaderSuccess: true, + fShaderId: "fragmentShaderSeparateInvariantWrongOrder", + fShaderSuccess: false, + linkSuccess: false, + passMsg: "fragment shader with invariant (separately set in wrong order) varying must fail", + }, + { + vShaderId: "vertexShaderInvariantGlPosition", + vShaderSuccess: true, + fShaderId: "fragmentShaderInvariantGlFragCoord", + fShaderSuccess: true, + linkSuccess: true, + passMsg: "vertex shader with invariant gl_Position and fragment shader with invariant gl_FragCoord must succeed", + }, + { + vShaderId: "vertexShaderVariant", + vShaderSuccess: true, + fShaderId: "fragmentShaderInvariantGlFragCoord", + fShaderSuccess: true, + linkSuccess: false, + passMsg: "vertex shader with variant gl_Position and fragment shader with invariant gl_FragCoord must fail", + }, + { + vShaderId: "vertexShaderInvariantGlPosition", + vShaderSuccess: true, + fShaderId: "fragmentShaderVariantGlFragCoord", + fShaderSuccess: true, + linkSuccess: true, + passMsg: "vertex shader with invariant gl_Position and fragment shader with variant gl_FragCoord must succeed", + }, + { + vShaderId: "vertexShaderInvariantGlPointSize", + vShaderSuccess: true, + fShaderId: "fragmentShaderInvariantGlPointCoord", + fShaderSuccess: true, + linkSuccess: true, + passMsg: "vertex shader with invariant gl_PointSize and fragment shader with invariant gl_PointCoord must succeed", + }, + { + vShaderId: "vertexShaderVariant", + vShaderSuccess: true, + fShaderId: "fragmentShaderInvariantGlPointCoord", + fShaderSuccess: true, + linkSuccess: false, + passMsg: "vertex shader with variant gl_PointSize and fragment shader with invariant gl_PointCoord must fail", + }, + { + vShaderId: "vertexShaderInvariantGlPointSize", + vShaderSuccess: true, + fShaderId: "fragmentShaderVariantGlPointCoord", + fShaderSuccess: true, + linkSuccess: true, + passMsg: "vertex shader with invariant gl_PointSize and fragment shader with variant gl_PointCoord must succeed", + }, + { + vShaderId: "vertexShaderVariant", + vShaderSuccess: true, + fShaderId: "fragmentShaderVariantGlFrontFacing", + fShaderSuccess: true, + linkSuccess: true, + passMsg: "fragment shader with variant gl_FrontFacing must succeed compilation", + }, + { + vShaderId: "vertexShaderVariant", + vShaderSuccess: true, + fShaderId: "fragmentShaderInvariantGlFrontFacing", + fShaderSuccess: false, + linkSuccess: false, + passMsg: "fragment shader with invariant gl_FrontFacing must fail compilation", + }, + { + vShaderId: "vertexShaderVariant", + vShaderSuccess: true, + fShaderId: "fragmentShaderGlobalInvariant", + fShaderSuccess: true, + linkSuccess: false, + passMsg: "vertex shader with variant varying and fragment shader with invariant (global setting) varying must fail", + }, + { + vShaderId: "vertexShaderInvariant", + vShaderSuccess: true, + fShaderId: "fragmentShaderGlobalInvariant", + fShaderSuccess: true, + linkSuccess: true, + passMsg: "vertex shader with invariant varying and fragment shader with invariant (global setting) varying must succeed", + } +]; + +GLSLConformanceTester.runTests(cases); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shaders-with-mis-matching-uniforms.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shaders-with-mis-matching-uniforms.html new file mode 100644 index 000000000..bd7f77a3e --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shaders-with-mis-matching-uniforms.html @@ -0,0 +1,108 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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"> +// Shaders with mis-matching uniform types should fail +// GLSL 1.017 4.3.4 +uniform $(type) u_uniform; + +void main() +{ + gl_Position = $(code); +} +</script> +<script id="fragmentShader" type="text/something-not-javascript"> +// Shaders with mis-matching uniform types should fail +// GLSL 1.017 4.3.4 +precision mediump float; + +uniform $(type) u_uniform; + +void main() +{ + gl_FragColor = $(code); +} +</script> +<script> +"use strict"; +var wtu = WebGLTestUtils; +var uniformTypes = [ + { type: "bool", code: "vec4(u_uniform, 0, 0, 0)", }, + { type: "float", code: "vec4(u_uniform, 0, 0, 0)", }, + { type: "int", code: "vec4(u_uniform, 0, 0, 0)", }, + { type: "vec2", code: "vec4(u_uniform, 0, 0)", }, + { type: "ivec2", code: "vec4(u_uniform, 0, 0)", }, + { type: "bvec2", code: "vec4(u_uniform, 0, 0)", }, + { type: "vec3", code: "vec4(u_uniform, 0)", }, + { type: "ivec3", code: "vec4(u_uniform, 0)", }, + { type: "bvec3", code: "vec4(u_uniform, 0)", }, + { type: "vec4", code: "vec4(u_uniform)", }, + { type: "ivec4", code: "vec4(u_uniform)", }, + { type: "bvec4", code: "vec4(u_uniform)", }, + { type: "mat2", code: "vec4(u_uniform[0][0], 0, 0, 0)", }, + { type: "mat3", code: "vec4(u_uniform[0][0], 0, 0, 0)", }, + { type: "mat4", code: "vec4(u_uniform[0][0], 0, 0, 0)", }, +]; +var vSource = wtu.getScript("vertexShader"); +var fSource = wtu.getScript("fragmentShader"); +var tests = []; +for (var ii = 0; ii < uniformTypes.length; ++ii) { + var u1 = uniformTypes[ii]; + var vs = wtu.replaceParams(vSource, u1); + for (var jj = ii + 1; jj < uniformTypes.length; ++jj) { + var u2 = uniformTypes[jj]; + var fs = wtu.replaceParams(fSource, u2); + tests.push({ + vShaderSource: vs, + vShaderSuccess: true, + fShaderSource: fs, + fShaderSuccess: true, + linkSuccess: false, + passMsg: "vertex shader with uniform " + u1.type + " and fragment shader with uniform " + u2.type + " with the same name should fail to link", + }); + } +} + +GLSLConformanceTester.runTests(tests); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shaders-with-mis-matching-varyings.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shaders-with-mis-matching-varyings.html new file mode 100644 index 000000000..f49426d1e --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shaders-with-mis-matching-varyings.html @@ -0,0 +1,101 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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"> +// Shaders with mis-matching varying types should fail +// GLSL 1.0.17 4.3.5 +attribute $(type) a_attribute; +varying $(type) v_varying; + +void main() +{ + v_varying = a_attribute; + gl_Position = vec4(0,0,0,0); +} +</script> +<script id="fragmentShader" type="text/something-not-javascript"> +// Shaders with mis-matching varyings types should fail +// GLSL 1.0.17 4.3.5 +precision mediump float; + +varying $(type) v_varying; + +void main() +{ + gl_FragColor = $(code); +} +</script> +<script> +"use strict"; +var wtu = WebGLTestUtils; +var varyingTypes = [ + { type: "float", code: "vec4(v_varying, 0, 0, 0)", }, + { type: "vec2", code: "vec4(v_varying, 0, 0)", }, + { type: "vec3", code: "vec4(v_varying, 0)", }, + { type: "vec4", code: "vec4(v_varying)", }, + { type: "mat2", code: "vec4(v_varying[0][0], 0, 0, 0)", }, + { type: "mat3", code: "vec4(v_varying[0][0], 0, 0, 0)", }, + { type: "mat4", code: "vec4(v_varying[0][0], 0, 0, 0)", }, +]; +var vSource = wtu.getScript("vertexShader"); +var fSource = wtu.getScript("fragmentShader"); +var tests = []; +for (var ii = 0; ii < varyingTypes.length; ++ii) { + var u1 = varyingTypes[ii]; + var vs = wtu.replaceParams(vSource, u1); + for (var jj = ii + 1; jj < varyingTypes.length; ++jj) { + var u2 = varyingTypes[jj]; + var fs = wtu.replaceParams(fSource, u2); + tests.push({ + vShaderSource: vs, + vShaderSuccess: true, + fShaderSource: fs, + fShaderSuccess: true, + linkSuccess: false, + passMsg: "vertex shader with varying " + u1.type + " and fragment shader with varying " + u2.type + " with the same name should fail to link", + }); + } +} +GLSLConformanceTester.runTests(tests); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shaders-with-missing-varyings.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shaders-with-missing-varyings.html new file mode 100644 index 000000000..bdbc48cb7 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shaders-with-missing-varyings.html @@ -0,0 +1,95 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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"> +// GLSL 1.0.17 4.3.5 +void main() +{ + gl_Position = vec4(0,0,0,0); +} +</script> +<script id="fragmentShader" type="text/something-not-javascript"> +// GLSL 1.0.17 4.3.5 +precision mediump float; + +varying $(type) v_varying; + +void main() +{ + gl_FragColor = $(code); +} +</script> +<script> +"use strict"; +var wtu = WebGLTestUtils; +var varyingTypes = [ + { type: "float", code: "vec4(v_varying, 0, 0, 0)", }, + { type: "vec2", code: "vec4(v_varying, 0, 0)", }, + { type: "vec3", code: "vec4(v_varying, 0)", }, + { type: "vec4", code: "vec4(v_varying)", }, + { type: "mat2", code: "vec4(v_varying[0][0], 0, 0, 0)", }, + { type: "mat3", code: "vec4(v_varying[0][0], 0, 0, 0)", }, + { type: "mat4", code: "vec4(v_varying[0][0], 0, 0, 0)", }, +]; +var vSource = wtu.getScript("vertexShader"); +var fSource = wtu.getScript("fragmentShader"); +var tests = []; +for (var ii = 0; ii < varyingTypes.length; ++ii) { + var u1 = varyingTypes[ii]; + var vs = wtu.replaceParams(vSource, u1); + for (var jj = ii + 1; jj < varyingTypes.length; ++jj) { + var u2 = varyingTypes[jj]; + var fs = wtu.replaceParams(fSource, u2); + tests.push({ + vShaderSource: vs, + vShaderSuccess: true, + fShaderSource: fs, + fShaderSuccess: true, + linkSuccess: false, + passMsg: "vertex shader no varyings and fragment shader with varying " + u2.type + " should fail to link", + }); + } +} +GLSLConformanceTester.runTests(tests); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shaders-with-name-conflicts.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shaders-with-name-conflicts.html new file mode 100644 index 000000000..8dc84e01e --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shaders-with-name-conflicts.html @@ -0,0 +1,104 @@ +<!-- + +/* +** Copyright (c) 2013 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="fragmentShader" type="text/something-not-javascript"> +// fragment shader should succeed +precision mediump float; +uniform vec4 foo; +void main() +{ + gl_FragColor = foo; +} +</script> +<script id="vertexShader" type="text/something-not-javascript"> +// vertex shader should succeed +attribute vec4 foo; +void main() +{ + gl_Position = foo; +} +</script> +<script> +"use strict"; + +/* +GLSL 1.017 section 4.2.6 + +... + +With the exception of uniform declarations, vertex and fragment shaders +have separate name spaces. Functions and global variables declared in a +vertex shader cannot be referenced by a fragment shader and vice versa. +Uniforms have a single name space. Uniforms declared with the same name +must have matching types and precisions. + +Section 4.3.3 + +Attribute variables are required to have global scope + +Section 4.3.4 + +The uniform qualifier is used to declare global variables + +QED: If both uniforms and attributes are in the global namespace they +conflict across shaders + +Note: This was brought up on the OpenGL ES working group and confirmed +that the spec required these conflicts to fail to link. + +Though most drivers allow this to work, some drivers to do no therefore +WebGL implementation must enforce this restriction to provide consistent +behavior. +*/ + +GLSLConformanceTester.runTests([ + { vShaderId: 'vertexShader', + vShaderSuccess: true, + fShaderId: 'fragmentShader', + fShaderSuccess: true, + linkSuccess: false, + passMsg: 'shaders with conflicting uniform/attribute names should fail' + }, +]); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shaders-with-uniform-structs.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shaders-with-uniform-structs.html new file mode 100644 index 000000000..63301ab4c --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shaders-with-uniform-structs.html @@ -0,0 +1,310 @@ +<!-- + +/* +** Copyright (c) 2014 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="vertexShaderStructSequence" type="text/something-not-javascript"> +// Structures must have the same name, sequence of type names, and +// type definitions, and field names to be considered the same type. +// GLSL 1.017 4.2.4 +precision mediump float; +struct info { + vec4 pos; + vec4 color; +}; + +uniform info uni; +void main() +{ + gl_Position = uni.pos; +} +</script> +<script id="fragmentShaderStructSequence" type="text/something-not-javascript"> +// Structures must have the same name, sequence of type names, and +// type definitions, and field names to be considered the same type. +// GLSL 1.017 4.2.4 +precision mediump float; +struct info { + vec4 color; + vec4 pos; +}; + +uniform info uni; +void main() +{ + gl_FragColor = uni.color; +} +</script> +<script id="vertexShaderStructName" type="text/something-not-javascript"> +// Structures must have the same name, sequence of type names, and +// type definitions, and field names to be considered the same type. +// GLSL 1.017 4.2.4 +precision mediump float; +struct info { + vec4 pos; + vec4 color; +}; + +uniform info uni; +void main() +{ + gl_Position = uni.pos; +} +</script> +<script id="fragmentShaderStructNameFailure" type="text/something-not-javascript"> +// Structures must have the same name, sequence of type names, and +// type definitions, and field names to be considered the same type. +// GLSL 1.017 4.2.4 +precision mediump float; +struct info1 { + vec4 pos; + vec4 color; +}; + +uniform info1 uni; +void main() +{ + gl_FragColor = uni.color; +} +</script> +<script id="fragmentShaderStructNameSuccess" type="text/something-not-javascript"> +// Structures must have the same name, sequence of type names, and +// type definitions, and field names to be considered the same type. +// GLSL 1.017 4.2.4 +precision mediump float; + +// Add a struct before info to make sure the struct info here is assigned +// a different internal unique ID from the struct info in vertex shader. +struct extra { + vec4 p; +}; + +struct info { + vec4 pos; + vec4 color; +}; + +uniform info uni; +void main() +{ + extra my; + my.p = uni.color; + gl_FragColor = my.p; +} +</script> +<script id="vertexShaderStructFieldName" type="text/something-not-javascript"> +// Structures must have the same name, sequence of type names, and +// type definitions, and field names to be considered the same type. +// GLSL 1.017 4.2.4 +precision mediump float; +struct info { + vec4 pos; + vec4 color; +}; + +uniform info uni; +void main() +{ + gl_Position = uni.pos; +} +</script> +<script id="fragmentShaderStructFieldName" type="text/something-not-javascript"> +// Structures must have the same name, sequence of type names, and +// type definitions, and field names to be considered the same type. +// GLSL 1.017 4.2.4 +precision mediump float; +struct info { + vec4 pos1; + vec4 color; +}; + +uniform info uni; +void main() +{ + gl_FragColor = uni.color; +} +</script> +<script id="vertexShaderStructFieldType" type="text/something-not-javascript"> +// Structures must have the same name, sequence of type names, and +// type definitions, and field names to be considered the same type. +// GLSL 1.017 4.2.4 +precision mediump float; +struct info { + vec4 pos; + vec4 color; +}; + +uniform info uni; +void main() +{ + gl_Position = uni.pos; +} +</script> +<script id="fragmentShaderStructFieldType" type="text/something-not-javascript"> +// Structures must have the same name, sequence of type names, and +// type definitions, and field names to be considered the same type. +// GLSL 1.017 4.2.4 +precision mediump float; +struct info { + vec3 pos; + vec4 color; +}; + +uniform info uni; +void main() +{ + gl_FragColor = uni.color; +} +</script> +<script id="vertexShaderStructFieldPrecision" type="text/something-not-javascript"> +// Structures must have the same name, sequence of type names, and +// type definitions, and field names to be considered the same type. +// GLSL 1.017 4.2.4 +struct info { + mediump vec4 pos; + highp vec4 color; +}; + +uniform info uni; +void main() +{ + gl_Position = uni.pos; +} +</script> +<script id="fragmentShaderStructFieldPrecision" type="text/something-not-javascript"> +// Structures must have the same name, sequence of type names, and +// type definitions, and field names to be considered the same type. +// GLSL 1.017 4.2.4 +precision mediump float; +struct info { + vec4 pos; + vec4 color; +}; + +uniform info uni; +void main() +{ + gl_FragColor = uni.color; +} +</script> +<script id="vertexShaderUnnamedStruct" type="text/something-not-javascript"> +// ANGLE regression on Windows, crbug.com/401296 +uniform struct { + float f; + vec4 v; +} u_struct; + +void main() +{ + gl_Position = u_struct.f * u_struct.v; +} +</script> +<script id="fragmentShaderSimple" type="text/something-not-javascript"> +void main() +{ + gl_FragColor = vec4(1.0); +} +</script> +<script> +"use strict"; +var wtu = WebGLTestUtils; + +var tests = []; +tests.push({ + vShaderSource: wtu.getScript("vertexShaderStructName"), + vShaderSuccess: true, + fShaderSource: wtu.getScript("fragmentShaderStructNameSuccess"), + fShaderSuccess: true, + linkSuccess: true, + passMsg: "Structures with the same defination must be considered the same type.", +}); +tests.push({ + vShaderSource: wtu.getScript("vertexShaderStructName"), + vShaderSuccess: true, + fShaderSource: wtu.getScript("fragmentShaderStructNameFailure"), + fShaderSuccess: true, + linkSuccess: false, + passMsg: "Structures must have the same name to be considered the same type.", +}); +tests.push({ + vShaderSource: wtu.getScript("vertexShaderStructSequence"), + vShaderSuccess: true, + fShaderSource: wtu.getScript("fragmentShaderStructSequence"), + fShaderSuccess: true, + linkSuccess: false, + passMsg: "Structures must have the same sequence of type names to be considered the same type.", +}); +tests.push({ + vShaderSource: wtu.getScript("vertexShaderStructFieldName"), + vShaderSuccess: true, + fShaderSource: wtu.getScript("fragmentShaderStructFieldName"), + fShaderSuccess: true, + linkSuccess: false, + passMsg: "Structures must have the same field names to be considered the same type.", +}); +tests.push({ + vShaderSource: wtu.getScript("vertexShaderStructFieldType"), + vShaderSuccess: true, + fShaderSource: wtu.getScript("fragmentShaderStructFieldType"), + fShaderSuccess: true, + linkSuccess: false, + passMsg: "Structures must have the same type definitions to be considered the same type.", +}); +tests.push({ + vShaderSource: wtu.getScript("vertexShaderStructFieldPrecision"), + vShaderSuccess: true, + fShaderSource: wtu.getScript("fragmentShaderStructFieldPrecision"), + fShaderSuccess: true, + linkSuccess: false, + passMsg: "Structures must have the same type definitions (including precision) to be considered the same type.", +}); +tests.push({ + vShaderSource: wtu.getScript("vertexShaderUnnamedStruct"), + vShaderSuccess: true, + fShaderSource: wtu.getScript("fragmentShaderSimple"), + fShaderSuccess: true, + linkSuccess: true, + passMsg: "Shaders with uniforms of unnamed struct type should compile and link successfully.", +}); + +GLSLConformanceTester.runTests(tests); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shaders-with-varyings.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shaders-with-varyings.html new file mode 100644 index 000000000..a33866596 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shaders-with-varyings.html @@ -0,0 +1,124 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="vertexShaderNoVarying" type="text/something-not-javascript"> +void main() +{ + gl_Position = vec4(0,0,0,0); +} +</script> +<script id="vertexShaderUnusedVarying" type="text/something-not-javascript"> +varying vec4 v_varying; + +void main() +{ + gl_Position = vec4(0,0,0,0); +} +</script> +<script id="vertexShaderUsedVarying" type="text/something-not-javascript"> +varying vec4 v_varying; + +void main() +{ + gl_Position = v_varying; +} +</script> +<script id="fragmentShaderUnusedVarying" type="text/something-not-javascript"> +precision mediump float; + +varying vec4 v_varying; + +void main() +{ + gl_FragColor = vec4(0,0,0,0); +} +</script> +<script id="fragmentShaderUsedVarying" type="text/something-not-javascript"> +precision mediump float; + +varying vec4 v_varying; + +void main() +{ + gl_FragColor = v_varying; +} +</script> +<script> +// GLSL 1.0.17 4.3.5 +"use strict"; +GLSLConformanceTester.runTests([ + { + vShaderId: "vertexShaderNoVarying", + vShaderSuccess: true, + fShaderId: "fragmentShaderUnusedVarying", + fShaderSuccess: true, + linkSuccess: true, + passMsg: "vertex shader with no varying and fragment shader with unused varying must succeed", + }, + { + vShaderId: "vertexShaderNoVarying", + vShaderSuccess: true, + fShaderId: "fragmentShaderUsedVarying", + fShaderSuccess: true, + linkSuccess: false, + passMsg: "vertex shader with no varying and fragment shader with used varying must fail", + }, + { + vShaderId: "vertexShaderUnusedVarying", + vShaderSuccess: true, + fShaderId: "fragmentShaderUnusedVarying", + fShaderSuccess: true, + linkSuccess: true, + passMsg: "vertex shader with unused varying and fragment shader with unused varying must succeed", + }, + { + vShaderId: "vertexShaderUnusedVarying", + vShaderSuccess: true, + fShaderId: "fragmentShaderUsedVarying", + fShaderSuccess: true, + linkSuccess: true, + passMsg: "vertex shader with unused varying and fragment shader with used varying must succeed", + }, +]); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shared.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shared.html new file mode 100644 index 000000000..4776d2a15 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shared.html @@ -0,0 +1,172 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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="sharedVertexShader" type="text/something-not-javascript"> +// shared vertex shader should succeed. +uniform mat4 viewProjection; +uniform vec3 worldPosition; +uniform vec3 nextPosition; +uniform float fishLength; +uniform float fishWaveLength; +uniform float fishBendAmount; +attribute vec4 position; +attribute vec2 texCoord; +varying vec4 v_position; +varying vec2 v_texCoord; +varying vec3 v_surfaceToLight; +void main() { + vec3 vz = normalize(worldPosition - nextPosition); + vec3 vx = normalize(cross(vec3(0,1,0), vz)); + vec3 vy = cross(vz, vx); + mat4 orientMat = mat4( + vec4(vx, 0), + vec4(vy, 0), + vec4(vz, 0), + vec4(worldPosition, 1)); + mat4 world = orientMat; + mat4 worldViewProjection = viewProjection * world; + mat4 worldInverseTranspose = world; + + v_texCoord = texCoord; + // NOTE:If you change this you need to change the laser code to match! + float mult = position.z > 0.0 ? + (position.z / fishLength) : + (-position.z / fishLength * 2.0); + float s = sin(mult * fishWaveLength); + float a = sign(s); + float offset = pow(mult, 2.0) * s * fishBendAmount; + v_position = ( + worldViewProjection * + (position + + vec4(offset, 0, 0, 0))); + v_surfaceToLight = (world * position).xyz; + gl_Position = v_position; +} +</script> +<script id="fragmentShaderA" type="text/something-not-javascript"> +// shared fragment shader should succeed. +precision mediump float; +uniform vec4 lightColor; +varying vec4 v_position; +varying vec2 v_texCoord; +varying vec3 v_surfaceToLight; + +uniform vec4 ambient; +uniform sampler2D diffuse; +uniform vec4 specular; +uniform float shininess; +uniform float specularFactor; +// #fogUniforms + +vec4 lit(float l ,float h, float m) { + return vec4(1.0, + max(l, 0.0), + (l > 0.0) ? pow(max(0.0, h), m) : 0.0, + 1.0); +} +void main() { + vec4 diffuseColor = texture2D(diffuse, v_texCoord); + vec4 normalSpec = vec4(0,0,0,0); // #noNormalMap + vec3 surfaceToLight = normalize(v_surfaceToLight); + vec3 halfVector = normalize(surfaceToLight); + vec4 litR = lit(1.0, 1.0, shininess); + vec4 outColor = vec4( + (lightColor * (diffuseColor * litR.y + diffuseColor * ambient + + specular * litR.z * specularFactor * normalSpec.a)).rgb, + diffuseColor.a); + // #fogCode + gl_FragColor = outColor; +} +</script> +<script id="fragmentShaderB" type="text/something-not-javascript"> +// shared fragment shader should succeed. +precision mediump float; +varying vec4 v_position; +varying vec2 v_texCoord; +varying vec3 v_surfaceToLight; + +// #fogUniforms + +vec4 lit(float l ,float h, float m) { + return vec4(1.0, + max(l, 0.0), + (l > 0.0) ? pow(max(0.0, h), m) : 0.0, + 1.0); +} +void main() { + vec4 normalSpec = vec4(0,0,0,0); // #noNormalMap + vec4 reflection = vec4(0,0,0,0); // #noReflection + vec3 surfaceToLight = normalize(v_surfaceToLight); + vec4 skyColor = vec4(0.5,0.5,1,1); // #noReflection + + vec3 halfVector = normalize(surfaceToLight); + vec4 litR = lit(1.0, 1.0, 10.0); + vec4 outColor = vec4(mix( + skyColor, + vec4(1,2,3,4) * (litR.y + litR.z * normalSpec.a), + 1.0 - reflection.r).rgb, + 1.0); + // #fogCode + gl_FragColor = outColor; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTests([ + { vShaderSource: document.getElementById("sharedVertexShader").text, + vShaderSuccess: true, + fShaderSource: document.getElementById("fragmentShaderA").text, + fShaderSuccess: true, + linkSuccess: true, + passMsg: 'shared fragment shader should succeed', + }, + { vShaderSource: document.getElementById("sharedVertexShader").text, + vShaderSuccess: true, + fShaderSource: document.getElementById("fragmentShaderB").text, + fShaderSuccess: true, + linkSuccess: true, + passMsg: 'shared fragment shader should succeed', + } +]); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-assign.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-assign.html new file mode 100644 index 000000000..26844fa13 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-assign.html @@ -0,0 +1,233 @@ +<!-- +/* +** Copyright (c) 2015 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 Structure Assignment Test</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> + +<script id="simple-vs" type="x-shader/x-vertex"> +attribute vec4 a_position; +void main(void) { + gl_Position = a_position; +} +</script> +<script id="simple-struct-fs" type="x-shader/x-fragment"> +precision mediump float; +struct my_struct { + float f; +}; + +my_struct a = my_struct(0.0); +my_struct b = my_struct(1.0); + +void main(void) { + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); + a = b; + if (a.f == 1.0) { + gl_FragColor.y = 1.0; + } +} +</script> +<script id="vec-struct-fs" type="x-shader/x-fragment"> +precision mediump float; +struct my_struct { + vec3 v; +}; + +my_struct a = my_struct(vec3(0.0, 0.0, 0.0)); +my_struct b = my_struct(vec3(1.0, 2.0, 3.0)); + +void main(void) { + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); + a = b; + if (a.v.x == 1.0) { + gl_FragColor.y = 1.0; + } +} +</script> +<script id="nested-struct-fs" type="x-shader/x-fragment"> +precision mediump float; + +struct s1 +{ + float f; +}; + +struct s2 +{ + s1 s; +}; + +s2 a = s2(s1(0.0)); +s2 b = s2(s1(1.0)); + +void main(void) { + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); + a = b; + if (a.s.f == 1.0) { + gl_FragColor.y = 1.0; + } +} +</script> +<script id="nested-vec-struct-fs" type="x-shader/x-fragment"> +precision mediump float; + +struct s1 +{ + vec3 v; +}; + +struct s2 +{ + s1 s; +}; + +s2 a = s2(s1(vec3(0.0, 0.0, 0.0))); +s2 b = s2(s1(vec3(1.0, 2.0, 3.0))); + +void main(void) { + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); + a = b; + if (a.s.v.x == 1.0) { + gl_FragColor.y = 1.0; + } +} +</script> +<script id="array-struct-fs" type="x-shader/x-fragment"> +precision mediump float; + +struct my_struct +{ + float f[3]; +}; + +void main(void) { + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); + my_struct a; + my_struct b; + for (int i = 0; i < 3; ++i) { + a.f[i] = 0.0; + b.f[i] = float(i); + } + + a = b; + if (a.f[1] == 1.0 && a.f[2] == 2.0) { + gl_FragColor.y = 1.0; + } +} +</script> +<script id="sampler-struct-fs" type="x-shader/x-fragment"> +precision mediump float; + +struct my_struct +{ + sampler2D s; +}; + +uniform my_struct a; + +void main(void) { + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); + my_struct b; + b = a; +} +</script> +</head> +<body> +<canvas id="canvas" width="50" height="50"></canvas> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +description("Testing struct assignment"); + +var wtu = WebGLTestUtils; +GLSLConformanceTester.runTests([ + { + vShaderId: "simple-vs", + vShaderSuccess: true, + fShaderId: "simple-struct-fs", + fShaderSuccess: true, + linkSuccess: true, + render: true, + passMsg: "Simple struct with one float", + }, + { + vShaderId: "simple-vs", + vShaderSuccess: true, + fShaderId: "vec-struct-fs", + fShaderSuccess: true, + linkSuccess: true, + render: true, + passMsg: "Simple struct with a vector", + }, + { + vShaderId: "simple-vs", + vShaderSuccess: true, + fShaderId: "nested-struct-fs", + fShaderSuccess: true, + linkSuccess: true, + render: true, + passMsg: "Nested struct with a float", + }, + { + vShaderId: "simple-vs", + vShaderSuccess: true, + fShaderId: "nested-vec-struct-fs", + fShaderSuccess: true, + linkSuccess: true, + render: true, + passMsg: "Nested struct with a vector", + }, + { + vShaderId: "simple-vs", + vShaderSuccess: true, + fShaderId: "array-struct-fs", + fShaderSuccess: false, + linkSuccess: false, + passMsg: "Assigning a struct containing an array should not compile", + }, + { + vShaderId: "simple-vs", + vShaderSuccess: true, + fShaderId: "sampler-struct-fs", + fShaderSuccess: false, + linkSuccess: false, + passMsg: "Assigning a struct containing a sampler should not compile", + } +]); +debug(""); + +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-equals.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-equals.html new file mode 100644 index 000000000..fee52dbbf --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-equals.html @@ -0,0 +1,238 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL Structure Equals Test</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> + +<script id="simple-vs" type="x-shader/x-vertex"> +attribute vec4 a_position; +void main(void) { + gl_Position = a_position; +} +</script> +<script id="simple-struct-fs" type="x-shader/x-fragment"> +precision mediump float; +struct my_struct { + float f; +}; + +my_struct a = my_struct(1.0); +my_struct b = my_struct(1.0); + +void main(void) { + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); + + if (a == b) { + gl_FragColor.y = 1.0; + } +} +</script> +<script id="vec-struct-fs" type="x-shader/x-fragment"> +precision mediump float; +struct my_struct { + vec3 v; +}; + +my_struct a = my_struct(vec3(1.0, 2.0, 3.0)); +my_struct b = my_struct(vec3(1.0, 2.0, 3.0)); + +void main(void) { + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); + + if (a == b) { + gl_FragColor.y = 1.0; + } +} +</script> +<script id="nested-struct-fs" type="x-shader/x-fragment"> +precision mediump float; + +struct s1 +{ + float f; +}; + +struct s2 +{ + s1 s; +}; + +s2 a = s2(s1(1.0)); +s2 b = s2(s1(1.0)); + +void main(void) { + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); + + if (a == b) { + gl_FragColor.y = 1.0; + } +} +</script> +<script id="nested-vec-struct-fs" type="x-shader/x-fragment"> +precision mediump float; + +struct s1 +{ + vec3 v; +}; + +struct s2 +{ + s1 s; +}; + +s2 a = s2(s1(vec3(1.0, 2.0, 3.0))); +s2 b = s2(s1(vec3(1.0, 2.0, 3.0))); + +void main(void) { + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); + + if (a == b) { + gl_FragColor.y = 1.0; + } +} +</script> +<script id="array-struct-fs" type="x-shader/x-fragment"> +precision mediump float; + +struct my_struct +{ + float f[3]; +}; + +void main(void) { + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); + my_struct a; + my_struct b; + for (int i = 0; i < 3; ++i) { + a.f[i] = 0.0; + b.f[i] = 1.0; + } + + if (a == b) { + gl_FragColor.x = 1.0; + } +} +</script> +<script id="sampler-struct-fs" type="x-shader/x-fragment"> +precision mediump float; + +struct my_struct +{ + sampler2D s; +}; + +uniform my_struct a; +uniform my_struct b; + +void main(void) { + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); + + if (a == b) { + gl_FragColor.x = 1.0; + } +} +</script> +</head> +<body> +<canvas id="canvas" width="50" height="50"></canvas> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +description("Testing struct equals"); + +var wtu = WebGLTestUtils; +GLSLConformanceTester.runTests([ + { + vShaderId: "simple-vs", + vShaderSuccess: true, + fShaderId: "simple-struct-fs", + fShaderSuccess: true, + linkSuccess: true, + render: true, + passMsg: "Simple struct with one float", + }, + { + vShaderId: "simple-vs", + vShaderSuccess: true, + fShaderId: "vec-struct-fs", + fShaderSuccess: true, + linkSuccess: true, + render: true, + passMsg: "Simple struct with a vector", + }, + { + vShaderId: "simple-vs", + vShaderSuccess: true, + fShaderId: "nested-struct-fs", + fShaderSuccess: true, + linkSuccess: true, + render: true, + passMsg: "Nested struct with a float", + }, + { + vShaderId: "simple-vs", + vShaderSuccess: true, + fShaderId: "nested-vec-struct-fs", + fShaderSuccess: true, + linkSuccess: true, + render: true, + passMsg: "Nested struct with a vector", + }, + { + vShaderId: "simple-vs", + vShaderSuccess: true, + fShaderId: "array-struct-fs", + fShaderSuccess: false, + linkSuccess: false, + passMsg: "Comparing a struct containing an array should not compile", + }, + { + vShaderId: "simple-vs", + vShaderSuccess: true, + fShaderId: "sampler-struct-fs", + fShaderSuccess: false, + linkSuccess: false, + passMsg: "Comparing a struct containing a sampler should not compile", + } +]); +debug(""); + +var successfullyParsed = true; +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-mixed-array-declarators.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-mixed-array-declarators.html new file mode 100644 index 000000000..c06002bcd --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-mixed-array-declarators.html @@ -0,0 +1,90 @@ +<!-- +/* +** Copyright (c) 2014 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ +--> +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<link rel="stylesheet" href="../../../resources/js-test-style.css" /> +<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> +<title></title> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script id="fragmentShader" type="text/something-not-javascript"> +precision mediump float; +void main() { + struct S { + $(type) field; + }; + S s1[2], s2; + $(var).field = $(initializer); + gl_FragColor = $(asVec4); +} +</script> +<script> +"use strict"; +description("Verifies that mixed (array vs. not array) struct declarators work correctly."); +var tests = []; +var wtu = WebGLTestUtils; +var typeInfos = [ + { type: 'float', initializer: '1.0', asVec4: 'vec4(0.0,$(var).field,0.0,1.0)' }, + { type: 'vec2', initializer: 'vec2(0.0, 1.0)', asVec4: 'vec4($(var).field,0.0,1.0)' }, + { type: 'vec3', initializer: 'vec3(0.0, 1.0, 0.0)', asVec4: 'vec4($(var).field,1.0)' }, + { type: 'vec4', initializer: 'vec4(0.0, 1.0, 0.0, 1.0)', asVec4: '$(var).field' }, + { type: 'int', initializer: '1', asVec4: 'vec4(0.0,$(var).field,0.0,1.0)' }, + { type: 'ivec2', initializer: 'ivec2(0, 1)', asVec4: 'vec4($(var).field,0.0,1.0)' }, + { type: 'ivec3', initializer: 'ivec3(0, 1, 0)', asVec4: 'vec4($(var).field,1.0)' }, + { type: 'ivec4', initializer: 'ivec4(0, 1, 0, 1)', asVec4: 'vec4($(var).field)' }, + { type: 'bool', initializer: 'true', asVec4: 'vec4(0.0,$(var).field,0.0,1.0)' }, + { type: 'bvec2', initializer: 'bvec2(false, true)', asVec4: 'vec4($(var).field,0.0,1.0)' }, + { type: 'bvec3', initializer: 'bvec3(false, true, false)', asVec4: 'vec4($(var).field,1.0)' }, + { type: 'bvec4', initializer: 'bvec4(false,true,false,true)',asVec4: 'vec4($(var).field)' }, +]; +['s1[0]', 's1[1]', 's2'].forEach(function(varName) { + typeInfos.forEach(function (typeInfo) { + var replaceParams = { + type: typeInfo.type, + initializer: typeInfo.initializer, + var: varName, + asVec4: wtu.replaceParams(typeInfo.asVec4, {var: varName}) + }; + tests.push({ + fShaderSource: wtu.replaceParams(wtu.getScript('fragmentShader'), replaceParams), + passMsg: typeInfo.type, + fShaderSuccess: true, + linkSuccess: true, + render:true + }); + }); +}); +GLSLConformanceTester.runTests(tests); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-nesting-exceeds-maximum.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-nesting-exceeds-maximum.html new file mode 100644 index 000000000..c6fe02fbd --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-nesting-exceeds-maximum.html @@ -0,0 +1,76 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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"> +// shader with too-deep struct nesting should fail per WebGL spec +struct nesting5 { + vec4 vecfield; +}; + +struct nesting4 { + nesting5 field5; +}; + +struct nesting3 { + nesting4 field4; +}; + +struct nesting2 { + nesting3 field3; +}; + +struct nesting1 { + nesting2 field2; +}; + +uniform nesting1 uniform1; +void main() +{ + gl_Position = uniform1.field2.field3.field4.field5.vecfield; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-nesting-of-variable-names.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-nesting-of-variable-names.html new file mode 100644 index 000000000..dca72cc46 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-nesting-of-variable-names.html @@ -0,0 +1,93 @@ +<!-- +/* +** Copyright (c) 2014 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ +--> +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<link rel="stylesheet" href="../../../resources/js-test-style.css" /> +<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> +<title></title> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script id="fragmentShader" type="text/something-not-javascript"> +precision mediump float; +struct S { $(outer_type) u; }; +void main() { + S S; // This is legal, 'S' as a typename is defined in another scope. + { + struct S { $(inner_type) a; }; // This is legal as well, 'S' is now defined as a variable name in an ancestor scope + S newvar; + newvar.a = $(initializer); + gl_FragColor = $(fragColor); + } +} +</script> +<script> +"use strict"; +description("This test verifies that defining a typename in a new scope when the typename is the name of a variable that hides a typename declaration succeeds for all combinations of GLSL types."); +var tests = []; +var wtu = WebGLTestUtils; +var typeInfo = [ + { Type: 'float', initializer: '1.0', fragColor: 'vec4(0.0, newvar.a, 0.0, 1.0)' }, + { Type: 'vec2', initializer: 'vec2(0.0, 1.0)', fragColor: 'vec4(newvar.a, 0.0, 1.0)' }, + { Type: 'vec3', initializer: 'vec3(0.0, 1.0, 0.0)', fragColor: 'vec4(newvar.a, 1.0)' }, + { Type: 'vec4', initializer: 'vec4(0.0, 1.0, 0.0, 1.0)', fragColor: 'newvar.a' }, + { Type: 'int', initializer: '1', fragColor: 'vec4(0.0, newvar.a, 0.0, 1.0)' }, + { Type: 'ivec2', initializer: 'ivec2(0, 1)', fragColor: 'vec4(newvar.a, 0.0, 1.0)' }, + { Type: 'ivec3', initializer: 'ivec3(0, 1, 0)', fragColor: 'vec4(newvar.a, 1.0)' }, + { Type: 'ivec4', initializer: 'ivec4(0, 1, 0, 1)', fragColor: 'vec4(newvar.a)' }, + { Type: 'bool', initializer: 'true', fragColor: 'vec4(0.0, newvar.a, 0.0, 1.0)' }, + { Type: 'bvec2', initializer: 'bvec2(false, true)', fragColor: 'vec4(newvar.a, 0.0, 1.0)' }, + { Type: 'bvec3', initializer: 'bvec3(false, true, false)', fragColor: 'vec4(newvar.a, 1.0)' }, + { Type: 'bvec4', initializer: 'bvec4(false,true,false,true)',fragColor: 'vec4(newvar.a)' }, +]; +typeInfo.forEach(function (outerType) { + typeInfo.forEach(function (innerType) { + var replaceParams = { + outer_type: outerType.Type, + inner_type: innerType.Type, + // use the initializer and fragColor for the inner type. Its definition should override the variable name in the outerscope. + initializer: innerType.initializer, + fragColor: innerType.fragColor + }; + tests.push({ + fShaderSource: wtu.replaceParams(wtu.getScript('fragmentShader'), replaceParams), + passMsg: 'Outer struct type: ' + outerType.Type + ' inner struct type: ' + innerType.Type, + fShaderSuccess: true, + linkSuccess: true, + render: true + }); + }) +}) +GLSLConformanceTester.runTests(tests); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-nesting-under-maximum.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-nesting-under-maximum.html new file mode 100644 index 000000000..b208358bb --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-nesting-under-maximum.html @@ -0,0 +1,72 @@ +<!-- + +/* +** Copyright (c) 2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests</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"> +// shader with struct nesting less than maximum in WebGL spec should succeed +struct nesting4 { + vec4 vecfield; +}; + +struct nesting3 { + nesting4 field4; +}; + +struct nesting2 { + nesting3 field3; +}; + +struct nesting1 { + nesting2 field2; +}; + +uniform nesting1 uniform1; +void main() +{ + gl_Position = uniform1.field2.field3.field4.vecfield; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-specifiers-in-uniforms.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-specifiers-in-uniforms.html new file mode 100644 index 000000000..548d640ab --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-specifiers-in-uniforms.html @@ -0,0 +1,84 @@ +<!-- +/* +** Copyright (c) 2014 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ +--> +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<link rel="stylesheet" href="../../../resources/js-test-style.css" /> +<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> +<title></title> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script id="fragmentShader" type="text/something-not-javascript"> +precision mediump float; +uniform struct S { $(type) field;} s; +void main() { + // All uniforms are required to be zero initialized. Add the color green + // to make the rendering test pass. + gl_FragColor = $(asVec4) + vec4(0.0, 1.0, 0.0, 1.0); +} +</script> +<script> +"use strict"; +description("Verifies that structure specifiers work with uniforms."); +var tests = []; +var wtu = WebGLTestUtils; +var typeInfos = [ + { type: 'float', asVec4: 'vec4(0.0,s.field,0.0,0.0)' }, + { type: 'vec2', asVec4: 'vec4(s.field,0.0,0.0)' }, + { type: 'vec3', asVec4: 'vec4(s.field,0.0)' }, + { type: 'vec4', asVec4: 's.field' }, + { type: 'int', asVec4: 'vec4(0.0,s.field,0.0,0.0)' }, + { type: 'ivec2', asVec4: 'vec4(s.field,0.0,0.0)' }, + { type: 'ivec3', asVec4: 'vec4(s.field,0.0)' }, + { type: 'ivec4', asVec4: 'vec4(s.field)' }, + { type: 'bool', asVec4: 'vec4(0.0,s.field,0.0,0.0)' }, + { type: 'bvec2', asVec4: 'vec4(s.field,0.0,0.0)' }, + { type: 'bvec3', asVec4: 'vec4(s.field,0.0)' }, + { type: 'bvec4', asVec4: 'vec4(s.field)' }, +]; +typeInfos.forEach(function (typeInfo) { + var replaceParams = { + type: typeInfo.type, + asVec4: typeInfo.asVec4 + }; + tests.push({ + fShaderSource: wtu.replaceParams(wtu.getScript('fragmentShader'), replaceParams), + passMsg: typeInfo.type, + fShaderSuccess: true, + linkSuccess: true, + render:true + }); +}); +GLSLConformanceTester.runTests(tests); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-unary-operators.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-unary-operators.html new file mode 100644 index 000000000..a2bdecb79 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-unary-operators.html @@ -0,0 +1,89 @@ +<!-- +/* +** Copyright (c) 2014 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ +--> +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<link rel="stylesheet" href="../../../resources/js-test-style.css" /> +<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> +<title></title> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script id="fragmentShader" type="text/something-not-javascript"> +precision mediump float; +struct S { $(type) t; }; +void main() { + S a; + a.t = $(initializer); + S b = $(operator)a; // Unary operators not allowed + gl_FragColor = $(fragColor); +} +</script> +<script> +"use strict"; +description("This test verifies that unary operators +, ++, -, --, !, and ~ do not work on structures. Per the spec, field selectors, equality and assignment are the only operators allowed on structures."); +var tests = []; +var wtu = WebGLTestUtils; +var operators = ['+', '++', '-', '--', '!', '~'] +var typeInfos = [ + { type: 'float', initializer: '1.0', fragColor: 'vec4(0.0, b.t, 0.0, 1.0)' }, + { type: 'vec2', initializer: 'vec2(0.0, 1.0)', fragColor: 'vec4(b.t, 0.0, 1.0)' }, + { type: 'vec3', initializer: 'vec3(0.0, 1.0, 0.0)', fragColor: 'vec4(b.t, 1.0)' }, + { type: 'vec4', initializer: 'vec4(0.0, 1.0, 0.0, 1.0)', fragColor: 'b.t' }, + { type: 'int', initializer: '1', fragColor: 'vec4(0.0, b.t, 0.0, 1.0)' }, + { type: 'ivec2', initializer: 'ivec2(0, 1)', fragColor: 'vec4(b.t, 0.0, 1.0)' }, + { type: 'ivec3', initializer: 'ivec3(0, 1, 0)', fragColor: 'vec4(b.t, 1.0)' }, + { type: 'ivec4', initializer: 'ivec4(0, 1, 0, 1)', fragColor: 'vec4(b.t)' }, + { type: 'bool', initializer: 'true', fragColor: 'vec4(0.0, b.t, 0.0, 1.0)' }, + { type: 'bvec2', initializer: 'bvec2(false, true)', fragColor: 'vec4(b.t, 0.0, 1.0)' }, + { type: 'bvec3', initializer: 'bvec3(false, true, false)', fragColor: 'vec4(b.t, 1.0)' }, + { type: 'bvec4', initializer: 'bvec4(false,true,false,true)',fragColor: 'vec4(b.t)' }, +]; +operators.forEach(function (operator) { + typeInfos.forEach(function (typeInfo) { + var replaceParams = { + initializer: typeInfo.initializer, + type: typeInfo.type, + fragColor: typeInfo.fragColor, + operator: operator, + }; + tests.push({ + fShaderSource: wtu.replaceParams(wtu.getScript('fragmentShader'), replaceParams), + passMsg: 'Unary operator ' + operator + ' cannot be used on a struct with a ' + typeInfo.type, + fShaderSuccess: false, + linkSuccess: false + }); + }); +}); +GLSLConformanceTester.runTests(tests); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/ternary-operator-on-arrays.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/ternary-operator-on-arrays.html new file mode 100644 index 000000000..4c462b617 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/ternary-operator-on-arrays.html @@ -0,0 +1,85 @@ +<!-- + +/* +** Copyright (c) 2015 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 - Ternary operator on arrays</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="fshader-array-ternary-operator" type="x-shader/x-fragment"> +precision mediump float; +void main() +{ + float a[3]; + float b[3]; + float c[3] = true ? a : b; +} +</script> +<script id="fshader-struct-array-ternary-operator" type="x-shader/x-fragment"> +precision mediump float; +struct MyStruct { + bool a[3]; +}; + +void main() +{ + MyStruct b; + MyStruct c; + MyStruct d = true ? b : c; +} +</script> +<script> +"use strict"; +description("Checks ternary operators for structs and arrays."); + +GLSLConformanceTester.runTests([ +{ fShaderId: 'fshader-array-ternary-operator', + fShaderSuccess: false, + linkSuccess: false, + passMsg: "Using ternary operators with arrays is not allowed", +}, +{ fShaderId: 'fshader-struct-array-ternary-operator', + fShaderSuccess: false, + linkSuccess: false, + passMsg: "By implication, using ternary operators with structs containing arrays is not allowed", +}, +]); + +debug(""); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/ternary-operators-in-global-initializers.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/ternary-operators-in-global-initializers.html new file mode 100644 index 000000000..2b578b372 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/ternary-operators-in-global-initializers.html @@ -0,0 +1,86 @@ +<!-- +/* +** Copyright (c) 2014 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ +--> +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<link rel="stylesheet" href="../../../resources/js-test-style.css" /> +<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> +<title>Ternary Operators in Global Initializers</title> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script id="fragmentShader" type="text/something-not-javascript"> +precision mediump float; +const $(type) green = $(green); +const $(type) black = $(black); +$(type) var = (true) ? green : black; +void main() { + gl_FragColor = $(asVec4); +} +</script> +<script> +"use strict"; +description("This test verifies that ternary operators can be used in global initializers."); +var tests = []; +var wtu = WebGLTestUtils; +var typeInfos = [ + { type: 'float', green: '1.0', black: '0.0', asVec4: 'vec4(0.0,var,0.0,1.0)' }, + { type: 'vec2', green: 'vec2(0.0,1.0)', black: 'vec2(0.0,0.0)', asVec4: 'vec4(var,0.0,1.0)' }, + { type: 'vec3', green: 'vec3(0.0,1.0,0.0)', black: 'vec3(0.0,0.0,0.0)', asVec4: 'vec4(var,1.0)' }, + { type: 'vec4', green: 'vec4(0.0,1.0,0.0,1.0)', black: 'vec4(0.0,0.0,0.0,0.0)', asVec4: 'var' }, + { type: 'int', green: '1', black: '0', asVec4: 'vec4(0.0,var,0.0,1.0)' }, + { type: 'ivec2', green: 'ivec2(0,1)', black: 'ivec2(0,0)', asVec4: 'vec4(var,0.0,1.0)' }, + { type: 'ivec3', green: 'ivec3(0,1,0)', black: 'ivec3(0,0,0)', asVec4: 'vec4(var,1.0)' }, + { type: 'ivec4', green: 'ivec4(0,1,0,1)', black: 'ivec4(0,0,0,0)', asVec4: 'vec4(var)' }, + { type: 'bool', green: 'true', black: 'false', asVec4: 'vec4(0.0,var,0.0,1.0)' }, + { type: 'bvec2', green: 'bvec2(false,true)', black: 'bvec2(false,false)', asVec4: 'vec4(var,0.0,1.0)' }, + { type: 'bvec3', green: 'bvec3(false,true,false)', black: 'bvec3(false,false,false)', asVec4: 'vec4(var,1.0)' }, + { type: 'bvec4', green: 'bvec4(false,true,false,true)',black: 'bvec4(false,false,false,false)', asVec4: 'vec4(var)' }, +]; +typeInfos.forEach(function (typeInfo) { + var replaceParams = { + type: typeInfo.type, + green: typeInfo.green, + black: typeInfo.black, + asVec4: typeInfo.asVec4, + }; + tests.push({ + fShaderSource: wtu.replaceParams(wtu.getScript('fragmentShader'), replaceParams), + passMsg: typeInfo.type, + fShaderSuccess: true, + linkSuccess: true, + render: true + }); +}); +GLSLConformanceTester.runTests(tests); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/ternary-operators-in-initializers.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/ternary-operators-in-initializers.html new file mode 100644 index 000000000..5a0f3d1cb --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/ternary-operators-in-initializers.html @@ -0,0 +1,143 @@ +<!-- +/* +** Copyright (c) 2014 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ +--> +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<link rel="stylesheet" href="../../../resources/js-test-style.css" /> +<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> +<title></title> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script id="intFragShader" type="text/something-not-javascript"> +void main() { + int i = 2, j = (i > 1) ? 1 : 0; + gl_FragColor = vec4(0.0, j, 0.0, 1.0); +} +</script> +<script id="ivec2FragShader" type="text/something-not-javascript"> +void main() { + ivec2 i = ivec2(2, 0), j = (i.x > 1) ? ivec2(0, 1) : ivec2(0, 0); + gl_FragColor = vec4(j, 0.0, 1.0); +} +</script> +<script id="ivec3FragShader" type="text/something-not-javascript"> +void main() { + ivec3 i = ivec3(0, 2, 0), j = (i.y > 1) ? ivec3(0, 1, 0) : ivec3(0, 0, 0); + gl_FragColor = vec4(j, 1.0); +} +</script> +<script id="ivec4FragShader" type="text/something-not-javascript"> +void main() { + ivec4 i = ivec4(0.0, 0.0, 2.0, 0.0), j = (i.z > 1) ? ivec4(0, 1, 0, 1) : ivec4(0, 0, 0, 1); + gl_FragColor = vec4(j); +} +</script> +<script id="floatFragShader" type="text/something-not-javascript"> +void main() { + precision mediump float; + float i = 2.0, j = (i > 1.0) ? 1.0 : 0.0; + gl_FragColor = vec4(0.0, j, 0.0, 1.0); +} +</script> +<script id="vec2FragShader" type="text/something-not-javascript"> +void main() { + precision mediump float; + vec2 i = vec2(2.0, 0.0), j = (i.x > 1.0) ? vec2(0.0, 1.0) : vec2(0.0, 0.0); + gl_FragColor = vec4(j, 0.0, 1.0); +} +</script> +<script id="vec3FragShader" type="text/something-not-javascript"> +void main() { + precision mediump float; + vec3 i = vec3(0.0, 2.0, 0.0), j = (i.y > 1.0) ? vec3(0.0, 1.0, 0.0) : vec3(0.0, 0.0, 0.0); + gl_FragColor = vec4(j, 1.0); +} +</script> +<script id="vec4FragShader" type="text/something-not-javascript"> +void main() { + precision mediump float; + vec4 i = vec4(0.0, 0.0, 2.0, 0.0), j = (i.z > 1.0) ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(0.0, 0.0, 0.0, 1.0); + gl_FragColor = j; +} +</script> +<script id="boolFragShader" type="text/something-not-javascript"> +void main() { + bool i = true, j = i ? true : false; + gl_FragColor = vec4(0.0, j, 0.0, 1.0); +} +</script> +<script id="bvec2FragShader" type="text/something-not-javascript"> +void main() { + bvec2 i = bvec2(true, false), j = i.x ? bvec2(false, true) : bvec2(false, false); + gl_FragColor = vec4(j, 0.0, 1.0); +} +</script> +<script id="bvec3FragShader" type="text/something-not-javascript"> +void main() { + bvec3 i = bvec3(false, true, false), j = i.y ? bvec3(false, true, false) : bvec3(false, false, false); + gl_FragColor = vec4(j, 1.0); +} +</script> +<script id="bvec4FragShader" type="text/something-not-javascript"> +void main() { + bvec4 i = bvec4(false, false, true, true), j = i.z ? bvec4(false, true, false, true) : bvec4(false, false, false, true); + gl_FragColor = vec4(j); +} +</script> +<script> +"use strict"; +description("This test verifies initializers with ternary operators correctly initialize all variables."); +// Test fragment shaders are of the form +// void main() { +// {type} i = {initializer}, j = {ternary test using i that succeeds} ? : {green} : {black}; +// gl_FragColor = vec4(...); // Emit green so that test will pass +// } +// The fragment shader must compile and link with the default vertex shader. J must be able to use the values of I as well as have its own +// values properly initialized. +var tests = [ + { fShaderId: 'intFragShader', passMsg: 'Ternary operator in integer initalization', fShaderSuccess: true, linkSuccess: true, render: true }, + { fShaderId: 'ivec2FragShader', passMsg: 'Ternary operator in ivec2 initalization', fShaderSuccess: true, linkSuccess: true, render: true }, + { fShaderId: 'ivec3FragShader', passMsg: 'Ternary operator in ivec3 initalization', fShaderSuccess: true, linkSuccess: true, render: true }, + { fShaderId: 'ivec4FragShader', passMsg: 'Ternary operator in ivec4 initalization', fShaderSuccess: true, linkSuccess: true, render: true }, + { fShaderId: 'floatFragShader', passMsg: 'Ternary operator in float initalization', fShaderSuccess: true, linkSuccess: true, render: true }, + { fShaderId: 'vec2FragShader', passMsg: 'Ternary operator in vec2 initalization', fShaderSuccess: true, linkSuccess: true, render: true }, + { fShaderId: 'vec3FragShader', passMsg: 'Ternary operator in vec3 initalization', fShaderSuccess: true, linkSuccess: true, render: true }, + { fShaderId: 'vec4FragShader', passMsg: 'Ternary operator in vec4 initalization', fShaderSuccess: true, linkSuccess: true, render: true }, + { fShaderId: 'boolFragShader', passMsg: 'Ternary operator in bool initalization', fShaderSuccess: true, linkSuccess: true, render: true }, + { fShaderId: 'bvec2FragShader', passMsg: 'Ternary operator in bvec2 initalization', fShaderSuccess: true, linkSuccess: true, render: true }, + { fShaderId: 'bvec3FragShader', passMsg: 'Ternary operator in bvec3 initalization', fShaderSuccess: true, linkSuccess: true, render: true }, + { fShaderId: 'bvec4FragShader', passMsg: 'Ternary operator in bvec4 initalization', fShaderSuccess: true, linkSuccess: true, render: true }, +]; +GLSLConformanceTester.runTests(tests); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/uniform-location-length-limits.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/uniform-location-length-limits.html new file mode 100644 index 000000000..58ec47617 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/uniform-location-length-limits.html @@ -0,0 +1,107 @@ +<!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. +*/ + +--> +<title>WebGL uniform location length tests</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> +</head> +<body> +<canvas id="example" width="50" height="50"> +There is supposed to be an example drawing here, but it's not important. +</canvas> +<div id="description">Verify limits on the lengths of uniform locations per WebGL spec, "Maximum Uniform and Attribute Location Lengths".</div> +<div id="console"></div> +<script id="goodVertexShader" type="x-shader/x-vertex"> +// A vertex shader where the needed uniform location is exactly 256 characters. +struct Nesting2 { + vec4 identifier62CharactersLong_01234567890123456789012345678901234; +}; + +struct Nesting1 { + Nesting2 identifier64CharactersLong_0123456789012345678901234567890123456; +}; + +uniform Nesting1 identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789; + +void main() { + gl_Position = identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.identifier64CharactersLong_0123456789012345678901234567890123456.identifier62CharactersLong_01234567890123456789012345678901234; +} +</script> +<script id="badVertexShader" type="x-shader/x-vertex"> +// A vertex shader where the needed uniform location is 257 characters. +struct Nesting2 { + vec4 identifier63CharactersLong_012345678901234567890123456789012345; +}; + +struct Nesting1 { + Nesting2 identifier64CharactersLong_0123456789012345678901234567890123456; +}; + +uniform Nesting1 identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789; + +void main() { + Nesting2 temp = identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.identifier64CharactersLong_0123456789012345678901234567890123456; + gl_Position = temp.identifier63CharactersLong_012345678901234567890123456789012345; +} +</script> +<script id="fragmentShader" type="x-shader/x-fragment"> +precision mediump float; + +void main() { + gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); +} +</script> +<script> +"use strict"; +var wtu = WebGLTestUtils; +var gl = wtu.create3DContext("example"); + +debug("Test uniform location underneath the length limit"); +var program = wtu.loadProgramFromScript(gl, "goodVertexShader", "fragmentShader"); +shouldBe('gl.getProgramParameter(program, gl.LINK_STATUS)', 'true'); +var uniformLoc = gl.getUniformLocation(program, "identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.identifier64CharactersLong_0123456789012345678901234567890123456.identifier62CharactersLong_01234567890123456789012345678901234"); +shouldBeNonNull('uniformLoc'); +wtu.glErrorShouldBe(gl, gl.NONE); + +debug("Test uniform location over the length limit"); +program = wtu.loadProgramFromScript(gl, "badVertexShader", "fragmentShader"); +wtu.glErrorShouldBe(gl, gl.NONE); +shouldBe('gl.getProgramParameter(program, gl.LINK_STATUS)', 'true'); +var uniformLoc = gl.getUniformLocation(program, "identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.identifier64CharactersLong_0123456789012345678901234567890123456.identifier63CharactersLong_012345678901234567890123456789012345"); +wtu.glErrorShouldBe(gl, gl.INVALID_VALUE); +shouldBeNull('uniformLoc'); + +var successfullyParsed = true; +</script> +<script src="../../../js/js-test-post.js"></script> +</body> +</html> |