summaryrefslogtreecommitdiffstats
path: root/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-struct-scope.html
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/shader-struct-scope.html231
1 files changed, 231 insertions, 0 deletions
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>