Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / webgl / src / sdk / tests / conformance / glsl / misc / shaders-with-mis-matching-uniforms.html
1 <!--
2
3 /*
4 ** Copyright (c) 2012 The Khronos Group Inc.
5 **
6 ** Permission is hereby granted, free of charge, to any person obtaining a
7 ** copy of this software and/or associated documentation files (the
8 ** "Materials"), to deal in the Materials without restriction, including
9 ** without limitation the rights to use, copy, modify, merge, publish,
10 ** distribute, sublicense, and/or sell copies of the Materials, and to
11 ** permit persons to whom the Materials are furnished to do so, subject to
12 ** the following conditions:
13 **
14 ** The above copyright notice and this permission notice shall be included
15 ** in all copies or substantial portions of the Materials.
16 **
17 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
24 */
25
26 -->
27
28 <!DOCTYPE html>
29 <html>
30 <head>
31 <meta charset="utf-8">
32 <title>WebGL GLSL Conformance Tests</title>
33 <link rel="stylesheet" href="../../../resources/js-test-style.css"/>
34 <link rel="stylesheet" href="../../resources/glsl-feature-tests.css"/>
35 <script src="../../../resources/js-test-pre.js"></script>
36 <script src="../../resources/webgl-test-utils.js"></script>
37 <script src="../../resources/glsl-conformance-test.js"></script>
38 </head>
39 <body>
40 <div id="description"></div>
41 <div id="console"></div>
42 <script id="vertexShader" type="text/something-not-javascript">
43 // Shaders with mis-matching uniform types should fail
44 // GLSL 1.017 4.3.4
45 uniform $(type) u_uniform;
46
47 void main()
48 {
49     gl_Position = $(code);
50 }
51 </script>
52 <script id="fragmentShader" type="text/something-not-javascript">
53 // Shaders with mis-matching uniform types should fail
54 // GLSL 1.017 4.3.4
55 precision mediump float;
56
57 uniform $(type) u_uniform;
58
59 void main()
60 {
61     gl_FragColor = $(code);
62 }
63 </script>
64 <script>
65 "use strict";
66 var wtu = WebGLTestUtils;
67 var uniformTypes = [
68   { type: "bool",  code: "vec4(u_uniform, 0, 0, 0)", },
69   { type: "float", code: "vec4(u_uniform, 0, 0, 0)", },
70   { type: "int",   code: "vec4(u_uniform, 0, 0, 0)", },
71   { type: "vec2",  code: "vec4(u_uniform, 0, 0)", },
72   { type: "ivec2", code: "vec4(u_uniform, 0, 0)", },
73   { type: "bvec2", code: "vec4(u_uniform, 0, 0)", },
74   { type: "vec3",  code: "vec4(u_uniform, 0)", },
75   { type: "ivec3", code: "vec4(u_uniform, 0)", },
76   { type: "bvec3", code: "vec4(u_uniform, 0)", },
77   { type: "vec4",  code: "vec4(u_uniform)", },
78   { type: "ivec4", code: "vec4(u_uniform)", },
79   { type: "bvec4", code: "vec4(u_uniform)", },
80   { type: "mat2",  code: "vec4(u_uniform[0][0], 0, 0, 0)", },
81   { type: "mat3",  code: "vec4(u_uniform[0][0], 0, 0, 0)", },
82   { type: "mat4",  code: "vec4(u_uniform[0][0], 0, 0, 0)", },
83 ];
84 var vSource = wtu.getScript("vertexShader");
85 var fSource = wtu.getScript("fragmentShader");
86 var tests = [];
87 for (var ii = 0; ii < uniformTypes.length; ++ii) {
88   var u1 = uniformTypes[ii];
89   var vs = wtu.replaceParams(vSource, u1);
90   for (var jj = ii + 1; jj < uniformTypes.length; ++jj) {
91     var u2 = uniformTypes[jj];
92     var fs = wtu.replaceParams(fSource, u2);
93     tests.push({
94       vShaderSource: vs,
95       vShaderSuccess: true,
96       fShaderSource: fs,
97       fShaderSuccess: true,
98       linkSuccess: false,
99       passMsg: "vertex shader with uniform " + u1.type + " and fragment shader with uniform " + u2.type + " with the same name should fail to link",
100     });
101   }
102 }
103
104 GLSLConformanceTester.runTests(tests);
105 var successfullyParsed = true;
106 </script>
107 </body>
108 </html>