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

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

Issue 8342021: Add webgl conformance tests r15841. (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/webgl/sdk/tests/
Patch Set: Created 9 years, 2 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
« 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
+ LF
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html><head>
3 <meta charset="utf-8">
4 <link rel="stylesheet" type="text/css" href="../unit.css" />
5 <script type="application/x-javascript" src="../unit.js"></script>
6 <script type="application/x-javascript" src="../util.js"></script>
7 <script type="application/x-javascript">
8
9 Tests.startUnit = function () {
10 var canvas = document.getElementById('gl');
11 var unwrappedGL = canvas.getContext(GL_CONTEXT_ID);
12 var gl = wrapGLContext(unwrappedGL);
13 return [gl, unwrappedGL];
14 }
15
16 Tests.testUniformf = function(gl, unwrappedGL) {
17 var sh = new Filter(gl, 'foobar-vert', 'foobar-frag');
18 sh.apply(function(f){
19 var fm4 = f.uniform('fm4');
20 var fm2 = f.uniform('fm2');
21 var fm3 = f.uniform('fm3');
22 assertGLError(gl, gl.INVALID_VALUE, "bad transpose 4fv",
23 function(){gl.uniformMatrix4fv(fm4, true, [1,0,0,0, 0,2,0,0, 0,0,3,0, 0, 0,0,4]);});
24 assertGLError(gl, gl.INVALID_VALUE, "bad transpose 3fv",
25 function(){gl.uniformMatrix3fv(fm3, true, [1,0,0, 0,2,0, 0,0,3]);});
26 assertGLError(gl, gl.INVALID_VALUE, "bad transpose 2fv",
27 function(){gl.uniformMatrix2fv(fm2, true, [1,0, 0,2]);});
28 assertThrowNoGLError(gl, "bad location",
29 function(){gl.uniformMatrix4fv(588939, false, [1,0,0,0, 0,2,0,0, 0,0,3,0 , 0,0,0,4]);});
30 assertThrowNoGLError(gl, "bad location (negative)",
31 function(){gl.uniformMatrix4fv(-588939, false, [1,0,0,0, 0,2,0,0, 0,0,3, 0, 0,0,0,4]);});
32 assertGLError(gl, gl.INVALID_VALUE, "17 values to 4fv",
33 function(){gl.uniformMatrix4fv(fm4, false, [0,1,0,0,0, 0,2,0,0, 0,0,3,0, 0,0,0,4]);});
34 assertGLError(gl, gl.INVALID_VALUE, "5 values to 2fv",
35 function(){gl.uniformMatrix2fv(fm2, false, [0,2,1, 2,2]);});
36 assertGLError(gl, gl.INVALID_VALUE, "10 values to 3fv",
37 function(){gl.uniformMatrix3fv(fm3, false, [0,2,2,2, 2,2,2, 2,1,2]);});
38 assertGLError(gl, gl.INVALID_VALUE, "too few values to 4fv",
39 function(){gl.uniformMatrix4fv(fm4, false, [0,0,0, 0,2,0,0, 0,0,3,0, 0,0 ,0,4]);});
40 assertGLError(gl, gl.INVALID_VALUE, "too few values to 2fv",
41 function(){gl.uniformMatrix2fv(fm2, false, [1, 2,2]);});
42 assertGLError(gl, gl.INVALID_VALUE, "too few values to 2fv",
43 function(){gl.uniformMatrix2fv(fm2, false, []);});
44 assertThrowNoGLError(gl, "string for data",
45 function(){gl.uniformMatrix2fv(fm2, false, "fm4");});
46 assertGLError(gl, gl.INVALID_VALUE, "too few values to 3fv",
47 function(){gl.uniformMatrix3fv(fm3, false, [2,2, 2,2,2, 2,1,2]);});
48 gl.uniformMatrix4fv(fm4, false, [1,0,0,0, 0,2,0,0, 0,0,3,0, 0,0,0,4]);
49 gl.uniformMatrix2fv(fm2, false, [2,1, 2,2]);
50 gl.uniformMatrix3fv(fm3, false, [2,2,2, 2,2,2, 2,1,2]);
51 assertGLError(gl, gl.INVALID_OPERATION, "3fv on mat4",
52 function(){gl.uniformMatrix3fv(fm4, false, [1,0,0, 0,2,0, 0,0,3]);});
53 assertGLError(gl, gl.INVALID_OPERATION, "3fv on mat2",
54 function(){gl.uniformMatrix3fv(fm2, false, [0,2,1, 0,2,2, 0,0,0]);});
55 assertGLError(gl, gl.INVALID_OPERATION, "2fv om mat3",
56 function(){gl.uniformMatrix2fv(fm3, false, [2,2, 2,2]);});
57 for (var ii = 2; ii <= 4; ++ii) {
58 var all = [];
59 var mats = [[],[]];
60 for (var jj = 0; jj < 2; ++jj) {
61 for (var kk = 0; kk < ii * ii; ++kk) {
62 mats[jj].push(jj + 1);
63 all.push(jj + 1);
64 }
65 }
66 var loc0Name = 'am' + ii + '[0]';
67 var loc1Name = 'am' + ii + '[1]';
68 var loc0 = f.uniform(loc0Name);
69 var loc1 = f.uniform(loc1Name);
70 var fname = "uniformMatrix" + ii + "fv";
71 assert(loc0Name, loc0 != null);
72 assert(loc1Name, loc1 != null);
73 assertOk("set array of 2 matrices " + ii + "fv",
74 function(){gl[fname].call(gl,loc0, false, all);});
75 var actual = unwrappedGL.getUniform(sh.shader.program, loc0);
76 assert("got value for loc0",
77 gl.NO_ERROR == checkError(gl, "getUniform loc0"));
78 assertArrayEquals(mats[0], actual);
79 var actual = unwrappedGL.getUniform(sh.shader.program, loc1);
80 assert("got value for loc1",
81 gl.NO_ERROR == checkError(gl, "getUniform loc1"));
82 assertArrayEquals(mats[1], actual);
83 assertOk("set array of second array of 2 matrixes",
84 function(){gl[fname].call(gl, loc1, false, mats[0]);});
85 var actual = unwrappedGL.getUniform(sh.shader.program, loc1);
86 assert("got value for loc1",
87 gl.NO_ERROR == checkError(gl, "getUniform loc1"));
88 assertArrayEquals(mats[0], actual);
89 var big = mats[1].concat([3]);
90 assertGLError(gl, gl.INVALID_VALUE, "set array of first array of 2 matrixe s plus 1 value",
91 function(){gl[fname].call(gl, loc0, false, big);});
92 }
93 });
94 var d = new Uint8Array(4);
95 gl.readPixels(0,0,1,1,gl.RGBA, gl.UNSIGNED_BYTE, d);
96 assertArrayEquals([1,2,3,8], d);
97 sh.destroy();
98 }
99
100 Tests.endUnit = function(gl) {
101 }
102
103 </script>
104 <script id="foobar-vert" type="x-shader/x-vertex">
105 attribute vec3 Vertex;
106 attribute vec2 Tex;
107
108 uniform mat2 fm2;
109 uniform mat3 fm3;
110 uniform mat2 am2[2];
111 uniform mat3 am3[2];
112 uniform mat4 am4[2];
113
114 varying vec4 texCoord0;
115 void main()
116 {
117 texCoord0 = vec4(Tex.s, 1.0-Tex.t, fm2[0][1]+fm3[2][1], 0.0);
118 float d = am2[0][1][1] + am3[0][2][2] + am4[0][3][3] +
119 am2[1][1][1] + am3[1][2][2] + am4[1][3][3];
120 gl_Position = vec4(Vertex, 1.0 + d * 0.0001);
121 }
122 </script>
123 <script id="foobar-frag" type="x-shader/x-fragment">
124 precision mediump float;
125
126 uniform mat4 fm4;
127
128 varying vec4 texCoord0;
129 void main()
130 {
131 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);
132 }
133 </script>
134 <style>canvas{ position:absolute; }</style>
135 </head><body>
136 <canvas id="gl" width="16" height="16"></canvas>
137 </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