Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / webgl / src / sdk / tests / conformance / glsl / constructors / glsl-construct-vec-mat-corner-cases.html
1 <!--
2
3 /*
4 ** Copyright (c) 2014 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
43 <script id="vsVec4Mat2Add" type="text/something-not-javascript">
44 void main()
45 {
46     mat2 m1 = mat2(1.0, 2.0, 3.0, 4.0);
47     mat2 m2 = mat2(0);
48     vec4 v = vec4(m1 + m2);
49     gl_Position = v;
50 }
51 </script>
52 <script id="fsVec4Mat3Add" type="text/something-not-javascript">
53 precision mediump float;
54 void main()
55 {
56     mat3 m1 = mat3(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0);
57     mat3 m2 = mat3(0);
58     vec4 v = vec4(m1 + m2);
59     gl_FragColor = v;
60 }
61 </script>
62
63 <script id="vsMat2Vec4Sub" type="text/something-not-javascript">
64 void main()
65 {
66     vec4 v1 = vec4(1.0, 2.0, 3.0, 4.0);
67     vec4 v2 = vec4(0);
68     mat2 m = mat2(v1 - v2);
69     gl_Position = vec4(1.0, m);
70 }
71 </script>
72 <script id="fsMat3Vec4AddSub" type="text/something-not-javascript">
73 precision mediump float;
74 void main()
75 {
76     vec4 v1 = vec4(1.0, 2.0, 3.0, 4.0);
77     vec4 v2 = vec4(0);
78     mat3 m = mat3(v1 + v2, 5.0, v1 - v2);
79     gl_FragColor = vec4(m);
80 }
81 </script>
82
83 <script id="vsVec4Mat2Func" type="text/something-not-javascript">
84 mat2 f(mat2 a)
85 {
86     return a;
87 }
88 void main()
89 {
90     mat2 m = mat2(1.0, 2.0, 3.0, 4.0);
91     vec4 v = vec4(f(m));
92     gl_Position = vec4(1.0, v);
93 }
94 </script>
95 <script id="fsVec4Mat3Func" type="text/something-not-javascript">
96 precision mediump float;
97 mat3 f(mat3 a)
98 {
99     return a;
100 }
101 void main()
102 {
103     mat3 m = mat3(0);
104     vec4 v = vec4(f(m));
105     gl_FragColor = v;
106 }
107 </script>
108
109 <script id="vsMat2Vec4Func" type="text/something-not-javascript">
110 vec4 f(vec4 a)
111 {
112     return a;
113 }
114 void main()
115 {
116     vec4 v = vec4(1.0, 2.0, 3.0, 4.0);
117     mat2 m = mat2(f(v));
118     gl_Position = vec4(1.0, m);
119 }
120 </script>
121 <script id="fsMat3Vec4Func" type="text/something-not-javascript">
122 precision mediump float;
123 vec4 f(vec4 a)
124 {
125     return a;
126 }
127 void main()
128 {
129     vec4 v1 = vec4(1.0, 2.0, 3.0, 4.0);
130     vec4 v2 = vec4(0);
131     mat3 m = mat3(f(v1), 5.0, f(v2));
132     gl_FragColor = vec4(m);
133 }
134 </script>
135
136 <script id="vsMat4VecMultiple" type="text/something-not-javascript">
137 vec4 f(vec4 a)
138 {
139     return a;
140 }
141 void main()
142 {
143     vec2 v2 = vec2(1.0, 2.0);
144     vec3 v3 = vec3(1.0, 2.0, 3.0);
145     vec4 v4 = vec4(1.0, 2.0, 3.0, 4.0);
146     mat4 m = mat4(0.0, v2, 1.0, v3 + vec3(1), 2.0, vec4(0), f(v4));
147     gl_Position = vec4(1.0, m);
148 }
149 </script>
150 <script id="fsMat4VecMultiple" type="text/something-not-javascript">
151 precision mediump float;
152 vec4 f(vec4 a)
153 {
154     return a;
155 }
156 void main()
157 {
158     vec2 v2 = vec2(1.0, 2.0);
159     vec3 v3 = vec3(1.0, 2.0, 3.0);
160     vec4 v4 = vec4(1.0, 2.0, 3.0, 4.0);
161     mat4 m = mat4(0.0, v2, 1.0, v3 + vec3(1), 2.0, vec4(0), f(v4));
162     gl_FragColor = vec4(m);
163 }
164 </script>
165
166 <script>
167 "use strict";
168 var wtu = WebGLTestUtils;
169 var tests = [];
170
171 tests.push({
172   vShaderSource: wtu.getScript("vsVec4Mat2Add"),
173   vShaderSuccess: true,
174   fShaderSource: wtu.getScript("fsVec4Mat3Add"),
175   fShaderSuccess: true,
176   linkSuccess: true,
177   passMsg: "vec(mat +/- mat) works ok",
178 });
179 tests.push({
180   vShaderSource: wtu.getScript("vsMat2Vec4Sub"),
181   vShaderSuccess: true,
182   fShaderSource: wtu.getScript("fsMat3Vec4AddSub"),
183   fShaderSuccess: true,
184   linkSuccess: true,
185   passMsg: "mat(vec +/- vec) works ok",
186 });
187 tests.push({
188   vShaderSource: wtu.getScript("vsVec4Mat2Func"),
189   vShaderSuccess: true,
190   fShaderSource: wtu.getScript("fsVec4Mat3Func"),
191   fShaderSuccess: true,
192   linkSuccess: true,
193   passMsg: "vec(func(mat)) works ok",
194 });
195 tests.push({
196   vShaderSource: wtu.getScript("vsMat2Vec4Func"),
197   vShaderSuccess: true,
198   fShaderSource: wtu.getScript("fsMat3Vec4Func"),
199   fShaderSuccess: true,
200   linkSuccess: true,
201   passMsg: "mat(func(vec)) works ok",
202 });
203 tests.push({
204   vShaderSource: wtu.getScript("vsMat4VecMultiple"),
205   vShaderSuccess: true,
206   fShaderSource: wtu.getScript("fsMat4VecMultiple"),
207   fShaderSuccess: true,
208   linkSuccess: true,
209   passMsg: "mat4(float, vec2, float, vec3+vec3, float, vec4, f(vec4)) works ok",
210 });
211
212 GLSLConformanceTester.runTests(tests);
213 var successfullyParsed = true;
214 </script>
215 </body>
216 </html>