Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(876)

Side by Side Diff: third_party/webgl/sdk/tests/conformance/glsl/misc/re-compile-re-link.html

Issue 10399113: Roll webgl conformance tests to r17874: part 2, adding r17874 (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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 Re-Compile and Re-link Shader conformance test.</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.js"> </script>
36 <script src="../../resources/webgl-test-utils.js"> </script>
37 </head>
38 <body>
39 <canvas id="example" width="4" height="4" style="width: 40px; height: 30px;"></c anvas>
40 <div id="description"></div>
41 <div id="console"></div>
42 <script id="vshader" type="x-shader/x-vertex">
43 attribute float column;
44 attribute float height;
45 uniform float position;
46 void main() {
47 gl_Position = vec4(mod(column - position, 1.0) * 2.0 - 1.0, height, 0, 1);
48 }
49 </script>
50
51 <script id="fshader1" type="x-shader/x-fragment">
52 precision mediump float;
53 void main() {
54 gl_FragColor = vec4(1,0,0,1);
55 }
56 </script>
57 <script id="fshader2" type="x-shader/x-fragment">
58 precision mediump float;
59 uniform float foobar;
60 void main() {
61 gl_FragColor = vec4(1,0,foobar,1);
62 }
63 </script>
64 <script id="vshaderB" type="not-js">
65 attribute vec2 position;
66 varying vec2 v_texCoord;
67 void main() {
68 gl_Position = vec4(position, 0, 1);
69 v_texCoord = vec2(position * 0.5 + 0.5);
70 }
71 </script>
72 <script id="fshaderB" type="not-js">
73 precision mediump float;
74 varying vec2 v_texCoord;
75 uniform sampler2D tex;
76 void main() {
77 gl_FragColor = texture2D(tex, v_texCoord);
78 }
79 </script>
80
81 <script>
82 description(document.title);
83 var wtu = WebGLTestUtils;
84 var gl = wtu.create3DContext("example");
85
86 var vsSource = document.getElementById("vshader").text;
87 var fs1Source = document.getElementById("fshader1").text;
88 var fs2Source = document.getElementById("fshader2").text;
89
90 var vsSourceB = document.getElementById("vshaderB").text;
91 var fsSourceB = document.getElementById("fshaderB").text;
92
93 var vShader = gl.createShader(gl.VERTEX_SHADER);
94 var fShader = gl.createShader(gl.FRAGMENT_SHADER);
95
96 var vShaderB = gl.createShader(gl.VERTEX_SHADER);
97 var fShaderB = gl.createShader(gl.FRAGMENT_SHADER);
98
99 var program = gl.createProgram();
100 var programB = gl.createProgram();
101
102 gl.attachShader(program, vShader);
103 gl.attachShader(program, fShader);
104
105 gl.attachShader(programB, vShaderB);
106 gl.attachShader(programB, fShaderB);
107
108 var success;
109 var shader;
110
111 function checkShaderStatus(s) {
112 shader = s;
113 shouldBeTrue("success = gl.getShaderParameter(shader, gl.COMPILE_STATUS)");
114 if (!success) {
115 debug("error: " + gl.getShaderInfoLog());
116 }
117 }
118
119 var prg;
120 function checkProgramStatus(p) {
121 prg = p;
122 shouldBeTrue("success = gl.getProgramParameter(prg, gl.LINK_STATUS)");
123 if (!success) {
124 debug("error: " + gl.getProgramInfoLog(prg));
125 }
126 }
127
128 for (var i = 0; i < 10; ++i) {
129 gl.shaderSource(vShader, vsSource);
130 gl.compileShader(vShader);
131 checkShaderStatus(vShader)
132 gl.shaderSource(fShader, fs1Source);
133 gl.compileShader(fShader);
134 checkShaderStatus(fShader)
135
136 gl.linkProgram(program);
137 checkProgramStatus(program)
138 gl.useProgram(program);
139
140 gl.shaderSource(vShaderB, vsSourceB);
141 gl.compileShader(vShaderB);
142 checkShaderStatus(vShaderB)
143 gl.shaderSource(fShaderB, fsSourceB);
144 gl.compileShader(fShaderB);
145 checkShaderStatus(fShaderB)
146
147 gl.linkProgram(programB);
148 checkProgramStatus(programB)
149
150 gl.useProgram(programB);
151 }
152
153 for (var i = 0; i < 10; ++i) {
154 // Now change the fragment shader
155 gl.shaderSource(fShader, fs2Source);
156 gl.compileShader(fShader);
157 checkShaderStatus(fShader)
158
159 // And re-link
160 gl.linkProgram(program);
161 checkProgramStatus(program)
162 }
163
164 glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors");
165
166 successfullyParsed = true;
167 </script>
168 <script src="../../../resources/js-test-post.js"></script>
169
170 </body>
171 </html>
172
173
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698