diff options
Diffstat (limited to 'dom/canvas/test/webgl-conf/checkout/conformance/glsl')
332 files changed, 22889 insertions, 0 deletions
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/00_test_list.txt b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/00_test_list.txt new file mode 100644 index 0000000000..8ab2039cc6 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/00_test_list.txt @@ -0,0 +1,12 @@ +bugs/00_test_list.txt +--min-version 1.0.3 constructors/00_test_list.txt +functions/00_test_list.txt +implicit/00_test_list.txt +--min-version 1.0.2 literals/00_test_list.txt +--min-version 1.0.2 matrices/00_test_list.txt +misc/00_test_list.txt +--min-version 1.0.4 preprocessor/00_test_list.txt +reserved/00_test_list.txt +--min-version 1.0.2 samplers/00_test_list.txt +variables/00_test_list.txt + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/00_test_list.txt b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/00_test_list.txt new file mode 100644 index 0000000000..c84e94bbd0 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/00_test_list.txt @@ -0,0 +1,52 @@ +--min-version 1.0.4 angle-ambiguous-function-call.html +--min-version 1.0.4 angle-constructor-invalid-parameters.html +--min-version 1.0.3 angle-d3d11-compiler-error.html +--min-version 1.0.3 angle-dx-variable-bug.html +--min-version 1.0.3 array-of-struct-with-int-first-position.html +--min-version 1.0.4 assign-to-swizzled-twice-in-function.html +--min-version 1.0.4 bool-type-cast-bug-int-float.html +--min-version 1.0.4 character-set.html +--min-version 1.0.3 compare-loop-index-to-uniform.html +--min-version 1.0.3 complex-glsl-does-not-crash.html +--min-version 1.0.4 compound-assignment-type-combination.html +--min-version 1.0.3 conditional-discard-in-loop.html +--min-version 1.0.3 conditional-discard-optimization.html +--min-version 1.0.4 conditional-texture-fetch.html +--min-version 1.0.3 constant-precision-qualifier.html +--min-version 1.0.3 --max-version 1.99 essl3-shaders-with-webgl1.html +--min-version 1.0.4 floor-div-cos-should-not-truncate.html +--min-version 1.0.3 floored-division-accuracy.html +--min-version 1.0.3 fragcoord-linking-bug.html +--min-version 1.0.4 gl-fragcoord-multisampling-bug.html +--min-version 1.0.4 global-invariant-does-not-leak-across-shaders.html +--min-version 1.0.4 if-return-and-elseif.html +--min-version 1.0.4 init-array-with-loop.html +--min-version 1.0.4 invariant-does-not-leak-across-shaders.html +--min-version 1.0.4 in-parameter-passed-as-inout-argument-and-global.html +--min-version 1.0.4 logic-inside-block-without-braces.html +--min-version 1.0.3 long-expressions-should-not-crash.html +--min-version 1.0.4 loop-if-loop-gradient.html +--min-version 1.0.3 modulo-arithmetic-accuracy.html +--min-version 1.0.3 multiplication-assignment.html +--min-version 1.0.3 nested-functions-should-not-crash.html +--min-version 1.0.4 nested-loops-with-break-and-continue.html +--min-version 1.0.4 nested-sequence-operator.html +--min-version 1.0.4 pow-of-small-constant-in-user-defined-function.html +--min-version 1.0.4 pow-with-constant-exponent-should-not-crash.html +--min-version 1.0.4 qualcomm-crash.html +--min-version 1.0.4 qualcomm-loop-with-continue-crash.html +--min-version 1.0.4 sampler-array-struct-function-arg.html +--min-version 1.0.3 sampler-array-using-loop-index.html +--min-version 1.0.4 sampler-struct-function-arg.html +--min-version 1.0.4 sequence-operator-evaluation-order.html +--min-version 1.0.4 sketchfab-lighting-shader-crash.html +--min-version 1.0.4 struct-constructor-highp-bug.html +--min-version 1.0.4 struct-with-single-member-constructor.html +--min-version 1.0.3 temp-expressions-should-not-crash.html +--min-version 1.0.4 unary-minus-operator-float-bug.html +--min-version 1.0.4 undefined-index-should-not-crash.html +--min-version 1.0.3 uniforms-should-not-lose-values.html +--min-version 1.0.4 varying-arrays-should-not-be-reversed.html +--min-version 1.0.4 vector-matrix-constructor-scalarization.html +--min-version 1.0.4 vector-scalar-arithmetic-inside-loop.html +--min-version 1.0.4 vector-scalar-arithmetic-inside-loop-complex.html diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/README.md b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/README.md new file mode 100644 index 0000000000..d917f6d741 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/README.md @@ -0,0 +1,18 @@ +BUGS +==== + +This folder is for GLSL tests that test driver specific bugs. + +Most tests in other folders are fairly generic. While they might +only fail on specific drivers the tests themselves are designed +to test something in a generic way. + +Tests in this folder on the otherhand are very targeted. They may +have very specific shaders that only fail under specific circumstances +on specific drivers. + +An example might be if there was a driver that failed only when +and identifier was named "ABC". It makes no sense to have a generic +test that says "must allow ABC". A generic test would test some +subset of all possible identifiers not just one. + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/angle-ambiguous-function-call.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/angle-ambiguous-function-call.html new file mode 100644 index 0000000000..c7f10a05f5 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/angle-ambiguous-function-call.html @@ -0,0 +1,72 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>ANGLE ambiguous function call test</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script src="../../../js/glsl-conformance-test.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script id="fshaderAmbiguousHLSLFunctionCall" type="x-shader/x-fragment"> +precision mediump float; +uniform vec4 uv; +uniform mat2 um; +vec4 foo(vec4 v) { + return v; +} +vec4 foo(mat2 m) { + return vec4(m); +} +void main() +{ + gl_FragColor = foo(uv) + foo(um); +} +</script> +<script id="fshaderAmbiguousHLSLStructFunctionCall" type="x-shader/x-fragment"> +precision mediump float; +uniform float u_zero; +struct S { float foo; }; +struct S2 { float foo; }; +float get(S s) { return s.foo + u_zero; } +float get(S2 s2) { return 0.25 + s2.foo + u_zero; } +void main() +{ + S s; + s.foo = 0.5; + S2 s2; + s2.foo = 0.25; + gl_FragColor = vec4(0.0, get(s) + get(s2), 0.0, 1.0); +} +</script> +<script type="text/javascript"> +"use strict"; +description("Test overloaded functions with vec4 and mat2 parameters that have had issues in ANGLE. Issues were due to HLSL compiler treating float4 and float2x2 as the same type when resolving which overloaded function to call."); + +GLSLConformanceTester.runTests([ +{ + fShaderId: 'fshaderAmbiguousHLSLFunctionCall', + fShaderSuccess: true, + linkSuccess: true, + passMsg: "Disambiguate correctly between overloaded function calls with 4-component float parameters" +}, +{ + fShaderId: 'fshaderAmbiguousHLSLStructFunctionCall', + fShaderSuccess: true, + linkSuccess: true, + passMsg: "Disambiguate correctly between overloaded function calls with struct parameters", + render: true +} +]); +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/angle-constructor-invalid-parameters.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/angle-constructor-invalid-parameters.html new file mode 100644 index 0000000000..6c663811f1 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/angle-constructor-invalid-parameters.html @@ -0,0 +1,56 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>ANGLE constructor bugs test</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script src="../../../js/glsl-conformance-test.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script id="fshaderSamplerInConstructorArguments" type="x-shader/x-fragment"> +precision mediump float; +uniform sampler2D s; +void main() +{ + gl_FragColor = vec4(0.0, s, 0.0, 0.0); +} +</script> +<script id="fshaderVoidInConstructorArguments" type="x-shader/x-fragment"> +precision mediump float; +void foo() {} +void main() +{ + gl_FragColor = vec4(0.0, foo(), 0.0, 0.0); +} +</script> +<script type="text/javascript"> +"use strict"; +description("Test constructors that have had issues in ANGLE"); + +GLSLConformanceTester.runTests([ +{ + fShaderId: 'fshaderSamplerInConstructorArguments', + fShaderSuccess: false, + linkSuccess: false, + passMsg: "Sampler in constructor arguments should not compile" +}, +{ + fShaderId: 'fshaderVoidInConstructorArguments', + fShaderSuccess: false, + linkSuccess: false, + passMsg: "Void in constructor arguments should not compile" +}, +]); +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/angle-d3d11-compiler-error.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/angle-d3d11-compiler-error.html new file mode 100644 index 0000000000..158ddad08f --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/angle-d3d11-compiler-error.html @@ -0,0 +1,96 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>ANGLE D3D11 Bug - Shader compilation error</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> + +<script id="vs" type="x-shader/x-fragment"> +precision mediump float; +uniform float A; +void main() { + bool B = bool(A); + float x = B ? -A : 1.+A; + float y = B ? 1.+A : -A; + gl_Position = vec4(x, y, 0, 0); +} + +</script> +<script id="fs" type="x-shader/x-fragment"> +precision mediump float; +void main() { + gl_FragColor = vec4(1, 0, 0, 1); +} +</script> + +<div id="description"></div> +<div id="console"></div> +<canvas id="canvas" width="2" height="2"> </canvas> +<script> +"use strict"; +// See http://crbug.com/371868 for original failing case. +description("This test checks an ANGLE D3D11 shader compiler error."); + +debug(""); +debug("Canvas.getContext"); + +var wtu = WebGLTestUtils; +var gl = wtu.create3DContext("canvas"); +if (!gl) { + testFailed("context does not exist"); +} else { + testPassed("context exists"); + + debug(""); + debug("Checking shader compilation and linking."); + + checkCompilation(); +} + +function checkCompilation() { + var vs = gl.createShader(gl.VERTEX_SHADER); + gl.shaderSource(vs, document.getElementById("vs").text); + gl.compileShader(vs); + if (!gl.getShaderParameter(vs, gl.COMPILE_STATUS)) { + testFailed("Vertex Shader failed to compile: " + gl.getShaderInfoLog(vs)); + return; + } + + var fs = gl.createShader(gl.FRAGMENT_SHADER); + gl.shaderSource(fs, document.getElementById("fs").text); + gl.compileShader(fs); + if (!gl.getShaderParameter(fs, gl.COMPILE_STATUS)) { + testFailed("Fragment Shader failed to compile: " + gl.getShaderInfoLog(fs)); + return; + } + + var p = gl.createProgram(); + gl.attachShader(p, vs); + gl.attachShader(p, fs); + gl.linkProgram(p); + if (!gl.getProgramParameter(p, gl.LINK_STATUS)) { + testFailed("Program failed to link: " + gl.getProgramInfoLog(p)); + return; + } + + testPassed("Linked Successfully"); +} + +debug(""); +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/bugs/angle-dx-variable-bug.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/angle-dx-variable-bug.html new file mode 100644 index 0000000000..c094beff66 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/angle-dx-variable-bug.html @@ -0,0 +1,96 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>ANGLE D3D11 Bug - Variables beginning with "dx_"</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> + +<script id="vs" type="x-shader/x-fragment"> +precision mediump float; +attribute vec4 position; +varying float dx_var; +void main() { + gl_Position = position; + dx_var = position.x; +} + +</script> +<script id="fs" type="x-shader/x-fragment"> +precision mediump float; +varying float dx_var; +void main() { + gl_FragColor = vec4(dx_var, 0, 0, 1); +} +</script> + +<div id="description"></div> +<div id="console"></div> +<canvas id="canvas" width="2" height="2"> </canvas> +<script> +"use strict"; +// See http://crbug.com/371868 for original failing case. +description("This test checks an ANGLE D3D11 shader compiler error."); + +debug(""); +debug("Canvas.getContext"); + +var wtu = WebGLTestUtils; +var gl = wtu.create3DContext("canvas"); +if (!gl) { + testFailed("context does not exist"); +} else { + testPassed("context exists"); + + debug(""); + debug("Checking shader compilation and linking."); + + checkCompilation() +} + +function checkCompilation() { + var vs = gl.createShader(gl.VERTEX_SHADER); + gl.shaderSource(vs, document.getElementById("vs").text); + gl.compileShader(vs); + if (!gl.getShaderParameter(vs, gl.COMPILE_STATUS)) { + testFailed("Vertex Shader failed to compile: " + gl.getShaderInfoLog(vs)); + return; + } + + var fs = gl.createShader(gl.FRAGMENT_SHADER); + gl.shaderSource(fs, document.getElementById("fs").text); + gl.compileShader(fs); + if (!gl.getShaderParameter(fs, gl.COMPILE_STATUS)) { + testFailed("Fragment Shader failed to compile: " + gl.getShaderInfoLog(fs)); + return; + } + + var p = gl.createProgram(); + gl.attachShader(p, vs); + gl.attachShader(p, fs); + gl.linkProgram(p); + if (!gl.getProgramParameter(p, gl.LINK_STATUS)) { + testFailed("Program failed to link: " + gl.getProgramInfoLog(p)); + return; + } + + testPassed("Linked Successfully"); +} + +debug(""); +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/bugs/array-of-struct-with-int-first-position.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/array-of-struct-with-int-first-position.html new file mode 100644 index 0000000000..e7dd805566 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/array-of-struct-with-int-first-position.html @@ -0,0 +1,141 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Driver Bug - Array of structs with int or bool in first position</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" style="border: none;" width="788" height="256"></canvas> +<div id="description"></div> +<div id="console"></div> + +<script id="shader-vs" type="x-shader/x-vertex"> +attribute vec2 pos; +void main(void) { + gl_Position = vec4(pos, 0.0, 1.0); +} +</script> + +<script id="shader-fs-int" type="x-shader/x-fragment"> +precision mediump float; +struct Light { + int unused; + vec3 color; +}; +const int numLights = 1; +void main() { + Light lights[numLights]; + lights[0].color = vec3(0.0, 0.5, 0.0); + + vec3 result = vec3(0.0, 0.0, 0.0); + for (int i=0; i<numLights; i++) { + result += lights[i].color; + } + gl_FragColor = vec4(result.rgb, 1.0); +} +</script> + +<script id="shader-fs-bool" type="x-shader/x-fragment"> +precision mediump float; +struct Light { + bool unused; + vec3 color; +}; +const int numLights = 1; +void main() { + Light lights[numLights]; + lights[0].color = vec3(0.0, 0.5, 0.0); + + vec3 result = vec3(0.0, 0.0, 0.0); + for (int i=0; i<numLights; i++) { + result += lights[i].color; + } + gl_FragColor = vec4(result.rgb, 1.0); +} +</script> + +<script id="shader-fs-bool-read" type="x-shader/x-fragment"> +precision mediump float; +struct Light { + bool useLight; + vec3 color; +}; +const int numLights = 1; +void main() { + Light lights[numLights]; + lights[0].color = vec3(0.0, 0.5, 0.0); + lights[0].useLight = true; + + vec3 result = vec3(0.0, 0.0, 0.0); + for (int i=0; i<numLights; i++) { + Light light = lights[i]; + if (light.useLight) { + result += light.color; + } + } + gl_FragColor = vec4(result.rgb, 1.0); +} +</script> + +<script> +"use strict"; + +function test() { + description(); + debug( + "This test checks accessing an array of structs, where the struct " + + "definition has an int or bool in the first position. " + + "This test has has failed in OS X on some NVIDIA cards, " + + "such as the NVIDIA GeForce GT 650M. If things are working " + + "correctly, then there will be a series of 50% green squares.") + debug(""); + + var wtu = WebGLTestUtils; + var canvas = document.getElementById("example"); + var gl = wtu.create3DContext(canvas); + + var testNum = 0; + var border = 10; // border between test squares for visibility + var squareSize = 256; + var expectedColor = [0, 127, 0, 255]; // 50% green + + function subTest(message, fragmentShader) { + debug(message); + var startX = (squareSize + border) * testNum; + var program = wtu.setupProgram( + gl, ["shader-vs", fragmentShader], ["pos"], null, true); + gl.viewport(startX, 0, squareSize, squareSize); + wtu.drawUnitQuad(gl); + wtu.checkCanvasRect( + gl, startX, 0, squareSize, squareSize, + expectedColor, "square should be 50% green", 1); + debug(""); + testNum++; + } + + if (!gl) { + testFailed("context does not exist"); + } else { + wtu.setupUnitQuad(gl); + subTest("Test unused int in first struct position.", "shader-fs-int"); + subTest("Test unused bool in first struct position.", "shader-fs-bool"); + subTest("Test used bool in first struct position.", "shader-fs-bool-read"); + } +} + +test(); +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/bugs/assign-to-swizzled-twice-in-function.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/assign-to-swizzled-twice-in-function.html new file mode 100644 index 0000000000..847127a408 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/assign-to-swizzled-twice-in-function.html @@ -0,0 +1,52 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Assigning an assignment to a swizzled value inside function</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script src="../../../js/glsl-conformance-test.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script id="fshader" type="x-shader/x-fragment"> +precision mediump float; + +vec2 f() +{ + vec2 r = vec2(0); + r.x = r.y = 1.0; + return r; +} + +void main() +{ + gl_FragColor.ga = f(); +} + +</script> +<script type="text/javascript"> +"use strict"; +description(); + +// Minimal test case based on report at http://crbug.com/798117 + +GLSLConformanceTester.runRenderTests([ +{ + fShaderId: 'fshader', + fShaderSuccess: true, + linkSuccess: true, + passMsg: "Assigning an assignment to a swizzled value inside a user-defined function" +} +]); +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/bool-type-cast-bug-int-float.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/bool-type-cast-bug-int-float.html new file mode 100644 index 0000000000..984c4e0289 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/bool-type-cast-bug-int-float.html @@ -0,0 +1,312 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Verify int(bool) and float(bool) work correctly (Mac AMD driver bug)</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +</head> +<body> +<canvas id="canvas" width="2" height="2"> </canvas> +<div id="description"></div> +<div id="console"></div> +<script id="vshader-int1" type="x-shader/x-vertex"> +attribute vec3 aPosition; +varying mediump float fvalue; +uniform bool bvalue; + +void main() { + gl_Position = vec4(aPosition, 1); + int ivalue = int(bvalue); + if (ivalue == 0) { + fvalue = 0.0; + } else if (ivalue == 1) { + fvalue = 1.0; + } else { + fvalue = -1.0; + } +} +</script> +<script id="fshader-int1" type="x-shader/x-fragment"> +varying mediump float fvalue; + +void main() { + if (fvalue == 1.0) + gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); + else if (fvalue == 0.0) + gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); + else + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); +} +</script> + +<script id="vshader-int2" type="x-shader/x-vertex"> +attribute vec3 aPosition; + +void main() { + gl_Position = vec4(aPosition, 1); +} +</script> +<script id="fshader-int2" type="x-shader/x-fragment"> +uniform bool bvalue; + +void main() { + int ivalue = int(bvalue); + + if (ivalue == 1) + gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); + else if (ivalue == 0) + gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); + else + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); +} +</script> + +<script id="vshader-float1" type="x-shader/x-vertex"> +attribute vec3 aPosition; +varying mediump float fvalue; +uniform bool bvalue; + +void main() { + gl_Position = vec4(aPosition, 1); + fvalue = float(bvalue); +} +</script> +<script id="fshader-float1" type="x-shader/x-fragment"> +varying mediump float fvalue; + +void main() { + if (fvalue == 1.0) + gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); + else if (fvalue == 0.0) + gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); + else + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); +} +</script> + +<script id="vshader-float2" type="x-shader/x-vertex"> +attribute vec3 aPosition; + +void main() { + gl_Position = vec4(aPosition, 1); +} +</script> +<script id="fshader-float2" type="x-shader/x-fragment"> +uniform bool bvalue; + +void main() { + mediump float fvalue = float(bvalue); + + if (fvalue == 1.0) + gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); + else if (fvalue == 0.0) + gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); + else + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); +} +</script> + +<script id="vshader-vec2-1" type="x-shader/x-vertex"> +attribute vec3 aPosition; +varying mediump vec2 fvalue; +uniform bool bvalue; + +void main() { + gl_Position = vec4(aPosition, 1); + fvalue = vec2(bvalue); +} +</script> +<script id="fshader-vec2-1" type="x-shader/x-fragment"> +varying mediump vec2 fvalue; + +void main() { + if (fvalue == vec2(1.0, 1.0)) + gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); + else if (fvalue == vec2(0.0, 0.0)) + gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); + else + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); +} +</script> + +<script id="vshader-vec2-2" type="x-shader/x-vertex"> +attribute vec3 aPosition; + +void main() { + gl_Position = vec4(aPosition, 1); +} +</script> +<script id="fshader-vec2-2" type="x-shader/x-fragment"> +precision mediump float; +uniform bool bvalue; + +void main() { + vec2 fvalue = vec2(bvalue); + + if (fvalue == vec2(1.0, 1.0)) + gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); + else if (fvalue == vec2(0.0, 0.0)) + gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); + else + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); +} +</script> + +<script id="vshader-vec3-1" type="x-shader/x-vertex"> +attribute vec3 aPosition; +varying mediump vec3 fvalue; +uniform bool bvalue; + +void main() { + gl_Position = vec4(aPosition, 1); + fvalue = vec3(bvalue); +} +</script> +<script id="fshader-vec3-1" type="x-shader/x-fragment"> +varying mediump vec3 fvalue; + +void main() { + if (fvalue == vec3(1.0, 1.0, 1.0)) + gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); + else if (fvalue == vec3(0.0, 0.0, 0.0)) + gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); + else + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); +} +</script> + +<script id="vshader-vec3-2" type="x-shader/x-vertex"> +attribute vec3 aPosition; + +void main() { + gl_Position = vec4(aPosition, 1); +} +</script> +<script id="fshader-vec3-2" type="x-shader/x-fragment"> +precision mediump float; +uniform bool bvalue; + +void main() { + vec3 fvalue = vec3(bvalue); + + if (fvalue == vec3(1.0, 1.0, 1.0)) + gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); + else if (fvalue == vec3(0.0, 0.0, 0.0)) + gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); + else + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); +} +</script> + +<script id="vshader-vec4-1" type="x-shader/x-vertex"> +attribute vec3 aPosition; +varying mediump vec4 fvalue; +uniform bool bvalue; + +void main() { + gl_Position = vec4(aPosition, 1); + fvalue = vec4(bvalue); +} +</script> +<script id="fshader-vec4-1" type="x-shader/x-fragment"> +varying mediump vec4 fvalue; + +void main() { + if (fvalue == vec4(1.0, 1.0, 1.0, 1.0)) + gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); + else if (fvalue == vec4(0.0, 0.0, 0.0, 0.0)) + gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); + else + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); +} +</script> + +<script id="vshader-vec4-2" type="x-shader/x-vertex"> +attribute vec3 aPosition; + +void main() { + gl_Position = vec4(aPosition, 1); +} +</script> +<script id="fshader-vec4-2" type="x-shader/x-fragment"> +precision mediump float; +uniform bool bvalue; + +void main() { + vec4 fvalue = vec4(bvalue); + + if (fvalue == vec4(1.0, 1.0, 1.0, 1.0)) + gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); + else if (fvalue == vec4(0.0, 0.0, 0.0, 0.0)) + gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); + else + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); +} +</script> + + <script type="application/javascript"> +"use strict"; +description("Verify int(bool) and float(bool) work correctly"); +debug(""); +var wtu = WebGLTestUtils; +function test() { + var gl = wtu.create3DContext("canvas"); + if (!gl) { + testFailed("context does not exist"); + return; + } + wtu.setupUnitQuad(gl); + + var testCases = [ + { vshader: "vshader-int1", fshader: "fshader-int1", desc: "vertex shader int" }, + { vshader: "vshader-int2", fshader: "fshader-int2", desc: "fragment shader int" }, + { vshader: "vshader-float1", fshader: "fshader-float1", desc: "vertex shader float" }, + { vshader: "vshader-float2", fshader: "fshader-float2", desc: "fragment shader float" }, + { vshader: "vshader-vec2-1", fshader: "fshader-vec2-1", desc: "vertex shader vec2" }, + { vshader: "vshader-vec2-2", fshader: "fshader-vec2-2", desc: "fragment shader vec2" }, + { vshader: "vshader-vec3-1", fshader: "fshader-vec3-1", desc: "vertex shader vec3" }, + { vshader: "vshader-vec3-2", fshader: "fshader-vec3-2", desc: "fragment shader vec3" }, + { vshader: "vshader-vec4-1", fshader: "fshader-vec4-1", desc: "vertex shader vec4" }, + { vshader: "vshader-vec4-2", fshader: "fshader-vec4-2", desc: "fragment shader vec4" }, + ]; + + for (var idx = 0; idx < testCases.length; ++idx) { + var test = testCases[idx]; + + debug(""); + var program = wtu.setupProgram(gl, [test.vshader, test.fshader], ["aPosition"]); + if (!program) { + testFailed("Fail to set up program"); + } else { + var uniformLoc = gl.getUniformLocation(program, 'bvalue'); + debug("Testing " + test.desc + " with false"); + gl.uniform1i(uniformLoc, 0); + wtu.drawUnitQuad(gl); + wtu.checkCanvas(gl, [0, 255, 0, 255]); + debug("Testing " + test.desc + " with true"); + gl.uniform1i(uniformLoc, 1); + wtu.drawUnitQuad(gl); + wtu.checkCanvas(gl, [255, 0, 0, 255]); + gl.deleteProgram(program); + wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from testing"); + } + } +}; + +test(); + +debug(""); +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/bugs/character-set.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/character-set.html new file mode 100644 index 0000000000..6d6fca5f89 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/character-set.html @@ -0,0 +1,115 @@ +<!-- +Copyright (c) 2020 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Character Set</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script src="../../../js/glsl-conformance-test.js"></script> +</head> +<body> + +<div id="description"></div> +<div id="console"></div> +<canvas id="canvas" width="2" height="2"> </canvas> +<script> +"use strict"; +// See http://crbug.com/1108588 for original failing case. +// Check "OpenGL Registry The OpenGL ES Shading Language" +// Section 3.2 Character Sets For more info +description("This test checks character set validation for glsl."); + +debug(""); +debug("Canvas.getContext"); + +let wtu = WebGLTestUtils; +let gl = wtu.create3DContext("canvas"); +let consoleDiv = document.getElementById("console"); +if (!gl) { + testFailed("context does not exist"); +} else { + testPassed("context exists"); + + debug(""); + debug("Checking shader character set validation and compilation"); + + runTest(); +} + +function testShaderSource(shaderSource, msg) { + if (!quietMode()) { + wtu.addShaderSource(consoleDiv, "test fragment shader", shaderSource); + } + + let shader = gl.createShader(gl.FRAGMENT_SHADER); + if (shader == null) { + testFailed("*** Error: unable to create shader '" + shaderSource + "'"); + return; + } + + gl.shaderSource(shader, shaderSource); + wtu.glErrorShouldBe(gl, gl.NO_ERROR, msg); +} + +function MUST(ifTruthy) { + return ifTruthy ? 'MUST' : 'MUST NOT'; +} + +function runTest() { + + const BAD_STRINGS = [ + '$', + '"', + '一些注释', + '#line 42 "foo.glsl"', + ]; + const TESTS = [ + ['in identifier', s => s, false], + ['in comment', s => `// ${s}`, true, true], + ['in ifdef-out', s => `#if 0 \n${s} \n#endif`, true], + ['in ifdef-out #preproc', s => `#if 0 \n#${s} \n#endif`, true], + ['in #preproc', s => `#${s}`, false], + ['in comment after #define', s => `#define TEST // ${s}`, true], // Regression test for crbug.com/940865 + ]; + + const glsl_tests = []; + + for (const s of BAD_STRINGS) { + for (const [where, template, validCompile] of TESTS) { + const st = template(s); + const src = ` +precision mediump float; +${st} +void main() { + gl_FragColor = vec4(1, 0, 0, 1); +}`.trim(); + + testShaderSource(src, `shaderSource allows Out-of-charset string '${s}' ${where} until compilation.`); + + glsl_tests.push( + { + fShaderSource: src, + fShaderSuccess: validCompile, + linkSuccess: validCompile, + passMsg: `Out-of-charset string '${s}' ${where} ${MUST(validCompile)} compile.` + } + ); + } + } + + GLSLConformanceTester.runTests(glsl_tests); +} + +debug(""); +var successfullyParsed = true; + +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/compare-loop-index-to-uniform.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/compare-loop-index-to-uniform.html new file mode 100644 index 0000000000..a96da7fea9 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/compare-loop-index-to-uniform.html @@ -0,0 +1,50 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Driver bug - Comparing loop index against uniform in a fragment shader should work</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script src="../../../js/glsl-conformance-test.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script id="fshader" type="x-shader/x-fragment"> +precision mediump float; +uniform int uCount; + +void main() { + float a = 0.0; + for (int i = 0; i < 5; ++i) { + if (i < uCount) { + a += 0.2; + } + } + gl_FragColor = vec4(1.0 - a, a, 0.0, 1.0); +} +</script> +<script type="application/javascript"> +"use strict"; +description("Comparing loop index to an uniform in a fragment shader should work."); + +GLSLConformanceTester.runRenderTests([ +{ + fShaderId: 'fshader', + fShaderSuccess: true, + linkSuccess: true, + passMsg: 'Compare a loop index to an uniform', + uniforms: [{name: "uCount", functionName: "uniform1i", value: 5}] +} +]); +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/complex-glsl-does-not-crash.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/complex-glsl-does-not-crash.html new file mode 100644 index 0000000000..7b324def84 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/complex-glsl-does-not-crash.html @@ -0,0 +1,191 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Driver Bug - complex glsl should not crash</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 = $(code); + 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 = $(code); +} +</script> +<script id="vshaderUniformTest" type="x-shader/x-fragment"> +attribute vec4 a_position; +varying vec4 v_varying; +$(uniforms) +void main() +{ + v_varying = $(code); + gl_Position = a_position; +} +</script> +<script id="fshaderUniformTest" type="x-shader/x-fragment"> +precision mediump float; +$(uniforms) +void main() +{ + gl_FragColor = $(code); +} +</script> +<script> +"use strict"; +description(); +debug(""); +var wtu = WebGLTestUtils; +var gl = wtu.create3DContext("example"); + +var uniformTypes = [ + { type: "bool", componentsPerRow: 1, rows: 1, code: "vec4(u_uniform$(id)$(index), 0, 0, 0)", }, + { type: "float", componentsPerRow: 1, rows: 1, code: "vec4(u_uniform$(id)$(index), 0, 0, 0)", }, + { type: "int", componentsPerRow: 1, rows: 1, code: "vec4(u_uniform$(id)$(index), 0, 0, 0)", }, + { type: "vec2", componentsPerRow: 2, rows: 1, code: "vec4(u_uniform$(id)$(index), 0, 0)", }, + { type: "ivec2", componentsPerRow: 2, rows: 1, code: "vec4(u_uniform$(id)$(index), 0, 0)", }, + { type: "bvec2", componentsPerRow: 2, rows: 1, code: "vec4(u_uniform$(id)$(index), 0, 0)", }, + { type: "vec3", componentsPerRow: 3, rows: 1, code: "vec4(u_uniform$(id)$(index), 0)", }, + { type: "ivec3", componentsPerRow: 3, rows: 1, code: "vec4(u_uniform$(id)$(index), 0)", }, + { type: "bvec3", componentsPerRow: 3, rows: 1, code: "vec4(u_uniform$(id)$(index), 0)", }, + { type: "vec4", componentsPerRow: 4, rows: 1, code: "vec4(u_uniform$(id)$(index))", }, + { type: "ivec4", componentsPerRow: 4, rows: 1, code: "vec4(u_uniform$(id)$(index))", }, + { type: "bvec4", componentsPerRow: 4, rows: 1, code: "vec4(u_uniform$(id)$(index))", }, +// Yes, the spec says mat2 takes 4 columns, 2 rows. + { type: "mat2", componentsPerRow: 4, rows: 2, code: "vec4(u_uniform$(id)$(index)[0], 0, 0)", }, + { type: "mat3", componentsPerRow: 3, rows: 3, code: "vec4(u_uniform$(id)$(index)[0], 0)", }, + { type: "mat4", componentsPerRow: 4, rows: 4, code: "vec4(u_uniform$(id)$(index)[0])", }, +// Samplers generally have more restictive 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: 128, // GLSL ES 1.0.17 Appendix A.7, + }, + { 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: 16, // GLSL ES 1.0.17 Appendix A.7, + }, +]; +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 numVars = 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 numPerRow = Math.floor(4 / info.componentsPerRow); + var numMax = Math.floor(shaderType.maxVectors * numPerRow / info.rows); + + // Test array[max] of the type + // Note: We can't test for success or failer as actual GL drivers are only required to be able to + // do the minimum number. After that it can fail for any reason. + var code = wtu.replaceParams(info.code, {id: "", index: "[" + (numVars - 1) + "]"}); + tests.push({ + vShaderSource: wtu.replaceParams(shaderType.vertArrayTest, {numTestType: numVars, code: code}, info), + vShaderSuccess: true, + fShaderSource: wtu.replaceParams(shaderType.fragArrayTest, {numTestType: numVars, code: code}, info), + fShaderSuccess: true, + linkSuccess: true, + ignoreResults: true, + passMsg: shaderType.type + " shader with uniform array of " + info.type + " with " + numVars + " elements (the maximum)", + }); + + var generateCode = function(numVars) { + var uniforms = []; + var codes = []; + for (var uu = 0; uu < numVars; ++uu) { + uniforms.push(" uniform " + info.type + " u_uniform" + uu + ";"); + codes.push(wtu.replaceParams(info.code, {id: uu, index: ""})); + } + return { + uniforms: uniforms.join("\n"), + code: codes.join(" + \n "), + }; + }; + + // Test max uniforms of type. + tests.push({ + vShaderSource: wtu.replaceParams(shaderType.vertUniformTest, generateCode(numMax), info), + vShaderSuccess: shaderType.vertExpectation, + fShaderSource: wtu.replaceParams(shaderType.fragUniformTest, generateCode(numMax), info), + fShaderSuccess: shaderType.fragExpectation, + linkSuccess: true, + ignoreResults: true, + passMsg: shaderType.type + " shader with " + (numMax) + " uniforms of " + info.type, + }); + } +} +GLSLConformanceTester.runTests(tests); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/compound-assignment-type-combination.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/compound-assignment-type-combination.html new file mode 100644 index 0000000000..7b61946b35 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/compound-assignment-type-combination.html @@ -0,0 +1,26 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Result type should match the l-value type in compound assignment</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 src="../../../js/tests/compound-assignment-type-combination.js"></script> +</head> +<body onload="runTest(1)"> +<div id="description"></div> +<div id="console"></div> +<script type="application/javascript"> +description(); +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/conditional-discard-in-loop.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/conditional-discard-in-loop.html new file mode 100644 index 0000000000..1c4709dd10 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/conditional-discard-in-loop.html @@ -0,0 +1,142 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Conditional discard in loop issue</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="output" style="border: none;" width="256" height="256"></canvas> +<div id="description"></div> +<div id="console"></div> + +<script id="shader-vs" type="x-shader/x-vertex"> +// Inputs +attribute vec4 a_position; +attribute vec2 a_tex_coords; + +// Output +varying vec2 v_tex_coords; + +void main(void) { + v_tex_coords = a_tex_coords; + gl_Position = a_position; +} +</script> + +<script id="shader-fs" type="x-shader/x-fragment"> +precision mediump float; + +// Constants +const float TEXEL_COUNT_V = 256.0; +const float TEXEL_HEIGHT = 1.0 / TEXEL_COUNT_V; +const float SEP_IX = TEXEL_COUNT_V / 2.0; + +const vec4 GREEN = vec4(0.0, 1.0, 0.0, 1.0); +const vec4 BLUE = vec4(0.0, 0.0, 1.0, 1.0); + +// Input +varying vec2 v_tex_coords; + +uniform sampler2D u_data; + +// Without this function or directly returning the data, the issue does not occur +mediump vec4 UnpackData(in vec4 inData) { + float s = inData.x; + // Note s is always 0 + // mod(0, 1) = 0 + // So return value = (0, 0, -1, 0) + return vec4(0.0, 0.0, mod(s, 1.0) - 1.0, 0.0); + + // Comment out the line above and uncomment the line below and the test succeeds on angle-dx11 + // return vec4(0.0, 0.0, -1.0, 0.0); +} + +void main(void) { + // Set initial color + gl_FragColor = BLUE; + + if (gl_FragCoord.y <= SEP_IX) { + mediump vec2 addr = vec2(v_tex_coords.x, TEXEL_HEIGHT); + + for (float e_ix = 0.0; e_ix < TEXEL_COUNT_V; ++e_ix) { + vec4 entry = texture2D(u_data, addr); + mediump vec4 unpack = UnpackData(entry); + + // Buffer is filled with 0, unpack is always (0, 0, -1, 0) + // So discard is always triggered + if (unpack.z == -1.0) { + discard; + } + + addr.y += unpack.z * TEXEL_HEIGHT; + } + // If discard is not triggered the output color is blue + } + else { + gl_FragColor = GREEN; + } +} +</script> + + +<script> +"use strict"; + +description(); +debug(""); +debug("If the code is executed correctly, the upper half of the viewport will be green, the lower half will be red."); +debug("This is a conformance suite test for the issue reported here : https://code.google.com/p/angleproject/issues/detail?id=706"); + +var wtu = WebGLTestUtils; +var canvas = document.getElementById("output"); +var gl = wtu.create3DContext(canvas); +if (!gl) { + testFailed("context does not exist"); +} else { + + // Create texture filled with zero's + var tex = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, tex); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + wtu.fillTexture(gl, tex, 256, 256, [0, 0, 0, 0]); + + // Clear complete viewport to red + gl.clearColor(1.0, 0.0, 0.0, 1.0); + gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); + + var attribBuffers = wtu.setupUnitQuad(gl, 0, 1); + var program = wtu.setupProgram(gl, ["shader-vs", "shader-fs"], ["a_position", "a_tex_coords"], [0, 1], true); + + // Bind texture + var uniformMap = wtu.getUniformMap(gl, program); + gl.activeTexture(gl.TEXTURE0); + gl.bindTexture(gl.TEXTURE_2D, tex); + gl.uniform1i(uniformMap.u_data.location, 0); + + // Draw + wtu.drawUnitQuad(gl); + + // Verify output + wtu.checkCanvasRect(gl, 0, 0, 256, 128, [ 255, 0, 0, 255 ], "should be red", 1); + wtu.checkCanvasRect(gl, 0, 128, 256, 128, [ 0, 255, 0, 255 ], "should be green", 1); +} + +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/bugs/conditional-discard-optimization.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/conditional-discard-optimization.html new file mode 100644 index 0000000000..1c3b1bb6fb --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/conditional-discard-optimization.html @@ -0,0 +1,117 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!-- author: Bill Baxter (wbaxter at google.com) --> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>ANGLE WebGL Shader Conditionals Repro</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="repro" style="border: none;" width="256" height="256"></canvas> +<div id="description"></div> +<div id="console"></div> + +<script id="shader-vs" type="x-shader/x-vertex"> +attribute vec2 pos; +varying mediump float varA; +void main(void) { + varA = 0.; + gl_Position = vec4(pos, 0.0, 1.0); +} +</script> + +<script id="shader-fs" type="x-shader/x-fragment"> +precision mediump float; +varying float varA; +void main(void) { + if (varA < -1. || (varA < -1. && varA > 1.)) { + discard; + } + gl_FragColor = vec4(0, 1, 0, 1) + 2. * varA * 2.; +} +</script> + +<script id="shader-fs-mutable" type="x-shader/x-fragment"> +precision mediump float; +varying float varA; +void main(void) { + float b = varA; + if (varA < (b -= 1.) || (varA < b && varA > (b += 2.))) { + discard; + } + gl_FragColor = vec4(0, 1, 0, 1) + 2. * varA * 2.; +} +</script> +<script id="shader-fs-unfolded" type="x-shader/x-fragment"> +precision mediump float; +varying float varA; +void main(void) { + bool s1 = varA < -1.; + if (!s1) { + bool s2 = varA < -1.; + if (s2) { + s2 = varA > 1.; + } + s1 = s2; + } + if (s1) { + discard; + } + gl_FragColor = vec4(0, 1, 0, 1) + 2. * varA * 2.; +} +</script> +<script> +"use strict"; + +description(); +debug(""); +debug("If things are working correctly, then there will be a green square."); +debug("Otherwise it will be a black void."); +debug("This is a repro for an issue seen on the D3D9 ANGLE implementation of WebGL on Chrome in a shader with a conditional discard, where the conditional is of the form (a || (b && c))."); + +var wtu = WebGLTestUtils; +var canvas = document.getElementById("repro"); +var gl = wtu.create3DContext(canvas); +if (!gl) { + testFailed("context does not exist"); +} else { + gl.clearColor(0.0, 0.0, 0.0, 1.0); + wtu.setupUnitQuad(gl); + + debug(""); + debug("Testing shader with conditional discard"); + gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); + var program = wtu.setupProgram(gl, ["shader-vs", "shader-fs"], ["pos"], undefined, true); + wtu.drawUnitQuad(gl); + wtu.checkCanvasRect(gl, 128, 128, 128, 128, [ 0, 255, 0, 255 ], "should be green", 1); + + debug(""); + debug("Testing conditional discard with side-effects in conditions"); + gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); + var programMutable = wtu.setupProgram(gl, ["shader-vs", "shader-fs-mutable"], ["pos"], undefined, true); + wtu.drawUnitQuad(gl); + wtu.checkCanvasRect(gl, 128, 128, 128, 128, [ 0, 255, 0, 255 ], "should be green", 1); + + debug(""); + debug("Testing conditional discard with unfolded condition logic"); + gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); + var programMutable = wtu.setupProgram(gl, ["shader-vs", "shader-fs-unfolded"], ["pos"], undefined, true); + wtu.drawUnitQuad(gl); + wtu.checkCanvasRect(gl, 128, 128, 128, 128, [ 0, 255, 0, 255 ], "should be green", 1); +} + +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/bugs/conditional-texture-fetch.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/conditional-texture-fetch.html new file mode 100644 index 0000000000..f382b8c800 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/conditional-texture-fetch.html @@ -0,0 +1,130 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Conditional texture fetch test</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script src="../../../js/glsl-conformance-test.js"></script> +</head> +<body> +<canvas id="output" style="border: none;" width="64" height="64"></canvas> +<div id="description"></div> +<div id="console"></div> +<script id="vshaderConditionalTextureFetch" type="x-shader/x-vertex"> +attribute vec2 a_position; +attribute vec4 a_canvasTileColor; +attribute vec2 a_texCoord; +varying vec2 texCoord; +varying vec4 canvasTileColor; +void main() +{ + canvasTileColor = a_canvasTileColor; + texCoord = a_texCoord; + gl_Position = vec4(a_position, 0.0, 1.0); +} +</script> +<script id="fshaderConditionalTextureFetch" type="x-shader/x-fragment"> +precision mediump float; +varying vec4 canvasTileColor; +uniform bool hasTexture; +uniform sampler2D canvasTileTexture; +varying vec2 texCoord; +uniform vec4 uvRect; +void main() +{ + vec4 finalColor = canvasTileColor; + if (hasTexture) { + vec2 clampedUV = clamp(texCoord.xy, uvRect.xy, uvRect.zw); + finalColor = texture2D(canvasTileTexture, clampedUV); + } + gl_FragColor = finalColor; +} +</script> +<script type="text/javascript"> +"use strict"; +description(); +debug("If the test passes correctly the viewport will be green."); + +var wtu = WebGLTestUtils; +var canvas = document.getElementById("output"); +var gl = wtu.create3DContext(canvas); + +var createGreenTexture = function() { + var texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + wtu.fillTexture(gl, texture, 1, 1, [0, 255, 0, 255]); + gl.bindTexture(gl.TEXTURE_2D, null); + return texture; +}; + +var test = function(greenTexture) { + // This is a reduced test case for a problem reported by Figma. + // Program compilation produces the following warning/error on ANGLE's + // D3D9 backend: + // [WARNING:angle_platform_impl.cc(51)] : rx::HLSLCompiler::compileToBinary(228): C:\fakepath(26,12): error X6077: texld/texldb/texldp/dsx/dsy instructions with r# as source cannot be used inside dynamic conditional 'if' blocks, dynamic conditional subroutine calls, or loop/rep with break*. + // + // All of the operations in the shader -- including the clamping of the + // texture coordinates -- seem to be needed in order to provoke this + // error. + // + // However, this doesn't seem to produce incorrect rendering results. + var program = wtu.setupProgram( + gl, + ["vshaderConditionalTextureFetch", + "fshaderConditionalTextureFetch"], + ["a_position", "a_canvasTileColor", "a_texCoord"], + [0, 1, 2], + true); + if (!program) { + testFailed("Shader compilation/link failed"); + } else { + // Set up buffers + wtu.setupUnitQuad(gl, 0, 2); + + // Set up constant color (red) + gl.vertexAttrib4f(1, 1, 0, 0, 1); + + var uniformMap = wtu.getUniformMap(gl, program); + + // Use texturing + gl.uniform1i(uniformMap["hasTexture"].location, 1); + + // Bind texture + gl.activeTexture(gl.TEXTURE0); + gl.bindTexture(gl.TEXTURE_2D, greenTexture); + gl.uniform1i(uniformMap["canvasTileTexture"].location, 0); + + // Set up (essentially no-op) clamp rectangle + gl.uniform4f(uniformMap["uvRect"].location, 0, 0, 0.25, 0.25); + + // Draw + wtu.clearAndDrawUnitQuad(gl); + + // Verify output + wtu.checkCanvas(gl, [0, 255, 0, 255], "should be green", 1); + } +}; + +if (!gl) { + testFailed("context does not exist"); +} else { + var tex = createGreenTexture(); + test(tex); +} +var successfullyParsed = true; +</script> +<script src="../../../js/js-test-post.js"></script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/constant-precision-qualifier.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/constant-precision-qualifier.html new file mode 100644 index 0000000000..d3628862bc --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/constant-precision-qualifier.html @@ -0,0 +1,115 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Bug - the precision qualifier of a constant variable should affect the precision of a consuming operation</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script src="../../../js/glsl-conformance-test.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script id="fshader" type="x-shader/x-fragment"> +// It is assumed that uTest is set to 0. It's here to make the expression not constant. +uniform mediump float uTest; + +void main() { + // exact representation of 4096.5 requires 13 bits of relative precision. + const highp float c = 4096.5; + mediump float a = 0.0; + // Below, addition should be evaluated at highp, since one of the operands has the highp qualifier. + // Thus fract should also be evaluated at highp. + // See OpenGL ES Shading Language spec section 4.5.2. + // This should make the result 0.5, since highp provides at least 16 bits of relative precision. + // (exceptions for operation precision are allowed for a small number of computationally + // intensive built-in functions, but it is reasonable to think that fract is not one of those). + // However, if fract() is incorrectly evaluated at minimum precision fulfilling mediump criteria, + // or at IEEE half float precision, the result is 0.0. + a = fract(c + uTest); + + // Multiply by 2.0 to make the color green. + gl_FragColor = vec4(0.0, 2.0 * a, 0.0, 1.0); +} +</script> +<script id="fshaderNoConstants" type="x-shader/x-fragment"> +// This shader has the same functionality as the one above, but it doesn't contain +// operations that can be constant folded at compile-time. +// It's here to provide a point of comparison. +uniform mediump float uTest; +uniform highp float uTestHigh; + +void main() { + highp float c = 4096.5 + uTestHigh; + mediump float a = 0.0; + a = fract(c + uTest); + gl_FragColor = vec4(0.0, 2.0 * a, 0.0, 1.0); +} +</script> +<script id="fshaderAllHighp" type="x-shader/x-fragment"> +// This shader has the same functionality as the one above, but it only uses highp. +// It's here to provide a point of comparison. +uniform highp float uTest; + +void main() { + highp float c = 4096.5 + uTest; + highp float a = 0.0; + a = fract(c + uTest); + gl_FragColor = vec4(0.0, 2.0 * a, 0.0, 1.0); +} +</script> +<script type="application/javascript"> +"use strict"; +description(); + +function test() { + var wtu = WebGLTestUtils; + var gl = wtu.create3DContext(); + if (!gl) { + testFailed("context does not exist"); + finishTest(); + return; + } + if (gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT).precision == 0) { + testPassed("highp precision not supported"); + finishTest(); + } else { + GLSLConformanceTester.runRenderTests([ + { + fShaderId: 'fshader', + fShaderSuccess: true, + linkSuccess: true, + passMsg: 'The precision qualifier of a constant affects built-in function results', + uniforms: [{name: "uTest", functionName: "uniform1f", value: 0}] + }, + { + fShaderId: 'fshaderNoConstants', + fShaderSuccess: true, + linkSuccess: true, + passMsg: 'The precision qualifier of a variable affects built-in function results', + uniforms: [{name: "uTest", functionName: "uniform1f", value: 0}, + {name: "uTestHigh", functionName: "uniform1f", value: 0}] + }, + { + fShaderId: 'fshaderAllHighp', + fShaderSuccess: true, + linkSuccess: true, + passMsg: 'All variables are qualified as highp', + uniforms: [{name: "uTest", functionName: "uniform1f", value: 0}] + }, + ]); + } +}; + +test(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/essl3-shaders-with-webgl1.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/essl3-shaders-with-webgl1.html new file mode 100644 index 0000000000..47e58c5c92 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/essl3-shaders-with-webgl1.html @@ -0,0 +1,138 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Browser bug - WebGL 1 context should not accept OpenGL ES 3 shading language shaders</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="ES1VertexShader" type="x-shader/x-vertex"> +precision mediump float; +attribute vec4 aPosition; + +void main() { + gl_Position = aPosition; +} +</script> +<script id="ES1FragmentShader" type="x-shader/x-fragment"> +precision mediump float; + +void main() { + gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); +} +</script> +<!-- Note that the version directive should be on the very first line in ESSL 3, see ESSL 3 section 3.3 --> +<script id="ES3VertexShader" type="x-shader/x-vertex">#version 300 es +precision mediump float; +in vec4 aPosition; + +void main() { + gl_Position = aPosition; +} +</script> +<script id="ES3FragmentShader" type="x-shader/x-fragment">#version 300 es +precision mediump float; +out vec4 my_FragColor; + +void main() { + my_FragColor = vec4(1.0, 0.0, 0.0, 1.0); +} +</script> +<script id="emptyES3FragmentShader" type="x-shader/x-fragment">#version 300 es +precision mediump float; +void main() { +} +</script> +<script id="vertexShaderWithInQualifier" type="x-shader/x-vertex"> +precision mediump float; +in vec4 aPosition; + +void main() { + gl_Position = aPosition; +} +</script> +<script id="fragmentShaderWithOutQualifier" type="x-shader/x-fragment"> +precision mediump float; +out vec4 my_FragColor; + +void main() { + my_FragColor = vec4(1.0, 0.0, 0.0, 1.0); +} +</script> +<script type="application/javascript"> +"use strict"; +description("OpenGL ES 3 shading language shaders should not be accepted by WebGL 1."); +GLSLConformanceTester.runTests([ + { + vShaderId: "ES3VertexShader", + vShaderSuccess: false, + fShaderId: "ES1FragmentShader", + fShaderSuccess: true, + linkSuccess: false, + passMsg: "OpenGL ES 3 shading language vertex shader with an in variable should not be accepted by WebGL 1." + }, + { + vShaderId: "ES1VertexShader", + vShaderSuccess: true, + fShaderId: "ES3FragmentShader", + fShaderSuccess: false, + linkSuccess: false, + passMsg: "OpenGL ES 3 shading language fragment shader with an out variable should not be accepted by WebGL 1." + }, + { + vShaderId: "ES1VertexShader", + vShaderSuccess: true, + fShaderId: "emptyES3FragmentShader", + fShaderSuccess: false, + linkSuccess: false, + passMsg: "OpenGL ES 3 shading language fragment shader with an empty body should not be accepted by WebGL 1." + }, + { + vShaderId: "ES3VertexShader", + vShaderSuccess: false, + fShaderId: "ES3FragmentShader", + fShaderSuccess: false, + linkSuccess: false, + passMsg: "OpenGL ES 3 shading language shaders should not be linked by WebGL 1." + }, + { + vShaderId: "ES3VertexShader", + vShaderSuccess: false, + fShaderId: "emptyES3FragmentShader", + fShaderSuccess: false, + linkSuccess: false, + passMsg: "OpenGL ES 3 shading language shaders including fragment shader with empty body should not be linked by WebGL 1." + }, + { + vShaderId: "vertexShaderWithInQualifier", + vShaderSuccess: false, + fShaderId: "ES1FragmentShader", + fShaderSuccess: true, + linkSuccess: false, + passMsg: "Vertex shader with an in qualifier on a global variable should not be accepted by WebGL 1." + }, + { + vShaderId: "ES1VertexShader", + vShaderSuccess: true, + fShaderId: "fragmentShaderWithOutQualifier", + fShaderSuccess: false, + linkSuccess: false, + passMsg: "Fragment shader with an out qualifier on a global variable should not be accepted by WebGL 1." + } +]); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/floor-div-cos-should-not-truncate.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/floor-div-cos-should-not-truncate.html new file mode 100644 index 0000000000..69a019aa1b --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/floor-div-cos-should-not-truncate.html @@ -0,0 +1,80 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Floor + divide + cosine should not truncate intermediate results.</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +</head> +<body> +<canvas id="canvas" width="256" height="256"> </canvas> +<div id="description"></div> +<div id="console"></div> + +<script id="vshader" type="x-shader/x-vertex"> +precision highp float; + +attribute vec3 pos; + +// This divisor must be greater than the 32-bit floating point +// representation of 1e6 / (2 * pi) to repro. +const float magic = 159154.953125; + +void main(void) { + // This floor must be present to repro. + float x = floor(pos.x); + + // This divide and cosine must be present to repro. + x = cos(x / magic); + + // If the GPU truncated 'x / magic' to 0, then 'cos(x / magic)' will produce + // 1.0, the green square will be moved offscreen, and the red background + // will be visible. + gl_Position.x = pos.y + x * 2.0; + gl_Position.y = pos.z; + gl_Position.z = 0.0; + gl_Position.w = 1.0; +} +</script> + +<script id="fshader" type="x-shader/x-fragment"> +precision highp float; + +void main(void) { + gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); +} +</script> + +<script type="application/javascript"> +"use strict"; +description("Flooring a number, then dividing by a large number, then computing the cosine of that should not truncate the intermediate values."); +debug("Regression test for <a href='https://code.google.com/p/angleproject/issues/detail?id=1179'>https://code.google.com/p/angleproject/issues/detail?id=1179</a>"); +var wtu = WebGLTestUtils; +var gl = wtu.create3DContext("canvas"); +var program = wtu.setupProgram(gl, ['vshader', 'fshader'], ['pos'], undefined, true); + +gl.clearColor(1, 0, 0, 1); +gl.clear(gl.COLOR_BUFFER_BIT); + +var magic = 159154.953125; +var x = (Math.PI / 2.0) * magic; +var data = [ + x, -1, -1, + x, 1, -1, + x, 1, 1, + x, -1, -1, + x, 1, 1, + x, -1, 1 +]; + +gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer()); +gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(data), gl.STATIC_DRAW); +gl.enableVertexAttribArray(0); +gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 12, 0); + +gl.drawArrays(gl.TRIANGLES, 0, 6); + +wtu.checkCanvas(gl, [0,255,0,255], "should be 0,255,0,255"); +finishTest(); +</script> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/floored-division-accuracy.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/floored-division-accuracy.html new file mode 100644 index 0000000000..6986344d3a --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/floored-division-accuracy.html @@ -0,0 +1,69 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!-- author: Bill Baxter (wbaxter at google.com) --> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Floored Division Accuracy Bug</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script src="../../../js/glsl-conformance-test.js"></script> +</head> + +<body> +<div id="description"></div> +<div id="console"></div> + +<script id="shader-vs" type="x-shader/x-vertex"> +attribute vec4 vPosition; +uniform float divisor; +varying vec4 vColor; +void main(void) { + gl_Position = vPosition; + float index = 9.0; + // Floating point operations don't have any guaranteed precision, but they + // should at least be accurate to 1 part in 10^5. + float value = floor((index / divisor) * 1.00001); + vColor = (value == 3.) ? vec4(0, 1, 0, 1) : vec4(1, 0, 0, 1); +} +</script> + +<script id="shader-fs" type="x-shader/x-fragment"> +precision mediump float; +varying vec4 vColor; +void main(void) { + gl_FragColor = vColor; +} +</script> +<script> +"use strict"; +description(); + +debug(""); +// Reproduces bug seen on Mac OS X with AMD Radeon HD 6490 GPU +debug("If things are working correctly, then the square will be green."); +debug("If your card thinks floor(9. / 3.) is not 3 to within 1 part in 10^5, "); +debug("then the square will be red."); + +GLSLConformanceTester.runRenderTests([ +{ + vShaderId: 'shader-vs', + vShaderSuccess: true, + fShaderId: 'shader-fs', + fShaderSuccess: true, + linkSuccess: true, + passMsg: 'Test that floor(9. / 3.) is 3 to within 1 part in 10^5', + uniforms: [{name: "divisor", functionName: "uniform1f", value: 3}] +} +]); + +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/fragcoord-linking-bug.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/fragcoord-linking-bug.html new file mode 100644 index 0000000000..f22632c0a4 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/fragcoord-linking-bug.html @@ -0,0 +1,93 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL compiler bug referencing gl_FragCoord</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> +<!-- These shaders were extracted from Skia's GPU accelerated backend "Ganesh". --> +<script id="shader-vs" type="x-shader/x-vertex"> +uniform mat3 uViewM; +uniform mat3 uStageMatrix_Stage1; +uniform vec4 urtAdjustment; +attribute vec2 aPosition; +attribute vec4 aColor; +varying vec4 vColor; +varying vec2 vMatrixCoord_Stage1; +void main() { + vec3 pos3 = uViewM * vec3(aPosition, 1); + vColor = aColor; + { // Stage 0: XferEffect + } + vMatrixCoord_Stage1 = (uStageMatrix_Stage1 * vec3(aPosition, 1)).xy; + { // Stage 1: Texture + } + gl_Position = vec4(dot(pos3.xz, urtAdjustment.xy), dot(pos3.yz, urtAdjustment.zw), 0, pos3.z); +} +</script> + +<script id="shader-fs" type="x-shader/x-fragment"> +precision mediump float; +uniform sampler2D uDstCopySampler; +uniform vec2 uDstCopyUpperLeft; +uniform vec2 uDstCopyCoordScale; +uniform float uRTHeight; +uniform sampler2D uSampler0_Stage1; +varying vec4 vColor; +varying vec2 vMatrixCoord_Stage1; +void main() { + vec4 fragCoordYDown = vec4(gl_FragCoord.x, uRTHeight - gl_FragCoord.y, gl_FragCoord.zw); + // Read color from copy of the destination. + vec2 _dstTexCoord = (fragCoordYDown.xy - uDstCopyUpperLeft) * uDstCopyCoordScale; + _dstTexCoord.y = 1.0 - _dstTexCoord.y; + vec4 _dstColor = texture2D(uDstCopySampler, _dstTexCoord); + + vec4 output_Stage0; + { // Stage 0: XferEffect + // SkXfermode::Mode: Multiply + output_Stage0.a = vColor.a + (1.0 - vColor.a) * _dstColor.a; + output_Stage0.rgb = (1.0 - vColor.a) * _dstColor.rgb + (1.0 - _dstColor.a) * vColor.rgb + vColor.rgb * _dstColor.rgb; + } + vec4 output_Stage1; + { // Stage 1: Texture + output_Stage1 = texture2D(uSampler0_Stage1, vMatrixCoord_Stage1); + } + gl_FragColor = ((output_Stage0 * output_Stage1) + ((vec4(1) - output_Stage1) * _dstColor)); +} +</script> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; + +description(); +debug(""); +debug('Verify shaders using gl_FragCoord z and w components compile and link correctly'); +debug('Regression test for Qualcomm bug ID CR649654'); +var wtu = WebGLTestUtils; +var gl = wtu.create3DContext(); +if (!gl) { + testFailed("context does not exist"); +} else { + var program = wtu.setupProgram(gl, ["shader-vs", "shader-fs"], null, null, true); + if (program) { + testPassed("Program compiled and linked successfully"); + } else { + testFailed("Program failed to compile and link"); + } +} + +var successfullyParsed = true; +</script> +<script src="../../../js/js-test-post.js"></script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/gl-fragcoord-multisampling-bug.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/gl-fragcoord-multisampling-bug.html new file mode 100644 index 0000000000..ef1184d49f --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/gl-fragcoord-multisampling-bug.html @@ -0,0 +1,66 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>gl_FragCoord multisampling bug</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="canvasHolder"></div> +<div id="description"></div> +<div id="console"></div> + +<script id="vshader" type="x-shader/x-vertex"> +attribute vec4 a_position; +void main() { + gl_Position = vec4(a_position.xy, 1.0, 1.0); +} +</script> + +<script id="fshader" type="x-shader/x-fragment"> +precision mediump float; + +void main() { + float depth = gl_FragCoord.z / gl_FragCoord.w; + gl_FragColor = vec4( 0.0, depth, 0.0, 1.0 ); +} +</script> + +<script type="application/javascript"> +"use strict"; +description("gl_FragCoord multisampling bug"); +debug("Verifies gl_FragCoord z/w values are unaffected by multisampling."); +debug('Regression test for <a href="https://github.com/mrdoob/three.js/issues/7769">Three.js Issue 7769</a>'); +var wtu = WebGLTestUtils; +for (var ii = 0; ii < 2; ++ii) { + debug("Testing " + (ii > 0 ? "with" : "without") + " multisampling"); + var canvas = document.createElement('canvas'); + canvas.width = 256; + canvas.height = 256; + canvas.style.padding = "2px"; + document.getElementById('canvasHolder').appendChild(canvas); + var options; + if (ii > 0) { + options = { antialias: true }; + } + var gl = wtu.create3DContext(canvas, options); + + gl.clearColor(1, 0, 0, 1); + gl.clear(gl.COLOR_BUFFER_BIT); + + var attribBuffers = wtu.setupUnitQuad(gl, 0, 1); + var program = wtu.setupProgram(gl, ['vshader', 'fshader'], ['a_position'], [0], true); + if (!program) { + testFailed("Shader compilation/link failed"); + } else { + // Draw + wtu.drawUnitQuad(gl); + // Verify output + wtu.checkCanvas(gl, [0, 255, 0, 255], "should be green", 3); + } +} + +finishTest(); +</script> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/global-invariant-does-not-leak-across-shaders.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/global-invariant-does-not-leak-across-shaders.html new file mode 100644 index 0000000000..b02622bb29 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/global-invariant-does-not-leak-across-shaders.html @@ -0,0 +1,77 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Global invariant does not leak across shaders</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script src="../../../js/glsl-conformance-test.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script id="InvariantVertex" type="x-shader/x-vertex"> +#pragma STDGL invariant(all) + +void main() +{ + gl_Position = vec4(1.0, 0.0, 0.0, 1.0); +} +</script> +<script id="Fragment" type="x-shader/x-fragment"> +precision mediump float; + +void main() +{ + gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); +} +</script> +<script id="VertexWithVarying" type="x-shader/x-vertex"> +varying vec2 testVarying; + +void main() { + gl_Position = vec4(1.0, 0.0, 0.0, 1.0); + testVarying = vec2(0.0, 0.0); +} +</script> +<script id="FragmentWithVarying" type="x-shader/x-fragment"> +precision mediump float; +varying vec2 testVarying; + +void main() +{ + gl_FragColor = vec4(testVarying, 0.0, 1.0); +} +</script> +<script type="text/javascript"> +"use strict"; +description("The use of the global invariant pragma in one shader must not affect other shaders."); + +GLSLConformanceTester.runTests([ + { + vShaderId: "InvariantVertex", + vShaderSuccess: true, + fShaderId: "Fragment", + fShaderSuccess: true, + linkSuccess: true, + passMsg: "Shaders using global invariant pragma should compile and link." + }, + { + vShaderId: "VertexWithVarying", + vShaderSuccess: true, + fShaderId: "FragmentWithVarying", + fShaderSuccess: true, + linkSuccess: true, + passMsg: "Shaders not using global invariant pragma should compile and link." + }, +]); +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/if-return-and-elseif.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/if-return-and-elseif.html new file mode 100644 index 0000000000..4e88ae83be --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/if-return-and-elseif.html @@ -0,0 +1,65 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>If with return and else if in fragment shader</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script src="../../../js/glsl-conformance-test.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script id="vshader" type="x-shader/x-vertex"> +attribute vec4 pos; +varying vec2 vPos; +void main() +{ + gl_Position = pos; + vPos = pos.xy; +} +</script> +<script id="fshader" type="x-shader/x-fragment"> +precision mediump float; + +varying vec2 vPos; +void main() +{ + if(vPos.x < 1.0) // This colors the whole canvas green + { + gl_FragColor = vec4(0, 1, 0, 1); + return; + } + else if(vPos.x < 1.1) // This should have no effect + { + gl_FragColor = vec4(1, 0, 0, 1); + } +} + +</script> +<script type="text/javascript"> +"use strict"; +description(); + +// Minimal test case based on report at http://anglebug.com/2325 + +GLSLConformanceTester.runRenderTests([ +{ + vShaderId: 'vshader', + vShaderSuccess: true, + fShaderId: 'fshader', + fShaderSuccess: true, + linkSuccess: true, + passMsg: "If and else if in fragment shader" +} +]); +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/in-parameter-passed-as-inout-argument-and-global.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/in-parameter-passed-as-inout-argument-and-global.html new file mode 100644 index 0000000000..77edd0ec3a --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/in-parameter-passed-as-inout-argument-and-global.html @@ -0,0 +1,52 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Function in parameter passed as an inout argument and a global variable with the same name</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script src="../../../js/glsl-conformance-test.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script id="fshaderParameters" type="x-shader/x-fragment"> +precision mediump float; +uniform vec3 u_zero; +vec3 p; +void G(inout vec3 q) { + p += q; +} +void F(in vec3 p) { + G(p); +} +void main(){ + F(u_zero + vec3(0.0, 1.0, 0.0)); + gl_FragColor = vec4(p, 1.0); +} +</script> +<script type="text/javascript"> +"use strict"; +description(); + +// This is intended to test an issue seen on NVIDIA OpenGL drivers (at least up to version 388.59). +// http://crbug.com/792210 + +GLSLConformanceTester.runRenderTests([ +{ + fShaderId: 'fshaderParameters', + fShaderSuccess: true, + linkSuccess: true, + passMsg: "Function in parameter passed as an inout argument and a global variable with the same name" +} +]); +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/init-array-with-loop.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/init-array-with-loop.html new file mode 100644 index 0000000000..2bd24765bd --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/init-array-with-loop.html @@ -0,0 +1,84 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Initializing an array with a loop test</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script src="../../../js/glsl-conformance-test.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script id="fshaderInitLoop" type="x-shader/x-fragment"> +precision mediump float; + +void initGlobals(); + +uniform vec4 in0; +vec4 out0; + +float func(float a[4]) { + a[0] = -1.0; + return a[0]; +} + +float arr[4]; + +bool isOk(vec4 a) { + vec4 ref = -(in0 + 1.0); + if (abs(a.x - ref.x) < 0.05 && abs(a.y - ref.y) < 0.05 && abs(a.z - ref.z) < 0.05 && abs(a.w - ref.w) < 0.05) + { + return true; + } + return false; +} + +void main() { + initGlobals(); + arr[0] = in0.x + 1.0; + arr[1] = in0.y + 1.0; + arr[2] = in0.z + 1.0; + arr[3] = in0.w + 1.0; + mediump float f = func(arr); + out0 = f * vec4(arr[0], arr[1], arr[2], arr[3]); + if (isOk(out0)) + { + gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); + } + else + { + gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); + } +} + +void initGlobals() { + out0 = vec4(0.0, 0.0, 0.0, 0.0); + for (int i = 0; i < 4; ++i) + { + arr[i] = 0.0; + } +} +</script> +<script type="text/javascript"> +"use strict"; +description(); + +GLSLConformanceTester.runRenderTests([ +{ + fShaderId: 'fshaderInitLoop', + fShaderSuccess: true, + linkSuccess: true, + passMsg: "Initialize a global array using a for loop" +} +]); +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/invariant-does-not-leak-across-shaders.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/invariant-does-not-leak-across-shaders.html new file mode 100644 index 0000000000..d203731012 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/invariant-does-not-leak-across-shaders.html @@ -0,0 +1,74 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Invariant does not leak across shaders</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script src="../../../js/glsl-conformance-test.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script id="InvariantVertex" type="x-shader/x-vertex"> +varying vec4 v_varying; +invariant v_varying; + +void main() +{ + gl_Position = v_varying; +} +</script> +<script id="InvariantFragment" type="x-shader/x-fragment"> +precision mediump float; +invariant varying vec4 v_varying; + +void main() +{ + gl_FragColor = v_varying; +} +</script> +<script id="VertexWithVarying" type="x-shader/x-vertex"> +varying vec4 v_varying; + +void main() { + gl_Position = v_varying; +} +</script> +<script type="text/javascript"> +"use strict"; +description("The use of the invariant qualifier in one shader must not affect other shaders."); + +debug(""); +debug("This is a deliberate subset of conformance/glsl/misc/shaders-with-invariance.html."); +debug("Compared with the original tests, order of the tests is different."); +debug("This test covers an ANGLE bug. See crbug.com/634813."); + +GLSLConformanceTester.runTests([ + { + vShaderId: "InvariantVertex", + vShaderSuccess: true, + fShaderId: "InvariantFragment", + fShaderSuccess: true, + linkSuccess: true, + passMsg: "Shaders using invariant qualifier should compile and link." + }, + { + vShaderId: "VertexWithVarying", + vShaderSuccess: true, + fShaderId: "InvariantFragment", + fShaderSuccess: true, + linkSuccess: false, + passMsg: "vertex shader with variant varying and fragment shader with invariant varying must fail" + }, +]); +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/logic-inside-block-without-braces.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/logic-inside-block-without-braces.html new file mode 100644 index 0000000000..2bbac4dbd0 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/logic-inside-block-without-braces.html @@ -0,0 +1,86 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Short-circuiting logic operator with side effects inside if statement without braces should work</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script src="../../../js/glsl-conformance-test.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script id="fshaderIf" type="x-shader/x-fragment"> +precision mediump float; +uniform bool uFalse; + +float wrong = 0.0; + +bool foo() { + wrong += 1.0; + return !uFalse; +} + +bool bar() { + return !uFalse; +} + +void main() { + // No braces here - that can affect whether the contents of the if get parsed as a block or a statement. + if (uFalse) + foo() && bar(); + gl_FragColor = vec4(0.0, 1.0 - wrong, 0.0, 1.0); +} +</script> +<script id="fshaderFor" type="x-shader/x-fragment"> +precision mediump float; + +float wrong = 0.0; + +bool foo() { + wrong += 1.0; + return false; +} + +bool bar() { + return false; +} + +void main() { + // No braces here - that can affect whether the contents of the for get parsed as a block or a statement. + for (int i = 0; i < 0; ++i) + foo() && bar(); + gl_FragColor = vec4(0.0, 1.0 - wrong, 0.0, 1.0); +} +</script> +<script type="application/javascript"> +"use strict"; +description("Short-circuiting logic operator with side effects inside if/for statement without braces should work."); +debug(""); + +GLSLConformanceTester.runRenderTests([ +{ + fShaderId: 'fshaderIf', + fShaderSuccess: true, + linkSuccess: true, + passMsg: 'Short-circuiting operator inside if statement without braces', + uniforms: [{name: "uFalse", functionName: "uniform1i", value: 0}] +}, +{ + fShaderId: 'fshaderFor', + fShaderSuccess: true, + linkSuccess: true, + passMsg: 'Short-circuiting operator inside for statement without braces' +} +]); +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/long-expressions-should-not-crash.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/long-expressions-should-not-crash.html new file mode 100644 index 0000000000..eaf0509b23 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/long-expressions-should-not-crash.html @@ -0,0 +1,136 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Driver Bug - long experssions should not crash</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script src="../../../js/glsl-conformance-test.js"></script> +</head> +<body> +<canvas id="example" width="40" height="40"> </canvas> +<div id="description"></div> +<div id="console"></div> +<script id="vshader" type="x-shader/x-vertex"> +void main(){ + gl_Position = vec4(0, 0, 0, 1); +} +</script> +<script id="vshaderUniformTest" type="x-shader/x-vertex"> +uniform vec4 u_uniform; +void main(){ + gl_Position = + $(code) + vec4(0, 0, 0, 1); +} +</script> +<script id="fshader" type="x-shader/x-fragment"> +precision mediump float; +void main() +{ + gl_FragColor = vec4(0, 0, 0, 0); +} +</script> +<script id="fshaderUniformTest" type="x-shader/x-fragment"> +precision mediump float; +uniform vec4 u_uniform; +void main() +{ + gl_FragColor = + $(code) + vec4(0, 0, 0, 0); +} +</script> +<script> +"use strict"; +var wtu = WebGLTestUtils; +var gl = wtu.create3DContext(); + +var vUniformTestSource = wtu.getScript("vshaderUniformTest"); +var fUniformTestSource = wtu.getScript("fshaderUniformTest"); + +var tests = [ +]; +var counts = [ + { count:10, + mustPass: true, + }, + { count:100, + mustPass: true, + }, + { count: 1000, + mustPass: false, + }, + { count: 10000, + mustPass: false, + }, +]; +var operatorSets = [ + ["+", "-", "/", "*"], + ["+"], + ["-"], +]; +counts.forEach(function(info) { + operatorSets.forEach(function(operators) { + var generateCode = function(numVars) { + var codes = []; + for (var uu = 0; uu < numVars; ++uu) { + codes.push("u_uniform " + operators[uu % operators.length]); + } + return { + code: codes.join("\n "), + }; + }; + + var subs = generateCode(info.count); + tests.push({ + vShaderId: "vshader", + vShaderSuccess: true, + fShaderSource: wtu.replaceParams(fUniformTestSource, subs), + fShaderSuccess: true, + linkSuccess: true, + ignoreResults: !info.mustPass, + passMsg: "shader with " + info.count + " [" + operators + "] operators in expression in multiple lines", + }); + tests.push({ + vShaderSource: wtu.replaceParams(vUniformTestSource, subs), + vShaderSuccess: true, + fShaderId: "fshader", + fShaderSuccess: true, + linkSuccess: true, + ignoreResults: !info.mustPass, + passMsg: "shader with " + info.count + " [" + operators + "] operators in expression in multiple lines", + }); + subs.code = subs.code.replace(/\n /g, "") + tests.push({ + vShaderId: "vshader", + vShaderSuccess: true, + fShaderSource: wtu.replaceParams(fUniformTestSource, subs), + fShaderSuccess: true, + linkSuccess: true, + ignoreResults: !info.mustPass, + passMsg: "shader with " + info.count + " [" + operators + "] operators in expression in one line", + }); + tests.push({ + vShaderSource: wtu.replaceParams(vUniformTestSource, subs), + vShaderSuccess: true, + fShaderId: "fshader", + fShaderSuccess: true, + linkSuccess: true, + ignoreResults: !info.mustPass, + passMsg: "shader with " + info.count + " [" + operators + "] operators in expression in one line", + }); + }); +}); +GLSLConformanceTester.runTests(tests); +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/loop-if-loop-gradient.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/loop-if-loop-gradient.html new file mode 100644 index 0000000000..914604ad07 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/loop-if-loop-gradient.html @@ -0,0 +1,75 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Gradient loop in if in loop crash</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script id='vshader' type='x-shader/x-vertex'> +precision highp float; +void main() { +gl_Position = vec4( 1.0, 1.0, 1.0, 1.0 ); +} +</script> +<script id='fshader' type='x-shader/x-fragment'> +precision mediump float; +uniform lowp sampler2D iChannel0; + +void main(){ + highp float c; + for (mediump float i = 0.0; i <= 1.0; i++) { + if (gl_FragCoord.x < 0.0) { + for (mediump float l = 0.0; l < 2.0; l++) { // with 1 as a bound it works + c = texture2D(iChannel0, vec2(l), 0.0).x; + } + } + } + gl_FragColor = vec4(c, vec3(1.0)); +} +</script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +description("This test checks an ANGLE regression that was caused by a complex ShaderToy shader. <a href='https://code.google.com/p/chromium/issues/detail?id=524297'>crbug.com/524297</a>"); + +debug(""); + +var wtu = WebGLTestUtils; +var gl = wtu.create3DContext(); + +gl.canvas.addEventListener("webglcontextlost", function(e) { + testFailed("WebGL context lost"); +}); + +if (!gl) { + testFailed("WebGL context does not exist"); +} else { + testPassed("WebGL context exists"); + debug(""); + + var program = wtu.setupProgram(gl, ['vshader', 'fshader']); + if (!gl.getProgramParameter(program, gl.LINK_STATUS)) { + testFailed("Program failed to link"); + } + wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors"); +} + +// Cycle through a rAF once to give any webglcontextlost events a chance to propagate +window.requestAnimationFrame(function() { finishTest(); }); + +debug(""); +var successfullyParsed = true; +</script> + +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/modulo-arithmetic-accuracy.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/modulo-arithmetic-accuracy.html new file mode 100644 index 0000000000..6e39f69ab7 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/modulo-arithmetic-accuracy.html @@ -0,0 +1,68 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!-- author: Bill Baxter (wbaxter at google.com) --> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Modulo Arithmetic Accuracy Bug</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script src="../../../js/glsl-conformance-test.js"></script> +</head> + +<body> +<div id="description"></div> +<div id="console"></div> + +<script id="shader-vs" type="x-shader/x-vertex"> +attribute vec4 vPosition; +uniform float divisor; +varying vec4 vColor; +void main(void) { + gl_Position = vPosition; + float index = 9.0; + // mod(x, y) is computed as x-y*floor(x/y). There are no guarantees on + // the precision of floating point operations in WebGL shaders, but division + // should be accurate to at least 1 part in 10^5. + float value = mod(index * 1.00001, divisor); + vColor = (value < 1.) ? vec4(0, 1, 0, 1) : vec4(1, 0, 0, 1); +} +</script> + +<script id="shader-fs" type="x-shader/x-fragment"> +precision mediump float; +varying vec4 vColor; +void main(void) { + gl_FragColor = vColor; +} +</script> +<script> +"use strict"; + +description(); +debug(""); +// Reproduces bug seen on Mac OS X with AMD Radeon HD 6490 GPU +debug("If things are working correctly, then the square will be green."); +debug("If your card thinks mod(9,3) is not 0, then the square will be red."); + +GLSLConformanceTester.runRenderTests([ +{ + vShaderId: 'shader-vs', + vShaderSuccess: true, + fShaderId: 'shader-fs', + fShaderSuccess: true, + linkSuccess: true, + passMsg: 'Test that mod(9/3) is 0', + uniforms: [{name: "divisor", functionName: "uniform1f", value: 3}] +} +]); +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/multiplication-assignment.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/multiplication-assignment.html new file mode 100644 index 0000000000..cb157cdec6 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/multiplication-assignment.html @@ -0,0 +1,50 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Multiplication assignment operator compilation bug</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script src="../../../js/glsl-conformance-test.js"></script> +</head> +<body> +<script id="fshader" type="x-shader/x-fragment"> +precision mediump float; +uniform mat3 rot; +float foo(vec3 bar) { + bar *= rot; + return 0.0; +} + +void main(void){ + gl_FragColor = vec4(foo(vec3(0))); +} +</script> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; + +description(); +debug(""); +debug('Verify multiplication assignment operator compiles correctly - regression test for <a href="https://code.google.com/p/chromium/issues/detail?id=384847">Chromium bug 384847</a>'); + +GLSLConformanceTester.runTests([ +{ + fShaderId: 'fshader', + fShaderSuccess: true, + linkSuccess: true, + passMsg: "vec3 *= mat3 multiplication assignment operator", +} +]); + +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/nested-functions-should-not-crash.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/nested-functions-should-not-crash.html new file mode 100644 index 0000000000..130f0a0e4f --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/nested-functions-should-not-crash.html @@ -0,0 +1,89 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Driver Bug - nested functions should not crash</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script src="../../../js/glsl-conformance-test.js"></script> +</head> +<body> +<canvas id="example" width="40" height="40"> </canvas> +<div id="description"></div> +<div id="console"></div> +<script id="vshader" type="x-shader/x-vertex"> +void main(){ + gl_Position = vec4(0, 0, 0, 1); +} +</script> +<script id="fshaderUniformTest" type="x-shader/x-fragment"> +precision mediump float; +uniform vec4 u_uniform; + +$(code) + +void main() +{ + gl_FragColor = function0(); +} +</script> +<script> +"use strict"; +var wtu = WebGLTestUtils; +var gl = wtu.create3DContext(); + +var fUniformTestSource = wtu.getScript("fshaderUniformTest"); + +var tests = [ +]; +var counts = [ + { count:10, + mustPass: true, + }, + { count:100, + mustPass: false, + }, + { count: 1000, + mustPass: false, + }, + { count: 10000, + mustPass: false, + }, +]; +var operators = ["+", "-", "/", "*"]; +counts.forEach(function(info) { + var generateCode = function(numVars) { + var codes = []; + codes.push("vec4 function" + numVars + "() { return u_uniform; }"); + for (var uu = 0; uu < numVars; ++uu) { + var id = numVars - uu - 1; + codes.push("vec4 function" + id + "() { return function" + (id + 1) + "(); }"); + } + return { + code: codes.join("\n\n"), + }; + }; + + var subs = generateCode(info.count); + tests.push({ + vShaderId: "vshader", + vShaderSuccess: true, + fShaderSource: wtu.replaceParams(fUniformTestSource, subs), + fShaderSuccess: true, + linkSuccess: true, + ignoreResults: !info.mustPass, + passMsg: "shader with " + info.count + " nested functions", + }); +}); +GLSLConformanceTester.runTests(tests); +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/nested-loops-with-break-and-continue.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/nested-loops-with-break-and-continue.html new file mode 100644 index 0000000000..d6a744741a --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/nested-loops-with-break-and-continue.html @@ -0,0 +1,83 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Using nested loops with break and/or continue statements in a fragment shader should work</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css" /> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +</head> +<body> +<canvas id="canvas" width="256" height="256"> </canvas> +<div id="description"></div> +<div id="console"></div> +<script id="vshader" type="x-shader/x-vertex"> +attribute vec3 aPosition; + +void main() { + gl_Position = vec4(aPosition, 1); +} +</script> +<script id="fshader" type="x-shader/x-fragment"> +precision mediump float; +uniform int uCount; + +void main() { + int a = 0; + for (int i = 0; i < 10; ++i) { + if (i >= uCount) { break; } + for (int j = 0; j < 10; ++j) { + if (j >= uCount) { continue; } + a += 1; + } + for (int j = 0; j < 10; ++j) { + if (j >= uCount) { break; } + a += 1; + } + for (int j = 0; j < 10; ++j) { + if (j >= uCount) { continue; } + a += 1; + } + for (int j = 0; j < 10; ++j) { + if (j >= uCount) { break; } + a += 1; + } + for (int j = 0; j < 10; ++j) { + if (j >= uCount) { continue; } + a += 1; + } + } + float b = (float(a) / 125.0) * (64.0 / 255.0); + gl_FragColor = vec4(b, 1.0 - b, 0.0, 1.0); +} +</script> +<script type="application/javascript"> +"use strict"; +description("Multiple loops using break and continue statements should work."); +debug(""); +var wtu = WebGLTestUtils; +function test() { + var gl = wtu.create3DContext("canvas"); + if (!gl) { + testFailed("context does not exist"); + return; + } + wtu.setupUnitQuad(gl); + var program = wtu.setupProgram(gl, ["vshader", "fshader"], ["aPosition"], undefined, true); + var uniformLoc = gl.getUniformLocation(program, 'uCount'); + gl.uniform1i(uniformLoc, 5); + wtu.drawUnitQuad(gl); + wtu.checkCanvas(gl, [64, 191, 0, 255], "should be 64,191,0,255"); +}; + +test(); +finishTest(); +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/nested-sequence-operator.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/nested-sequence-operator.html new file mode 100644 index 0000000000..b202b854ff --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/nested-sequence-operator.html @@ -0,0 +1,47 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Nested sequence operator</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script src="../../../js/glsl-conformance-test.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script id="fshaderNestedSequenceOperator" type="x-shader/x-fragment"> +precision mediump float; +// Note that keep_flop_positive is expected to keep its default value false. +uniform bool keep_flop_positive; +float flop; +void main() +{ + flop = -1.0, + (flop *= -1.0, + keep_flop_positive ? 0.0 : flop *= -1.0), + gl_FragColor = vec4(0, -flop, 0, 1); +} +</script> +<script type="text/javascript"> +"use strict"; +description("Test a nested sequence operator with a ternary operator inside. The ternary operator needs to be converted into an if statement on a HLSL based WebGL backend, which makes this case tricky."); + +GLSLConformanceTester.runRenderTests([ +{ + fShaderId: 'fshaderNestedSequenceOperator', + fShaderSuccess: true, + linkSuccess: true, + passMsg: "Nested sequence operator is evaluated in the expected order." +} +]); +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/pow-of-small-constant-in-user-defined-function.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/pow-of-small-constant-in-user-defined-function.html new file mode 100644 index 0000000000..d5fa55b898 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/pow-of-small-constant-in-user-defined-function.html @@ -0,0 +1,74 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Bug - calculating powers of constants smaller than 1.0e-5 in user-defined functions should work</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +</head> +<body> +<canvas id="canvas" width="256" height="256"> </canvas> +<div id="description"></div> +<div id="console"></div> +<script id="vshader" type="x-shader/x-vertex"> +attribute vec3 aPosition; + +void main() { + gl_Position = vec4(aPosition, 1); +} +</script> +<script id="fshader" type="x-shader/x-fragment"> +precision highp float; + +float fun(float arg) { + // These values are still easily within the highp range. + // The minimum range in terms of 10's exponent is around -19 to 19, and IEEE-754 single precision range is higher than that. + return 1.0e12 * pow(arg, 2.0); +} + +void main() { + // Note that the bug did not reproduce if an uniform was passed to the function instead of a constant, + // or if the expression was moved outside the user-defined function. + const float a = 1.0e-6; + float b = fun(a); + if (abs(b - 1.0) < 0.01) { + gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); // green + } else { + gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); // red + } +} +</script> +<script type="application/javascript"> +"use strict"; +description(); +debug(""); +var wtu = WebGLTestUtils; +function test() { + var gl = wtu.create3DContext("canvas"); + if (!gl) { + testFailed("context does not exist"); + return; + } + if (gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT).precision == 0) { + testPassed("highp precision not supported"); + } else { + wtu.setupUnitQuad(gl); + var program = wtu.setupProgram(gl, ["vshader", "fshader"], ["aPosition"], undefined, true); + wtu.drawUnitQuad(gl); + wtu.checkCanvasRect(gl, 0, 0, 256, 256, [0, 255, 0, 255]); + } +}; + +test(); +finishTest(); +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/pow-with-constant-exponent-should-not-crash.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/pow-with-constant-exponent-should-not-crash.html new file mode 100644 index 0000000000..8e95842b12 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/pow-with-constant-exponent-should-not-crash.html @@ -0,0 +1,65 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Bug - pow() with constant vector exponent should not crash</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script src="../../../js/glsl-conformance-test.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script id="fshaderTest" type="x-shader/x-fragment"> +precision mediump float; +void main() +{ + // pow() with a constant vector exponent may cause a crash on NVIDIA 331 series OpenGL drivers + vec2 v = pow(gl_FragCoord.xy, vec2(2.0)); + float y = pow(v, vec2(0.45, 0.5)).y; + gl_FragColor = vec4(0.0, 1.0 + y - gl_FragCoord.y, 0.0, 1.0); +} +</script> +<script id="fshaderNestedTest" type="x-shader/x-fragment"> +precision mediump float; +void main() +{ + // pow() with a constant vector exponent may cause a crash on NVIDIA 331 series OpenGL drivers + // workarounds for this should work even if problematic pow() statements are nested within + // each other. + float y = pow(pow(gl_FragCoord.xy, vec2(2.0)), vec2(0.45, 0.5)).y; + gl_FragColor = vec4(0.0, 1.0 + y - gl_FragCoord.y, 0.0, 1.0); +} +</script> +<script> +"use strict"; + +// This test has quite a lot of tolerance since pow() doesn't have explicit precision requirements +// in ESSL1, and in ESSL3 the limits are very loose. +GLSLConformanceTester.runRenderTests([ + { + fShaderId: "fshaderTest", + fShaderSuccess: true, + linkSuccess: true, + renderTolerance: 20, + passMsg: "shader with pow() with a constant vector exponent should not crash", + }, + { + fShaderId: "fshaderNestedTest", + fShaderSuccess: true, + linkSuccess: true, + renderTolerance: 20, + passMsg: "shader with nested pow() calls with constant vector exponents should not crash", + } +]); +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/qualcomm-crash.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/qualcomm-crash.html new file mode 100644 index 0000000000..f1ef1e47ab --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/qualcomm-crash.html @@ -0,0 +1,136 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Qualcomm program link crash Tests</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script id='vshader1' type='x-shader/x-vertex'> +precision highp float; +void main() { +gl_Position = vec4( 1.0, 1.0, 1.0, 1.0 ); +} +</script> +<script id='fshader1' type='x-shader/x-fragment'> +precision highp float; +uniform int renderType; +uniform sampler2D texMap; +void main() { + vec2 uv = vec2(0.0, 0.0); + if( renderType == 0 ) { + gl_FragColor = texture2D( texMap, uv ); + } else { + vec4 texture = texture2D( texMap, uv ); + gl_FragColor = texture; + } +} +</script> + +<script id='vshader2' type='x-shader/x-vertex'> +attribute vec3 vertex_position; +uniform mat4 matrix_model; +uniform mat4 matrix_viewProjection; + +attribute vec4 vertex_boneWeights; +attribute vec4 vertex_boneIndices; + +uniform sampler2D texture_poseMap; +uniform vec2 texture_poseMapSize; + +mat4 getBoneMatrix(const in float i) +{ + float j = i * 4.0; + float x = mod(j, float(texture_poseMapSize.x)); + float y = floor(j / float(texture_poseMapSize.x)); + + float dx = 1.0 / float(texture_poseMapSize.x); + float dy = 1.0 / float(texture_poseMapSize.y); + + y = dy * (y + 0.5); + + vec4 v1 = texture2D(texture_poseMap, vec2(dx * (x + 0.5), y)); + vec4 v2 = texture2D(texture_poseMap, vec2(dx * (x + 1.5), y)); + vec4 v3 = texture2D(texture_poseMap, vec2(dx * (x + 2.5), y)); + vec4 v4 = texture2D(texture_poseMap, vec2(dx * (x + 3.5), y)); + + mat4 bone = mat4(v1, v2, v3, v4); + + return bone; +} + +void main(void) +{ + mat4 modelMatrix = vertex_boneWeights.x * getBoneMatrix(vertex_boneIndices.x) + + vertex_boneWeights.y * getBoneMatrix(vertex_boneIndices.y) + + vertex_boneWeights.z * getBoneMatrix(vertex_boneIndices.z) + + vertex_boneWeights.w * getBoneMatrix(vertex_boneIndices.w); + + vec4 positionW = modelMatrix * vec4(vertex_position, 1.0); + gl_Position = matrix_viewProjection * positionW; + +} +</script> +<script id='fshader2' type='x-shader/x-fragment'> +precision highp float; +void main() { + gl_FragColor = vec4( 1.0, 1.0, 1.0, 1.0 ); +} +</script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +description("This test checks a known bug in some Qualcomm drivers which causes crashes when linking certain shaders. <a href='https://code.google.com/p/chromium/issues/detail?id=498947'>crbug.com/498947</a>"); + +debug(""); + +var wtu = WebGLTestUtils; +var gl = wtu.create3DContext(); + +gl.canvas.addEventListener("webglcontextlost", function(e) { + testFailed("WebGL context lost"); +}); + +if (!gl) { + testFailed("WebGL context does not exist"); +} else { + testPassed("WebGL context exists"); + debug(""); + + if (gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT).precision == 0) { + testPassed("highp precision not supported"); + } else { + var program1 = wtu.setupProgram(gl, ['vshader1', 'fshader1']); + if (!gl.getProgramParameter(program1, gl.LINK_STATUS)) { + testFailed("Program failed to link"); + } + wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors"); + + debug(""); + + var program2 = wtu.setupProgram(gl, ['vshader2', 'fshader2']); + if (!gl.getProgramParameter(program2, gl.LINK_STATUS)) { + testFailed("Program failed to link"); + } + wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors"); + } +} + +// Cycle through a rAF once to give any webglcontextlost events a chance to propagate +window.requestAnimationFrame(function() { finishTest(); }); + +debug(""); +var successfullyParsed = true; +</script> + +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/qualcomm-loop-with-continue-crash.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/qualcomm-loop-with-continue-crash.html new file mode 100644 index 0000000000..ff94c52268 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/qualcomm-loop-with-continue-crash.html @@ -0,0 +1,71 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Qualcomm loop with continue crash test</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script id='vshader1' type='x-shader/x-vertex'> +void main () +{ +} +</script> +<script id='fshader1' type='x-shader/x-fragment'> +void main () +{ + int count1 = 0, count2 = 0; + for(int i=0;i<4;i++) + { + if(count1 == 2) + continue; + } +} +</script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +description("This test exercises a crash on Adreno 300 series GPUs when compiling certain loop constructs. <a href='https://code.google.com/p/chromium/issues/detail?id=527761'>crbug.com/527761</a>"); + +debug(""); + +var wtu = WebGLTestUtils; +var gl = wtu.create3DContext(); + +gl.canvas.addEventListener("webglcontextlost", function(e) { + testFailed("WebGL context lost"); +}); + +if (!gl) { + testFailed("WebGL context does not exist"); +} else { + testPassed("WebGL context exists"); + debug(""); + + var program1 = wtu.setupProgram(gl, ['vshader1', 'fshader1']); + if (!gl.getProgramParameter(program1, gl.LINK_STATUS)) { + testFailed("Program failed to link"); + } + wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors"); + + debug(""); +} + +// Cycle through a rAF once to give any webglcontextlost events a chance to propagate +window.requestAnimationFrame(function() { finishTest(); }); + +debug(""); +var successfullyParsed = true; +</script> + +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/sampler-array-struct-function-arg.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/sampler-array-struct-function-arg.html new file mode 100644 index 0000000000..b39179a186 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/sampler-array-struct-function-arg.html @@ -0,0 +1,72 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL struct containing an array of samplers passed into a user-defined function</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script src="../../../js/glsl-conformance-test.js"></script> +</head> +<body> + +<canvas id="output" style="border: none;" width="64" height="64"></canvas> +<div id="description"></div> +<div id="console"></div> +<script id="fshaderSampler" type="x-shader/x-fragment"> +precision mediump float; + +struct S { + sampler2D sam[2]; +}; + +uniform S uni; + +vec4 useSampler(S arg) +{ + return texture2D(arg.sam[0], vec2(0.0, 0.0)); +} + +void main() { + gl_FragColor = vec4(useSampler(uni)); +} +</script> +<script type="application/javascript"> +"use strict"; +description(); + +var wtu = WebGLTestUtils; +var canvas = document.getElementById("output"); +var gl = wtu.create3DContext(canvas); + +if (!gl) { + testFailed("Could not create a GL context."); +} else { + debug("Drawing with a shader that uses a sampler array in a struct passed into a function."); + var program = wtu.setupProgram( + gl, [wtu.simpleVertexShader, 'fshaderSampler'], ['a_position'], [0], true); + wtu.setupUnitQuad(gl); + + var tex = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, tex); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + wtu.fillTexture(gl, tex, 1, 1, [0, 255, 0, 255]); + + wtu.clearAndDrawUnitQuad(gl); + wtu.checkCanvas(gl, [0, 255, 0, 255], "should be green"); +} + +var successfullyParsed = true; +</script> +<script src="../../../js/js-test-post.js"></script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/sampler-array-using-loop-index.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/sampler-array-using-loop-index.html new file mode 100644 index 0000000000..c5707a1f89 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/sampler-array-using-loop-index.html @@ -0,0 +1,81 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Sampler arrays using loop index should compile fine.</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 vec4 vPosition; +void main() +{ + gl_Position = vPosition; +} +</script> + +<script id="fshader" type="x-shader/x-fragment"> +precision mediump float; +uniform sampler2D uni[2]; + +float zero(int x) +{ + return float(x) - float(x); +} + +void main() +{ + vec4 c = vec4(0,0,0,0); + for (int ii = 1; ii < 3; ++ii) { + if (c.x > 255.0) { + c.x = 255.0 + zero(ii); + break; + } + c += texture2D(uni[ii - 1], vec2(0.5, 0.5)); + } + gl_FragColor = c; +} +</script> +<script> +"use strict"; +description(document.title); +var wtu = WebGLTestUtils; +var gl = wtu.create3DContext("example"); +var program = wtu.setupTexturedQuad(gl); + +//------------------------------------------------------------------------------ +var program = wtu.setupProgram( + gl, ['vshader', 'fshader'], ['vPosition'], undefined, true); + +for (var ii = 0; ii < 2; ++ii) { + var loc = gl.getUniformLocation(program, "uni[" + ii + "]"); + gl.activeTexture(gl.TEXTURE0 + ii); + var tex = gl.createTexture(); + wtu.fillTexture(gl, tex, 1, 1, [32, 16, 8, ii * 9], 0); + gl.uniform1i(loc, ii); +} + +wtu.clearAndDrawUnitQuad(gl); +wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup."); +wtu.checkCanvas(gl, [64, 32, 16, 9], + "Should render correctly", 1); + +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/bugs/sampler-struct-function-arg.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/sampler-struct-function-arg.html new file mode 100644 index 0000000000..f2bc755444 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/sampler-struct-function-arg.html @@ -0,0 +1,113 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Passing a struct containing a sampler to a function.</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +</head> + +<body> +<canvas id="output" style="border: none;" width="64" height="64"></canvas> +<div id="description"></div> +<div id="console"></div> + +<script id="shader-fs" type="x-shader/x-fragment"> + precision mediump float; + + struct SomeStruct{ + sampler2D source; + }; + + vec4 fun(SomeStruct s){ + return texture2D(s.source, vec2(0.5)); + } + + uniform SomeStruct green; + void main(){ + gl_FragColor = fun(green); + } +</script> + +<script id="shader-fs-array" type="x-shader/x-fragment"> + precision mediump float; + + struct SomeStruct{ + sampler2D source; + }; + + vec4 fun(SomeStruct s[2]){ + return texture2D(s[0].source, vec2(0.5)); + } + + uniform SomeStruct green[2]; + void main(){ + gl_FragColor = fun(green); + } +</script> + +<script> +"use strict"; + +description(); +debug("If the test passes correctly the viewport will be green."); + +var wtu = WebGLTestUtils; +var canvas = document.getElementById("output"); +var gl = wtu.create3DContext(canvas); + +var textureGreen; + +var createGreenTexture = function() { + var texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + wtu.fillTexture(gl, texture, 1, 1, [0, 255, 0, 255]); + gl.bindTexture(gl.TEXTURE_2D, null); + return texture; +}; + +var test = function(fragShaderId, texUniformName) { + var program = wtu.setupProgram(gl, [wtu.simpleVertexShader, fragShaderId], ["a_position"], [0], true); + + if (!program) { + testFailed("Shader compilation/link failed"); + } else { + // Bind texture + var uniformMap = wtu.getUniformMap(gl, program); + gl.activeTexture(gl.TEXTURE0); + gl.bindTexture(gl.TEXTURE_2D, textureGreen); + gl.uniform1i(uniformMap[texUniformName].location, 0); + + // Draw + wtu.clearAndDrawUnitQuad(gl); + + // Verify output + wtu.checkCanvasRect(gl, 0, 128, 256, 128, [0, 255,0, 255], "should be green", 1); + } +}; + +if (!gl) { + testFailed("context does not exist"); +} else { + wtu.setupUnitQuad(gl, 0, 1); + textureGreen = createGreenTexture(); + test("shader-fs", "green.source"); + test("shader-fs-array", "green[0].source"); +} +var successfullyParsed = true; +</script> +<script src="../../../js/js-test-post.js"></script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/sequence-operator-evaluation-order.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/sequence-operator-evaluation-order.html new file mode 100644 index 0000000000..7e9af6f1aa --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/sequence-operator-evaluation-order.html @@ -0,0 +1,116 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL short-circuiting operators should be evaluated after previous operands in a sequence</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script src="../../../js/glsl-conformance-test.js"></script> +</head> +<body> +<canvas id="canvas" width="64" height="64"> </canvas> +<div id="description"></div> +<div id="console"></div> +<script id="fshaderSequenceSideEffectsAffectTernary" type="x-shader/x-fragment"> +precision mediump float; + +bool correct = true; + +uniform float u_zero; + +float wrong() { + correct = false; + return 0.0; +} + +void main() { + // ESSL 1.00 section 5.9, about sequence operator: + // "All expressions are evaluated, in order, from left to right" + // Also use a ternary operator where the third operand has side effects to make sure + // only the second operand is evaluated. + float a = u_zero - 0.5; // Result should be -0.5. + float green = (a++, a > 0.0 ? 1.0 : wrong()); + gl_FragColor = vec4(0.0, correct ? green : 0.0, 0.0, 1.0); +} +</script> +<script id="fshaderSequenceSideEffectsAffectAnd" type="x-shader/x-fragment"> +precision mediump float; + +uniform bool u_false; + +bool sideEffectA = false; +bool funcA() { + sideEffectA = true; + return true; +} + +bool sideEffectB = false; +bool funcB() { + sideEffectB = true; + return true; +} + +void main() { + bool b = (funcA(), u_false == sideEffectA && funcB()); + gl_FragColor = (!b && sideEffectA && !sideEffectB) ? vec4(0, 1, 0, 1) : vec4(1, 0, 0, 1); +} +</script> +<script id="fshaderSequenceSideEffectsAffectOr" type="x-shader/x-fragment"> +precision mediump float; + +uniform bool u_false; + +bool sideEffectA = false; +bool funcA() { + sideEffectA = true; + return false; +} + +bool sideEffectB = false; +bool funcB() { + sideEffectB = true; + return false; +} + +void main() { + bool b = (funcA(), (u_false == !sideEffectA) || funcB()); + gl_FragColor = (b && sideEffectA && !sideEffectB) ? vec4(0, 1, 0, 1) : vec4(1, 0, 0, 1); +} +</script> +<script type="application/javascript"> +"use strict"; +description(); +debug(""); +debug("This test is targeted to stress syntax tree transformations that might need to be done in shader translation to unfold operators."); + +GLSLConformanceTester.runRenderTests([ +{ + fShaderId: 'fshaderSequenceSideEffectsAffectTernary', + fShaderSuccess: true, + linkSuccess: true, + passMsg: 'Expression where first operand of a sequence operator has side effects which affect the second operand that is a ternary operator' +}, +{ + fShaderId: 'fshaderSequenceSideEffectsAffectAnd', + fShaderSuccess: true, + linkSuccess: true, + passMsg: 'Expression where first operand of a sequence operator has side effects which affect the second operand that is an and operator' +}, +{ + fShaderId: 'fshaderSequenceSideEffectsAffectOr', + fShaderSuccess: true, + linkSuccess: true, + passMsg: 'Expression where first operand of a sequence operator has side effects which affect the second operand that is an or operator' +} +]); +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/sketchfab-lighting-shader-crash.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/sketchfab-lighting-shader-crash.html new file mode 100644 index 0000000000..73416d17de --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/sketchfab-lighting-shader-crash.html @@ -0,0 +1,84 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Sketchfab Lighting Shader Crash</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script id='vshader1' type='x-shader/x-vertex'> +attribute float testValue; // Can be uniform as well. +varying mediump float FragVarying; // Necessary to reproduce. + +void main() { + // Crashes with mat4 as well. Does not crash with vectors. + mat2 projectionMatrix = mat2(0.0, 0.0, 0.0, 0.0); + if (testValue == 1.0) + { + // Using the matrix variable appears necessary. + projectionMatrix[0][0] = 1.0; + } + + FragVarying = 0.0; + // Referencing the matrix is necessary though clearly the compiler + // doesn't realize the assignment is useless. + gl_Position = vec4(projectionMatrix[1][0], 0.0, 0.0, 1.0); +} +</script> +<script id='fshader1' type='x-shader/x-fragment'> +precision mediump float; +varying float FragVarying; + +void main() { + gl_FragColor = vec4(FragVarying, 0.0, 0.0, 1.0); +} +</script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +description("This test demonstrates a crash on the Nexus 5 (Adreno 330) when compiling Sketchfab's lighting shader. <a href='https://code.google.com/p/chromium/issues/detail?id=551937'>crbug.com/551937</a>"); + +debug(""); + +var wtu = WebGLTestUtils; +var gl = wtu.create3DContext(); + +gl.canvas.addEventListener("webglcontextlost", function(e) { + testFailed("WebGL context lost"); +}); + +if (!gl) { + testFailed("WebGL context does not exist"); +} else { + testPassed("WebGL context exists"); + debug(""); + + var program1 = wtu.setupProgram(gl, ['vshader1', 'fshader1']); + if (!gl.getProgramParameter(program1, gl.LINK_STATUS)) { + testFailed("Program failed to link"); + } else { + testPassed("Program linked successfully"); + } + wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors"); + + debug(""); +} + +// Cycle through rAF a few times to give any webglcontextlost events a chance to propagate. +wtu.waitForComposite(function() { finishTest(); }); + +debug(""); +var successfullyParsed = true; +</script> + +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/struct-constructor-highp-bug.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/struct-constructor-highp-bug.html new file mode 100644 index 0000000000..afb72e1916 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/struct-constructor-highp-bug.html @@ -0,0 +1,50 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Struct constructor highp bug.</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script src="../../../js/glsl-conformance-test.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script id="fshader" type="x-shader/x-fragment"> +#ifdef GL_FRAGMENT_PRECISION_HIGH +precision highp float; +#else +precision mediump float; +#endif + +struct Test { + vec3 color; +}; + +void main() { + vec3 color = vec3( 0.0, 1.0, 0.0 ); + Test test = Test( color ); + gl_FragColor = vec4( test.color, 1.0 ); +} +</script> + +<script type="application/javascript"> +"use strict"; +description("Struct constructors should evaluate properly."); +debug("Regression test for Three.js bug worked around in <a href='https://github.com/mrdoob/three.js/pull/7556'>https://github.com/mrdoob/three.js/pull/7556</a> that reproduced on Nexus 4 and 5 (Adreno 320 and 330)."); +debug("When high precision is used in the fragment shader on these devices, bugs occur in evaluation of structs' constructors. Thanks to Mr. doob for the reduced test case."); + +GLSLConformanceTester.runRenderTests([ +{ + fShaderId: 'fshader', + fShaderSuccess: true, + linkSuccess: true, + passMsg: "Struct contstructor evaluation" +} +]); + +</script> + +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/struct-with-single-member-constructor.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/struct-with-single-member-constructor.html new file mode 100644 index 0000000000..8d1008326f --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/struct-with-single-member-constructor.html @@ -0,0 +1,52 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL struct with a single member constructor test</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script src="../../../js/glsl-conformance-test.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script id="fshader" type="x-shader/x-fragment"> +#version 100 + +precision mediump float; + +struct S { + mat2 rotation; +}; +void main(void) +{ + float angle = 1.0; + S(mat2(1.0, angle, 1.0, 1.0)); +} +</script> +<script> +"use strict"; +description(); +debug("This is a regression test for <a href='https://bugs.chromium.org/p/swiftshader/issues/detail?id=56'>Swiftshader bug 56</a>."); +debug(""); + +GLSLConformanceTester.runTests([ +{ + fShaderId: 'fshader', + fShaderSuccess: true, + linkSuccess: true, + passMsg: "Construct a struct with a single matrix member" +} +]); + +</script> + +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/temp-expressions-should-not-crash.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/temp-expressions-should-not-crash.html new file mode 100644 index 0000000000..c28db1daad --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/temp-expressions-should-not-crash.html @@ -0,0 +1,100 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Driver Bug - temp experssions should not crash</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script src="../../../js/glsl-conformance-test.js"></script> +</head> +<body> +<canvas id="example" width="40" height="40"> </canvas> +<div id="description"></div> +<div id="console"></div> +<script id="vshader" type="x-shader/x-vertex"> +void main(){ + gl_Position = vec4(0, 0, 0, 1); +} +</script> +<script id="fshaderUniformTest" type="x-shader/x-fragment"> +precision mediump float; +uniform vec4 u_uniform; +void main() +{ + vec4 temp = vec4(0, 0, 0, 0); +$(code) + gl_FragColor = temp; +} +</script> +<script> +"use strict"; +var wtu = WebGLTestUtils; +var gl = wtu.create3DContext(); + +var fUniformTestSource = wtu.getScript("fshaderUniformTest"); + +var tests = [ +]; +var counts = [ + { count:100, + mustPass: true, + }, + { count: 1000, + mustPass: false, + }, + { count: 10000, + mustPass: false, + }, +]; +var operators = ["+", "-", "/", "*"]; +counts.forEach(function(info) { + var generateCode = function(numVars) { + var codes = []; + var count = 0; + var step = 10; + for (var uu = 0; uu < numVars; uu += step) { + var subCodes = [""]; + for (var vv = 0; vv < step; ++vv) { + subCodes.push(operators[(count++) % operators.length]); + } + subCodes.push(""); + codes.push(" temp += " + subCodes.join("\n u_uniform ") + ";"); + } + return { + code: codes.join("\n"), + }; + }; + + var subs = generateCode(info.count); + tests.push({ + vShaderId: "vshader", + vShaderSuccess: true, + fShaderSource: wtu.replaceParams(fUniformTestSource, subs), + fShaderSuccess: true, + linkSuccess: true, + ignoreResults: !info.mustPass, + passMsg: "shader with uniform with " + info.count + " operators in temp expressions in multiple lines", + }); + subs.code = subs.code.replace(/\n +/g, " ") + tests.push({ + vShaderId: "vshader", + vShaderSuccess: true, + fShaderSource: wtu.replaceParams(fUniformTestSource, subs), + fShaderSuccess: true, + linkSuccess: true, + ignoreResults: !info.mustPass, + passMsg: "shader with uniform with " + info.count + " operators in temp expressions in one line", + }); +}); +GLSLConformanceTester.runTests(tests); +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/unary-minus-operator-float-bug.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/unary-minus-operator-float-bug.html new file mode 100644 index 0000000000..85f7231444 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/unary-minus-operator-float-bug.html @@ -0,0 +1,49 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL unary minus operator with float bug Tests</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script src="../../../js/glsl-conformance-test.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script id="fshader" type="x-shader/x-fragment"> +precision mediump float; +void main () { + float f = -1.0; + // atan(tan(0.5), -f) is in range [1.5707, 1.5708) on Mac OSX 10.11 with Intel GPU. + // But it should be 0.5. + gl_FragColor = vec4(atan(tan(0.5), -f), 0.0, 0.0, 1.0); +} +</script> +<script> +"use strict"; +description("Test for unary minus operator with float bug on MacOSX 10.11 with Intel GPU"); +debug("This is a regression test for <a href='https://bugs.chromium.org/p/chromium/issues/detail?id=308366'>Chromium Issue 308366</a>"); +debug(""); + +GLSLConformanceTester.runRenderTests([ +{ + fShaderId: 'fshader', + fShaderSuccess: true, + linkSuccess: true, + passMsg: "Evaluate unary minus operator and atan(x, y)", + renderTolerance: 3, + renderColor: [127, 0, 0, 255] +} +]); + +</script> + +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/undefined-index-should-not-crash.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/undefined-index-should-not-crash.html new file mode 100644 index 0000000000..0c97c987f8 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/undefined-index-should-not-crash.html @@ -0,0 +1,64 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Bug - indexing with 'int()' should not crash</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script src="../../../js/glsl-conformance-test.js"></script> +</head> +<body> +<canvas id="example" width="40" height="40"> </canvas> +<div id="description"></div> +<div id="console"></div> +<script id="vshader" type="x-shader/x-vertex"> +void main(){ + gl_Position = vec4(0.0, 0.0, 0.0, 1.0); +} +</script> +<script id="fshaderTest" type="x-shader/x-fragment"> +precision mediump float; +uniform vec4 uniformVec; +uniform mat4 uniformMat; +uniform float uniformArray[4]; +void main() +{ + vec4 tempVec = vec4(0.0); + mat4 tempMat = mat4(0.0); + float tempArray[4]; + gl_FragColor = vec4($(indexed)[int()]); +} +</script> +<script> +"use strict"; +var wtu = WebGLTestUtils; + +var fTestSource = wtu.getScript("fshaderTest"); + +var tests = []; + +var indexedValues = ['tempVec', 'tempMat[0]', 'tempArray', 'uniformVec', 'uniformMat[0]', 'uniformArray']; + +for (var i = 0; i < indexedValues.length; ++i) { + var subs = {indexed: indexedValues[i]}; + tests.push({ + vShaderId: "vshader", + vShaderSuccess: true, + fShaderSource: wtu.replaceParams(fTestSource, subs), + fShaderSuccess: false, + linkSuccess: false, + passMsg: "shader with invalid index expression int() should not compile", + }); +} +GLSLConformanceTester.runTests(tests); +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/uniforms-should-not-lose-values.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/uniforms-should-not-lose-values.html new file mode 100644 index 0000000000..fc99f0f87f --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/uniforms-should-not-lose-values.html @@ -0,0 +1,81 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Driver Bug - Uniforms should no lose values</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +</head> +<body> +<canvas id="canvas" width="512" height="256"> </canvas> +<div id="description"></div> +<div id="console"></div> +<script id="vshader" type="x-shader/x-vertex"> +uniform float k,u; +uniform mat4 l; +attribute vec3 a; +void main(){ + gl_Position=l*vec4(a,1.+u+k); +} +</script> +<script id="fshader" type="x-shader/x-fragment"> +precision mediump float; +uniform float w,x,y,z; +void main() { + gl_FragColor=vec4(1.-y,y,w+x+z,1); +} +</script> +<script> +"use strict"; +// Certain drivers fail this test. Specifically Mac NVidia GT 330 on OSX 10.8.2 +description(); +debug(""); +var wtu = WebGLTestUtils; +function test() { + var gl = wtu.create3DContext("canvas"); + if (!gl) { + testFailed("context does not exist"); + return; + } + + wtu.setupUnitQuad(gl); + var program = wtu.setupProgram(gl, ["vshader", "fshader"], ["a"], undefined, true); + + var setUniformf = function(name, val) { + var loc = gl.getUniformLocation(program, name); + var func = 'uniform' + val.length + 'fv'; + gl[func](loc, val); + }; + + var setUniformMat = function(name, val) { + var loc = gl.getUniformLocation(program, name); + var func = 'uniformMatrix' + Math.sqrt(val.length) + 'fv'; + gl[func](loc, false, val); + }; + + setUniformMat('l', [1, 0 ,0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); + gl.viewport(0, 0, 256, 256); + setUniformf('y', [0]); + wtu.drawUnitQuad(gl); + gl.viewport(256, 0, 256, 256); + setUniformf('y', [1]); + wtu.drawUnitQuad(gl); + wtu.checkCanvasRect(gl, 0, 0, 256, 256, [255, 0, 0, 255]); + wtu.checkCanvasRect(gl, 256, 0, 256, 256, [0, 255, 0, 255]); + + wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors"); +} +test(); +var successfullyParsed = true; +</script> +<script src="../../../js/js-test-post.js"></script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/varying-arrays-should-not-be-reversed.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/varying-arrays-should-not-be-reversed.html new file mode 100644 index 0000000000..14cdd9fe09 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/varying-arrays-should-not-be-reversed.html @@ -0,0 +1,82 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Varying arrays should not be reversed</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +</head> +<body> +<canvas id="canvas" width="512" height="256"> </canvas> +<div id="description"></div> +<div id="console"></div> +<script id="vshader" type="x-shader/x-vertex"> +varying float colors[3]; +uniform vec3 testData; +attribute vec3 position; +void main(){ + gl_Position = vec4(position, 1.0); + colors[0] = testData.x; + colors[1] = testData.y; + colors[2] = testData.z; +} +</script> +<script id="fshader" type="x-shader/x-fragment"> +precision mediump float; +varying float colors[3]; +void main() { + gl_FragColor = vec4(colors[0], colors[1], colors[2], 1.0); +} +</script> +<script> +"use strict"; +description("Varying arrays should not be reversed."); +debug("This issue has been seen in Chrome on Nexus 7 2013 (Adreno 320) and Moto G3 (Adreno 306)."); +debug(""); +debug("If things are working correctly, the vertical stripes should be: red, green, blue, light blue, orange"); +debug(""); +debug("If they are not, the red and blue channels will appear to be swapped and you will see: blue, green, red, orange, light blue"); +var wtu = WebGLTestUtils; +function test() { + var gl = wtu.create3DContext("canvas"); + if (!gl) { + testFailed("context does not exist"); + return; + } + + wtu.setupUnitQuad(gl); + var program = wtu.setupProgram(gl, ["vshader", "fshader"], ["position"], undefined, true); + var loc = gl.getUniformLocation(program, 'testData'); + + var triples = [ + [255, 0, 0], + [0, 255, 0], + [0, 0, 255], + [0, 128, 255], + [255, 128, 0] + ]; + + for (var i = 0; i < triples.length; i++) { + var triple = triples[i]; + var x = i * 64; + gl.viewport(x, 0, 64, 256); + gl.uniform3f(loc, triple[0] / 255, triple[1] / 255, triple[2] / 255); + wtu.drawUnitQuad(gl); + wtu.checkCanvasRect(gl, x, 0, 64, 256, [triple[0], triple[1], triple[2], 255]); + } + + wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors"); +} +test(); +var successfullyParsed = true; +</script> +<script src="../../../js/js-test-post.js"></script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/vector-matrix-constructor-scalarization.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/vector-matrix-constructor-scalarization.html new file mode 100644 index 0000000000..a6ad3483c3 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/vector-matrix-constructor-scalarization.html @@ -0,0 +1,181 @@ +<!-- +Copyright (c) 2021 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title></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> + +<!-- + +Original Shadertoy: +https://www.shadertoy.com/view/ttGyzh + + float a = 0.; // bug + #define A 0. // ok +//#define A min(0.,iTime) // bug + + + #define r(a) mat2( cos( a + vec4(0,-1.5708,1.5708,0) ) ) // bug +//#define r(a) mat2( cos(a), -sin(a), sin(a), cos(a) ) // no bug +//#define r(a) cos(a),sin(a)) // no bug ( vec instead of mat ) +//#define r(a) cos(a+vec2(0,-1.5708)) // no bug ( vec instead of mat ) + +vec2 c; +#define f(U,a) ( c = (U) * r(a) , sin(10.*c.x) ) + +void mainImage( out vec4 O, vec2 U ) +{ + U /= iResolution.xy; + + O = U.y > .5 + ? vec4( f(U,a) , f(U*4.,a) , 0,0) // top + : vec4( f(U,A) , f(U*4.,A) , 0,0); // bottom +} +--> + +<script id="vshader" type="x-shader/x-vertex"> +attribute vec2 aPosition; +attribute vec2 aTexCoord; + +varying vec2 vTexCoord; + +void main(void) { + gl_Position = vec4(aPosition, 0.0, 1.0); + vTexCoord = aTexCoord; +} +</script> +<script id="fshader" type="x-shader/x-fragment"> +precision mediump float; + +varying vec2 vTexCoord; + +float a = 0.; +#define A 0. + +#define r(a) mat2( cos( a + vec4(0,-1.5708,1.5708,0) ) ) +vec2 c; +#define f(U,a) ( c = (U) * r(a) , sin(10.*c.x) ) + +void main() { + vec2 U = vTexCoord; + + gl_FragColor = U.y > .5 + ? vec4( f(U,a) , f(U*4.,a) , 0,1.0) // top + : vec4( f(U,A) , f(U*4.,A) , 0,1.0); // bottom +} +</script> + +<script id="compileVShader" type="x-shader/x-vertex"> +varying vec2 v_texcoord; + +void main() { + v_texcoord = vec2(0.0, 0.0); + gl_Position = vec4(1.0, 0.0, 0.0, 1.0); +} +</script> +<script id="compileFShader" type="x-shader/x-fragment"> +// From http://crbug.com/398694 +precision mediump float; +uniform sampler2D s_texture; +uniform vec4 color_weights; +varying vec2 v_texcoord; +void main() { + gl_FragColor = color_weights * mat4( + vec4(texture2D(s_texture, v_texcoord).rgb, 1.0), + vec4(texture2D(s_texture, v_texcoord).rgb, 1.0), + vec4(texture2D(s_texture, v_texcoord).rgb, 1.0), + vec4(texture2D(s_texture, v_texcoord).rgb, 1.0)); +} +</script> + +</head> +<body> +<canvas id="example"></canvas> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +debug(""); + +description("Vector and matrix constructor scalarization workaround (SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS) caused bugs"); +debug('Regression test for <a href="http://crbug.com/1165751">crbug.com/1165751</a>'); + +// Note: Firefox reports that without this workaround, there are +// failures on at least Windows / Intel GPU / OpenGL on: +// conformance/glsl/constructors/glsl-construct-mat2.html +// https://searchfox.org/mozilla-central/source/dom/canvas/WebGLShaderValidator.cpp#63 + +// Chromium reported that +// conformance/glsl/misc/shader-struct-scope.html failed on macOS and +// on Linux AMD without this workaround enabled: +// http://crbug.com/angleproject/701 + +const wtu = WebGLTestUtils; +const canvas = document.getElementById("example"); +const sz = canvas.width = canvas.height = 256; +const gl = wtu.create3DContext(canvas, undefined); + +if (!gl) { + testFailed("WebGL context creation failed"); + finishTest(); +} else { + testPassed("WebGL context creation succeeded"); + runDrawTest(); + runCompileTest(); + finishTest(); +} + +function runDrawTest() { + debug("Ensure that shader translation isn't broken by the vector and matrix constructor scalarization workaround"); + let positionLocation = 0; + let texCoordLocation = 1; + wtu.setupUnitQuad(gl, positionLocation, texCoordLocation); + let program = wtu.setupProgram(gl, ["vshader", "fshader"], + ["aPosition", "aTexCoord"], + [positionLocation, texCoordLocation], true); + if (!program) { + testFailed("Error compiling shaders"); + return; + } + gl.useProgram(program); + // Buffers returned from setupQuad above, and ignored, are already bound. + wtu.drawUnitQuad(gl); + + // Top and bottom halves should be roughly equal. Go through one + // horizontal scanline in the middle. + const compareHeight = sz / 4; + let pixelValue = new Uint8Array(4); + let allEqual = true; + // Empirically found that tolerance between the top and bottom + // needs to be up to roughly 8 on some platforms. + const tolerance = 8; + let tempBuf = new Uint8Array(4); + // Step over some pixels to spew slightly fewer comparison messages. + for (let x = 0; x < sz; x += 4) { + gl.readPixels(x, compareHeight, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pixelValue); + wtu.checkCanvasRect(gl, x, sz - compareHeight, 1, 1, pixelValue, undefined, tolerance, tempBuf); + } +} + +function runCompileTest() { + debug("Running compilation test"); + let program = wtu.setupProgram(gl, ["compileVShader", "compileFShader"], [], [], true); + if (program) { + testPassed("Shader previously requiring SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS compiled successfully"); + } else { + testFailed("Shader previously requiring SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS failed to compile"); + } +} + +</script> + +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/vector-scalar-arithmetic-inside-loop-complex.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/vector-scalar-arithmetic-inside-loop-complex.html new file mode 100644 index 0000000000..3b1277c1be --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/vector-scalar-arithmetic-inside-loop-complex.html @@ -0,0 +1,80 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL vector/scalar arithmetic inside a for loop (complex cases)</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script src="../../../js/glsl-conformance-test.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script id="fShaderVectorCompoundMulAndAddInSeparateStatementsInsideForLoop" type="x-shader/x-fragment"> +precision mediump float; + +void main() { + gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); + for (int i = 0; i < 2; i++) + { + float x = gl_FragCoord.x; + float y = (x *= 2.0); + gl_FragColor = gl_FragColor + vec4(y, y, y, y); + } + if (gl_FragColor.g == gl_FragColor.r && + gl_FragColor.b == gl_FragColor.r && + gl_FragColor.a == gl_FragColor.r) + { + gl_FragColor = vec4(0, 1, 0, 1); + } +} +</script> +<script id="fShaderVectorCompoundMulAndAddInSeparateStatementsInsideForLoop2" type="x-shader/x-fragment"> +precision mediump float; + +void main() { + gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); + for (int i = 0; i < 2; i++) + { + float x = gl_FragCoord.x; + float y = (x *= 2.0); + gl_FragColor = gl_FragColor + vec4(x, y, x, y); + } + if (gl_FragColor.g == gl_FragColor.r && + gl_FragColor.b == gl_FragColor.r && + gl_FragColor.a == gl_FragColor.r) + { + gl_FragColor = vec4(0, 1, 0, 1); + } +} +</script> +<script type="text/javascript"> +"use strict"; +description(); + +// See http://crbug.com/772651 + +GLSLConformanceTester.runRenderTests([ +{ + fShaderId: 'fShaderVectorCompoundMulAndAddInSeparateStatementsInsideForLoop', + fShaderSuccess: true, + linkSuccess: true, + passMsg: "Adding a vector that's just 4 copies of a scalar to another vector inside for loop should work." +}, +{ + fShaderId: 'fShaderVectorCompoundMulAndAddInSeparateStatementsInsideForLoop2', + fShaderSuccess: true, + linkSuccess: true, + passMsg: "Adding a vector that's just 4 copies of a scalar stored in two different variables to another vector inside for loop should work." +} +]); +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/vector-scalar-arithmetic-inside-loop.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/vector-scalar-arithmetic-inside-loop.html new file mode 100644 index 0000000000..622ea38129 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/vector-scalar-arithmetic-inside-loop.html @@ -0,0 +1,99 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL vector/scalar arithmetic inside a for loop</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script src="../../../js/glsl-conformance-test.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script id="fShaderVectorMulAndAddInsideForLoop" type="x-shader/x-fragment"> +void main(){ + gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); + for (int i = 0; i < 2; i++) + { + gl_FragColor += (2.0 * gl_FragCoord.x); + } + if (gl_FragColor.g == gl_FragColor.r && + gl_FragColor.b == gl_FragColor.r && + gl_FragColor.a == gl_FragColor.r) + { + gl_FragColor = vec4(0, 1, 0, 1); + } +} +</script> +<script id="fShaderVectorCompoundMulAndAddInsideForLoop" type="x-shader/x-fragment"> +precision mediump float; + +void main() { + gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); + for (int i = 0; i < 2; i++) + { + float x = gl_FragCoord.x; + gl_FragColor = gl_FragColor + (x *= 2.0); + } + if (gl_FragColor.g == gl_FragColor.r && + gl_FragColor.b == gl_FragColor.r && + gl_FragColor.a == gl_FragColor.r) + { + gl_FragColor = vec4(0, 1, 0, 1); + } +} +</script> +<script id="fShaderVectorCompoundDivAndAddInsideForLoop" type="x-shader/x-fragment"> +precision mediump float; + +void main() { + gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); + for (int i = 0; i < 2; i++) + { + float x = gl_FragCoord.x; + gl_FragColor = gl_FragColor + (x /= 2.0); + } + if (gl_FragColor.g == gl_FragColor.r && + gl_FragColor.b == gl_FragColor.r && + gl_FragColor.a == gl_FragColor.r) + { + gl_FragColor = vec4(0, 1, 0, 1); + } +} +</script> +<script type="text/javascript"> +"use strict"; +description(); + +// See http://crbug.com/772651 + +GLSLConformanceTester.runRenderTests([ +{ + fShaderId: 'fShaderVectorMulAndAddInsideForLoop', + fShaderSuccess: true, + linkSuccess: true, + passMsg: "Adding a scalar to a vector inside for loop should work." +}, +{ + fShaderId: 'fShaderVectorCompoundMulAndAddInsideForLoop', + fShaderSuccess: true, + linkSuccess: true, + passMsg: "Adding a scalar (target of a compound assignment/multiplication operation) to a vector inside for loop should work." +}, +{ + fShaderId: 'fShaderVectorCompoundDivAndAddInsideForLoop', + fShaderSuccess: true, + linkSuccess: true, + passMsg: "Adding a scalar (target of a compound assignment/division operation) to a vector inside for loop should work." +} +]); +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/00_test_list.txt b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/00_test_list.txt new file mode 100644 index 0000000000..6758bea8e8 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/00_test_list.txt @@ -0,0 +1,14 @@ +glsl-construct-vec2.html +glsl-construct-vec3.html +glsl-construct-vec4.html +glsl-construct-ivec2.html +glsl-construct-ivec3.html +glsl-construct-ivec4.html +glsl-construct-bvec2.html +glsl-construct-bvec3.html +glsl-construct-bvec4.html +glsl-construct-mat2.html +glsl-construct-mat3.html +glsl-construct-mat4.html +--min-version 1.0.3 glsl-construct-vec-mat-corner-cases.html +--min-version 1.0.3 glsl-construct-vec-mat-index.html diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-bvec2.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-bvec2.html new file mode 100644 index 0000000000..b1e72160d1 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-bvec2.html @@ -0,0 +1,39 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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> +<script src="../../../js/glsl-constructor-tests-generator.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +var targetType = "bvec2"; +description("Test " + targetType + " constructor expressions."); + +var testSet = GLSLConstructorTestsGenerator.getDefaultTestSet(targetType); + +// Generate tests +var testCases = GLSLConstructorTestsGenerator.getConstructorTests(targetType, testSet); + +// Run the tests +GLSLConformanceTester.runTests(testCases); + +debug(""); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-bvec3.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-bvec3.html new file mode 100644 index 0000000000..57f51d3902 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-bvec3.html @@ -0,0 +1,39 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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> +<script src="../../../js/glsl-constructor-tests-generator.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +var targetType = "bvec3"; +description("Test " + targetType + " constructor expressions."); + +var testSet = GLSLConstructorTestsGenerator.getDefaultTestSet(targetType); + +// Generate tests +var testCases = GLSLConstructorTestsGenerator.getConstructorTests(targetType, testSet); + +// Run the tests +GLSLConformanceTester.runTests(testCases); + +debug(""); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-bvec4.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-bvec4.html new file mode 100644 index 0000000000..a873c016d1 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-bvec4.html @@ -0,0 +1,39 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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> +<script src="../../../js/glsl-constructor-tests-generator.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +var targetType = "bvec4"; +description("Test " + targetType + " constructor expressions."); + +var testSet = GLSLConstructorTestsGenerator.getDefaultTestSet(targetType); + +// Generate tests +var testCases = GLSLConstructorTestsGenerator.getConstructorTests(targetType, testSet); + +// Run the tests +GLSLConformanceTester.runTests(testCases); + +debug(""); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-ivec2.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-ivec2.html new file mode 100644 index 0000000000..5524fe3abc --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-ivec2.html @@ -0,0 +1,39 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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> +<script src="../../../js/glsl-constructor-tests-generator.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +var targetType = "ivec2"; +description("Test " + targetType + " constructor expressions."); + +var testSet = GLSLConstructorTestsGenerator.getDefaultTestSet(targetType); + +// Generate tests +var testCases = GLSLConstructorTestsGenerator.getConstructorTests(targetType, testSet); + +// Run the tests +GLSLConformanceTester.runTests(testCases); + +debug(""); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-ivec3.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-ivec3.html new file mode 100644 index 0000000000..594f6713f3 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-ivec3.html @@ -0,0 +1,39 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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> +<script src="../../../js/glsl-constructor-tests-generator.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +var targetType = "ivec3"; +description("Test " + targetType + " constructor expressions."); + +var testSet = GLSLConstructorTestsGenerator.getDefaultTestSet(targetType); + +// Generate tests +var testCases = GLSLConstructorTestsGenerator.getConstructorTests(targetType, testSet); + +// Run the tests +GLSLConformanceTester.runTests(testCases); + +debug(""); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-ivec4.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-ivec4.html new file mode 100644 index 0000000000..8bc59761e1 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-ivec4.html @@ -0,0 +1,39 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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> +<script src="../../../js/glsl-constructor-tests-generator.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +var targetType = "ivec4"; +description("Test " + targetType + " constructor expressions."); + +var testSet = GLSLConstructorTestsGenerator.getDefaultTestSet(targetType); + +// Generate tests +var testCases = GLSLConstructorTestsGenerator.getConstructorTests(targetType, testSet); + +// Run the tests +GLSLConformanceTester.runTests(testCases); + +debug(""); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-mat2.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-mat2.html new file mode 100644 index 0000000000..5a4afb817d --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-mat2.html @@ -0,0 +1,39 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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> +<script src="../../../js/glsl-constructor-tests-generator.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +var targetType = "mat2"; +description("Test " + targetType + " constructor expressions."); + +var testSet = GLSLConstructorTestsGenerator.getDefaultTestSet(targetType); + +// Generate tests +var testCases = GLSLConstructorTestsGenerator.getConstructorTests(targetType, testSet); + +// Run the tests +GLSLConformanceTester.runTests(testCases); + +debug(""); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-mat3.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-mat3.html new file mode 100644 index 0000000000..e4a2e9815d --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-mat3.html @@ -0,0 +1,39 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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> +<script src="../../../js/glsl-constructor-tests-generator.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +var targetType = "mat3"; +description("Test " + targetType + " constructor expressions."); + +var testSet = GLSLConstructorTestsGenerator.getDefaultTestSet(targetType); + +// Generate tests +var testCases = GLSLConstructorTestsGenerator.getConstructorTests(targetType, testSet); + +// Run the tests +GLSLConformanceTester.runTests(testCases); + +debug(""); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-mat4.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-mat4.html new file mode 100644 index 0000000000..81fd92b2ab --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-mat4.html @@ -0,0 +1,39 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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> +<script src="../../../js/glsl-constructor-tests-generator.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +var targetType = "mat4"; +description("Test " + targetType + " constructor expressions."); + +var testSet = GLSLConstructorTestsGenerator.getDefaultTestSet(targetType); + +// Generate tests +var testCases = GLSLConstructorTestsGenerator.getConstructorTests(targetType, testSet); + +// Run the tests +GLSLConformanceTester.runTests(testCases); + +debug(""); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-vec-mat-corner-cases.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-vec-mat-corner-cases.html new file mode 100644 index 0000000000..a2c8f306ae --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-vec-mat-corner-cases.html @@ -0,0 +1,195 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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="vsVec4Mat2Add" type="text/something-not-javascript"> +void main() +{ + mat2 m1 = mat2(1.0, 2.0, 3.0, 4.0); + mat2 m2 = mat2(0); + vec4 v = vec4(m1 + m2); + gl_Position = v; +} +</script> +<script id="fsVec4Mat3Add" type="text/something-not-javascript"> +precision mediump float; +void main() +{ + mat3 m1 = mat3(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0); + mat3 m2 = mat3(0); + vec4 v = vec4(m1 + m2); + gl_FragColor = v; +} +</script> + +<script id="vsMat2Vec4Sub" type="text/something-not-javascript"> +void main() +{ + vec4 v1 = vec4(1.0, 2.0, 3.0, 4.0); + vec4 v2 = vec4(0); + mat2 m = mat2(v1 - v2); + gl_Position = vec4(1.0, m); +} +</script> +<script id="fsMat3Vec4AddSub" type="text/something-not-javascript"> +precision mediump float; +void main() +{ + vec4 v1 = vec4(1.0, 2.0, 3.0, 4.0); + vec4 v2 = vec4(0); + mat3 m = mat3(v1 + v2, 5.0, v1 - v2); + gl_FragColor = vec4(m); +} +</script> + +<script id="vsVec4Mat2Func" type="text/something-not-javascript"> +mat2 f(mat2 a) +{ + return a; +} +void main() +{ + mat2 m = mat2(1.0, 2.0, 3.0, 4.0); + vec4 v = vec4(f(m)); + gl_Position = vec4(1.0, v); +} +</script> +<script id="fsVec4Mat3Func" type="text/something-not-javascript"> +precision mediump float; +mat3 f(mat3 a) +{ + return a; +} +void main() +{ + mat3 m = mat3(0); + vec4 v = vec4(f(m)); + gl_FragColor = v; +} +</script> + +<script id="vsMat2Vec4Func" type="text/something-not-javascript"> +vec4 f(vec4 a) +{ + return a; +} +void main() +{ + vec4 v = vec4(1.0, 2.0, 3.0, 4.0); + mat2 m = mat2(f(v)); + gl_Position = vec4(1.0, m); +} +</script> +<script id="fsMat3Vec4Func" type="text/something-not-javascript"> +precision mediump float; +vec4 f(vec4 a) +{ + return a; +} +void main() +{ + vec4 v1 = vec4(1.0, 2.0, 3.0, 4.0); + vec4 v2 = vec4(0); + mat3 m = mat3(f(v1), 5.0, f(v2)); + gl_FragColor = vec4(m); +} +</script> + +<script id="vsMat4VecMultiple" type="text/something-not-javascript"> +vec4 f(vec4 a) +{ + return a; +} +void main() +{ + vec2 v2 = vec2(1.0, 2.0); + vec3 v3 = vec3(1.0, 2.0, 3.0); + vec4 v4 = vec4(1.0, 2.0, 3.0, 4.0); + mat4 m = mat4(0.0, v2, 1.0, v3 + vec3(1), 2.0, vec4(0), f(v4)); + gl_Position = vec4(1.0, m); +} +</script> +<script id="fsMat4VecMultiple" type="text/something-not-javascript"> +precision mediump float; +vec4 f(vec4 a) +{ + return a; +} +void main() +{ + vec2 v2 = vec2(1.0, 2.0); + vec3 v3 = vec3(1.0, 2.0, 3.0); + vec4 v4 = vec4(1.0, 2.0, 3.0, 4.0); + mat4 m = mat4(0.0, v2, 1.0, v3 + vec3(1), 2.0, vec4(0), f(v4)); + gl_FragColor = vec4(m); +} +</script> + +<script> +"use strict"; +var wtu = WebGLTestUtils; +var tests = []; + +tests.push({ + vShaderSource: wtu.getScript("vsVec4Mat2Add"), + vShaderSuccess: true, + fShaderSource: wtu.getScript("fsVec4Mat3Add"), + fShaderSuccess: true, + linkSuccess: true, + passMsg: "vec(mat +/- mat) works ok", +}); +tests.push({ + vShaderSource: wtu.getScript("vsMat2Vec4Sub"), + vShaderSuccess: true, + fShaderSource: wtu.getScript("fsMat3Vec4AddSub"), + fShaderSuccess: true, + linkSuccess: true, + passMsg: "mat(vec +/- vec) works ok", +}); +tests.push({ + vShaderSource: wtu.getScript("vsVec4Mat2Func"), + vShaderSuccess: true, + fShaderSource: wtu.getScript("fsVec4Mat3Func"), + fShaderSuccess: true, + linkSuccess: true, + passMsg: "vec(func(mat)) works ok", +}); +tests.push({ + vShaderSource: wtu.getScript("vsMat2Vec4Func"), + vShaderSuccess: true, + fShaderSource: wtu.getScript("fsMat3Vec4Func"), + fShaderSuccess: true, + linkSuccess: true, + passMsg: "mat(func(vec)) works ok", +}); +tests.push({ + vShaderSource: wtu.getScript("vsMat4VecMultiple"), + vShaderSuccess: true, + fShaderSource: wtu.getScript("fsMat4VecMultiple"), + fShaderSuccess: true, + linkSuccess: true, + passMsg: "mat4(float, vec2, float, vec3+vec3, float, vec4, f(vec4)) works ok", +}); + +GLSLConformanceTester.runTests(tests); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-vec-mat-index.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-vec-mat-index.html new file mode 100644 index 0000000000..084d532f8a --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-vec-mat-index.html @@ -0,0 +1,53 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> +// A matrix constructor with two writes and reads to the same variable inside it in different parameters must succeed "mat2(index++, vec4(index++))" +// ESSL 1.00 spec section 5.4 Constructors: "Arguments are evaluated from left to right." +precision mediump float; +bool equal(mat2 m1, mat2 m2) +{ + float EPSILON = 0.00001; + for (int i = 0; i < 2; i++) { + for (int j = 0; j < 2; j++) { + if (abs(m1[i][j] - m2[i][j]) > EPSILON) + return false; + } + } + return true; +} +void main() +{ + int i = 0; + mat2 m = mat2(i++, vec4(i++)); + if (equal(m, mat2(0, 1, 1, 1))) + gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); + else + gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); +} +</script> + +<script> +"use strict"; +GLSLConformanceTester.runRenderTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-vec2.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-vec2.html new file mode 100644 index 0000000000..6fa0d2af52 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-vec2.html @@ -0,0 +1,39 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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> +<script src="../../../js/glsl-constructor-tests-generator.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +var targetType = "vec2"; +description("Test " + targetType + " constructor expressions."); + +var testSet = GLSLConstructorTestsGenerator.getDefaultTestSet(targetType); + +// Generate tests +var testCases = GLSLConstructorTestsGenerator.getConstructorTests(targetType, testSet); + +// Run the tests +GLSLConformanceTester.runTests(testCases); + +debug(""); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-vec3.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-vec3.html new file mode 100644 index 0000000000..b5e1a7cd4d --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-vec3.html @@ -0,0 +1,39 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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> +<script src="../../../js/glsl-constructor-tests-generator.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +var targetType = "vec3"; +description("Test " + targetType + " constructor expressions."); + +var testSet = GLSLConstructorTestsGenerator.getDefaultTestSet(targetType); + +// Generate tests +var testCases = GLSLConstructorTestsGenerator.getConstructorTests(targetType, testSet); + +// Run the tests +GLSLConformanceTester.runTests(testCases); + +debug(""); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-vec4.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-vec4.html new file mode 100644 index 0000000000..c66fa470a0 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/constructors/glsl-construct-vec4.html @@ -0,0 +1,39 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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> +<script src="../../../js/glsl-constructor-tests-generator.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +var targetType = "vec4"; +description("Test " + targetType + " constructor expressions."); + +var testSet = GLSLConstructorTestsGenerator.getDefaultTestSet(targetType); + +// Generate tests +var testCases = GLSLConstructorTestsGenerator.getConstructorTests(targetType, testSet); + +// Run the tests +GLSLConformanceTester.runTests(testCases); + +debug(""); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/00_test_list.txt b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/00_test_list.txt new file mode 100644 index 0000000000..dd06ea0520 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/00_test_list.txt @@ -0,0 +1,36 @@ +glsl-function.html +glsl-function-abs.html +glsl-function-acos.html +glsl-function-asin.html +glsl-function-atan.html +glsl-function-atan-xy.html +glsl-function-ceil.html +glsl-function-clamp-float.html +glsl-function-clamp-gentype.html +glsl-function-cos.html +glsl-function-cross.html +glsl-function-distance.html +glsl-function-dot.html +glsl-function-faceforward.html +glsl-function-floor.html +glsl-function-fract.html +glsl-function-length.html +#glsl-function-lessThan.html +glsl-function-max-float.html +glsl-function-max-gentype.html +glsl-function-min-float.html +glsl-function-min-gentype.html +glsl-function-mix-float.html +glsl-function-mix-gentype.html +glsl-function-mod-float.html +glsl-function-mod-gentype.html +glsl-function-normalize.html +glsl-function-reflect.html +#glsl-function-refract.html +glsl-function-sign.html +glsl-function-sin.html +glsl-function-step-float.html +glsl-function-step-gentype.html +glsl-function-smoothstep-float.html +glsl-function-smoothstep-gentype.html + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-abs.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-abs.html new file mode 100644 index 0000000000..e7e3b19207 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-abs.html @@ -0,0 +1,45 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL abs function 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +GLSLGenerator.runFeatureTest({ + feature: "abs", + testFunc: "$(func)($(arg0))", + emuFunc: ["float $(func)_base(float value) {", + " return value >= 0.0 ? value : -value;", + "}"].join("\n"), + gridRes: 4, + tests: [ + ["$(output) = vec4(", + " $(func)($(input).x * 2.0 - 1.0),", + " 0.5,", + " 0,", + " 1);"].join("\n"), + "$(output) = vec4(0, $(func)($(input).xy * 2.0 - vec2(1, 1)), 1);", + "$(output) = vec4($(func)($(input).xyz * 2.0 - vec3(1, 1, 1)), 1);", + "$(output) = $(func)($(input) * 2.0 - vec4(1, 1, 1, 1));" + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-acos.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-acos.html new file mode 100644 index 0000000000..ba6b9ab33f --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-acos.html @@ -0,0 +1,95 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL acos function 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; + +var piConstants = [ + "const float kPI = 3.14159265358979323846;", + "const float kHalfPI = (kPI * 0.5);", + "const float k2PI = (kPI * 2.0);" +].join("\n"); + +var kPI = Math.PI; +var kHalfPI = Math.PI * 0.5; +var k2PI = Math.PI * 2.0; +var acos = Math.acos; // shorthand + +GLSLGenerator.runReferenceImageTest({ + feature: "acos", + args: "$(type) value", + testFunc: "$(func)($(type))", + gridRes: 8, + tolerance: 2, + extra: piConstants, + tests: [ + { + source: ["$(output) = vec4(", + " $(func)($(input).x * 0.8) / kPI,", + " $(func)($(input).y * 0.8) / kPI,", + " 0,", + " 1);"].join("\n"), + generator: function(x, y, z, w) { + return [ acos(x * 0.8) / kPI, + acos(y * 0.8) / kPI, + 0, + 1 ]; + }, + }, + { + source: ["$(output) = vec4(", + " $(func)($(input).xy * 0.8) / kPI,", + " 0, 1);"].join("\n"), + generator: function(x, y, z, w) { + return [ acos(x * 0.8) / kPI, + acos(y * 0.8) / kPI, + 0, + 1 ]; + }, + }, + { + source: ["$(output) = vec4(", + " $(func)($(input).xyz * 0.8) / kPI,", + " 1);"].join("\n"), + generator: function(x, y, z, w) { + return [ acos(x * 0.8) / kPI, + acos(y * 0.8) / kPI, + acos(z * 0.8) / kPI, + 1 ]; + }, + }, + { + source: ["$(output) = ", + " $(func)($(input) * 0.8) / kPI;", + ].join("\n"), + generator: function(x, y, z, w) { + return [ acos(x * 0.8) / kPI, + acos(y * 0.8) / kPI, + acos(z * 0.8) / kPI, + acos(w * 0.8) / kPI ]; + }, + }, + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-asin.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-asin.html new file mode 100644 index 0000000000..051c4f7d81 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-asin.html @@ -0,0 +1,95 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL asin function 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; + +var piConstants = [ + "const float kPI = 3.14159265358979323846;", + "const float kHalfPI = (kPI * 0.5);", + "const float k2PI = (kPI * 2.0);" +].join("\n"); + +var kPI = Math.PI; +var kHalfPI = Math.PI * 0.5; +var k2PI = Math.PI * 2.0; +var asin = Math.asin; // shorthand + +GLSLGenerator.runReferenceImageTest({ + feature: "asin", + args: "$(type) value", + testFunc: "$(func)($(type))", + gridRes: 8, + tolerance: 2, + extra: piConstants, + tests: [ + { + source: ["$(output) = vec4(", + " $(func)($(input).x * 0.8) / kPI + 0.5,", + " $(func)($(input).y * 0.8) / kPI + 0.5,", + " 0,", + " 1);"].join("\n"), + generator: function(x, y, z, w) { + return [ asin(x * 0.8) / kPI + 0.5, + asin(y * 0.8) / kPI + 0.5, + 0, + 1 ]; + }, + }, + { + source: ["$(output) = vec4(", + " $(func)($(input).xy * 0.8) / kPI + 0.5,", + " 0, 1);"].join("\n"), + generator: function(x, y, z, w) { + return [ asin(x * 0.8) / kPI + 0.5, + asin(y * 0.8) / kPI + 0.5, + 0, + 1 ]; + }, + }, + { + source: ["$(output) = vec4(", + " $(func)($(input).xyz * 0.8) / kPI + 0.5,", + " 1);"].join("\n"), + generator: function(x, y, z, w) { + return [ asin(x * 0.8) / kPI + 0.5, + asin(y * 0.8) / kPI + 0.5, + asin(z * 0.8) / kPI + 0.5, + 1 ]; + }, + }, + { + source: ["$(output) = ", + " $(func)($(input) * 0.8) / kPI + 0.5;", + ].join("\n"), + generator: function(x, y, z, w) { + return [ asin(x * 0.8) / kPI + 0.5, + asin(y * 0.8) / kPI + 0.5, + asin(z * 0.8) / kPI + 0.5, + asin(w * 0.8) / kPI + 0.5 ]; + }, + }, + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-atan-xy.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-atan-xy.html new file mode 100644 index 0000000000..e20d18d2c0 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-atan-xy.html @@ -0,0 +1,98 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL atan-xy function 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; + +var piConstants = [ + "const float kPI = 3.14159265358979323846;", + "const float kHalfPI = (kPI * 0.5);", + "const float k2PI = (kPI * 2.0);" +].join("\n"); + +var kPI = Math.PI; +var kHalfPI = Math.PI * 0.5; +var k2PI = Math.PI * 2.0; +var atan2 = Math.atan2; // shorthand + +GLSLGenerator.runReferenceImageTest({ + feature: "atan", + args: "$(type) y, $(type) x", + testFunc: "$(func)($(type), $(type))", + gridRes: 8, + tolerance: 5, + extra: piConstants, + tests: [ + { + source: ["$(output) = vec4(", + " $(func)($(input).x + 0.1, $(input).y) / k2PI + 0.5,", + " 0,", + " 0,", + " 1);"].join("\n"), + generator: function(x, y, z, w) { + return [ atan2(x + 0.1, y) / k2PI + 0.5, + 0, + 0, + 1 ]; + }, + }, + { + source: ["$(output) = vec4(", + " $(func)($(input).xy + vec2(0.1, 0.1), $(input).yx) / ", + " k2PI + vec2(0.5, 0.5),", + " 0, 1);"].join("\n"), + generator: function(x, y, z, w) { + return [ atan2(x + 0.1, y) / k2PI + 0.5, + atan2(y + 0.1, x) / k2PI + 0.5, + 0, + 1 ]; + }, + }, + { + source: ["$(output) = vec4(", + " $(func)($(input).xyz + vec3(0.1, 0.1, 0.1), $(input).yzx) / ", + " k2PI + vec3(0.5, 0.5, 0.5),", + " 1);"].join("\n"), + generator: function(x, y, z, w) { + return [ atan2(x + 0.1, y) / k2PI + 0.5, + atan2(y + 0.1, z) / k2PI + 0.5, + atan2(z + 0.1, x) / k2PI + 0.5, + 1 ]; + }, + }, + { + source: ["$(output) = ", + " $(func)($(input) + vec4(0.1, 0.1, 0.1, 0.1), $(input).wzyx) / ", + " k2PI + vec4(0.5, 0.5, 0.5, 0.5);", + ].join("\n"), + generator: function(x, y, z, w) { + return [ atan2(x + 0.1, w) / k2PI + 0.5, + atan2(y + 0.1, z) / k2PI + 0.5, + atan2(z + 0.1, y) / k2PI + 0.5, + atan2(w + 0.1, x) / k2PI + 0.5 ]; + }, + }, + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-atan.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-atan.html new file mode 100644 index 0000000000..20d1366f70 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-atan.html @@ -0,0 +1,95 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL atan function 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; + +var piConstants = [ + "const float kPI = 3.14159265358979323846;", + "const float kHalfPI = (kPI * 0.5);", + "const float k2PI = (kPI * 2.0);" +].join("\n"); + +var kPI = Math.PI; +var kHalfPI = Math.PI * 0.5; +var k2PI = Math.PI * 2.0; +var atan = Math.atan; // shorthand + +GLSLGenerator.runReferenceImageTest({ + feature: "atan", + args: "$(type) value", + testFunc: "$(func)($(type))", + gridRes: 8, + tolerance: 4, + extra: piConstants, + tests: [ + { + source: ["$(output) = vec4(", + " $(func)($(input).x * 8.0 - 4.0) / k2PI + 0.5,", + " 0.5,", + " 0,", + " 1);"].join("\n"), + generator: function(x, y, z, w) { + return [ atan(x * 8.0 - 4.0) / k2PI + 0.5, + 0.5, + 0, + 1 ]; + }, + }, + { + source: ["$(output) = vec4(", + " $(func)($(input).xy * 8.0 - vec2(4, 4)) / k2PI + vec2(0.5, 0.5),", + " 0, 1);"].join("\n"), + generator: function(x, y, z, w) { + return [ atan(x * 8.0 - 4) / k2PI + 0.5, + atan(y * 8.0 - 4) / k2PI + 0.5, + 0, + 1 ]; + }, + }, + { + source: ["$(output) = vec4(", + " $(func)($(input).xyz * 8.0 - vec3(4, 4, 4)) / k2PI + vec3(0.5, 0.5, 0.5),", + " 1);"].join("\n"), + generator: function(x, y, z, w) { + return [ atan(x * 8.0 - 4) / k2PI + 0.5, + atan(y * 8.0 - 4) / k2PI + 0.5, + atan(z * 8.0 - 4) / k2PI + 0.5, + 1 ]; + }, + }, + { + source: ["$(output) = ", + " $(func)($(input) * 8.0 - vec4(4, 4, 4, 4)) / k2PI + vec4(0.5, 0.5, 0.5, 0.5);", + ].join("\n"), + generator: function(x, y, z, w) { + return [ atan(x * 8.0 - 4) / k2PI + 0.5, + atan(y * 8.0 - 4) / k2PI + 0.5, + atan(z * 8.0 - 4) / k2PI + 0.5, + atan(w * 8.0 - 4) / k2PI + 0.5 ]; + }, + }, + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-ceil.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-ceil.html new file mode 100644 index 0000000000..a031b93fa3 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-ceil.html @@ -0,0 +1,53 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL ceil function 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +GLSLGenerator.runFeatureTest({ + feature: "ceil", + testFunc: "$(func)($(arg0))", + emuFunc: ["float $(func)_base(float value) {", + " float m = mod(value, 1.0);", + " return m != 0.0 ? (value + 1.0 - m) : value;", + "}"].join("\n"), + gridRes: 8, + tests: [ + ["$(output) = vec4(", + " $(func)($(input).x * 8.0 - 4.0) / 8.0 + 0.5,", + " $(func)($(input).y * 8.0 - 4.0) / 8.0 + 0.5,", + " 0,", + " 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)($(input).xy * 8.0 - vec2(4, 4)) / 8.0 + vec2(0.5, 0.5),", + " 0, 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)($(input).xyz * 8.0 - vec3(4, 4, 4)) / 8.0 + ", + " vec3(0.5, 0.5, 0.5),", + " 1);"].join("\n"), + ["$(output) = ", + " $(func)($(input) * 8.0 - vec4(4, 4, 4, 4)) / 8.0 + ", + " vec4(0.5, 0.5, 0.5, 0.5);"].join("\n") + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-clamp-float.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-clamp-float.html new file mode 100644 index 0000000000..bb74a30961 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-clamp-float.html @@ -0,0 +1,56 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL clamp-gentype function 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +GLSLGenerator.runFeatureTest({ + feature: "clamp", + args: "$(type) value, float minValue, float maxValue", + baseArgs: "value$(field), minValue, maxValue", + testFunc: "$(func)($(type), float, float)", + emuFunc: ["float $(func)_base(float value, float minValue, float maxValue) {", + " return min(max(value, minValue), maxValue);", + "}"].join("\n"), + gridRes: 8, + tests: [ + ["$(output) = vec4(", + " $(func)($(input).x * 6.0 - 3.0, -1.5, 1.5) / 3.0 + 0.5,", + " $(func)($(input).y * 10.0 - 5.0, -2.5, 2.5) / 5.0 + 0.5,", + " 0,", + " 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)($(input).xy * vec2(6, 10) - vec2(3, 5), -1.5, 2.0) / ", + " vec2(3.0, 5.0) + vec2(0.5, 0.5),", + " 0, 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)($(input).xyz * vec3(6, 10, 8) - vec3(3, 5, 4), -1.5, 2.0) / ", + " vec3(3, 5, 4) + vec3(0.5, 0.5, 0.5),", + " 1);"].join("\n"), + ["$(output) = ", + " $(func)($(input) * vec4(6, 10, 8, 4) - vec4(3, 5, 4, 2),", + " -1.5, 2.2) / vec4(3, 5, 4, 2) + ", + " vec4(0.5, 0.5, 0.5, 0.5);"].join("\n") + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-clamp-gentype.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-clamp-gentype.html new file mode 100644 index 0000000000..2967bdc57d --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-clamp-gentype.html @@ -0,0 +1,59 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL clamp-gentype function 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +GLSLGenerator.runFeatureTest({ + feature: "clamp", + args: "$(type) value, $(type) minValue, $(type) maxValue", + baseArgs: "value$(field), minValue$(field), maxValue$(field)", + testFunc: "$(func)($(type), $(type), $(type))", + emuFunc: ["float $(func)_base(float value, float minValue, float maxValue) {", + " return min(max(value, minValue), maxValue);", + "}"].join("\n"), + gridRes: 8, + tests: [ + ["$(output) = vec4(", + " $(func)($(input).x * 6.0 - 3.0, -1.5, 1.5) / 3.0 + 0.5,", + " $(func)($(input).y * 10.0 - 5.0, -2.5, 2.5) / 5.0 + 0.5,", + " 0,", + " 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)($(input).xy * vec2(6, 10) - vec2(3, 5), ", + " vec2(-1.5, -2.5), vec2(1.5, 2.5)) / ", + " vec2(3.0, 5.0) + vec2(0.5, 0.5),", + " 0, 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)($(input).xyz * vec3(6, 10, 8) - vec3(3, 5, 4), ", + " vec3(-1.5, -2.5, -2), vec3(1.5, 2.5, 2)) / vec3(3, 5, 4) + ", + " vec3(0.5, 0.5, 0.5),", + " 1);"].join("\n"), + ["$(output) = ", + " $(func)($(input) * vec4(6, 10, 8, 4) - vec4(3, 5, 4, 2),", + " vec4(-1.5, -2.5, -2, -1), vec4(1.5, 2.5, 2, 1)) / ", + " vec4(3, 5, 4, 2) + ", + " vec4(0.5, 0.5, 0.5, 0.5);"].join("\n") + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-cos.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-cos.html new file mode 100644 index 0000000000..a62ffc76fc --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-cos.html @@ -0,0 +1,99 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL cos function 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; + +var piConstants = [ + "const float kPI = 3.14159265358979323846;", + "const float kHalfPI = (kPI * 0.5);", + "const float k2PI = (kPI * 2.0);" +].join("\n"); + +var kPI = Math.PI; +var kHalfPI = Math.PI * 0.5; +var k2PI = Math.PI * 2.0; +var cos = Math.cos; // shorthand + +GLSLGenerator.runReferenceImageTest({ + feature: "cos", + args: "$(type) value", + testFunc: "$(func)($(type))", + gridRes: 8, + tolerance: 3, + extra: piConstants, + tests: [ + { + source: ["$(output) = vec4(", + " $(func)($(input).x * kHalfPI + kHalfPI),", + " $(func)($(input).y * kHalfPI),", + " 0,", + " 1);"].join("\n"), + generator: function(x, y, z, w) { + return [ cos(x * kHalfPI + kHalfPI), + cos(y * kHalfPI), + 0, + 1 ]; + }, + }, + { + source: ["$(output) = vec4(", + " $(func)($(input).xy * vec2(kPI, k2PI)) * 0.5 + vec2(0.5, 0.5),", + " 0, 1);"].join("\n"), + generator: function(x, y, z, w) { + return [ cos(x * kPI) * 0.5 + 0.5, + cos(y * k2PI) * 0.5 + 0.5, + 0, + 1 ]; + }, + }, + { + // FIXME: for some reason, this test requires a higher tolerance when run in a vertex shader. + source: ["$(output) = vec4(", + " $(func)($(input).xyz * vec3(kPI, k2PI, 4.0)) * ", + " 0.5 + vec3(0.5, 0.5, 0.5),", + " 1);"].join("\n"), + generator: function(x, y, z, w) { + return [ cos(x * kPI) * 0.5 + 0.5, + cos(y * k2PI) * 0.5 + 0.5, + cos(z * 4.0) * 0.5 + 0.5, + 1 ]; + }, + tolerance: 7, + }, + { + source: ["$(output) = ", + " $(func)($(input) * vec4(k2PI, 4.0, kHalfPI, kPI)) *", + " 0.5 + vec4(0.5, 0.5, 0.5, 1);", + ].join("\n"), + generator: function(x, y, z, w) { + return [ cos(x * k2PI) * 0.5 + 0.5, + cos(y * 4.0) * 0.5 + 0.5, + cos(z * kHalfPI) * 0.5 + 0.5, + cos(w * kPI) * 0.5 + 1.0 ]; + }, + }, + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-cross.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-cross.html new file mode 100644 index 0000000000..37d17a4eda --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-cross.html @@ -0,0 +1,53 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL cross function 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; + +GLSLGenerator.runFeatureTest({ + feature: "cross", + args: "$(type) x, $(type) y", + baseArgs: "value$(field)", + testFunc: "$(func)($(type),$(type))", + emuFuncs: [ + { type: "vec3", + code: [ + "vec3 $(func)_emu($(args)) {", + " return vec3(", + " x[1] * y[2] - y[1] * x[2],", + " x[2] * y[0] - y[2] * x[0],", + " x[0] * y[1] - y[0] * x[1]);", + "}"].join("\n") + }, + ], + gridRes: 8, + tests: [ + ["$(output) = vec4(", + " $(func)(", + " normalize($(input).xyz - 0.5),", + " normalize($(input).yzw - 0.5)) * 0.5 + 0.5,", + " 1);"].join("\n") + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-distance.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-distance.html new file mode 100644 index 0000000000..1efa4f7e4e --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-distance.html @@ -0,0 +1,88 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL distance function 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; + +GLSLGenerator.runFeatureTest({ + feature: "distance", + args: "$(type) p1, $(type) p2", + baseArgs: "value$(field)", + testFunc: "$(func)($(type),$(type))", + emuFuncs: [ + { type: "float", + code: [ + "float $(func)_emu($(args)) {", + " return abs(p1 - p2);", + "}"].join("\n") + }, + { type: "vec2", + code: [ + "float $(func)_emu($(args)) {", + " return length(p1 - p2);", + "}"].join("\n") + }, + { type: "vec3", + code: [ + "float $(func)_emu($(args)) {", + " return length(p1 - p2);", + "}"].join("\n") + }, + { type: "vec4", + code: [ + "float $(func)_emu($(args)) {", + " return length(p1 - p2);", + "}"].join("\n") + } + ], + gridRes: 8, + tests: [ + ["$(output) = vec4(", + " $(func)(", + " $(input).x * 8.0 - 4.0,", + " $(input).y * 8.0 - 4.0) / 8.0,", + " 0,", + " 0,", + " 1);"].join("\n"), + ["$(output) = vec4(", + " 0,", + " $(func)(", + " $(input).xy * 8.0 - 4.0,", + " $(input).wz * 8.0 - 4.0) / 8.0,", + " 0, 1);"].join("\n"), + ["$(output) = vec4(", + " 0, 0,", + " $(func)(", + " $(input).xyz * 8.0 - 4.0,", + " $(input).yzw * 8.0 - 4.0) / 8.0,", + " 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)(", + " vec4($(input).xyz, 0) * 8.0 - 4.0,", + " vec4(0, $(input).wzy) * 8.0 - 4.0) / 8.0,", + " 0, 0, 1);", + ].join("\n") + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-dot.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-dot.html new file mode 100644 index 0000000000..c29e43e464 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-dot.html @@ -0,0 +1,90 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL dot function 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; + +GLSLGenerator.runFeatureTest({ + feature: "dot", + args: "$(type) p1, $(type) p2", + baseArgs: "value$(field)", + testFunc: "$(func)($(type),$(type))", + fragmentTolerance: 1, + emuFuncs: [ + { type: "float", + code: [ + "float $(func)_emu($(args)) {", + " return p1 * p2;", + "}"].join("\n") + }, + { type: "vec2", + code: [ + "float $(func)_emu($(args)) {", + " return p1.x * p2.x + p1.y * p2.y;", + "}"].join("\n") + }, + { type: "vec3", + code: [ + "float $(func)_emu($(args)) {", + " return p1.x * p2.x + p1.y * p2.y + p1.z * p2.z;", + "}"].join("\n") + }, + { type: "vec4", + code: [ + "float $(func)_emu($(args)) {", + " return p1.x * p2.x + p1.y * p2.y + p1.z * p2.z + p1.w * p2.w;", + "}"].join("\n") + } + ], + gridRes: 8, + tests: [ + ["$(output) = vec4(", + " $(func)(", + " $(input).x * 8.0 - 4.0,", + " $(input).y * 8.0 - 4.0) / 8.0,", + " 0,", + " 0,", + " 1);"].join("\n"), + ["$(output) = vec4(", + " 0,", + " $(func)(", + " $(input).xy * 8.0 - 4.0,", + " $(input).wz * 8.0 - 4.0) / 8.0,", + " 0, 1);"].join("\n"), + ["$(output) = vec4(", + " 0, 0,", + " $(func)(", + " $(input).xyz * 8.0 - 4.0,", + " $(input).yzw * 8.0 - 4.0) / 8.0,", + " 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)(", + " vec4($(input).xyz, 0) * 8.0 - 4.0,", + " vec4(0, $(input).wzy) * 8.0 - 4.0) / 8.0,", + " 0, 0, 1);", + ].join("\n") + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-faceforward.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-faceforward.html new file mode 100644 index 0000000000..16a4e72ef7 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-faceforward.html @@ -0,0 +1,66 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL faceforward function 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; + +GLSLGenerator.runFeatureTest({ + feature: "faceforward", + args: "$(type) N, $(type) I, $(type) Nref", + baseArgs: "value$(field)", + testFunc: "$(func)($(type),$(type),$(type))", + simpleEmu: [ + "$(type) $(func)_emu($(args)) {", + " return dot(Nref, I) < 0.0 ? N : -N;", + "}"].join("\n"), + gridRes: 8, + tests: [ + ["$(output) = vec4(", + " $(func)(", + " $(input).x * 2.0 - 1.0,", + " $(input).y * 2.0 - 1.0,", + " $(input).z * 2.0 - 1.0),", + " 0,", + " 0,", + " 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)(", + " $(input).xy * 2.0 - 1.0,", + " $(input).yz * 2.0 - 1.0,", + " $(input).zw * 2.0 - 1.0),", + " 0, 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)(", + " $(input).xyz * 2.0 - 1.0,", + " $(input).yzw * 2.0 - 1.0,", + " $(input).zwx * 2.0 - 1.0),", + " 1);"].join("\n"), + ["$(output) = ", + " $(func)(", + " $(input).xyzw * 2.0 - 1.0,", + " $(input).yzwx * 2.0 - 1.0,", + " $(input).zwxy * 2.0 - 1.0);" + ].join("\n") + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-floor.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-floor.html new file mode 100644 index 0000000000..371ebd746b --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-floor.html @@ -0,0 +1,52 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL floor function 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +GLSLGenerator.runFeatureTest({ + feature: "floor", + testFunc: "$(func)($(arg0))", + emuFunc: ["float $(func)_base(float value) {", + " return value - mod(value, 1.0);", + "}"].join("\n"), + gridRes: 8, + tests: [ + ["$(output) = vec4(", + " $(func)($(input).x * 8.0 - 4.0) / 8.0 + 0.5,", + " $(func)($(input).y * 8.0 - 4.0) / 8.0 + 0.5,", + " 0,", + " 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)($(input).xy * 8.0 - vec2(4, 4)) / 8.0 + vec2(0.5, 0.5),", + " 0, 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)($(input).xyz * 8.0 - vec3(4, 4, 4)) / 8.0 + ", + " vec3(0.5, 0.5, 0.5),", + " 1);"].join("\n"), + ["$(output) = ", + " $(func)($(input) * 8.0 - vec4(4, 4, 4, 4)) / 8.0 + ", + " vec4(0.5, 0.5, 0.5, 0.5);"].join("\n") + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-fract.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-fract.html new file mode 100644 index 0000000000..90e1c0bf13 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-fract.html @@ -0,0 +1,50 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL fract function 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +GLSLGenerator.runFeatureTest({ + feature: "fract", + testFunc: "$(func)($(arg0))", + emuFunc: ["float $(func)_base(float value) {", + " return value - floor(value);", + "}"].join("\n"), + gridRes: 8, + tests: [ + ["$(output) = vec4(", + " $(func)($(input).x * 4.0 - 2.0),", + " $(func)($(input).y * 4.0 - 2.0),", + " 0,", + " 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)($(input).xy * 4.0 - vec2(2, 2)),", + " 0, 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)($(input).xyz * 4.0 - vec3(2, 2, 2)),", + " 1);"].join("\n"), + ["$(output) = ", + " $(func)($(input) * 4.0 - vec4(2, 2, 2, 2));"].join("\n") + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-length.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-length.html new file mode 100644 index 0000000000..f3f04f4543 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-length.html @@ -0,0 +1,87 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL length function 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; + +GLSLGenerator.runFeatureTest({ + feature: "length", + args: "$(type) value", + baseArgs: "value$(field)", + testFunc: "$(func)($(type))", + fragmentTolerance: 1, + emuFuncs: [ + { type: "float", + code: [ + "float $(func)_emu($(args)) {", + " return abs($(baseArgs));", + "}"].join("\n") + }, + { type: "vec2", + code: [ + "float $(func)_emu($(args)) {", + " return sqrt(", + " $(baseArgsX) * $(baseArgsX) + ", + " $(baseArgsY) * $(baseArgsY));", + "}"].join("\n") + }, + { type: "vec3", + code: [ + "float $(func)_emu($(args)) {", + " return sqrt(", + " $(baseArgsX) * $(baseArgsX) + ", + " $(baseArgsY) * $(baseArgsY) + ", + " $(baseArgsZ) * $(baseArgsZ));", + "}"].join("\n") + }, + { type: "vec4", + code: [ + "float $(func)_emu($(args)) {", + " return sqrt(", + " $(baseArgsX) * $(baseArgsX) + ", + " $(baseArgsY) * $(baseArgsY) + ", + " $(baseArgsZ) * $(baseArgsZ) + ", + " $(baseArgsW) * $(baseArgsW));", + "}"].join("\n") + } + ], + gridRes: 8, + tests: [ + ["$(output) = vec4(", + " $(func)($(input).x * 8.0 - 4.0) / 4.0,", + " $(func)($(input).y * 8.0 - 4.0) / 4.0,", + " 0,", + " 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)($(input).xy * 8.0 - 4.0) / 4.0,", + " 0, 0, 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)($(input).xyz * 8.0 - 4.0) / 4.0,", + " 0, 0, 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)($(input) * 8.0 - 4.0) / 4.0, 0, 0, 1);", + ].join("\n") + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-lessThan.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-lessThan.html new file mode 100644 index 0000000000..d461c2ee16 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-lessThan.html @@ -0,0 +1,52 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL lessThan function 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +GLSLGenerator.runFeatureTest({ + feature: "lessThan", + args: "$(type) x, $(type) y", + bvecTest: true, + baseArgs: "x, y", + testFunc: "$(func)($(type), $(type))", + emuFunc: ["bool $(func) _base(float x, float y) {", + " return x < y;", + "}"].join("\n"), + gridRes: 8, + tests: [ + ["bvec2 r = bvec2($(func)($(input).xy, $(input).yw));", + "$(output) = vec4(", + " r.x ? 0.2: 0.8,", + " r.y ? 0.2: 0.8,", + " 0, 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)($(input).xyz * 8.0 - vec3(4, 4, 4)) / 8.0 + ", + " vec3(0.5, 0.5, 0.5),", + " 1);"].join("\n"), + ["$(output) = ", + " $(func)($(input) * 8.0 - vec4(4, 4, 4, 4)) / 8.0 + ", + " vec4(0.5, 0.5, 0.5, 0.5);"].join("\n") + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-max-float.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-max-float.html new file mode 100644 index 0000000000..880fa24b48 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-max-float.html @@ -0,0 +1,52 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL max-float function 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +GLSLGenerator.runFeatureTest({ + feature: "max", + args: "$(type) value, float maxValue", + baseArgs: "value$(field), maxValue", + testFunc: "$(func)($(arg0), float)", + emuFunc: ["float $(func)_base(float value, float maxValue) {", + " return value > maxValue ? value : maxValue;", + "}"].join("\n"), + gridRes: 8, + tests: [ + ["$(output) = vec4(", + " $(func)($(input).x, 0.5),", + " $(func)($(input).y, 0.5),", + " 0,", + " 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)($(input).xy, 0.5),", + " 0, 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)($(input).xyz, 0.5),", + " 1);"].join("\n"), + ["$(output) = ", + " $(func)($(input), 0.5);"].join("\n") + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-max-gentype.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-max-gentype.html new file mode 100644 index 0000000000..8d30dacdf9 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-max-gentype.html @@ -0,0 +1,52 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL max-gentype function 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +GLSLGenerator.runFeatureTest({ + feature: "max", + args: "$(type) value, $(type) maxValue", + baseArgs: "value$(field), maxValue$(field)", + testFunc: "$(func)($(type), $(type))", + emuFunc: ["float $(func)_base(float value, float maxValue) {", + " return value > maxValue ? value : maxValue;", + "}"].join("\n"), + gridRes: 8, + tests: [ + ["$(output) = vec4(", + " $(func)($(input).x, 0.5),", + " $(func)($(input).y, 0.5),", + " 0,", + " 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)($(input).xy, vec2(0.5, 0.5)),", + " 0, 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)($(input).xyz, vec3(0.5, 0.5, 0.5)),", + " 1);"].join("\n"), + ["$(output) = ", + " $(func)($(input), vec4(0.5, 0.5, 0.5, 0.5));"].join("\n") + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-min-float.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-min-float.html new file mode 100644 index 0000000000..1cb140ce45 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-min-float.html @@ -0,0 +1,52 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL min-float function 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +GLSLGenerator.runFeatureTest({ + feature: "min", + args: "$(type) value, float divisor", + baseArgs: "value$(field), divisor", + testFunc: "$(func)($(arg0), float)", + emuFunc: ["float $(func)_base(float value, float divisor) {", + " return value < divisor ? value : divisor;", + "}"].join("\n"), + gridRes: 8, + tests: [ + ["$(output) = vec4(", + " $(func)($(input).x, 0.5),", + " $(func)($(input).y, 0.5),", + " 0,", + " 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)($(input).xy, 0.5),", + " 0, 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)($(input).xyz, 0.5),", + " 1);"].join("\n"), + ["$(output) = ", + " $(func)($(input), 0.5);"].join("\n") + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-min-gentype.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-min-gentype.html new file mode 100644 index 0000000000..4ff565112a --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-min-gentype.html @@ -0,0 +1,52 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL min-gentype function 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +GLSLGenerator.runFeatureTest({ + feature: "min", + args: "$(type) value, $(type) minValue", + baseArgs: "value$(field), minValue$(field)", + testFunc: "$(func)($(type), $(type))", + emuFunc: ["float $(func)_base(float value, float minValue) {", + " return value < minValue ? value : minValue;", + "}"].join("\n"), + gridRes: 8, + tests: [ + ["$(output) = vec4(", + " $(func)($(input).x, 0.5),", + " $(func)($(input).y, 0.5),", + " 0,", + " 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)($(input).xy, vec2(0.5, 0.5)),", + " 0, 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)($(input).xyz, vec3(0.5, 0.5, 0.5)),", + " 1);"].join("\n"), + ["$(output) = ", + " $(func)($(input), vec4(0.5, 0.5, 0.5, 0.5));"].join("\n") + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-mix-float.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-mix-float.html new file mode 100644 index 0000000000..34e70068c2 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-mix-float.html @@ -0,0 +1,54 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL mix-float function 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +GLSLGenerator.runFeatureTest({ + feature: "mix", + args: "$(type) startValue, $(type) endValue, float mixValue", + baseArgs: "startValue$(field), endValue$(field), mixValue", + testFunc: "$(func)($(type), $(type), float)", + emuFunc: [ + "float $(func)_base(float startValue, float endValue, float mixValue) {", + " return startValue * (1.0 - mixValue) + endValue * mixValue;", + "}"].join("\n"), + gridRes: 8, + tests: [ + ["$(output) = vec4(", + " $(func)(1.0, 0.0, $(input).x),", + " ($(func)(-2.0, 3.0, $(input).y) + 2.0) / 5.0,", + " 0,", + " 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)(vec2(1, -2), vec2(0, 2), $(input).z), ", + " 0, 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)(vec3(1, -2, -1), vec3(0, 2, 3), $(input).y),", + " 1);"].join("\n"), + ["$(output) = ", + " $(func)(vec4(1, -2, -1, 0.5), vec4(0, 2, 3, 1), $(input).w);" + ].join("\n") + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-mix-gentype.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-mix-gentype.html new file mode 100644 index 0000000000..2fa3330e7e --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-mix-gentype.html @@ -0,0 +1,54 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL mix-gentype function 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +GLSLGenerator.runFeatureTest({ + feature: "mix", + args: "$(type) startValue, $(type) endValue, $(type) mixValue", + baseArgs: "startValue$(field), endValue$(field), mixValue$(field)", + testFunc: "$(func)($(type), $(type), $(type))", + emuFunc: [ + "float $(func)_base(float startValue, float endValue, float mixValue) {", + " return startValue * (1.0 - mixValue) + endValue * mixValue;", + "}"].join("\n"), + gridRes: 8, + tests: [ + ["$(output) = vec4(", + " $(func)(1.0, 0.0, $(input).x),", + " ($(func)(-2.0, 3.0, $(input).y) + 2.0) / 5.0,", + " 0,", + " 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)(vec2(1, -2), vec2(0, 2), $(input).xy), ", + " 0, 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)(vec3(1, -2, -1), vec3(0, 2, 3), $(input).xyz),", + " 1);"].join("\n"), + ["$(output) = ", + " $(func)(vec4(1, -2, -1, 0.5), vec4(0, 2, 3, 1), $(input));" + ].join("\n") + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-mod-float.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-mod-float.html new file mode 100644 index 0000000000..83bcf76715 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-mod-float.html @@ -0,0 +1,53 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL mod-float function 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +GLSLGenerator.runFeatureTest({ + feature: "mod", + args: "$(type) value, float divisor", + baseArgs: "value$(field), divisor", + testFunc: "$(func)($(arg0), float)", + fragmentTolerance: 1, + emuFunc: ["float $(func)_base(float value, float divisor) {", + " return value - divisor * floor(value / divisor);", + "}"].join("\n"), + gridRes: 8, + tests: [ + ["$(output) = vec4(", + " $(func)($(input).x * 6.0 - 3.0, 1.5) / 1.5,", + " $(func)($(input).y * 6.0 - 3.0, 1.5) / 1.5,", + " 0,", + " 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)($(input).xy * 6.0 - vec2(3, 3), 1.5) / 1.5,", + " 0, 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)($(input).xyz * 6.0 - vec3(3, 3, 3), 1.5) / 1.5,", + " 1);"].join("\n"), + ["$(output) = ", + " $(func)($(input) * 6.0 - vec4(3, 3, 3, 3), 1.5) / 1.5;"].join("\n") + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-mod-gentype.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-mod-gentype.html new file mode 100644 index 0000000000..9b562300b9 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-mod-gentype.html @@ -0,0 +1,56 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL mod-gentype function 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +GLSLGenerator.runFeatureTest({ + feature: "mod", + args: "$(type) value, $(type) divisor", + baseArgs: "value$(field), divisor$(field)", + testFunc: "$(func)($(type), $(type))", + emuFunc: ["float $(func)_base(float value, float divisor) {", + " return value - divisor * floor(value / divisor);", + "}"].join("\n"), + gridRes: 8, + tolerance: 1, + tests: [ + ["$(output) = vec4(", + " $(func)($(input).x * 6.0 - 3.0, 1.5) / 1.5,", + " $(func)($(input).y * 10.0 - 5.0, 2.1) / 2.1,", + " 0,", + " 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)($(input).xy * vec2(6, 10) - vec2(3, 5), ", + " vec2(1.5, 2.1)) / vec2(1.5, 2.1),", + " 0, 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)($(input).xyz * vec3(6, 10, 8) - vec3(3, 5, 4), ", + " vec3(1.5, 2.1, 3.2)) / vec3(1.5, 2.1, 3.2),", + " 1);"].join("\n"), + ["$(output) = ", + " $(func)($(input) * vec4(6, 10, 8, 4) - vec4(3, 5, 4, 2),", + " vec4(1.5, 2.1, 3.2, 1.1)) / vec4(1.5, 2.1, 3.2, 1.1);"].join("\n") + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-normalize.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-normalize.html new file mode 100644 index 0000000000..bd5f8844d9 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-normalize.html @@ -0,0 +1,59 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL normalize function 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +GLSLGenerator.runFeatureTest({ + feature: "normalize", + args: "$(type) value", + testFunc: "$(func)($(type))", + simpleEmu: [ + "$(type) $(func)_emu($(args)) {", + " return value / length(value);", + "}"].join("\n"), + gridRes: 8, + tolerance: 1, + tests: [ + ["$(output) = vec4(", + " $(func)(", + " $(input).x * 8.0 - 4.1) * 0.5 + 0.5,", + " 0.5,", + " 0,", + " 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)(", + " $(input).xy * 8.0 - 4.1) * 0.5 + 0.5,", + " 0, 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)(", + " $(input).xyz * 8.0 - 4.1) * 0.5 + 0.5,", + " 1);"].join("\n"), + ["$(output) = ", + " $(func)(", + " vec4($(input).xyz, 0) * 8.0 - 4.1) * 0.5 + 0.5 + vec4(0,0,0,0.5);", + ].join("\n") + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-reflect.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-reflect.html new file mode 100644 index 0000000000..70d9e557f7 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-reflect.html @@ -0,0 +1,61 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL reflect function 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +GLSLGenerator.runFeatureTest({ + feature: "reflect", + args: "$(type) I, $(type) N", + baseArgs: "value$(field)", + testFunc: "$(func)($(type),$(type))", + simpleEmu: [ + "$(type) $(func)_emu($(args)) {", + " return I - 2.0 * dot(N, I) * N;", + "}"].join("\n"), + gridRes: 8, + tests: [ + ["$(output) = vec4(", + " $(func)(", + " $(input).x * 2.0 - 1.0,", + " $(input).y * 2.0 - 1.0),", + " 0,", + " 0,", + " 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)(", + " $(input).xy * 2.0 - 1.0,", + " $(input).yz * 2.0 - 1.0),", + " 0, 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)(", + " $(input).xyz * 2.0 - 1.0,", + " $(input).yzw * 2.0 - 1.0),", + " 1);"].join("\n"), + ["$(output) = ", + " $(func)(", + " $(input).xyzw * 2.0 - 1.0,", + " $(input).yzwx * 2.0 - 1.0);" + ].join("\n") + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-refract.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-refract.html new file mode 100644 index 0000000000..1ee43b2f60 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-refract.html @@ -0,0 +1,70 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL refract function 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +GLSLGenerator.runFeatureTest({ + feature: "refract", + args: "$(type) I, $(type) N, float eta", + baseArgs: "value$(field)", + testFunc: "$(func)($(type),$(type),float)", + simpleEmu: [ + "$(type) $(func)_emu($(args)) {", + " float dotNI = dot(N, I);", + " float k = 1.0 - eta * eta * (1.0 - dotNI * dotNI);", + " if (k < 0.0) {", + " return $(type)(0.0);", + " }", + " return eta * I - (eta * dotNI * sqrt(k)) * N;", + "}"].join("\n"), + gridRes: 8, + tests: [ + ["$(output) = vec4(", + " $(func)(", + " $(input).x * 2.0 - 1.0,", + " $(input).y * 2.0 - 1.0,", + " $(input).w),", + " 0,", + " 0,", + " 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)(", + " $(input).xy * 2.0 - 1.0,", + " $(input).yz * 2.0 - 1.0,", + " $(input).w),", + " 0, 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)(", + " $(input).xyz * 2.0 - 1.0,", + " $(input).yzw * 2.0 - 1.0,", + " $(input).w),", + " 1);"].join("\n"), + ["$(output) = ", + " $(func)(", + " $(input).xyzw * 2.0 - 1.0,", + " $(input).yzwx * 2.0 - 1.0,", + " $(input).w);" + ].join("\n") + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-sign.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-sign.html new file mode 100644 index 0000000000..3185c647ea --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-sign.html @@ -0,0 +1,52 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL sign function 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +GLSLGenerator.runFeatureTest({ + feature: "sign", + testFunc: "$(func)($(arg0))", + emuFunc: ["float $(func)_base(float value) {", + " if (value == 0.0) return 0.0;", + " return value > 0.0 ? 1.0 : -1.0;", + "}"].join("\n"), + gridRes: 4, + tests: [ + ["$(output) = vec4(", + " $(func)($(input).x * 2.0 - 1.0) * 0.5 + 0.5,", + " 0.5,", + " 0,", + " 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)($(input).xy * 2.0 - vec2(1, 1)) * 0.5 + vec2(0.5, 0.5),", + " 0, 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)($(input).xyz * 2.0 - vec3(1, 1, 1)) * 0.5 + ", + " vec3(0.5, 0.5, 0.5),", + " 1);"].join("\n"), + ["$(output) = ", + " $(func)($(input) * 2.0 - vec4(1, 1, 1, 1)) * 0.5 + ", + " vec4(0.5, 0.5, 0.5, 0.5);"].join("\n") + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-sin.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-sin.html new file mode 100644 index 0000000000..b27e6ace1a --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-sin.html @@ -0,0 +1,96 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL sin function 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; + +var piConstants = [ + "const float kPI = 3.14159265358979323846;", + "const float kHalfPI = (kPI * 0.5);", + "const float k2PI = (kPI * 2.0);" +].join("\n"); + +var kPI = Math.PI; +var kHalfPI = Math.PI * 0.5; +var k2PI = Math.PI * 2.0; +var sin = Math.sin; // shorthand + +GLSLGenerator.runReferenceImageTest({ + feature: "sin", + args: "$(type) value", + testFunc: "$(func)($(type))", + gridRes: 8, + tolerance: 4, + extra: piConstants, + tests: [ + { + source: ["$(output) = vec4(", + " $(func)($(input).x * kHalfPI + kHalfPI),", + " $(func)($(input).y * kHalfPI),", + " 0,", + " 1);"].join("\n"), + generator: function(x, y, z, w) { + return [ sin(x * kHalfPI + kHalfPI), + sin(y * kHalfPI), + 0, + 1 ]; + }, + }, + { + source: ["$(output) = vec4(", + " $(func)($(input).xy * vec2(kPI, k2PI)) * 0.5 + vec2(0.5, 0.5),", + " 0, 1);"].join("\n"), + generator: function(x, y, z, w) { + return [ sin(x * kPI) * 0.5 + 0.5, + sin(y * k2PI) * 0.5 + 0.5, + 0, + 1 ]; + }, + }, + { + source: ["$(output) = vec4(", + " $(func)($(input).xyz * vec3(kPI, k2PI, 4.0)) * ", + " 0.5 + vec3(0.5, 0.5, 0.5),", + " 1);"].join("\n"), + generator: function(x, y, z, w) { + return [ sin(x * kPI) * 0.5 + 0.5, + sin(y * k2PI) * 0.5 + 0.5, + sin(z * 4.0) * 0.5 + 0.5, + 1 ]; + }, + }, + { + source: ["$(output) = ", + " $(func)($(input) * vec4(k2PI, 4.0, kHalfPI, kPI)) *", + " 0.5 + vec4(0.5, 0.5, 0.5, 1);", + ].join("\n"), + generator: function(x, y, z, w) { + return [ sin(x * k2PI) * 0.5 + 0.5, + sin(y * 4.0) * 0.5 + 0.5, + sin(z * kHalfPI) * 0.5 + 0.5, + sin(w * kPI) * 0.5 + 1 ]; + }, + }, + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-smoothstep-float.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-smoothstep-float.html new file mode 100644 index 0000000000..a963ec0fb7 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-smoothstep-float.html @@ -0,0 +1,97 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL smoothstep-float function 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; + +function clamp(value, min, max) { + return Math.max(min, Math.min(value, max)); +} + +function smoothstep(edge0, edge1, value) { + var t = clamp((value - edge0) / (edge1 - edge0), 0, 1); + return t * t * (3 - 2 * t); +} + +GLSLGenerator.runReferenceImageTest({ + feature: "smoothstep", + args: "float edge0, float edge1, $(type) value", + testFunc: "$(func)(float, float, $(type))", + gridRes: 8, + tolerance: 4, + tests: [ + { + source: ["$(output) = vec4(", + " $(func)(0.3, 0.7, $(input).x),", + " $(func)(0.2, 0.8, $(input).y),", + " 0,", + " 1);"].join("\n"), + generator: function(x, y, z, w) { + return [ smoothstep(0.3, 0.7, x), + smoothstep(0.2, 0.8, y), + 0, + 1 ]; + }, + }, + { + source: [ "$(output) = vec4(", + " $(func)(0.4, 0.8, $(input).xy),", + " 0, 1);"].join("\n"), + generator: function(x, y, z, w) { + return [ smoothstep(0.4, 0.8, x), + smoothstep(0.4, 0.8, y), + 0, + 1 ]; + }, + }, + { + // FIXME: this test seems to need a higher tolerance when run in a vertex shader. + source: [ "$(output) = vec4(", + " $(func)(0.3, 0.7, $(input).xyz),", + " 1);"].join("\n"), + generator: function(x, y, z, w) { + return [ smoothstep(0.3, 0.7, x), + smoothstep(0.3, 0.7, y), + smoothstep(0.3, 0.7, z), + 1 ]; + }, + tolerance: 12, + fragmentTolerance: 3, + }, + { + // FIXME: this test seems to need a higher tolerance when run in a vertex shader. + source: ["$(output) = ", + " $(func)(0.3, 0.9, $(input));"].join("\n"), + generator: function(x, y, z, w) { + return [ smoothstep(0.3, 0.9, x), + smoothstep(0.3, 0.9, y), + smoothstep(0.3, 0.9, z), + smoothstep(0.3, 0.9, w) ]; + }, + tolerance: 7, + fragmentTolerance: 3, + }, + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-smoothstep-gentype.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-smoothstep-gentype.html new file mode 100644 index 0000000000..84c992ed64 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-smoothstep-gentype.html @@ -0,0 +1,56 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL smoothstep-gentype function 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; + +GLSLGenerator.runFeatureTest({ + feature: "smoothstep", + args: "$(type) edge0, $(type) edge1, $(type) value", + baseArgs: "edge0$(field), edge1$(field), value$(field)", + testFunc: "$(func)($(type), $(type), $(type))", + emuFunc: ["float $(func)_base(float edge0, float edge1, float value) {", + " float t = clamp((value - edge0) / (edge1 - edge0), 0.0, 1.0);", + " return t * t * (3.0 - 2.0 * t);", + "}"].join("\n"), + gridRes: 8, + tolerance: 1, + tests: [ + ["$(output) = vec4(", + " $(func)(0.3, 0.7, $(input).x),", + " $(func)(0.2, 0.8, $(input).y),", + " 0,", + " 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)(vec2(0.4, 0.6), vec2(0.8, 0.9), $(input).xy),", + " 0, 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)(vec3(0.3, 0.5, 0.7), vec3(0.7, 0.9, 1.0), $(input).xyz),", + " 1);"].join("\n"), + ["$(output) = ", + " $(func)(vec4(0.3, 0.4, 0.5, 0.2), ", + " vec4(0.7, 0.6, 0.9, 0.8), ", + " $(input));"].join("\n") + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-step-float.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-step-float.html new file mode 100644 index 0000000000..09f6e38612 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-step-float.html @@ -0,0 +1,52 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL step-float function 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +GLSLGenerator.runFeatureTest({ + feature: "step", + args: "float edge, $(type) value", + baseArgs: "edge, value$(field)", + testFunc: "$(func)(float, $(type))", + emuFunc: ["float $(func)_base(float edge, float value) {", + " return value < edge ? 0.0 : 1.0;", + "}"].join("\n"), + gridRes: 8, + tests: [ + ["$(output) = vec4(", + " $(func)(0.3, $(input).x),", + " $(func)(0.7, $(input).y),", + " 0,", + " 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)(0.4, $(input).xy),", + " 0, 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)(0.4, $(input).xyz),", + " 1);"].join("\n"), + ["$(output) = ", + " $(func)(0.4, $(input));"].join("\n") + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-step-gentype.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-step-gentype.html new file mode 100644 index 0000000000..8b267265f6 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function-step-gentype.html @@ -0,0 +1,51 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL step-gentype function 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +GLSLGenerator.runFeatureTest({ + feature: "step", + args: "$(type) edge, $(type) value", + baseArgs: "edge$(field), value$(field)", + testFunc: "$(func)($(type), $(type))", + emuFunc: ["float $(func)_base(float edge, float value) {", + " return value < edge ? 0.0 : 1.0;", + "}"].join("\n"), + gridRes: 8, + tests: [ + ["$(output) = vec4(", + " $(func)(0.3, $(input).x),", + " $(func)(0.7, $(input).y),", + " 0,", + " 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)(vec2(0.4, 0.6), $(input).xy),", + " 0, 1);"].join("\n"), + ["$(output) = vec4(", + " $(func)(vec3(0.3, 0.5, 0.7), $(input).xyz),", + " 1);"].join("\n"), + ["$(output) = ", + " $(func)( vec4(0.3, 0.4, 0.5, 0.2), $(input));"].join("\n") + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function.html new file mode 100644 index 0000000000..51acf0dae2 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/functions/glsl-function.html @@ -0,0 +1,39 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL function test 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +GLSLGenerator.runFeatureTest({ + feature: "the_GLSL_test_harness", + testFunc: "pass through", + emuFunc: "float $(func)_base(float value) { return 0.0; }", + gridRes: 4, + tests: [ + "$(output) = vec4($(input).x, 0, 0, 1);", + "$(output) = vec4(0, $(input).xy, 1);", + "$(output) = vec4($(input).xyz, 1);", + "$(output) = $(input);" + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/00_test_list.txt b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/00_test_list.txt new file mode 100644 index 0000000000..d700b29a56 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/00_test_list.txt @@ -0,0 +1,65 @@ +add_int_float.vert.html +add_int_mat2.vert.html +add_int_mat3.vert.html +add_int_mat4.vert.html +add_int_vec2.vert.html +add_int_vec3.vert.html +add_int_vec4.vert.html +add_ivec2_vec2.vert.html +add_ivec3_vec3.vert.html +add_ivec4_vec4.vert.html +assign_int_to_float.vert.html +assign_ivec2_to_vec2.vert.html +assign_ivec3_to_vec3.vert.html +assign_ivec4_to_vec4.vert.html +construct_struct.vert.html +divide_int_float.vert.html +divide_int_mat2.vert.html +divide_int_mat3.vert.html +divide_int_mat4.vert.html +divide_int_vec2.vert.html +divide_int_vec3.vert.html +divide_int_vec4.vert.html +divide_ivec2_vec2.vert.html +divide_ivec3_vec3.vert.html +divide_ivec4_vec4.vert.html +equal_int_float.vert.html +equal_ivec2_vec2.vert.html +equal_ivec3_vec3.vert.html +equal_ivec4_vec4.vert.html +function_int_float.vert.html +function_ivec2_vec2.vert.html +function_ivec3_vec3.vert.html +function_ivec4_vec4.vert.html +greater_than.vert.html +greater_than_equal.vert.html +less_than.vert.html +less_than_equal.vert.html +multiply_int_float.vert.html +multiply_int_mat2.vert.html +multiply_int_mat3.vert.html +multiply_int_mat4.vert.html +multiply_int_vec2.vert.html +multiply_int_vec3.vert.html +multiply_int_vec4.vert.html +multiply_ivec2_vec2.vert.html +multiply_ivec3_vec3.vert.html +multiply_ivec4_vec4.vert.html +not_equal_int_float.vert.html +not_equal_ivec2_vec2.vert.html +not_equal_ivec3_vec3.vert.html +not_equal_ivec4_vec4.vert.html +subtract_int_float.vert.html +subtract_int_mat2.vert.html +subtract_int_mat3.vert.html +subtract_int_mat4.vert.html +subtract_int_vec2.vert.html +subtract_int_vec3.vert.html +subtract_int_vec4.vert.html +subtract_ivec2_vec2.vert.html +subtract_ivec3_vec3.vert.html +subtract_ivec4_vec4.vert.html +ternary_int_float.vert.html +ternary_ivec2_vec2.vert.html +ternary_ivec3_vec3.vert.html +ternary_ivec4_vec4.vert.html diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/add_int_float.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/add_int_float.vert.html new file mode 100644 index 0000000000..6805834dcd --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/add_int_float.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast adding integer to float should fail +void main() +{ + float f = 1.0 + 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/add_int_mat2.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/add_int_mat2.vert.html new file mode 100644 index 0000000000..89eed34cc1 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/add_int_mat2.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast adding integer to mat2 should fail +void main() +{ + mat2 f = mat2(1.0) + 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/add_int_mat3.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/add_int_mat3.vert.html new file mode 100644 index 0000000000..6a921d4012 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/add_int_mat3.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast adding integer to mat3 should fail +void main() +{ + mat3 f = mat3(1.0) + 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/add_int_mat4.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/add_int_mat4.vert.html new file mode 100644 index 0000000000..17c134d096 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/add_int_mat4.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast adding integer to mat4 should fail +void main() +{ + mat4 f = mat4(1.0) + 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/add_int_vec2.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/add_int_vec2.vert.html new file mode 100644 index 0000000000..d985b77e74 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/add_int_vec2.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast adding integer to vec2 should fail +void main() +{ + vec2 f = vec2(1.0, 2.0) + 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/add_int_vec3.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/add_int_vec3.vert.html new file mode 100644 index 0000000000..2db9028769 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/add_int_vec3.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast adding integer to vec3 should fail +void main() +{ + vec3 f = vec3(1.0, 2.0, 3.0) + 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/add_int_vec4.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/add_int_vec4.vert.html new file mode 100644 index 0000000000..6cca2d9887 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/add_int_vec4.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast adding integer to vec4 should fail +void main() +{ + vec4 f = vec4(1.0, 2.0, 3.0, 4.0) + 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/add_ivec2_vec2.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/add_ivec2_vec2.vert.html new file mode 100644 index 0000000000..86cd54eb5d --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/add_ivec2_vec2.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast adding ivec2 to vec2 should fail +void main() +{ + vec2 f = vec2(1.0, 2.0) + ivec2(1, 2); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/add_ivec3_vec3.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/add_ivec3_vec3.vert.html new file mode 100644 index 0000000000..dfcbe64110 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/add_ivec3_vec3.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast adding ivec3 to vec3 should fail +void main() +{ + vec3 f = vec3(1.0, 2.0, 3.0) + ivec3(1, 2, 3); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/add_ivec4_vec4.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/add_ivec4_vec4.vert.html new file mode 100644 index 0000000000..54c55be4f4 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/add_ivec4_vec4.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast adding ivec4 to vec4 should fail +void main() +{ + vec4 f = vec4(1.0, 2.0, 3.0, 4.0) + ivec4(1, 2, 3, 4); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/assign_int_to_float.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/assign_int_to_float.vert.html new file mode 100644 index 0000000000..d3f835e218 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/assign_int_to_float.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast assing int to float should fail +void main() +{ + float f = -123; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/assign_ivec2_to_vec2.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/assign_ivec2_to_vec2.vert.html new file mode 100644 index 0000000000..ccaed7e041 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/assign_ivec2_to_vec2.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast assigning ivec2 to vec2 should fail +void main() +{ + vec2 f = ivec2(1, 2); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/assign_ivec3_to_vec3.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/assign_ivec3_to_vec3.vert.html new file mode 100644 index 0000000000..35f0ee4029 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/assign_ivec3_to_vec3.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast assigning ivec3 to vec3 should fail +void main() +{ + vec3 f = ivec3(1, 2, 3); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/assign_ivec4_to_vec4.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/assign_ivec4_to_vec4.vert.html new file mode 100644 index 0000000000..8745a50f50 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/assign_ivec4_to_vec4.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast assigning ivec4 to vec4 should fail +void main() +{ + vec4 f = ivec4(1, 2, 3, 4); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/construct_struct.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/construct_struct.vert.html new file mode 100644 index 0000000000..c62dc731f3 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/construct_struct.vert.html @@ -0,0 +1,40 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast from int to float in struct initializer should fail +struct Foo { + float bar; +}; + +void main() { + Foo foo = Foo(1); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/divide_int_float.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/divide_int_float.vert.html new file mode 100644 index 0000000000..902b2e9669 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/divide_int_float.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of float divided by int should fail +void main() +{ + float f = 1.0 / 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/divide_int_mat2.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/divide_int_mat2.vert.html new file mode 100644 index 0000000000..ac7a547249 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/divide_int_mat2.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of mat2 divided by int should fail +void main() +{ + mat2 f = mat2(1.0) / 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/divide_int_mat3.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/divide_int_mat3.vert.html new file mode 100644 index 0000000000..2ad85937a2 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/divide_int_mat3.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of mat3 divided by int should fail +void main() +{ + mat3 f = mat3(1.0) / 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/divide_int_mat4.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/divide_int_mat4.vert.html new file mode 100644 index 0000000000..df22909191 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/divide_int_mat4.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of mat4 divided by int should fail +void main() +{ + mat4 f = mat4(1.0) / 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/divide_int_vec2.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/divide_int_vec2.vert.html new file mode 100644 index 0000000000..545ca3e341 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/divide_int_vec2.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of vec2 divided by int should fail +void main() +{ + vec2 f = vec2(1.0, 2.0) / 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/divide_int_vec3.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/divide_int_vec3.vert.html new file mode 100644 index 0000000000..fa80b9836a --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/divide_int_vec3.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of vec3 divided by int should fail +void main() +{ + vec3 f = vec3(1.0, 2.0, 3.0) / 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/divide_int_vec4.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/divide_int_vec4.vert.html new file mode 100644 index 0000000000..136de073c1 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/divide_int_vec4.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of vec4 divided by int should fail +void main() +{ + vec4 f = vec4(1.0, 2.0, 3.0, 4.0) / 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/divide_ivec2_vec2.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/divide_ivec2_vec2.vert.html new file mode 100644 index 0000000000..de88cd680b --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/divide_ivec2_vec2.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of vec2 divided by ivec2 should fail +void main() +{ + vec2 f = vec2(1.0, 2.0) / ivec2(1, 2); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/divide_ivec3_vec3.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/divide_ivec3_vec3.vert.html new file mode 100644 index 0000000000..99e8a69a09 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/divide_ivec3_vec3.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of vec3 divided by ivec3 should fail +void main() +{ + vec3 f = vec3(1.0, 2.0, 3.0) / ivec3(1, 2, 3); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/divide_ivec4_vec4.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/divide_ivec4_vec4.vert.html new file mode 100644 index 0000000000..2039ba9e1c --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/divide_ivec4_vec4.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of vec4 divided by ivec4 should fail +void main() +{ + vec4 f = vec4(1.0, 2.0, 3.0, 4.0) / ivec4(1, 2, 3, 4); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/equal_int_float.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/equal_int_float.vert.html new file mode 100644 index 0000000000..ebfdb6ae54 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/equal_int_float.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of int to float in comparision should fail +void main() +{ + bool b = 1.0 == 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/equal_ivec2_vec2.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/equal_ivec2_vec2.vert.html new file mode 100644 index 0000000000..8d16edde32 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/equal_ivec2_vec2.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of ivec2 to vec2 in comparision should fail +void main() +{ + bool b = vec2(1.0, 2.0) == ivec2(1, 2); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/equal_ivec3_vec3.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/equal_ivec3_vec3.vert.html new file mode 100644 index 0000000000..a6951cb77f --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/equal_ivec3_vec3.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of ivec3 to vec3 in comparision should fail +void main() +{ + bool b = vec3(1.0, 2.0, 3.0) == ivec3(1, 2, 3); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/equal_ivec4_vec4.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/equal_ivec4_vec4.vert.html new file mode 100644 index 0000000000..39bdbafee2 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/equal_ivec4_vec4.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of ivec4 to vec4 in comparision should fail +void main() +{ + bool b = vec4(1.0, 2.0, 3.0, 4.0) == ivec4(1, 2, 3, 4); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/function_int_float.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/function_int_float.vert.html new file mode 100644 index 0000000000..0a20eeab37 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/function_int_float.vert.html @@ -0,0 +1,40 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of int to float in function argument should fail +float foo(float f) { + return f; +} + +void main() { + float f = foo(1); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/function_ivec2_vec2.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/function_ivec2_vec2.vert.html new file mode 100644 index 0000000000..d4401c25c9 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/function_ivec2_vec2.vert.html @@ -0,0 +1,40 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of ivec2 to vec2 in function argument should fail +vec2 foo(vec2 f) { + return f; +} + +void main() { + vec2 f = foo(ivec2(1, 2)); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/function_ivec3_vec3.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/function_ivec3_vec3.vert.html new file mode 100644 index 0000000000..1658ac5de8 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/function_ivec3_vec3.vert.html @@ -0,0 +1,40 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of ivec3 to vec3 in function argument should fail +vec3 foo(vec3 f) { + return f; +} + +void main() { + vec3 f = foo(ivec3(1, 2, 3)); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/function_ivec4_vec4.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/function_ivec4_vec4.vert.html new file mode 100644 index 0000000000..87e49c503d --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/function_ivec4_vec4.vert.html @@ -0,0 +1,40 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of ivec4 to vec4 in function argument should fail +vec4 foo(vec4 f) { + return f; +} + +void main() { + vec4 f = foo(ivec4(1, 2, 3, 4)); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/greater_than.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/greater_than.vert.html new file mode 100644 index 0000000000..73c2164a08 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/greater_than.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of int to float with greater than should fail +void main() +{ + bool b = 1.0 > 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/greater_than_equal.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/greater_than_equal.vert.html new file mode 100644 index 0000000000..58dfe5ed77 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/greater_than_equal.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of int to float with greater than or equal to should fail +void main() +{ + bool b = 1.0 >= 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/less_than.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/less_than.vert.html new file mode 100644 index 0000000000..c1addc6316 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/less_than.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of int to float with less than should fail +void main() +{ + bool b = 1.0 < 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/less_than_equal.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/less_than_equal.vert.html new file mode 100644 index 0000000000..a4a7573e40 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/less_than_equal.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of int to float with less than or equal to should fail +void main() +{ + bool b = 1.0 <= 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/multiply_int_float.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/multiply_int_float.vert.html new file mode 100644 index 0000000000..5e14dba1af --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/multiply_int_float.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of int to float in multiply should fail +void main() +{ + float f = 1.0 * 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/multiply_int_mat2.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/multiply_int_mat2.vert.html new file mode 100644 index 0000000000..36ec2ae995 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/multiply_int_mat2.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of int to mat2 in multiply should fail +void main() +{ + mat2 f = mat2(1.0) * 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/multiply_int_mat3.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/multiply_int_mat3.vert.html new file mode 100644 index 0000000000..a44379ccd7 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/multiply_int_mat3.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of int to mat3 in multiply should fail +void main() +{ + mat3 f = mat3(1.0) * 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/multiply_int_mat4.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/multiply_int_mat4.vert.html new file mode 100644 index 0000000000..f33d147f36 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/multiply_int_mat4.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of int to mat4 in multiply should fail +void main() +{ + mat4 f = mat4(1.0) * 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/multiply_int_vec2.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/multiply_int_vec2.vert.html new file mode 100644 index 0000000000..ff83c9a657 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/multiply_int_vec2.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of int to vec2 in multiply should fail +void main() +{ + vec2 f = vec2(1.0, 2.0) * 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/multiply_int_vec3.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/multiply_int_vec3.vert.html new file mode 100644 index 0000000000..a39872f21f --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/multiply_int_vec3.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of int to vec3 in multiply should fail +void main() +{ + vec3 f = vec3(1.0, 2.0, 3.0) * 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/multiply_int_vec4.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/multiply_int_vec4.vert.html new file mode 100644 index 0000000000..8543b6d410 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/multiply_int_vec4.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of int to vec4 in multiply should fail +void main() +{ + vec4 f = vec4(1.0, 2.0, 3.0, 4.0) * 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/multiply_ivec2_vec2.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/multiply_ivec2_vec2.vert.html new file mode 100644 index 0000000000..03d797a333 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/multiply_ivec2_vec2.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of ivec2 to vec2 in multiply should fail +void main() +{ + vec2 f = vec2(1.0, 2.0) * ivec2(1, 2); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/multiply_ivec3_vec3.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/multiply_ivec3_vec3.vert.html new file mode 100644 index 0000000000..92951c42f6 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/multiply_ivec3_vec3.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of ivec3 to vec3 in multiply should fail +void main() +{ + vec3 f = vec3(1.0, 2.0, 3.0) * ivec3(1, 2, 3); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/multiply_ivec4_vec4.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/multiply_ivec4_vec4.vert.html new file mode 100644 index 0000000000..c5b3ce4741 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/multiply_ivec4_vec4.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of ivec4 to vec4 in multiply should fail +void main() +{ + vec4 f = vec4(1.0, 2.0, 3.0, 4.0) * ivec4(1, 2, 3, 4); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/not_equal_int_float.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/not_equal_int_float.vert.html new file mode 100644 index 0000000000..9a87af0ae4 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/not_equal_int_float.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of int to float in not equal comparison should fail +void main() +{ + bool b = 1.0 != 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/not_equal_ivec2_vec2.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/not_equal_ivec2_vec2.vert.html new file mode 100644 index 0000000000..81984c9cca --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/not_equal_ivec2_vec2.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of ivec2 to vec2 in not equal comparison should fail +void main() +{ + bool b = vec2(1.0, 2.0) != ivec2(1, 2); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/not_equal_ivec3_vec3.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/not_equal_ivec3_vec3.vert.html new file mode 100644 index 0000000000..3b1acc1527 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/not_equal_ivec3_vec3.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of ivec3 to vec3 in not equal comparison should fail +void main() +{ + bool b = vec3(1.0, 2.0, 3.0) != ivec3(1, 2, 3); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/not_equal_ivec4_vec4.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/not_equal_ivec4_vec4.vert.html new file mode 100644 index 0000000000..a28210486c --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/not_equal_ivec4_vec4.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of ivec4 to vec4 in not equal comparison should fail +void main() +{ + bool b = vec4(1.0, 2.0, 3.0, 4.0) != ivec4(1, 2, 3, 4); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/subtract_int_float.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/subtract_int_float.vert.html new file mode 100644 index 0000000000..0a9ee88498 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/subtract_int_float.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of int to float in subtraction should fail +void main() +{ + float f = 1.0 - 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/subtract_int_mat2.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/subtract_int_mat2.vert.html new file mode 100644 index 0000000000..c6ac5e3fc0 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/subtract_int_mat2.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of int to mat2 in subtraction should fail +void main() +{ + mat2 f = mat2(1.0) - 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/subtract_int_mat3.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/subtract_int_mat3.vert.html new file mode 100644 index 0000000000..bb04a9094b --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/subtract_int_mat3.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of int to mat3 in subtraction should fail +void main() +{ + mat3 f = mat3(1.0) - 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/subtract_int_mat4.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/subtract_int_mat4.vert.html new file mode 100644 index 0000000000..e1dc2807b6 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/subtract_int_mat4.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of int to mat4 in subtraction should fail +void main() +{ + mat4 f = mat4(1.0) - 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/subtract_int_vec2.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/subtract_int_vec2.vert.html new file mode 100644 index 0000000000..0a89e5f4e4 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/subtract_int_vec2.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of int to vec2 in subtraction should fail +void main() +{ + vec2 f = vec2(1.0, 2.0) - 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/subtract_int_vec3.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/subtract_int_vec3.vert.html new file mode 100644 index 0000000000..ec0fdc673b --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/subtract_int_vec3.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of int to vec3 in subtraction should fail +void main() +{ + vec3 f = vec3(1.0, 2.0, 3.0) - 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/subtract_int_vec4.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/subtract_int_vec4.vert.html new file mode 100644 index 0000000000..fc53e4ae55 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/subtract_int_vec4.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of int to vec4 in subtraction should fail +void main() +{ + vec4 f = vec4(1.0, 2.0, 3.0, 4.0) - 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/subtract_ivec2_vec2.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/subtract_ivec2_vec2.vert.html new file mode 100644 index 0000000000..770384258a --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/subtract_ivec2_vec2.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of ivec2 to vec2 in subtraction should fail +void main() +{ + vec2 f = vec2(1.0, 2.0) - ivec2(1, 2); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/subtract_ivec3_vec3.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/subtract_ivec3_vec3.vert.html new file mode 100644 index 0000000000..1203b09a3a --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/subtract_ivec3_vec3.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of ivec3 to vec3 in subtraction should fail +void main() +{ + vec3 f = vec3(1.0, 2.0, 3.0) - ivec3(1, 2, 3); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/subtract_ivec4_vec4.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/subtract_ivec4_vec4.vert.html new file mode 100644 index 0000000000..e440bec91f --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/subtract_ivec4_vec4.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of ivec4 to vec4 in subtraction should fail +void main() +{ + vec4 f = vec4(1.0, 2.0, 3.0, 4.0) - ivec4(1, 2, 3, 4); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/ternary_int_float.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/ternary_int_float.vert.html new file mode 100644 index 0000000000..7898bb92e8 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/ternary_int_float.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of int to float in ternary expression should fail +void main() +{ + float f = true ? 1.0 : 1; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/ternary_ivec2_vec2.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/ternary_ivec2_vec2.vert.html new file mode 100644 index 0000000000..08dca0cc02 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/ternary_ivec2_vec2.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of ivec2 to vec2 in ternary expression should fail +void main() +{ + vec2 f = true ? vec2(1.0, 2.0) : ivec2(1, 2); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/ternary_ivec3_vec3.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/ternary_ivec3_vec3.vert.html new file mode 100644 index 0000000000..a281e59296 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/ternary_ivec3_vec3.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of ivec3 to vec3 in ternary expression should fail +void main() +{ + vec3 f = true ? vec3(1.0, 2.0, 3.0) : ivec3(1, 2, 3); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/ternary_ivec4_vec4.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/ternary_ivec4_vec4.vert.html new file mode 100644 index 0000000000..ba2b669b8f --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/implicit/ternary_ivec4_vec4.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// implicit cast of ivec4 to vec4 in ternary expression should fail +void main() +{ + vec4 f = true ? vec4(1.0, 2.0, 3.0, 4.0) : ivec4(1, 2, 3, 4); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/literals/00_test_list.txt b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/literals/00_test_list.txt new file mode 100644 index 0000000000..50802bf346 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/literals/00_test_list.txt @@ -0,0 +1,3 @@ +float_literal.vert.html +--min-version 1.0.3 literal_precision.html +overflow_leak.vert.html diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/literals/float_literal.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/literals/float_literal.vert.html new file mode 100644 index 0000000000..86bbf8a883 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/literals/float_literal.vert.html @@ -0,0 +1,51 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// parsing floating point literals should succeed +void main() { + float zero = 0.0; + float fractionalConstant = 1.0; + float fractionalConstantExponent = 1.0e1; + float fractionalConstantPosExponent = 1.0e+1; + float fractionalConstantNegExponent = 1.0e-1; + float digitSequenceExponent = 1e1; + float digitSequencePosExponent = 1e+1; + float digitSequenceNegExponent = 1e-1; + float pointDigit = .1; + float digitPoint= 1.; + float upperCaseExponent = 1.0E1; + highp float posInRange = 4611686018427387903.; // 2^62 - 1 + highp float posOutRange = 4611686018427387905.; // 2^62 + 1 + highp float posHuge = 1E100; + highp float negInRange = -4611686018427387903.; + highp float negOutRange = -4611686018427387905.; + highp float negHuge = -1E100; + gl_Position = 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/literals/literal_precision.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/literals/literal_precision.html new file mode 100644 index 0000000000..c2ccbbe1ce --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/literals/literal_precision.html @@ -0,0 +1,35 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// parsing floating point literals with precision should fail +void main() { + mediump float zero = mediump 0.0; + gl_Position = vec4(zero, 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/literals/overflow_leak.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/literals/overflow_leak.vert.html new file mode 100644 index 0000000000..b11960dd5f --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/literals/overflow_leak.vert.html @@ -0,0 +1,61 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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> +<canvas id="example" width="2" height="2"> </canvas> +<script id="vshader" type="x-shader/x-vertex"> +// float literal overflow should not affect next literal parsing. +precision mediump float; + +varying vec4 v_color; +attribute vec4 a_position; +void main() { + highp float floatOverflow = 1E100; + int i = 10; + if (i == 10) + v_color = vec4(0.0, 1.0, 0.0, 1.0); + else + v_color = vec4(1.0, 0.0, 0.0, 1.0); + gl_Position = a_position; +} +</script> +<script id="fshader" type="x-shader/x-fragment"> +precision mediump float; + +varying vec4 v_color; +void main() { + gl_FragColor = v_color; +} +</script> +<script> +"use strict"; +description(); +var wtu = WebGLTestUtils; +var gl = wtu.create3DContext("example"); +wtu.setupUnitQuad(gl); +var program = wtu.setupProgram(gl, ["vshader", "fshader"]); +if (!program) + testFailed("Fail to setup program"); +wtu.clearAndDrawUnitQuad(gl); +wtu.checkCanvas(gl, [0, 255, 0, 255], "should be green"); + +var successfullyParsed = true; +</script> +<script src="../../../js/js-test-post.js"></script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/matrices/00_test_list.txt b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/matrices/00_test_list.txt new file mode 100644 index 0000000000..74693de0ea --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/matrices/00_test_list.txt @@ -0,0 +1,3 @@ +glsl-mat4-to-mat3.html +--min-version 1.0.3 glsl-mat3-construction.html +--min-version 1.0.4 matrix-compound-multiply.html diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/matrices/glsl-mat3-construction.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/matrices/glsl-mat3-construction.html new file mode 100644 index 0000000000..bca1bdb706 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/matrices/glsl-mat3-construction.html @@ -0,0 +1,72 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL mat3 construction 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script id="shader_emu" type="something-not-js"> +mat3 mat3_emu(vec3 v3_0, vec3 v3_1, vec3 v3_2) { + mat3 test; + test[0] = v3_0; + test[1] = v3_1; + test[2] = v3_2; + return test; +} +</script> +<script id="shader_test" type="something-not-js"> + vec3 v3 = vec3($(input).xyz); + mat3 m3 = $(conversion)(v3, v3, v3); + vec3 c; + if ($(input).y < 0.33) { + c = m3[0]; + } else if ($(input).y > 0.66) { + c = m3[1]; + } else { + c = m3[2]; + } + $(output) = vec4(c, 1); +</script> +<script> +"use strict"; +// See resources glsl-generator runBasicTest for how this works +var wtu = WebGLTestUtils; +GLSLGenerator.runBasicTest({ + gridRes: 8, + tests: [ + { + name: "vec3 to mat3", + reference: { + shader: wtu.getScript("shader_test"), + subs: { + emu: wtu.getScript("shader_emu"), + conversion: "mat3_emu" + } + }, + test: { + shader: wtu.getScript("shader_test"), + subs: { + conversion: "mat3" + }, + } + } + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/matrices/glsl-mat4-to-mat3.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/matrices/glsl-mat4-to-mat3.html new file mode 100644 index 0000000000..4716c630cb --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/matrices/glsl-mat4-to-mat3.html @@ -0,0 +1,70 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL mat4 to mat3 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-generator.js"> </script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script id="shader_emu" type="something-not-js"> +mat3 mat3_emu(mat4 m4) { + return mat3( + m4[0][0], m4[0][1], m4[0][2], + m4[1][0], m4[1][1], m4[1][2], + m4[2][0], m4[2][1], m4[2][2]); +} +</script> +<script id="shader_test" type="something-not-js"> + mat4 m4 = mat4($(input), $(input).yzwx, $(input).zwxy, $(input).wxyz); + mat3 m3 = $(conversion)(m4); + vec3 c; + if ($(input).y < 0.33) { + c = m3[0]; + } else if ($(input).y > 0.66) { + c = m3[1]; + } else { + c = m3[2]; + } + $(output) = vec4(c, 1); +</script> +<script> +"use strict"; +// See resources glsl-generator runBasicTest for how this works +var wtu = WebGLTestUtils; +GLSLGenerator.runBasicTest({ + gridRes: 8, + tests: [ + { + name: "mat4 to mat3", + reference: { + shader: wtu.getScript("shader_test"), + subs: { + emu: wtu.getScript("shader_emu"), + conversion: "mat3_emu" + } + }, + test: { + shader: wtu.getScript("shader_test"), + subs: { + conversion: "mat3" + }, + } + } + ] +}); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/matrices/matrix-compound-multiply.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/matrices/matrix-compound-multiply.html new file mode 100644 index 0000000000..a485160c56 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/matrices/matrix-compound-multiply.html @@ -0,0 +1,71 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Matrix compound multiplication 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="canvas" width="256" height="256"> </canvas> +<div id="description"></div> +<div id="console"></div> +<script id="vshader" type="x-shader/x-vertex"> +attribute vec3 aPosition; + +void main() { + gl_Position = vec4(aPosition, 1); +} +</script> +<script id="fshader" type="x-shader/x-fragment"> +precision mediump float; + +void main() { + $(type) a = $(type)(0.0); + $(type) b = $(type)(0.0); + a[1][1] = 3.0; // 2nd column, 2nd row + b[0][1] = 2.0; // 1st column, 2nd row + $(type) c = a * b; + a *= b; + $(type) diffMat = a - c; + float diff = length(diffMat[0]) + length(diffMat[1]); + gl_FragColor = vec4(0.0, diff < 0.01 ? 1.0 : 0.0, 0.0, 1.0); +} +</script> +<script type="application/javascript"> +"use strict"; +description("Matrix compound multiplication test comparing against normal multiplication."); +debug(""); +var wtu = WebGLTestUtils; +function test() { + var gl = wtu.create3DContext("canvas"); + if (!gl) { + testFailed("context does not exist"); + return; + } + wtu.setupUnitQuad(gl); + var fshaderTemplate = wtu.getScript('fshader'); + + var types = ['mat2', 'mat3', 'mat4']; + for (var i = 0; i < types.length; ++i) { + debug(''); + debug('Testing type ' + types[i]); + var fshaderSource = wtu.replaceParams(fshaderTemplate, {type: types[i]}); + var program = wtu.setupProgram(gl, ['vshader', fshaderSource], ["aPosition"], undefined, true); + wtu.drawUnitQuad(gl); + wtu.checkCanvas(gl, [0, 255, 0, 255], 'should be green'); + } +}; + +test(); +finishTest(); +</script> +</body> +</html> 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 0000000000..c60310df14 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/00_test_list.txt @@ -0,0 +1,126 @@ +--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 +--min-version 1.0.4 fragcolor-fragdata-invariant.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 +--min-version 1.0.4 local-variable-shadowing-outer-function.html +non-ascii-comments.vert.html +non-ascii.vert.html +--min-version 1.0.2 re-compile-re-link.html +--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-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-1-of-8.html +--min-version 1.0.2 shader-with-non-reserved-words-2-of-8.html +--min-version 1.0.2 shader-with-non-reserved-words-3-of-8.html +--min-version 1.0.2 shader-with-non-reserved-words-4-of-8.html +--min-version 1.0.2 shader-with-non-reserved-words-5-of-8.html +--min-version 1.0.2 shader-with-non-reserved-words-6-of-8.html +--min-version 1.0.2 shader-with-non-reserved-words-7-of-8.html +--min-version 1.0.2 shader-with-non-reserved-words-8-of-8.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 +--min-version 1.0.4 struct-as-inout-parameter.html +--min-version 1.0.4 struct-as-out-parameter.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 +--min-version 1.0.4 uninitialized-local-global-variables.html +--min-version 1.0.4 sampler-operand.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 0000000000..1f18a2309b --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/attrib-location-length-limits.html @@ -0,0 +1,89 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> +<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 0000000000..da0c55a164 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/boolean_precision.html @@ -0,0 +1,72 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..f9d8be7f70 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/const-variable-initialization.html @@ -0,0 +1,244 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..dc945fe2c6 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/embedded-struct-definitions-forbidden.html @@ -0,0 +1,41 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..785180f7e8 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/empty-declaration.html @@ -0,0 +1,111 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..b8c308d2d9 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/empty_main.vert.html @@ -0,0 +1,33 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..3db79d94e5 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/expression-list-in-declarator-initializer.html @@ -0,0 +1,68 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> +<!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/fragcolor-fragdata-invariant.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/fragcolor-fragdata-invariant.html new file mode 100644 index 0000000000..d936872514 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/fragcolor-fragdata-invariant.html @@ -0,0 +1,40 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests - gl_FragColor and gl_FragData both declared as invariant</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"> +// Declaring both gl_FragColor and gl_FragData invariant should succeed. +precision mediump float; + +// Static write of both gl_FragColor and gl_FragData is disallowed. However, simply declaring a variable invariant is not really accessing the variable, so it should be ok. +invariant gl_FragColor; +invariant gl_FragData; + +void main() +{ + 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/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 0000000000..6e462c123a --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/gl_position_unset.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..99e7417f69 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/global-variable-init.html @@ -0,0 +1,323 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 id="builtInConstant" type="x-shader/x-fragment"> +precision mediump float; +int i = gl_MaxFragmentUniformVectors; + +void main() { + float green = (i > 0) ? 1.0 : 0.0; + gl_FragColor = vec4(0.0, green, 0.0, 1.0); +} +</script> +<script id="builtInNonConstant" type="x-shader/x-fragment"> +precision mediump float; +vec4 v = gl_FragCoord; + +void main() { + gl_FragColor = v; +} +</script> +<script type="application/javascript"> +"use strict"; +description(); +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." + }, + { + fShaderId: "builtInConstant", + fShaderSuccess: true, + linkSuccess: true, + render: true, + passMsg: "Referencing a built-in constant in a global variable initializer should be accepted by WebGL." + }, + { + fShaderId: "builtInNonConstant", + fShaderSuccess: false, + linkSuccess: false, + passMsg: "Referencing a built-in non-constant in a global variable initializer should not be accepted by WebGL." + } +]); +var successfullyParsed = true; +</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 0000000000..1e8aebde39 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/glsl-2types-of-textures-on-same-unit.html @@ -0,0 +1,132 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..566356fc43 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/glsl-function-nodes.html @@ -0,0 +1,134 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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-vertex-branch.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/glsl-vertex-branch.html new file mode 100644 index 0000000000..dee3597546 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/glsl-vertex-branch.html @@ -0,0 +1,128 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..50970e6ccf --- /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 0000000000..1f096ec30f --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/large-loop-compile.html @@ -0,0 +1,172 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"); + const timeString = `${endTime - startTime} ms`; + if (endTime - startTime < 7500) { + testPassed("Shader compilation completed in a reasonable amount of time: " + timeString); + } else { + testFailed("Shader compilation took an unreasonably long time: " + timeString); + } + } + finishTest(); + }, 500); +} +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/local-variable-shadowing-outer-function.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/local-variable-shadowing-outer-function.html new file mode 100644 index 0000000000..4fb814c0d9 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/local-variable-shadowing-outer-function.html @@ -0,0 +1,59 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Test - Local Variable Shadowing Outer Function</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<link rel="stylesheet" href="../../../resources/glsl-feature-tests.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script src="../../../js/glsl-conformance-test.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script id="vertexShader" type="text/something-not-javascript"> +// vertex shader must succeed +attribute vec3 vertex; +varying float interp; +void main() { + interp = vertex.x; + gl_Position = vec4(vertex, 1.0); +} +</script> +<script id="fragmentShader" type="text/something-not-javascript"> +// local variable shadowing outer function definition must succeed +precision mediump float; + +varying float interp; + +float rsquared(float radius) +{ + return radius * radius; +} + +void some_computation(float radius, out float bsdf) { + bsdf = 0.0; + float rsquared = rsquared(radius); + bsdf += rsquared; +} + +void main() { + float comp; + some_computation(interp, comp); + gl_FragColor = vec4(comp, 0.0, 0.0, 1.0); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> 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 0000000000..14d807ed71 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/non-ascii-comments.vert.html @@ -0,0 +1,54 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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/plain"> +Loading... +</script> +<script> +"use strict"; + +// Via `[].map.call(str, x => x.codePointAt(0));` +let a = [12371,12428,12399,65313,65331,65315,65321,65321,12391,12399,12394,12356,12391,12377,12290]; +let b = [65332,65352,65353,65363,12288,65321,65363,12288,65326,65359,65364,12288,65313,65331,65315,65321,65321]; +a = String.fromCodePoint(...a); +b = String.fromCodePoint(...b); + +// - + +vertexShader.textContent = ` +// Non ascii comments in source should succeed +// ${a} +// ${b} +/* + * ${b} + */ +#define TEST 1 // ${b} +void main() { + gl_Position = vec4(1,1,1,1); // ${b} +} // ${b} +`; + +// - + +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 0000000000..7cc05b9354 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/non-ascii.vert.html @@ -0,0 +1,54 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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/plain"> +Loading... +</script> +<script> +"use strict"; + +// Via `[].map.call(str, x => x.codePointAt(0));` +let a = [12371,12428,12399,65313,65331,65315,65321,65321,12391,12399,12394,12356,12391,12377,12290]; +let b = [65332,65352,65353,65363,12288,65321,65363,12288,65326,65359,65364,12288,65313,65331,65315,65321,65321]; +let c = [65326,65359,65364,65313,65331,65315,65321,65321]; +a = String.fromCodePoint(...a); +b = String.fromCodePoint(...b); +c = String.fromCodePoint(...c); + +// - + +vertexShader.textContent = ` +// Non ascii data in source should fail +// See GLSL ES Spec 1.0.17 section 3.1 and 3.2 +// ${a} +// ${b} +uniform mat4 ${c}; +void main() { + gl_Position = vec4(1,1,1,1); +} +`; + +// - + +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 0000000000..caed432120 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/re-compile-re-link.html @@ -0,0 +1,150 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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(shader)); + } +} + +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/sampler-operand.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/sampler-operand.html new file mode 100644 index 0000000000..4b6d6c0bad --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/sampler-operand.html @@ -0,0 +1,51 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests - sampler operands</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<link rel="stylesheet" href="../../../resources/glsl-feature-tests.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script src="../../../js/glsl-conformance-test.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> + +<script> +// ESSL(1.00, 3.00, 3.10) section 4.1.7 +// Except for array indexing, structure field selection, and +// parentheses, samplers are not allowed to be operands in expressions. +</script> + +<script id="samplerAdding" type="x-shader/x-fragment"> +// This covers an ANGLE bug. +// See https://bugs.chromium.org/p/angleproject/issues/detail?id=2028. +uniform sampler2D s1; +uniform sampler2D s2; +void main() { + s1 + s2; +} +</script> + +<script> +"use strict"; +GLSLConformanceTester.runTests([ + { fShaderId: 'samplerAdding', + fShaderSuccess: false, + linkSuccess: false, + passMsg: 'Adding on samplers should fail' + }, +]); + +var successfullyParsed = true; +</script> +</body> +</html> 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 0000000000..8ea601f719 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/sequence-operator-returns-constant.html @@ -0,0 +1,60 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..4574846469 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-precision-format-obeyed.html @@ -0,0 +1,83 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..a04faf03b1 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-struct-scope.html @@ -0,0 +1,231 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!-- 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 0000000000..22a968470f --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-uniform-packing-restrictions.html @@ -0,0 +1,251 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..741ad7b63f --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-varying-packing-restrictions.html @@ -0,0 +1,188 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..9ed15009b5 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-256-character-define.html @@ -0,0 +1,36 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..66112ded1d --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-256-character-identifier.frag.html @@ -0,0 +1,105 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..0d43c280e4 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-257-character-define.html @@ -0,0 +1,36 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..e3b70e99e8 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-257-character-identifier.frag.html @@ -0,0 +1,36 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..cbd2191902 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-_webgl-identifier.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..778375dc01 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-arbitrary-indexing.frag.html @@ -0,0 +1,41 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..eedbf67244 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-arbitrary-indexing.vert.html @@ -0,0 +1,40 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..e4acce11fc --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-array-of-structs-containing-arrays.html @@ -0,0 +1,133 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..87560e3e70 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-array-of-structs-uniform.html @@ -0,0 +1,145 @@ + +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..14b1ffb189 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-attrib-array.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..f8069d11b2 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-attrib-struct.vert.html @@ -0,0 +1,39 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..3c9d302854 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-clipvertex.vert.html @@ -0,0 +1,36 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..70816d4173 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-comma-assignment.html @@ -0,0 +1,41 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..ec672d569e --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-comma-conditional-assignment.html @@ -0,0 +1,192 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..b63a10ae5d --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-comma-separated-variable-declarations.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..7d5826cf9c --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-conditional-scoping-negative.html @@ -0,0 +1,42 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..31b705dfea --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-conditional-scoping.html @@ -0,0 +1,45 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..b03af46f4f --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-default-precision.frag.html @@ -0,0 +1,38 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..a8f43ec6f8 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-default-precision.vert.html @@ -0,0 +1,39 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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-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 0000000000..50803c92ac --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-dfdx-no-ext.frag.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..0636867932 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-dfdx.frag.html @@ -0,0 +1,36 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..76643dd3c0 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-do-loop.html @@ -0,0 +1,40 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..fec151fc81 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-error-directive.html @@ -0,0 +1,51 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..908dc9fb03 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-explicit-int-cast.vert.html @@ -0,0 +1,38 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..04362b86c1 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-float-return-value.frag.html @@ -0,0 +1,46 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..cf11a88d9f --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-for-loop.html @@ -0,0 +1,83 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..c4d9620fd5 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-for-scoping.html @@ -0,0 +1,38 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..48454492c4 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-frag-depth.frag.html @@ -0,0 +1,38 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..dfa12e471a --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-function-recursion.frag.html @@ -0,0 +1,45 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..be694ae5ee --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-function-scoped-struct.html @@ -0,0 +1,42 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..c18f3cc495 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-functional-scoping.html @@ -0,0 +1,39 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..52cd783902 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-glcolor.vert.html @@ -0,0 +1,35 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..bc8a7b3a8d --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-gles-1.frag.html @@ -0,0 +1,39 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..b569958f5a --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-gles-symbol.frag.html @@ -0,0 +1,39 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..6303915f30 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-global-variable-precision-mismatch.html @@ -0,0 +1,128 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..9387918f1a --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-glprojectionmatrix.vert.html @@ -0,0 +1,35 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..7a9ed875b2 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-hex-int-constant-macro.html @@ -0,0 +1,38 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..04902c50db --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-illegal-default-precision.frag.html @@ -0,0 +1,238 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..5710fddfd5 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-illegal-default-precision.vert.html @@ -0,0 +1,224 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..c77a3e1915 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-implicit-vec3-to-vec4-cast.vert.html @@ -0,0 +1,38 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..bc0cf93cc2 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-include.vert.html @@ -0,0 +1,39 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..7b4430c0f8 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-int-return-value.frag.html @@ -0,0 +1,42 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..af918519c6 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-invalid-identifier.frag.html @@ -0,0 +1,36 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..2445e7d3c0 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-ivec2-return-value.frag.html @@ -0,0 +1,42 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..c765ef9259 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-ivec3-return-value.frag.html @@ -0,0 +1,42 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..77317d22e8 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-ivec4-return-value.frag.html @@ -0,0 +1,42 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..df7401ef3c --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-limited-indexing.frag.html @@ -0,0 +1,54 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..4f22beb027 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-long-line.html @@ -0,0 +1,67 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..b80cf3a995 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-non-ascii-error.frag.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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-1-of-8.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-non-reserved-words-1-of-8.html new file mode 100644 index 0000000000..f2f8bc674e --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-non-reserved-words-1-of-8.html @@ -0,0 +1,31 @@ +<!-- +Copyright (c) 2022 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests - Non Reserved Words 1 of 8</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/tests/shader-with-non-reserved-words.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; + +const numParts = 8; +const part = 1; +testNonReservedWords(part, numParts); + +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-non-reserved-words-2-of-8.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-non-reserved-words-2-of-8.html new file mode 100644 index 0000000000..4be404a5d6 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-non-reserved-words-2-of-8.html @@ -0,0 +1,31 @@ +<!-- +Copyright (c) 2022 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests - Non Reserved Words 2 of 8</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/tests/shader-with-non-reserved-words.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; + +const numParts = 8; +const part = 2; +testNonReservedWords(part, numParts); + +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-non-reserved-words-3-of-8.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-non-reserved-words-3-of-8.html new file mode 100644 index 0000000000..58b8ab21d6 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-non-reserved-words-3-of-8.html @@ -0,0 +1,31 @@ +<!-- +Copyright (c) 2022 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests - Non Reserved Words 3 of 8</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/tests/shader-with-non-reserved-words.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; + +const numParts = 8; +const part = 3; +testNonReservedWords(part, numParts); + +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-non-reserved-words-4-of-8.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-non-reserved-words-4-of-8.html new file mode 100644 index 0000000000..4c2162970a --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-non-reserved-words-4-of-8.html @@ -0,0 +1,31 @@ +<!-- +Copyright (c) 2022 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests - Non Reserved Words 4 of 8</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/tests/shader-with-non-reserved-words.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; + +const numParts = 8; +const part = 4; +testNonReservedWords(part, numParts); + +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-non-reserved-words-5-of-8.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-non-reserved-words-5-of-8.html new file mode 100644 index 0000000000..546cc04d84 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-non-reserved-words-5-of-8.html @@ -0,0 +1,31 @@ +<!-- +Copyright (c) 2022 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests - Non Reserved Words 5 of 8</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/tests/shader-with-non-reserved-words.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; + +const numParts = 8; +const part = 5; +testNonReservedWords(part, numParts); + +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-non-reserved-words-6-of-8.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-non-reserved-words-6-of-8.html new file mode 100644 index 0000000000..7fad96cedc --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-non-reserved-words-6-of-8.html @@ -0,0 +1,31 @@ +<!-- +Copyright (c) 2022 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests - Non Reserved Words 6 of 8</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/tests/shader-with-non-reserved-words.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; + +const numParts = 8; +const part = 6; +testNonReservedWords(part, numParts); + +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-non-reserved-words-7-of-8.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-non-reserved-words-7-of-8.html new file mode 100644 index 0000000000..b45abfe2bb --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-non-reserved-words-7-of-8.html @@ -0,0 +1,31 @@ +<!-- +Copyright (c) 2022 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests - Non Reserved Words 7 of 8</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/tests/shader-with-non-reserved-words.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; + +const numParts = 8; +const part = 7; +testNonReservedWords(part, numParts); + +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-non-reserved-words-8-of-8.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-non-reserved-words-8-of-8.html new file mode 100644 index 0000000000..f901cacc58 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-non-reserved-words-8-of-8.html @@ -0,0 +1,31 @@ +<!-- +Copyright (c) 2022 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL Conformance Tests - Non Reserved Words 8 of 8</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/tests/shader-with-non-reserved-words.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; + +const numParts = 8; +const part = 8; +testNonReservedWords(part, numParts); + +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 0000000000..536b66ec0b --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-precision.frag.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..c8e31d5927 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-preprocessor-whitespace.html @@ -0,0 +1,62 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..c79315d3f9 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-quoted-error.frag.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..fd6953e0fe --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-reserved-words.html @@ -0,0 +1,263 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..c05649aa83 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-short-circuiting-operators.html @@ -0,0 +1,156 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..e96ab4055c --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-similar-uniform-array-names.html @@ -0,0 +1,109 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..b5e87f9c85 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-too-many-uniforms.html @@ -0,0 +1,123 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..fac53b08d8 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-two-initializer-types.html @@ -0,0 +1,36 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..06783bcfd8 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-undefined-preprocessor-symbol.frag.html @@ -0,0 +1,39 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..be8d3067b7 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-uniform-in-loop-condition.vert.html @@ -0,0 +1,42 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..c5f5860707 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-vec2-return-value.frag.html @@ -0,0 +1,44 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..fe5a60c6c4 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-vec3-return-value.frag.html @@ -0,0 +1,44 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..69001a0f83 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-vec4-return-value.frag.html @@ -0,0 +1,44 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..2cc0e8ea61 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-vec4-vec3-vec4-conditional.html @@ -0,0 +1,36 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..0d88a7f689 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-version-100.frag.html @@ -0,0 +1,41 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..9a0357971f --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-version-100.vert.html @@ -0,0 +1,38 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..c1bc6d7d07 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-version-120.vert.html @@ -0,0 +1,38 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..6983c92f9d --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-version-130.vert.html @@ -0,0 +1,38 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..a1c0af9d9b --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-webgl-identifier.vert.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..592f55541e --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-with-while-loop.html @@ -0,0 +1,38 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..c5543e2119 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-without-precision.frag.html @@ -0,0 +1,37 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..c06de87ef8 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shaders-with-constant-expression-loop-conditions.html @@ -0,0 +1,115 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> +<!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 0000000000..205d78cee4 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shaders-with-invariance.html @@ -0,0 +1,332 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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: true, + passMsg: "vertex shader with variant varying and fragment shader with invariant (global setting) varying must succeed", + }, + { + vShaderId: "vertexShaderInvariant", + vShaderSuccess: true, + fShaderId: "fragmentShaderGlobalInvariant", + fShaderSuccess: true, + linkSuccess: false, + passMsg: "vertex shader with invariant varying and fragment shader with invariant (global setting) varying must fail", + } +]; + +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 0000000000..73a032278f --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shaders-with-mis-matching-uniforms.html @@ -0,0 +1,87 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..342bbc0199 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shaders-with-mis-matching-varyings.html @@ -0,0 +1,80 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..4dab279f60 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shaders-with-missing-varyings.html @@ -0,0 +1,74 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..e4c9af8b8f --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shaders-with-name-conflicts.html @@ -0,0 +1,88 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"; + +/* +This test previously concluded that an attribute in a vertex shader +would conflict across shaders with a uniform of the same name in the +fragment shader, based on the following sections of the GLSL ES 1.0.17 +specification: + +--- +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 +--- + +GLSL ES 3.00 later confirmed that pipeline stages have distinct +namespaces. The OpenGL ES working group confirmed in discussions +https://github.com/KhronosGroup/WebGL/issues/3201 that this was the +intended behavior for GLSL ES 1.00. + +For this reason, this test asserts that such usage does not generate a +conflict. +*/ + +GLSLConformanceTester.runTests([ + { vShaderId: 'vertexShader', + vShaderSuccess: true, + fShaderId: 'fragmentShader', + fShaderSuccess: true, + linkSuccess: true, + passMsg: 'using the same name for a vertex shader attribute and fragment shader uniform should succeed' + }, +]); +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 0000000000..8713bd0cbe --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shaders-with-uniform-structs.html @@ -0,0 +1,289 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..87baaa2bdc --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shaders-with-varyings.html @@ -0,0 +1,103 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..77786bb385 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shared.html @@ -0,0 +1,151 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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-as-inout-parameter.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-as-inout-parameter.html new file mode 100644 index 0000000000..e041661477 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-as-inout-parameter.html @@ -0,0 +1,117 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL Structure as Inout Parameter 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="struct-inout-parameter-fs" type="x-shader/x-fragment"> +struct ColorData { + vec3 red; + vec3 blue; +}; + +void modify(inout ColorData colorData) { + colorData.red += vec3(0.5, 0.0, 0.0); + colorData.blue += vec3(0.0, 0.0, 0.5); +} + +void main() { + ColorData colorData; + colorData.red = vec3(0.5, 0.0, 0.0); + colorData.blue = vec3(0.0, 0.0, 0.5); + + vec3 red = vec3(1.0, 0.0, 0.0); + vec3 green = vec3(0.0, 1.0, 0.0); + vec3 blue = vec3(0.0, 0.0, 1.0); + vec3 finalColor; + + modify(colorData); + + if (colorData.red == red && colorData.blue == blue) + finalColor = green; + else + finalColor = red; + + gl_FragColor = vec4(finalColor, 1.0); +} +</script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +description("Testing structs as inout parameter"); + +debug('Regression test for <a href="http://crbug.com/851870">http://crbug.com/851870</a> / <a href="https://github.com/mrdoob/three.js/issues/14137">https://github.com/mrdoob/three.js/issues/14137</a>'); + +function prepend(floatPrecision) { + let source = document.getElementById('struct-inout-parameter-fs').text; + return 'precision ' + floatPrecision + ' float;\n' + source; +} + +let tests = [ + { + vShaderId: "simple-vs", + vShaderSuccess: true, + fShaderSource: prepend('lowp'), + fShaderSuccess: true, + linkSuccess: true, + render: true, + passMsg: "lowp struct used as inout parameter", + }, + { + vShaderId: "simple-vs", + vShaderSuccess: true, + fShaderSource: prepend('mediump'), + fShaderSuccess: true, + linkSuccess: true, + render: true, + passMsg: "mediump struct used as inout parameter", + }, +]; + +let wtu = WebGLTestUtils; +let gl = wtu.create3DContext(); +let precision = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT); +let highpSupported = (precision.rangeMin >= 62 && precision.rangeMax >= 62 && precision.precision >= 16); +debug("highp is" + (highpSupported ? "" : " not") + " supported in fragment shaders"); + +if (highpSupported) { + tests.push( + { + vShaderId: "simple-vs", + vShaderSuccess: true, + fShaderSource: prepend('highp'), + fShaderSuccess: true, + linkSuccess: true, + render: true, + passMsg: "highp struct used as inout parameter", + } + ); +} + +GLSLConformanceTester.runTests(tests); +debug(""); + +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-as-out-parameter.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-as-out-parameter.html new file mode 100644 index 0000000000..4190c691e8 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-as-out-parameter.html @@ -0,0 +1,115 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>GLSL Structure as Out Parameter 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="struct-out-parameter-fs" type="x-shader/x-fragment"> +struct ColorData { + vec3 red; + vec3 blue; +}; + +void modify(out ColorData colorData) { + colorData.red = vec3(1.0, 0.0, 0.0); + colorData.blue = vec3(0.0, 0.0, 1.0); +} + +void main() { + ColorData colorData; + + vec3 red = vec3(1.0, 0.0, 0.0); + vec3 green = vec3(0.0, 1.0, 0.0); + vec3 blue = vec3(0.0, 0.0, 1.0); + vec3 finalColor; + + modify(colorData); + + if (colorData.red == red && colorData.blue == blue) + finalColor = green; + else + finalColor = red; + + gl_FragColor = vec4(finalColor, 1.0); +} +</script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +description("Testing structs as out parameter"); + +debug('Regression test for <a href="http://crbug.com/851873">http://crbug.com/851873</a> / <a href="https://github.com/mrdoob/three.js/issues/14137">https://github.com/mrdoob/three.js/issues/14137</a>'); + +function prepend(floatPrecision) { + let source = document.getElementById('struct-out-parameter-fs').text; + return 'precision ' + floatPrecision + ' float;\n' + source; +} + +let tests = [ + { + vShaderId: "simple-vs", + vShaderSuccess: true, + fShaderSource: prepend('lowp'), + fShaderSuccess: true, + linkSuccess: true, + render: true, + passMsg: "lowp struct used as out parameter", + }, + { + vShaderId: "simple-vs", + vShaderSuccess: true, + fShaderSource: prepend('mediump'), + fShaderSuccess: true, + linkSuccess: true, + render: true, + passMsg: "mediump struct used as out parameter", + }, +]; + +let wtu = WebGLTestUtils; +let gl = wtu.create3DContext(); +let precision = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT); +let highpSupported = (precision.rangeMin >= 62 && precision.rangeMax >= 62 && precision.precision >= 16); +debug("highp is" + (highpSupported ? "" : " not") + " supported in fragment shaders"); + +if (highpSupported) { + tests.push( + { + vShaderId: "simple-vs", + vShaderSuccess: true, + fShaderSource: prepend('highp'), + fShaderSuccess: true, + linkSuccess: true, + render: true, + passMsg: "highp struct used as out parameter", + } + ); +} + +GLSLConformanceTester.runTests(tests); +debug(""); + +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 0000000000..9d1d77d068 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-assign.html @@ -0,0 +1,214 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..50ac40e5c6 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-equals.html @@ -0,0 +1,217 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..108cee9d0f --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-mixed-array-declarators.html @@ -0,0 +1,71 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> +<!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 0000000000..772e47d70d --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-nesting-exceeds-maximum.html @@ -0,0 +1,55 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..0762628141 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-nesting-of-variable-names.html @@ -0,0 +1,74 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> +<!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 0000000000..1707e57007 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-nesting-under-maximum.html @@ -0,0 +1,51 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..3c0c704a29 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-specifiers-in-uniforms.html @@ -0,0 +1,65 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> +<!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 0000000000..d14a860fd8 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-unary-operators.html @@ -0,0 +1,70 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> +<!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 0000000000..adeddc5e33 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/ternary-operator-on-arrays.html @@ -0,0 +1,64 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 0000000000..a8fe592ad0 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/ternary-operators-in-global-initializers.html @@ -0,0 +1,67 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> +<!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 0000000000..cdbc59a5c9 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/ternary-operators-in-initializers.html @@ -0,0 +1,124 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> +<!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 0000000000..8aeaeb1937 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/uniform-location-length-limits.html @@ -0,0 +1,86 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> +<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> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/uninitialized-local-global-variables.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/uninitialized-local-global-variables.html new file mode 100644 index 0000000000..d0552af096 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/uninitialized-local-global-variables.html @@ -0,0 +1,274 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Uninitialized local/global variables should be initialized</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<link rel="stylesheet" href="../../../resources/glsl-feature-tests.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"> </script> + +<script id="vs_uninit_in_frag" type="x-shader/x-vertex"> +precision mediump float; +attribute vec4 a_position; +void main() { + gl_Position = a_position; +} +</script> + +<!-- Uninitialized local in vertex shader --> +<script id="vs_uninit_local_in_vert" type="x-shader/x-vertex"> +precision mediump float; +attribute vec4 a_position; +varying vec3 v_uninit; +void main() { + vec3 uninit; // uninitialized + v_uninit = uninit; + gl_Position = a_position; +} +</script> +<script id="fs_uninit_local_in_vert" type="x-shader/x-fragment"> +precision mediump float; +varying vec3 v_uninit; +void main() { + gl_FragColor = v_uninit.xyzz; +} +</script> + +<!-- Uninitialized local in fragment shader --> +<script id="fs_uninit_local_in_frag" type="x-shader/x-fragment"> +precision mediump float; +void main() { + vec2 uninit; // uninitialized + gl_FragColor = uninit.xyyy; +} +</script> + +<!-- Uninitialized global in vertex shader --> +<script id="vs_uninit_global_in_vert" type="x-shader/x-vertex"> +precision mediump float; +attribute vec4 a_position; +varying float v_uninit; +float uninit; // uninitialized +void main() { + v_uninit = uninit; + gl_Position = a_position; +} +</script> +<script id="fs_uninit_global_in_vert" type="x-shader/x-fragment"> +precision mediump float; +varying float v_uninit; +void main() { + gl_FragColor = vec4(v_uninit); +} +</script> + +<!-- Uninitialized global in fragment shader --> +<script id="fs_uninit_global_in_frag" type="x-shader/x-fragment"> +precision mediump float; +vec4 uninit; // uninitialized +void main() { + gl_FragColor = uninit; +} +</script> + +<!-- Uninitialized local int in fragment shader --> +<script id="fs_uninit_local_int_in_frag" type="x-shader/x-fragment"> +precision mediump float; +void main() { + int uninit; + gl_FragColor = vec4(uninit); +} +</script> + +<!-- Uninitialized local variable and another variable in the same declaration using it as an initializer in fragment shader --> +<script id="fs_uninit_two_local_variables_in_declaration_in_frag" type="x-shader/x-fragment"> +precision mediump float; +void main() { + vec2 uninit, uninit2 = uninit; + gl_FragColor = uninit2.xyyy; +} +</script> + +<!-- Uninitialized local array and another variable in the same declaration using it in its initializer in fragment shader --> +<script id="fs_uninit_array_and_another_in_declaration_in_frag" type="x-shader/x-fragment"> +precision mediump float; +void main() { + vec2 uninit[2], uninit2 = uninit[0]; + gl_FragColor = uninit2.xyyy; +} +</script> + +<!-- Uninitialized global int in fragment shader --> +<script id="fs_uninit_global_int_in_frag" type="x-shader/x-fragment"> +precision mediump float; +int uninit; // uninitialized +void main() { + gl_FragColor = vec4(uninit); +} +</script> + +<!-- Uninitialized local struct in fragment shader --> +<script id="fs_uninit_local_struct_in_frag" type="x-shader/x-fragment"> +precision mediump float; +struct S { vec4 v; }; +void main() { + S uninit; // uninitialized + gl_FragColor = uninit.v; +} +</script> + +<!-- Uninitialized global struct in fragment shader --> +<script id="fs_uninit_global_struct_in_frag" type="x-shader/x-fragment"> +precision mediump float; +struct S { vec4 v; }; +S uninit; // uninitialized +void main() { + gl_FragColor = uninit.v; +} +</script> + +<!-- Uninitialized nameless local struct in fragment shader --> +<script id="fs_uninit_nameless_local_struct_in_frag" type="x-shader/x-fragment"> +precision mediump float; +void main() { + struct { vec4 v; } uninit; // uninitialized + gl_FragColor = uninit.v; +} +</script> + +<!-- Uninitialized nameless global struct in fragment shader --> +<script id="fs_uninit_nameless_global_struct_in_frag" type="x-shader/x-fragment"> +precision mediump float; +struct { vec4 v; } uninit; // uninitialized +void main() { + gl_FragColor = uninit.v; +} +</script> + +<!-- Uninitialized local bool in fragment shader --> +<script id="fs_uninit_local_bool_in_frag" type="x-shader/x-fragment"> +precision mediump float; +void main() { + bool uninit[16]; // uninitialized + bool result; + for (int i = 0; i < 16; i++) { + result = result || uninit[i]; + } + gl_FragColor = result ? vec4(1, 0, 0, 1) : vec4(0); +} +</script> + +<!-- Uninitialized global bool in fragment shader --> +<script id="fs_uninit_global_bool_in_frag" type="x-shader/x-fragment"> +precision mediump float; +bool uninit[16]; // uninitialized +void main() { + bool result = false; + for (int i = 0; i < 16; i++) { + result = result || uninit[i]; + } + gl_FragColor = result ? vec4(1, 0, 0, 1) : vec4(0); +} +</script> + +</head> +<body> +<canvas id="canvas" width="50" height="50"></canvas> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +description('Uninitialized local/global variables should be initialized: http://anglebug.com/1966'); + +var wtu = WebGLTestUtils; +var gl = wtu.create3DContext("canvas"); +wtu.setupUnitQuad(gl); + +var cases = [ + { + name: "Uninitialized local variable in vertex shader", + prog: ["vs_uninit_local_in_vert", "fs_uninit_local_in_vert"], + }, + { + name: "Uninitialized local variable in fragment shader", + prog: ["vs_uninit_in_frag", "fs_uninit_local_in_frag"], + }, + { + name: "Uninitialized global variable in vertex shader", + prog: ["vs_uninit_global_in_vert", "fs_uninit_global_in_vert"], + }, + { + name: "Uninitialized global variable in fragment shader", + prog: ["vs_uninit_in_frag", "fs_uninit_global_in_frag"], + }, + { + name: "Uninitialized local int variable in fragment shader", + prog: ["vs_uninit_in_frag", "fs_uninit_local_int_in_frag"], + }, + { + name: "Uninitialized local variable and another variable in the same declaration using it as an initializer in fragment shader", + prog: ["vs_uninit_in_frag", "fs_uninit_two_local_variables_in_declaration_in_frag"], + }, + { + name: "Uninitialized local array and another variable in the same declaration using it in its initializer in fragment shader", + prog: ["vs_uninit_in_frag", "fs_uninit_array_and_another_in_declaration_in_frag"], + }, + { + name: "Uninitialized global int variable in fragment shader", + prog: ["vs_uninit_in_frag", "fs_uninit_global_int_in_frag"], + }, + { + name: "Uninitialized local struct variable in fragment shader", + prog: ["vs_uninit_in_frag", "fs_uninit_local_struct_in_frag"], + }, + { + name: "Uninitialized global struct variable in fragment shader", + prog: ["vs_uninit_in_frag", "fs_uninit_global_struct_in_frag"], + }, + { + name: "Uninitialized nameless local struct variable in fragment shader", + prog: ["vs_uninit_in_frag", "fs_uninit_nameless_local_struct_in_frag"], + }, + { + name: "Uninitialized nameless global struct variable in fragment shader", + prog: ["vs_uninit_in_frag", "fs_uninit_nameless_global_struct_in_frag"], + }, + { + name: "Uninitialized local bool array variable in fragment shader", + prog: ["vs_uninit_in_frag", "fs_uninit_local_bool_in_frag"], + }, + { + name: "Uninitialized global bool array variable in fragment shader", + prog: ["vs_uninit_in_frag", "fs_uninit_global_bool_in_frag"], + }, +]; + +function runTest() { + for (var i = 0; i < cases.length; ++i) { + debug(""); + debug(cases[i].name); + var program = wtu.setupProgram(gl, cases[i].prog, ["a_position"], undefined, true); + gl.clearColor(1.0, 0.0, 0.0, 1.0); + wtu.clearAndDrawUnitQuad(gl); + wtu.checkCanvas(gl, [0, 0, 0, 0]); + } + + debug(""); + wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors"); +} + +runTest(); + +var successfullyParsed = true; +</script> +<script src="../../../js/js-test-post.js"></script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/preprocessor/00_test_list.txt b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/preprocessor/00_test_list.txt new file mode 100644 index 0000000000..110657c1f7 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/preprocessor/00_test_list.txt @@ -0,0 +1,2 @@ +--min-version 1.0.4 comments.html +--min-version 1.0.4 macro-expansion-tricky.html diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/preprocessor/comments.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/preprocessor/comments.html new file mode 100644 index 0000000000..0e3dfb3e32 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/preprocessor/comments.html @@ -0,0 +1,204 @@ +<!-- +Copyright (c) 2020 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Comments</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script src="../../../js/glsl-conformance-test.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +description(); + +// Your syntax highlighter may hate this file. +// Because this stuff is tricky, we collect all tests here, including duplicating from other tests. +// That way, this test file is a one-stop-shop for validation testing. + +const nonAscii = [ + 65533, + 65533, + 65533, + 65533, + 834, + 96, + 65533, + 114, + 65533, + 98, + 65533, + 104, + 65533, + 104, + 65533, + 322, + 834, + 514, + 65533, + 65533, + 322, + 65533, + 65533, + 66, +].map(x => String.fromCodePoint(x)).join(''); + +GLSLConformanceTester.runTests([{ + vShaderSource: `void main() {}`, + vShaderSuccess: true, + linkSuccess: true, + passMsg: 'Normal minimal testcase' + }, { + vShaderSource: `void main() {}/*`, + vShaderSuccess: false, + linkSuccess: false, + passMsg: 'Missing block-comment-end' + }, { + vShaderSource: `void main() {}/**`, + vShaderSuccess: false, + linkSuccess: false, + passMsg: 'Partial block-comment-end' + }, { + vShaderSource: `void main() {}/**/`, + vShaderSuccess: true, + linkSuccess: true, + passMsg: 'Complete block-comment-end' + }, { + vShaderSource: `void main() {}/* **/`, + vShaderSuccess: true, + linkSuccess: true, + passMsg: 'Complete block-comment-end with **/' + }, { + vShaderSource: `void main() {}/`, + vShaderSuccess: false, + linkSuccess: false, + passMsg: 'Partial line-comment-begin at EOF' + }, { + vShaderSource: `void main() {}//`, + vShaderSuccess: true, + linkSuccess: true, + passMsg: 'Complete line-comment-begin at EOF' + }, { + vShaderSource: `// +void main() {}`, + vShaderSuccess: true, + linkSuccess: true, + passMsg: `Minimal line comment: "//,\\n"` + }, { + vShaderSource: `//\ + +void main() {}`, + vShaderSuccess: true, + linkSuccess: true, + passMsg: `Minimal continued line comment: "//,\\,\\n,\\n"` + }, { + vShaderSource: `//\ +a +void main() {}`, + vShaderSuccess: true, + linkSuccess: true, + passMsg: `Line-comment continuation with content that must be skipped: "//,\\,\\n,a,\\n"` + }, { + vShaderSource: `void main() {} // The quick brown fox jumped\\over the lazy dog`, + vShaderSuccess: true, + linkSuccess: true, + passMsg: 'Backslash in comment' + }, { + vShaderSource: `void main() {} // The quick brown fox jumped\\over the lazy dog +`, + vShaderSuccess: true, + linkSuccess: true, + passMsg: 'Backslash in comment with newline before EOF' + }, { + vShaderSource: `void main() {} // The quick brown fox jumped\\ +over the lazy dog`, + vShaderSuccess: true, + linkSuccess: true, + passMsg: 'Line-comment with backslash-line-continuation' + }, { + vShaderSource: `void main() {} // The quick brown fox jumped\\ +over the lazy dog +`, + vShaderSuccess: true, + linkSuccess: true, + passMsg: 'Line-comment with backslash-line-continuation with newline before EOF' + }, { + vShaderSource: `void main() {}//${String.fromCodePoint(0x8f)}`, + vShaderSuccess: true, + linkSuccess: true, + passMsg: 'upper-ascii in line-comment' + }, { + vShaderSource: `void main() {}/*${String.fromCodePoint(0x8f)}*/`, + vShaderSuccess: true, + linkSuccess: true, + passMsg: 'upper-ascii in block-comment' + + // - + // Like comment_frag.frag from conformance/ogles/GL/build/build_049_to_056.html + }, { + vShaderSource: ` +void main() +{ + /****** // comment not closed +}`, + vShaderSuccess: false, + linkSuccess: false, + passMsg: 'Unclosed block-comment containing line-comment' + + + // - + // Like conformance/glsl/misc/non-ascii-comments.vert.html + }, { + vShaderSource: `void main() {}/*${String.fromCodePoint(0x8f)}`, + vShaderSuccess: false, + linkSuccess: false, + passMsg: 'upper-ascii in unterminated block-comment' + }, { + vShaderSource: `void main() {}// ${nonAscii}`, + vShaderSuccess: true, + linkSuccess: true, + passMsg: 'More non-ascii in line-comment' + }, { + vShaderSource: `void main() {}/* + * ${nonAscii} + */`, + vShaderSuccess: true, + linkSuccess: true, + passMsg: 'More non-ascii in block-comment' + }, { + vShaderSource: `void main() {}/* + * ${nonAscii} + *`, + vShaderSuccess: false, + linkSuccess: false, + passMsg: 'More non-ascii in unterminated block-comment' + + + // - + // Like deqp/data/gles2/shaders/preprocessor.html | preprocessor.comments.comment_trick_2_* + }, { + vShaderSource: `void main() { + float out0; + /**/ + out0 = 1.0; + /*/ + out0 = 0.0; + /**/ + }`, + vShaderSuccess: true, + linkSuccess: true, + passMsg: '/**/ /*/ /**/' +}]); +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/preprocessor/macro-expansion-tricky.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/preprocessor/macro-expansion-tricky.html new file mode 100644 index 0000000000..8c925f4d7d --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/preprocessor/macro-expansion-tricky.html @@ -0,0 +1,46 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Tricky macro expansion</title> +<link rel="stylesheet" href="../../../resources/js-test-style.css"/> +<script src="../../../js/js-test-pre.js"></script> +<script src="../../../js/webgl-test-utils.js"></script> +<script src="../../../js/glsl-conformance-test.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<script id="fshaderRecursiveMacroNameInsideIncompleteMacroInvocationInMacroExpansion" type="x-shader/x-fragment"> +#define m(a) +#define a m((a) +a) + +precision mediump float; + +void main() { + gl_FragColor = vec4(0.0); +} +</script> +<script type="application/javascript"> +"use strict"; +description(); + +GLSLConformanceTester.runTests([ +{ + fShaderId: 'fshaderRecursiveMacroNameInsideIncompleteMacroInvocationInMacroExpansion', + fShaderSuccess: true, + linkSuccess: true, + passMsg: 'Recursive macro name inside incomplete macro invocation in macro expansion should not crash' +} +]); +</script> +</body> +</html> + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/reserved/00_test_list.txt b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/reserved/00_test_list.txt new file mode 100644 index 0000000000..7c2da3e8f5 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/reserved/00_test_list.txt @@ -0,0 +1,8 @@ +_webgl_field.vert.html +_webgl_function.vert.html +_webgl_struct.vert.html +_webgl_variable.vert.html +webgl_field.vert.html +webgl_function.vert.html +webgl_struct.vert.html +webgl_variable.vert.html diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/reserved/_webgl_field.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/reserved/_webgl_field.vert.html new file mode 100644 index 0000000000..b9bba36da7 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/reserved/_webgl_field.vert.html @@ -0,0 +1,40 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// use of reserved _webgl prefix as structure field should fail +struct Foo { + int _webgl_bar; +}; + +void main() { + Foo foo = Foo(1); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/reserved/_webgl_function.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/reserved/_webgl_function.vert.html new file mode 100644 index 0000000000..ea9586fd53 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/reserved/_webgl_function.vert.html @@ -0,0 +1,38 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// use of reserved _webgl prefix as function name should fail +vec4 _webgl_foo() { + return vec4(1.0); +} + +void main() { + gl_Position = _webgl_foo(); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/reserved/_webgl_struct.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/reserved/_webgl_struct.vert.html new file mode 100644 index 0000000000..df61e9d7d2 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/reserved/_webgl_struct.vert.html @@ -0,0 +1,38 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// use of reserved _webgl prefix as structure name should fail +struct _webgl_Foo { + int bar; +}; + +void main() { + _webgl_Foo foo = _webgl_Foo(1); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/reserved/_webgl_variable.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/reserved/_webgl_variable.vert.html new file mode 100644 index 0000000000..bcae6ec7ab --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/reserved/_webgl_variable.vert.html @@ -0,0 +1,34 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// use of reserved _webgl prefix as structure field should fail +void main() { + vec4 _webgl_foo; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/reserved/webgl_field.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/reserved/webgl_field.vert.html new file mode 100644 index 0000000000..a41712661f --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/reserved/webgl_field.vert.html @@ -0,0 +1,40 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// use of reserved webgl_ prefix as structure field should fail +struct Foo { + int webgl_bar; +}; + +void main() { + Foo foo = Foo(1); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> + + diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/reserved/webgl_function.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/reserved/webgl_function.vert.html new file mode 100644 index 0000000000..4a9ac1698a --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/reserved/webgl_function.vert.html @@ -0,0 +1,38 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// use of reserved webgl_ prefix as function name should fail +vec4 webgl_foo() { + return vec4(1.0); +} + +void main() { + gl_Position = webgl_foo(); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/reserved/webgl_struct.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/reserved/webgl_struct.vert.html new file mode 100644 index 0000000000..a5a0294a3d --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/reserved/webgl_struct.vert.html @@ -0,0 +1,38 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// use of reserved webgl_ prefix as structure name should fail +struct webgl_Foo { + int bar; +}; + +void main() { + webgl_Foo foo = webgl_Foo(1); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/reserved/webgl_variable.vert.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/reserved/webgl_variable.vert.html new file mode 100644 index 0000000000..f2b6708e9a --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/reserved/webgl_variable.vert.html @@ -0,0 +1,34 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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"> + +// use of reserved webgl_ prefix as variable should fail +void main() { + vec4 webgl_foo; +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/samplers/00_test_list.txt b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/samplers/00_test_list.txt new file mode 100644 index 0000000000..c0f612d81d --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/samplers/00_test_list.txt @@ -0,0 +1,4 @@ +glsl-function-texture2d-bias.html +glsl-function-texture2dlod.html +glsl-function-texture2dproj.html +--min-version 1.0.3 glsl-function-texture2dprojlod.html diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/samplers/glsl-function-texture2d-bias.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/samplers/glsl-function-texture2d-bias.html new file mode 100644 index 0000000000..073276615f --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/samplers/glsl-function-texture2d-bias.html @@ -0,0 +1,101 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL texture2D GLSL 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> +</head> +<body> +<canvas id="example" width="256" height="256" style="width: 16px; height: 16px;"></canvas> +<div id="description"></div> +<div id="console"></div> +<script id="vshader2d" type="x-shader/x-vertex"> +attribute vec4 vPosition; +attribute vec2 texCoord0; +varying vec2 texCoord; +void main() { + gl_Position = vPosition; + texCoord = texCoord0; +} +</script> +<script id="fshader2d" type="x-shader/x-fragment"> +precision mediump float; +uniform sampler2D tex; +uniform float bias; +varying vec2 texCoord; +void main() { + gl_FragData[0] = texture2D(tex, texCoord, bias); +} +</script> +<script> +"use strict"; +description("tests GLSL texture2D function with bias"); + +var wtu = WebGLTestUtils; +var canvas = document.getElementById("example"); + +shouldBe("canvas.width", "256"); +shouldBe("canvas.height", "256"); + +var gl = wtu.create3DContext(canvas); +var program = wtu.setupProgram( + gl, ['vshader2d', 'fshader2d'], ['vPosition', 'texCoord0'], [0, 1]); +wtu.setupUnitQuad(gl, 0, 1); + +var colors = [ + {name: 'red', color:[255, 0, 0, 255]}, + {name: 'green', color:[0, 255, 0, 255]}, + {name: 'blue', color:[0, 0, 255, 255]}, + {name: 'yellow', color:[255, 255, 0, 255]}, + {name: 'magenta', color:[255, 0, 255, 255]}, + {name: 'cyan', color:[0, 255, 255, 255]}, + {name: 'pink', color:[255, 128, 128, 255]}, + {name: 'gray', color:[128, 128, 128, 255]}, + {name: 'light green', color:[128, 255, 128, 255]}, +]; + +shouldBe("colors.length", "9"); + +var tex = gl.createTexture(); +gl.bindTexture(gl.TEXTURE_2D, tex); +gl.texParameteri( + gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_NEAREST); +gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); +gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT); +gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT); + +for (var ii = 0; ii < colors.length; ++ii) { + var color = colors[ii]; + var size = Math.pow(2, colors.length - ii - 1); + wtu.fillTexture(gl, tex, size, size, color.color, ii); +} + +var loc = gl.getUniformLocation(program, "bias"); + +for (var ii = 0; ii < colors.length; ++ii) { + gl.uniform1f(loc, ii); + var color = colors[ii]; + wtu.clearAndDrawUnitQuad(gl); + wtu.checkCanvas( + gl, color.color, + "256x256 texture drawn to 256x256 dest with bias = " + ii + + " should be " + color.name); +} +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/samplers/glsl-function-texture2dlod.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/samplers/glsl-function-texture2dlod.html new file mode 100644 index 0000000000..41387bca15 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/samplers/glsl-function-texture2dlod.html @@ -0,0 +1,109 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL texture2D GLSL 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> +</head> +<body> +<canvas id="example" width="256" height="256" style="width: 16px; height: 16px;"></canvas> +<div id="description"></div> +<div id="console"></div> +<script id="vshader2d" type="x-shader/x-vertex"> +attribute vec4 vPosition; +attribute vec2 texCoord0; +varying vec4 color; +uniform sampler2D tex; +uniform float lod; +void main() { + gl_Position = vPosition; + color = texture2DLod(tex, texCoord0, lod); +} +</script> +<script id="fshader2d" type="x-shader/x-fragment"> +precision mediump float; +varying vec4 color; +void main() { + gl_FragData[0] = color; +} +</script> +<script> +"use strict"; +description("tests GLSL texture2DLod function"); + +var wtu = WebGLTestUtils; +var canvas = document.getElementById("example"); + +shouldBe("canvas.width", "256"); +shouldBe("canvas.height", "256"); + +var colors = [ + {name: 'red', color:[255, 0, 0, 255]}, + {name: 'green', color:[0, 255, 0, 255]}, + {name: 'blue', color:[0, 0, 255, 255]}, + {name: 'yellow', color:[255, 255, 0, 255]}, + {name: 'magenta', color:[255, 0, 255, 255]}, + {name: 'cyan', color:[0, 255, 255, 255]}, + {name: 'pink', color:[255, 128, 128, 255]}, + {name: 'gray', color:[128, 128, 128, 255]}, + {name: 'light green', color:[128, 255, 128, 255]}, +]; + +var gl = wtu.create3DContext(canvas); +if (gl.getParameter(gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS) > 0) { + runTest(); +} else { + testPassed("MAX_VERTEX_TEXTURE_IMAGE_UNITS == 0, this is okay."); +} + +function runTest() { + var program = wtu.setupProgram( + gl, ['vshader2d', 'fshader2d'], ['vPosition', 'texCoord0'], [0, 1]); + wtu.setupUnitQuad(gl, 0, 1); + + shouldBe("colors.length", "9"); + + var tex = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, tex); + gl.texParameteri( + gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST_MIPMAP_LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT); + + for (var ii = 0; ii < colors.length; ++ii) { + var color = colors[ii]; + var size = Math.pow(2, colors.length - ii - 1); + wtu.fillTexture(gl, tex, size, size, color.color, ii); + } + + var loc = gl.getUniformLocation(program, "lod"); + + for (var ii = 0; ii < colors.length; ++ii) { + gl.uniform1f(loc, ii); + var color = colors[ii]; + wtu.clearAndDrawUnitQuad(gl); + wtu.checkCanvas( + gl, color.color, + "256x256 texture drawn to 256x256 dest with lod = " + ii + + " should be " + color.name); + } + 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/samplers/glsl-function-texture2dproj.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/samplers/glsl-function-texture2dproj.html new file mode 100644 index 0000000000..c9e042f9a9 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/samplers/glsl-function-texture2dproj.html @@ -0,0 +1,116 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL texture2D GLSL 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> +</head> +<body> +<canvas id="example" width="32" height="32"></canvas> +<div id="description"></div> +<div id="console"></div> +<script id="vshader0" type="x-shader/x-vertex"> +attribute vec4 vPosition; +attribute vec2 texCoord0; +varying vec2 texCoord; +void main() { + gl_Position = vPosition; + texCoord = texCoord0; +} +</script> +<script id="fshader0" type="x-shader/x-fragment"> +precision mediump float; +uniform sampler2D tex; +uniform float divisor; +varying vec2 texCoord; +void main() { + gl_FragData[0] = texture2DProj(tex, vec3(texCoord, divisor)); +} +</script> +<script id="vshader1" type="x-shader/x-vertex"> +attribute vec4 vPosition; +attribute vec2 texCoord0; +varying vec2 texCoord; +void main() { + gl_Position = vPosition; + texCoord = texCoord0; +} +</script> +<script id="fshader1" type="x-shader/x-fragment"> +precision mediump float; +uniform sampler2D tex; +uniform float divisor; +varying vec2 texCoord; +void main() { + gl_FragData[0] = texture2DProj(tex, vec4(texCoord, 123.0, divisor)); +} +</script> +<script> +"use strict"; +description("tests GLSL texture2DProj function with"); + +var wtu = WebGLTestUtils; +var gl = wtu.create3DContext("example", {antialias: false}); + +wtu.setupUnitQuad(gl, 0, 1); +var tex = gl.createTexture(); +gl.bindTexture(gl.TEXTURE_2D, tex); +gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); +gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); +gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT); +gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT); + +var c = document.createElement("canvas"); +c.width = 16; +c.height = 16; +var ctx = c.getContext("2d"); +ctx.fillStyle = "rgb(0,255,0)"; +ctx.fillRect(0, 0, 16, 16); +ctx.fillStyle = "rgb(0,0,255)"; +ctx.fillRect(0, 0, 8, 8); +ctx.fillRect(8, 8, 8, 8); + +gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, c); + +for (var ss = 0; ss < 2; ++ss) { + debug(""); + debug(ss ? "testing vec4 version" : "testing vec3 version"); + var program = wtu.setupProgram( + gl, ['vshader' + ss, 'fshader' + ss], + ['vPosition', 'texCoord0'], [0, 1]); + gl.useProgram(program); + var loc = gl.getUniformLocation(program, "divisor"); + + for (var ii = 0; ii < 3; ++ii) { + var denominator = Math.pow(2, ii); + gl.uniform1f(loc, 1 / denominator); + wtu.clearAndDrawUnitQuad(gl); + var size = 16 / denominator; + for (var yy = 0; yy < 32; yy += size) { + for (var xx = 0; xx < 32; xx += size) { + var odd = (xx / size + yy / size) % 2; + var color = odd ? [0, 255, 0, 255] : [0, 0, 255, 255]; + var msg = "" + xx + ", " + yy + ", " + size + ", " + size + " should be " + (odd ? "green" : "blue"); + wtu.checkCanvasRect(gl, xx, yy, size, size, color, msg); + } + } + } +} +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/samplers/glsl-function-texture2dprojlod.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/samplers/glsl-function-texture2dprojlod.html new file mode 100644 index 0000000000..c7c091ee8e --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/samplers/glsl-function-texture2dprojlod.html @@ -0,0 +1,162 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL texture2D GLSL 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> +</head> +<body> +<canvas id="example" width="256" height="256" style="width: 16px; height: 16px;"></canvas> +<div id="description"></div> +<div id="console"></div> +<script id="vshader2dvec3" type="x-shader/x-vertex"> +attribute vec4 vPosition; +varying vec4 color; +uniform sampler2D tex; +uniform float divisor; +uniform float lod; +void main() { + gl_Position = vPosition; + color = texture2DProjLod(tex, vec3(0.75 * divisor, 0.25 * divisor, divisor), lod); +} +</script> +<script id="vshader2dvec4" type="x-shader/x-vertex"> +attribute vec4 vPosition; +varying vec4 color; +uniform sampler2D tex; +uniform float divisor; +uniform float lod; +void main() { + gl_Position = vPosition; + color = texture2DProjLod(tex, vec4(0.75 * divisor, 0.25 * divisor, 123.0, divisor), lod); +} +</script> +<script id="fshader2d" type="x-shader/x-fragment"> +precision mediump float; +varying vec4 color; +void main() { + gl_FragData[0] = color; +} +</script> +<script> +"use strict"; +description("tests GLSL texture2DProjLod function"); + +var wtu = WebGLTestUtils; +var canvas = document.getElementById("example"); + +shouldBe("canvas.width", "256"); +shouldBe("canvas.height", "256"); + +var colors = [ + {name: 'red', color:[255, 0, 0, 255]}, + {name: 'green', color:[0, 255, 0, 255]}, + {name: 'blue', color:[0, 0, 255, 255]}, + {name: 'yellow', color:[255, 255, 0, 255]}, + {name: 'magenta', color:[255, 0, 255, 255]}, + {name: 'cyan', color:[0, 255, 255, 255]}, + {name: 'pink', color:[255, 128, 128, 255]}, + {name: 'gray', color:[128, 128, 128, 255]}, + {name: 'light green', color:[128, 255, 128, 255]}, +]; +var contextTypes = ["2d", "webgl"]; +var vectorTypes = ["vec3", "vec4"]; + +var gl = wtu.create3DContext(canvas); +if (gl.getParameter(gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS) > 0) { + runTest(); +} else { + testPassed("MAX_VERTEX_TEXTURE_IMAGE_UNITS == 0, this is okay."); +} + + +function runTest() { + // Avoid creating a WebGL context for every test, as it causes: + // Too many active WebGL contexts. Oldest context will be lost. + var canvasWebGL = document.createElement("canvas"); + var ctxWebGL = canvasWebGL.getContext("webgl"); + + // Might as well do the same for canvas 2d + var canvas2d = document.createElement("canvas"); + var ctx2d = canvas2d.getContext("2d"); + + shouldBe("colors.length", "9"); + contextTypes.forEach((context) => { + vectorTypes.forEach((vectorType) => { + debug(""); + debug(`testing ${context} context with ${vectorType} vertex shader`); + var program = wtu.setupProgram( + gl, ['vshader2d' + vectorType, 'fshader2d'], ['vPosition', 'texCoord0'], [0, 1]); + wtu.setupUnitQuad(gl, 0, 1); + + var tex = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, tex); + gl.texParameteri( + gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST_MIPMAP_NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT); + + // Fill the top right quadrant of each texture level with one of the colors + for (var ii = 0; ii < colors.length; ++ii) { + var color = colors[ii]; + var size = Math.pow(2, colors.length - ii - 1); + + if (context === "2d") { + canvas2d.width = size; + canvas2d.height = size; + ctx2d.fillStyle = "rgb(0,0,0)"; + ctx2d.fillRect(0, 0, size, size); + ctx2d.fillStyle = "rgb(" + color.color[0] + "," + color.color[1] + "," + color.color[2] + ")"; + ctx2d.fillRect(size / 2, 0, size / 2, size / 2); + gl.texImage2D(gl.TEXTURE_2D, ii, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas2d); + } else if (context === "webgl") { + canvasWebGL.width = canvasWebGL.height = size; + ctxWebGL.clearColor(0, 0, 0, 1); + ctxWebGL.clear(gl.COLOR_BUFFER_BIT); + ctxWebGL.enable(gl.SCISSOR_TEST); + ctxWebGL.scissor(size/2, size/2, size/2, size/2) + ctxWebGL.clearColor(color.color[0]/255, color.color[1]/255, color.color[2]/255, 1) + ctxWebGL.clear(gl.COLOR_BUFFER_BIT); + gl.texImage2D(gl.TEXTURE_2D, ii, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvasWebGL); + } + } + + var lodLoc = gl.getUniformLocation(program, "lod"); + var divLoc = gl.getUniformLocation(program, "divisor"); + + for (var div = 1; div < 4; ++div) { + for (var ii = 0; ii < colors.length - 1; ++ii) { + gl.uniform1f(lodLoc, ii); + gl.uniform1f(divLoc, div); + var lodColor = colors[ii]; + var size = Math.pow(2, colors.length - ii - 1); + wtu.clearAndDrawUnitQuad(gl); + wtu.checkCanvas( + gl, lodColor.color, + "sampling with lod = " + ii + + " divider = " + div + + " should be " + lodColor.name); + } + } + }); + }); + 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/variables/00_test_list.txt b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/variables/00_test_list.txt new file mode 100644 index 0000000000..31fe0f8f20 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/variables/00_test_list.txt @@ -0,0 +1,6 @@ +gl-fragcoord.html +gl-frontfacing.html +gl-pointcoord.html +--min-version 1.0.2 glsl-built-ins.html +--min-version 1.0.3 gl-fragcoord-xy-values.html +--min-version 1.0.3 gl-fragdata-and-fragcolor.html diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/variables/gl-fragcoord-xy-values.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/variables/gl-fragcoord-xy-values.html new file mode 100644 index 0000000000..161a58bfc6 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/variables/gl-fragcoord-xy-values.html @@ -0,0 +1,185 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>gl-fragcoord 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="canvas" width="32" height="32"> +</canvas> +<div id="description"></div> +<div id="console"></div> +<script id="vshader" type="x-shader/x-vertex"> +// Inputs +attribute vec4 aPosInfo; + +// Outputs +varying vec2 vTargetPixelCoord; + +void main() +{ + vTargetPixelCoord = aPosInfo.zw; + + gl_PointSize = 1.0; + gl_Position = vec4(aPosInfo.xy, 0.0, 1.0); +} +</script> + +<script id="fshader" type="x-shader/x-fragment"> +precision mediump float; + +// Inputs +varying vec2 vTargetPixelCoord; + +// Colors used to signal correctness +const vec4 red = vec4(1.0, 0.0, 0.0, 1.0); +const vec4 green = vec4(0.0, 1.0, 0.0, 1.0); + +void main() +{ + // Check pixel index + bool pixelIxValid = (floor(gl_FragCoord.xy) == vTargetPixelCoord); + + // Check fractional part of coordinates + bool fracCoordValid = all(lessThan(abs(fract(gl_FragCoord.xy) - vec2(0.5)), vec2(0.0001))); + + gl_FragColor = (pixelIxValid && fracCoordValid) ? green : red; +} +</script> + +<script id="test_fshader" type="x-shader/x-fragment"> +// Shader to test if the frame buffer positions within the output pixel are different for the five render passes +// Pass on frame buffer position in varying, change in vertex shader : vTargetPixelCoord = aPosInfo.xy; +// Set test_fshader in setupProgram() + +precision mediump float; + +// Inputs +varying vec2 vTargetPixelCoord; + +const vec2 pixSize = vec2(2.0/32.0, 2.0/32.0); + +void main() +{ + // Coordinates within a framebuffer pixel [0, 1> + vec2 inPixelCoord = fract(vTargetPixelCoord / pixSize); + + // Create different color dependent on the position inside the framebuffer pixel + float r = (inPixelCoord.x < 0.4) ? 0.2 : (inPixelCoord.x > 0.6) ? 0.8 : 0.5; + float g = (inPixelCoord.y < 0.4) ? 0.2 : (inPixelCoord.y > 0.6) ? 0.8 : 0.5; + + gl_FragColor = vec4(r, g, 0.0, 1.0); +} +</script> + +<script> +"use strict"; + +// Test if gl_FragCoord.xy values are always of the form : +// (first framebuffer pixel index + 0.5, second framebuffer pixel index + 0.5) +// (if no multisampling) + +// This is done by rendering a set of points which targets either the center of the +// output pixel or the center of one of the quadrants + +// Constants +var floatsPerAttribute = 4; + +// Globals +var wtu; +var gl; +var program; +var vxBuffer; + +// Set data for one attribute (framebuffer.xy, pixel_index.xy) +function setPixelData(data, dIx, xx, yy, xSize, ySize, xOffset, yOffset) +{ + // Frame buffer first coordinate [-1, 1] + data[dIx++] = (xx + 0.5) * xSize + xOffset - 1; + + // Frame buffer second coordinate [-1, 1] + data[dIx++] = (yy + 0.5) * ySize + yOffset - 1; + + // Frame buffer pixel first index + data[dIx++] = xx; + + // Frame buffer pixel second index + data[dIx++] = yy; + + return dIx; +} + +// Create attribute data +function createAttributeData(xOffset, yOffset) +{ + // Retrieve realised dimensions of viewport + var widthPx = gl.drawingBufferWidth; + var heightPx = gl.drawingBufferHeight; + var pixelCount = widthPx * heightPx; + + // Pixel size in framebuffer coordinates + var pWidth = 2 / widthPx; + var pHeight = 2 / heightPx; + var data = new Float32Array(pixelCount * floatsPerAttribute); + var dIx = 0; + for (var yy = 0; yy < heightPx; ++yy) + for (var xx = 0; xx < widthPx; ++xx) + dIx = setPixelData(data, dIx, xx, yy, pWidth, pHeight, xOffset * pWidth, yOffset * pHeight); + + if (dIx !== data.length) + wtu.error("gl-fragcoord-xy-values.html, createAttributeData(), index not correct at end"); + + return data; +} + +// Initialize test +function init() +{ + description("tests gl_FragCoord.xy values"); + + wtu = WebGLTestUtils; + gl = wtu.create3DContext("canvas", { antialias: false }); + program = wtu.setupProgram(gl, ["vshader", "fshader"], ["aPosInfo"]); + vxBuffer = gl.createBuffer(); + + gl.bindBuffer(gl.ARRAY_BUFFER, vxBuffer); + gl.enableVertexAttribArray(0); + gl.vertexAttribPointer(0, floatsPerAttribute, gl.FLOAT, false, 0, 0); +} + +// Render data +function render(xOffset, yOffset, passMsg) +{ + // Set attribute data + var data = createAttributeData(xOffset, yOffset); + gl.bufferData(gl.ARRAY_BUFFER, data, gl.DYNAMIC_DRAW); + + gl.clear(gl.COLOR_BUFFER_BIT); + gl.drawArrays(gl.POINTS, 0, data.length / floatsPerAttribute); + wtu.glErrorShouldBe(gl, gl.NO_ERROR, "no errors from draw"); + var green = [0, 255, 0, 255]; + wtu.checkCanvas(gl, green, passMsg); +} + +// Run tests +init(); +render(0, 0, "green : sampling at center of output pixel is correct"); +render(0.25, 0.25, "green : sampling in top right quadrant of output pixel is correct"); +render(-0.25, 0.25, "green : sampling in top left quadrant of output pixel is correct"); +render( 0.25, -0.25, "green : sampling in bottom right quadrant of output pixel is correct"); +render(-0.25, -0.25, "green : sampling in bottom left quadrant of output pixel is correct"); +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/variables/gl-fragcoord.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/variables/gl-fragcoord.html new file mode 100644 index 0000000000..e5f6e27537 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/variables/gl-fragcoord.html @@ -0,0 +1,84 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>gl-fragcoord 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="32" height="32"> +</canvas> +<div id="description"></div> +<div id="console"></div> +<script id="vshader" type="x-shader/x-vertex"> +attribute vec4 vPosition; +void main() +{ + gl_Position = vPosition; +} +</script> + +<script id="fshader" type="x-shader/x-fragment"> +precision mediump float; +void main() +{ + gl_FragColor = vec4( + floor(gl_FragCoord.x * 4.0 / 32.0) / 4.0, + floor(gl_FragCoord.y * 4.0 / 32.0) / 4.0, + floor(gl_FragCoord.z * 4.0) / 4.0, + 1); +} +</script> + +<script> +"use strict"; +function init() +{ + description("tests gl_FragCoord"); + + var wtu = WebGLTestUtils; + var gl = wtu.create3DContext("example"); + var program = wtu.setupProgram(gl, ["vshader", "fshader"], ["vPosition"]); + + var vertexObject = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array( + [-1, -1, -1, 1, -1, 0, -1, 1, 0, + -1, 1, 0, 1, -1, 0, 1, 1, 1]), + 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, 6); + wtu.glErrorShouldBe(gl, gl.NO_ERROR, "no errors from draw"); + + for (var xx = 0; xx < 32; xx += 4) { + for (var yy = 0; yy < 32; yy += 4) { + var zz = (xx / 64) + (yy / 64); + var color = [ + Math.floor(Math.floor(xx * 4.0 / 32.0) / 4 * 256), + Math.floor(Math.floor(yy * 4.0 / 32.0) / 4 * 256), + Math.floor(Math.floor(zz * 4.0) / 4 * 256) + ]; + var msg = "should be " + color; + wtu.checkCanvasRect(gl, xx, yy, 1, 1, color, msg, 4); + } + } +} + +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/variables/gl-fragdata-and-fragcolor.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/variables/gl-fragdata-and-fragcolor.html new file mode 100644 index 0000000000..5f0e82e8af --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/variables/gl-fragdata-and-fragcolor.html @@ -0,0 +1,38 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!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 static assignment to both gl_FragData[0] and gl_FragColor should fail. +// GLES spec section 3.8.2 subsection Shader Outputs. +precision mediump float; + +void main() +{ + gl_FragData[0] = vec4(1, 0, 0, 1); + gl_FragColor = vec4(0, 1, 0, 1); +} +</script> +<script> +"use strict"; +GLSLConformanceTester.runTest(); +var successfullyParsed = true; +</script> +</body> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/glsl/variables/gl-frontfacing.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/variables/gl-frontfacing.html new file mode 100644 index 0000000000..1716161bcf --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/variables/gl-frontfacing.html @@ -0,0 +1,86 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>gl-fragcoord 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="32" height="32"> +</canvas> +<div id="description"></div> +<div id="console"></div> +<script id="vshader" type="x-shader/x-vertex"> +attribute vec4 vPosition; +void main() +{ + gl_Position = vPosition; +} +</script> + +<script id="fshader" type="x-shader/x-fragment"> +precision mediump float; +void main() +{ + gl_FragColor = vec4( + gl_FrontFacing ? 1.0 : 0.0, + gl_FrontFacing ? 0.0 : 1.0, + 0, + 1); +} +</script> + +<script> +"use strict"; +function init() +{ + description("tests gl_FrontFacing"); + + var wtu = WebGLTestUtils; + var gl = wtu.create3DContext("example"); + var program = wtu.setupProgram(gl, ["vshader", "fshader"], ["vPosition"]); + + var gridRes = 4; + wtu.setupIndexedQuad(gl, gridRes, 0, true); + + gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); + gl.drawElements(gl.TRIANGLES, gridRes * gridRes * 6, gl.UNSIGNED_SHORT, 0); + wtu.glErrorShouldBe(gl, gl.NO_ERROR, "no errors from draw"); + + var step = 32 / gridRes; + var halfStep = step / 2; + var quarterStep = halfStep / 2; + for (var xx = 0; xx < 32; xx += step) { + for (var yy = 0; yy < 32; yy += step) { + for (var ii = 0; ii < 2; ++ii) { + var color = [ + ii == 0 ? 255 : 0, + ii == 0 ? 0 : 255, + 0 + ]; + var msg = "should be " + color; + wtu.checkCanvasRect( + gl, + xx + quarterStep + halfStep * ii, + yy + quarterStep + halfStep * ii, + 1, 1, color, msg, 4); + } + } + } +} + +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/variables/gl-pointcoord.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/variables/gl-pointcoord.html new file mode 100644 index 0000000000..f87078a6ff --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/variables/gl-pointcoord.html @@ -0,0 +1,141 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>gl-pointcoord 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="256" height="256"> +</canvas> +<div id="description"></div> +<div id="console"></div> +<script id="vshader" type="x-shader/x-vertex"> +attribute vec4 vPosition; +uniform float uPointSize; +void main() +{ + gl_PointSize = uPointSize; + gl_Position = vPosition; +} +</script> + +<script id="fshader" type="x-shader/x-fragment"> +precision mediump float; +void main() +{ + gl_FragColor = vec4( + gl_PointCoord.x, + gl_PointCoord.y, + 0, + 1); +} +</script> + +<script> +"use strict"; +description("Checks gl_PointCoord and gl_PointSize"); +debug(""); + +// NOTE: I'm not 100% confident in this test. I think it is correct. + +var wtu = WebGLTestUtils; +var gl = wtu.create3DContext("example"); +shouldBeNonNull("gl"); +var program = wtu.setupProgram(gl, ["vshader", "fshader"], ["vPosition"]); +shouldBe("gl.getError()", "gl.NO_ERROR"); + +var canvas = gl.canvas; +var width = canvas.width; +var height = canvas.height; +shouldBe("width", "height"); + +var maxPointSize = gl.getParameter(gl.ALIASED_POINT_SIZE_RANGE)[1]; +shouldBeTrue("maxPointSize >= 1"); +// The minimum and maximum point sizes may be floating-point numbers. +shouldBeTrue("Math.floor(maxPointSize) >= 1"); +maxPointSize = Math.floor(maxPointSize); +shouldBeTrue("maxPointSize % 1 == 0"); + +maxPointSize = Math.min(maxPointSize, 64); +var pointWidth = maxPointSize / width; +var pointStep = Math.floor(maxPointSize / 4); +var pointStep = Math.max(1, pointStep); + +var pointSizeLoc = gl.getUniformLocation(program, "uPointSize"); +gl.uniform1f(pointSizeLoc, maxPointSize); + +var pixelOffset = (maxPointSize % 2) ? (1 / width) : 0; +var vertexObject = gl.createBuffer(); +gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject); +gl.bufferData( + gl.ARRAY_BUFFER, + new Float32Array( + [-0.5 + pixelOffset, -0.5 + pixelOffset, + 0.5 + pixelOffset, -0.5 + pixelOffset, + -0.5 + pixelOffset, 0.5 + pixelOffset, + 0.5 + pixelOffset, 0.5 + pixelOffset]), + gl.STATIC_DRAW); +gl.enableVertexAttribArray(0); +gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0); + +gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); + +gl.drawArrays(gl.POINTS, 0, 4); +shouldBe("gl.getError()", "gl.NO_ERROR"); + +function s2p(s) { + return (s + 1.0) * 0.5 * width; +} + +//function print(x, y) { +// var b = new Uint8Array(4); +// gl.readPixels(x, y, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, b); +// debug("" + x + "," + y + ": " + b[0] + "," + b[1] + "," + b[2]); +//} +// +//for (var ii = 0; ii < 100; ++ii) { +// print(ii, ii); +//} + +for (var py = 0; py < 2; ++py) { + for (var px = 0; px < 2; ++px) { + debug(""); + var pointX = -0.5 + px + pixelOffset; + var pointY = -0.5 + py + pixelOffset; + for (var yy = 0; yy < maxPointSize; yy += pointStep) { + for (var xx = 0; xx < maxPointSize; xx += pointStep) { + // formula for s and t from OpenGL ES 2.0 spec section 3.3 + var xw = s2p(pointX); + var yw = s2p(pointY); + //debug("xw: " + xw + " yw: " + yw); + var u = xx / maxPointSize * 2 - 1; + var v = yy / maxPointSize * 2 - 1; + var xf = Math.floor(s2p(pointX + u * pointWidth)); + var yf = Math.floor(s2p(pointY + v * pointWidth)); + //debug("xf: " + xf + " yf: " + yf); + var s = 0.5 + (xf + 0.5 - xw) / maxPointSize; + var t = 0.5 + (yf + 0.5 - yw) / maxPointSize; + //debug("s: " + s + " t: " + t); + var color = [Math.floor(s * 255), Math.floor((1 - t) * 255), 0]; + var msg = "pixel " + xf + "," + yf + " should be " + color; + wtu.checkCanvasRect(gl, xf, yf, 1, 1, color, msg, 4); + } + } + } +} + +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/variables/glsl-built-ins.html b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/variables/glsl-built-ins.html new file mode 100644 index 0000000000..32c3f8f5e1 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/glsl/variables/glsl-built-ins.html @@ -0,0 +1,106 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL built in variables 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> +</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="vshaderCheck" type="x-shader/x-vertex"> +attribute vec4 a_position; +varying vec4 v_color; +void main() +{ + gl_Position = a_position; + v_color = (gl_$(name) == $(max)) ? vec4(0,1,0,1) : vec4(1,0,0,1); +} +</script> +<script id="fshader" type="x-shader/x-fragment"> +precision mediump float; +varying vec4 v_color; +void main() +{ + gl_FragColor = v_color; +} +</script> +<script id="fshaderCheck" type="x-shader/x-fragment"> +precision mediump float; +void main() +{ + gl_FragColor = (gl_$(name) == $(max)) ? vec4(0,1,0,1) : vec4(1,0,0,1); +} +</script> +<script> +"use strict"; +description(); +var wtu = WebGLTestUtils; +var gl = wtu.create3DContext("example"); +var contextVersion = wtu.getDefault3DContextVersion(); + +var variables = [ + { name: 'MaxVertexAttribs', min: 8, }, + { name: 'MaxVertexUniformVectors', min: 128, }, + { name: 'MaxVaryingVectors', min: 8, }, + { name: 'MaxVertexTextureImageUnits', min: 0, }, + { name: 'MaxCombinedTextureImageUnits', min: 8, }, + { name: 'MaxTextureImageUnits', min: 8, }, + { name: 'MaxFragmentUniformVectors', min: 16, }, +]; + +if (contextVersion <= 1) { + variables.push({ name: 'MaxDrawBuffers', min: 1, max: 1}); +} else { + variables.push({ name: 'MaxDrawBuffers', min: 1, }); +} + +var toUnderscore = function(str) { + return str.replace(/([a-z])([A-Z])/g, function (g) { return g[0] + "_" + g[1].toUpperCase() }).toUpperCase(); +}; + +var shaderPairs = [ + [wtu.getScript("vshader"), wtu.getScript("fshaderCheck")], + [wtu.getScript("vshaderCheck"), wtu.getScript("fshader")], +]; + +wtu.setupUnitQuad(gl); + +variables.forEach(function(variable) { + debug(""); + debug("Testing gl_" + variable.name); + if (!variable.max) { + variable.max = gl.getParameter(gl[toUnderscore(variable.name)]); + expectTrue(variable.max >= variable.min, "gl.getParameter(gl." + toUnderscore(variable.name) + ") >= " + variable.min); + } + shaderPairs.forEach(function(pair) { + var shaders = [wtu.replaceParams(pair[0], variable), wtu.replaceParams(pair[1], variable)]; + var program = wtu.setupProgram(gl, shaders, ["a_position"], undefined, true); + wtu.clearAndDrawUnitQuad(gl); + wtu.checkCanvas(gl, [0, 255, 0, 255], "should be green"); + }); +}); + +var successfullyParsed = true; +</script> +<script src="../../../js/js-test-post.js"></script> +</body> +</html> + |