tizen beta release
[framework/web/webkit-efl.git] / LayoutTests / fast / canvas / webgl / uniform-location-length-limits.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>WebGL uniform location length tests</title>
6 <script src="../../js/resources/js-test-pre.js"></script>
7 <script src="resources/webgl-test.js"> </script>
8 <script src="resources/webgl-test-utils.js"> </script>
9 </head>
10 <body>
11 <canvas id="example" width="50" height="50">
12 There is supposed to be an example drawing here, but it's not important.
13 </canvas>
14 <div id="description">Verify limits on the lengths of uniform locations.</div>
15 <div id="console"></div>
16 <script id="goodVertexShader" type="x-shader/x-vertex">
17 // A vertex shader where the needed uniform location is exactly 256 characters.
18 struct Nesting2 {
19     vec4 identifier62CharactersLong_01234567890123456789012345678901234;
20 };
21
22 struct Nesting1 {
23     Nesting2 identifier64CharactersLong_0123456789012345678901234567890123456;
24 };
25
26 uniform Nesting1 identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789;
27
28 void main() {
29     gl_Position = identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.identifier64CharactersLong_0123456789012345678901234567890123456.identifier62CharactersLong_01234567890123456789012345678901234;
30 }
31 </script>
32 <script id="badVertexShader" type="x-shader/x-vertex">
33 // A vertex shader where the needed uniform location is 257 characters.
34 struct Nesting2 {
35     vec4 identifier63CharactersLong_012345678901234567890123456789012345;
36 };
37
38 struct Nesting1 {
39     Nesting2 identifier64CharactersLong_0123456789012345678901234567890123456;
40 };
41
42 uniform Nesting1 identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789;
43
44 void main() {
45     Nesting2 temp = identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.identifier64CharactersLong_0123456789012345678901234567890123456;
46     gl_Position = temp.identifier63CharactersLong_012345678901234567890123456789012345;
47 }
48 </script>
49 <script id="fragmentShader" type="x-shader/x-fragment">
50 precision mediump float;
51
52 void main() {
53     gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
54 }
55 </script>
56 <script>
57 if (window.initNonKhronosFramework) {
58     window.initNonKhronosFramework(false);
59 }
60
61 var wtu = WebGLTestUtils;
62 var gl = wtu.create3DContext(document.getElementById("example"));
63
64 debug("Test uniform location underneath the length limit");
65 var program = wtu.loadProgramFromScript(gl, "goodVertexShader", "fragmentShader");
66 shouldBe('gl.getProgramParameter(program, gl.LINK_STATUS)', 'true');
67 var uniformLoc = gl.getUniformLocation(program, "identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.identifier64CharactersLong_0123456789012345678901234567890123456.identifier62CharactersLong_01234567890123456789012345678901234");
68 shouldBeNonNull('uniformLoc');
69 wtu.glErrorShouldBe(gl, gl.NONE);
70
71 debug("Test uniform location over the length limit");
72 program = wtu.loadProgramFromScript(gl, "badVertexShader", "fragmentShader");
73 wtu.glErrorShouldBe(gl, gl.NONE);
74 shouldBe('gl.getProgramParameter(program, gl.LINK_STATUS)', 'true');
75 var uniformLoc = gl.getUniformLocation(program, "identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.identifier64CharactersLong_0123456789012345678901234567890123456.identifier63CharactersLong_012345678901234567890123456789012345");
76 wtu.glErrorShouldBe(gl, gl.INVALID_VALUE);
77 shouldBeNull('uniformLoc');
78
79 </script>
80 <script src="../../js/resources/js-test-post.js"></script>
81 </body>
82 </html>