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

Side by Side Diff: conformance/more/functions/uniformMatrixBadArgs.html

Issue 41503006: Add ToT WebGL conformance tests : part 8 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/webgl/sdk/tests/
Patch Set: Created 7 years, 1 month 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
« no previous file with comments | « conformance/more/functions/uniformMatrix.html ('k') | conformance/more/functions/uniformf.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <!--
6
7 /*
8 ** Copyright (c) 2012 The Khronos Group Inc.
9 **
10 ** Permission is hereby granted, free of charge, to any person obtaining a
11 ** copy of this software and/or associated documentation files (the
12 ** "Materials"), to deal in the Materials without restriction, including
13 ** without limitation the rights to use, copy, modify, merge, publish,
14 ** distribute, sublicense, and/or sell copies of the Materials, and to
15 ** permit persons to whom the Materials are furnished to do so, subject to
16 ** the following conditions:
17 **
18 ** The above copyright notice and this permission notice shall be included
19 ** in all copies or substantial portions of the Materials.
20 **
21 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
25 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
26 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
28 */
29
30 -->
31 <link rel="stylesheet" type="text/css" href="../unit.css" />
32 <script type="application/x-javascript" src="../unit.js"></script>
33 <script type="application/x-javascript" src="../util.js"></script>
34 <script type="application/x-javascript">
35
36 Tests.startUnit = function () {
37 var canvas = document.getElementById('gl');
38 var unwrappedGL = getGLContext(canvas);
39 var gl = wrapGLContext(unwrappedGL);
40 return [gl, unwrappedGL];
41 }
42
43 Tests.testUniformf = function(gl, unwrappedGL) {
44 var sh = new Filter(gl, 'foobar-vert', 'foobar-frag');
45 sh.apply(function(f){
46 var fm4 = f.uniform('fm4');
47 var fm2 = f.uniform('fm2');
48 var fm3 = f.uniform('fm3');
49 assertGLError(gl, gl.INVALID_VALUE, "bad transpose 4fv",
50 function(){gl.uniformMatrix4fv(fm4, true, [1,0,0,0, 0,2,0,0, 0,0,3,0, 0, 0,0,4]);});
51 assertGLError(gl, gl.INVALID_VALUE, "bad transpose 3fv",
52 function(){gl.uniformMatrix3fv(fm3, true, [1,0,0, 0,2,0, 0,0,3]);});
53 assertGLError(gl, gl.INVALID_VALUE, "bad transpose 2fv",
54 function(){gl.uniformMatrix2fv(fm2, true, [1,0, 0,2]);});
55 assertThrowNoGLError(gl, "bad location",
56 function(){gl.uniformMatrix4fv(588939, false, [1,0,0,0, 0,2,0,0, 0,0,3,0 , 0,0,0,4]);});
57 assertThrowNoGLError(gl, "bad location (negative)",
58 function(){gl.uniformMatrix4fv(-588939, false, [1,0,0,0, 0,2,0,0, 0,0,3, 0, 0,0,0,4]);});
59 assertGLError(gl, gl.INVALID_VALUE, "17 values to 4fv",
60 function(){gl.uniformMatrix4fv(fm4, false, [0,1,0,0,0, 0,2,0,0, 0,0,3,0, 0,0,0,4]);});
61 assertGLError(gl, gl.INVALID_VALUE, "5 values to 2fv",
62 function(){gl.uniformMatrix2fv(fm2, false, [0,2,1, 2,2]);});
63 assertGLError(gl, gl.INVALID_VALUE, "10 values to 3fv",
64 function(){gl.uniformMatrix3fv(fm3, false, [0,2,2,2, 2,2,2, 2,1,2]);});
65 assertGLError(gl, gl.INVALID_VALUE, "too few values to 4fv",
66 function(){gl.uniformMatrix4fv(fm4, false, [0,0,0, 0,2,0,0, 0,0,3,0, 0,0 ,0,4]);});
67 assertGLError(gl, gl.INVALID_VALUE, "too few values to 2fv",
68 function(){gl.uniformMatrix2fv(fm2, false, [1, 2,2]);});
69 assertGLError(gl, gl.INVALID_VALUE, "too few values to 2fv",
70 function(){gl.uniformMatrix2fv(fm2, false, []);});
71 assertThrowNoGLError(gl, "string for data",
72 function(){gl.uniformMatrix2fv(fm2, false, "fm4");});
73 assertGLError(gl, gl.INVALID_VALUE, "too few values to 3fv",
74 function(){gl.uniformMatrix3fv(fm3, false, [2,2, 2,2,2, 2,1,2]);});
75 gl.uniformMatrix4fv(fm4, false, [1,0,0,0, 0,2,0,0, 0,0,3,0, 0,0,0,4]);
76 gl.uniformMatrix2fv(fm2, false, [2,1, 2,2]);
77 gl.uniformMatrix3fv(fm3, false, [2,2,2, 2,2,2, 2,1,2]);
78 assertGLError(gl, gl.INVALID_OPERATION, "3fv on mat4",
79 function(){gl.uniformMatrix3fv(fm4, false, [1,0,0, 0,2,0, 0,0,3]);});
80 assertGLError(gl, gl.INVALID_OPERATION, "3fv on mat2",
81 function(){gl.uniformMatrix3fv(fm2, false, [0,2,1, 0,2,2, 0,0,0]);});
82 assertGLError(gl, gl.INVALID_OPERATION, "2fv om mat3",
83 function(){gl.uniformMatrix2fv(fm3, false, [2,2, 2,2]);});
84 for (var ii = 2; ii <= 4; ++ii) {
85 var all = [];
86 var mats = [[],[]];
87 for (var jj = 0; jj < 2; ++jj) {
88 for (var kk = 0; kk < ii * ii; ++kk) {
89 mats[jj].push(jj + 1);
90 all.push(jj + 1);
91 }
92 }
93 var loc0Name = 'am' + ii + '[0]';
94 var loc1Name = 'am' + ii + '[1]';
95 var loc0 = f.uniform(loc0Name);
96 var loc1 = f.uniform(loc1Name);
97 var fname = "uniformMatrix" + ii + "fv";
98 assert(loc0Name, loc0 != null);
99 assert(loc1Name, loc1 != null);
100 assertOk("set array of 2 matrices " + ii + "fv",
101 function(){gl[fname].call(gl,loc0, false, all);});
102 var actual = unwrappedGL.getUniform(sh.shader.program, loc0);
103 assert("got value for loc0",
104 gl.NO_ERROR == checkError(gl, "getUniform loc0"));
105 assertArrayEquals(mats[0], actual);
106 var actual = unwrappedGL.getUniform(sh.shader.program, loc1);
107 assert("got value for loc1",
108 gl.NO_ERROR == checkError(gl, "getUniform loc1"));
109 assertArrayEquals(mats[1], actual);
110 assertOk("set array of second array of 2 matrixes",
111 function(){gl[fname].call(gl, loc1, false, mats[0]);});
112 var actual = unwrappedGL.getUniform(sh.shader.program, loc1);
113 assert("got value for loc1",
114 gl.NO_ERROR == checkError(gl, "getUniform loc1"));
115 assertArrayEquals(mats[0], actual);
116 var big = mats[1].concat([3]);
117 assertGLError(gl, gl.INVALID_VALUE, "set array of first array of 2 matrixe s plus 1 value",
118 function(){gl[fname].call(gl, loc0, false, big);});
119 }
120 });
121 var d = new Uint8Array(4);
122 gl.readPixels(0,0,1,1,gl.RGBA, gl.UNSIGNED_BYTE, d);
123 assertArrayEquals([1,2,3,8], d);
124 sh.destroy();
125 }
126
127 Tests.endUnit = function(gl) {
128 }
129
130 </script>
131 <script id="foobar-vert" type="x-shader/x-vertex">
132 attribute vec3 Vertex;
133 attribute vec2 Tex;
134
135 uniform mat2 fm2;
136 uniform mat3 fm3;
137 uniform mat2 am2[2];
138 uniform mat3 am3[2];
139 uniform mat4 am4[2];
140
141 varying vec4 texCoord0;
142 void main()
143 {
144 texCoord0 = vec4(Tex.s, 1.0-Tex.t, fm2[0][1]+fm3[2][1], 0.0);
145 float d = am2[0][1][1] + am3[0][2][2] + am4[0][3][3] +
146 am2[1][1][1] + am3[1][2][2] + am4[1][3][3];
147 gl_Position = vec4(Vertex, 1.0 + d * 0.0001);
148 }
149 </script>
150 <script id="foobar-frag" type="x-shader/x-fragment">
151 precision mediump float;
152
153 uniform mat4 fm4;
154
155 varying vec4 texCoord0;
156 void main()
157 {
158 gl_FragColor = vec4(fm4[0][0]/256.0, fm4[1][1]/256.0, fm4[2][2]/256.0, fm4[3 ][3]*texCoord0.z/256.0);
159 }
160 </script>
161 <style>canvas{ position:absolute; }</style>
162 </head><body>
163 <canvas id="gl" width="16" height="16"></canvas>
164 </body></html>
OLDNEW
« no previous file with comments | « conformance/more/functions/uniformMatrix.html ('k') | conformance/more/functions/uniformf.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698