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/bugs/complex-glsl-does-not-crash.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/bugs/complex-glsl-does-not-crash.html')
-rw-r--r-- | dom/canvas/test/webgl-conf/checkout/conformance/glsl/bugs/complex-glsl-does-not-crash.html | 191 |
1 files changed, 191 insertions, 0 deletions
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> |