diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-as-out-parameter.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-as-out-parameter.html')
-rw-r--r-- | dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/struct-as-out-parameter.html | 115 |
1 files changed, 115 insertions, 0 deletions
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> |