Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / webgl / src / sdk / tests / conformance / glsl / bugs / compare-loop-index-to-uniform.html
1 <!--
2
3 /*
4 ** Copyright (c) 2013 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>Driver bug - Comparing loop index against uniform in a fragment shader should work</title>
33 <link rel="stylesheet" href="../../../resources/js-test-style.css"/>
34 <script src="../../../resources/js-test-pre.js"></script>
35 <script src="../../resources/webgl-test-utils.js"></script>
36 </head>
37 <body>
38 <canvas id="canvas" width="256" height="256"> </canvas>
39 <div id="description"></div>
40 <div id="console"></div>
41 <script id="vshader" type="x-shader/x-vertex">
42 attribute vec3 aPosition;
43
44 void main() {
45     gl_Position = vec4(aPosition, 1);
46 }
47 </script>
48 <script id="fshader" type="x-shader/x-fragment">
49 precision mediump float;
50 uniform int uCount;
51
52 void main() {
53     float a = 0.0;
54     for (int i = 0; i < 5; ++i) {
55         if (i < uCount) {
56             a += 0.2;
57         }
58     }
59     gl_FragColor = vec4(1.0 - a, a, 0.0, 1.0);
60 }
61 </script>
62 <script type="text/javascript">
63 "use strict";
64 description("Comparing loop index to an uniform in a fragment shader should work.");
65 debug("");
66 var wtu = WebGLTestUtils;
67 function test() {
68   var gl = wtu.create3DContext("canvas");
69   if (!gl) {
70     testFailed("context does not exist");
71     return;
72   }
73   wtu.setupUnitQuad(gl);
74   var program = wtu.setupProgram(gl, ["vshader", "fshader"], ["aPosition"], undefined, true);
75   var uniformLoc = gl.getUniformLocation(program, 'uCount');
76   gl.uniform1i(uniformLoc, 5);
77   wtu.drawUnitQuad(gl);
78   wtu.checkCanvasRect(gl, 0, 0, 256, 256, [0, 255, 0, 255]);
79 };
80
81 test();
82 var successfullyParsed = true;
83 finishTest();
84 </script>
85 </body>
86 </html>
87