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

Side by Side Diff: third_party/webgl/sdk/tests/conformance/programs/gl-get-active-uniform.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 getActiveUniform 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="16" height="16"></canvas>
40 <div id="description"></div>
41 <div id="console"></div>
42 <script id="vshader" type="x-shader/x-vertex">
43 void main()
44 {
45 gl_Position = vec4(0, 0, 0, 1);
46 }
47 </script>
48 <script id="fshader" type="x-shader/x-fragment">
49 precision mediump float;
50 uniform $type uniform0;
51 void main()
52 {
53 gl_FragColor = vec4(0,$access,0,1);
54 }
55 </script>
56 <script id="fshaderA" type="x-shader/x-fragment">
57 precision mediump float;
58 uniform float uniform0;
59 void main()
60 {
61 gl_FragColor = vec4(0,uniform0,0,1);
62 }
63 </script>
64 <script id="fshaderB" type="x-shader/x-fragment">
65 precision mediump float;
66 uniform float uniform0;
67 uniform float uniform1;
68 void main()
69 {
70 gl_FragColor = vec4(0,uniform0,uniform1,1);
71 }
72 </script>
73 <script>
74 description("Tests getActiveUniform for various types");
75
76 var wtu = WebGLTestUtils;
77 var gl = wtu.create3DContext("example");
78
79 var tests = [
80 { glType: gl.FLOAT, size: 1, type: 'float', access: 'uniform0'},
81 { glType: gl.FLOAT_VEC2, size: 1, type: 'vec2', access: 'uniform0[1]'},
82 { glType: gl.FLOAT_VEC3, size: 1, type: 'vec3', access: 'uniform0[2]'},
83 { glType: gl.FLOAT_VEC4, size: 1, type: 'vec4', access: 'uniform0[3]'},
84 { glType: gl.FLOAT_MAT2, size: 1, type: 'mat2', access: 'uniform0[1][1]'},
85 { glType: gl.FLOAT_MAT3, size: 1, type: 'mat3', access: 'uniform0[2][2]'},
86 { glType: gl.FLOAT_MAT3, size: 1, type: 'mat3', access: 'uniform0[2][2]'},
87 { glType: gl.FLOAT_MAT4, size: 1, type: 'mat4', access: 'uniform0[3][3]'},
88 { glType: gl.INT, size: 1, type: 'int', access: 'float(uniform0)'},
89 { glType: gl.INT_VEC2, size: 1, type: 'ivec2', access: 'float(uniform0[1])'},
90 { glType: gl.INT_VEC3, size: 1, type: 'ivec3', access: 'float(uniform0[2])'},
91 { glType: gl.INT_VEC4, size: 1, type: 'ivec4', access: 'float(uniform0[3])'},
92 { glType: gl.BOOL, size: 1, type: 'bool', access: 'float(uniform0)'},
93 { glType: gl.BOOL_VEC2, size: 1, type: 'bvec2', access: 'float(uniform0[1])'},
94 { glType: gl.BOOL_VEC3, size: 1, type: 'bvec3', access: 'float(uniform0[2])'},
95 { glType: gl.BOOL_VEC4, size: 1, type: 'bvec4', access: 'float(uniform0[3])'},
96 { glType: gl.SAMPLER_2D,
97 size: 1,
98 type: 'sampler2D',
99 access: 'texture2D(uniform0, vec2(0,0)).x'
100 },
101 { glType: gl.SAMPLER_CUBE,
102 size: 1,
103 type: 'samplerCube',
104 access: 'textureCube(uniform0, vec3(0,1,0)).x'
105 }
106 ];
107
108 var vs = wtu.loadShaderFromScript(gl, 'vshader', gl.VERTEX_SHADER);
109 var source = document.getElementById('fshader').text;
110
111 function createProgram(type, access) {
112 var fs = wtu.loadShader(
113 gl,
114 source.replace('$type', type).replace('$access', access),
115 gl.FRAGMENT_SHADER);
116 var program = wtu.setupProgram(gl, [vs, fs]);
117 glErrorShouldBe(gl, gl.NO_ERROR, "no errors from setup");
118 return program;
119 }
120
121 for (var tt = 0; tt < tests.length; ++tt) {
122 var t = tests[tt];
123 var program = createProgram(t.type, t.access);
124 var numUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);
125 var found = false;
126 for (var ii = 0; ii < numUniforms; ++ii) {
127 var info = gl.getActiveUniform(program, ii);
128 if (info.name == 'uniform0') {
129 found = true;
130 assertMsg(info.type == t.glType,
131 "type must be " + wtu.glEnumToString(gl, t.glType) + " was " +
132 wtu.glEnumToString(gl, info.type));
133 assertMsg(info.size == t.size,
134 "size must be " + t.size + ' was ' + info.size);
135 }
136 }
137 if (!found) {
138 testFailed("uniform 'uniform0' not found");
139 }
140 }
141
142 var p1 = wtu.setupProgram(gl, [vs, 'fshaderA']);
143 glErrorShouldBe(gl, gl.NO_ERROR, "no errors from program A");
144 var p2 = wtu.setupProgram(gl, [vs, 'fshaderB']);
145 glErrorShouldBe(gl, gl.NO_ERROR, "no errors from program B");
146 var l1 = gl.getUniformLocation(p1, 'uniform0');
147 glErrorShouldBe(gl, gl.NO_ERROR, "no errors getting location of uniform0 p1");
148 var l2 = gl.getUniformLocation(p2, 'uniform0');
149 glErrorShouldBe(gl, gl.NO_ERROR, "no errors getting location of uniform0 p2");
150
151 gl.useProgram(p2);
152 gl.uniform1f(l2, 1);
153 glErrorShouldBe(gl, gl.NO_ERROR, "no errors setting uniform 0");
154 gl.uniform1f(l1, 2);
155 glErrorShouldBe(gl, gl.INVALID_OPERATION,
156 "setting a uniform using a location from another program");
157
158 successfullyParsed = true;
159 </script>
160 <script src="../../resources/js-test-post.js"></script>
161
162 </body>
163 </html>
164
165
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698