1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 3.1 Module
3 * -------------------------------------------------
5 * Copyright 2014 The Android Open Source Project
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 * \brief Negative Shader API tests.
22 *//*--------------------------------------------------------------------*/
24 #include "es31fNegativeShaderApiTests.hpp"
26 #include "deUniquePtr.hpp"
28 #include "glwDefs.hpp"
29 #include "glwEnums.hpp"
31 #include "gluShaderProgram.hpp"
32 #include "gluCallLogWrapper.hpp"
34 #include "gluContextInfo.hpp"
35 #include "gluRenderContext.hpp"
44 namespace NegativeTestShared
47 using glu::CallLogWrapper;
50 static const char* vertexShaderSource = "#version 300 es\n"
53 " gl_Position = vec4(0.0);\n"
56 static const char* fragmentShaderSource = "#version 300 es\n"
57 "layout(location = 0) out mediump vec4 fragColor;"
60 " fragColor = vec4(0.0);\n"
63 static const char* uniformTestVertSource = "#version 300 es\n"
64 "uniform mediump vec4 vec4_v;\n"
65 "uniform mediump mat4 mat4_v;\n"
68 " gl_Position = mat4_v * vec4_v;\n"
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;"
78 " fragColor.xy = (vec4(uvec4_f) + vec4(ivec4_f)).xy;\n"
79 " fragColor.zw = texture(sampler_f, vec2(0.0, 0.0)).zw;\n"
82 static const char* uniformBlockVertSource = "#version 300 es\n"
83 "layout(shared) uniform Block { lowp float var; };\n"
86 " gl_Position = vec4(var);\n"
89 static bool supportsES32orGL45(NegativeTestContext& ctx)
91 return contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) ||
92 contextSupports(ctx.getRenderContext().getType(), glu::ApiType::core(4, 5));
95 // Shader control commands
96 void create_shader (NegativeTestContext& ctx)
98 ctx.beginSection("GL_INVALID_ENUM is generated if shaderType is not an accepted value.");
99 ctx.glCreateShader(-1);
100 ctx.expectError(GL_INVALID_ENUM);
104 void shader_source (NegativeTestContext& ctx)
106 // make notAShader not a shader id
107 const GLuint notAShader = ctx.glCreateShader(GL_VERTEX_SHADER);
108 ctx.glDeleteShader(notAShader);
110 ctx.beginSection("GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
111 ctx.glShaderSource(notAShader, 0, 0, 0);
112 ctx.expectError(GL_INVALID_VALUE);
115 ctx.beginSection("GL_INVALID_VALUE is generated if count is less than 0.");
116 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
117 ctx.glShaderSource(shader, -1, 0, 0);
118 ctx.expectError(GL_INVALID_VALUE);
121 ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not a shader object.");
122 GLuint program = ctx.glCreateProgram();
123 ctx.glShaderSource(program, 0, 0, 0);
124 ctx.expectError(GL_INVALID_OPERATION);
127 ctx.glDeleteProgram(program);
128 ctx.glDeleteShader(shader);
131 void compile_shader (NegativeTestContext& ctx)
133 const GLuint notAShader = ctx.glCreateShader(GL_VERTEX_SHADER);
134 ctx.glDeleteShader(notAShader);
136 ctx.beginSection("GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
137 ctx.glCompileShader(notAShader);
138 ctx.expectError(GL_INVALID_VALUE);
141 ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not a shader object.");
142 GLuint program = ctx.glCreateProgram();
143 ctx.glCompileShader(program);
144 ctx.expectError(GL_INVALID_OPERATION);
147 ctx.glDeleteProgram(program);
150 void delete_shader (NegativeTestContext& ctx)
152 const GLuint notAShader = ctx.glCreateShader(GL_VERTEX_SHADER);
153 ctx.glDeleteShader(notAShader);
155 ctx.beginSection("GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
156 ctx.glDeleteShader(notAShader);
157 ctx.expectError(GL_INVALID_VALUE);
161 void shader_binary (NegativeTestContext& ctx)
163 std::vector<deInt32> binaryFormats;
164 deBool shaderBinarySupported = !binaryFormats.empty();
166 GLuint shaderPair[2];
167 GLuint nonProgram[2];
168 GLuint shaderProgram[2];
171 deInt32 numFormats = 0x1234;
172 ctx.glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &numFormats);
175 ctx.getLog() << TestLog::Message << "// No supported extensions available." << TestLog::EndMessage;
178 binaryFormats.resize(numFormats);
179 ctx.glGetIntegerv(GL_SHADER_BINARY_FORMATS, &binaryFormats[0]);
183 if (!shaderBinarySupported)
184 ctx.getLog() << TestLog::Message << "// Shader binaries not supported." << TestLog::EndMessage;
186 ctx.getLog() << TestLog::Message << "// Shader binaries supported" << TestLog::EndMessage;
188 shaders[0] = ctx.glCreateShader(GL_VERTEX_SHADER);
189 shaders[1] = ctx.glCreateShader(GL_VERTEX_SHADER);
190 shaderPair[0] = ctx.glCreateShader(GL_VERTEX_SHADER);
191 shaderPair[1] = ctx.glCreateShader(GL_FRAGMENT_SHADER);
194 shaderProgram[0] = ctx.glCreateShader(GL_VERTEX_SHADER);
195 shaderProgram[1] = ctx.glCreateProgram();
197 ctx.beginSection("GL_INVALID_ENUM is generated if binaryFormat is not an accepted value.");
198 ctx.glShaderBinary(1, &shaders[0], -1, 0, 0);
199 ctx.expectError(GL_INVALID_ENUM);
202 if (shaderBinarySupported)
204 ctx.beginSection("GL_INVALID_VALUE is generated if the data pointed to by binary does not match the format specified by binaryFormat.");
205 const GLbyte data = 0x005F;
206 ctx.glShaderBinary(1, &shaders[0], binaryFormats[0], &data, 1);
207 ctx.expectError(GL_INVALID_VALUE);
210 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.");
211 ctx.glShaderBinary(2, &shaders[0], binaryFormats[0], 0, 0);
212 ctx.expectError(GL_INVALID_OPERATION, GL_INVALID_VALUE);
215 ctx.beginSection("GL_INVALID_VALUE is generated if count or length is negative.");
216 ctx.glShaderBinary(2, &shaderPair[0], binaryFormats[0], 0, -1);
217 ctx.expectError(GL_INVALID_VALUE);
218 ctx.glShaderBinary(-1, &shaderPair[0], binaryFormats[0], 0, 0);
219 ctx.expectError(GL_INVALID_VALUE);
222 ctx.beginSection("GL_INVALID_VALUE is generated if shaders contains anything other than shader or program objects.");
223 ctx.glShaderBinary(2, &nonProgram[0], binaryFormats[0], 0, 0);
224 ctx.expectError(GL_INVALID_VALUE);
227 ctx.beginSection("GL_INVALID_OPERATION is generated if shaders refers to a program object.");
228 ctx.glShaderBinary(2, &shaderProgram[0], binaryFormats[0], 0, 0);
229 ctx.expectError(GL_INVALID_OPERATION);
233 ctx.glDeleteShader(shaders[0]);
234 ctx.glDeleteShader(shaders[1]);
237 void attach_shader (NegativeTestContext& ctx)
239 GLuint shader1 = ctx.glCreateShader(GL_VERTEX_SHADER);
240 GLuint shader2 = ctx.glCreateShader(GL_VERTEX_SHADER);
241 GLuint program = ctx.glCreateProgram();
243 const GLuint notAShader = ctx.glCreateShader(GL_VERTEX_SHADER);
244 const GLuint notAProgram = ctx.glCreateProgram();
246 ctx.glDeleteShader(notAShader);
247 ctx.glDeleteProgram(notAProgram);
249 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
250 ctx.glAttachShader(shader1, shader1);
251 ctx.expectError(GL_INVALID_OPERATION);
254 ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not a shader object.");
255 ctx.glAttachShader(program, program);
256 ctx.expectError(GL_INVALID_OPERATION);
257 ctx.glAttachShader(shader1, program);
258 ctx.expectError(GL_INVALID_OPERATION);
261 ctx.beginSection("GL_INVALID_VALUE is generated if either program or shader is not a value generated by OpenGL.");
262 ctx.glAttachShader(program, notAShader);
263 ctx.expectError(GL_INVALID_VALUE);
264 ctx.glAttachShader(notAProgram, shader1);
265 ctx.expectError(GL_INVALID_VALUE);
266 ctx.glAttachShader(notAProgram, notAShader);
267 ctx.expectError(GL_INVALID_VALUE);
270 ctx.beginSection("GL_INVALID_OPERATION is generated if shader is already attached to program.");
271 ctx.glAttachShader(program, shader1);
272 ctx.expectError(GL_NO_ERROR);
273 ctx.glAttachShader(program, shader1);
274 ctx.expectError(GL_INVALID_OPERATION);
277 if (glu::isContextTypeES(ctx.getRenderContext().getType()))
279 ctx.beginSection("GL_INVALID_OPERATION is generated if a shader of the same type as shader is already attached to program.");
280 ctx.glAttachShader(program, shader2);
281 ctx.expectError(GL_INVALID_OPERATION);
285 ctx.glDeleteProgram(program);
286 ctx.glDeleteShader(shader1);
287 ctx.glDeleteShader(shader2);
290 void detach_shader (NegativeTestContext& ctx)
292 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
293 GLuint program = ctx.glCreateProgram();
295 const GLuint notAShader = ctx.glCreateShader(GL_VERTEX_SHADER);
296 const GLuint notAProgram = ctx.glCreateProgram();
298 ctx.glDeleteShader(notAShader);
299 ctx.glDeleteProgram(notAProgram);
301 ctx.beginSection("GL_INVALID_VALUE is generated if either program or shader is not a value generated by OpenGL.");
302 ctx.glDetachShader(notAProgram, shader);
303 ctx.expectError(GL_INVALID_VALUE);
304 ctx.glDetachShader(program, notAShader);
305 ctx.expectError(GL_INVALID_VALUE);
306 ctx.glDetachShader(notAProgram, notAShader);
307 ctx.expectError(GL_INVALID_VALUE);
310 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
311 ctx.glDetachShader(shader, shader);
312 ctx.expectError(GL_INVALID_OPERATION);
315 ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not a shader object.");
316 ctx.glDetachShader(program, program);
317 ctx.expectError(GL_INVALID_OPERATION);
318 ctx.glDetachShader(shader, program);
319 ctx.expectError(GL_INVALID_OPERATION);
322 ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not attached to program.");
323 ctx.glDetachShader(program, shader);
324 ctx.expectError(GL_INVALID_OPERATION);
327 ctx.glDeleteProgram(program);
328 ctx.glDeleteShader(shader);
331 void link_program (NegativeTestContext& ctx)
333 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
335 const GLuint notAProgram = ctx.glCreateProgram();
336 ctx.glDeleteProgram(notAProgram);
338 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
339 ctx.glLinkProgram(notAProgram);
340 ctx.expectError(GL_INVALID_VALUE);
343 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
344 ctx.glLinkProgram(shader);
345 ctx.expectError(GL_INVALID_OPERATION);
348 ctx.glDeleteShader(shader);
350 ctx.beginSection("GL_INVALID_OPERATION is generated if program is the currently active program object and transform feedback mode is active.");
351 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
352 deUint32 buf = 0x1234;
353 deUint32 tfID = 0x1234;
354 const char* tfVarying = "gl_Position";
356 ctx.glGenTransformFeedbacks (1, &tfID);
357 ctx.glGenBuffers (1, &buf);
359 ctx.glUseProgram (program.getProgram());
360 ctx.glTransformFeedbackVaryings (program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
361 ctx.glLinkProgram (program.getProgram());
362 ctx.glBindTransformFeedback (GL_TRANSFORM_FEEDBACK, tfID);
363 ctx.glBindBuffer (GL_TRANSFORM_FEEDBACK_BUFFER, buf);
364 ctx.glBufferData (GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
365 ctx.glBindBufferBase (GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
366 ctx.glBeginTransformFeedback (GL_TRIANGLES);
367 ctx.expectError (GL_NO_ERROR);
369 ctx.glLinkProgram (program.getProgram());
370 ctx.expectError (GL_INVALID_OPERATION);
372 ctx.glEndTransformFeedback ();
373 ctx.glDeleteTransformFeedbacks (1, &tfID);
374 ctx.glDeleteBuffers (1, &buf);
375 ctx.expectError (GL_NO_ERROR);
379 void use_program (NegativeTestContext& ctx)
381 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
383 const GLuint notAProgram = ctx.glCreateProgram();
384 ctx.glDeleteProgram(notAProgram);
386 ctx.beginSection("GL_INVALID_VALUE is generated if program is neither 0 nor a value generated by OpenGL.");
387 ctx.glUseProgram(notAProgram);
388 ctx.expectError(GL_INVALID_VALUE);
391 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
392 ctx.glUseProgram(shader);
393 ctx.expectError(GL_INVALID_OPERATION);
396 ctx.beginSection("GL_INVALID_OPERATION is generated if transform feedback mode is active and not paused.");
397 glu::ShaderProgram program1(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
398 glu::ShaderProgram program2(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
399 deUint32 buf = 0x1234;
400 deUint32 tfID = 0x1234;
401 const char* tfVarying = "gl_Position";
403 ctx.glGenTransformFeedbacks (1, &tfID);
404 ctx.glGenBuffers (1, &buf);
406 ctx.glUseProgram (program1.getProgram());
407 ctx.glTransformFeedbackVaryings (program1.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
408 ctx.glLinkProgram (program1.getProgram());
409 ctx.glBindTransformFeedback (GL_TRANSFORM_FEEDBACK, tfID);
410 ctx.glBindBuffer (GL_TRANSFORM_FEEDBACK_BUFFER, buf);
411 ctx.glBufferData (GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
412 ctx.glBindBufferBase (GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
413 ctx.glBeginTransformFeedback (GL_TRIANGLES);
414 ctx.expectError (GL_NO_ERROR);
416 ctx.glUseProgram (program2.getProgram());
417 ctx.expectError (GL_INVALID_OPERATION);
419 ctx.glPauseTransformFeedback ();
420 ctx.glUseProgram (program2.getProgram());
421 ctx.expectError (GL_NO_ERROR);
423 ctx.glEndTransformFeedback ();
424 ctx.glDeleteTransformFeedbacks (1, &tfID);
425 ctx.glDeleteBuffers (1, &buf);
426 ctx.expectError (GL_NO_ERROR);
430 ctx.glDeleteShader(shader);
433 void delete_program (NegativeTestContext& ctx)
435 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
437 const GLuint notAProgram = ctx.glCreateProgram();
438 ctx.glDeleteProgram(notAProgram);
440 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
441 ctx.glDeleteProgram(notAProgram);
442 ctx.expectError(GL_INVALID_VALUE);
445 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not zero and is the name of a shader object.");
446 ctx.glDeleteProgram(shader);
447 ctx.expectError(GL_INVALID_OPERATION);
450 ctx.glDeleteShader(shader);
453 void validate_program (NegativeTestContext& ctx)
455 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
457 const GLuint notAProgram = ctx.glCreateProgram();
458 ctx.glDeleteProgram(notAProgram);
460 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
461 ctx.glValidateProgram(notAProgram);
462 ctx.expectError(GL_INVALID_VALUE);
465 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
466 ctx.glValidateProgram(shader);
467 ctx.expectError(GL_INVALID_OPERATION);
470 ctx.glDeleteShader(shader);
473 void get_program_binary (NegativeTestContext& ctx)
475 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
476 glu::ShaderProgram programInvalid (ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, ""));
477 GLenum binaryFormat = -1;
478 GLsizei binaryLength = -1;
479 GLint binaryPtr = -1;
481 GLint linkStatus = -1;
483 ctx.beginSection("GL_INVALID_OPERATION is generated if bufSize is less than the size of GL_PROGRAM_BINARY_LENGTH for program.");
484 ctx.glGetProgramiv (program.getProgram(), GL_PROGRAM_BINARY_LENGTH, &bufSize);
485 ctx.expectError (GL_NO_ERROR);
486 ctx.glGetProgramiv (program.getProgram(), GL_LINK_STATUS, &linkStatus);
487 ctx.getLog() << TestLog::Message << "// GL_PROGRAM_BINARY_LENGTH = " << bufSize << TestLog::EndMessage;
488 ctx.getLog() << TestLog::Message << "// GL_LINK_STATUS = " << linkStatus << TestLog::EndMessage;
489 ctx.expectError (GL_NO_ERROR);
491 ctx.glGetProgramBinary (program.getProgram(), 0, &binaryLength, &binaryFormat, &binaryPtr);
492 ctx.expectError (GL_INVALID_OPERATION);
495 ctx.glGetProgramBinary (program.getProgram(), bufSize-1, &binaryLength, &binaryFormat, &binaryPtr);
496 ctx.expectError (GL_INVALID_OPERATION);
500 ctx.beginSection("GL_INVALID_OPERATION is generated if GL_LINK_STATUS for the program object is false.");
501 ctx.glGetProgramiv (programInvalid.getProgram(), GL_PROGRAM_BINARY_LENGTH, &bufSize);
502 ctx.expectError (GL_NO_ERROR);
503 ctx.glGetProgramiv (programInvalid.getProgram(), GL_LINK_STATUS, &linkStatus);
504 ctx.getLog() << TestLog::Message << "// GL_PROGRAM_BINARY_LENGTH = " << bufSize << TestLog::EndMessage;
505 ctx.getLog() << TestLog::Message << "// GL_LINK_STATUS = " << linkStatus << TestLog::EndMessage;
506 ctx.expectError (GL_NO_ERROR);
510 ctx.glGetProgramBinary (programInvalid.getProgram(), bufSize, &binaryLength, &binaryFormat, &binaryPtr);
511 ctx.expectError (GL_INVALID_OPERATION);
516 if (isContextTypeES(ctx.getRenderContext().getType()))
517 ctx.fail("Program should not have linked");
521 void program_binary (NegativeTestContext& ctx)
523 glu::ShaderProgram srcProgram (ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
524 GLuint dstProgram = ctx.glCreateProgram();
525 GLuint unusedShader = ctx.glCreateShader(GL_VERTEX_SHADER);
526 GLenum binaryFormat = -1;
527 GLsizei binaryLength = -1;
528 std::vector<deUint8> binaryBuf;
530 GLint linkStatus = -1;
532 ctx.glGetProgramiv (srcProgram.getProgram(), GL_PROGRAM_BINARY_LENGTH, &bufSize);
533 ctx.glGetProgramiv (srcProgram.getProgram(), GL_LINK_STATUS, &linkStatus);
534 ctx.getLog() << TestLog::Message << "// GL_PROGRAM_BINARY_LENGTH = " << bufSize << TestLog::EndMessage;
535 ctx.getLog() << TestLog::Message << "// GL_LINK_STATUS = " << linkStatus << TestLog::EndMessage;
537 TCU_CHECK(bufSize >= 0);
540 binaryBuf.resize(bufSize);
541 ctx.glGetProgramBinary (srcProgram.getProgram(), bufSize, &binaryLength, &binaryFormat, &binaryBuf[0]);
542 ctx.expectError (GL_NO_ERROR);
544 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not the name of an existing program object.");
545 ctx.glProgramBinary (unusedShader, binaryFormat, &binaryBuf[0], binaryLength);
546 ctx.expectError (GL_INVALID_OPERATION);
549 ctx.beginSection("GL_INVALID_ENUM is generated if binaryFormat is not a value recognized by the implementation.");
550 ctx.glProgramBinary (dstProgram, -1, &binaryBuf[0], binaryLength);
551 ctx.expectError (GL_INVALID_ENUM);
555 ctx.glDeleteShader(unusedShader);
556 ctx.glDeleteProgram(dstProgram);
559 void program_parameteri (NegativeTestContext& ctx)
561 GLuint program = ctx.glCreateProgram();
562 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
564 const GLuint notAProgram = ctx.glCreateProgram();
565 ctx.glDeleteProgram(notAProgram);
567 ctx.beginSection("GL_INVALID_VALUE is generated if program is not the name of an existing program object.");
568 ctx.glProgramParameteri(notAProgram, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE);
569 ctx.expectError(GL_INVALID_VALUE);
572 ctx.beginSection("GL_INVALID_OPERATION is generated if program is the name of a shader object.");
573 ctx.glProgramParameteri(shader, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE);
574 ctx.expectError(GL_INVALID_OPERATION);
577 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not GL_PROGRAM_BINARY_RETRIEVABLE_HINT or PROGRAM_SEPARABLE.");
578 ctx.glProgramParameteri(program, -1, GL_TRUE);
579 ctx.expectError(GL_INVALID_ENUM);
582 ctx.beginSection("GL_INVALID_VALUE is generated if value is not GL_FALSE or GL_TRUE.");
583 ctx.glProgramParameteri(program, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, 2);
584 ctx.expectError(GL_INVALID_VALUE);
587 ctx.glDeleteProgram(program);
588 ctx.glDeleteShader(shader);
591 void gen_samplers (NegativeTestContext& ctx)
593 ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
595 ctx.glGenSamplers (-1, &sampler);
596 ctx.expectError (GL_INVALID_VALUE);
600 void bind_sampler (NegativeTestContext& ctx)
602 int maxTexImageUnits = 0x1234;
604 ctx.glGetIntegerv (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxTexImageUnits);
605 ctx.glGenSamplers (1, &sampler);
607 ctx.beginSection("GL_INVALID_VALUE is generated if unit is greater than or equal to the value of GL_MAX_COMBIED_TEXTURE_IMAGE_UNITS.");
608 ctx.glBindSampler (maxTexImageUnits, sampler);
609 ctx.expectError (GL_INVALID_VALUE);
612 ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not zero or a name previously returned from a call to ctx.glGenSamplers.");
613 ctx.glBindSampler (1, -1);
614 ctx.expectError (GL_INVALID_OPERATION);
617 ctx.beginSection("GL_INVALID_OPERATION is generated if sampler has been deleted by a call to ctx.glDeleteSamplers.");
618 ctx.glDeleteSamplers(1, &sampler);
619 ctx.glBindSampler (1, sampler);
620 ctx.expectError (GL_INVALID_OPERATION);
624 void delete_samplers (NegativeTestContext& ctx)
626 ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
627 ctx.glDeleteSamplers(-1, 0);
628 ctx.expectError (GL_INVALID_VALUE);
632 void get_sampler_parameteriv (NegativeTestContext& ctx)
636 ctx.glGenSamplers (1, &sampler);
638 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.");
639 ctx.glGetSamplerParameteriv (-1, GL_TEXTURE_MAG_FILTER, ¶ms);
640 ctx.expectError (GL_INVALID_OPERATION);
643 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
644 ctx.glGetSamplerParameteriv (sampler, -1, ¶ms);
645 ctx.expectError (GL_INVALID_ENUM);
648 ctx.glDeleteSamplers(1, &sampler);
651 void get_sampler_parameterfv (NegativeTestContext& ctx)
655 ctx.glGenSamplers (1, &sampler);
657 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.");
658 ctx.glGetSamplerParameterfv (-1, GL_TEXTURE_MAG_FILTER, ¶ms);
659 ctx.expectError (GL_INVALID_OPERATION);
662 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
663 ctx.glGetSamplerParameterfv (sampler, -1, ¶ms);
664 ctx.expectError (GL_INVALID_ENUM);
667 ctx.glDeleteSamplers(1, &sampler);
670 void get_sampler_parameterIiv (NegativeTestContext& ctx)
672 if (!supportsES32orGL45(ctx))
673 throw tcu::NotSupportedError("glGetSamplerParameterIiv is not supported.", DE_NULL, __FILE__, __LINE__);
675 GLuint sampler = 0x1234;
676 GLint borderColor[] = { 0x1234, 0x4123, 0x3412, 0x2341 };
678 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.");
679 ctx.glGetSamplerParameterIiv(sampler, GL_TEXTURE_BORDER_COLOR, &borderColor[0]);
680 ctx.expectError(GL_INVALID_OPERATION);
683 ctx.glGenSamplers(1, &sampler);
685 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
686 ctx.glGetSamplerParameterIiv(sampler, -1, &borderColor[0]);
687 ctx.expectError(GL_INVALID_ENUM);
690 ctx.glDeleteSamplers(1, &sampler);
693 void get_sampler_parameterIuiv (NegativeTestContext& ctx)
695 if (!supportsES32orGL45(ctx))
696 throw tcu::NotSupportedError("glGetSamplerParameterIuiv is not supported.", DE_NULL, __FILE__, __LINE__);
698 GLuint sampler = 0x1234;
699 GLuint borderColor[] = { 0x1234, 0x4123, 0x3412, 0x2341 };
701 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.");
702 ctx.glGetSamplerParameterIuiv(sampler, GL_TEXTURE_BORDER_COLOR, &borderColor[0]);
703 ctx.expectError(GL_INVALID_OPERATION);
706 ctx.glGenSamplers(1, &sampler);
708 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
709 ctx.glGetSamplerParameterIuiv(sampler, -1, &borderColor[0]);
710 ctx.expectError(GL_INVALID_ENUM);
713 ctx.glDeleteSamplers(1, &sampler);
716 void sampler_parameteri (NegativeTestContext& ctx)
720 ctx.glGenSamplers(1, &sampler);
722 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.");
723 ctx.glSamplerParameteri(-1, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
724 ctx.expectError(GL_INVALID_OPERATION);
727 ctx.beginSection("GL_INVALID_ENUM is generated if params should have a defined constant value (based on the value of pname) and does not.");
728 ctx.glSamplerParameteri(sampler, GL_TEXTURE_WRAP_S, -1);
729 ctx.expectError(GL_INVALID_ENUM);
732 if (supportsES32orGL45(ctx))
734 ctx.beginSection("GL_INVALID_ENUM is generated if glSamplerParameteri is called for a non-scalar parameter.");
735 ctx.glSamplerParameteri(sampler, GL_TEXTURE_BORDER_COLOR, 0);
736 ctx.expectError(GL_INVALID_ENUM);
740 ctx.glDeleteSamplers(1, &sampler);
743 void sampler_parameteriv (NegativeTestContext& ctx)
747 ctx.glGenSamplers (1, &sampler);
749 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.");
750 params = GL_CLAMP_TO_EDGE;
751 ctx.glSamplerParameteriv (-1, GL_TEXTURE_WRAP_S, ¶ms);
752 ctx.expectError (GL_INVALID_OPERATION);
755 ctx.beginSection("GL_INVALID_ENUM is generated if params should have a defined constant value (based on the value of pname) and does not.");
757 ctx.glSamplerParameteriv (sampler, GL_TEXTURE_WRAP_S, ¶ms);
758 ctx.expectError (GL_INVALID_ENUM);
761 ctx.glDeleteSamplers(1, &sampler);
764 void sampler_parameterf (NegativeTestContext& ctx)
768 ctx.glGenSamplers(1, &sampler);
770 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.");
771 ctx.glSamplerParameterf(-1, GL_TEXTURE_MIN_LOD, -1000.0f);
772 ctx.expectError(GL_INVALID_OPERATION);
775 ctx.beginSection("GL_INVALID_ENUM is generated if params should have a defined constant value (based on the value of pname) and does not.");
776 ctx.glSamplerParameterf(sampler, GL_TEXTURE_WRAP_S, -1.0f);
777 ctx.expectError(GL_INVALID_ENUM);
780 if (supportsES32orGL45(ctx))
782 ctx.beginSection("GL_INVALID_ENUM is generated if glSamplerParameterf is called for a non-scalar parameter.");
783 ctx.glSamplerParameteri(sampler, GL_TEXTURE_BORDER_COLOR, 0);
784 ctx.expectError(GL_INVALID_ENUM);
788 ctx.glDeleteSamplers(1, &sampler);
791 void sampler_parameterfv (NegativeTestContext& ctx)
795 ctx.glGenSamplers (1, &sampler);
797 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.");
799 ctx.glSamplerParameterfv (-1, GL_TEXTURE_WRAP_S, ¶ms);
800 ctx.expectError (GL_INVALID_OPERATION);
803 ctx.beginSection("GL_INVALID_ENUM is generated if params should have a defined constant value (based on the value of pname) and does not.");
805 ctx.glSamplerParameterfv (sampler, GL_TEXTURE_WRAP_S, ¶ms);
806 ctx.expectError (GL_INVALID_ENUM);
809 ctx.glDeleteSamplers(1, &sampler);
812 void sampler_parameterIiv (NegativeTestContext& ctx)
814 if (!supportsES32orGL45(ctx))
815 throw tcu::NotSupportedError("glSamplerParameterIiv is not supported.", DE_NULL, __FILE__, __LINE__);
818 GLint color[] = {0, 0, 0, 0};
820 ctx.glGenSamplers(1, &sampler);
822 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.");
823 ctx.glSamplerParameterIiv(-1, GL_TEXTURE_BORDER_COLOR, color);
824 ctx.expectError(GL_INVALID_OPERATION);
827 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted sampler state name.");
828 ctx.glSamplerParameterIiv(sampler, -1, color);
829 ctx.expectError(GL_INVALID_ENUM);
833 void sampler_parameterIuiv (NegativeTestContext& ctx)
835 if (!supportsES32orGL45(ctx))
836 throw tcu::NotSupportedError("glSamplerParameterIuiv is not supported.", DE_NULL, __FILE__, __LINE__);
839 GLuint color[] = {0, 0, 0, 0};
841 ctx.glGenSamplers(1, &sampler);
843 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.");
844 ctx.glSamplerParameterIuiv(-1, GL_TEXTURE_BORDER_COLOR, color);
845 ctx.expectError(GL_INVALID_OPERATION);
848 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted sampler state name.");
849 ctx.glSamplerParameterIuiv(sampler, -1, color);
850 ctx.expectError(GL_INVALID_ENUM);
854 // Shader data commands
856 void get_attrib_location (NegativeTestContext& ctx)
858 GLuint programEmpty = ctx.glCreateProgram();
859 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
861 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
863 const GLuint notAProgram = ctx.glCreateProgram();
864 ctx.glDeleteProgram(notAProgram);
866 ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been successfully linked.");
867 ctx.glBindAttribLocation (programEmpty, 0, "test");
868 ctx.glGetAttribLocation (programEmpty, "test");
869 ctx.expectError (GL_INVALID_OPERATION);
872 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a program or shader object.");
873 ctx.glUseProgram (program.getProgram());
874 ctx.glBindAttribLocation (program.getProgram(), 0, "test");
875 ctx.expectError (GL_NO_ERROR);
876 ctx.glGetAttribLocation (program.getProgram(), "test");
877 ctx.expectError (GL_NO_ERROR);
878 ctx.glGetAttribLocation (notAProgram, "test");
879 ctx.expectError (GL_INVALID_VALUE);
882 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
883 ctx.glGetAttribLocation (shader, "test");
884 ctx.expectError (GL_INVALID_OPERATION);
887 ctx.glUseProgram (0);
888 ctx.glDeleteShader (shader);
889 ctx.glDeleteProgram (programEmpty);
892 void get_uniform_location (NegativeTestContext& ctx)
894 GLuint programEmpty = ctx.glCreateProgram();
895 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
897 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
899 const GLuint notAProgram = ctx.glCreateProgram();
900 ctx.glDeleteProgram(notAProgram);
902 ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been successfully linked.");
903 ctx.glGetUniformLocation(programEmpty, "test");
904 ctx.expectError(GL_INVALID_OPERATION);
907 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
908 ctx.glUseProgram(program.getProgram());
909 ctx.glGetUniformLocation(notAProgram, "test");
910 ctx.expectError(GL_INVALID_VALUE);
913 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
914 ctx.glGetAttribLocation(shader, "test");
915 ctx.expectError(GL_INVALID_OPERATION);
919 ctx.glDeleteProgram(programEmpty);
920 ctx.glDeleteShader(shader);
923 void bind_attrib_location (NegativeTestContext& ctx)
925 GLuint program = ctx.glCreateProgram();
926 GLuint maxIndex = ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
927 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
929 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
930 ctx.glBindAttribLocation(program, maxIndex, "test");
931 ctx.expectError(GL_INVALID_VALUE);
934 ctx.beginSection("GL_INVALID_OPERATION is generated if name starts with the reserved prefix \"gl_\".");
935 ctx.glBindAttribLocation(program, maxIndex-1, "gl_test");
936 ctx.expectError(GL_INVALID_OPERATION);
939 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
940 ctx.glBindAttribLocation(-1, maxIndex-1, "test");
941 ctx.expectError(GL_INVALID_VALUE);
944 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
945 ctx.glBindAttribLocation(shader, maxIndex-1, "test");
946 ctx.expectError(GL_INVALID_OPERATION);
949 ctx.glDeleteProgram(program);
950 ctx.glDeleteShader(shader);
953 void uniform_block_binding (NegativeTestContext& ctx)
955 GLint maxUniformBufferBindings = -1;
956 GLint numActiveUniforms = -1;
957 GLint numActiveBlocks = -1;
959 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformBlockVertSource, uniformTestFragSource));
961 shader = ctx.glCreateShader(GL_VERTEX_SHADER);
962 ctx.glUseProgram(program.getProgram());
964 ctx.glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUniformBufferBindings);
965 ctx.glGetProgramiv(program.getProgram(), GL_ACTIVE_UNIFORMS, &numActiveUniforms);
966 ctx.glGetProgramiv(program.getProgram(), GL_ACTIVE_UNIFORM_BLOCKS, &numActiveBlocks);
967 ctx.getLog() << TestLog::Message << "// GL_MAX_UNIFORM_BUFFER_BINDINGS = " << maxUniformBufferBindings << TestLog::EndMessage;
968 ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORMS = " << numActiveUniforms << TestLog::EndMessage;
969 ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORM_BLOCKS = " << numActiveBlocks << TestLog::EndMessage;
970 ctx.expectError (GL_NO_ERROR);
972 ctx.beginSection("GL_INVALID_VALUE is generated if uniformBlockIndex is not an active uniform block index of program.");
973 ctx.glUniformBlockBinding(program.getProgram(), -1, 0);
974 ctx.expectError(GL_INVALID_VALUE);
975 ctx.glUniformBlockBinding(program.getProgram(), 5, 0);
976 ctx.expectError(GL_INVALID_VALUE);
979 ctx.beginSection("GL_INVALID_VALUE is generated if uniformBlockBinding is greater than or equal to the value of GL_MAX_UNIFORM_BUFFER_BINDINGS.");
980 ctx.glUniformBlockBinding(program.getProgram(), maxUniformBufferBindings, 0);
981 ctx.expectError(GL_INVALID_VALUE);
984 ctx.beginSection("GL_INVALID_VALUE is generated if program is not the name of a program object generated by the GL.");
985 ctx.glUniformBlockBinding(-1, 0, 0);
986 ctx.expectError(GL_INVALID_VALUE);
989 ctx.beginSection("GL_INVALID_OPERATION is generated if program is the name of a shader object.");
990 ctx.glUniformBlockBinding(shader, 0, 0);
991 ctx.expectError(GL_INVALID_OPERATION);
994 ctx.glDeleteShader(shader);
999 void uniformf_invalid_program (NegativeTestContext& ctx)
1001 ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object.");
1002 ctx.glUseProgram(0);
1003 ctx.glUniform1f(-1, 0.0f);
1004 ctx.expectError(GL_INVALID_OPERATION);
1005 ctx.glUniform2f(-1, 0.0f, 0.0f);
1006 ctx.expectError(GL_INVALID_OPERATION);
1007 ctx.glUniform3f(-1, 0.0f, 0.0f, 0.0f);
1008 ctx.expectError(GL_INVALID_OPERATION);
1009 ctx.glUniform4f(-1, 0.0f, 0.0f, 0.0f, 0.0f);
1010 ctx.expectError(GL_INVALID_OPERATION);
1014 void uniformf_incompatible_type (NegativeTestContext& ctx)
1016 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1018 ctx.glUseProgram(program.getProgram());
1019 GLint vec4_v = ctx.glGetUniformLocation(program.getProgram(), "vec4_v"); // vec4
1020 GLint ivec4_f = ctx.glGetUniformLocation(program.getProgram(), "ivec4_f"); // ivec4
1021 GLint uvec4_f = ctx.glGetUniformLocation(program.getProgram(), "uvec4_f"); // uvec4
1022 GLint sampler_f = ctx.glGetUniformLocation(program.getProgram(), "sampler_f"); // sampler2D
1023 ctx.expectError(GL_NO_ERROR);
1025 if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1)
1027 ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1028 ctx.fail("Failed to retrieve uniform location");
1031 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.");
1032 ctx.glUseProgram(program.getProgram());
1033 ctx.glUniform1f(vec4_v, 0.0f);
1034 ctx.expectError(GL_INVALID_OPERATION);
1035 ctx.glUniform2f(vec4_v, 0.0f, 0.0f);
1036 ctx.expectError(GL_INVALID_OPERATION);
1037 ctx.glUniform3f(vec4_v, 0.0f, 0.0f, 0.0f);
1038 ctx.expectError(GL_INVALID_OPERATION);
1039 ctx.glUniform4f(vec4_v, 0.0f, 0.0f, 0.0f, 0.0f);
1040 ctx.expectError(GL_NO_ERROR);
1043 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.");
1044 ctx.glUseProgram(program.getProgram());
1045 ctx.glUniform4f(ivec4_f, 0.0f, 0.0f, 0.0f, 0.0f);
1046 ctx.expectError(GL_INVALID_OPERATION);
1047 ctx.glUniform4f(uvec4_f, 0.0f, 0.0f, 0.0f, 0.0f);
1048 ctx.expectError(GL_INVALID_OPERATION);
1051 ctx.beginSection("GL_INVALID_OPERATION is generated if a sampler is loaded using a command other than ctx.glUniform1i and ctx.glUniform1iv.");
1052 ctx.glUseProgram(program.getProgram());
1053 ctx.glUniform1f(sampler_f, 0.0f);
1054 ctx.expectError(GL_INVALID_OPERATION);
1057 ctx.glUseProgram(0);
1060 void uniformf_invalid_location (NegativeTestContext& ctx)
1062 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1064 ctx.glUseProgram(program.getProgram());
1065 ctx.expectError(GL_NO_ERROR);
1067 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.");
1068 ctx.glUseProgram(program.getProgram());
1069 ctx.glUniform1f(-2, 0.0f);
1070 ctx.expectError(GL_INVALID_OPERATION);
1071 ctx.glUniform2f(-2, 0.0f, 0.0f);
1072 ctx.expectError(GL_INVALID_OPERATION);
1073 ctx.glUniform3f(-2, 0.0f, 0.0f, 0.0f);
1074 ctx.expectError(GL_INVALID_OPERATION);
1075 ctx.glUniform4f(-2, 0.0f, 0.0f, 0.0f, 0.0f);
1076 ctx.expectError(GL_INVALID_OPERATION);
1078 ctx.glUseProgram(program.getProgram());
1079 ctx.glUniform1f(-1, 0.0f);
1080 ctx.expectError(GL_NO_ERROR);
1081 ctx.glUniform2f(-1, 0.0f, 0.0f);
1082 ctx.expectError(GL_NO_ERROR);
1083 ctx.glUniform3f(-1, 0.0f, 0.0f, 0.0f);
1084 ctx.expectError(GL_NO_ERROR);
1085 ctx.glUniform4f(-1, 0.0f, 0.0f, 0.0f, 0.0f);
1086 ctx.expectError(GL_NO_ERROR);
1089 ctx.glUseProgram(0);
1094 void uniformfv_invalid_program (NegativeTestContext& ctx)
1096 std::vector<GLfloat> data(4);
1098 ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object.");
1099 ctx.glUseProgram(0);
1100 ctx.glUniform1fv(-1, 1, &data[0]);
1101 ctx.expectError(GL_INVALID_OPERATION);
1102 ctx.glUniform2fv(-1, 1, &data[0]);
1103 ctx.expectError(GL_INVALID_OPERATION);
1104 ctx.glUniform3fv(-1, 1, &data[0]);
1105 ctx.expectError(GL_INVALID_OPERATION);
1106 ctx.glUniform4fv(-1, 1, &data[0]);
1107 ctx.expectError(GL_INVALID_OPERATION);
1111 void uniformfv_incompatible_type (NegativeTestContext& ctx)
1113 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1115 ctx.glUseProgram(program.getProgram());
1116 GLint vec4_v = ctx.glGetUniformLocation(program.getProgram(), "vec4_v"); // vec4
1117 GLint ivec4_f = ctx.glGetUniformLocation(program.getProgram(), "ivec4_f"); // ivec4
1118 GLint uvec4_f = ctx.glGetUniformLocation(program.getProgram(), "uvec4_f"); // uvec4
1119 GLint sampler_f = ctx.glGetUniformLocation(program.getProgram(), "sampler_f"); // sampler2D
1120 ctx.expectError(GL_NO_ERROR);
1122 if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1)
1124 ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1125 ctx.fail("Failed to retrieve uniform location");
1128 std::vector<GLfloat> data(4);
1130 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.");
1131 ctx.glUseProgram(program.getProgram());
1132 ctx.glUniform1fv(vec4_v, 1, &data[0]);
1133 ctx.expectError(GL_INVALID_OPERATION);
1134 ctx.glUniform2fv(vec4_v, 1, &data[0]);
1135 ctx.expectError(GL_INVALID_OPERATION);
1136 ctx.glUniform3fv(vec4_v, 1, &data[0]);
1137 ctx.expectError(GL_INVALID_OPERATION);
1138 ctx.glUniform4fv(vec4_v, 1, &data[0]);
1139 ctx.expectError(GL_NO_ERROR);
1142 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.");
1143 ctx.glUseProgram(program.getProgram());
1144 ctx.glUniform4fv(ivec4_f, 1, &data[0]);
1145 ctx.expectError(GL_INVALID_OPERATION);
1146 ctx.glUniform4fv(uvec4_f, 1, &data[0]);
1147 ctx.expectError(GL_INVALID_OPERATION);
1150 ctx.beginSection("GL_INVALID_OPERATION is generated if a sampler is loaded using a command other than ctx.glUniform1i and ctx.glUniform1iv.");
1151 ctx.glUseProgram(program.getProgram());
1152 ctx.glUniform1fv(sampler_f, 1, &data[0]);
1153 ctx.expectError(GL_INVALID_OPERATION);
1156 ctx.glUseProgram(0);
1159 void uniformfv_invalid_location (NegativeTestContext& ctx)
1161 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1163 ctx.glUseProgram(program.getProgram());
1164 ctx.expectError(GL_NO_ERROR);
1166 std::vector<GLfloat> data(4);
1168 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.");
1169 ctx.glUseProgram(program.getProgram());
1170 ctx.glUniform1fv(-2, 1, &data[0]);
1171 ctx.expectError(GL_INVALID_OPERATION);
1172 ctx.glUniform2fv(-2, 1, &data[0]);
1173 ctx.expectError(GL_INVALID_OPERATION);
1174 ctx.glUniform3fv(-2, 1, &data[0]);
1175 ctx.expectError(GL_INVALID_OPERATION);
1176 ctx.glUniform4fv(-2, 1, &data[0]);
1177 ctx.expectError(GL_INVALID_OPERATION);
1179 ctx.glUseProgram(program.getProgram());
1180 ctx.glUniform1fv(-1, 1, &data[0]);
1181 ctx.expectError(GL_NO_ERROR);
1182 ctx.glUniform2fv(-1, 1, &data[0]);
1183 ctx.expectError(GL_NO_ERROR);
1184 ctx.glUniform3fv(-1, 1, &data[0]);
1185 ctx.expectError(GL_NO_ERROR);
1186 ctx.glUniform4fv(-1, 1, &data[0]);
1187 ctx.expectError(GL_NO_ERROR);
1190 ctx.glUseProgram(0);
1193 void uniformfv_invalid_count (NegativeTestContext& ctx)
1195 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1197 ctx.glUseProgram (program.getProgram());
1198 GLint vec4_v = ctx.glGetUniformLocation(program.getProgram(), "vec4_v"); // vec4
1199 ctx.expectError(GL_NO_ERROR);
1203 ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1204 ctx.fail("Failed to retrieve uniform location");
1207 std::vector<GLfloat> data(8);
1209 ctx.beginSection("GL_INVALID_OPERATION is generated if count is greater than 1 and the indicated uniform variable is not an array variable.");
1210 ctx.glUseProgram(program.getProgram());
1211 ctx.glUniform1fv(vec4_v, 2, &data[0]);
1212 ctx.expectError(GL_INVALID_OPERATION);
1213 ctx.glUniform2fv(vec4_v, 2, &data[0]);
1214 ctx.expectError(GL_INVALID_OPERATION);
1215 ctx.glUniform3fv(vec4_v, 2, &data[0]);
1216 ctx.expectError(GL_INVALID_OPERATION);
1217 ctx.glUniform4fv(vec4_v, 2, &data[0]);
1218 ctx.expectError(GL_INVALID_OPERATION);
1221 ctx.glUseProgram(0);
1226 void uniformi_invalid_program (NegativeTestContext& ctx)
1228 ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object.");
1229 ctx.glUseProgram(0);
1230 ctx.glUniform1i(-1, 0);
1231 ctx.expectError(GL_INVALID_OPERATION);
1232 ctx.glUniform2i(-1, 0, 0);
1233 ctx.expectError(GL_INVALID_OPERATION);
1234 ctx.glUniform3i(-1, 0, 0, 0);
1235 ctx.expectError(GL_INVALID_OPERATION);
1236 ctx.glUniform4i(-1, 0, 0, 0, 0);
1237 ctx.expectError(GL_INVALID_OPERATION);
1241 void uniformi_incompatible_type (NegativeTestContext& ctx)
1243 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1245 ctx.glUseProgram(program.getProgram());
1246 GLint vec4_v = ctx.glGetUniformLocation(program.getProgram(), "vec4_v"); // vec4
1247 GLint ivec4_f = ctx.glGetUniformLocation(program.getProgram(), "ivec4_f"); // ivec4
1248 GLint uvec4_f = ctx.glGetUniformLocation(program.getProgram(), "uvec4_f"); // uvec4
1249 GLint sampler_f = ctx.glGetUniformLocation(program.getProgram(), "sampler_f"); // sampler2D
1250 ctx.expectError(GL_NO_ERROR);
1252 if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1)
1254 ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1255 ctx.fail("Failed to retrieve uniform location");
1258 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.");
1259 ctx.glUseProgram(program.getProgram());
1260 ctx.glUniform1i(ivec4_f, 0);
1261 ctx.expectError(GL_INVALID_OPERATION);
1262 ctx.glUniform2i(ivec4_f, 0, 0);
1263 ctx.expectError(GL_INVALID_OPERATION);
1264 ctx.glUniform3i(ivec4_f, 0, 0, 0);
1265 ctx.expectError(GL_INVALID_OPERATION);
1266 ctx.glUniform4i(ivec4_f, 0, 0, 0, 0);
1267 ctx.expectError(GL_NO_ERROR);
1270 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.");
1271 ctx.glUseProgram(program.getProgram());
1272 ctx.glUniform1i(uvec4_f, 0);
1273 ctx.expectError(GL_INVALID_OPERATION);
1274 ctx.glUniform2i(uvec4_f, 0, 0);
1275 ctx.expectError(GL_INVALID_OPERATION);
1276 ctx.glUniform3i(uvec4_f, 0, 0, 0);
1277 ctx.expectError(GL_INVALID_OPERATION);
1278 ctx.glUniform4i(uvec4_f, 0, 0, 0, 0);
1279 ctx.expectError(GL_INVALID_OPERATION);
1282 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.");
1283 ctx.glUseProgram(program.getProgram());
1284 ctx.glUniform1i(vec4_v, 0);
1285 ctx.expectError(GL_INVALID_OPERATION);
1286 ctx.glUniform2i(vec4_v, 0, 0);
1287 ctx.expectError(GL_INVALID_OPERATION);
1288 ctx.glUniform3i(vec4_v, 0, 0, 0);
1289 ctx.expectError(GL_INVALID_OPERATION);
1290 ctx.glUniform4i(vec4_v, 0, 0, 0, 0);
1291 ctx.expectError(GL_INVALID_OPERATION);
1294 ctx.glUseProgram(0);
1297 void uniformi_invalid_location (NegativeTestContext& ctx)
1299 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1301 ctx.glUseProgram(program.getProgram());
1302 ctx.expectError(GL_NO_ERROR);
1304 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.");
1305 ctx.glUseProgram(program.getProgram());
1306 ctx.glUniform1i(-2, 0);
1307 ctx.expectError(GL_INVALID_OPERATION);
1308 ctx.glUniform2i(-2, 0, 0);
1309 ctx.expectError(GL_INVALID_OPERATION);
1310 ctx.glUniform3i(-2, 0, 0, 0);
1311 ctx.expectError(GL_INVALID_OPERATION);
1312 ctx.glUniform4i(-2, 0, 0, 0, 0);
1313 ctx.expectError(GL_INVALID_OPERATION);
1315 ctx.glUseProgram(program.getProgram());
1316 ctx.glUniform1i(-1, 0);
1317 ctx.expectError(GL_NO_ERROR);
1318 ctx.glUniform2i(-1, 0, 0);
1319 ctx.expectError(GL_NO_ERROR);
1320 ctx.glUniform3i(-1, 0, 0, 0);
1321 ctx.expectError(GL_NO_ERROR);
1322 ctx.glUniform4i(-1, 0, 0, 0, 0);
1323 ctx.expectError(GL_NO_ERROR);
1326 ctx.glUseProgram(0);
1331 void uniformiv_invalid_program (NegativeTestContext& ctx)
1333 std::vector<GLint> data(4);
1335 ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object.");
1336 ctx.glUseProgram(0);
1337 ctx.glUniform1iv(-1, 1, &data[0]);
1338 ctx.expectError(GL_INVALID_OPERATION);
1339 ctx.glUniform2iv(-1, 1, &data[0]);
1340 ctx.expectError(GL_INVALID_OPERATION);
1341 ctx.glUniform3iv(-1, 1, &data[0]);
1342 ctx.expectError(GL_INVALID_OPERATION);
1343 ctx.glUniform4iv(-1, 1, &data[0]);
1344 ctx.expectError(GL_INVALID_OPERATION);
1348 void uniformiv_incompatible_type (NegativeTestContext& ctx)
1350 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1352 ctx.glUseProgram(program.getProgram());
1353 GLint vec4_v = ctx.glGetUniformLocation(program.getProgram(), "vec4_v"); // vec4
1354 GLint ivec4_f = ctx.glGetUniformLocation(program.getProgram(), "ivec4_f"); // ivec4
1355 GLint uvec4_f = ctx.glGetUniformLocation(program.getProgram(), "uvec4_f"); // uvec4
1356 GLint sampler_f = ctx.glGetUniformLocation(program.getProgram(), "sampler_f"); // sampler2D
1357 ctx.expectError(GL_NO_ERROR);
1359 if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1)
1361 ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1362 ctx.fail("Failed to retrieve uniform location");
1365 std::vector<GLint> data(4);
1367 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.");
1368 ctx.glUseProgram(program.getProgram());
1369 ctx.glUniform1iv(ivec4_f, 1, &data[0]);
1370 ctx.expectError(GL_INVALID_OPERATION);
1371 ctx.glUniform2iv(ivec4_f, 1, &data[0]);
1372 ctx.expectError(GL_INVALID_OPERATION);
1373 ctx.glUniform3iv(ivec4_f, 1, &data[0]);
1374 ctx.expectError(GL_INVALID_OPERATION);
1375 ctx.glUniform4iv(ivec4_f, 1, &data[0]);
1376 ctx.expectError(GL_NO_ERROR);
1379 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.");
1380 ctx.glUseProgram(program.getProgram());
1381 ctx.glUniform1iv(vec4_v, 1, &data[0]);
1382 ctx.expectError(GL_INVALID_OPERATION);
1383 ctx.glUniform2iv(vec4_v, 1, &data[0]);
1384 ctx.expectError(GL_INVALID_OPERATION);
1385 ctx.glUniform3iv(vec4_v, 1, &data[0]);
1386 ctx.expectError(GL_INVALID_OPERATION);
1387 ctx.glUniform4iv(vec4_v, 1, &data[0]);
1388 ctx.expectError(GL_INVALID_OPERATION);
1391 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.");
1392 ctx.glUseProgram(program.getProgram());
1393 ctx.glUniform1iv(uvec4_f, 1, &data[0]);
1394 ctx.expectError(GL_INVALID_OPERATION);
1395 ctx.glUniform2iv(uvec4_f, 1, &data[0]);
1396 ctx.expectError(GL_INVALID_OPERATION);
1397 ctx.glUniform3iv(uvec4_f, 1, &data[0]);
1398 ctx.expectError(GL_INVALID_OPERATION);
1399 ctx.glUniform4iv(uvec4_f, 1, &data[0]);
1400 ctx.expectError(GL_INVALID_OPERATION);
1403 ctx.glUseProgram(0);
1406 void uniformiv_invalid_location (NegativeTestContext& ctx)
1408 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1410 ctx.glUseProgram(program.getProgram());
1411 ctx.expectError(GL_NO_ERROR);
1413 std::vector<GLint> data(4);
1415 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.");
1416 ctx.glUseProgram(program.getProgram());
1417 ctx.glUniform1iv(-2, 1, &data[0]);
1418 ctx.expectError(GL_INVALID_OPERATION);
1419 ctx.glUniform2iv(-2, 1, &data[0]);
1420 ctx.expectError(GL_INVALID_OPERATION);
1421 ctx.glUniform3iv(-2, 1, &data[0]);
1422 ctx.expectError(GL_INVALID_OPERATION);
1423 ctx.glUniform4iv(-2, 1, &data[0]);
1424 ctx.expectError(GL_INVALID_OPERATION);
1426 ctx.glUseProgram(program.getProgram());
1427 ctx.glUniform1iv(-1, 1, &data[0]);
1428 ctx.expectError(GL_NO_ERROR);
1429 ctx.glUniform2iv(-1, 1, &data[0]);
1430 ctx.expectError(GL_NO_ERROR);
1431 ctx.glUniform3iv(-1, 1, &data[0]);
1432 ctx.expectError(GL_NO_ERROR);
1433 ctx.glUniform4iv(-1, 1, &data[0]);
1434 ctx.expectError(GL_NO_ERROR);
1437 ctx.glUseProgram(0);
1440 void uniformiv_invalid_count (NegativeTestContext& ctx)
1442 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1444 ctx.glUseProgram (program.getProgram());
1445 GLint ivec4_f = ctx.glGetUniformLocation(program.getProgram(), "ivec4_f"); // ivec4
1446 ctx.expectError(GL_NO_ERROR);
1450 ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1451 ctx.fail("Failed to retrieve uniform location");
1454 std::vector<GLint> data(8);
1456 ctx.beginSection("GL_INVALID_OPERATION is generated if count is greater than 1 and the indicated uniform variable is not an array variable.");
1457 ctx.glUseProgram(program.getProgram());
1458 ctx.glUniform1iv(ivec4_f, 2, &data[0]);
1459 ctx.expectError(GL_INVALID_OPERATION);
1460 ctx.glUniform2iv(ivec4_f, 2, &data[0]);
1461 ctx.expectError(GL_INVALID_OPERATION);
1462 ctx.glUniform3iv(ivec4_f, 2, &data[0]);
1463 ctx.expectError(GL_INVALID_OPERATION);
1464 ctx.glUniform4iv(ivec4_f, 2, &data[0]);
1465 ctx.expectError(GL_INVALID_OPERATION);
1468 ctx.glUseProgram(0);
1471 // ctx.glUniform{1234}ui
1473 void uniformui_invalid_program (NegativeTestContext& ctx)
1475 ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object.");
1476 ctx.glUseProgram(0);
1477 ctx.glUniform1ui(-1, 0);
1478 ctx.expectError(GL_INVALID_OPERATION);
1479 ctx.glUniform2ui(-1, 0, 0);
1480 ctx.expectError(GL_INVALID_OPERATION);
1481 ctx.glUniform3ui(-1, 0, 0, 0);
1482 ctx.expectError(GL_INVALID_OPERATION);
1483 ctx.glUniform4ui(-1, 0, 0, 0, 0);
1484 ctx.expectError(GL_INVALID_OPERATION);
1488 void uniformui_incompatible_type (NegativeTestContext& ctx)
1490 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1492 ctx.glUseProgram(program.getProgram());
1493 GLint vec4_v = ctx.glGetUniformLocation(program.getProgram(), "vec4_v"); // vec4
1494 GLint ivec4_f = ctx.glGetUniformLocation(program.getProgram(), "ivec4_f"); // ivec4
1495 GLint uvec4_f = ctx.glGetUniformLocation(program.getProgram(), "uvec4_f"); // uvec4
1496 GLint sampler_f = ctx.glGetUniformLocation(program.getProgram(), "sampler_f"); // sampler2D
1497 ctx.expectError(GL_NO_ERROR);
1499 if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1)
1501 ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1502 ctx.fail("Failed to retrieve uniform location");
1505 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.");
1506 ctx.glUseProgram(program.getProgram());
1507 ctx.glUniform1ui(uvec4_f, 0);
1508 ctx.expectError(GL_INVALID_OPERATION);
1509 ctx.glUniform2ui(uvec4_f, 0, 0);
1510 ctx.expectError(GL_INVALID_OPERATION);
1511 ctx.glUniform3ui(uvec4_f, 0, 0, 0);
1512 ctx.expectError(GL_INVALID_OPERATION);
1513 ctx.glUniform4ui(uvec4_f, 0, 0, 0, 0);
1514 ctx.expectError(GL_NO_ERROR);
1517 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.");
1518 ctx.glUseProgram(program.getProgram());
1519 ctx.glUniform1ui(ivec4_f, 0);
1520 ctx.expectError(GL_INVALID_OPERATION);
1521 ctx.glUniform2ui(ivec4_f, 0, 0);
1522 ctx.expectError(GL_INVALID_OPERATION);
1523 ctx.glUniform3ui(ivec4_f, 0, 0, 0);
1524 ctx.expectError(GL_INVALID_OPERATION);
1525 ctx.glUniform4ui(ivec4_f, 0, 0, 0, 0);
1526 ctx.expectError(GL_INVALID_OPERATION);
1529 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.");
1530 ctx.glUseProgram(program.getProgram());
1531 ctx.glUniform1ui(vec4_v, 0);
1532 ctx.expectError(GL_INVALID_OPERATION);
1533 ctx.glUniform2ui(vec4_v, 0, 0);
1534 ctx.expectError(GL_INVALID_OPERATION);
1535 ctx.glUniform3ui(vec4_v, 0, 0, 0);
1536 ctx.expectError(GL_INVALID_OPERATION);
1537 ctx.glUniform4ui(vec4_v, 0, 0, 0, 0);
1538 ctx.expectError(GL_INVALID_OPERATION);
1541 ctx.beginSection("GL_INVALID_OPERATION is generated if a sampler is loaded using a command other than ctx.glUniform1i and ctx.glUniform1iv.");
1542 ctx.glUseProgram(program.getProgram());
1543 ctx.glUniform1ui(sampler_f, 0);
1544 ctx.expectError(GL_INVALID_OPERATION);
1547 ctx.glUseProgram(0);
1550 void uniformui_invalid_location (NegativeTestContext& ctx)
1552 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1554 ctx.glUseProgram(program.getProgram());
1555 ctx.expectError(GL_NO_ERROR);
1557 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.");
1558 ctx.glUseProgram(program.getProgram());
1559 ctx.glUniform1i(-2, 0);
1560 ctx.expectError(GL_INVALID_OPERATION);
1561 ctx.glUniform2i(-2, 0, 0);
1562 ctx.expectError(GL_INVALID_OPERATION);
1563 ctx.glUniform3i(-2, 0, 0, 0);
1564 ctx.expectError(GL_INVALID_OPERATION);
1565 ctx.glUniform4i(-2, 0, 0, 0, 0);
1566 ctx.expectError(GL_INVALID_OPERATION);
1568 ctx.glUseProgram(program.getProgram());
1569 ctx.glUniform1i(-1, 0);
1570 ctx.expectError(GL_NO_ERROR);
1571 ctx.glUniform2i(-1, 0, 0);
1572 ctx.expectError(GL_NO_ERROR);
1573 ctx.glUniform3i(-1, 0, 0, 0);
1574 ctx.expectError(GL_NO_ERROR);
1575 ctx.glUniform4i(-1, 0, 0, 0, 0);
1576 ctx.expectError(GL_NO_ERROR);
1579 ctx.glUseProgram(0);
1582 // ctx.glUniform{1234}uiv
1584 void uniformuiv_invalid_program (NegativeTestContext& ctx)
1586 std::vector<GLuint> data(4);
1588 ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object.");
1589 ctx.glUseProgram(0);
1590 ctx.glUniform1uiv(-1, 1, &data[0]);
1591 ctx.expectError(GL_INVALID_OPERATION);
1592 ctx.glUniform2uiv(-1, 1, &data[0]);
1593 ctx.expectError(GL_INVALID_OPERATION);
1594 ctx.glUniform3uiv(-1, 1, &data[0]);
1595 ctx.expectError(GL_INVALID_OPERATION);
1596 ctx.glUniform4uiv(-1, 1, &data[0]);
1597 ctx.expectError(GL_INVALID_OPERATION);
1601 void uniformuiv_incompatible_type (NegativeTestContext& ctx)
1603 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1605 ctx.glUseProgram(program.getProgram());
1606 GLint vec4_v = ctx.glGetUniformLocation(program.getProgram(), "vec4_v"); // vec4
1607 GLint ivec4_f = ctx.glGetUniformLocation(program.getProgram(), "ivec4_f"); // ivec4
1608 GLint uvec4_f = ctx.glGetUniformLocation(program.getProgram(), "uvec4_f"); // uvec4
1609 GLint sampler_f = ctx.glGetUniformLocation(program.getProgram(), "sampler_f"); // sampler2D
1610 ctx.expectError(GL_NO_ERROR);
1612 if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1)
1614 ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1615 ctx.fail("Failed to retrieve uniform location");
1618 std::vector<GLuint> data(4);
1620 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.");
1621 ctx.glUseProgram(program.getProgram());
1622 ctx.glUniform1uiv(uvec4_f, 1, &data[0]);
1623 ctx.expectError(GL_INVALID_OPERATION);
1624 ctx.glUniform2uiv(uvec4_f, 1, &data[0]);
1625 ctx.expectError(GL_INVALID_OPERATION);
1626 ctx.glUniform3uiv(uvec4_f, 1, &data[0]);
1627 ctx.expectError(GL_INVALID_OPERATION);
1628 ctx.glUniform4uiv(uvec4_f, 1, &data[0]);
1629 ctx.expectError(GL_NO_ERROR);
1632 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.");
1633 ctx.glUseProgram(program.getProgram());
1634 ctx.glUniform1uiv(vec4_v, 1, &data[0]);
1635 ctx.expectError(GL_INVALID_OPERATION);
1636 ctx.glUniform2uiv(vec4_v, 1, &data[0]);
1637 ctx.expectError(GL_INVALID_OPERATION);
1638 ctx.glUniform3uiv(vec4_v, 1, &data[0]);
1639 ctx.expectError(GL_INVALID_OPERATION);
1640 ctx.glUniform4uiv(vec4_v, 1, &data[0]);
1641 ctx.expectError(GL_INVALID_OPERATION);
1644 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.");
1645 ctx.glUseProgram(program.getProgram());
1646 ctx.glUniform1uiv(ivec4_f, 1, &data[0]);
1647 ctx.expectError(GL_INVALID_OPERATION);
1648 ctx.glUniform2uiv(ivec4_f, 1, &data[0]);
1649 ctx.expectError(GL_INVALID_OPERATION);
1650 ctx.glUniform3uiv(ivec4_f, 1, &data[0]);
1651 ctx.expectError(GL_INVALID_OPERATION);
1652 ctx.glUniform4uiv(ivec4_f, 1, &data[0]);
1653 ctx.expectError(GL_INVALID_OPERATION);
1656 ctx.beginSection("GL_INVALID_OPERATION is generated if a sampler is loaded using a command other than ctx.glUniform1i and ctx.glUniform1iv.");
1657 ctx.glUseProgram(program.getProgram());
1658 ctx.glUniform1uiv(sampler_f, 1, &data[0]);
1659 ctx.expectError(GL_INVALID_OPERATION);
1662 ctx.glUseProgram(0);
1665 void uniformuiv_invalid_location (NegativeTestContext& ctx)
1667 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1669 ctx.glUseProgram(program.getProgram());
1670 ctx.expectError(GL_NO_ERROR);
1672 std::vector<GLuint> data(4);
1674 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.");
1675 ctx.glUseProgram(program.getProgram());
1676 ctx.glUniform1uiv(-2, 1, &data[0]);
1677 ctx.expectError(GL_INVALID_OPERATION);
1678 ctx.glUniform2uiv(-2, 1, &data[0]);
1679 ctx.expectError(GL_INVALID_OPERATION);
1680 ctx.glUniform3uiv(-2, 1, &data[0]);
1681 ctx.expectError(GL_INVALID_OPERATION);
1682 ctx.glUniform4uiv(-2, 1, &data[0]);
1683 ctx.expectError(GL_INVALID_OPERATION);
1685 ctx.glUseProgram(program.getProgram());
1686 ctx.glUniform1uiv(-1, 1, &data[0]);
1687 ctx.expectError(GL_NO_ERROR);
1688 ctx.glUniform2uiv(-1, 1, &data[0]);
1689 ctx.expectError(GL_NO_ERROR);
1690 ctx.glUniform3uiv(-1, 1, &data[0]);
1691 ctx.expectError(GL_NO_ERROR);
1692 ctx.glUniform4uiv(-1, 1, &data[0]);
1693 ctx.expectError(GL_NO_ERROR);
1696 ctx.glUseProgram(0);
1699 void uniformuiv_invalid_count (NegativeTestContext& ctx)
1701 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1703 ctx.glUseProgram (program.getProgram());
1704 int uvec4_f = ctx.glGetUniformLocation(program.getProgram(), "uvec4_f"); // uvec4
1705 ctx.expectError(GL_NO_ERROR);
1709 ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1710 ctx.fail("Failed to retrieve uniform location");
1713 std::vector<GLuint> data(8);
1715 ctx.beginSection("GL_INVALID_OPERATION is generated if count is greater than 1 and the indicated uniform variable is not an array variable.");
1716 ctx.glUseProgram(program.getProgram());
1717 ctx.glUniform1uiv(uvec4_f, 2, &data[0]);
1718 ctx.expectError(GL_INVALID_OPERATION);
1719 ctx.glUniform2uiv(uvec4_f, 2, &data[0]);
1720 ctx.expectError(GL_INVALID_OPERATION);
1721 ctx.glUniform3uiv(uvec4_f, 2, &data[0]);
1722 ctx.expectError(GL_INVALID_OPERATION);
1723 ctx.glUniform4uiv(uvec4_f, 2, &data[0]);
1724 ctx.expectError(GL_INVALID_OPERATION);
1727 ctx.glUseProgram(0);
1731 // ctx.glUniformMatrix*fv
1733 void uniform_matrixfv_invalid_program (NegativeTestContext& ctx)
1735 std::vector<GLfloat> data(16);
1737 ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object.");
1738 ctx.glUseProgram(0);
1739 ctx.glUniformMatrix2fv(-1, 1, GL_FALSE, &data[0]);
1740 ctx.expectError(GL_INVALID_OPERATION);
1741 ctx.glUniformMatrix3fv(-1, 1, GL_FALSE, &data[0]);
1742 ctx.expectError(GL_INVALID_OPERATION);
1743 ctx.glUniformMatrix4fv(-1, 1, GL_FALSE, &data[0]);
1744 ctx.expectError(GL_INVALID_OPERATION);
1746 ctx.glUniformMatrix2x3fv(-1, 1, GL_FALSE, &data[0]);
1747 ctx.expectError(GL_INVALID_OPERATION);
1748 ctx.glUniformMatrix3x2fv(-1, 1, GL_FALSE, &data[0]);
1749 ctx.expectError(GL_INVALID_OPERATION);
1750 ctx.glUniformMatrix2x4fv(-1, 1, GL_FALSE, &data[0]);
1751 ctx.expectError(GL_INVALID_OPERATION);
1752 ctx.glUniformMatrix4x2fv(-1, 1, GL_FALSE, &data[0]);
1753 ctx.expectError(GL_INVALID_OPERATION);
1754 ctx.glUniformMatrix3x4fv(-1, 1, GL_FALSE, &data[0]);
1755 ctx.expectError(GL_INVALID_OPERATION);
1756 ctx.glUniformMatrix4x3fv(-1, 1, GL_FALSE, &data[0]);
1757 ctx.expectError(GL_INVALID_OPERATION);
1761 void uniform_matrixfv_incompatible_type (NegativeTestContext& ctx)
1763 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1765 ctx.glUseProgram (program.getProgram());
1766 GLint mat4_v = ctx.glGetUniformLocation(program.getProgram(), "mat4_v"); // mat4
1767 GLint sampler_f = ctx.glGetUniformLocation(program.getProgram(), "sampler_f"); // sampler2D
1768 ctx.expectError(GL_NO_ERROR);
1770 if (mat4_v == -1 || sampler_f == -1)
1772 ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1773 ctx.fail("Failed to retrieve uniform location");
1776 std::vector<GLfloat> data(16);
1778 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.");
1779 ctx.glUseProgram(program.getProgram());
1780 ctx.glUniformMatrix2fv(mat4_v, 1, GL_FALSE, &data[0]);
1781 ctx.expectError(GL_INVALID_OPERATION);
1782 ctx.glUniformMatrix3fv(mat4_v, 1, GL_FALSE, &data[0]);
1783 ctx.expectError(GL_INVALID_OPERATION);
1784 ctx.glUniformMatrix4fv(mat4_v, 1, GL_FALSE, &data[0]);
1785 ctx.expectError(GL_NO_ERROR);
1787 ctx.glUniformMatrix2x3fv(mat4_v, 1, GL_FALSE, &data[0]);
1788 ctx.expectError(GL_INVALID_OPERATION);
1789 ctx.glUniformMatrix3x2fv(mat4_v, 1, GL_FALSE, &data[0]);
1790 ctx.expectError(GL_INVALID_OPERATION);
1791 ctx.glUniformMatrix2x4fv(mat4_v, 1, GL_FALSE, &data[0]);
1792 ctx.expectError(GL_INVALID_OPERATION);
1793 ctx.glUniformMatrix4x2fv(mat4_v, 1, GL_FALSE, &data[0]);
1794 ctx.expectError(GL_INVALID_OPERATION);
1795 ctx.glUniformMatrix3x4fv(mat4_v, 1, GL_FALSE, &data[0]);
1796 ctx.expectError(GL_INVALID_OPERATION);
1797 ctx.glUniformMatrix4x3fv(mat4_v, 1, GL_FALSE, &data[0]);
1798 ctx.expectError(GL_INVALID_OPERATION);
1801 ctx.beginSection("GL_INVALID_OPERATION is generated if a sampler is loaded using a command other than ctx.glUniform1i and ctx.glUniform1iv.");
1802 ctx.glUseProgram(program.getProgram());
1803 ctx.glUniformMatrix2fv(sampler_f, 1, GL_FALSE, &data[0]);
1804 ctx.expectError(GL_INVALID_OPERATION);
1805 ctx.glUniformMatrix3fv(sampler_f, 1, GL_FALSE, &data[0]);
1806 ctx.expectError(GL_INVALID_OPERATION);
1807 ctx.glUniformMatrix4fv(sampler_f, 1, GL_FALSE, &data[0]);
1808 ctx.expectError(GL_INVALID_OPERATION);
1810 ctx.glUniformMatrix2x3fv(sampler_f, 1, GL_FALSE, &data[0]);
1811 ctx.expectError(GL_INVALID_OPERATION);
1812 ctx.glUniformMatrix3x2fv(sampler_f, 1, GL_FALSE, &data[0]);
1813 ctx.expectError(GL_INVALID_OPERATION);
1814 ctx.glUniformMatrix2x4fv(sampler_f, 1, GL_FALSE, &data[0]);
1815 ctx.expectError(GL_INVALID_OPERATION);
1816 ctx.glUniformMatrix4x2fv(sampler_f, 1, GL_FALSE, &data[0]);
1817 ctx.expectError(GL_INVALID_OPERATION);
1818 ctx.glUniformMatrix3x4fv(sampler_f, 1, GL_FALSE, &data[0]);
1819 ctx.expectError(GL_INVALID_OPERATION);
1820 ctx.glUniformMatrix4x3fv(sampler_f, 1, GL_FALSE, &data[0]);
1821 ctx.expectError(GL_INVALID_OPERATION);
1824 ctx.glUseProgram(0);
1827 void uniform_matrixfv_invalid_location (NegativeTestContext& ctx)
1829 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1831 ctx.glUseProgram(program.getProgram());
1832 ctx.expectError(GL_NO_ERROR);
1834 std::vector<GLfloat> data(16);
1836 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.");
1837 ctx.glUseProgram(program.getProgram());
1838 ctx.glUniformMatrix2fv(-2, 1, GL_FALSE, &data[0]);
1839 ctx.expectError(GL_INVALID_OPERATION);
1840 ctx.glUniformMatrix3fv(-2, 1, GL_FALSE, &data[0]);
1841 ctx.expectError(GL_INVALID_OPERATION);
1842 ctx.glUniformMatrix4fv(-2, 1, GL_FALSE, &data[0]);
1843 ctx.expectError(GL_INVALID_OPERATION);
1845 ctx.glUniformMatrix2x3fv(-2, 1, GL_FALSE, &data[0]);
1846 ctx.expectError(GL_INVALID_OPERATION);
1847 ctx.glUniformMatrix3x2fv(-2, 1, GL_FALSE, &data[0]);
1848 ctx.expectError(GL_INVALID_OPERATION);
1849 ctx.glUniformMatrix2x4fv(-2, 1, GL_FALSE, &data[0]);
1850 ctx.expectError(GL_INVALID_OPERATION);
1851 ctx.glUniformMatrix4x2fv(-2, 1, GL_FALSE, &data[0]);
1852 ctx.expectError(GL_INVALID_OPERATION);
1853 ctx.glUniformMatrix3x4fv(-2, 1, GL_FALSE, &data[0]);
1854 ctx.expectError(GL_INVALID_OPERATION);
1855 ctx.glUniformMatrix4x3fv(-2, 1, GL_FALSE, &data[0]);
1856 ctx.expectError(GL_INVALID_OPERATION);
1858 ctx.glUseProgram(program.getProgram());
1859 ctx.glUniformMatrix2fv(-1, 1, GL_FALSE, &data[0]);
1860 ctx.expectError(GL_NO_ERROR);
1861 ctx.glUniformMatrix3fv(-1, 1, GL_FALSE, &data[0]);
1862 ctx.expectError(GL_NO_ERROR);
1863 ctx.glUniformMatrix4fv(-1, 1, GL_FALSE, &data[0]);
1864 ctx.expectError(GL_NO_ERROR);
1866 ctx.glUniformMatrix2x3fv(-1, 1, GL_FALSE, &data[0]);
1867 ctx.expectError(GL_NO_ERROR);
1868 ctx.glUniformMatrix3x2fv(-1, 1, GL_FALSE, &data[0]);
1869 ctx.expectError(GL_NO_ERROR);
1870 ctx.glUniformMatrix2x4fv(-1, 1, GL_FALSE, &data[0]);
1871 ctx.expectError(GL_NO_ERROR);
1872 ctx.glUniformMatrix4x2fv(-1, 1, GL_FALSE, &data[0]);
1873 ctx.expectError(GL_NO_ERROR);
1874 ctx.glUniformMatrix3x4fv(-1, 1, GL_FALSE, &data[0]);
1875 ctx.expectError(GL_NO_ERROR);
1876 ctx.glUniformMatrix4x3fv(-1, 1, GL_FALSE, &data[0]);
1877 ctx.expectError(GL_NO_ERROR);
1880 ctx.glUseProgram(0);
1883 void uniform_matrixfv_invalid_count (NegativeTestContext& ctx)
1885 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1887 ctx.glUseProgram (program.getProgram());
1888 GLint mat4_v = ctx.glGetUniformLocation(program.getProgram(), "mat4_v"); // mat4
1889 ctx.expectError(GL_NO_ERROR);
1893 ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1894 ctx.fail("Failed to retrieve uniform location");
1897 std::vector<GLfloat> data(32);
1899 ctx.beginSection("GL_INVALID_OPERATION is generated if count is greater than 1 and the indicated uniform variable is not an array variable.");
1900 ctx.glUseProgram(program.getProgram());
1901 ctx.glUniformMatrix2fv(mat4_v, 2, GL_FALSE, &data[0]);
1902 ctx.expectError(GL_INVALID_OPERATION);
1903 ctx.glUniformMatrix3fv(mat4_v, 2, GL_FALSE, &data[0]);
1904 ctx.expectError(GL_INVALID_OPERATION);
1905 ctx.glUniformMatrix4fv(mat4_v, 2, GL_FALSE, &data[0]);
1906 ctx.expectError(GL_INVALID_OPERATION);
1908 ctx.glUniformMatrix2x3fv(mat4_v, 1, GL_FALSE, &data[0]);
1909 ctx.expectError(GL_INVALID_OPERATION);
1910 ctx.glUniformMatrix3x2fv(mat4_v, 1, GL_FALSE, &data[0]);
1911 ctx.expectError(GL_INVALID_OPERATION);
1912 ctx.glUniformMatrix2x4fv(mat4_v, 1, GL_FALSE, &data[0]);
1913 ctx.expectError(GL_INVALID_OPERATION);
1914 ctx.glUniformMatrix4x2fv(mat4_v, 1, GL_FALSE, &data[0]);
1915 ctx.expectError(GL_INVALID_OPERATION);
1916 ctx.glUniformMatrix3x4fv(mat4_v, 1, GL_FALSE, &data[0]);
1917 ctx.expectError(GL_INVALID_OPERATION);
1918 ctx.glUniformMatrix4x3fv(mat4_v, 1, GL_FALSE, &data[0]);
1919 ctx.expectError(GL_INVALID_OPERATION);
1922 ctx.glUseProgram(0);
1925 // Transform feedback
1926 void gen_transform_feedbacks (NegativeTestContext& ctx)
1928 ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
1930 ctx.glGenTransformFeedbacks(-1, &id);
1931 ctx.expectError(GL_INVALID_VALUE);
1935 void bind_transform_feedback (NegativeTestContext& ctx)
1938 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
1939 deUint32 buf = 0x1234;
1940 const char* tfVarying = "gl_Position";
1942 ctx.glGenBuffers (1, &buf);
1943 ctx.glGenTransformFeedbacks (2, tfID);
1945 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_TRANSFORM_FEEDBACK.");
1946 ctx.glBindTransformFeedback(-1, tfID[0]);
1947 ctx.expectError(GL_INVALID_ENUM);
1950 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.");
1951 ctx.glUseProgram (program.getProgram());
1952 ctx.glTransformFeedbackVaryings (program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
1953 ctx.glLinkProgram (program.getProgram());
1954 ctx.glBindTransformFeedback (GL_TRANSFORM_FEEDBACK, tfID[0]);
1955 ctx.glBindBuffer (GL_TRANSFORM_FEEDBACK_BUFFER, buf);
1956 ctx.glBufferData (GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
1957 ctx.glBindBufferBase (GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
1958 ctx.glBeginTransformFeedback (GL_TRIANGLES);
1959 ctx.expectError (GL_NO_ERROR);
1961 ctx.glBindTransformFeedback (GL_TRANSFORM_FEEDBACK, tfID[1]);
1962 ctx.expectError (GL_INVALID_OPERATION);
1964 ctx.glEndTransformFeedback ();
1965 ctx.expectError (GL_NO_ERROR);
1968 ctx.glUseProgram (0);
1969 ctx.glDeleteBuffers (1, &buf);
1970 ctx.glDeleteTransformFeedbacks (2, tfID);
1971 ctx.expectError (GL_NO_ERROR);
1973 ctx.beginSection("GL_INVALID_OPERATION is generated if id has been deleted with glDeleteTransformFeedback().");
1974 ctx.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, tfID[0]);
1975 ctx.expectError(GL_INVALID_OPERATION);
1978 ctx.beginSection("GL_INVALID_OPERATION is generated if id is not 0 or a value returned from glGenTransformFeedbacks().");
1979 ctx.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, -1);
1980 ctx.expectError(GL_INVALID_OPERATION);
1984 void delete_transform_feedbacks (NegativeTestContext& ctx)
1988 deUint32 buf = 0x1234;
1989 const char* tfVarying = "gl_Position";
1990 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
1992 ctx.glGenBuffers(1, &buf);
1993 ctx.glGenTransformFeedbacks(1, &id);
1994 ctx.glGenTransformFeedbacks(2, tfID);
1996 ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
1997 ctx.glDeleteTransformFeedbacks(-1, &id);
1998 ctx.expectError(GL_INVALID_VALUE);
2001 ctx.beginSection("GL_INVALID_OPERATION is generated if the transform feedback operation for any object named by ids is currently active.");
2002 ctx.glUseProgram(program.getProgram());
2003 ctx.glTransformFeedbackVaryings(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
2004 ctx.glLinkProgram(program.getProgram());
2005 ctx.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, tfID[0]);
2006 ctx.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
2007 ctx.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
2008 ctx.glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
2009 ctx.glBeginTransformFeedback(GL_TRIANGLES);
2010 ctx.expectError(GL_NO_ERROR);
2012 ctx.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, tfID[1]);
2013 ctx.expectError(GL_INVALID_OPERATION);
2015 ctx.glDeleteTransformFeedbacks(2, tfID);
2016 ctx.expectError(GL_INVALID_OPERATION);
2018 ctx.glEndTransformFeedback();
2019 ctx.expectError(GL_NO_ERROR);
2023 ctx.glDeleteTransformFeedbacks(1, &id);
2024 ctx.glDeleteTransformFeedbacks(2, tfID);
2025 ctx.glDeleteBuffers(1, &buf);
2029 void begin_transform_feedback (NegativeTestContext& ctx)
2032 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
2033 deUint32 buf = 0x1234;
2034 const char* tfVarying = "gl_Position";
2036 ctx.glGenBuffers (1, &buf);
2037 ctx.glGenTransformFeedbacks (2, tfID);
2039 ctx.glUseProgram (program.getProgram());
2040 ctx.glTransformFeedbackVaryings (program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
2041 ctx.glLinkProgram (program.getProgram());
2042 ctx.glBindTransformFeedback (GL_TRANSFORM_FEEDBACK, tfID[0]);
2043 ctx.glBindBuffer (GL_TRANSFORM_FEEDBACK_BUFFER, buf);
2044 ctx.glBufferData (GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
2045 ctx.glBindBufferBase (GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
2046 ctx.expectError (GL_NO_ERROR);
2048 ctx.beginSection("GL_INVALID_ENUM is generated if primitiveMode is not one of GL_POINTS, GL_LINES, or GL_TRIANGLES.");
2049 ctx.glBeginTransformFeedback (-1);
2050 ctx.expectError (GL_INVALID_ENUM);
2053 ctx.beginSection("GL_INVALID_OPERATION is generated if transform feedback is already active.");
2054 ctx.glBeginTransformFeedback (GL_TRIANGLES);
2055 ctx.expectError (GL_NO_ERROR);
2056 ctx.glBeginTransformFeedback (GL_POINTS);
2057 ctx.expectError (GL_INVALID_OPERATION);
2060 ctx.beginSection("GL_INVALID_OPERATION is generated if any binding point used in transform feedback mode does not have a buffer object bound.");
2061 ctx.glBindBufferBase (GL_TRANSFORM_FEEDBACK_BUFFER, 0, 0);
2062 ctx.glBeginTransformFeedback (GL_TRIANGLES);
2063 ctx.expectError (GL_INVALID_OPERATION);
2064 ctx.glBindBufferBase (GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
2067 ctx.beginSection("GL_INVALID_OPERATION is generated if no binding points would be used because no program object is active.");
2068 ctx.glUseProgram (0);
2069 ctx.glBeginTransformFeedback (GL_TRIANGLES);
2070 ctx.expectError (GL_INVALID_OPERATION);
2071 ctx.glUseProgram (program.getProgram());
2074 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.");
2075 ctx.glTransformFeedbackVaryings (program.getProgram(), 0, 0, GL_INTERLEAVED_ATTRIBS);
2076 ctx.glBeginTransformFeedback (GL_TRIANGLES);
2077 ctx.expectError (GL_INVALID_OPERATION);
2080 ctx.glEndTransformFeedback ();
2081 ctx.glDeleteBuffers (1, &buf);
2082 ctx.glDeleteTransformFeedbacks (2, tfID);
2083 ctx.expectError (GL_NO_ERROR);
2086 void pause_transform_feedback (NegativeTestContext& ctx)
2089 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
2090 deUint32 buf = 0x1234;
2091 const char* tfVarying = "gl_Position";
2093 ctx.glGenBuffers (1, &buf);
2094 ctx.glGenTransformFeedbacks (2, tfID);
2096 ctx.glUseProgram (program.getProgram());
2097 ctx.glTransformFeedbackVaryings (program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
2098 ctx.glLinkProgram (program.getProgram());
2099 ctx.glBindTransformFeedback (GL_TRANSFORM_FEEDBACK, tfID[0]);
2100 ctx.glBindBuffer (GL_TRANSFORM_FEEDBACK_BUFFER, buf);
2101 ctx.glBufferData (GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
2102 ctx.glBindBufferBase (GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
2103 ctx.expectError (GL_NO_ERROR);
2105 ctx.beginSection("GL_INVALID_OPERATION is generated if the currently bound transform feedback object is not active or is paused.");
2106 ctx.glPauseTransformFeedback ();
2107 ctx.expectError (GL_INVALID_OPERATION);
2108 ctx.glBeginTransformFeedback (GL_TRIANGLES);
2109 ctx.glPauseTransformFeedback ();
2110 ctx.expectError (GL_NO_ERROR);
2111 ctx.glPauseTransformFeedback ();
2112 ctx.expectError (GL_INVALID_OPERATION);
2115 ctx.glEndTransformFeedback ();
2116 ctx.glDeleteBuffers (1, &buf);
2117 ctx.glDeleteTransformFeedbacks (2, tfID);
2118 ctx.expectError (GL_NO_ERROR);
2121 void resume_transform_feedback (NegativeTestContext& ctx)
2124 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
2125 deUint32 buf = 0x1234;
2126 const char* tfVarying = "gl_Position";
2128 ctx.glGenBuffers (1, &buf);
2129 ctx.glGenTransformFeedbacks (2, tfID);
2131 ctx.glUseProgram (program.getProgram());
2132 ctx.glTransformFeedbackVaryings (program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
2133 ctx.glLinkProgram (program.getProgram());
2134 ctx.glBindTransformFeedback (GL_TRANSFORM_FEEDBACK, tfID[0]);
2135 ctx.glBindBuffer (GL_TRANSFORM_FEEDBACK_BUFFER, buf);
2136 ctx.glBufferData (GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
2137 ctx.glBindBufferBase (GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
2138 ctx.expectError (GL_NO_ERROR);
2140 ctx.beginSection("GL_INVALID_OPERATION is generated if the currently bound transform feedback object is not active or is not paused.");
2141 ctx.glResumeTransformFeedback ();
2142 ctx.expectError (GL_INVALID_OPERATION);
2143 ctx.glBeginTransformFeedback (GL_TRIANGLES);
2144 ctx.glResumeTransformFeedback ();
2145 ctx.expectError (GL_INVALID_OPERATION);
2146 ctx.glPauseTransformFeedback ();
2147 ctx.glResumeTransformFeedback ();
2148 ctx.expectError (GL_NO_ERROR);
2151 ctx.glEndTransformFeedback ();
2152 ctx.glDeleteBuffers (1, &buf);
2153 ctx.glDeleteTransformFeedbacks (2, tfID);
2154 ctx.expectError (GL_NO_ERROR);
2157 void end_transform_feedback (NegativeTestContext& ctx)
2160 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
2161 deUint32 buf = 0x1234;
2162 const char* tfVarying = "gl_Position";
2164 ctx.glGenBuffers (1, &buf);
2165 ctx.glGenTransformFeedbacks (1, &tfID);
2167 ctx.glUseProgram (program.getProgram());
2168 ctx.glTransformFeedbackVaryings (program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
2169 ctx.glLinkProgram (program.getProgram());
2170 ctx.glBindTransformFeedback (GL_TRANSFORM_FEEDBACK, tfID);
2171 ctx.glBindBuffer (GL_TRANSFORM_FEEDBACK_BUFFER, buf);
2172 ctx.glBufferData (GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
2173 ctx.glBindBufferBase (GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
2174 ctx.expectError (GL_NO_ERROR);
2176 ctx.beginSection("GL_INVALID_OPERATION is generated if transform feedback is not active.");
2177 ctx.glEndTransformFeedback ();
2178 ctx.expectError (GL_INVALID_OPERATION);
2179 ctx.glBeginTransformFeedback (GL_TRIANGLES);
2180 ctx.glEndTransformFeedback ();
2181 ctx.expectError (GL_NO_ERROR);
2184 ctx.glDeleteBuffers (1, &buf);
2185 ctx.glDeleteTransformFeedbacks (1, &tfID);
2186 ctx.expectError (GL_NO_ERROR);
2189 void get_transform_feedback_varying (NegativeTestContext& ctx)
2192 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
2193 glu::ShaderProgram programInvalid (ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, ""));
2194 const char* tfVarying = "gl_Position";
2195 int maxTransformFeedbackVaryings = 0;
2202 const GLuint notAProgram = ctx.glCreateProgram();
2203 ctx.glDeleteProgram(notAProgram);
2205 ctx.glGenTransformFeedbacks (1, &tfID);
2207 ctx.glTransformFeedbackVaryings (program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
2208 ctx.expectError (GL_NO_ERROR);
2209 ctx.glLinkProgram (program.getProgram());
2210 ctx.expectError (GL_NO_ERROR);
2212 ctx.glBindTransformFeedback (GL_TRANSFORM_FEEDBACK, tfID);
2213 ctx.expectError (GL_NO_ERROR);
2215 ctx.beginSection("GL_INVALID_VALUE is generated if program is not the name of a program object.");
2216 ctx.glGetTransformFeedbackVarying (notAProgram, 0, 32, &length, &size, &type, &name[0]);
2217 ctx.expectError (GL_INVALID_VALUE);
2220 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater or equal to the value of GL_TRANSFORM_FEEDBACK_VARYINGS.");
2221 ctx.glGetProgramiv (program.getProgram(), GL_TRANSFORM_FEEDBACK_VARYINGS, &maxTransformFeedbackVaryings);
2222 ctx.glGetTransformFeedbackVarying (program.getProgram(), maxTransformFeedbackVaryings, 32, &length, &size, &type, &name[0]);
2223 ctx.expectError (GL_INVALID_VALUE);
2226 ctx.beginSection("GL_INVALID_OPERATION or GL_INVALID_VALUE is generated program has not been linked.");
2227 ctx.glGetTransformFeedbackVarying (programInvalid.getProgram(), 0, 32, &length, &size, &type, &name[0]);
2228 ctx.expectError (GL_INVALID_OPERATION, GL_INVALID_VALUE);
2231 ctx.glDeleteTransformFeedbacks (1, &tfID);
2232 ctx.expectError (GL_NO_ERROR);
2235 void transform_feedback_varyings (NegativeTestContext& ctx)
2238 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
2239 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
2240 const char* tfVarying = "gl_Position";
2241 GLint maxTransformFeedbackSeparateAttribs = 0;
2243 const GLuint notAProgram = ctx.glCreateProgram();
2244 ctx.glDeleteProgram(notAProgram);
2246 ctx.glGenTransformFeedbacks (1, &tfID);
2247 ctx.expectError (GL_NO_ERROR);
2249 ctx.beginSection("GL_INVALID_VALUE is generated if program is not the name of a program object.");
2250 ctx.glTransformFeedbackVaryings (notAProgram, 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
2251 ctx.expectError (GL_INVALID_VALUE);
2254 ctx.beginSection("GL_INVALID_OPERATION is generated if program is the name of a shader object.");
2255 ctx.glTransformFeedbackVaryings(shader, 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
2256 ctx.expectError(GL_INVALID_OPERATION);
2257 ctx.glDeleteShader(shader);
2260 ctx.beginSection("GL_INVALID_VALUE is generated if count is negative.");
2261 ctx.glTransformFeedbackVaryings(program.getProgram(), -1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
2262 ctx.expectError(GL_INVALID_VALUE);
2265 ctx.beginSection("GL_INVALID_ENUM is generated if bufferMode is not SEPARATE_ATTRIBS or INTERLEAVED_ATTRIBS.");
2266 ctx.glTransformFeedbackVaryings(program.getProgram(), 1, &tfVarying, 0);
2267 ctx.expectError(GL_INVALID_ENUM);
2270 ctx.beginSection("GL_INVALID_VALUE is generated if bufferMode is GL_SEPARATE_ATTRIBS and count is greater than GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS.");
2271 ctx.glGetIntegerv (GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &maxTransformFeedbackSeparateAttribs);
2272 ctx.glTransformFeedbackVaryings (program.getProgram(), maxTransformFeedbackSeparateAttribs+1, &tfVarying, GL_SEPARATE_ATTRIBS);
2273 ctx.expectError (GL_INVALID_VALUE);
2276 ctx.glDeleteTransformFeedbacks (1, &tfID);
2277 ctx.expectError (GL_NO_ERROR);
2281 void link_compute_shader (NegativeTestContext& ctx)
2283 const char* computeShaderSource = "#version 320 es\n"
2284 "void main (void)\n"
2288 const GLenum shaderTypes[] = {
2292 GL_TESS_CONTROL_SHADER,
2293 GL_TESS_EVALUATION_SHADER
2296 ctx.beginSection("Compute Shader linked with shader of other kind.");
2297 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(shaderTypes); ndx++)
2299 GLint linkStatus = -1;
2300 GLuint program = ctx.glCreateProgram();
2301 GLuint computeShader = ctx.glCreateShader(GL_COMPUTE_SHADER);
2302 GLuint otherShader = ctx.glCreateShader(shaderTypes[ndx]);
2303 const char* otherShaderSource = (shaderTypes[ndx] != GL_GEOMETRY_SHADER) ?
2304 computeShaderSource :
2306 "layout(max_vertices = 3) out;\n"
2307 "void main(void){}\n\0";
2309 ctx.glShaderSource(computeShader, 1, &computeShaderSource, DE_NULL);
2310 ctx.glShaderSource(otherShader, 1, &otherShaderSource, DE_NULL);
2311 ctx.glCompileShader(computeShader);
2312 ctx.glCompileShader(otherShader);
2313 ctx.glAttachShader(program, computeShader);
2314 ctx.glAttachShader(program, otherShader);
2315 ctx.glLinkProgram(program);
2316 ctx.glGetProgramiv(program, GL_LINK_STATUS, &linkStatus);
2317 ctx.glDeleteShader(otherShader);
2318 ctx.glDeleteShader(computeShader);
2319 ctx.glDeleteProgram(program);
2320 if (linkStatus != GL_FALSE)
2321 ctx.fail("Program should not have linked");
2326 const char* computeShaderSource310 = "#version 310 es\n"
2327 "void main (void)\n"
2330 GLint linkStatus = -1;
2331 GLuint program = ctx.glCreateProgram();
2332 GLuint computeShader = ctx.glCreateShader(GL_COMPUTE_SHADER);
2333 GLuint computeShader310 = ctx.glCreateShader(GL_FRAGMENT_SHADER);
2335 ctx.glShaderSource(computeShader, 1, &computeShaderSource, DE_NULL);
2336 ctx.glShaderSource(computeShader310, 1, &computeShaderSource310, DE_NULL);
2337 ctx.beginSection("Compute Shader should not be linked with shaders of different version.");
2338 ctx.glCompileShader(computeShader);
2339 ctx.glCompileShader(computeShader310);
2340 ctx.glAttachShader(program, computeShader);
2341 ctx.glAttachShader(program, computeShader310);
2342 ctx.glLinkProgram(program);
2343 ctx.glGetProgramiv(program, GL_LINK_STATUS, &linkStatus);
2344 ctx.glDeleteShader(computeShader310);
2345 ctx.glDeleteShader(computeShader);
2346 ctx.glDeleteProgram(program);
2347 if (linkStatus != GL_FALSE)
2348 ctx.fail("Program should not have linked");
2353 void compile_compute_shader_helper (NegativeTestContext& ctx, const char* const* computeShaderSource, GLint* compileStatus)
2355 GLuint shader = ctx.glCreateShader(GL_COMPUTE_SHADER);
2357 *compileStatus = -1;
2358 ctx.glShaderSource(shader, 1, computeShaderSource, DE_NULL);
2359 ctx.glCompileShader(shader);
2360 ctx.glGetShaderiv(shader, GL_COMPILE_STATUS, compileStatus);
2361 ctx.glDeleteShader(shader);
2364 void compile_compute_shader (NegativeTestContext& ctx)
2366 GLint compileStatus;
2367 ctx.beginSection("Compile Computer Shader");
2370 const char* const computeShaderSource = "#version 300 es\n"
2371 "void main (void)\n"
2375 compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2376 if (compileStatus != GL_FALSE)
2377 ctx.fail("Compute Shader should not have compiled with #version 300 es.");
2380 const char* const computeShaderSource = "#version 310 es\n"
2381 "buffer SSBO { vec4 data }"
2382 "void main (void)\n"
2386 compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2387 if (compileStatus != GL_FALSE)
2388 ctx.fail("Compute Shader should not have compiled: incorrect SSBO syntax.");
2391 const char* const computeShaderSource = "#version 310 es\n"
2392 "buffer SSBO { vec4 data;};"
2393 "uniform mat4 data;"
2394 "void main (void)\n"
2398 compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2399 if (compileStatus != GL_FALSE)
2400 ctx.fail("Compute Shader should not have compiled: buffer variable redefinition.");
2403 const char* const computeShaderSource = "#version 310 es\n"
2404 "buffer SSBO { vec4 data[]; vec4 moreData;};"
2405 "void main (void)\n"
2409 compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2410 if (compileStatus != GL_FALSE)
2411 ctx.fail("Compute Shader should not have compiled: unspecified length buffer member not at the end.");
2414 const char* const computeShaderSource = "#version 310 es\n"
2416 "void main (void)\n"
2420 compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2421 if (compileStatus != GL_FALSE)
2422 ctx.fail("Compute Shader should not have compiled: input qualifier used.");
2425 const char* const computeShaderSource = "#version 310 es\n"
2426 "shared uint data = 0;";
2428 compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2429 if (compileStatus != GL_FALSE)
2430 ctx.fail("Compute Shader should not have compiled: shared-qualified variable initialized.");
2433 const char* const computeShaderSource = "#version 310 es\n"
2434 "buffer SSBO { vec4 data; vec4 moreData[];} ssbo;"
2435 "void test (vec4 data[10]) {}"
2436 "void main (void)\n"
2438 " test(ssbo.moreData);"
2441 compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2442 if (compileStatus != GL_FALSE)
2443 ctx.fail("Compute Shader should not have compiled: unspecified length buffer member passed as argument to function.");
2446 const char* const computeShaderSource = "#version 310 es\n"
2447 "buffer SSBO { vec4 data; vec4 moreData[];} ssbo;"
2448 "void main (void)\n"
2450 " vec4 var = ssbo.moreData[-1];"
2453 compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2454 if (compileStatus != GL_FALSE)
2455 ctx.fail("Compute Shader should not have compiled: unspecified length buffer member indexed with negative constant expression.");
2458 const char* const computeShaderSource = "#version 310 es\n"
2459 "layout(binding=-1) buffer SSBO { vec4 data;};"
2460 "void main (void)\n"
2464 compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2465 if (compileStatus != GL_FALSE)
2466 ctx.fail("Compute Shader should not have compiled: binding point less than zero.");
2469 const char* const computeShaderSource = "#version 310 es\n"
2470 "layout(binding=1) buffer;"
2471 "layout(binding=2) buffer SSBO { vec4 data;};"
2472 "void main (void)\n"
2476 compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2477 if (compileStatus != GL_FALSE)
2478 ctx.fail("Compute Shader should not have compiled: binding point specified for global scope.");
2481 const char* const computeShaderSource = "#version 310 es\n"
2483 " layout(binding=1) vec4 data;"
2484 " layout(binding=2) vec4 moreData[];"
2486 "void main (void)\n"
2490 compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2491 if (compileStatus != GL_FALSE)
2492 ctx.fail("Compute Shader should not have compiled: binding point specified for block member declarations.");
2495 const char* const computeShaderSource = "#version 310 es\n"
2496 "readonly buffer SSBO {vec4 data;} ssbo;"
2497 "void main (void)\n"
2499 "ssbo.data = vec4(1, 1, 1, 1);"
2502 compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2503 if (compileStatus != GL_FALSE)
2504 ctx.fail("Compute Shader should not have compiled: writing to buffer block qualified with readonly.");
2507 const char* const computeShaderSource = "#version 310 es\n"
2508 "writeonly buffer SSBO {vec4 data;} ssbo;"
2509 "void main (void)\n"
2511 "vec4 var = ssbo.data;"
2514 compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2515 if (compileStatus != GL_FALSE)
2516 ctx.fail("Compute Shader should not have compiled: reading from buffer block qualified with writeonly.");
2522 void srgb_decode_samplerparameteri (NegativeTestContext& ctx)
2524 if (!ctx.isExtensionSupported("GL_EXT_texture_sRGB_decode"))
2525 TCU_THROW(NotSupportedError, "GL_EXT_texture_sRGB_decode is not supported.");
2527 GLuint sampler = 0x1234;
2528 GLint samplerMode = -1;
2530 ctx.glGenSamplers(1, &sampler);
2532 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).");
2533 ctx.glSamplerParameteri(sampler, GL_TEXTURE_SRGB_DECODE_EXT, samplerMode);
2534 ctx.expectError(GL_INVALID_ENUM);
2537 ctx.glDeleteSamplers(1, &sampler);
2540 void srgb_decode_samplerparameterf (NegativeTestContext& ctx)
2542 if (!ctx.isExtensionSupported("GL_EXT_texture_sRGB_decode"))
2543 TCU_THROW(NotSupportedError, "GL_EXT_texture_sRGB_decode is not supported.");
2545 GLuint sampler = 0x1234;
2546 GLfloat samplerMode = -1.0f;
2548 ctx.glGenSamplers(1, &sampler);
2550 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).");
2551 ctx.glSamplerParameterf(sampler, GL_TEXTURE_SRGB_DECODE_EXT, samplerMode);
2552 ctx.expectError(GL_INVALID_ENUM);
2555 ctx.glDeleteSamplers(1, &sampler);
2558 void srgb_decode_samplerparameteriv (NegativeTestContext& ctx)
2560 if (!ctx.isExtensionSupported("GL_EXT_texture_sRGB_decode"))
2561 TCU_THROW(NotSupportedError, "GL_EXT_texture_sRGB_decode is not supported.");
2563 int params[1] = { GL_LINEAR };
2564 GLuint sampler = 0x1234;
2566 ctx.glGenSamplers(1, &sampler);
2568 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).");
2570 ctx.glSamplerParameteriv(sampler, GL_TEXTURE_SRGB_DECODE_EXT, ¶ms[0]);
2571 ctx.expectError(GL_INVALID_ENUM);
2574 ctx.glDeleteSamplers(1, &sampler);
2577 void srgb_decode_samplerparameterfv (NegativeTestContext& ctx)
2579 if (!ctx.isExtensionSupported("GL_EXT_texture_sRGB_decode"))
2580 TCU_THROW(NotSupportedError, "GL_EXT_texture_sRGB_decode is not supported.");
2582 float params[1] = { GL_LINEAR };
2583 GLuint sampler = 0x1234;
2585 ctx.glGenSamplers(1, &sampler);
2588 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).");
2589 ctx.glSamplerParameterfv(sampler, GL_TEXTURE_SRGB_DECODE_EXT, ¶ms[0]);
2590 ctx.expectError(GL_INVALID_ENUM);
2593 ctx.glDeleteSamplers(1, &sampler);
2596 void srgb_decode_samplerparameterIiv (NegativeTestContext& ctx)
2598 if (!supportsES32orGL45(ctx))
2599 TCU_THROW(NotSupportedError, "glSamplerParameterIiv is not supported.");
2601 if (!ctx.isExtensionSupported("GL_EXT_texture_sRGB_decode"))
2602 TCU_THROW(NotSupportedError, "GL_EXT_texture_sRGB_decode is not supported.");
2604 GLint samplerMode[] = {GL_DEPTH_COMPONENT, GL_STENCIL_INDEX};
2605 GLuint sampler = 0x1234;
2607 ctx.glGenSamplers(1, &sampler);
2609 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).");
2610 samplerMode[0] = -1;
2611 samplerMode[1] = -1;
2612 ctx.glSamplerParameterIiv(sampler, GL_TEXTURE_SRGB_DECODE_EXT, samplerMode);
2613 ctx.expectError(GL_INVALID_ENUM);
2616 ctx.glDeleteSamplers(1, &sampler);
2619 void srgb_decode_samplerparameterIuiv (NegativeTestContext& ctx)
2621 if (!supportsES32orGL45(ctx))
2622 TCU_THROW(NotSupportedError, "glSamplerParameterIuiv is not supported.");
2624 if (!ctx.isExtensionSupported("GL_EXT_texture_sRGB_decode"))
2625 TCU_THROW(NotSupportedError, "GL_EXT_texture_sRGB_decode is not supported.");
2627 GLuint samplerMode[] = {GL_DEPTH_COMPONENT, GL_STENCIL_INDEX};
2628 GLuint sampler = 0x1234;
2630 ctx.glGenSamplers(1, &sampler);
2632 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).");
2633 samplerMode[0] = GL_DONT_CARE;
2634 samplerMode[1] = GL_DONT_CARE;
2635 ctx.glSamplerParameterIuiv(sampler, GL_TEXTURE_SRGB_DECODE_EXT, samplerMode);
2636 ctx.expectError(GL_INVALID_ENUM);
2639 ctx.glDeleteSamplers(1, &sampler);
2642 std::vector<FunctionContainer> getNegativeShaderApiTestFunctions ()
2644 FunctionContainer funcs[] =
2646 {create_shader, "create_shader", "Invalid glCreateShader() usage" },
2647 {shader_source, "shader_source", "Invalid glShaderSource() usage" },
2648 {compile_shader, "compile_shader", "Invalid glCompileShader() usage" },
2649 {delete_shader, "delete_shader", "Invalid glDeleteShader() usage" },
2650 {shader_binary, "shader_binary", "Invalid glShaderBinary() usage" },
2651 {attach_shader, "attach_shader", "Invalid glAttachShader() usage" },
2652 {detach_shader, "detach_shader", "Invalid glDetachShader() usage" },
2653 {link_program, "link_program", "Invalid glLinkProgram() usage" },
2654 {use_program, "use_program", "Invalid glUseProgram() usage" },
2655 {delete_program, "delete_program", "Invalid glDeleteProgram() usage" },
2656 {validate_program, "validate_program", "Invalid glValidateProgram() usage" },
2657 {get_program_binary, "get_program_binary", "Invalid glGetProgramBinary() usage" },
2658 {program_binary, "program_binary", "Invalid glProgramBinary() usage" },
2659 {program_parameteri, "program_parameteri", "Invalid glProgramParameteri() usage" },
2660 {gen_samplers, "gen_samplers", "Invalid glGenSamplers() usage" },
2661 {bind_sampler, "bind_sampler", "Invalid glBindSampler() usage" },
2662 {delete_samplers, "delete_samplers", "Invalid glDeleteSamplers() usage" },
2663 {get_sampler_parameteriv, "get_sampler_parameteriv", "Invalid glGetSamplerParameteriv() usage" },
2664 {get_sampler_parameterfv, "get_sampler_parameterfv", "Invalid glGetSamplerParameterfv() usage" },
2665 {get_sampler_parameterIiv, "get_sampler_parameterIiv", "Invalid glGetSamplerParameterIiv() usage" },
2666 {get_sampler_parameterIuiv, "get_sampler_parameterIuiv", "Invalid glGetSamplerParameterIuiv() usage" },
2667 {sampler_parameteri, "sampler_parameteri", "Invalid glSamplerParameteri() usage" },
2668 {sampler_parameteriv, "sampler_parameteriv", "Invalid glSamplerParameteriv() usage" },
2669 {sampler_parameterf, "sampler_parameterf", "Invalid glSamplerParameterf() usage" },
2670 {sampler_parameterfv, "sampler_parameterfv", "Invalid glSamplerParameterfv() usage" },
2671 {sampler_parameterIiv, "sampler_parameterIiv", "Invalid glSamplerParameterIiv() usage" },
2672 {sampler_parameterIuiv, "sampler_parameterIuiv", "Invalid glSamplerParameterIuiv() usage" },
2673 {get_attrib_location, "get_attrib_location", "Invalid glGetAttribLocation() usage" },
2674 {get_uniform_location, "get_uniform_location", "Invalid glGetUniformLocation() usage" },
2675 {bind_attrib_location, "bind_attrib_location", "Invalid glBindAttribLocation() usage" },
2676 {uniform_block_binding, "uniform_block_binding", "Invalid glUniformBlockBinding() usage" },
2677 {uniformf_invalid_program, "uniformf_invalid_program", "Invalid glUniform{1234}f() usage" },
2678 {uniformf_incompatible_type, "uniformf_incompatible_type", "Invalid glUniform{1234}f() usage" },
2679 {uniformf_invalid_location, "uniformf_invalid_location", "Invalid glUniform{1234}f() usage" },
2680 {uniformfv_invalid_program, "uniformfv_invalid_program", "Invalid glUniform{1234}fv() usage" },
2681 {uniformfv_incompatible_type, "uniformfv_incompatible_type", "Invalid glUniform{1234}fv() usage" },
2682 {uniformfv_invalid_location, "uniformfv_invalid_location", "Invalid glUniform{1234}fv() usage" },
2683 {uniformfv_invalid_count, "uniformfv_invalid_count", "Invalid glUniform{1234}fv() usage" },
2684 {uniformi_invalid_program, "uniformi_invalid_program", "Invalid glUniform{1234}i() usage" },
2685 {uniformi_incompatible_type, "uniformi_incompatible_type", "Invalid glUniform{1234}i() usage" },
2686 {uniformi_invalid_location, "uniformi_invalid_location", "Invalid glUniform{1234}i() usage" },
2687 {uniformiv_invalid_program, "uniformiv_invalid_program", "Invalid glUniform{1234}iv() usage" },
2688 {uniformiv_incompatible_type, "uniformiv_incompatible_type", "Invalid glUniform{1234}iv() usage" },
2689 {uniformiv_invalid_location, "uniformiv_invalid_location", "Invalid glUniform{1234}iv() usage" },
2690 {uniformiv_invalid_count, "uniformiv_invalid_count", "Invalid glUniform{1234}iv() usage" },
2691 {uniformui_invalid_program, "uniformui_invalid_program", "Invalid glUniform{234}ui() usage" },
2692 {uniformui_incompatible_type, "uniformui_incompatible_type", "Invalid glUniform{1234}ui() usage" },
2693 {uniformui_invalid_location, "uniformui_invalid_location", "Invalid glUniform{1234}ui() usage" },
2694 {uniformuiv_invalid_program, "uniformuiv_invalid_program", "Invalid glUniform{234}uiv() usage" },
2695 {uniformuiv_incompatible_type, "uniformuiv_incompatible_type", "Invalid glUniform{1234}uiv() usage" },
2696 {uniformuiv_invalid_location, "uniformuiv_invalid_location", "Invalid glUniform{1234}uiv() usage" },
2697 {uniformuiv_invalid_count, "uniformuiv_invalid_count", "Invalid glUniform{1234}uiv() usage" },
2698 {uniform_matrixfv_invalid_program, "uniform_matrixfv_invalid_program", "Invalid glUniformMatrix{234}fv() usage" },
2699 {uniform_matrixfv_incompatible_type, "uniform_matrixfv_incompatible_type", "Invalid glUniformMatrix{234}fv() usage" },
2700 {uniform_matrixfv_invalid_location, "uniform_matrixfv_invalid_location", "Invalid glUniformMatrix{234}fv() usage" },
2701 {uniform_matrixfv_invalid_count, "uniform_matrixfv_invalid_count", "Invalid glUniformMatrix{234}fv() usage" },
2702 {gen_transform_feedbacks, "gen_transform_feedbacks", "Invalid glGenTransformFeedbacks() usage" },
2703 {bind_transform_feedback, "bind_transform_feedback", "Invalid glBindTransformFeedback() usage" },
2704 {delete_transform_feedbacks, "delete_transform_feedbacks", "Invalid glDeleteTransformFeedbacks() usage" },
2705 {begin_transform_feedback, "begin_transform_feedback", "Invalid glBeginTransformFeedback() usage" },
2706 {pause_transform_feedback, "pause_transform_feedback", "Invalid glPauseTransformFeedback() usage" },
2707 {resume_transform_feedback, "resume_transform_feedback", "Invalid glResumeTransformFeedback() usage" },
2708 {end_transform_feedback, "end_transform_feedback", "Invalid glEndTransformFeedback() usage" },
2709 {get_transform_feedback_varying, "get_transform_feedback_varying", "Invalid glGetTransformFeedbackVarying() usage"},
2710 {transform_feedback_varyings, "transform_feedback_varyings", "Invalid glTransformFeedbackVaryings() usage" },
2711 {compile_compute_shader, "compile_compute_shader", "Invalid Compute Shader compilation" },
2712 {link_compute_shader, "link_compute_shader", "Invalid Compute Shader linkage" },
2713 {srgb_decode_samplerparameteri, "srgb_decode_samplerparameteri", "Invalid glSamplerParameteri() usage srgb" },
2714 {srgb_decode_samplerparameterf, "srgb_decode_samplerparameterf", "Invalid glSamplerParameterf() usage srgb" },
2715 {srgb_decode_samplerparameteriv, "srgb_decode_samplerparameteriv", "Invalid glSamplerParameteriv() usage srgb" },
2716 {srgb_decode_samplerparameterfv, "srgb_decode_samplerparameterfv", "Invalid glSamplerParameterfv() usage srgb" },
2717 {srgb_decode_samplerparameterIiv, "srgb_decode_samplerparameterIiv", "Invalid glSamplerParameterIiv() usage srgb" },
2718 {srgb_decode_samplerparameterIuiv, "srgb_decode_samplerparameterIuiv", "Invalid glSamplerParameterIiuv() usage srgb" },
2721 return std::vector<FunctionContainer>(DE_ARRAY_BEGIN(funcs), DE_ARRAY_END(funcs));
2724 } // NegativeTestShared