Merge vk-gl-cts/vulkan-cts-1.0.2 into vk-gl-cts/vulkan-cts-1.1.0
[platform/upstream/VK-GL-CTS.git] / modules / gles31 / functional / es31fNegativeShaderApiTests.cpp
1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program OpenGL ES 3.1 Module
3  * -------------------------------------------------
4  *
5  * Copyright 2014 The Android Open Source Project
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  *//*!
20  * \file
21  * \brief Negative Shader API tests.
22  *//*--------------------------------------------------------------------*/
23
24 #include "es31fNegativeShaderApiTests.hpp"
25
26 #include "deUniquePtr.hpp"
27
28 #include "glwDefs.hpp"
29 #include "glwEnums.hpp"
30
31 #include "gluShaderProgram.hpp"
32 #include "gluCallLogWrapper.hpp"
33
34 #include "gluContextInfo.hpp"
35 #include "gluRenderContext.hpp"
36
37
38 namespace deqp
39 {
40 namespace gles31
41 {
42 namespace Functional
43 {
44 namespace NegativeTestShared
45 {
46 using tcu::TestLog;
47 using glu::CallLogWrapper;
48 using namespace glw;
49
50 static const char* vertexShaderSource           =       "#version 300 es\n"
51                                                                                                 "void main (void)\n"
52                                                                                                 "{\n"
53                                                                                                 "       gl_Position = vec4(0.0);\n"
54                                                                                                 "}\n\0";
55
56 static const char* fragmentShaderSource         =       "#version 300 es\n"
57                                                                                                 "layout(location = 0) out mediump vec4 fragColor;"
58                                                                                                 "void main (void)\n"
59                                                                                                 "{\n"
60                                                                                                 "       fragColor = vec4(0.0);\n"
61                                                                                                 "}\n\0";
62
63 static const char* uniformTestVertSource        =       "#version 300 es\n"
64                                                                                                 "uniform mediump vec4 vec4_v;\n"
65                                                                                                 "uniform mediump mat4 mat4_v;\n"
66                                                                                                 "void main (void)\n"
67                                                                                                 "{\n"
68                                                                                                 "       gl_Position = mat4_v * vec4_v;\n"
69                                                                                                 "}\n\0";
70
71 static const char* uniformTestFragSource        =       "#version 300 es\n"
72                                                                                                 "uniform mediump ivec4 ivec4_f;\n"
73                                                                                                 "uniform mediump uvec4 uvec4_f;\n"
74                                                                                                 "uniform sampler2D sampler_f;\n"
75                                                                                                 "layout(location = 0) out mediump vec4 fragColor;"
76                                                                                                 "void main (void)\n"
77                                                                                                 "{\n"
78                                                                                                 "       fragColor.xy = (vec4(uvec4_f) + vec4(ivec4_f)).xy;\n"
79                                                                                                 "       fragColor.zw = texture(sampler_f, vec2(0.0, 0.0)).zw;\n"
80                                                                                                 "}\n\0";
81
82 static const char* uniformBlockVertSource       =       "#version 300 es\n"
83                                                                                                 "layout(shared) uniform Block { lowp float var; };\n"
84                                                                                                 "void main (void)\n"
85                                                                                                 "{\n"
86                                                                                                 "       gl_Position = vec4(var);\n"
87                                                                                                 "}\n\0";
88
89
90 // Shader control commands
91 void create_shader (NegativeTestContext& ctx)
92 {
93         ctx.beginSection("GL_INVALID_ENUM is generated if shaderType is not an accepted value.");
94         ctx.glCreateShader(-1);
95         ctx.expectError(GL_INVALID_ENUM);
96         ctx.endSection();
97 }
98
99 void shader_source (NegativeTestContext& ctx)
100 {
101         // make notAShader not a shader id
102         const GLuint notAShader = ctx.glCreateShader(GL_VERTEX_SHADER);
103         ctx.glDeleteShader(notAShader);
104
105         ctx.beginSection("GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
106         ctx.glShaderSource(notAShader, 0, 0, 0);
107         ctx.expectError(GL_INVALID_VALUE);
108         ctx.endSection();
109
110         ctx.beginSection("GL_INVALID_VALUE is generated if count is less than 0.");
111         GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
112         ctx.glShaderSource(shader, -1, 0, 0);
113         ctx.expectError(GL_INVALID_VALUE);
114         ctx.endSection();
115
116         ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not a shader object.");
117         GLuint program = ctx.glCreateProgram();
118         ctx.glShaderSource(program, 0, 0, 0);
119         ctx.expectError(GL_INVALID_OPERATION);
120         ctx.endSection();
121
122         ctx.glDeleteProgram(program);
123         ctx.glDeleteShader(shader);
124 }
125
126 void compile_shader (NegativeTestContext& ctx)
127 {
128         const GLuint notAShader = ctx.glCreateShader(GL_VERTEX_SHADER);
129         ctx.glDeleteShader(notAShader);
130
131         ctx.beginSection("GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
132         ctx.glCompileShader(notAShader);
133         ctx.expectError(GL_INVALID_VALUE);
134         ctx.endSection();
135
136         ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not a shader object.");
137         GLuint program = ctx.glCreateProgram();
138         ctx.glCompileShader(program);
139         ctx.expectError(GL_INVALID_OPERATION);
140         ctx.endSection();
141
142         ctx.glDeleteProgram(program);
143 }
144
145 void delete_shader (NegativeTestContext& ctx)
146 {
147         const GLuint notAShader = ctx.glCreateShader(GL_VERTEX_SHADER);
148         ctx.glDeleteShader(notAShader);
149
150         ctx.beginSection("GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
151         ctx.glDeleteShader(notAShader);
152         ctx.expectError(GL_INVALID_VALUE);
153         ctx.endSection();
154 }
155
156 void shader_binary (NegativeTestContext& ctx)
157 {
158         std::vector<deInt32> binaryFormats;
159         deBool shaderBinarySupported = !binaryFormats.empty();
160         GLuint shaders[2];
161         GLuint shaderPair[2];
162         GLuint nonProgram[2];
163         GLuint shaderProgram[2];
164
165         {
166                 deInt32 numFormats = 0x1234;
167                 ctx.glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &numFormats);
168
169                 if (numFormats == 0)
170                         ctx.getLog() << TestLog::Message << "// No supported extensions available." << TestLog::EndMessage;
171                 else
172                 {
173                         binaryFormats.resize(numFormats);
174                         ctx.glGetIntegerv(GL_SHADER_BINARY_FORMATS, &binaryFormats[0]);
175                 }
176         }
177
178         if (!shaderBinarySupported)
179                 ctx.getLog() << TestLog::Message << "// Shader binaries not supported." << TestLog::EndMessage;
180         else
181                 ctx.getLog() << TestLog::Message << "// Shader binaries supported" << TestLog::EndMessage;
182
183         shaders[0]                      = ctx.glCreateShader(GL_VERTEX_SHADER);
184         shaders[1]                      = ctx.glCreateShader(GL_VERTEX_SHADER);
185         shaderPair[0]           = ctx.glCreateShader(GL_VERTEX_SHADER);
186         shaderPair[1]           = ctx.glCreateShader(GL_FRAGMENT_SHADER);
187         nonProgram[0]           = -1;
188         nonProgram[1]           = -1;
189         shaderProgram[0]        = ctx.glCreateShader(GL_VERTEX_SHADER);
190         shaderProgram[1]        = ctx.glCreateProgram();
191
192         ctx.beginSection("GL_INVALID_ENUM is generated if binaryFormat is not an accepted value.");
193         ctx.glShaderBinary(1, &shaders[0], -1, 0, 0);
194         ctx.expectError(GL_INVALID_ENUM);
195         ctx.endSection();
196
197         if (shaderBinarySupported)
198         {
199                 ctx.beginSection("GL_INVALID_VALUE is generated if the data pointed to by binary does not match the format specified by binaryFormat.");
200                 const GLbyte data = 0x005F;
201                 ctx.glShaderBinary(1, &shaders[0], binaryFormats[0], &data, 1);
202                 ctx.expectError(GL_INVALID_VALUE);
203                 ctx.endSection();
204
205                 ctx.beginSection("GL_INVALID_OPERATION is generated if more than one of the handles in shaders refers to the same type of shader, or GL_INVALID_VALUE due to invalid data pointer.");
206                 ctx.glShaderBinary(2, &shaders[0], binaryFormats[0], 0, 0);
207                 ctx.expectError(GL_INVALID_OPERATION, GL_INVALID_VALUE);
208                 ctx.endSection();
209
210                 ctx.beginSection("GL_INVALID_VALUE is generated if count or length is negative.");
211                 ctx.glShaderBinary(2, &shaderPair[0], binaryFormats[0], 0, -1);
212                 ctx.expectError(GL_INVALID_VALUE);
213                 ctx.glShaderBinary(-1, &shaderPair[0], binaryFormats[0], 0, 0);
214                 ctx.expectError(GL_INVALID_VALUE);
215                 ctx.endSection();
216
217                 ctx.beginSection("GL_INVALID_VALUE is generated if shaders contains anything other than shader or program objects.");
218                 ctx.glShaderBinary(2, &nonProgram[0], binaryFormats[0], 0, 0);
219                 ctx.expectError(GL_INVALID_VALUE);
220                 ctx.endSection();
221
222                 ctx.beginSection("GL_INVALID_OPERATION is generated if shaders refers to a program object.");
223                 ctx.glShaderBinary(2, &shaderProgram[0], binaryFormats[0], 0, 0);
224                 ctx.expectError(GL_INVALID_OPERATION);
225                 ctx.endSection();
226         }
227
228         ctx.glDeleteShader(shaders[0]);
229         ctx.glDeleteShader(shaders[1]);
230 }
231
232 void attach_shader (NegativeTestContext& ctx)
233 {
234         GLuint shader1 = ctx.glCreateShader(GL_VERTEX_SHADER);
235         GLuint shader2 = ctx.glCreateShader(GL_VERTEX_SHADER);
236         GLuint program = ctx.glCreateProgram();
237
238         const GLuint notAShader = ctx.glCreateShader(GL_VERTEX_SHADER);
239         const GLuint notAProgram = ctx.glCreateProgram();
240
241         ctx.glDeleteShader(notAShader);
242         ctx.glDeleteProgram(notAProgram);
243
244         ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
245         ctx.glAttachShader(shader1, shader1);
246         ctx.expectError(GL_INVALID_OPERATION);
247         ctx.endSection();
248
249         ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not a shader object.");
250         ctx.glAttachShader(program, program);
251         ctx.expectError(GL_INVALID_OPERATION);
252         ctx.glAttachShader(shader1, program);
253         ctx.expectError(GL_INVALID_OPERATION);
254         ctx.endSection();
255
256         ctx.beginSection("GL_INVALID_VALUE is generated if either program or shader is not a value generated by OpenGL.");
257         ctx.glAttachShader(program, notAShader);
258         ctx.expectError(GL_INVALID_VALUE);
259         ctx.glAttachShader(notAProgram, shader1);
260         ctx.expectError(GL_INVALID_VALUE);
261         ctx.glAttachShader(notAProgram, notAShader);
262         ctx.expectError(GL_INVALID_VALUE);
263         ctx.endSection();
264
265         ctx.beginSection("GL_INVALID_OPERATION is generated if shader is already attached to program.");
266         ctx.glAttachShader(program, shader1);
267         ctx.expectError(GL_NO_ERROR);
268         ctx.glAttachShader(program, shader1);
269         ctx.expectError(GL_INVALID_OPERATION);
270         ctx.endSection();
271
272         ctx.beginSection("GL_INVALID_OPERATION is generated if a shader of the same type as shader is already attached to program.");
273         ctx.glAttachShader(program, shader2);
274         ctx.expectError(GL_INVALID_OPERATION);
275         ctx.endSection();
276
277         ctx.glDeleteProgram(program);
278         ctx.glDeleteShader(shader1);
279         ctx.glDeleteShader(shader2);
280 }
281
282 void detach_shader (NegativeTestContext& ctx)
283 {
284         GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
285         GLuint program = ctx.glCreateProgram();
286
287         const GLuint notAShader = ctx.glCreateShader(GL_VERTEX_SHADER);
288         const GLuint notAProgram = ctx.glCreateProgram();
289
290         ctx.glDeleteShader(notAShader);
291         ctx.glDeleteProgram(notAProgram);
292
293         ctx.beginSection("GL_INVALID_VALUE is generated if either program or shader is not a value generated by OpenGL.");
294         ctx.glDetachShader(notAProgram, shader);
295         ctx.expectError(GL_INVALID_VALUE);
296         ctx.glDetachShader(program, notAShader);
297         ctx.expectError(GL_INVALID_VALUE);
298         ctx.glDetachShader(notAProgram, notAShader);
299         ctx.expectError(GL_INVALID_VALUE);
300         ctx.endSection();
301
302         ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
303         ctx.glDetachShader(shader, shader);
304         ctx.expectError(GL_INVALID_OPERATION);
305         ctx.endSection();
306
307         ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not a shader object.");
308         ctx.glDetachShader(program, program);
309         ctx.expectError(GL_INVALID_OPERATION);
310         ctx.glDetachShader(shader, program);
311         ctx.expectError(GL_INVALID_OPERATION);
312         ctx.endSection();
313
314         ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not attached to program.");
315         ctx.glDetachShader(program, shader);
316         ctx.expectError(GL_INVALID_OPERATION);
317         ctx.endSection();
318
319         ctx.glDeleteProgram(program);
320         ctx.glDeleteShader(shader);
321 }
322
323 void link_program (NegativeTestContext& ctx)
324 {
325         GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
326
327         const GLuint notAProgram = ctx.glCreateProgram();
328         ctx.glDeleteProgram(notAProgram);
329
330         ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
331         ctx.glLinkProgram(notAProgram);
332         ctx.expectError(GL_INVALID_VALUE);
333         ctx.endSection();
334
335         ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
336         ctx.glLinkProgram(shader);
337         ctx.expectError(GL_INVALID_OPERATION);
338         ctx.endSection();
339
340         ctx.glDeleteShader(shader);
341
342         ctx.beginSection("GL_INVALID_OPERATION is generated if program is the currently active program object and transform feedback mode is active.");
343         glu::ShaderProgram                      program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
344         deUint32                                        buf = 0x1234;
345         deUint32                                        tfID = 0x1234;
346         const char* tfVarying           = "gl_Position";
347
348         ctx.glGenTransformFeedbacks             (1, &tfID);
349         ctx.glGenBuffers                                (1, &buf);
350
351         ctx.glUseProgram                                (program.getProgram());
352         ctx.glTransformFeedbackVaryings (program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
353         ctx.glLinkProgram                               (program.getProgram());
354         ctx.glBindTransformFeedback             (GL_TRANSFORM_FEEDBACK, tfID);
355         ctx.glBindBuffer                                (GL_TRANSFORM_FEEDBACK_BUFFER, buf);
356         ctx.glBufferData                                (GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
357         ctx.glBindBufferBase                    (GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
358         ctx.glBeginTransformFeedback    (GL_TRIANGLES);
359         ctx.expectError                                 (GL_NO_ERROR);
360
361         ctx.glLinkProgram                               (program.getProgram());
362         ctx.expectError                         (GL_INVALID_OPERATION);
363
364         ctx.glEndTransformFeedback              ();
365         ctx.glDeleteTransformFeedbacks  (1, &tfID);
366         ctx.glDeleteBuffers                             (1, &buf);
367         ctx.expectError                         (GL_NO_ERROR);
368         ctx.endSection();
369 }
370
371 void use_program (NegativeTestContext& ctx)
372 {
373         GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
374
375         const GLuint notAProgram = ctx.glCreateProgram();
376         ctx.glDeleteProgram(notAProgram);
377
378         ctx.beginSection("GL_INVALID_VALUE is generated if program is neither 0 nor a value generated by OpenGL.");
379         ctx.glUseProgram(notAProgram);
380         ctx.expectError(GL_INVALID_VALUE);
381         ctx.endSection();
382
383         ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
384         ctx.glUseProgram(shader);
385         ctx.expectError(GL_INVALID_OPERATION);
386         ctx.endSection();
387
388         ctx.beginSection("GL_INVALID_OPERATION is generated if transform feedback mode is active and not paused.");
389         glu::ShaderProgram                      program1(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
390         glu::ShaderProgram                      program2(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
391         deUint32                                        buf = 0x1234;
392         deUint32                                        tfID = 0x1234;
393         const char* tfVarying           = "gl_Position";
394
395         ctx.glGenTransformFeedbacks             (1, &tfID);
396         ctx.glGenBuffers                                (1, &buf);
397
398         ctx.glUseProgram                                (program1.getProgram());
399         ctx.glTransformFeedbackVaryings (program1.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
400         ctx.glLinkProgram                               (program1.getProgram());
401         ctx.glBindTransformFeedback             (GL_TRANSFORM_FEEDBACK, tfID);
402         ctx.glBindBuffer                                (GL_TRANSFORM_FEEDBACK_BUFFER, buf);
403         ctx.glBufferData                                (GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
404         ctx.glBindBufferBase                    (GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
405         ctx.glBeginTransformFeedback    (GL_TRIANGLES);
406         ctx.expectError                                 (GL_NO_ERROR);
407
408         ctx.glUseProgram                                (program2.getProgram());
409         ctx.expectError                         (GL_INVALID_OPERATION);
410
411         ctx.glPauseTransformFeedback    ();
412         ctx.glUseProgram                                (program2.getProgram());
413         ctx.expectError                         (GL_NO_ERROR);
414
415         ctx.glEndTransformFeedback              ();
416         ctx.glDeleteTransformFeedbacks  (1, &tfID);
417         ctx.glDeleteBuffers                             (1, &buf);
418         ctx.expectError                         (GL_NO_ERROR);
419         ctx.endSection();
420
421         ctx.glUseProgram(0);
422         ctx.glDeleteShader(shader);
423 }
424
425 void delete_program (NegativeTestContext& ctx)
426 {
427         GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
428
429         const GLuint notAProgram = ctx.glCreateProgram();
430         ctx.glDeleteProgram(notAProgram);
431
432         ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
433         ctx.glDeleteProgram(notAProgram);
434         ctx.expectError(GL_INVALID_VALUE);
435         ctx.endSection();
436
437         ctx.beginSection("GL_INVALID_OPERATION is generated if program is not zero and is the name of a shader object.");
438         ctx.glDeleteProgram(shader);
439         ctx.expectError(GL_INVALID_OPERATION);
440         ctx.endSection();
441
442         ctx.glDeleteShader(shader);
443 }
444
445 void validate_program (NegativeTestContext& ctx)
446 {
447         GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
448
449         const GLuint notAProgram = ctx.glCreateProgram();
450         ctx.glDeleteProgram(notAProgram);
451
452         ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
453         ctx.glValidateProgram(notAProgram);
454         ctx.expectError(GL_INVALID_VALUE);
455         ctx.endSection();
456
457         ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
458         ctx.glValidateProgram(shader);
459         ctx.expectError(GL_INVALID_OPERATION);
460         ctx.endSection();
461
462         ctx.glDeleteShader(shader);
463 }
464
465 void get_program_binary (NegativeTestContext& ctx)
466 {
467         glu::ShaderProgram                              program                 (ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
468         glu::ShaderProgram                              programInvalid  (ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, ""));
469         GLenum                                                  binaryFormat    = -1;
470         GLsizei                                                 binaryLength    = -1;
471         GLint                                                   binaryPtr               = -1;
472         GLint                                                   bufSize                 = -1;
473         GLint                                                   linkStatus              = -1;
474
475         ctx.beginSection("GL_INVALID_OPERATION is generated if bufSize is less than the size of GL_PROGRAM_BINARY_LENGTH for program.");
476         ctx.glGetProgramiv              (program.getProgram(), GL_PROGRAM_BINARY_LENGTH,        &bufSize);
477         ctx.expectError         (GL_NO_ERROR);
478         ctx.glGetProgramiv              (program.getProgram(), GL_LINK_STATUS,                          &linkStatus);
479         ctx.getLog() << TestLog::Message << "// GL_PROGRAM_BINARY_LENGTH = " << bufSize << TestLog::EndMessage;
480         ctx.getLog() << TestLog::Message << "// GL_LINK_STATUS = " << linkStatus << TestLog::EndMessage;
481         ctx.expectError         (GL_NO_ERROR);
482
483         ctx.glGetProgramBinary  (program.getProgram(), 0, &binaryLength, &binaryFormat, &binaryPtr);
484         ctx.expectError         (GL_INVALID_OPERATION);
485         if (bufSize > 0)
486         {
487                 ctx.glGetProgramBinary  (program.getProgram(), bufSize-1, &binaryLength, &binaryFormat, &binaryPtr);
488                 ctx.expectError         (GL_INVALID_OPERATION);
489         }
490         ctx.endSection();
491
492         ctx.beginSection("GL_INVALID_OPERATION is generated if GL_LINK_STATUS for the program object is false.");
493         ctx.glGetProgramiv              (programInvalid.getProgram(), GL_PROGRAM_BINARY_LENGTH, &bufSize);
494         ctx.expectError         (GL_NO_ERROR);
495         ctx.glGetProgramiv              (programInvalid.getProgram(), GL_LINK_STATUS,                   &linkStatus);
496         ctx.getLog() << TestLog::Message << "// GL_PROGRAM_BINARY_LENGTH = " << bufSize << TestLog::EndMessage;
497         ctx.getLog() << TestLog::Message << "// GL_LINK_STATUS = " << linkStatus << TestLog::EndMessage;
498         ctx.expectError         (GL_NO_ERROR);
499
500         ctx.glGetProgramBinary  (programInvalid.getProgram(), bufSize, &binaryLength, &binaryFormat, &binaryPtr);
501         ctx.expectError         (GL_INVALID_OPERATION);
502         ctx.endSection();
503 }
504
505 void program_binary (NegativeTestContext& ctx)
506 {
507         glu::ShaderProgram              srcProgram              (ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
508         GLuint                                  dstProgram              = ctx.glCreateProgram();
509         GLuint                                  dummyShader             = ctx.glCreateShader(GL_VERTEX_SHADER);
510         GLenum                                  binaryFormat    = -1;
511         GLsizei                                 binaryLength    = -1;
512         std::vector<deUint8>    binaryBuf;
513         GLint                                   bufSize                 = -1;
514         GLint                                   linkStatus              = -1;
515
516         ctx.glGetProgramiv              (srcProgram.getProgram(), GL_PROGRAM_BINARY_LENGTH,     &bufSize);
517         ctx.glGetProgramiv              (srcProgram.getProgram(), GL_LINK_STATUS,                       &linkStatus);
518         ctx.getLog() << TestLog::Message << "// GL_PROGRAM_BINARY_LENGTH = " << bufSize << TestLog::EndMessage;
519         ctx.getLog() << TestLog::Message << "// GL_LINK_STATUS = " << linkStatus << TestLog::EndMessage;
520
521         TCU_CHECK(bufSize >= 0);
522         if (bufSize > 0)
523         {
524                 binaryBuf.resize(bufSize);
525                 ctx.glGetProgramBinary  (srcProgram.getProgram(), bufSize, &binaryLength, &binaryFormat, &binaryBuf[0]);
526                 ctx.expectError                 (GL_NO_ERROR);
527
528                 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not the name of an existing program object.");
529                 ctx.glProgramBinary             (dummyShader, binaryFormat, &binaryBuf[0], binaryLength);
530                 ctx.expectError                 (GL_INVALID_OPERATION);
531                 ctx.endSection();
532
533                 ctx.beginSection("GL_INVALID_ENUM is generated if binaryFormat is not a value recognized by the implementation.");
534                 ctx.glProgramBinary             (dstProgram, -1, &binaryBuf[0], binaryLength);
535                 ctx.expectError                 (GL_INVALID_ENUM);
536                 ctx.endSection();
537         }
538
539         ctx.glDeleteShader(dummyShader);
540         ctx.glDeleteProgram(dstProgram);
541 }
542
543 void program_parameteri (NegativeTestContext& ctx)
544 {
545         GLuint program  = ctx.glCreateProgram();
546         GLuint shader   = ctx.glCreateShader(GL_VERTEX_SHADER);
547
548         const GLuint notAProgram = ctx.glCreateProgram();
549         ctx.glDeleteProgram(notAProgram);
550
551         ctx.beginSection("GL_INVALID_VALUE is generated if program is not the name of an existing program object.");
552         ctx.glProgramParameteri(notAProgram, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE);
553         ctx.expectError(GL_INVALID_VALUE);
554         ctx.endSection();
555
556         ctx.beginSection("GL_INVALID_OPERATION is generated if program is the name of a shader object.");
557         ctx.glProgramParameteri(shader, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE);
558         ctx.expectError(GL_INVALID_OPERATION);
559         ctx.endSection();
560
561         ctx.beginSection("GL_INVALID_ENUM is generated if pname is not GL_PROGRAM_BINARY_RETRIEVABLE_HINT or PROGRAM_SEPARABLE.");
562         ctx.glProgramParameteri(program, -1, GL_TRUE);
563         ctx.expectError(GL_INVALID_ENUM);
564         ctx.endSection();
565
566         ctx.beginSection("GL_INVALID_VALUE is generated if value is not GL_FALSE or GL_TRUE.");
567         ctx.glProgramParameteri(program, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, 2);
568         ctx.expectError(GL_INVALID_VALUE);
569         ctx.endSection();
570
571         ctx.glDeleteProgram(program);
572         ctx.glDeleteShader(shader);
573 }
574
575 void gen_samplers (NegativeTestContext& ctx)
576 {
577         ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
578         GLuint sampler = 0;
579         ctx.glGenSamplers       (-1, &sampler);
580         ctx.expectError (GL_INVALID_VALUE);
581         ctx.endSection();
582 }
583
584 void bind_sampler (NegativeTestContext& ctx)
585 {
586         int                             maxTexImageUnits = 0x1234;
587         GLuint                  sampler = 0;
588         ctx.glGetIntegerv       (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxTexImageUnits);
589         ctx.glGenSamplers       (1, &sampler);
590
591         ctx.beginSection("GL_INVALID_VALUE is generated if unit is greater than or equal to the value of GL_MAX_COMBIED_TEXTURE_IMAGE_UNITS.");
592         ctx.glBindSampler       (maxTexImageUnits, sampler);
593         ctx.expectError (GL_INVALID_VALUE);
594         ctx.endSection();
595
596         ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not zero or a name previously returned from a call to ctx.glGenSamplers.");
597         ctx.glBindSampler       (1, -1);
598         ctx.expectError (GL_INVALID_OPERATION);
599         ctx.endSection();
600
601         ctx.beginSection("GL_INVALID_OPERATION is generated if sampler has been deleted by a call to ctx.glDeleteSamplers.");
602         ctx.glDeleteSamplers(1, &sampler);
603         ctx.glBindSampler       (1, sampler);
604         ctx.expectError (GL_INVALID_OPERATION);
605         ctx.endSection();
606 }
607
608 void delete_samplers (NegativeTestContext& ctx)
609 {
610         ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
611         ctx.glDeleteSamplers(-1, 0);
612         ctx.expectError (GL_INVALID_VALUE);
613         ctx.endSection();
614 }
615
616 void get_sampler_parameteriv (NegativeTestContext& ctx)
617 {
618         int                             params = 0x1234;
619         GLuint                  sampler = 0;
620         ctx.glGenSamplers       (1, &sampler);
621
622         ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object returned from a previous call to ctx.glGenSamplers.");
623         ctx.glGetSamplerParameteriv     (-1, GL_TEXTURE_MAG_FILTER, &params);
624         ctx.expectError                 (GL_INVALID_OPERATION);
625         ctx.endSection();
626
627         ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
628         ctx.glGetSamplerParameteriv     (sampler, -1, &params);
629         ctx.expectError                 (GL_INVALID_ENUM);
630         ctx.endSection();
631
632         ctx.glDeleteSamplers(1, &sampler);
633 }
634
635 void get_sampler_parameterfv (NegativeTestContext& ctx)
636 {
637         float                           params  = 0.0f;
638         GLuint                          sampler = 0;
639         ctx.glGenSamplers       (1, &sampler);
640
641         ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object returned from a previous call to ctx.glGenSamplers.");
642         ctx.glGetSamplerParameterfv     (-1, GL_TEXTURE_MAG_FILTER, &params);
643         ctx.expectError                 (GL_INVALID_OPERATION);
644         ctx.endSection();
645
646         ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
647         ctx.glGetSamplerParameterfv     (sampler, -1, &params);
648         ctx.expectError                 (GL_INVALID_ENUM);
649         ctx.endSection();
650
651         ctx.glDeleteSamplers(1, &sampler);
652 }
653
654 void get_sampler_parameterIiv (NegativeTestContext& ctx)
655 {
656         if (!contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
657                 throw tcu::NotSupportedError("glGetSamplerParameterIiv is not supported.", DE_NULL, __FILE__, __LINE__);
658
659         GLuint  sampler         = 0x1234;
660         GLint   borderColor     = 0x1234;
661
662         ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object returned from a previous call to ctx.glGenSamplers.");
663         ctx.glGetSamplerParameterIiv(sampler, GL_TEXTURE_BORDER_COLOR, &borderColor);
664         ctx.expectError(GL_INVALID_OPERATION);
665         ctx.endSection();
666
667         ctx.glGenSamplers(1, &sampler);
668
669         ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
670         ctx.glGetSamplerParameterIiv(sampler, -1, &borderColor);
671         ctx.expectError(GL_INVALID_ENUM);
672         ctx.endSection();
673
674         ctx.glDeleteSamplers(1, &sampler);
675 }
676
677 void get_sampler_parameterIuiv (NegativeTestContext& ctx)
678 {
679         if (!contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
680                 throw tcu::NotSupportedError("glGetSamplerParameterIuiv is not supported.", DE_NULL, __FILE__, __LINE__);
681
682         GLuint  sampler         = 0x1234;
683         GLuint  borderColor     = 0x1234;
684
685         ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object returned from a previous call to ctx.glGenSamplers.");
686         ctx.glGetSamplerParameterIuiv(sampler, GL_TEXTURE_BORDER_COLOR, &borderColor);
687         ctx.expectError(GL_INVALID_OPERATION);
688         ctx.endSection();
689
690         ctx.glGenSamplers(1, &sampler);
691
692         ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
693         ctx.glGetSamplerParameterIuiv(sampler, -1, &borderColor);
694         ctx.expectError(GL_INVALID_ENUM);
695         ctx.endSection();
696
697         ctx.glDeleteSamplers(1, &sampler);
698 }
699
700 void sampler_parameteri (NegativeTestContext& ctx)
701 {
702         GLuint sampler = 0;
703
704         ctx.glGenSamplers(1, &sampler);
705
706         ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object previously returned from a call to ctx.glGenSamplers.");
707         ctx.glSamplerParameteri(-1, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
708         ctx.expectError(GL_INVALID_OPERATION);
709         ctx.endSection();
710
711         ctx.beginSection("GL_INVALID_ENUM is generated if params should have a defined constant value (based on the value of pname) and does not.");
712         ctx.glSamplerParameteri(sampler, GL_TEXTURE_WRAP_S, -1);
713         ctx.expectError(GL_INVALID_ENUM);
714         ctx.endSection();
715
716         if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
717         {
718                 ctx.beginSection("GL_INVALID_ENUM is generated if glSamplerParameteri is called for a non-scalar parameter.");
719                 ctx.glSamplerParameteri(sampler, GL_TEXTURE_BORDER_COLOR, 0);
720                 ctx.expectError(GL_INVALID_ENUM);
721                 ctx.endSection();
722         }
723
724         ctx.glDeleteSamplers(1, &sampler);
725 }
726
727 void sampler_parameteriv (NegativeTestContext& ctx)
728 {
729         int                             params = 0x1234;
730         GLuint                  sampler = 0;
731         ctx.glGenSamplers       (1, &sampler);
732
733         ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object previously returned from a call to ctx.glGenSamplers.");
734         params = GL_CLAMP_TO_EDGE;
735         ctx.glSamplerParameteriv        (-1, GL_TEXTURE_WRAP_S, &params);
736         ctx.expectError                 (GL_INVALID_OPERATION);
737         ctx.endSection();
738
739         ctx.beginSection("GL_INVALID_ENUM is generated if params should have a defined constant value (based on the value of pname) and does not.");
740         params = -1;
741         ctx.glSamplerParameteriv        (sampler, GL_TEXTURE_WRAP_S, &params);
742         ctx.expectError                 (GL_INVALID_ENUM);
743         ctx.endSection();
744
745         ctx.glDeleteSamplers(1, &sampler);
746 }
747
748 void sampler_parameterf (NegativeTestContext& ctx)
749 {
750         GLuint sampler = 0;
751
752         ctx.glGenSamplers(1, &sampler);
753
754         ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object previously returned from a call to ctx.glGenSamplers.");
755         ctx.glSamplerParameterf(-1, GL_TEXTURE_MIN_LOD, -1000.0f);
756         ctx.expectError(GL_INVALID_OPERATION);
757         ctx.endSection();
758
759         ctx.beginSection("GL_INVALID_ENUM is generated if params should have a defined constant value (based on the value of pname) and does not.");
760         ctx.glSamplerParameterf(sampler, GL_TEXTURE_WRAP_S, -1.0f);
761         ctx.expectError(GL_INVALID_ENUM);
762         ctx.endSection();
763
764         if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
765         {
766                 ctx.beginSection("GL_INVALID_ENUM is generated if glSamplerParameterf is called for a non-scalar parameter.");
767                 ctx.glSamplerParameteri(sampler, GL_TEXTURE_BORDER_COLOR, 0);
768                 ctx.expectError(GL_INVALID_ENUM);
769                 ctx.endSection();
770         }
771
772         ctx.glDeleteSamplers(1, &sampler);
773 }
774
775 void sampler_parameterfv (NegativeTestContext& ctx)
776 {
777         float                   params;
778         GLuint                  sampler = 0;
779         ctx.glGenSamplers       (1, &sampler);
780
781         ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object previously returned from a call to ctx.glGenSamplers.");
782         params = -1000.0f;
783         ctx.glSamplerParameterfv        (-1, GL_TEXTURE_WRAP_S, &params);
784         ctx.expectError                 (GL_INVALID_OPERATION);
785         ctx.endSection();
786
787         ctx.beginSection("GL_INVALID_ENUM is generated if params should have a defined constant value (based on the value of pname) and does not.");
788         params = -1.0f;
789         ctx.glSamplerParameterfv        (sampler, GL_TEXTURE_WRAP_S, &params);
790         ctx.expectError                 (GL_INVALID_ENUM);
791         ctx.endSection();
792
793         ctx.glDeleteSamplers(1, &sampler);
794 }
795
796 void sampler_parameterIiv (NegativeTestContext& ctx)
797 {
798         if (!contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
799                 throw tcu::NotSupportedError("glSamplerParameterIiv is not supported.", DE_NULL, __FILE__, __LINE__);
800
801         GLuint  sampler;
802         GLint   color[] = {0, 0, 0, 0};
803
804         ctx.glGenSamplers(1, &sampler);
805
806         ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object previously returned from a call to ctx.glGenSamplers.");
807         ctx.glSamplerParameterIiv(-1, GL_TEXTURE_BORDER_COLOR, color);
808         ctx.expectError(GL_INVALID_OPERATION);
809         ctx.endSection();
810
811         ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted sampler state name.");
812         ctx.glSamplerParameterIiv(sampler, -1, color);
813         ctx.expectError(GL_INVALID_ENUM);
814         ctx.endSection();
815 }
816
817 void sampler_parameterIuiv (NegativeTestContext& ctx)
818 {
819         if (!contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
820                 throw tcu::NotSupportedError("glSamplerParameterIuiv is not supported.", DE_NULL, __FILE__, __LINE__);
821
822         GLuint  sampler;
823         GLuint  color[] = {0, 0, 0, 0};
824
825         ctx.glGenSamplers(1, &sampler);
826
827         ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object previously returned from a call to ctx.glGenSamplers.");
828         ctx.glSamplerParameterIuiv(-1, GL_TEXTURE_BORDER_COLOR, color);
829         ctx.expectError(GL_INVALID_OPERATION);
830         ctx.endSection();
831
832         ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted sampler state name.");
833         ctx.glSamplerParameterIuiv(sampler, -1, color);
834         ctx.expectError(GL_INVALID_ENUM);
835         ctx.endSection();
836 }
837
838 // Shader data commands
839
840 void get_attrib_location (NegativeTestContext& ctx)
841 {
842         GLuint programEmpty             = ctx.glCreateProgram();
843         GLuint shader                   = ctx.glCreateShader(GL_VERTEX_SHADER);
844
845         glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
846
847         const GLuint notAProgram = ctx.glCreateProgram();
848         ctx.glDeleteProgram(notAProgram);
849
850         ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been successfully linked.");
851         ctx.glBindAttribLocation                (programEmpty, 0, "test");
852         ctx.glGetAttribLocation                 (programEmpty, "test");
853         ctx.expectError                         (GL_INVALID_OPERATION);
854         ctx.endSection();
855
856         ctx.beginSection("GL_INVALID_VALUE is generated if program is not a program or shader object.");
857         ctx.glUseProgram                                (program.getProgram());
858         ctx.glBindAttribLocation                (program.getProgram(), 0, "test");
859         ctx.expectError                         (GL_NO_ERROR);
860         ctx.glGetAttribLocation                 (program.getProgram(), "test");
861         ctx.expectError                         (GL_NO_ERROR);
862         ctx.glGetAttribLocation                 (notAProgram, "test");
863         ctx.expectError                         (GL_INVALID_VALUE);
864         ctx.endSection();
865
866         ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
867         ctx.glGetAttribLocation                 (shader, "test");
868         ctx.expectError                         (GL_INVALID_OPERATION);
869         ctx.endSection();
870
871         ctx.glUseProgram                                (0);
872         ctx.glDeleteShader                              (shader);
873         ctx.glDeleteProgram                             (programEmpty);
874 }
875
876 void get_uniform_location (NegativeTestContext& ctx)
877 {
878         GLuint programEmpty = ctx.glCreateProgram();
879         GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
880
881         glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
882
883         const GLuint notAProgram = ctx.glCreateProgram();
884         ctx.glDeleteProgram(notAProgram);
885
886         ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been successfully linked.");
887         ctx.glGetUniformLocation(programEmpty, "test");
888         ctx.expectError(GL_INVALID_OPERATION);
889         ctx.endSection();
890
891         ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
892         ctx.glUseProgram(program.getProgram());
893         ctx.glGetUniformLocation(notAProgram, "test");
894         ctx.expectError(GL_INVALID_VALUE);
895         ctx.endSection();
896
897         ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
898         ctx.glGetAttribLocation(shader, "test");
899         ctx.expectError(GL_INVALID_OPERATION);
900         ctx.endSection();
901
902         ctx.glUseProgram(0);
903         ctx.glDeleteProgram(programEmpty);
904         ctx.glDeleteShader(shader);
905 }
906
907 void bind_attrib_location (NegativeTestContext& ctx)
908 {
909         GLuint program = ctx.glCreateProgram();
910         GLuint maxIndex = ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
911         GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
912
913         ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
914         ctx.glBindAttribLocation(program, maxIndex, "test");
915         ctx.expectError(GL_INVALID_VALUE);
916         ctx.endSection();
917
918         ctx.beginSection("GL_INVALID_OPERATION is generated if name starts with the reserved prefix \"gl_\".");
919         ctx.glBindAttribLocation(program, maxIndex-1, "gl_test");
920         ctx.expectError(GL_INVALID_OPERATION);
921         ctx.endSection();
922
923         ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
924         ctx.glBindAttribLocation(-1, maxIndex-1, "test");
925         ctx.expectError(GL_INVALID_VALUE);
926         ctx.endSection();
927
928         ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
929         ctx.glBindAttribLocation(shader, maxIndex-1, "test");
930         ctx.expectError(GL_INVALID_OPERATION);
931         ctx.endSection();
932
933         ctx.glDeleteProgram(program);
934         ctx.glDeleteShader(shader);
935 }
936
937 void uniform_block_binding (NegativeTestContext& ctx)
938 {
939         GLint                           maxUniformBufferBindings        = -1;
940         GLint                           numActiveUniforms                       = -1;
941         GLint                           numActiveBlocks                         = -1;
942         GLuint                          shader                                          = -1;
943         glu::ShaderProgram      program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformBlockVertSource, uniformTestFragSource));
944
945         shader = ctx.glCreateShader(GL_VERTEX_SHADER);
946         ctx.glUseProgram(program.getProgram());
947
948         ctx.glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUniformBufferBindings);
949         ctx.glGetProgramiv(program.getProgram(), GL_ACTIVE_UNIFORMS, &numActiveUniforms);
950         ctx.glGetProgramiv(program.getProgram(), GL_ACTIVE_UNIFORM_BLOCKS, &numActiveBlocks);
951         ctx.getLog() << TestLog::Message << "// GL_MAX_UNIFORM_BUFFER_BINDINGS = " << maxUniformBufferBindings << TestLog::EndMessage;
952         ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORMS = "                          << numActiveUniforms            << TestLog::EndMessage;
953         ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORM_BLOCKS = "            << numActiveBlocks                      << TestLog::EndMessage;
954         ctx.expectError (GL_NO_ERROR);
955
956         ctx.beginSection("GL_INVALID_VALUE is generated if uniformBlockIndex is not an active uniform block index of program.");
957         ctx.glUniformBlockBinding(program.getProgram(), -1, 0);
958         ctx.expectError(GL_INVALID_VALUE);
959         ctx.glUniformBlockBinding(program.getProgram(), 5, 0);
960         ctx.expectError(GL_INVALID_VALUE);
961         ctx.endSection();
962
963         ctx.beginSection("GL_INVALID_VALUE is generated if uniformBlockBinding is greater than or equal to the value of GL_MAX_UNIFORM_BUFFER_BINDINGS.");
964         ctx.glUniformBlockBinding(program.getProgram(), maxUniformBufferBindings, 0);
965         ctx.expectError(GL_INVALID_VALUE);
966         ctx.endSection();
967
968         ctx.beginSection("GL_INVALID_VALUE is generated if program is not the name of a program object generated by the GL.");
969         ctx.glUniformBlockBinding(-1, 0, 0);
970         ctx.expectError(GL_INVALID_VALUE);
971         ctx.endSection();
972
973         ctx.beginSection("GL_INVALID_OPERATION is generated if program is the name of a shader object.");
974         ctx.glUniformBlockBinding(shader, 0, 0);
975         ctx.expectError(GL_INVALID_OPERATION);
976         ctx.endSection();
977
978         ctx.glDeleteShader(shader);
979 }
980
981 // ctx.glUniform*f
982
983 void uniformf_invalid_program (NegativeTestContext& ctx)
984 {
985         ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object.");
986         ctx.glUseProgram(0);
987         ctx.glUniform1f(-1, 0.0f);
988         ctx.expectError(GL_INVALID_OPERATION);
989         ctx.glUniform2f(-1, 0.0f, 0.0f);
990         ctx.expectError(GL_INVALID_OPERATION);
991         ctx.glUniform3f(-1, 0.0f, 0.0f, 0.0f);
992         ctx.expectError(GL_INVALID_OPERATION);
993         ctx.glUniform4f(-1, 0.0f, 0.0f, 0.0f, 0.0f);
994         ctx.expectError(GL_INVALID_OPERATION);
995         ctx.endSection();
996 }
997
998 void uniformf_incompatible_type (NegativeTestContext& ctx)
999 {
1000         glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1001
1002         ctx.glUseProgram(program.getProgram());
1003         GLint vec4_v    = ctx.glGetUniformLocation(program.getProgram(), "vec4_v");     // vec4
1004         GLint ivec4_f   = ctx.glGetUniformLocation(program.getProgram(), "ivec4_f");    // ivec4
1005         GLint uvec4_f   = ctx.glGetUniformLocation(program.getProgram(), "uvec4_f");    // uvec4
1006         GLint sampler_f = ctx.glGetUniformLocation(program.getProgram(), "sampler_f");  // sampler2D
1007         ctx.expectError(GL_NO_ERROR);
1008
1009         if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1)
1010         {
1011                 ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1012                 ctx.fail("Failed to retrieve uniform location");
1013         }
1014
1015         ctx.beginSection("GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the ctx.glUniform command.");
1016         ctx.glUseProgram(program.getProgram());
1017         ctx.glUniform1f(vec4_v, 0.0f);
1018         ctx.expectError(GL_INVALID_OPERATION);
1019         ctx.glUniform2f(vec4_v, 0.0f, 0.0f);
1020         ctx.expectError(GL_INVALID_OPERATION);
1021         ctx.glUniform3f(vec4_v, 0.0f, 0.0f, 0.0f);
1022         ctx.expectError(GL_INVALID_OPERATION);
1023         ctx.glUniform4f(vec4_v, 0.0f, 0.0f, 0.0f, 0.0f);
1024         ctx.expectError(GL_NO_ERROR);
1025         ctx.endSection();
1026
1027         ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}f is used to load a uniform variable of type int, ivec2, ivec3, ivec4, unsigned int, uvec2, uvec3, uvec4.");
1028         ctx.glUseProgram(program.getProgram());
1029         ctx.glUniform4f(ivec4_f, 0.0f, 0.0f, 0.0f, 0.0f);
1030         ctx.expectError(GL_INVALID_OPERATION);
1031         ctx.glUniform4f(uvec4_f, 0.0f, 0.0f, 0.0f, 0.0f);
1032         ctx.expectError(GL_INVALID_OPERATION);
1033         ctx.endSection();
1034
1035         ctx.beginSection("GL_INVALID_OPERATION is generated if a sampler is loaded using a command other than ctx.glUniform1i and ctx.glUniform1iv.");
1036         ctx.glUseProgram(program.getProgram());
1037         ctx.glUniform1f(sampler_f, 0.0f);
1038         ctx.expectError(GL_INVALID_OPERATION);
1039         ctx.endSection();
1040
1041         ctx.glUseProgram(0);
1042 }
1043
1044 void uniformf_invalid_location (NegativeTestContext& ctx)
1045 {
1046         glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1047
1048         ctx.glUseProgram(program.getProgram());
1049         ctx.expectError(GL_NO_ERROR);
1050
1051         ctx.beginSection("GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1.");
1052         ctx.glUseProgram(program.getProgram());
1053         ctx.glUniform1f(-2, 0.0f);
1054         ctx.expectError(GL_INVALID_OPERATION);
1055         ctx.glUniform2f(-2, 0.0f, 0.0f);
1056         ctx.expectError(GL_INVALID_OPERATION);
1057         ctx.glUniform3f(-2, 0.0f, 0.0f, 0.0f);
1058         ctx.expectError(GL_INVALID_OPERATION);
1059         ctx.glUniform4f(-2, 0.0f, 0.0f, 0.0f, 0.0f);
1060         ctx.expectError(GL_INVALID_OPERATION);
1061
1062         ctx.glUseProgram(program.getProgram());
1063         ctx.glUniform1f(-1, 0.0f);
1064         ctx.expectError(GL_NO_ERROR);
1065         ctx.glUniform2f(-1, 0.0f, 0.0f);
1066         ctx.expectError(GL_NO_ERROR);
1067         ctx.glUniform3f(-1, 0.0f, 0.0f, 0.0f);
1068         ctx.expectError(GL_NO_ERROR);
1069         ctx.glUniform4f(-1, 0.0f, 0.0f, 0.0f, 0.0f);
1070         ctx.expectError(GL_NO_ERROR);
1071         ctx.endSection();
1072
1073         ctx.glUseProgram(0);
1074 }
1075
1076 // ctx.glUniform*fv
1077
1078 void uniformfv_invalid_program (NegativeTestContext& ctx)
1079 {
1080         std::vector<GLfloat> data(4);
1081
1082         ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object.");
1083         ctx.glUseProgram(0);
1084         ctx.glUniform1fv(-1, 1, &data[0]);
1085         ctx.expectError(GL_INVALID_OPERATION);
1086         ctx.glUniform2fv(-1, 1, &data[0]);
1087         ctx.expectError(GL_INVALID_OPERATION);
1088         ctx.glUniform3fv(-1, 1, &data[0]);
1089         ctx.expectError(GL_INVALID_OPERATION);
1090         ctx.glUniform4fv(-1, 1, &data[0]);
1091         ctx.expectError(GL_INVALID_OPERATION);
1092         ctx.endSection();
1093 }
1094
1095 void uniformfv_incompatible_type (NegativeTestContext& ctx)
1096 {
1097         glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1098
1099         ctx.glUseProgram(program.getProgram());
1100         GLint vec4_v    = ctx.glGetUniformLocation(program.getProgram(), "vec4_v");     // vec4
1101         GLint ivec4_f   = ctx.glGetUniformLocation(program.getProgram(), "ivec4_f");    // ivec4
1102         GLint uvec4_f   = ctx.glGetUniformLocation(program.getProgram(), "uvec4_f");    // uvec4
1103         GLint sampler_f = ctx.glGetUniformLocation(program.getProgram(), "sampler_f");  // sampler2D
1104         ctx.expectError(GL_NO_ERROR);
1105
1106         if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1)
1107         {
1108                 ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1109                 ctx.fail("Failed to retrieve uniform location");
1110         }
1111
1112         std::vector<GLfloat> data(4);
1113
1114         ctx.beginSection("GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the ctx.glUniform command.");
1115         ctx.glUseProgram(program.getProgram());
1116         ctx.glUniform1fv(vec4_v, 1, &data[0]);
1117         ctx.expectError(GL_INVALID_OPERATION);
1118         ctx.glUniform2fv(vec4_v, 1, &data[0]);
1119         ctx.expectError(GL_INVALID_OPERATION);
1120         ctx.glUniform3fv(vec4_v, 1, &data[0]);
1121         ctx.expectError(GL_INVALID_OPERATION);
1122         ctx.glUniform4fv(vec4_v, 1, &data[0]);
1123         ctx.expectError(GL_NO_ERROR);
1124         ctx.endSection();
1125
1126         ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}fv is used to load a uniform variable of type int, ivec2, ivec3, ivec4, unsigned int, uvec2, uvec3, uvec4.");
1127         ctx.glUseProgram(program.getProgram());
1128         ctx.glUniform4fv(ivec4_f, 1, &data[0]);
1129         ctx.expectError(GL_INVALID_OPERATION);
1130         ctx.glUniform4fv(uvec4_f, 1, &data[0]);
1131         ctx.expectError(GL_INVALID_OPERATION);
1132         ctx.endSection();
1133
1134         ctx.beginSection("GL_INVALID_OPERATION is generated if a sampler is loaded using a command other than ctx.glUniform1i and ctx.glUniform1iv.");
1135         ctx.glUseProgram(program.getProgram());
1136         ctx.glUniform1fv(sampler_f, 1, &data[0]);
1137         ctx.expectError(GL_INVALID_OPERATION);
1138         ctx.endSection();
1139
1140         ctx.glUseProgram(0);
1141 }
1142
1143 void uniformfv_invalid_location (NegativeTestContext& ctx)
1144 {
1145         glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1146
1147         ctx.glUseProgram(program.getProgram());
1148         ctx.expectError(GL_NO_ERROR);
1149
1150         std::vector<GLfloat> data(4);
1151
1152         ctx.beginSection("GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1.");
1153         ctx.glUseProgram(program.getProgram());
1154         ctx.glUniform1fv(-2, 1, &data[0]);
1155         ctx.expectError(GL_INVALID_OPERATION);
1156         ctx.glUniform2fv(-2, 1, &data[0]);
1157         ctx.expectError(GL_INVALID_OPERATION);
1158         ctx.glUniform3fv(-2, 1, &data[0]);
1159         ctx.expectError(GL_INVALID_OPERATION);
1160         ctx.glUniform4fv(-2, 1, &data[0]);
1161         ctx.expectError(GL_INVALID_OPERATION);
1162
1163         ctx.glUseProgram(program.getProgram());
1164         ctx.glUniform1fv(-1, 1, &data[0]);
1165         ctx.expectError(GL_NO_ERROR);
1166         ctx.glUniform2fv(-1, 1, &data[0]);
1167         ctx.expectError(GL_NO_ERROR);
1168         ctx.glUniform3fv(-1, 1, &data[0]);
1169         ctx.expectError(GL_NO_ERROR);
1170         ctx.glUniform4fv(-1, 1, &data[0]);
1171         ctx.expectError(GL_NO_ERROR);
1172         ctx.endSection();
1173
1174         ctx.glUseProgram(0);
1175 }
1176
1177 void uniformfv_invalid_count (NegativeTestContext& ctx)
1178 {
1179         glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1180
1181         ctx.glUseProgram        (program.getProgram());
1182         GLint vec4_v                    = ctx.glGetUniformLocation(program.getProgram(), "vec4_v");     // vec4
1183         ctx.expectError(GL_NO_ERROR);
1184
1185         if (vec4_v == -1)
1186         {
1187                 ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1188                 ctx.fail("Failed to retrieve uniform location");
1189         }
1190
1191         std::vector<GLfloat> data(8);
1192
1193         ctx.beginSection("GL_INVALID_OPERATION is generated if count is greater than 1 and the indicated uniform variable is not an array variable.");
1194         ctx.glUseProgram(program.getProgram());
1195         ctx.glUniform1fv(vec4_v, 2, &data[0]);
1196         ctx.expectError(GL_INVALID_OPERATION);
1197         ctx.glUniform2fv(vec4_v, 2, &data[0]);
1198         ctx.expectError(GL_INVALID_OPERATION);
1199         ctx.glUniform3fv(vec4_v, 2, &data[0]);
1200         ctx.expectError(GL_INVALID_OPERATION);
1201         ctx.glUniform4fv(vec4_v, 2, &data[0]);
1202         ctx.expectError(GL_INVALID_OPERATION);
1203         ctx.endSection();
1204
1205         ctx.glUseProgram(0);
1206 }
1207
1208 // ctx.glUniform*i
1209
1210 void uniformi_invalid_program (NegativeTestContext& ctx)
1211 {
1212         ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object.");
1213         ctx.glUseProgram(0);
1214         ctx.glUniform1i(-1, 0);
1215         ctx.expectError(GL_INVALID_OPERATION);
1216         ctx.glUniform2i(-1, 0, 0);
1217         ctx.expectError(GL_INVALID_OPERATION);
1218         ctx.glUniform3i(-1, 0, 0, 0);
1219         ctx.expectError(GL_INVALID_OPERATION);
1220         ctx.glUniform4i(-1, 0, 0, 0, 0);
1221         ctx.expectError(GL_INVALID_OPERATION);
1222         ctx.endSection();
1223 }
1224
1225 void uniformi_incompatible_type (NegativeTestContext& ctx)
1226 {
1227         glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1228
1229         ctx.glUseProgram(program.getProgram());
1230         GLint vec4_v    = ctx.glGetUniformLocation(program.getProgram(), "vec4_v");     // vec4
1231         GLint ivec4_f   = ctx.glGetUniformLocation(program.getProgram(), "ivec4_f");    // ivec4
1232         GLint uvec4_f   = ctx.glGetUniformLocation(program.getProgram(), "uvec4_f");    // uvec4
1233         GLint sampler_f = ctx.glGetUniformLocation(program.getProgram(), "sampler_f");  // sampler2D
1234         ctx.expectError(GL_NO_ERROR);
1235
1236         if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1)
1237         {
1238                 ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1239                 ctx.fail("Failed to retrieve uniform location");
1240         }
1241
1242         ctx.beginSection("GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the ctx.glUniform command.");
1243         ctx.glUseProgram(program.getProgram());
1244         ctx.glUniform1i(ivec4_f, 0);
1245         ctx.expectError(GL_INVALID_OPERATION);
1246         ctx.glUniform2i(ivec4_f, 0, 0);
1247         ctx.expectError(GL_INVALID_OPERATION);
1248         ctx.glUniform3i(ivec4_f, 0, 0, 0);
1249         ctx.expectError(GL_INVALID_OPERATION);
1250         ctx.glUniform4i(ivec4_f, 0, 0, 0, 0);
1251         ctx.expectError(GL_NO_ERROR);
1252         ctx.endSection();
1253
1254         ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}i is used to load a uniform variable of type unsigned int, uvec2, uvec3, uvec4, or an array of these.");
1255         ctx.glUseProgram(program.getProgram());
1256         ctx.glUniform1i(uvec4_f, 0);
1257         ctx.expectError(GL_INVALID_OPERATION);
1258         ctx.glUniform2i(uvec4_f, 0, 0);
1259         ctx.expectError(GL_INVALID_OPERATION);
1260         ctx.glUniform3i(uvec4_f, 0, 0, 0);
1261         ctx.expectError(GL_INVALID_OPERATION);
1262         ctx.glUniform4i(uvec4_f, 0, 0, 0, 0);
1263         ctx.expectError(GL_INVALID_OPERATION);
1264         ctx.endSection();
1265
1266         ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}i is used to load a uniform variable of type float, vec2, vec3, or vec4.");
1267         ctx.glUseProgram(program.getProgram());
1268         ctx.glUniform1i(vec4_v, 0);
1269         ctx.expectError(GL_INVALID_OPERATION);
1270         ctx.glUniform2i(vec4_v, 0, 0);
1271         ctx.expectError(GL_INVALID_OPERATION);
1272         ctx.glUniform3i(vec4_v, 0, 0, 0);
1273         ctx.expectError(GL_INVALID_OPERATION);
1274         ctx.glUniform4i(vec4_v, 0, 0, 0, 0);
1275         ctx.expectError(GL_INVALID_OPERATION);
1276         ctx.endSection();
1277
1278         ctx.glUseProgram(0);
1279 }
1280
1281 void uniformi_invalid_location (NegativeTestContext& ctx)
1282 {
1283         glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1284
1285         ctx.glUseProgram(program.getProgram());
1286         ctx.expectError(GL_NO_ERROR);
1287
1288         ctx.beginSection("GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1.");
1289         ctx.glUseProgram(program.getProgram());
1290         ctx.glUniform1i(-2, 0);
1291         ctx.expectError(GL_INVALID_OPERATION);
1292         ctx.glUniform2i(-2, 0, 0);
1293         ctx.expectError(GL_INVALID_OPERATION);
1294         ctx.glUniform3i(-2, 0, 0, 0);
1295         ctx.expectError(GL_INVALID_OPERATION);
1296         ctx.glUniform4i(-2, 0, 0, 0, 0);
1297         ctx.expectError(GL_INVALID_OPERATION);
1298
1299         ctx.glUseProgram(program.getProgram());
1300         ctx.glUniform1i(-1, 0);
1301         ctx.expectError(GL_NO_ERROR);
1302         ctx.glUniform2i(-1, 0, 0);
1303         ctx.expectError(GL_NO_ERROR);
1304         ctx.glUniform3i(-1, 0, 0, 0);
1305         ctx.expectError(GL_NO_ERROR);
1306         ctx.glUniform4i(-1, 0, 0, 0, 0);
1307         ctx.expectError(GL_NO_ERROR);
1308         ctx.endSection();
1309
1310         ctx.glUseProgram(0);
1311 }
1312
1313 // ctx.glUniform*iv
1314
1315 void uniformiv_invalid_program (NegativeTestContext& ctx)
1316 {
1317         std::vector<GLint> data(4);
1318
1319         ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object.");
1320         ctx.glUseProgram(0);
1321         ctx.glUniform1iv(-1, 1, &data[0]);
1322         ctx.expectError(GL_INVALID_OPERATION);
1323         ctx.glUniform2iv(-1, 1, &data[0]);
1324         ctx.expectError(GL_INVALID_OPERATION);
1325         ctx.glUniform3iv(-1, 1, &data[0]);
1326         ctx.expectError(GL_INVALID_OPERATION);
1327         ctx.glUniform4iv(-1, 1, &data[0]);
1328         ctx.expectError(GL_INVALID_OPERATION);
1329         ctx.endSection();
1330 }
1331
1332 void uniformiv_incompatible_type (NegativeTestContext& ctx)
1333 {
1334         glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1335
1336         ctx.glUseProgram(program.getProgram());
1337         GLint vec4_v    = ctx.glGetUniformLocation(program.getProgram(), "vec4_v");     // vec4
1338         GLint ivec4_f   = ctx.glGetUniformLocation(program.getProgram(), "ivec4_f");    // ivec4
1339         GLint uvec4_f   = ctx.glGetUniformLocation(program.getProgram(), "uvec4_f");    // uvec4
1340         GLint sampler_f = ctx.glGetUniformLocation(program.getProgram(), "sampler_f");  // sampler2D
1341         ctx.expectError(GL_NO_ERROR);
1342
1343         if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1)
1344         {
1345                 ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1346                 ctx.fail("Failed to retrieve uniform location");
1347         }
1348
1349         std::vector<GLint> data(4);
1350
1351         ctx.beginSection("GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the ctx.glUniform command.");
1352         ctx.glUseProgram(program.getProgram());
1353         ctx.glUniform1iv(ivec4_f, 1, &data[0]);
1354         ctx.expectError(GL_INVALID_OPERATION);
1355         ctx.glUniform2iv(ivec4_f, 1, &data[0]);
1356         ctx.expectError(GL_INVALID_OPERATION);
1357         ctx.glUniform3iv(ivec4_f, 1, &data[0]);
1358         ctx.expectError(GL_INVALID_OPERATION);
1359         ctx.glUniform4iv(ivec4_f, 1, &data[0]);
1360         ctx.expectError(GL_NO_ERROR);
1361         ctx.endSection();
1362
1363         ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}iv is used to load a uniform variable of type float, vec2, vec3, or vec4.");
1364         ctx.glUseProgram(program.getProgram());
1365         ctx.glUniform1iv(vec4_v, 1, &data[0]);
1366         ctx.expectError(GL_INVALID_OPERATION);
1367         ctx.glUniform2iv(vec4_v, 1, &data[0]);
1368         ctx.expectError(GL_INVALID_OPERATION);
1369         ctx.glUniform3iv(vec4_v, 1, &data[0]);
1370         ctx.expectError(GL_INVALID_OPERATION);
1371         ctx.glUniform4iv(vec4_v, 1, &data[0]);
1372         ctx.expectError(GL_INVALID_OPERATION);
1373         ctx.endSection();
1374
1375         ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}iv is used to load a uniform variable of type unsigned int, uvec2, uvec3 or uvec4.");
1376         ctx.glUseProgram(program.getProgram());
1377         ctx.glUniform1iv(uvec4_f, 1, &data[0]);
1378         ctx.expectError(GL_INVALID_OPERATION);
1379         ctx.glUniform2iv(uvec4_f, 1, &data[0]);
1380         ctx.expectError(GL_INVALID_OPERATION);
1381         ctx.glUniform3iv(uvec4_f, 1, &data[0]);
1382         ctx.expectError(GL_INVALID_OPERATION);
1383         ctx.glUniform4iv(uvec4_f, 1, &data[0]);
1384         ctx.expectError(GL_INVALID_OPERATION);
1385         ctx.endSection();
1386
1387         ctx.glUseProgram(0);
1388 }
1389
1390 void uniformiv_invalid_location (NegativeTestContext& ctx)
1391 {
1392         glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1393
1394         ctx.glUseProgram(program.getProgram());
1395         ctx.expectError(GL_NO_ERROR);
1396
1397         std::vector<GLint> data(4);
1398
1399         ctx.beginSection("GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1.");
1400         ctx.glUseProgram(program.getProgram());
1401         ctx.glUniform1iv(-2, 1, &data[0]);
1402         ctx.expectError(GL_INVALID_OPERATION);
1403         ctx.glUniform2iv(-2, 1, &data[0]);
1404         ctx.expectError(GL_INVALID_OPERATION);
1405         ctx.glUniform3iv(-2, 1, &data[0]);
1406         ctx.expectError(GL_INVALID_OPERATION);
1407         ctx.glUniform4iv(-2, 1, &data[0]);
1408         ctx.expectError(GL_INVALID_OPERATION);
1409
1410         ctx.glUseProgram(program.getProgram());
1411         ctx.glUniform1iv(-1, 1, &data[0]);
1412         ctx.expectError(GL_NO_ERROR);
1413         ctx.glUniform2iv(-1, 1, &data[0]);
1414         ctx.expectError(GL_NO_ERROR);
1415         ctx.glUniform3iv(-1, 1, &data[0]);
1416         ctx.expectError(GL_NO_ERROR);
1417         ctx.glUniform4iv(-1, 1, &data[0]);
1418         ctx.expectError(GL_NO_ERROR);
1419         ctx.endSection();
1420
1421         ctx.glUseProgram(0);
1422 }
1423
1424 void uniformiv_invalid_count (NegativeTestContext& ctx)
1425 {
1426         glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1427
1428         ctx.glUseProgram                        (program.getProgram());
1429         GLint ivec4_f                   = ctx.glGetUniformLocation(program.getProgram(), "ivec4_f"); // ivec4
1430         ctx.expectError(GL_NO_ERROR);
1431
1432         if (ivec4_f == -1)
1433         {
1434                 ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1435                 ctx.fail("Failed to retrieve uniform location");
1436         }
1437
1438         std::vector<GLint> data(8);
1439
1440         ctx.beginSection("GL_INVALID_OPERATION is generated if count is greater than 1 and the indicated uniform variable is not an array variable.");
1441         ctx.glUseProgram(program.getProgram());
1442         ctx.glUniform1iv(ivec4_f, 2, &data[0]);
1443         ctx.expectError(GL_INVALID_OPERATION);
1444         ctx.glUniform2iv(ivec4_f, 2, &data[0]);
1445         ctx.expectError(GL_INVALID_OPERATION);
1446         ctx.glUniform3iv(ivec4_f, 2, &data[0]);
1447         ctx.expectError(GL_INVALID_OPERATION);
1448         ctx.glUniform4iv(ivec4_f, 2, &data[0]);
1449         ctx.expectError(GL_INVALID_OPERATION);
1450         ctx.endSection();
1451
1452         ctx.glUseProgram(0);
1453 }
1454
1455 // ctx.glUniform{1234}ui
1456
1457 void uniformui_invalid_program (NegativeTestContext& ctx)
1458 {
1459         ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object.");
1460         ctx.glUseProgram(0);
1461         ctx.glUniform1ui(-1, 0);
1462         ctx.expectError(GL_INVALID_OPERATION);
1463         ctx.glUniform2ui(-1, 0, 0);
1464         ctx.expectError(GL_INVALID_OPERATION);
1465         ctx.glUniform3ui(-1, 0, 0, 0);
1466         ctx.expectError(GL_INVALID_OPERATION);
1467         ctx.glUniform4ui(-1, 0, 0, 0, 0);
1468         ctx.expectError(GL_INVALID_OPERATION);
1469         ctx.endSection();
1470 }
1471
1472 void uniformui_incompatible_type (NegativeTestContext& ctx)
1473 {
1474         glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1475
1476         ctx.glUseProgram(program.getProgram());
1477         GLint vec4_v    = ctx.glGetUniformLocation(program.getProgram(), "vec4_v");     // vec4
1478         GLint ivec4_f   = ctx.glGetUniformLocation(program.getProgram(), "ivec4_f");    // ivec4
1479         GLint uvec4_f   = ctx.glGetUniformLocation(program.getProgram(), "uvec4_f");    // uvec4
1480         GLint sampler_f = ctx.glGetUniformLocation(program.getProgram(), "sampler_f");  // sampler2D
1481         ctx.expectError(GL_NO_ERROR);
1482
1483         if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1)
1484         {
1485                 ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1486                 ctx.fail("Failed to retrieve uniform location");
1487         }
1488
1489         ctx.beginSection("GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the ctx.glUniform command.");
1490         ctx.glUseProgram(program.getProgram());
1491         ctx.glUniform1ui(uvec4_f, 0);
1492         ctx.expectError(GL_INVALID_OPERATION);
1493         ctx.glUniform2ui(uvec4_f, 0, 0);
1494         ctx.expectError(GL_INVALID_OPERATION);
1495         ctx.glUniform3ui(uvec4_f, 0, 0, 0);
1496         ctx.expectError(GL_INVALID_OPERATION);
1497         ctx.glUniform4ui(uvec4_f, 0, 0, 0, 0);
1498         ctx.expectError(GL_NO_ERROR);
1499         ctx.endSection();
1500
1501         ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}i is used to load a uniform variable of type int, ivec2, ivec3, ivec4, or an array of these.");
1502         ctx.glUseProgram(program.getProgram());
1503         ctx.glUniform1ui(ivec4_f, 0);
1504         ctx.expectError(GL_INVALID_OPERATION);
1505         ctx.glUniform2ui(ivec4_f, 0, 0);
1506         ctx.expectError(GL_INVALID_OPERATION);
1507         ctx.glUniform3ui(ivec4_f, 0, 0, 0);
1508         ctx.expectError(GL_INVALID_OPERATION);
1509         ctx.glUniform4ui(ivec4_f, 0, 0, 0, 0);
1510         ctx.expectError(GL_INVALID_OPERATION);
1511         ctx.endSection();
1512
1513         ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}i is used to load a uniform variable of type float, vec2, vec3, or vec4.");
1514         ctx.glUseProgram(program.getProgram());
1515         ctx.glUniform1ui(vec4_v, 0);
1516         ctx.expectError(GL_INVALID_OPERATION);
1517         ctx.glUniform2ui(vec4_v, 0, 0);
1518         ctx.expectError(GL_INVALID_OPERATION);
1519         ctx.glUniform3ui(vec4_v, 0, 0, 0);
1520         ctx.expectError(GL_INVALID_OPERATION);
1521         ctx.glUniform4ui(vec4_v, 0, 0, 0, 0);
1522         ctx.expectError(GL_INVALID_OPERATION);
1523         ctx.endSection();
1524
1525         ctx.beginSection("GL_INVALID_OPERATION is generated if a sampler is loaded using a command other than ctx.glUniform1i and ctx.glUniform1iv.");
1526         ctx.glUseProgram(program.getProgram());
1527         ctx.glUniform1ui(sampler_f, 0);
1528         ctx.expectError(GL_INVALID_OPERATION);
1529         ctx.endSection();
1530
1531         ctx.glUseProgram(0);
1532 }
1533
1534 void uniformui_invalid_location (NegativeTestContext& ctx)
1535 {
1536         glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1537
1538         ctx.glUseProgram(program.getProgram());
1539         ctx.expectError(GL_NO_ERROR);
1540
1541         ctx.beginSection("GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1.");
1542         ctx.glUseProgram(program.getProgram());
1543         ctx.glUniform1i(-2, 0);
1544         ctx.expectError(GL_INVALID_OPERATION);
1545         ctx.glUniform2i(-2, 0, 0);
1546         ctx.expectError(GL_INVALID_OPERATION);
1547         ctx.glUniform3i(-2, 0, 0, 0);
1548         ctx.expectError(GL_INVALID_OPERATION);
1549         ctx.glUniform4i(-2, 0, 0, 0, 0);
1550         ctx.expectError(GL_INVALID_OPERATION);
1551
1552         ctx.glUseProgram(program.getProgram());
1553         ctx.glUniform1i(-1, 0);
1554         ctx.expectError(GL_NO_ERROR);
1555         ctx.glUniform2i(-1, 0, 0);
1556         ctx.expectError(GL_NO_ERROR);
1557         ctx.glUniform3i(-1, 0, 0, 0);
1558         ctx.expectError(GL_NO_ERROR);
1559         ctx.glUniform4i(-1, 0, 0, 0, 0);
1560         ctx.expectError(GL_NO_ERROR);
1561         ctx.endSection();
1562
1563         ctx.glUseProgram(0);
1564 }
1565
1566 // ctx.glUniform{1234}uiv
1567
1568 void uniformuiv_invalid_program (NegativeTestContext& ctx)
1569 {
1570         std::vector<GLuint> data(4);
1571
1572         ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object.");
1573         ctx.glUseProgram(0);
1574         ctx.glUniform1uiv(-1, 1, &data[0]);
1575         ctx.expectError(GL_INVALID_OPERATION);
1576         ctx.glUniform2uiv(-1, 1, &data[0]);
1577         ctx.expectError(GL_INVALID_OPERATION);
1578         ctx.glUniform3uiv(-1, 1, &data[0]);
1579         ctx.expectError(GL_INVALID_OPERATION);
1580         ctx.glUniform4uiv(-1, 1, &data[0]);
1581         ctx.expectError(GL_INVALID_OPERATION);
1582         ctx.endSection();
1583 }
1584
1585 void uniformuiv_incompatible_type (NegativeTestContext& ctx)
1586 {
1587         glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1588
1589         ctx.glUseProgram(program.getProgram());
1590         GLint vec4_v    = ctx.glGetUniformLocation(program.getProgram(), "vec4_v");     // vec4
1591         GLint ivec4_f   = ctx.glGetUniformLocation(program.getProgram(), "ivec4_f");    // ivec4
1592         GLint uvec4_f   = ctx.glGetUniformLocation(program.getProgram(), "uvec4_f");    // uvec4
1593         GLint sampler_f = ctx.glGetUniformLocation(program.getProgram(), "sampler_f");  // sampler2D
1594         ctx.expectError(GL_NO_ERROR);
1595
1596         if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1)
1597         {
1598                 ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1599                 ctx.fail("Failed to retrieve uniform location");
1600         }
1601
1602         std::vector<GLuint> data(4);
1603
1604         ctx.beginSection("GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the ctx.glUniform command.");
1605         ctx.glUseProgram(program.getProgram());
1606         ctx.glUniform1uiv(uvec4_f, 1, &data[0]);
1607         ctx.expectError(GL_INVALID_OPERATION);
1608         ctx.glUniform2uiv(uvec4_f, 1, &data[0]);
1609         ctx.expectError(GL_INVALID_OPERATION);
1610         ctx.glUniform3uiv(uvec4_f, 1, &data[0]);
1611         ctx.expectError(GL_INVALID_OPERATION);
1612         ctx.glUniform4uiv(uvec4_f, 1, &data[0]);
1613         ctx.expectError(GL_NO_ERROR);
1614         ctx.endSection();
1615
1616         ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}uiv is used to load a uniform variable of type float, vec2, vec3, or vec4.");
1617         ctx.glUseProgram(program.getProgram());
1618         ctx.glUniform1uiv(vec4_v, 1, &data[0]);
1619         ctx.expectError(GL_INVALID_OPERATION);
1620         ctx.glUniform2uiv(vec4_v, 1, &data[0]);
1621         ctx.expectError(GL_INVALID_OPERATION);
1622         ctx.glUniform3uiv(vec4_v, 1, &data[0]);
1623         ctx.expectError(GL_INVALID_OPERATION);
1624         ctx.glUniform4uiv(vec4_v, 1, &data[0]);
1625         ctx.expectError(GL_INVALID_OPERATION);
1626         ctx.endSection();
1627
1628         ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}uiv is used to load a uniform variable of type int, ivec2, ivec3 or ivec4.");
1629         ctx.glUseProgram(program.getProgram());
1630         ctx.glUniform1uiv(ivec4_f, 1, &data[0]);
1631         ctx.expectError(GL_INVALID_OPERATION);
1632         ctx.glUniform2uiv(ivec4_f, 1, &data[0]);
1633         ctx.expectError(GL_INVALID_OPERATION);
1634         ctx.glUniform3uiv(ivec4_f, 1, &data[0]);
1635         ctx.expectError(GL_INVALID_OPERATION);
1636         ctx.glUniform4uiv(ivec4_f, 1, &data[0]);
1637         ctx.expectError(GL_INVALID_OPERATION);
1638         ctx.endSection();
1639
1640         ctx.beginSection("GL_INVALID_OPERATION is generated if a sampler is loaded using a command other than ctx.glUniform1i and ctx.glUniform1iv.");
1641         ctx.glUseProgram(program.getProgram());
1642         ctx.glUniform1uiv(sampler_f, 1, &data[0]);
1643         ctx.expectError(GL_INVALID_OPERATION);
1644         ctx.endSection();
1645
1646         ctx.glUseProgram(0);
1647 }
1648
1649 void uniformuiv_invalid_location (NegativeTestContext& ctx)
1650 {
1651         glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1652
1653         ctx.glUseProgram(program.getProgram());
1654         ctx.expectError(GL_NO_ERROR);
1655
1656         std::vector<GLuint> data(4);
1657
1658         ctx.beginSection("GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1.");
1659         ctx.glUseProgram(program.getProgram());
1660         ctx.glUniform1uiv(-2, 1, &data[0]);
1661         ctx.expectError(GL_INVALID_OPERATION);
1662         ctx.glUniform2uiv(-2, 1, &data[0]);
1663         ctx.expectError(GL_INVALID_OPERATION);
1664         ctx.glUniform3uiv(-2, 1, &data[0]);
1665         ctx.expectError(GL_INVALID_OPERATION);
1666         ctx.glUniform4uiv(-2, 1, &data[0]);
1667         ctx.expectError(GL_INVALID_OPERATION);
1668
1669         ctx.glUseProgram(program.getProgram());
1670         ctx.glUniform1uiv(-1, 1, &data[0]);
1671         ctx.expectError(GL_NO_ERROR);
1672         ctx.glUniform2uiv(-1, 1, &data[0]);
1673         ctx.expectError(GL_NO_ERROR);
1674         ctx.glUniform3uiv(-1, 1, &data[0]);
1675         ctx.expectError(GL_NO_ERROR);
1676         ctx.glUniform4uiv(-1, 1, &data[0]);
1677         ctx.expectError(GL_NO_ERROR);
1678         ctx.endSection();
1679
1680         ctx.glUseProgram(0);
1681 }
1682
1683 void uniformuiv_invalid_count (NegativeTestContext& ctx)
1684 {
1685         glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1686
1687         ctx.glUseProgram                        (program.getProgram());
1688         int uvec4_f                             = ctx.glGetUniformLocation(program.getProgram(), "uvec4_f"); // uvec4
1689         ctx.expectError(GL_NO_ERROR);
1690
1691         if (uvec4_f == -1)
1692         {
1693                 ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1694                 ctx.fail("Failed to retrieve uniform location");
1695         }
1696
1697         std::vector<GLuint> data(8);
1698
1699         ctx.beginSection("GL_INVALID_OPERATION is generated if count is greater than 1 and the indicated uniform variable is not an array variable.");
1700         ctx.glUseProgram(program.getProgram());
1701         ctx.glUniform1uiv(uvec4_f, 2, &data[0]);
1702         ctx.expectError(GL_INVALID_OPERATION);
1703         ctx.glUniform2uiv(uvec4_f, 2, &data[0]);
1704         ctx.expectError(GL_INVALID_OPERATION);
1705         ctx.glUniform3uiv(uvec4_f, 2, &data[0]);
1706         ctx.expectError(GL_INVALID_OPERATION);
1707         ctx.glUniform4uiv(uvec4_f, 2, &data[0]);
1708         ctx.expectError(GL_INVALID_OPERATION);
1709         ctx.endSection();
1710
1711         ctx.glUseProgram(0);
1712 }
1713
1714
1715 // ctx.glUniformMatrix*fv
1716
1717 void uniform_matrixfv_invalid_program (NegativeTestContext& ctx)
1718 {
1719         std::vector<GLfloat> data(16);
1720
1721         ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object.");
1722         ctx.glUseProgram(0);
1723         ctx.glUniformMatrix2fv(-1, 1, GL_FALSE, &data[0]);
1724         ctx.expectError(GL_INVALID_OPERATION);
1725         ctx.glUniformMatrix3fv(-1, 1, GL_FALSE, &data[0]);
1726         ctx.expectError(GL_INVALID_OPERATION);
1727         ctx.glUniformMatrix4fv(-1, 1, GL_FALSE, &data[0]);
1728         ctx.expectError(GL_INVALID_OPERATION);
1729
1730         ctx.glUniformMatrix2x3fv(-1, 1, GL_FALSE, &data[0]);
1731         ctx.expectError(GL_INVALID_OPERATION);
1732         ctx.glUniformMatrix3x2fv(-1, 1, GL_FALSE, &data[0]);
1733         ctx.expectError(GL_INVALID_OPERATION);
1734         ctx.glUniformMatrix2x4fv(-1, 1, GL_FALSE, &data[0]);
1735         ctx.expectError(GL_INVALID_OPERATION);
1736         ctx.glUniformMatrix4x2fv(-1, 1, GL_FALSE, &data[0]);
1737         ctx.expectError(GL_INVALID_OPERATION);
1738         ctx.glUniformMatrix3x4fv(-1, 1, GL_FALSE, &data[0]);
1739         ctx.expectError(GL_INVALID_OPERATION);
1740         ctx.glUniformMatrix4x3fv(-1, 1, GL_FALSE, &data[0]);
1741         ctx.expectError(GL_INVALID_OPERATION);
1742         ctx.endSection();
1743 }
1744
1745 void uniform_matrixfv_incompatible_type (NegativeTestContext& ctx)
1746 {
1747         glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1748
1749         ctx.glUseProgram                        (program.getProgram());
1750         GLint mat4_v                    = ctx.glGetUniformLocation(program.getProgram(), "mat4_v");     // mat4
1751         GLint sampler_f                 = ctx.glGetUniformLocation(program.getProgram(), "sampler_f");  // sampler2D
1752         ctx.expectError(GL_NO_ERROR);
1753
1754         if (mat4_v == -1 || sampler_f == -1)
1755         {
1756                 ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1757                 ctx.fail("Failed to retrieve uniform location");
1758         }
1759
1760         std::vector<GLfloat> data(16);
1761
1762         ctx.beginSection("GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the ctx.glUniform command.");
1763         ctx.glUseProgram(program.getProgram());
1764         ctx.glUniformMatrix2fv(mat4_v, 1, GL_FALSE, &data[0]);
1765         ctx.expectError(GL_INVALID_OPERATION);
1766         ctx.glUniformMatrix3fv(mat4_v, 1, GL_FALSE, &data[0]);
1767         ctx.expectError(GL_INVALID_OPERATION);
1768         ctx.glUniformMatrix4fv(mat4_v, 1, GL_FALSE, &data[0]);
1769         ctx.expectError(GL_NO_ERROR);
1770
1771         ctx.glUniformMatrix2x3fv(mat4_v, 1, GL_FALSE, &data[0]);
1772         ctx.expectError(GL_INVALID_OPERATION);
1773         ctx.glUniformMatrix3x2fv(mat4_v, 1, GL_FALSE, &data[0]);
1774         ctx.expectError(GL_INVALID_OPERATION);
1775         ctx.glUniformMatrix2x4fv(mat4_v, 1, GL_FALSE, &data[0]);
1776         ctx.expectError(GL_INVALID_OPERATION);
1777         ctx.glUniformMatrix4x2fv(mat4_v, 1, GL_FALSE, &data[0]);
1778         ctx.expectError(GL_INVALID_OPERATION);
1779         ctx.glUniformMatrix3x4fv(mat4_v, 1, GL_FALSE, &data[0]);
1780         ctx.expectError(GL_INVALID_OPERATION);
1781         ctx.glUniformMatrix4x3fv(mat4_v, 1, GL_FALSE, &data[0]);
1782         ctx.expectError(GL_INVALID_OPERATION);
1783         ctx.endSection();
1784
1785         ctx.beginSection("GL_INVALID_OPERATION is generated if a sampler is loaded using a command other than ctx.glUniform1i and ctx.glUniform1iv.");
1786         ctx.glUseProgram(program.getProgram());
1787         ctx.glUniformMatrix2fv(sampler_f, 1, GL_FALSE, &data[0]);
1788         ctx.expectError(GL_INVALID_OPERATION);
1789         ctx.glUniformMatrix3fv(sampler_f, 1, GL_FALSE, &data[0]);
1790         ctx.expectError(GL_INVALID_OPERATION);
1791         ctx.glUniformMatrix4fv(sampler_f, 1, GL_FALSE, &data[0]);
1792         ctx.expectError(GL_INVALID_OPERATION);
1793
1794         ctx.glUniformMatrix2x3fv(sampler_f, 1, GL_FALSE, &data[0]);
1795         ctx.expectError(GL_INVALID_OPERATION);
1796         ctx.glUniformMatrix3x2fv(sampler_f, 1, GL_FALSE, &data[0]);
1797         ctx.expectError(GL_INVALID_OPERATION);
1798         ctx.glUniformMatrix2x4fv(sampler_f, 1, GL_FALSE, &data[0]);
1799         ctx.expectError(GL_INVALID_OPERATION);
1800         ctx.glUniformMatrix4x2fv(sampler_f, 1, GL_FALSE, &data[0]);
1801         ctx.expectError(GL_INVALID_OPERATION);
1802         ctx.glUniformMatrix3x4fv(sampler_f, 1, GL_FALSE, &data[0]);
1803         ctx.expectError(GL_INVALID_OPERATION);
1804         ctx.glUniformMatrix4x3fv(sampler_f, 1, GL_FALSE, &data[0]);
1805         ctx.expectError(GL_INVALID_OPERATION);
1806         ctx.endSection();
1807
1808         ctx.glUseProgram(0);
1809 }
1810
1811 void uniform_matrixfv_invalid_location (NegativeTestContext& ctx)
1812 {
1813         glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1814
1815         ctx.glUseProgram(program.getProgram());
1816         ctx.expectError(GL_NO_ERROR);
1817
1818         std::vector<GLfloat> data(16);
1819
1820         ctx.beginSection("GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1.");
1821         ctx.glUseProgram(program.getProgram());
1822         ctx.glUniformMatrix2fv(-2, 1, GL_FALSE, &data[0]);
1823         ctx.expectError(GL_INVALID_OPERATION);
1824         ctx.glUniformMatrix3fv(-2, 1, GL_FALSE, &data[0]);
1825         ctx.expectError(GL_INVALID_OPERATION);
1826         ctx.glUniformMatrix4fv(-2, 1, GL_FALSE, &data[0]);
1827         ctx.expectError(GL_INVALID_OPERATION);
1828
1829         ctx.glUniformMatrix2x3fv(-2, 1, GL_FALSE, &data[0]);
1830         ctx.expectError(GL_INVALID_OPERATION);
1831         ctx.glUniformMatrix3x2fv(-2, 1, GL_FALSE, &data[0]);
1832         ctx.expectError(GL_INVALID_OPERATION);
1833         ctx.glUniformMatrix2x4fv(-2, 1, GL_FALSE, &data[0]);
1834         ctx.expectError(GL_INVALID_OPERATION);
1835         ctx.glUniformMatrix4x2fv(-2, 1, GL_FALSE, &data[0]);
1836         ctx.expectError(GL_INVALID_OPERATION);
1837         ctx.glUniformMatrix3x4fv(-2, 1, GL_FALSE, &data[0]);
1838         ctx.expectError(GL_INVALID_OPERATION);
1839         ctx.glUniformMatrix4x3fv(-2, 1, GL_FALSE, &data[0]);
1840         ctx.expectError(GL_INVALID_OPERATION);
1841
1842         ctx.glUseProgram(program.getProgram());
1843         ctx.glUniformMatrix2fv(-1, 1, GL_FALSE, &data[0]);
1844         ctx.expectError(GL_NO_ERROR);
1845         ctx.glUniformMatrix3fv(-1, 1, GL_FALSE, &data[0]);
1846         ctx.expectError(GL_NO_ERROR);
1847         ctx.glUniformMatrix4fv(-1, 1, GL_FALSE, &data[0]);
1848         ctx.expectError(GL_NO_ERROR);
1849
1850         ctx.glUniformMatrix2x3fv(-1, 1, GL_FALSE, &data[0]);
1851         ctx.expectError(GL_NO_ERROR);
1852         ctx.glUniformMatrix3x2fv(-1, 1, GL_FALSE, &data[0]);
1853         ctx.expectError(GL_NO_ERROR);
1854         ctx.glUniformMatrix2x4fv(-1, 1, GL_FALSE, &data[0]);
1855         ctx.expectError(GL_NO_ERROR);
1856         ctx.glUniformMatrix4x2fv(-1, 1, GL_FALSE, &data[0]);
1857         ctx.expectError(GL_NO_ERROR);
1858         ctx.glUniformMatrix3x4fv(-1, 1, GL_FALSE, &data[0]);
1859         ctx.expectError(GL_NO_ERROR);
1860         ctx.glUniformMatrix4x3fv(-1, 1, GL_FALSE, &data[0]);
1861         ctx.expectError(GL_NO_ERROR);
1862         ctx.endSection();
1863
1864         ctx.glUseProgram(0);
1865 }
1866
1867 void uniform_matrixfv_invalid_count (NegativeTestContext& ctx)
1868 {
1869         glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1870
1871         ctx.glUseProgram                        (program.getProgram());
1872         GLint mat4_v                    = ctx.glGetUniformLocation(program.getProgram(), "mat4_v"); // mat4
1873         ctx.expectError(GL_NO_ERROR);
1874
1875         if (mat4_v == -1)
1876         {
1877                 ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1878                 ctx.fail("Failed to retrieve uniform location");
1879         }
1880
1881         std::vector<GLfloat> data(32);
1882
1883         ctx.beginSection("GL_INVALID_OPERATION is generated if count is greater than 1 and the indicated uniform variable is not an array variable.");
1884         ctx.glUseProgram(program.getProgram());
1885         ctx.glUniformMatrix2fv(mat4_v, 2, GL_FALSE, &data[0]);
1886         ctx.expectError(GL_INVALID_OPERATION);
1887         ctx.glUniformMatrix3fv(mat4_v, 2, GL_FALSE, &data[0]);
1888         ctx.expectError(GL_INVALID_OPERATION);
1889         ctx.glUniformMatrix4fv(mat4_v, 2, GL_FALSE, &data[0]);
1890         ctx.expectError(GL_INVALID_OPERATION);
1891
1892         ctx.glUniformMatrix2x3fv(mat4_v, 1, GL_FALSE, &data[0]);
1893         ctx.expectError(GL_INVALID_OPERATION);
1894         ctx.glUniformMatrix3x2fv(mat4_v, 1, GL_FALSE, &data[0]);
1895         ctx.expectError(GL_INVALID_OPERATION);
1896         ctx.glUniformMatrix2x4fv(mat4_v, 1, GL_FALSE, &data[0]);
1897         ctx.expectError(GL_INVALID_OPERATION);
1898         ctx.glUniformMatrix4x2fv(mat4_v, 1, GL_FALSE, &data[0]);
1899         ctx.expectError(GL_INVALID_OPERATION);
1900         ctx.glUniformMatrix3x4fv(mat4_v, 1, GL_FALSE, &data[0]);
1901         ctx.expectError(GL_INVALID_OPERATION);
1902         ctx.glUniformMatrix4x3fv(mat4_v, 1, GL_FALSE, &data[0]);
1903         ctx.expectError(GL_INVALID_OPERATION);
1904         ctx.endSection();
1905
1906         ctx.glUseProgram(0);
1907 }
1908
1909 // Transform feedback
1910 void gen_transform_feedbacks (NegativeTestContext& ctx)
1911 {
1912         ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
1913         GLuint id = 0;
1914         ctx.glGenTransformFeedbacks(-1, &id);
1915         ctx.expectError(GL_INVALID_VALUE);
1916         ctx.endSection();
1917 }
1918
1919 void bind_transform_feedback (NegativeTestContext& ctx)
1920 {
1921         GLuint                                          tfID[2];
1922         glu::ShaderProgram                      program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
1923         deUint32                                        buf = 0x1234;
1924         const char* tfVarying           = "gl_Position";
1925
1926         ctx.glGenBuffers                                (1, &buf);
1927         ctx.glGenTransformFeedbacks             (2, tfID);
1928
1929         ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_TRANSFORM_FEEDBACK.");
1930         ctx.glBindTransformFeedback(-1, tfID[0]);
1931         ctx.expectError(GL_INVALID_ENUM);
1932         ctx.endSection();
1933
1934         ctx.beginSection("GL_INVALID_OPERATION is generated if the transform feedback operation is active on the currently bound transform feedback object, and is not paused.");
1935         ctx.glUseProgram                                (program.getProgram());
1936         ctx.glTransformFeedbackVaryings (program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
1937         ctx.glLinkProgram                               (program.getProgram());
1938         ctx.glBindTransformFeedback             (GL_TRANSFORM_FEEDBACK, tfID[0]);
1939         ctx.glBindBuffer                                (GL_TRANSFORM_FEEDBACK_BUFFER, buf);
1940         ctx.glBufferData                                (GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
1941         ctx.glBindBufferBase                    (GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
1942         ctx.glBeginTransformFeedback    (GL_TRIANGLES);
1943         ctx.expectError                         (GL_NO_ERROR);
1944
1945         ctx.glBindTransformFeedback             (GL_TRANSFORM_FEEDBACK, tfID[1]);
1946         ctx.expectError                         (GL_INVALID_OPERATION);
1947
1948         ctx.glEndTransformFeedback              ();
1949         ctx.expectError                         (GL_NO_ERROR);
1950         ctx.endSection();
1951
1952         ctx.glUseProgram                                (0);
1953         ctx.glDeleteBuffers                             (1, &buf);
1954         ctx.glDeleteTransformFeedbacks  (2, tfID);
1955         ctx.expectError                         (GL_NO_ERROR);
1956
1957         ctx.beginSection("GL_INVALID_OPERATION is generated if id has been deleted with glDeleteTransformFeedback().");
1958         ctx.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, tfID[0]);
1959         ctx.expectError(GL_INVALID_OPERATION);
1960         ctx.endSection();
1961
1962         ctx.beginSection("GL_INVALID_OPERATION is generated if id is not 0 or a value returned from glGenTransformFeedbacks().");
1963         ctx.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, -1);
1964         ctx.expectError(GL_INVALID_OPERATION);
1965         ctx.endSection();
1966 }
1967
1968 void delete_transform_feedbacks (NegativeTestContext& ctx)
1969 {
1970         GLuint                          id                      = 0;
1971         GLuint                          tfID[2];
1972         deUint32                        buf                     = 0x1234;
1973         const char*                     tfVarying       = "gl_Position";
1974         glu::ShaderProgram      program         (ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
1975
1976         ctx.glGenBuffers(1, &buf);
1977         ctx.glGenTransformFeedbacks(1, &id);
1978         ctx.glGenTransformFeedbacks(2, tfID);
1979
1980         ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
1981         ctx.glDeleteTransformFeedbacks(-1, &id);
1982         ctx.expectError(GL_INVALID_VALUE);
1983         ctx.endSection();
1984
1985         ctx.beginSection("GL_INVALID_OPERATION is generated if the transform feedback operation for any object named by ids is currently active.");
1986         ctx.glUseProgram(program.getProgram());
1987         ctx.glTransformFeedbackVaryings(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
1988         ctx.glLinkProgram(program.getProgram());
1989         ctx.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, tfID[0]);
1990         ctx.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
1991         ctx.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
1992         ctx.glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
1993         ctx.glBeginTransformFeedback(GL_TRIANGLES);
1994         ctx.expectError(GL_NO_ERROR);
1995
1996         ctx.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, tfID[1]);
1997         ctx.expectError(GL_INVALID_OPERATION);
1998
1999         ctx.glDeleteTransformFeedbacks(2, tfID);
2000         ctx.expectError(GL_INVALID_OPERATION);
2001
2002         ctx.glEndTransformFeedback();
2003         ctx.expectError(GL_NO_ERROR);
2004         ctx.endSection();
2005
2006
2007         ctx.glDeleteTransformFeedbacks(1, &id);
2008         ctx.glDeleteTransformFeedbacks(2, tfID);
2009         ctx.glDeleteBuffers(1, &buf);
2010
2011 }
2012
2013 void begin_transform_feedback (NegativeTestContext& ctx)
2014 {
2015         GLuint                                          tfID[2];
2016         glu::ShaderProgram                      program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
2017         deUint32                                        buf = 0x1234;
2018         const char* tfVarying           = "gl_Position";
2019
2020         ctx.glGenBuffers                                (1, &buf);
2021         ctx.glGenTransformFeedbacks             (2, tfID);
2022
2023         ctx.glUseProgram                                (program.getProgram());
2024         ctx.glTransformFeedbackVaryings (program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
2025         ctx.glLinkProgram                               (program.getProgram());
2026         ctx.glBindTransformFeedback             (GL_TRANSFORM_FEEDBACK, tfID[0]);
2027         ctx.glBindBuffer                                (GL_TRANSFORM_FEEDBACK_BUFFER, buf);
2028         ctx.glBufferData                                (GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
2029         ctx.glBindBufferBase                    (GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
2030         ctx.expectError                                 (GL_NO_ERROR);
2031
2032         ctx.beginSection("GL_INVALID_ENUM is generated if primitiveMode is not one of GL_POINTS, GL_LINES, or GL_TRIANGLES.");
2033         ctx.glBeginTransformFeedback    (-1);
2034         ctx.expectError                                 (GL_INVALID_ENUM);
2035         ctx.endSection();
2036
2037         ctx.beginSection("GL_INVALID_OPERATION is generated if transform feedback is already active.");
2038         ctx.glBeginTransformFeedback    (GL_TRIANGLES);
2039         ctx.expectError                                 (GL_NO_ERROR);
2040         ctx.glBeginTransformFeedback    (GL_POINTS);
2041         ctx.expectError                                 (GL_INVALID_OPERATION);
2042         ctx.endSection();
2043
2044         ctx.beginSection("GL_INVALID_OPERATION is generated if any binding point used in transform feedback mode does not have a buffer object bound.");
2045         ctx.glBindBufferBase                    (GL_TRANSFORM_FEEDBACK_BUFFER, 0, 0);
2046         ctx.glBeginTransformFeedback    (GL_TRIANGLES);
2047         ctx.expectError                                 (GL_INVALID_OPERATION);
2048         ctx.glBindBufferBase                    (GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
2049         ctx.endSection();
2050
2051         ctx.beginSection("GL_INVALID_OPERATION is generated if no binding points would be used because no program object is active.");
2052         ctx.glUseProgram                                (0);
2053         ctx.glBeginTransformFeedback    (GL_TRIANGLES);
2054         ctx.expectError                                 (GL_INVALID_OPERATION);
2055         ctx.glUseProgram                                (program.getProgram());
2056         ctx.endSection();
2057
2058         ctx.beginSection("GL_INVALID_OPERATION is generated if no binding points would be used because the active program object has specified no varying variables to record.");
2059         ctx.glTransformFeedbackVaryings (program.getProgram(), 0, 0, GL_INTERLEAVED_ATTRIBS);
2060         ctx.glBeginTransformFeedback    (GL_TRIANGLES);
2061         ctx.expectError                                 (GL_INVALID_OPERATION);
2062         ctx.endSection();
2063
2064         ctx.glEndTransformFeedback              ();
2065         ctx.glDeleteBuffers                             (1, &buf);
2066         ctx.glDeleteTransformFeedbacks  (2, tfID);
2067         ctx.expectError                                 (GL_NO_ERROR);
2068 }
2069
2070 void pause_transform_feedback (NegativeTestContext& ctx)
2071 {
2072         GLuint                                          tfID[2];
2073         glu::ShaderProgram                      program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
2074         deUint32                                        buf = 0x1234;
2075         const char* tfVarying           = "gl_Position";
2076
2077         ctx.glGenBuffers                                (1, &buf);
2078         ctx.glGenTransformFeedbacks             (2, tfID);
2079
2080         ctx.glUseProgram                                (program.getProgram());
2081         ctx.glTransformFeedbackVaryings (program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
2082         ctx.glLinkProgram                               (program.getProgram());
2083         ctx.glBindTransformFeedback             (GL_TRANSFORM_FEEDBACK, tfID[0]);
2084         ctx.glBindBuffer                                (GL_TRANSFORM_FEEDBACK_BUFFER, buf);
2085         ctx.glBufferData                                (GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
2086         ctx.glBindBufferBase                    (GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
2087         ctx.expectError                                 (GL_NO_ERROR);
2088
2089         ctx.beginSection("GL_INVALID_OPERATION is generated if the currently bound transform feedback object is not active or is paused.");
2090         ctx.glPauseTransformFeedback    ();
2091         ctx.expectError                                 (GL_INVALID_OPERATION);
2092         ctx.glBeginTransformFeedback    (GL_TRIANGLES);
2093         ctx.glPauseTransformFeedback    ();
2094         ctx.expectError                                 (GL_NO_ERROR);
2095         ctx.glPauseTransformFeedback    ();
2096         ctx.expectError                                 (GL_INVALID_OPERATION);
2097         ctx.endSection();
2098
2099         ctx.glEndTransformFeedback              ();
2100         ctx.glDeleteBuffers                             (1, &buf);
2101         ctx.glDeleteTransformFeedbacks  (2, tfID);
2102         ctx.expectError                                 (GL_NO_ERROR);
2103 }
2104
2105 void resume_transform_feedback (NegativeTestContext& ctx)
2106 {
2107         GLuint                                          tfID[2];
2108         glu::ShaderProgram                      program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
2109         deUint32                                        buf = 0x1234;
2110         const char* tfVarying           = "gl_Position";
2111
2112         ctx.glGenBuffers                                (1, &buf);
2113         ctx.glGenTransformFeedbacks             (2, tfID);
2114
2115         ctx.glUseProgram                                (program.getProgram());
2116         ctx.glTransformFeedbackVaryings (program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
2117         ctx.glLinkProgram                               (program.getProgram());
2118         ctx.glBindTransformFeedback             (GL_TRANSFORM_FEEDBACK, tfID[0]);
2119         ctx.glBindBuffer                                (GL_TRANSFORM_FEEDBACK_BUFFER, buf);
2120         ctx.glBufferData                                (GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
2121         ctx.glBindBufferBase                    (GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
2122         ctx.expectError                                 (GL_NO_ERROR);
2123
2124         ctx.beginSection("GL_INVALID_OPERATION is generated if the currently bound transform feedback object is not active or is not paused.");
2125         ctx.glResumeTransformFeedback   ();
2126         ctx.expectError                                 (GL_INVALID_OPERATION);
2127         ctx.glBeginTransformFeedback    (GL_TRIANGLES);
2128         ctx.glResumeTransformFeedback   ();
2129         ctx.expectError                                 (GL_INVALID_OPERATION);
2130         ctx.glPauseTransformFeedback    ();
2131         ctx.glResumeTransformFeedback   ();
2132         ctx.expectError                                 (GL_NO_ERROR);
2133         ctx.endSection();
2134
2135         ctx.glEndTransformFeedback              ();
2136         ctx.glDeleteBuffers                             (1, &buf);
2137         ctx.glDeleteTransformFeedbacks  (2, tfID);
2138         ctx.expectError                                 (GL_NO_ERROR);
2139 }
2140
2141 void end_transform_feedback (NegativeTestContext& ctx)
2142 {
2143         GLuint                                          tfID = 0;
2144         glu::ShaderProgram                      program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
2145         deUint32                                        buf = 0x1234;
2146         const char* tfVarying           = "gl_Position";
2147
2148         ctx.glGenBuffers                                (1, &buf);
2149         ctx.glGenTransformFeedbacks             (1, &tfID);
2150
2151         ctx.glUseProgram                                (program.getProgram());
2152         ctx.glTransformFeedbackVaryings (program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
2153         ctx.glLinkProgram                               (program.getProgram());
2154         ctx.glBindTransformFeedback             (GL_TRANSFORM_FEEDBACK, tfID);
2155         ctx.glBindBuffer                                (GL_TRANSFORM_FEEDBACK_BUFFER, buf);
2156         ctx.glBufferData                                (GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
2157         ctx.glBindBufferBase                    (GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
2158         ctx.expectError                                 (GL_NO_ERROR);
2159
2160         ctx.beginSection("GL_INVALID_OPERATION is generated if transform feedback is not active.");
2161         ctx.glEndTransformFeedback              ();
2162         ctx.expectError                                 (GL_INVALID_OPERATION);
2163         ctx.glBeginTransformFeedback    (GL_TRIANGLES);
2164         ctx.glEndTransformFeedback              ();
2165         ctx.expectError                                 (GL_NO_ERROR);
2166         ctx.endSection();
2167
2168         ctx.glDeleteBuffers                             (1, &buf);
2169         ctx.glDeleteTransformFeedbacks  (1, &tfID);
2170         ctx.expectError                                 (GL_NO_ERROR);
2171 }
2172
2173 void get_transform_feedback_varying (NegativeTestContext& ctx)
2174 {
2175         GLuint                                  tfID = 0;
2176         glu::ShaderProgram              program                 (ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
2177         glu::ShaderProgram              programInvalid  (ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, ""));
2178         const char* tfVarying   = "gl_Position";
2179         int                                             maxTransformFeedbackVaryings = 0;
2180
2181         GLsizei                                 length;
2182         GLsizei                                 size;
2183         GLenum                                  type;
2184         char                                    name[32];
2185
2186         const GLuint notAProgram = ctx.glCreateProgram();
2187         ctx.glDeleteProgram(notAProgram);
2188
2189         ctx.glGenTransformFeedbacks                             (1, &tfID);
2190
2191         ctx.glTransformFeedbackVaryings                 (program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
2192         ctx.expectError                                         (GL_NO_ERROR);
2193         ctx.glLinkProgram                                               (program.getProgram());
2194         ctx.expectError                                         (GL_NO_ERROR);
2195
2196         ctx.glBindTransformFeedback                             (GL_TRANSFORM_FEEDBACK, tfID);
2197         ctx.expectError                                         (GL_NO_ERROR);
2198
2199         ctx.beginSection("GL_INVALID_VALUE is generated if program is not the name of a program object.");
2200         ctx.glGetTransformFeedbackVarying               (notAProgram, 0, 32, &length, &size, &type, &name[0]);
2201         ctx.expectError                                         (GL_INVALID_VALUE);
2202         ctx.endSection();
2203
2204         ctx.beginSection("GL_INVALID_VALUE is generated if index is greater or equal to the value of GL_TRANSFORM_FEEDBACK_VARYINGS.");
2205         ctx.glGetProgramiv                                              (program.getProgram(), GL_TRANSFORM_FEEDBACK_VARYINGS, &maxTransformFeedbackVaryings);
2206         ctx.glGetTransformFeedbackVarying               (program.getProgram(), maxTransformFeedbackVaryings, 32, &length, &size, &type, &name[0]);
2207         ctx.expectError                                         (GL_INVALID_VALUE);
2208         ctx.endSection();
2209
2210         ctx.beginSection("GL_INVALID_OPERATION or GL_INVALID_VALUE is generated program has not been linked.");
2211         ctx.glGetTransformFeedbackVarying               (programInvalid.getProgram(), 0, 32, &length, &size, &type, &name[0]);
2212         ctx.expectError                                         (GL_INVALID_OPERATION, GL_INVALID_VALUE);
2213         ctx.endSection();
2214
2215         ctx.glDeleteTransformFeedbacks                  (1, &tfID);
2216         ctx.expectError                                         (GL_NO_ERROR);
2217 }
2218
2219 void transform_feedback_varyings (NegativeTestContext& ctx)
2220 {
2221         GLuint                                                                          tfID = 0;
2222         GLuint shader                                                           = ctx.glCreateShader(GL_VERTEX_SHADER);
2223         glu::ShaderProgram program                                      (ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
2224         const char* tfVarying                                           = "gl_Position";
2225         GLint maxTransformFeedbackSeparateAttribs       = 0;
2226
2227         const GLuint notAProgram = ctx.glCreateProgram();
2228         ctx.glDeleteProgram(notAProgram);
2229
2230         ctx.glGenTransformFeedbacks                             (1, &tfID);
2231         ctx.expectError                                         (GL_NO_ERROR);
2232
2233         ctx.beginSection("GL_INVALID_VALUE is generated if program is not the name of a program object.");
2234         ctx.glTransformFeedbackVaryings                 (notAProgram, 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
2235         ctx.expectError                                         (GL_INVALID_VALUE);
2236         ctx.endSection();
2237
2238         ctx.beginSection("GL_INVALID_OPERATION is generated if program is the name of a shader object.");
2239         ctx.glTransformFeedbackVaryings(shader, 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
2240         ctx.expectError(GL_INVALID_OPERATION);
2241         ctx.glDeleteShader(shader);
2242         ctx.endSection();
2243
2244         ctx.beginSection("GL_INVALID_VALUE is generated if count is negative.");
2245         ctx.glTransformFeedbackVaryings(program.getProgram(), -1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
2246         ctx.expectError(GL_INVALID_VALUE);
2247         ctx.endSection();
2248
2249         ctx.beginSection("GL_INVALID_ENUM is generated if bufferMode is not SEPARATE_ATTRIBS or INTERLEAVED_ATTRIBS.");
2250         ctx.glTransformFeedbackVaryings(program.getProgram(), 1, &tfVarying, 0);
2251         ctx.expectError(GL_INVALID_ENUM);
2252         ctx.endSection();
2253
2254         ctx.beginSection("GL_INVALID_VALUE is generated if bufferMode is GL_SEPARATE_ATTRIBS and count is greater than GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS.");
2255         ctx.glGetIntegerv                                               (GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &maxTransformFeedbackSeparateAttribs);
2256         ctx.glTransformFeedbackVaryings                 (program.getProgram(), maxTransformFeedbackSeparateAttribs+1, &tfVarying, GL_SEPARATE_ATTRIBS);
2257         ctx.expectError                                         (GL_INVALID_VALUE);
2258         ctx.endSection();
2259
2260         ctx.glDeleteTransformFeedbacks                  (1, &tfID);
2261         ctx.expectError                                         (GL_NO_ERROR);
2262
2263 }
2264
2265 void link_compute_shader (NegativeTestContext& ctx)
2266 {
2267         const char* computeShaderSource         =       "#version 320 es\n"
2268                                                                                         "void main (void)\n"
2269                                                                                         "{\n"
2270                                                                                         "}\n\0";
2271         {
2272                 const GLenum shaderTypes[]                      =       {
2273                                                                                                         GL_VERTEX_SHADER,
2274                                                                                                         GL_FRAGMENT_SHADER,
2275                                                                                                         GL_GEOMETRY_SHADER,
2276                                                                                                         GL_TESS_CONTROL_SHADER,
2277                                                                                                         GL_TESS_EVALUATION_SHADER
2278                                                                                                 };
2279
2280                 ctx.beginSection("Compute Shader linked with shader of other kind.");
2281                 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(shaderTypes); ndx++)
2282                 {
2283                         GLint linkStatus                                =       -1;
2284                         GLuint program                                  =       ctx.glCreateProgram();
2285                         GLuint computeShader                    =       ctx.glCreateShader(GL_COMPUTE_SHADER);
2286                         GLuint otherShader                              =       ctx.glCreateShader(shaderTypes[ndx]);
2287                         const char* otherShaderSource   =       (shaderTypes[ndx] != GL_GEOMETRY_SHADER)        ?
2288                                                                                                 computeShaderSource                                                     :
2289                                                                                                 "#version 320 es\n"
2290                                                                                                 "layout(max_vertices = 3) out;\n"
2291                                                                                                 "void main(void){}\n\0";
2292
2293                         ctx.glShaderSource(computeShader, 1, &computeShaderSource, DE_NULL);
2294                         ctx.glShaderSource(otherShader, 1, &otherShaderSource, DE_NULL);
2295                         ctx.glCompileShader(computeShader);
2296                         ctx.glCompileShader(otherShader);
2297                         ctx.glAttachShader(program, computeShader);
2298                         ctx.glAttachShader(program, otherShader);
2299                         ctx.glLinkProgram(program);
2300                         ctx.glGetProgramiv(program, GL_LINK_STATUS, &linkStatus);
2301                         ctx.glDeleteShader(otherShader);
2302                         ctx.glDeleteShader(computeShader);
2303                         ctx.glDeleteProgram(program);
2304                         if (linkStatus != GL_FALSE)
2305                                 ctx.fail("Program should not have linked");
2306                 }
2307                 ctx.endSection();
2308         }
2309         {
2310                 const char* computeShaderSource310      =       "#version 310 es\n"
2311                                                                                                 "void main (void)\n"
2312                                                                                                 "{\n"
2313                                                                                                 "}\n\0";
2314                 GLint linkStatus                                        =       -1;
2315                 GLuint program                                          =       ctx.glCreateProgram();
2316                 GLuint computeShader                            =       ctx.glCreateShader(GL_COMPUTE_SHADER);
2317                 GLuint computeShader310                         =       ctx.glCreateShader(GL_FRAGMENT_SHADER);
2318
2319                 ctx.glShaderSource(computeShader, 1, &computeShaderSource, DE_NULL);
2320                 ctx.glShaderSource(computeShader310, 1, &computeShaderSource310, DE_NULL);
2321                 ctx.beginSection("Compute Shader should not be linked with shaders of different version.");
2322                 ctx.glCompileShader(computeShader);
2323                 ctx.glCompileShader(computeShader310);
2324                 ctx.glAttachShader(program, computeShader);
2325                 ctx.glAttachShader(program, computeShader310);
2326                 ctx.glLinkProgram(program);
2327                 ctx.glGetProgramiv(program, GL_LINK_STATUS, &linkStatus);
2328                 ctx.glDeleteShader(computeShader310);
2329                 ctx.glDeleteShader(computeShader);
2330                 ctx.glDeleteProgram(program);
2331                 if (linkStatus != GL_FALSE)
2332                         ctx.fail("Program should not have linked");
2333                 ctx.endSection();
2334         }
2335 }
2336
2337 void compile_compute_shader_helper (NegativeTestContext& ctx, const char* const* computeShaderSource, GLint* compileStatus)
2338 {
2339         GLuint shader = ctx.glCreateShader(GL_COMPUTE_SHADER);
2340
2341         *compileStatus = -1;
2342         ctx.glShaderSource(shader, 1, computeShaderSource, DE_NULL);
2343         ctx.glCompileShader(shader);
2344         ctx.glGetShaderiv(shader, GL_COMPILE_STATUS, compileStatus);
2345         ctx.glDeleteShader(shader);
2346 }
2347
2348 void compile_compute_shader (NegativeTestContext& ctx)
2349 {
2350         GLint compileStatus;
2351         ctx.beginSection("Compile Computer Shader");
2352
2353         {
2354                 const char* const computeShaderSource           =       "#version 300 es\n"
2355                                                                                                                 "void main (void)\n"
2356                                                                                                                 "{\n"
2357                                                                                                                 "}\n";
2358
2359                 compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2360                 if (compileStatus != GL_FALSE)
2361                         ctx.fail("Compute Shader should not have compiled with #version 300 es.");
2362         }
2363         {
2364                 const char* const computeShaderSource           =       "#version 310 es\n"
2365                                                                                                                 "buffer SSBO { vec4 data }"
2366                                                                                                                 "void main (void)\n"
2367                                                                                                                 "{\n"
2368                                                                                                                 "}\n";
2369
2370                 compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2371                 if (compileStatus != GL_FALSE)
2372                         ctx.fail("Compute Shader should not have compiled: incorrect SSBO syntax.");
2373         }
2374         {
2375                 const char* const computeShaderSource           =       "#version 310 es\n"
2376                                                                                                                 "buffer SSBO { vec4 data;};"
2377                                                                                                                 "uniform mat4 data;"
2378                                                                                                                 "void main (void)\n"
2379                                                                                                                 "{\n"
2380                                                                                                                 "}\n";
2381
2382                 compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2383                 if (compileStatus != GL_FALSE)
2384                         ctx.fail("Compute Shader should not have compiled: buffer variable redefinition.");
2385         }
2386         {
2387                 const char* const computeShaderSource           =       "#version 310 es\n"
2388                                                                                                                 "buffer SSBO { vec4 data[]; vec4 moreData;};"
2389                                                                                                                 "void main (void)\n"
2390                                                                                                                 "{\n"
2391                                                                                                                 "}\n";
2392
2393                 compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2394                 if (compileStatus != GL_FALSE)
2395                         ctx.fail("Compute Shader should not have compiled: unspecified length buffer member not at the end.");
2396         }
2397         {
2398                 const char* const computeShaderSource           =       "#version 310 es\n"
2399                                                                                                                 "in vec4 data;"
2400                                                                                                                 "void main (void)\n"
2401                                                                                                                 "{\n"
2402                                                                                                                 "}\n";
2403
2404                 compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2405                 if (compileStatus != GL_FALSE)
2406                         ctx.fail("Compute Shader should not have compiled: input qualifier used.");
2407         }
2408         {
2409                 const char* const computeShaderSource           =       "#version 310 es\n"
2410                                                                                                                 "shared uint data = 0;";
2411
2412                 compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2413                 if (compileStatus != GL_FALSE)
2414                         ctx.fail("Compute Shader should not have compiled: shared-qualified variable initialized.");
2415         }
2416         {
2417                 const char* const computeShaderSource           =       "#version 310 es\n"
2418                                                                                                                 "buffer SSBO { vec4 data; vec4 moreData[];} ssbo;"
2419                                                                                                                 "void test (vec4 data[10]) {}"
2420                                                                                                                 "void main (void)\n"
2421                                                                                                                 "{\n"
2422                                                                                                                 "    test(ssbo.moreData);"
2423                                                                                                                 "}\n";
2424
2425                 compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2426                 if (compileStatus != GL_FALSE)
2427                         ctx.fail("Compute Shader should not have compiled: unspecified length buffer member passed as argument to function.");
2428         }
2429         {
2430                 const char* const computeShaderSource           =       "#version 310 es\n"
2431                                                                                                                 "buffer SSBO { vec4 data; vec4 moreData[];} ssbo;"
2432                                                                                                                 "void main (void)\n"
2433                                                                                                                 "{\n"
2434                                                                                                                 "    vec4 var = ssbo.moreData[-1];"
2435                                                                                                                 "}\n";
2436
2437                 compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2438                 if (compileStatus != GL_FALSE)
2439                         ctx.fail("Compute Shader should not have compiled: unspecified length buffer member indexed with negative constant expression.");
2440         }
2441         {
2442                 const char* const computeShaderSource           =       "#version 310 es\n"
2443                                                                                                                 "layout(binding=-1) buffer SSBO { vec4 data;};"
2444                                                                                                                 "void main (void)\n"
2445                                                                                                                 "{\n"
2446                                                                                                                 "}\n";
2447
2448                 compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2449                 if (compileStatus != GL_FALSE)
2450                         ctx.fail("Compute Shader should not have compiled: binding point less than zero.");
2451         }
2452         {
2453                 const char* const computeShaderSource           =       "#version 310 es\n"
2454                                                                                                                 "layout(binding=1) buffer;"
2455                                                                                                                 "layout(binding=2) buffer SSBO { vec4 data;};"
2456                                                                                                                 "void main (void)\n"
2457                                                                                                                 "{\n"
2458                                                                                                                 "}\n";
2459
2460                 compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2461                 if (compileStatus != GL_FALSE)
2462                         ctx.fail("Compute Shader should not have compiled: binding point specified for global scope.");
2463         }
2464         {
2465                 const char* const computeShaderSource           =       "#version 310 es\n"
2466                                                                                                                 "buffer SSBO {"
2467                                                                                                                 "       layout(binding=1) vec4 data;"
2468                                                                                                                 "       layout(binding=2) vec4 moreData[];"
2469                                                                                                                 "} ssbo;"
2470                                                                                                                 "void main (void)\n"
2471                                                                                                                 "{\n"
2472                                                                                                                 "}\n";
2473
2474                 compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2475                 if (compileStatus != GL_FALSE)
2476                         ctx.fail("Compute Shader should not have compiled: binding point specified for block member declarations.");
2477         }
2478         {
2479                 const char* const computeShaderSource           =       "#version 310 es\n"
2480                                                                                                                 "readonly buffer SSBO {vec4 data;} ssbo;"
2481                                                                                                                 "void main (void)\n"
2482                                                                                                                 "{\n"
2483                                                                                                                         "ssbo.data = vec4(1, 1, 1, 1);"
2484                                                                                                                 "}\n";
2485
2486                 compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2487                 if (compileStatus != GL_FALSE)
2488                         ctx.fail("Compute Shader should not have compiled: writing to buffer block qualified with readonly.");
2489         }
2490         {
2491                 const char* const computeShaderSource           =       "#version 310 es\n"
2492                                                                                                                 "writeonly buffer SSBO {vec4 data;} ssbo;"
2493                                                                                                                 "void main (void)\n"
2494                                                                                                                 "{\n"
2495                                                                                                                         "vec4 var = ssbo.data;"
2496                                                                                                                 "}\n";
2497
2498                 compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2499                 if (compileStatus != GL_FALSE)
2500                         ctx.fail("Compute Shader should not have compiled: reading from buffer block qualified with writeonly.");
2501         }
2502
2503         ctx.endSection();
2504 }
2505
2506 void srgb_decode_samplerparameteri (NegativeTestContext& ctx)
2507 {
2508         if (!ctx.isExtensionSupported("GL_EXT_texture_sRGB_decode"))
2509                 TCU_THROW(NotSupportedError, "GL_EXT_texture_sRGB_decode is not supported.");
2510
2511         GLuint  sampler         = 0x1234;
2512         GLint   samplerMode     = -1;
2513
2514         ctx.glGenSamplers(1, &sampler);
2515
2516         ctx.beginSection("GL_INVALID_ENUM is generated if pname is GL_TEXTURE_SRGB_DECODE_EXT and the value of param(s) is not a valid value (one of DECODE_EXT, or SKIP_DECODE_EXT).");
2517         ctx.glSamplerParameteri(sampler, GL_TEXTURE_SRGB_DECODE_EXT, samplerMode);
2518         ctx.expectError(GL_INVALID_ENUM);
2519         ctx.endSection();
2520
2521         ctx.glDeleteSamplers(1, &sampler);
2522 }
2523
2524 void srgb_decode_samplerparameterf (NegativeTestContext& ctx)
2525 {
2526         if (!ctx.isExtensionSupported("GL_EXT_texture_sRGB_decode"))
2527                 TCU_THROW(NotSupportedError, "GL_EXT_texture_sRGB_decode is not supported.");
2528
2529         GLuint  sampler = 0x1234;
2530         GLfloat samplerMode     = -1.0f;
2531
2532         ctx.glGenSamplers(1, &sampler);
2533
2534         ctx.beginSection("GL_INVALID_ENUM is generated if pname is GL_TEXTURE_SRGB_DECODE_EXT and the value of param(s) is not a valid value (one of DECODE_EXT, or SKIP_DECODE_EXT).");
2535         ctx.glSamplerParameterf(sampler, GL_TEXTURE_SRGB_DECODE_EXT, samplerMode);
2536         ctx.expectError(GL_INVALID_ENUM);
2537         ctx.endSection();
2538
2539         ctx.glDeleteSamplers(1, &sampler);
2540 }
2541
2542 void srgb_decode_samplerparameteriv (NegativeTestContext& ctx)
2543 {
2544         if (!ctx.isExtensionSupported("GL_EXT_texture_sRGB_decode"))
2545                 TCU_THROW(NotSupportedError, "GL_EXT_texture_sRGB_decode is not supported.");
2546
2547         int             params[1]       = { GL_LINEAR };
2548         GLuint  sampler         = 0x1234;
2549
2550         ctx.glGenSamplers(1, &sampler);
2551
2552         ctx.beginSection("GL_INVALID_ENUM is generated if pname is GL_TEXTURE_SRGB_DECODE_EXT and the value of param(s) is not a valid value (one of DECODE_EXT, or SKIP_DECODE_EXT).");
2553         params[0] = -1;
2554         ctx.glSamplerParameteriv(sampler, GL_TEXTURE_SRGB_DECODE_EXT, &params[0]);
2555         ctx.expectError(GL_INVALID_ENUM);
2556         ctx.endSection();
2557
2558         ctx.glDeleteSamplers(1, &sampler);
2559 }
2560
2561 void srgb_decode_samplerparameterfv (NegativeTestContext& ctx)
2562 {
2563         if (!ctx.isExtensionSupported("GL_EXT_texture_sRGB_decode"))
2564                 TCU_THROW(NotSupportedError, "GL_EXT_texture_sRGB_decode is not supported.");
2565
2566         float   params[1]       = { GL_LINEAR };
2567         GLuint  sampler         = 0x1234;
2568
2569         ctx.glGenSamplers(1, &sampler);
2570
2571         params[0] = -1.0f;
2572         ctx.beginSection("GL_INVALID_ENUM is generated if pname is GL_TEXTURE_SRGB_DECODE_EXT and the value of param(s) is not a valid value (one of DECODE_EXT, or SKIP_DECODE_EXT).");
2573         ctx.glSamplerParameterfv(sampler, GL_TEXTURE_SRGB_DECODE_EXT, &params[0]);
2574         ctx.expectError(GL_INVALID_ENUM);
2575         ctx.endSection();
2576
2577         ctx.glDeleteSamplers(1, &sampler);
2578 }
2579
2580 void srgb_decode_samplerparameterIiv (NegativeTestContext& ctx)
2581 {
2582         if (!contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
2583                 TCU_THROW(NotSupportedError, "glSamplerParameterIiv is not supported.");
2584
2585         if (!ctx.isExtensionSupported("GL_EXT_texture_sRGB_decode"))
2586                 TCU_THROW(NotSupportedError, "GL_EXT_texture_sRGB_decode is not supported.");
2587
2588         GLint   samplerMode[]   = {GL_DEPTH_COMPONENT, GL_STENCIL_INDEX};
2589         GLuint  sampler                 = 0x1234;
2590
2591         ctx.glGenSamplers(1, &sampler);
2592
2593         ctx.beginSection("GL_INVALID_ENUM is generated if pname is GL_TEXTURE_SRGB_DECODE_EXT and the value of param(s) is not a valid value (one of DECODE_EXT, or SKIP_DECODE_EXT).");
2594         samplerMode[0] = -1;
2595         samplerMode[1] = -1;
2596         ctx.glSamplerParameterIiv(sampler, GL_TEXTURE_SRGB_DECODE_EXT, samplerMode);
2597         ctx.expectError(GL_INVALID_ENUM);
2598         ctx.endSection();
2599
2600         ctx.glDeleteSamplers(1, &sampler);
2601 }
2602
2603 void srgb_decode_samplerparameterIuiv (NegativeTestContext& ctx)
2604 {
2605         if (!contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
2606                 TCU_THROW(NotSupportedError, "glSamplerParameterIuiv is not supported.");
2607
2608         if (!ctx.isExtensionSupported("GL_EXT_texture_sRGB_decode"))
2609                 TCU_THROW(NotSupportedError, "GL_EXT_texture_sRGB_decode is not supported.");
2610
2611         GLuint  samplerMode[]   = {GL_DEPTH_COMPONENT, GL_STENCIL_INDEX};
2612         GLuint  sampler                 = 0x1234;
2613
2614         ctx.glGenSamplers(1, &sampler);
2615
2616         ctx.beginSection("GL_INVALID_ENUM is generated if pname is GL_TEXTURE_SRGB_DECODE_EXT and the value of param(s) is not a valid value (one of DECODE_EXT, or SKIP_DECODE_EXT).");
2617         samplerMode[0] = GL_DONT_CARE;
2618         samplerMode[1] = GL_DONT_CARE;
2619         ctx.glSamplerParameterIuiv(sampler, GL_TEXTURE_SRGB_DECODE_EXT, samplerMode);
2620         ctx.expectError(GL_INVALID_ENUM);
2621         ctx.endSection();
2622
2623         ctx.glDeleteSamplers(1, &sampler);
2624 }
2625
2626 std::vector<FunctionContainer> getNegativeShaderApiTestFunctions ()
2627 {
2628         FunctionContainer funcs[] =
2629         {
2630                 {create_shader,                                                 "create_shader",                                                "Invalid glCreateShader() usage"                           },
2631                 {shader_source,                                                 "shader_source",                                                "Invalid glShaderSource() usage"                           },
2632                 {compile_shader,                                                "compile_shader",                                               "Invalid glCompileShader() usage"                          },
2633                 {delete_shader,                                                 "delete_shader",                                                "Invalid glDeleteShader() usage"                           },
2634                 {shader_binary,                                                 "shader_binary",                                                "Invalid glShaderBinary() usage"                           },
2635                 {attach_shader,                                                 "attach_shader",                                                "Invalid glAttachShader() usage"                           },
2636                 {detach_shader,                                                 "detach_shader",                                                "Invalid glDetachShader() usage"                           },
2637                 {link_program,                                                  "link_program",                                                 "Invalid glLinkProgram() usage"                            },
2638                 {use_program,                                                   "use_program",                                                  "Invalid glUseProgram() usage"                             },
2639                 {delete_program,                                                "delete_program",                                               "Invalid glDeleteProgram() usage"                          },
2640                 {validate_program,                                              "validate_program",                                             "Invalid glValidateProgram() usage"                        },
2641                 {get_program_binary,                                    "get_program_binary",                                   "Invalid glGetProgramBinary() usage"               },
2642                 {program_binary,                                                "program_binary",                                               "Invalid glProgramBinary() usage"                          },
2643                 {program_parameteri,                                    "program_parameteri",                                   "Invalid glProgramParameteri() usage"              },
2644                 {gen_samplers,                                                  "gen_samplers",                                                 "Invalid glGenSamplers() usage"                            },
2645                 {bind_sampler,                                                  "bind_sampler",                                                 "Invalid glBindSampler() usage"                            },
2646                 {delete_samplers,                                               "delete_samplers",                                              "Invalid glDeleteSamplers() usage"                         },
2647                 {get_sampler_parameteriv,                               "get_sampler_parameteriv",                              "Invalid glGetSamplerParameteriv() usage"          },
2648                 {get_sampler_parameterfv,                               "get_sampler_parameterfv",                              "Invalid glGetSamplerParameterfv() usage"          },
2649                 {get_sampler_parameterIiv,                              "get_sampler_parameterIiv",                             "Invalid glGetSamplerParameterIiv() usage"         },
2650                 {get_sampler_parameterIuiv,                             "get_sampler_parameterIuiv",                    "Invalid glGetSamplerParameterIuiv() usage"        },
2651                 {sampler_parameteri,                                    "sampler_parameteri",                                   "Invalid glSamplerParameteri() usage"              },
2652                 {sampler_parameteriv,                                   "sampler_parameteriv",                                  "Invalid glSamplerParameteriv() usage"             },
2653                 {sampler_parameterf,                                    "sampler_parameterf",                                   "Invalid glSamplerParameterf() usage"              },
2654                 {sampler_parameterfv,                                   "sampler_parameterfv",                                  "Invalid glSamplerParameterfv() usage"             },
2655                 {sampler_parameterIiv,                                  "sampler_parameterIiv",                                 "Invalid glSamplerParameterIiv() usage"            },
2656                 {sampler_parameterIuiv,                                 "sampler_parameterIuiv",                                "Invalid glSamplerParameterIuiv() usage"           },
2657                 {get_attrib_location,                                   "get_attrib_location",                                  "Invalid glGetAttribLocation() usage"              },
2658                 {get_uniform_location,                                  "get_uniform_location",                                 "Invalid glGetUniformLocation() usage"             },
2659                 {bind_attrib_location,                                  "bind_attrib_location",                                 "Invalid glBindAttribLocation() usage"             },
2660                 {uniform_block_binding,                                 "uniform_block_binding",                                "Invalid glUniformBlockBinding() usage"            },
2661                 {uniformf_invalid_program,                              "uniformf_invalid_program",                             "Invalid glUniform{1234}f() usage"                         },
2662                 {uniformf_incompatible_type,                    "uniformf_incompatible_type",                   "Invalid glUniform{1234}f() usage"                         },
2663                 {uniformf_invalid_location,                             "uniformf_invalid_location",                    "Invalid glUniform{1234}f() usage"                         },
2664                 {uniformfv_invalid_program,                             "uniformfv_invalid_program",                    "Invalid glUniform{1234}fv() usage"                        },
2665                 {uniformfv_incompatible_type,                   "uniformfv_incompatible_type",                  "Invalid glUniform{1234}fv() usage"                        },
2666                 {uniformfv_invalid_location,                    "uniformfv_invalid_location",                   "Invalid glUniform{1234}fv() usage"                        },
2667                 {uniformfv_invalid_count,                               "uniformfv_invalid_count",                              "Invalid glUniform{1234}fv() usage"                        },
2668                 {uniformi_invalid_program,                              "uniformi_invalid_program",                             "Invalid glUniform{1234}i() usage"                         },
2669                 {uniformi_incompatible_type,                    "uniformi_incompatible_type",                   "Invalid glUniform{1234}i() usage"                         },
2670                 {uniformi_invalid_location,                             "uniformi_invalid_location",                    "Invalid glUniform{1234}i() usage"                         },
2671                 {uniformiv_invalid_program,                             "uniformiv_invalid_program",                    "Invalid glUniform{1234}iv() usage"                        },
2672                 {uniformiv_incompatible_type,                   "uniformiv_incompatible_type",                  "Invalid glUniform{1234}iv() usage"                        },
2673                 {uniformiv_invalid_location,                    "uniformiv_invalid_location",                   "Invalid glUniform{1234}iv() usage"                        },
2674                 {uniformiv_invalid_count,                               "uniformiv_invalid_count",                              "Invalid glUniform{1234}iv() usage"                        },
2675                 {uniformui_invalid_program,                             "uniformui_invalid_program",                    "Invalid glUniform{234}ui() usage"                         },
2676                 {uniformui_incompatible_type,                   "uniformui_incompatible_type",                  "Invalid glUniform{1234}ui() usage"                        },
2677                 {uniformui_invalid_location,                    "uniformui_invalid_location",                   "Invalid glUniform{1234}ui() usage"                        },
2678                 {uniformuiv_invalid_program,                    "uniformuiv_invalid_program",                   "Invalid glUniform{234}uiv() usage"                        },
2679                 {uniformuiv_incompatible_type,                  "uniformuiv_incompatible_type",                 "Invalid glUniform{1234}uiv() usage"               },
2680                 {uniformuiv_invalid_location,                   "uniformuiv_invalid_location",                  "Invalid glUniform{1234}uiv() usage"               },
2681                 {uniformuiv_invalid_count,                              "uniformuiv_invalid_count",                             "Invalid glUniform{1234}uiv() usage"               },
2682                 {uniform_matrixfv_invalid_program,              "uniform_matrixfv_invalid_program",             "Invalid glUniformMatrix{234}fv() usage"           },
2683                 {uniform_matrixfv_incompatible_type,    "uniform_matrixfv_incompatible_type",   "Invalid glUniformMatrix{234}fv() usage"           },
2684                 {uniform_matrixfv_invalid_location,             "uniform_matrixfv_invalid_location",    "Invalid glUniformMatrix{234}fv() usage"           },
2685                 {uniform_matrixfv_invalid_count,                "uniform_matrixfv_invalid_count",               "Invalid glUniformMatrix{234}fv() usage"           },
2686                 {gen_transform_feedbacks,                               "gen_transform_feedbacks",                              "Invalid glGenTransformFeedbacks() usage"          },
2687                 {bind_transform_feedback,                               "bind_transform_feedback",                              "Invalid glBindTransformFeedback() usage"          },
2688                 {delete_transform_feedbacks,                    "delete_transform_feedbacks",                   "Invalid glDeleteTransformFeedbacks() usage"   },
2689                 {begin_transform_feedback,                              "begin_transform_feedback",                             "Invalid glBeginTransformFeedback() usage"         },
2690                 {pause_transform_feedback,                              "pause_transform_feedback",                             "Invalid glPauseTransformFeedback() usage"         },
2691                 {resume_transform_feedback,                             "resume_transform_feedback",                    "Invalid glResumeTransformFeedback() usage"        },
2692                 {end_transform_feedback,                                "end_transform_feedback",                               "Invalid glEndTransformFeedback() usage"           },
2693                 {get_transform_feedback_varying,                "get_transform_feedback_varying",               "Invalid glGetTransformFeedbackVarying() usage"},
2694                 {transform_feedback_varyings,                   "transform_feedback_varyings",                  "Invalid glTransformFeedbackVaryings() usage"  },
2695                 {compile_compute_shader,                                "compile_compute_shader",                               "Invalid Compute Shader compilation"               },
2696                 {link_compute_shader,                                   "link_compute_shader",                                  "Invalid Compute Shader linkage"                           },
2697                 {srgb_decode_samplerparameteri,                 "srgb_decode_samplerparameteri",                "Invalid glSamplerParameteri() usage srgb"         },
2698                 {srgb_decode_samplerparameterf,                 "srgb_decode_samplerparameterf",                "Invalid glSamplerParameterf() usage srgb"         },
2699                 {srgb_decode_samplerparameteriv,                "srgb_decode_samplerparameteriv",               "Invalid glSamplerParameteriv() usage srgb"        },
2700                 {srgb_decode_samplerparameterfv,                "srgb_decode_samplerparameterfv",               "Invalid glSamplerParameterfv() usage srgb"        },
2701                 {srgb_decode_samplerparameterIiv,               "srgb_decode_samplerparameterIiv",              "Invalid glSamplerParameterIiv() usage srgb"   },
2702                 {srgb_decode_samplerparameterIuiv,              "srgb_decode_samplerparameterIuiv",             "Invalid glSamplerParameterIiuv() usage srgb"  },
2703         };
2704
2705         return std::vector<FunctionContainer>(DE_ARRAY_BEGIN(funcs), DE_ARRAY_END(funcs));
2706 }
2707
2708 } // NegativeTestShared
2709 } // Functional
2710 } // gles31
2711 } // deqp