• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program OpenGL ES 3.1 Module
3  * -------------------------------------------------
4  *
5  * Copyright 2014 The Android Open Source Project
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  *//*!
20  * \file
21  * \brief Negative Buffer API tests.
22  *//*--------------------------------------------------------------------*/
23 
24 #include "es31fNegativeBufferApiTests.hpp"
25 
26 #include "gluCallLogWrapper.hpp"
27 
28 #include "glwDefs.hpp"
29 #include "glwEnums.hpp"
30 
31 namespace deqp
32 {
33 namespace gles31
34 {
35 namespace Functional
36 {
37 namespace NegativeTestShared
38 {
39 
40 using tcu::TestLog;
41 using glu::CallLogWrapper;
42 using namespace glw;
43 
44 // Buffers
bind_buffer(NegativeTestContext & ctx)45 void bind_buffer (NegativeTestContext& ctx)
46 {
47 	ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the allowable values.");
48 	ctx.glBindBuffer(-1, 0);
49 	ctx.expectError(GL_INVALID_ENUM);
50 	ctx.endSection();
51 }
52 
delete_buffers(NegativeTestContext & ctx)53 void delete_buffers (NegativeTestContext& ctx)
54 {
55 	ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
56 	ctx.glDeleteBuffers(-1, 0);
57 	ctx.expectError(GL_INVALID_VALUE);
58 	ctx.endSection();
59 }
60 
gen_buffers(NegativeTestContext & ctx)61 void gen_buffers (NegativeTestContext& ctx)
62 {
63 	ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
64 	ctx.glGenBuffers(-1, 0);
65 	ctx.expectError(GL_INVALID_VALUE);
66 	ctx.endSection();
67 }
68 
buffer_data(NegativeTestContext & ctx)69 void buffer_data (NegativeTestContext& ctx)
70 {
71 	GLuint buffer = 0x1234;
72 	ctx.glGenBuffers(1, &buffer);
73 	ctx.glBindBuffer(GL_ARRAY_BUFFER, buffer);
74 
75 	ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER.");
76 	ctx.glBufferData(-1, 0, NULL, GL_STREAM_DRAW);
77 	ctx.expectError(GL_INVALID_ENUM);
78 	ctx.endSection();
79 
80 	ctx.beginSection("GL_INVALID_ENUM is generated if usage is not GL_STREAM_DRAW, GL_STATIC_DRAW, or GL_DYNAMIC_DRAW.");
81 	ctx.glBufferData(GL_ARRAY_BUFFER, 0, NULL, -1);
82 	ctx.expectError(GL_INVALID_ENUM);
83 	ctx.endSection();
84 
85 	ctx.beginSection("GL_INVALID_VALUE is generated if size is negative.");
86 	ctx.glBufferData(GL_ARRAY_BUFFER, -1, NULL, GL_STREAM_DRAW);
87 	ctx.expectError(GL_INVALID_VALUE);
88 	ctx.endSection();
89 
90 	ctx.beginSection("GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.");
91 	ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
92 	ctx.glBufferData(GL_ARRAY_BUFFER, 0, NULL, GL_STREAM_DRAW);
93 	ctx.expectError(GL_INVALID_OPERATION);
94 	ctx.endSection();
95 
96 	ctx.glDeleteBuffers(1, &buffer);
97 }
98 
buffer_sub_data(NegativeTestContext & ctx)99 void buffer_sub_data (NegativeTestContext& ctx)
100 {
101 	GLuint buffer = 0x1234;
102 	ctx.glGenBuffers(1, &buffer);
103 	ctx.glBindBuffer(GL_ARRAY_BUFFER, buffer);
104 	ctx.glBufferData(GL_ARRAY_BUFFER, 10, 0, GL_STREAM_DRAW);
105 
106 	ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER.");
107 	ctx.glBufferSubData(-1, 1, 1, 0);
108 	ctx.expectError(GL_INVALID_ENUM);
109 	ctx.endSection();
110 
111 	ctx.beginSection("GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.");
112 	ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
113 	ctx.glBufferSubData(GL_ARRAY_BUFFER, 1, 1, 0);
114 	ctx.expectError(GL_INVALID_OPERATION);
115 	ctx.endSection();
116 
117 	ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer object being updated is mapped.");
118 	ctx.glBindBuffer(GL_ARRAY_BUFFER, buffer);
119 	ctx.glMapBufferRange(GL_ARRAY_BUFFER, 0, 5, GL_MAP_READ_BIT);
120 	ctx.expectError(GL_NO_ERROR);
121 	ctx.glBufferSubData(GL_ARRAY_BUFFER, 1, 1, 0);
122 	ctx.expectError(GL_INVALID_OPERATION);
123 	ctx.endSection();
124 
125 	ctx.glDeleteBuffers(1, &buffer);
126 }
127 
buffer_sub_data_size_offset(NegativeTestContext & ctx)128 void buffer_sub_data_size_offset (NegativeTestContext& ctx)
129 {
130 	GLuint buffer = 0x1234;
131 	ctx.glGenBuffers(1, &buffer);
132 	ctx.glBindBuffer(GL_ARRAY_BUFFER, buffer);
133 	ctx.glBufferData(GL_ARRAY_BUFFER, 10, 0, GL_STREAM_DRAW);
134 
135 	ctx.beginSection("GL_INVALID_VALUE is generated if offset or size is negative, or if together they define a region of memory that extends beyond the buffer object's allocated data store.");
136 	ctx.glBufferSubData(GL_ARRAY_BUFFER, -1, 1, 0);
137 	ctx.expectError(GL_INVALID_VALUE);
138 	ctx.glBufferSubData(GL_ARRAY_BUFFER, -1, -1, 0);
139 	ctx.expectError(GL_INVALID_VALUE);
140 	ctx.glBufferSubData(GL_ARRAY_BUFFER, 1, -1, 0);
141 	ctx.expectError(GL_INVALID_VALUE);
142 	ctx.glBufferSubData(GL_ARRAY_BUFFER, 15, 1, 0);
143 	ctx.expectError(GL_INVALID_VALUE);
144 	ctx.glBufferSubData(GL_ARRAY_BUFFER, 1, 15, 0);
145 	ctx.expectError(GL_INVALID_VALUE);
146 	ctx.glBufferSubData(GL_ARRAY_BUFFER, 8, 8, 0);
147 	ctx.expectError(GL_INVALID_VALUE);
148 	ctx.endSection();
149 
150 	ctx.glDeleteBuffers(1, &buffer);
151 }
152 
clear(NegativeTestContext & ctx)153 void clear (NegativeTestContext& ctx)
154 {
155 	ctx.beginSection("GL_INVALID_VALUE is generated if any bit other than the three defined bits is set in mask.");
156 	ctx.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
157 	ctx.expectError(GL_NO_ERROR);
158 	ctx.glClear(0x00000200);
159 	ctx.expectError(GL_INVALID_VALUE);
160 	ctx.glClear(0x00001000);
161 	ctx.expectError(GL_INVALID_VALUE);
162 	ctx.glClear(0x00000010);
163 	ctx.expectError(GL_INVALID_VALUE);
164 	ctx.endSection();
165 }
166 
read_pixels(NegativeTestContext & ctx)167 void read_pixels (NegativeTestContext& ctx)
168 {
169 	std::vector<GLubyte>	ubyteData	(4);
170 	GLuint					fbo			= 0x1234;
171 
172 	ctx.beginSection("GL_INVALID_OPERATION is generated if the combination of format and type is unsupported.");
173 	ctx.glReadPixels(0, 0, 1, 1, GL_LUMINANCE_ALPHA, GL_UNSIGNED_SHORT_4_4_4_4, &ubyteData[0]);
174 	ctx.expectError(GL_INVALID_OPERATION);
175 	ctx.endSection();
176 
177 	ctx.beginSection("GL_INVALID_VALUE is generated if either width or height is negative.");
178 	ctx.glReadPixels(0, 0, -1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
179 	ctx.expectError(GL_INVALID_VALUE);
180 	ctx.glReadPixels(0, 0, 1, -1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
181 	ctx.expectError(GL_INVALID_VALUE);
182 	ctx.glReadPixels(0, 0, -1, -1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
183 	ctx.expectError(GL_INVALID_VALUE);
184 	ctx.endSection();
185 
186 	ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
187 	ctx.glGenFramebuffers(1, &fbo);
188 	ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
189 	ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
190 	ctx.glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
191 	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
192 	ctx.endSection();
193 
194 	ctx.glDeleteFramebuffers(1, &fbo);
195 }
196 
readn_pixels(NegativeTestContext & ctx)197 void readn_pixels (NegativeTestContext& ctx)
198 {
199 	std::vector<GLfloat>	floatData	(4);
200 	std::vector<GLubyte>	ubyteData	(4);
201 	GLuint					fbo			= 0x1234;
202 
203 	if (!contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2))
204 		&& !ctx.isExtensionSupported("GL_KHR_robustness")
205 		&& !ctx.isExtensionSupported("GL_EXT_robustness"))
206 	{
207 		TCU_THROW(NotSupportedError, "GLES 3.2 or robustness extension not supported");
208 	}
209 
210 	ctx.beginSection("GL_INVALID_OPERATION is generated if the combination of format and type is unsupported.");
211 	ctx.glReadnPixels(0, 0, 1, 1, GL_LUMINANCE_ALPHA, GL_UNSIGNED_SHORT_4_4_4_4, (int) ubyteData.size(), &ubyteData[0]);
212 	ctx.expectError(GL_INVALID_OPERATION);
213 	ctx.endSection();
214 
215 	ctx.beginSection("GL_INVALID_VALUE is generated if either width or height is negative.");
216 	ctx.glReadnPixels(0, 0, -1, 1, GL_RGBA, GL_UNSIGNED_BYTE, (int) ubyteData.size(), &ubyteData[0]);
217 	ctx.expectError(GL_INVALID_VALUE);
218 	ctx.glReadnPixels(0, 0, 1, -1, GL_RGBA, GL_UNSIGNED_BYTE, (int) ubyteData.size(), &ubyteData[0]);
219 	ctx.expectError(GL_INVALID_VALUE);
220 	ctx.glReadnPixels(0, 0, -1, -1, GL_RGBA, GL_UNSIGNED_BYTE, (int) ubyteData.size(), &ubyteData[0]);
221 	ctx.expectError(GL_INVALID_VALUE);
222 	ctx.endSection();
223 
224 	ctx.beginSection("GL_INVALID_OPERATION is generated by ReadnPixels if the buffer size required to store the requested data is larger than bufSize.");
225 	ctx.glReadnPixels(0, 0, 0x1234, 0x1234, GL_RGBA, GL_UNSIGNED_BYTE, (int) ubyteData.size(), &ubyteData[0]);
226 	ctx.expectError(GL_INVALID_OPERATION);
227 	ctx.glReadnPixels(0, 0, 1, 1, GL_RGBA, GL_FLOAT, (int) floatData.size(), &floatData[0]);
228 	ctx.expectError(GL_INVALID_OPERATION);
229 	ctx.endSection();
230 
231 	ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
232 	ctx.glGenFramebuffers(1, &fbo);
233 	ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
234 	ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
235 	ctx.glReadnPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, (int) ubyteData.size(), &ubyteData[0]);
236 	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
237 	ctx.endSection();
238 
239 	ctx.glDeleteFramebuffers(1, &fbo);
240 }
241 
read_pixels_format_mismatch(NegativeTestContext & ctx)242 void read_pixels_format_mismatch (NegativeTestContext& ctx)
243 {
244 	std::vector<GLubyte>	ubyteData	(4);
245 	std::vector<GLushort>	ushortData	(4);
246 	GLint					readFormat	= 0x1234;
247 	GLint					readType	= 0x1234;
248 
249 	ctx.beginSection("Unsupported combinations of format and type will generate an GL_INVALID_OPERATION error.");
250 	ctx.glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_SHORT_5_6_5, &ushortData[0]);
251 	ctx.expectError(GL_INVALID_OPERATION);
252 	ctx.glReadPixels(0, 0, 1, 1, GL_ALPHA, GL_UNSIGNED_SHORT_5_6_5, &ushortData[0]);
253 	ctx.expectError(GL_INVALID_OPERATION);
254 	ctx.glReadPixels(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, &ushortData[0]);
255 	ctx.expectError(GL_INVALID_OPERATION);
256 	ctx.glReadPixels(0, 0, 1, 1, GL_ALPHA, GL_UNSIGNED_SHORT_4_4_4_4, &ushortData[0]);
257 	ctx.expectError(GL_INVALID_OPERATION);
258 	ctx.glReadPixels(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, &ushortData[0]);
259 	ctx.expectError(GL_INVALID_OPERATION);
260 	ctx.glReadPixels(0, 0, 1, 1, GL_ALPHA, GL_UNSIGNED_SHORT_5_5_5_1, &ushortData[0]);
261 	ctx.expectError(GL_INVALID_OPERATION);
262 	ctx.endSection();
263 
264 	ctx.beginSection("GL_RGBA/GL_UNSIGNED_BYTE is always accepted and the other acceptable pair can be discovered by querying GL_IMPLEMENTATION_COLOR_READ_FORMAT and GL_IMPLEMENTATION_COLOR_READ_TYPE.");
265 	ctx.glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
266 	ctx.expectError(GL_NO_ERROR);
267 	ctx.glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &readFormat);
268 	ctx.glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &readType);
269 	ctx.glReadPixels(0, 0, 1, 1, readFormat, readType, &ubyteData[0]);
270 	ctx.expectError(GL_NO_ERROR);
271 	ctx.endSection();
272 }
273 
read_pixels_fbo_format_mismatch(NegativeTestContext & ctx)274 void read_pixels_fbo_format_mismatch (NegativeTestContext& ctx)
275 {
276 	std::vector<GLubyte>	ubyteData(4);
277 	std::vector<float>		floatData(4);
278 	deUint32				fbo = 0x1234;
279 	deUint32				texture = 0x1234;
280 
281 	ctx.glGenTextures			(1, &texture);
282 	ctx.glBindTexture			(GL_TEXTURE_2D, texture);
283 	ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
284 	ctx.glGenFramebuffers		(1, &fbo);
285 	ctx.glBindFramebuffer		(GL_FRAMEBUFFER, fbo);
286 	ctx.glFramebufferTexture2D	(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
287 	ctx.expectError				(GL_NO_ERROR);
288 
289 	ctx.beginSection("GL_INVALID_OPERATION is generated if currently bound framebuffer format is incompatible with format and type.");
290 
291 	ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
292 	ctx.glFramebufferTexture2D	(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
293 	ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
294 	ctx.expectError				(GL_NO_ERROR);
295 	ctx.glReadPixels			(0, 0, 1, 1, GL_RGBA, GL_FLOAT, &floatData[0]);
296 	ctx.expectError				(GL_INVALID_OPERATION);
297 
298 	ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL);
299 	ctx.glFramebufferTexture2D	(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
300 	ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
301 	ctx.expectError				(GL_NO_ERROR);
302 	ctx.glReadPixels			(0, 0, 1, 1, GL_RGBA, GL_FLOAT, &floatData[0]);
303 	ctx.expectError				(GL_INVALID_OPERATION);
304 
305 	ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
306 	ctx.glFramebufferTexture2D	(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
307 	ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
308 	ctx.expectError				(GL_NO_ERROR);
309 	ctx.glReadPixels			(0, 0, 1, 1, GL_RGBA, GL_FLOAT, &floatData[0]);
310 	ctx.expectError				(GL_INVALID_OPERATION);
311 
312 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) ||
313 		ctx.isExtensionSupported("GL_EXT_color_buffer_float"))
314 	{
315 		ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA32F, 32, 32, 0, GL_RGBA, GL_FLOAT, NULL);
316 		ctx.expectError				(GL_NO_ERROR);
317 		ctx.glFramebufferTexture2D	(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
318 		ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
319 		ctx.expectError				(GL_NO_ERROR);
320 		ctx.glReadPixels			(0, 0, 1, 1, GL_RGBA, GL_INT, &floatData[0]);
321 		ctx.expectError				(GL_INVALID_OPERATION);
322 	}
323 
324 	ctx.endSection();
325 
326 	ctx.beginSection("GL_INVALID_OPERATION is generated if GL_READ_FRAMEBUFFER_BINDING is non-zero, the read framebuffer is complete, and the value of GL_SAMPLE_BUFFERS for the read framebuffer is greater than zero.");
327 
328 	int			binding			= -1;
329 	int			sampleBuffers = 0x1234;
330 	deUint32	rbo = 0x1234;
331 
332 	ctx.glGenRenderbuffers(1, &rbo);
333 	ctx.glBindRenderbuffer(GL_RENDERBUFFER, rbo);
334 	ctx.glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA8, 32, 32);
335 	ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo);
336 
337 	ctx.glGetIntegerv			(GL_READ_FRAMEBUFFER_BINDING, &binding);
338 	ctx.getLog() << TestLog::Message << "// GL_READ_FRAMEBUFFER_BINDING: " << binding << TestLog::EndMessage;
339 	ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
340 	ctx.glGetIntegerv			(GL_SAMPLE_BUFFERS, &sampleBuffers);
341 	ctx.getLog() << TestLog::Message << "// GL_SAMPLE_BUFFERS: " << sampleBuffers << TestLog::EndMessage;
342 	ctx.expectError				(GL_NO_ERROR);
343 
344 	if (binding == 0 || sampleBuffers <= 0)
345 	{
346 		ctx.getLog() << TestLog::Message << "// ERROR: expected GL_READ_FRAMEBUFFER_BINDING to be non-zero and GL_SAMPLE_BUFFERS to be greater than zero" << TestLog::EndMessage;
347 		ctx.fail("Got invalid value");
348 	}
349 	else
350 	{
351 		ctx.glReadPixels	(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
352 		ctx.expectError		(GL_INVALID_OPERATION);
353 	}
354 
355 	ctx.endSection();
356 
357 	ctx.glBindRenderbuffer		(GL_RENDERBUFFER, 0);
358 	ctx.glBindTexture			(GL_TEXTURE_2D, 0);
359 	ctx.glBindFramebuffer		(GL_FRAMEBUFFER, 0);
360 	ctx.glDeleteFramebuffers	(1, &fbo);
361 	ctx.glDeleteTextures		(1, &texture);
362 	ctx.glDeleteRenderbuffers	(1, &rbo);
363 }
364 
bind_buffer_range(NegativeTestContext & ctx)365 void bind_buffer_range (NegativeTestContext& ctx)
366 {
367 	deUint32	bufAC		= 0x1234;
368 	deUint32	bufU		= 0x1234;
369 	deUint32	bufTF		= 0x1234;
370 	int			maxTFSize	= 0x1234;
371 	int			maxUSize	= 0x1234;
372 	int			uAlignment	= 0x1234;
373 
374 	ctx.glGenBuffers(1, &bufU);
375 	ctx.glBindBuffer(GL_UNIFORM_BUFFER, bufU);
376 	ctx.glBufferData(GL_UNIFORM_BUFFER, 16, NULL, GL_STREAM_DRAW);
377 
378 	ctx.glGenBuffers(1, &bufTF);
379 	ctx.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, bufTF);
380 	ctx.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 16, NULL, GL_STREAM_DRAW);
381 
382 	ctx.glGenBuffers(1, &bufAC);
383 	ctx.glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, bufAC);
384 	ctx.glBufferData(GL_ATOMIC_COUNTER_BUFFER, 16, NULL, GL_STREAM_DRAW);
385 
386 	ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_ATOMIC_COUNTER_BUFFER, GL_SHADER_STORAGE_BUFFER, GL_TRANSFORM_FEEDBACK_BUFFER or GL_UNIFORM_BUFFER.");
387 	ctx.glBindBufferRange(GL_ARRAY_BUFFER, 0, bufU, 0, 4);
388 	ctx.expectError(GL_INVALID_ENUM);
389 	ctx.endSection();
390 
391 	ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_TRANSFORM_FEEDBACK_BUFFER and index is greater than or equal to GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS.");
392 	ctx.glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &maxTFSize);
393 	ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, maxTFSize, bufTF, 0, 4);
394 	ctx.expectError(GL_INVALID_VALUE);
395 	ctx.endSection();
396 
397 	ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_UNIFORM_BUFFER and index is greater than or equal to GL_MAX_UNIFORM_BUFFER_BINDINGS.");
398 	ctx.glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUSize);
399 	ctx.glBindBufferRange(GL_UNIFORM_BUFFER, maxUSize, bufU, 0, 4);
400 	ctx.expectError(GL_INVALID_VALUE);
401 	ctx.endSection();
402 
403 	ctx.beginSection("GL_INVALID_VALUE is generated if size is less than or equal to zero.");
404 	ctx.glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, 0, -1);
405 	ctx.expectError(GL_INVALID_VALUE);
406 	ctx.glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, 0, 0);
407 	ctx.expectError(GL_INVALID_VALUE);
408 	ctx.endSection();
409 
410 	ctx.beginSection("GL_INVALID_VALUE is generated if offset is less than zero.");
411 	ctx.glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, -1, 0);
412 	ctx.expectError(GL_INVALID_VALUE);
413 	ctx.endSection();
414 
415 	ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_TRANSFORM_FEEDBACK_BUFFER and size or offset are not multiples of 4.");
416 	ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, bufTF, 4, 5);
417 	ctx.expectError(GL_INVALID_VALUE);
418 	ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, bufTF, 5, 4);
419 	ctx.expectError(GL_INVALID_VALUE);
420 	ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, bufTF, 5, 7);
421 	ctx.expectError(GL_INVALID_VALUE);
422 	ctx.endSection();
423 
424 	ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_UNIFORM_BUFFER and offset is not a multiple of GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT.");
425 	ctx.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &uAlignment);
426 	ctx.glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, uAlignment+1, 4);
427 	ctx.expectError(GL_INVALID_VALUE);
428 	ctx.endSection();
429 
430 	int maxACize	= 0x1234;
431 	int maxSSize	= 0x1234;
432 	int ssAlignment	= 0x1234;
433 
434 	ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_ATOMIC_COUNTER_BUFFER and index is greater than or equal to GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS.");
435 	ctx.glGetIntegerv(GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS, &maxACize);
436 	ctx.glBindBufferRange(GL_ATOMIC_COUNTER_BUFFER, maxACize, bufU, 0, 4);
437 	ctx.expectError(GL_INVALID_VALUE);
438 	ctx.endSection();
439 
440 	ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_SHADER_STORAGE_BUFFER and index is greater than or equal to GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS.");
441 	ctx.glGetIntegerv(GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS, &maxSSize);
442 	ctx.glBindBufferRange(GL_SHADER_STORAGE_BUFFER, maxSSize, bufU, 0, 4);
443 	ctx.expectError(GL_INVALID_VALUE);
444 	ctx.endSection();
445 
446 	ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_ATOMIC_COUNTER_BUFFER and offset is not multiples of 4.");
447 	ctx.glBindBufferRange(GL_ATOMIC_COUNTER_BUFFER, 0, bufTF, 5, 4);
448 	ctx.expectError(GL_INVALID_VALUE);
449 	ctx.endSection();
450 
451 	ctx.glGetIntegerv(GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT, &ssAlignment);
452 
453 	if (ssAlignment != 1)
454 	{
455 		ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_SHADER_STORAGE_BUFFER and offset is not a multiple of the value of GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT.");
456 		ctx.glBindBufferRange(GL_SHADER_STORAGE_BUFFER, 0, bufTF, ssAlignment+1, 4);
457 		ctx.expectError(GL_INVALID_VALUE);
458 		ctx.endSection();
459 	}
460 
461 	ctx.glDeleteBuffers(1, &bufU);
462 	ctx.glDeleteBuffers(1, &bufTF);
463 	ctx.glDeleteBuffers(1, &bufAC);
464 }
465 
bind_buffer_base(NegativeTestContext & ctx)466 void bind_buffer_base (NegativeTestContext& ctx)
467 {
468 	deUint32	bufU		= 0x1234;
469 	deUint32	bufTF		= 0x1234;
470 	int			maxUSize	= 0x1234;
471 	int			maxTFSize	= 0x1234;
472 
473 	ctx.glGenBuffers(1, &bufU);
474 	ctx.glBindBuffer(GL_UNIFORM_BUFFER, bufU);
475 	ctx.glBufferData(GL_UNIFORM_BUFFER, 16, NULL, GL_STREAM_DRAW);
476 
477 	ctx.glGenBuffers(1, &bufTF);
478 	ctx.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, bufTF);
479 	ctx.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 16, NULL, GL_STREAM_DRAW);
480 	ctx.expectError(GL_NO_ERROR);
481 
482 	ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_ATOMIC_COUNTER_BUFFER, GL_SHADER_STORAGE_BUFFER, GL_TRANSFORM_FEEDBACK_BUFFER or GL_UNIFORM_BUFFER.");
483 	ctx.glBindBufferBase(-1, 0, bufU);
484 	ctx.expectError(GL_INVALID_ENUM);
485 	ctx.glBindBufferBase(GL_ARRAY_BUFFER, 0, bufU);
486 	ctx.expectError(GL_INVALID_ENUM);
487 	ctx.endSection();
488 
489 	ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_UNIFORM_BUFFER and index is greater than or equal to GL_MAX_UNIFORM_BUFFER_BINDINGS.");
490 	ctx.glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUSize);
491 	ctx.glBindBufferBase(GL_UNIFORM_BUFFER, maxUSize, bufU);
492 	ctx.expectError(GL_INVALID_VALUE);
493 	ctx.endSection();
494 
495 	ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_TRANSFORM_FEEDBACK_BUFFER andindex is greater than or equal to GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS.");
496 	ctx.glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &maxTFSize);
497 	ctx.glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, maxTFSize, bufTF);
498 	ctx.expectError(GL_INVALID_VALUE);
499 	ctx.endSection();
500 
501 	ctx.glDeleteBuffers(1, &bufU);
502 	ctx.glDeleteBuffers(1, &bufTF);
503 }
504 
clear_bufferiv(NegativeTestContext & ctx)505 void clear_bufferiv (NegativeTestContext& ctx)
506 {
507 	std::vector<int>	data			(32*32);
508 	deUint32			fbo				= 0x1234;
509 	deUint32			texture			= 0x1234;
510 	int					maxDrawBuffers	= 0x1234;
511 
512 	ctx.glGenTextures			(1, &texture);
513 	ctx.glBindTexture			(GL_TEXTURE_2D, texture);
514 	ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL);
515 	ctx.glGenFramebuffers		(1, &fbo);
516 	ctx.glBindFramebuffer		(GL_FRAMEBUFFER, fbo);
517 	ctx.glFramebufferTexture2D	(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
518 	ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
519 	ctx.expectError				(GL_NO_ERROR);
520 
521 	ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not an accepted value.");
522 	ctx.glClearBufferiv			(-1, 0, &data[0]);
523 	ctx.expectError				(GL_INVALID_ENUM);
524 	ctx.glClearBufferiv			(GL_FRAMEBUFFER, 0, &data[0]);
525 	ctx.expectError				(GL_INVALID_ENUM);
526 	ctx.endSection();
527 
528 	ctx.beginSection("GL_INVALID_ENUM is generated if buffer is GL_DEPTH or GL_DEPTH_STENCIL.");
529 	ctx.glClearBufferiv			(GL_DEPTH, 1, &data[0]);
530 	ctx.expectError				(GL_INVALID_ENUM);
531 	ctx.glClearBufferiv			(GL_DEPTH_STENCIL, 1, &data[0]);
532 	ctx.expectError				(GL_INVALID_ENUM);
533 	ctx.endSection();
534 
535 	ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR or GL_STENCIL and drawBuffer is greater than or equal to GL_MAX_DRAW_BUFFERS.");
536 	ctx.glGetIntegerv			(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
537 	ctx.glClearBufferiv			(GL_COLOR, maxDrawBuffers, &data[0]);
538 	ctx.expectError				(GL_INVALID_VALUE);
539 	ctx.endSection();
540 
541 	ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR or GL_STENCIL and drawBuffer is negative.");
542 	ctx.glClearBufferiv			(GL_COLOR, -1, &data[0]);
543 	ctx.expectError				(GL_INVALID_VALUE);
544 	ctx.endSection();
545 
546 	ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_STENCIL and drawBuffer is not zero.");
547 	ctx.glClearBufferiv			(GL_STENCIL, 1, &data[0]);
548 	ctx.expectError				(GL_INVALID_VALUE);
549 	ctx.endSection();
550 
551 	ctx.glDeleteFramebuffers	(1, &fbo);
552 	ctx.glDeleteTextures		(1, &texture);
553 }
554 
clear_bufferuiv(NegativeTestContext & ctx)555 void clear_bufferuiv (NegativeTestContext& ctx)
556 {
557 	std::vector<deUint32>	data			(32*32);
558 	deUint32				fbo				= 0x1234;
559 	deUint32				texture			= 0x1234;
560 	int						maxDrawBuffers	= 0x1234;
561 
562 	ctx.glGenTextures			(1, &texture);
563 	ctx.glBindTexture			(GL_TEXTURE_2D, texture);
564 	ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
565 	ctx.glGenFramebuffers		(1, &fbo);
566 	ctx.glBindFramebuffer		(GL_FRAMEBUFFER, fbo);
567 	ctx.glFramebufferTexture2D	(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
568 	ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
569 	ctx.expectError				(GL_NO_ERROR);
570 
571 	ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not GL_COLOR.");
572 	ctx.glClearBufferuiv		(-1, 0, &data[0]);
573 	ctx.expectError				(GL_INVALID_ENUM);
574 	ctx.glClearBufferuiv		(GL_FRAMEBUFFER, 0, &data[0]);
575 	ctx.expectError				(GL_INVALID_ENUM);
576 	ctx.endSection();
577 
578 	ctx.beginSection("GL_INVALID_ENUM is generated if buffer is GL_DEPTH, GL_STENCIL, or GL_DEPTH_STENCIL.");
579 	ctx.glClearBufferuiv		(GL_DEPTH, 0, &data[0]);
580 	ctx.expectError				(GL_INVALID_ENUM);
581 	ctx.glClearBufferuiv		(GL_STENCIL, 0, &data[0]);
582 	ctx.expectError				(GL_INVALID_ENUM);
583 	ctx.glClearBufferuiv		(GL_DEPTH_STENCIL, 0, &data[0]);
584 	ctx.expectError				(GL_INVALID_ENUM);
585 	ctx.endSection();
586 
587 	ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR and drawBuffer is greater than or equal to GL_MAX_DRAW_BUFFERS.");
588 	ctx.glGetIntegerv			(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
589 	ctx.glClearBufferuiv		(GL_COLOR, maxDrawBuffers, &data[0]);
590 	ctx.expectError				(GL_INVALID_VALUE);
591 	ctx.endSection();
592 
593 	ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR and drawBuffer is negative.");
594 	ctx.glClearBufferuiv		(GL_COLOR, -1, &data[0]);
595 	ctx.expectError				(GL_INVALID_VALUE);
596 	ctx.endSection();
597 
598 	ctx.glDeleteFramebuffers	(1, &fbo);
599 	ctx.glDeleteTextures		(1, &texture);
600 }
601 
clear_bufferfv(NegativeTestContext & ctx)602 void clear_bufferfv (NegativeTestContext& ctx)
603 {
604 	std::vector<float>	data			(32*32);
605 	deUint32			fbo				= 0x1234;
606 	deUint32			texture			= 0x1234;
607 	int					maxDrawBuffers	= 0x1234;
608 
609 	ctx.glGenTextures			(1, &texture);
610 	ctx.glBindTexture			(GL_TEXTURE_2D, texture);
611 	ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA32F, 32, 32, 0, GL_RGBA, GL_FLOAT, NULL);
612 	ctx.glGenFramebuffers		(1, &fbo);
613 	ctx.glBindFramebuffer		(GL_FRAMEBUFFER, fbo);
614 	ctx.glFramebufferTexture2D	(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
615 	ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
616 	ctx.expectError				(GL_NO_ERROR);
617 
618 	ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not GL_COLOR or GL_DEPTH.");
619 	ctx.glClearBufferfv			(-1, 0, &data[0]);
620 	ctx.expectError				(GL_INVALID_ENUM);
621 	ctx.glClearBufferfv			(GL_FRAMEBUFFER, 0, &data[0]);
622 	ctx.expectError				(GL_INVALID_ENUM);
623 	ctx.endSection();
624 
625 	ctx.beginSection("GL_INVALID_ENUM is generated if buffer is GL_STENCIL or GL_DEPTH_STENCIL.");
626 	ctx.glClearBufferfv			(GL_STENCIL, 1, &data[0]);
627 	ctx.expectError				(GL_INVALID_ENUM);
628 	ctx.glClearBufferfv			(GL_DEPTH_STENCIL, 1, &data[0]);
629 	ctx.expectError				(GL_INVALID_ENUM);
630 	ctx.endSection();
631 
632 	ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR and drawBuffer is greater than or equal to GL_MAX_DRAW_BUFFERS.");
633 	ctx.glGetIntegerv			(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
634 	ctx.glClearBufferfv			(GL_COLOR, maxDrawBuffers, &data[0]);
635 	ctx.expectError				(GL_INVALID_VALUE);
636 	ctx.endSection();
637 
638 	ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR and drawBuffer is negative.");
639 	ctx.glClearBufferfv			(GL_COLOR, -1, &data[0]);
640 	ctx.expectError				(GL_INVALID_VALUE);
641 	ctx.endSection();
642 
643 	ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_DEPTH and drawBuffer is not zero.");
644 	ctx.glClearBufferfv			(GL_DEPTH, 1, &data[0]);
645 	ctx.expectError				(GL_INVALID_VALUE);
646 	ctx.endSection();
647 
648 	ctx.glDeleteFramebuffers	(1, &fbo);
649 	ctx.glDeleteTextures		(1, &texture);
650 }
651 
clear_bufferfi(NegativeTestContext & ctx)652 void clear_bufferfi (NegativeTestContext& ctx)
653 {
654 	ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not GL_DEPTH_STENCIL.");
655 	ctx.glClearBufferfi		(-1, 0, 1.0f, 1);
656 	ctx.expectError			(GL_INVALID_ENUM);
657 	ctx.glClearBufferfi		(GL_FRAMEBUFFER, 0, 1.0f, 1);
658 	ctx.expectError			(GL_INVALID_ENUM);
659 	ctx.glClearBufferfi		(GL_DEPTH, 0, 1.0f, 1);
660 	ctx.expectError			(GL_INVALID_ENUM);
661 	ctx.glClearBufferfi		(GL_STENCIL, 0, 1.0f, 1);
662 	ctx.expectError			(GL_INVALID_ENUM);
663 	ctx.glClearBufferfi		(GL_COLOR, 0, 1.0f, 1);
664 	ctx.expectError			(GL_INVALID_ENUM);
665 	ctx.endSection();
666 
667 	ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_DEPTH_STENCIL and drawBuffer is not zero.");
668 	ctx.glClearBufferfi		(GL_DEPTH_STENCIL, 1, 1.0f, 1);
669 	ctx.expectError			(GL_INVALID_VALUE);
670 	ctx.endSection();
671 }
672 
copy_buffer_sub_data(NegativeTestContext & ctx)673 void copy_buffer_sub_data (NegativeTestContext& ctx)
674 {
675 	deUint32				buf[2];
676 	std::vector<float>		data	(32*32);
677 
678 	ctx.glGenBuffers			(2, buf);
679 	ctx.glBindBuffer			(GL_COPY_READ_BUFFER, buf[0]);
680 	ctx.glBufferData			(GL_COPY_READ_BUFFER, 32, &data[0], GL_DYNAMIC_COPY);
681 	ctx.glBindBuffer			(GL_COPY_WRITE_BUFFER, buf[1]);
682 	ctx.glBufferData			(GL_COPY_WRITE_BUFFER, 32, &data[0], GL_DYNAMIC_COPY);
683 	ctx.expectError				(GL_NO_ERROR);
684 
685 	ctx.beginSection("GL_INVALID_VALUE is generated if any of readoffset, writeoffset or size is negative.");
686 	ctx.glCopyBufferSubData		(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, -4);
687 	ctx.expectError				(GL_INVALID_VALUE);
688 	ctx.glCopyBufferSubData		(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, -1, 0, 4);
689 	ctx.expectError				(GL_INVALID_VALUE);
690 	ctx.glCopyBufferSubData		(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, -1, 4);
691 	ctx.expectError				(GL_INVALID_VALUE);
692 	ctx.endSection();
693 
694 	ctx.beginSection("GL_INVALID_VALUE is generated if readoffset + size exceeds the size of the buffer object bound to readtarget.");
695 	ctx.glCopyBufferSubData		(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 36);
696 	ctx.expectError				(GL_INVALID_VALUE);
697 	ctx.glCopyBufferSubData		(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 24, 0, 16);
698 	ctx.expectError				(GL_INVALID_VALUE);
699 	ctx.glCopyBufferSubData		(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 36, 0, 4);
700 	ctx.expectError				(GL_INVALID_VALUE);
701 	ctx.endSection();
702 
703 	ctx.beginSection("GL_INVALID_VALUE is generated if writeoffset + size exceeds the size of the buffer object bound to writetarget.");
704 	ctx.glCopyBufferSubData		(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 36);
705 	ctx.expectError				(GL_INVALID_VALUE);
706 	ctx.glCopyBufferSubData		(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 24, 16);
707 	ctx.expectError				(GL_INVALID_VALUE);
708 	ctx.glCopyBufferSubData		(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 36, 4);
709 	ctx.expectError				(GL_INVALID_VALUE);
710 	ctx.endSection();
711 
712 	ctx.beginSection("GL_INVALID_VALUE is generated if the same buffer object is bound to both readtarget and writetarget and the ranges [readoffset, readoffset + size) and [writeoffset, writeoffset + size) overlap.");
713 	ctx.glBindBuffer			(GL_COPY_WRITE_BUFFER, buf[0]);
714 	ctx.glCopyBufferSubData		(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 16, 4);
715 	ctx.expectError				(GL_NO_ERROR);
716 	ctx.glCopyBufferSubData		(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 4);
717 	ctx.expectError				(GL_INVALID_VALUE);
718 	ctx.glCopyBufferSubData		(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 16, 18);
719 	ctx.expectError				(GL_INVALID_VALUE);
720 	ctx.glBindBuffer			(GL_COPY_WRITE_BUFFER, buf[1]);
721 	ctx.endSection();
722 
723 	ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to readtarget or writetarget.");
724 	ctx.glBindBuffer			(GL_COPY_READ_BUFFER, 0);
725 	ctx.glCopyBufferSubData		(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16);
726 	ctx.expectError				(GL_INVALID_OPERATION);
727 
728 	ctx.glBindBuffer			(GL_COPY_READ_BUFFER, buf[0]);
729 	ctx.glBindBuffer			(GL_COPY_WRITE_BUFFER, 0);
730 	ctx.glCopyBufferSubData		(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16);
731 	ctx.expectError				(GL_INVALID_OPERATION);
732 
733 	ctx.glBindBuffer			(GL_COPY_WRITE_BUFFER, buf[1]);
734 	ctx.endSection();
735 
736 	ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer object bound to either readtarget or writetarget is mapped.");
737 	ctx.glMapBufferRange		(GL_COPY_READ_BUFFER, 0, 4, GL_MAP_READ_BIT);
738 	ctx.glCopyBufferSubData		(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16);
739 	ctx.expectError				(GL_INVALID_OPERATION);
740 	ctx.glUnmapBuffer			(GL_COPY_READ_BUFFER);
741 
742 	ctx.glMapBufferRange		(GL_COPY_WRITE_BUFFER, 0, 4, GL_MAP_READ_BIT);
743 	ctx.glCopyBufferSubData		(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16);
744 	ctx.expectError				(GL_INVALID_OPERATION);
745 	ctx.glUnmapBuffer			(GL_COPY_WRITE_BUFFER);
746 	ctx.endSection();
747 
748 	ctx.glDeleteBuffers(2, buf);
749 }
750 
draw_buffers(NegativeTestContext & ctx)751 void draw_buffers (NegativeTestContext& ctx)
752 {
753 	deUint32				fbo						= 0x1234;
754 	deUint32				texture					= 0x1234;
755 	int						maxDrawBuffers			= 0x1234;
756 	int						maxColorAttachments		= -1;
757 	ctx.glGetIntegerv		(GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
758 	ctx.glGetIntegerv		(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
759 	std::vector<deUint32>	values					(maxDrawBuffers+1);
760 	std::vector<deUint32>	attachments				(4);
761 	std::vector<GLfloat>	data					(32*32);
762 	values[0]				= GL_NONE;
763 	values[1]				= GL_BACK;
764 	values[2]				= GL_COLOR_ATTACHMENT0;
765 	values[3]				= GL_DEPTH_ATTACHMENT;
766 	attachments[0]			= (glw::GLenum) (GL_COLOR_ATTACHMENT0 + maxColorAttachments);
767 	attachments[1]			= GL_COLOR_ATTACHMENT0;
768 	attachments[2]			= GL_COLOR_ATTACHMENT1;
769 	attachments[3]			= GL_NONE;
770 
771 	ctx.glGenTextures			(1, &texture);
772 	ctx.glBindTexture			(GL_TEXTURE_2D, texture);
773 	ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
774 	ctx.glGenFramebuffers		(1, &fbo);
775 	ctx.glBindFramebuffer		(GL_FRAMEBUFFER, fbo);
776 	ctx.glFramebufferTexture2D	(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
777 	ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
778 	ctx.expectError				(GL_NO_ERROR);
779 
780 	ctx.beginSection("GL_INVALID_ENUM is generated if one of the values in bufs is not an accepted value.");
781 	ctx.glDrawBuffers			(2, &values[2]);
782 	ctx.expectError				(GL_INVALID_ENUM);
783 	ctx.endSection();
784 
785 	ctx.beginSection("GL_INVALID_OPERATION is generated if the GL is bound to a draw framebuffer and DrawBuffers is supplied with BACK or COLOR_ATTACHMENTm where m is greater than or equal to the value of MAX_COLOR_ATTACHMENTS.");
786 	ctx.glBindFramebuffer		(GL_FRAMEBUFFER, fbo);
787 	ctx.glDrawBuffers			(1, &values[1]);
788 	ctx.expectError				(GL_INVALID_OPERATION);
789 	ctx.glDrawBuffers			(4, &attachments[0]);
790 	ctx.expectError				(GL_INVALID_OPERATION);
791 	ctx.endSection();
792 
793 	ctx.beginSection("GL_INVALID_OPERATION is generated if the GL is bound to the default framebuffer and n is not 1.");
794 	ctx.glBindFramebuffer		(GL_FRAMEBUFFER, 0);
795 	ctx.glDrawBuffers			(2, &values[0]);
796 	ctx.expectError				(GL_INVALID_OPERATION);
797 	ctx.endSection();
798 
799 	ctx.beginSection("GL_INVALID_OPERATION is generated if the GL is bound to the default framebuffer and the value in bufs is one of the GL_COLOR_ATTACHMENTn tokens.");
800 	ctx.glBindFramebuffer		(GL_FRAMEBUFFER, 0);
801 	ctx.glDrawBuffers			(1, &values[2]);
802 	ctx.expectError				(GL_INVALID_OPERATION);
803 	ctx.endSection();
804 
805 	ctx.beginSection("GL_INVALID_OPERATION is generated if the GL is bound to a framebuffer object and the ith buffer listed in bufs is anything other than GL_NONE or GL_COLOR_ATTACHMENTSi.");
806 	ctx.glBindFramebuffer		(GL_FRAMEBUFFER, fbo);
807 	ctx.glDrawBuffers			(1, &values[1]);
808 	ctx.expectError				(GL_INVALID_OPERATION);
809 	ctx.glDrawBuffers			(4, &attachments[0]);
810 	ctx.expectError				(GL_INVALID_OPERATION);
811 
812 	ctx.endSection();
813 
814 	ctx.beginSection("GL_INVALID_VALUE is generated if n is less than 0 or greater than GL_MAX_DRAW_BUFFERS.");
815 	ctx.glDrawBuffers			(-1, &values[1]);
816 	ctx.expectError				(GL_INVALID_VALUE);
817 	ctx.glDrawBuffers			(maxDrawBuffers+1, &values[0]);
818 	ctx.expectError				(GL_INVALID_VALUE);
819 	ctx.endSection();
820 
821 	ctx.glDeleteTextures(1, &texture);
822 	ctx.glDeleteFramebuffers(1, &fbo);
823 }
824 
flush_mapped_buffer_range(NegativeTestContext & ctx)825 void flush_mapped_buffer_range (NegativeTestContext& ctx)
826 {
827 	deUint32				buf		= 0x1234;
828 	std::vector<GLfloat>	data	(32);
829 
830 	ctx.glGenBuffers			(1, &buf);
831 	ctx.glBindBuffer			(GL_ARRAY_BUFFER, buf);
832 	ctx.glBufferData			(GL_ARRAY_BUFFER, 32, &data[0], GL_STATIC_READ);
833 	ctx.glMapBufferRange		(GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT);
834 	ctx.expectError				(GL_NO_ERROR);
835 
836 	ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted values.");
837 	ctx.glFlushMappedBufferRange(-1, 0, 16);
838 	ctx.expectError				(GL_INVALID_ENUM);
839 	ctx.endSection();
840 
841 	ctx.beginSection("GL_INVALID_VALUE is generated if offset or length is negative, or if offset + length exceeds the size of the mapping.");
842 	ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, -1, 1);
843 	ctx.expectError				(GL_INVALID_VALUE);
844 	ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, -1);
845 	ctx.expectError				(GL_INVALID_VALUE);
846 	ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 12, 8);
847 	ctx.expectError				(GL_INVALID_VALUE);
848 	ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 24, 4);
849 	ctx.expectError				(GL_INVALID_VALUE);
850 	ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 24);
851 	ctx.expectError				(GL_INVALID_VALUE);
852 	ctx.endSection();
853 
854 	ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
855 	ctx.glBindBuffer			(GL_ARRAY_BUFFER, 0);
856 	ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 8);
857 	ctx.expectError				(GL_INVALID_OPERATION);
858 	ctx.endSection();
859 
860 	ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer bound to target is not mapped, or is mapped without the GL_MAP_FLUSH_EXPLICIT flag.");
861 	ctx.glBindBuffer			(GL_ARRAY_BUFFER, buf);
862 	ctx.glUnmapBuffer			(GL_ARRAY_BUFFER);
863 	ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 8);
864 	ctx.expectError				(GL_INVALID_OPERATION);
865 	ctx.glMapBufferRange		(GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT);
866 	ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 8);
867 	ctx.expectError				(GL_INVALID_OPERATION);
868 	ctx.endSection();
869 
870 	ctx.glUnmapBuffer			(GL_ARRAY_BUFFER);
871 	ctx.glDeleteBuffers			(1, &buf);
872 }
873 
map_buffer_range(NegativeTestContext & ctx)874 void map_buffer_range (NegativeTestContext& ctx)
875 {
876 	deUint32				buf		= 0x1234;
877 	std::vector<GLfloat>	data	(32);
878 
879 	ctx.glGenBuffers			(1, &buf);
880 	ctx.glBindBuffer			(GL_ARRAY_BUFFER, buf);
881 	ctx.glBufferData			(GL_ARRAY_BUFFER, 32, &data[0], GL_DYNAMIC_COPY);
882 	ctx.expectError				(GL_NO_ERROR);
883 
884 	ctx.beginSection("GL_INVALID_VALUE is generated if either of offset or length is negative.");
885 	ctx.glMapBufferRange		(GL_ARRAY_BUFFER, -1, 1, GL_MAP_READ_BIT);
886 	ctx.expectError				(GL_INVALID_VALUE);
887 
888 	ctx.glMapBufferRange		(GL_ARRAY_BUFFER, 1, -1, GL_MAP_READ_BIT);
889 	ctx.expectError				(GL_INVALID_VALUE);
890 	ctx.endSection();
891 
892 	ctx.beginSection("GL_INVALID_VALUE is generated if offset + length is greater than the value of GL_BUFFER_SIZE.");
893 	ctx.glMapBufferRange		(GL_ARRAY_BUFFER, 0, 33, GL_MAP_READ_BIT);
894 	ctx.expectError				(GL_INVALID_VALUE);
895 
896 	ctx.glMapBufferRange		(GL_ARRAY_BUFFER, 32, 1, GL_MAP_READ_BIT);
897 	ctx.expectError				(GL_INVALID_VALUE);
898 
899 	ctx.glMapBufferRange		(GL_ARRAY_BUFFER, 16, 17, GL_MAP_READ_BIT);
900 	ctx.expectError				(GL_INVALID_VALUE);
901 	ctx.endSection();
902 
903 	ctx.beginSection("GL_INVALID_VALUE is generated if access has any bits set other than those accepted.");
904 	ctx.glMapBufferRange		(GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | 0x1000);
905 	ctx.expectError				(GL_INVALID_VALUE);
906 
907 	ctx.glMapBufferRange		(GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT | 0x1000);
908 	ctx.expectError				(GL_INVALID_VALUE);
909 	ctx.endSection();
910 
911 	ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer is already in a mapped state.");
912 	ctx.glMapBufferRange		(GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT);
913 	ctx.expectError				(GL_NO_ERROR);
914 	ctx.glMapBufferRange		(GL_ARRAY_BUFFER, 16, 8, GL_MAP_READ_BIT);
915 	ctx.expectError				(GL_INVALID_OPERATION);
916 	ctx.glUnmapBuffer			(GL_ARRAY_BUFFER);
917 	ctx.endSection();
918 
919 	ctx.beginSection("GL_INVALID_OPERATION is generated if neither GL_MAP_READ_BIT or GL_MAP_WRITE_BIT is set.");
920 	ctx.glMapBufferRange		(GL_ARRAY_BUFFER, 0, 16, GL_MAP_INVALIDATE_RANGE_BIT);
921 	ctx.expectError				(GL_INVALID_OPERATION);
922 	ctx.endSection();
923 
924 	ctx.beginSection("GL_INVALID_OPERATION is generated if length is 0");
925 	ctx.glMapBufferRange		(GL_ARRAY_BUFFER, 0, 0, GL_MAP_READ_BIT);
926 	ctx.expectError				(GL_INVALID_OPERATION);
927 	ctx.endSection();
928 
929 	ctx.beginSection("GL_INVALID_OPERATION is generated if GL_MAP_READ_BIT is set and any of GL_MAP_INVALIDATE_RANGE_BIT, GL_MAP_INVALIDATE_BUFFER_BIT, or GL_MAP_UNSYNCHRONIZED_BIT is set.");
930 	ctx.glMapBufferRange		(GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_INVALIDATE_RANGE_BIT);
931 	ctx.expectError				(GL_INVALID_OPERATION);
932 
933 	ctx.glMapBufferRange		(GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
934 	ctx.expectError				(GL_INVALID_OPERATION);
935 
936 	ctx.glMapBufferRange		(GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
937 	ctx.expectError				(GL_INVALID_OPERATION);
938 	ctx.endSection();
939 
940 	ctx.beginSection("GL_INVALID_OPERATION is generated if GL_MAP_FLUSH_EXPLICIT_BIT is set and GL_MAP_WRITE_BIT is not set.");
941 	ctx.glMapBufferRange		(GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_FLUSH_EXPLICIT_BIT);
942 	ctx.expectError				(GL_INVALID_OPERATION);
943 	ctx.endSection();
944 
945 	ctx.glDeleteBuffers			(1, &buf);
946 }
947 
read_buffer(NegativeTestContext & ctx)948 void read_buffer (NegativeTestContext& ctx)
949 {
950 	deUint32	fbo					= 0x1234;
951 	deUint32	texture				= 0x1234;
952 	int			maxColorAttachments	= 0x1234;
953 
954 	ctx.glGetIntegerv			(GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
955 	ctx.glGenTextures			(1, &texture);
956 	ctx.glBindTexture			(GL_TEXTURE_2D, texture);
957 	ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
958 	ctx.glGenFramebuffers		(1, &fbo);
959 	ctx.glBindFramebuffer		(GL_FRAMEBUFFER, fbo);
960 	ctx.glFramebufferTexture2D	(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
961 	ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
962 	ctx.expectError				(GL_NO_ERROR);
963 
964 	ctx.beginSection("GL_INVALID_ENUM is generated if mode is not GL_BACK, GL_NONE, or GL_COLOR_ATTACHMENTi.");
965 	ctx.glReadBuffer			(GL_NONE);
966 	ctx.expectError				(GL_NO_ERROR);
967 	ctx.glReadBuffer			(1);
968 	ctx.expectError				(GL_INVALID_ENUM);
969 	ctx.glReadBuffer			(GL_FRAMEBUFFER);
970 	ctx.expectError				(GL_INVALID_ENUM);
971 	ctx.glReadBuffer			(GL_COLOR_ATTACHMENT0 - 1);
972 	ctx.expectError				(GL_INVALID_ENUM);
973 	ctx.glReadBuffer			(GL_FRONT);
974 	ctx.expectError				(GL_INVALID_ENUM);
975 
976 	// \ note Spec isn't actually clear here, but it is safe to assume that
977 	//		  GL_DEPTH_ATTACHMENT can't be interpreted as GL_COLOR_ATTACHMENTm
978 	//		  where m = (GL_DEPTH_ATTACHMENT - GL_COLOR_ATTACHMENT0).
979 	ctx.glReadBuffer			(GL_DEPTH_ATTACHMENT);
980 	ctx.expectError				(GL_INVALID_ENUM);
981 	ctx.glReadBuffer			(GL_STENCIL_ATTACHMENT);
982 	ctx.expectError				(GL_INVALID_ENUM);
983 	ctx.glReadBuffer			(GL_STENCIL_ATTACHMENT+1);
984 	ctx.expectError				(GL_INVALID_ENUM);
985 	ctx.glReadBuffer			(0xffffffffu);
986 	ctx.expectError				(GL_INVALID_ENUM);
987 	ctx.endSection();
988 
989 	ctx.beginSection("GL_INVALID_OPERATION error is generated if src is GL_BACK or if src is GL_COLOR_ATTACHMENTm where m is greater than or equal to the value of GL_MAX_COLOR_ATTACHMENTS.");
990 	ctx.glReadBuffer			(GL_BACK);
991 	ctx.expectError				(GL_INVALID_OPERATION);
992 	ctx.glReadBuffer			(GL_COLOR_ATTACHMENT0 + maxColorAttachments);
993 	ctx.expectError				(GL_INVALID_OPERATION);
994 
995 	if (GL_COLOR_ATTACHMENT0+maxColorAttachments < GL_DEPTH_ATTACHMENT-1)
996 	{
997 		ctx.glReadBuffer			(GL_DEPTH_ATTACHMENT - 1);
998 		ctx.expectError				(GL_INVALID_OPERATION);
999 	}
1000 
1001 	ctx.endSection();
1002 
1003 	ctx.beginSection("GL_INVALID_OPERATION is generated if the current framebuffer is the default framebuffer and mode is not GL_NONE or GL_BACK.");
1004 	ctx.glBindFramebuffer		(GL_FRAMEBUFFER, 0);
1005 	ctx.glReadBuffer			(GL_COLOR_ATTACHMENT0);
1006 	ctx.expectError				(GL_INVALID_OPERATION);
1007 	ctx.endSection();
1008 
1009 	ctx.beginSection("GL_INVALID_OPERATION is generated if the current framebuffer is a named framebuffer and mode is not GL_NONE or GL_COLOR_ATTACHMENTi.");
1010 	ctx.glBindFramebuffer		(GL_FRAMEBUFFER, fbo);
1011 	ctx.glReadBuffer			(GL_BACK);
1012 	ctx.expectError				(GL_INVALID_OPERATION);
1013 	ctx.endSection();
1014 
1015 	ctx.glDeleteTextures(1, &texture);
1016 	ctx.glDeleteFramebuffers(1, &fbo);
1017 }
1018 
unmap_buffer(NegativeTestContext & ctx)1019 void unmap_buffer (NegativeTestContext& ctx)
1020 {
1021 	deUint32				buf		= 0x1234;
1022 	std::vector<GLfloat>	data	(32);
1023 
1024 	ctx.glGenBuffers			(1, &buf);
1025 	ctx.glBindBuffer			(GL_ARRAY_BUFFER, buf);
1026 	ctx.glBufferData			(GL_ARRAY_BUFFER, 32, &data[0], GL_DYNAMIC_COPY);
1027 	ctx.expectError				(GL_NO_ERROR);
1028 
1029 	ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer data store is already in an unmapped state.");
1030 	ctx.glUnmapBuffer			(GL_ARRAY_BUFFER);
1031 	ctx.expectError				(GL_INVALID_OPERATION);
1032 	ctx.endSection();
1033 
1034 	ctx.glDeleteBuffers			(1, &buf);
1035 }
1036 // Framebuffer Objects
1037 
bind_framebuffer(NegativeTestContext & ctx)1038 void bind_framebuffer (NegativeTestContext& ctx)
1039 {
1040 	ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_DRAW_FRAMEBUFFER, GL_READ_FRAMEBUFFER, or GL_FRAMEBUFFER.");
1041 	ctx.glBindFramebuffer(-1, 0);
1042 	ctx.expectError(GL_INVALID_ENUM);
1043 	ctx.glBindFramebuffer(GL_RENDERBUFFER, 0);
1044 	ctx.expectError(GL_INVALID_ENUM);
1045 	ctx.endSection();
1046 }
1047 
bind_renderbuffer(NegativeTestContext & ctx)1048 void bind_renderbuffer (NegativeTestContext& ctx)
1049 {
1050 	ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
1051 	ctx.glBindRenderbuffer(-1, 0);
1052 	ctx.expectError(GL_INVALID_ENUM);
1053 	ctx.glBindRenderbuffer(GL_FRAMEBUFFER, 0);
1054 	ctx.expectError(GL_INVALID_ENUM);
1055 	ctx.endSection();
1056 }
1057 
check_framebuffer_status(NegativeTestContext & ctx)1058 void check_framebuffer_status (NegativeTestContext& ctx)
1059 {
1060 	ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_DRAW_FRAMEBUFFER, GL_READ_FRAMEBUFFER, or GL_FRAMEBUFFER..");
1061 	ctx.glCheckFramebufferStatus(-1);
1062 	ctx.expectError(GL_INVALID_ENUM);
1063 	ctx.glCheckFramebufferStatus(GL_RENDERBUFFER);
1064 	ctx.expectError(GL_INVALID_ENUM);
1065 	ctx.endSection();
1066 }
1067 
gen_framebuffers(NegativeTestContext & ctx)1068 void gen_framebuffers (NegativeTestContext& ctx)
1069 {
1070 	ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
1071 	ctx.glGenFramebuffers(-1, 0);
1072 	ctx.expectError(GL_INVALID_VALUE);
1073 	ctx.endSection();
1074 }
1075 
gen_renderbuffers(NegativeTestContext & ctx)1076 void gen_renderbuffers (NegativeTestContext& ctx)
1077 {
1078 	ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
1079 	ctx.glGenRenderbuffers(-1, 0);
1080 	ctx.expectError(GL_INVALID_VALUE);
1081 	ctx.endSection();
1082 }
1083 
delete_framebuffers(NegativeTestContext & ctx)1084 void delete_framebuffers (NegativeTestContext& ctx)
1085 {
1086 	ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
1087 	ctx.glDeleteFramebuffers(-1, 0);
1088 	ctx.expectError(GL_INVALID_VALUE);
1089 	ctx.endSection();
1090 }
1091 
delete_renderbuffers(NegativeTestContext & ctx)1092 void delete_renderbuffers (NegativeTestContext& ctx)
1093 {;
1094 	ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
1095 	ctx.glDeleteRenderbuffers(-1, 0);
1096 	ctx.expectError(GL_INVALID_VALUE);
1097 	ctx.endSection();
1098 }
1099 
framebuffer_renderbuffer(NegativeTestContext & ctx)1100 void framebuffer_renderbuffer (NegativeTestContext& ctx)
1101 {
1102 	GLuint fbo = 0x1234;
1103 	GLuint rbo = 0x1234;
1104 	ctx.glGenFramebuffers(1, &fbo);
1105 	ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1106 	ctx.glGenRenderbuffers(1, &rbo);
1107 
1108 	ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
1109 	ctx.glFramebufferRenderbuffer(-1, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
1110 	ctx.expectError(GL_INVALID_ENUM);
1111 	ctx.endSection();
1112 
1113 	ctx.beginSection("GL_INVALID_ENUM is generated if attachment is not one of the accepted tokens.");
1114 	ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, -1, GL_RENDERBUFFER, 0);
1115 	ctx.expectError(GL_INVALID_ENUM);
1116 	ctx.endSection();
1117 
1118 	ctx.beginSection("GL_INVALID_ENUM is generated if renderbuffertarget is not GL_RENDERBUFFER.");
1119 	ctx.glBindRenderbuffer(GL_RENDERBUFFER, rbo);
1120 	ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, rbo);
1121 	ctx.expectError(GL_INVALID_ENUM);
1122 	ctx.glBindRenderbuffer(GL_RENDERBUFFER, 0);
1123 	ctx.endSection();
1124 
1125 	ctx.beginSection("GL_INVALID_OPERATION is generated if renderbuffer is neither 0 nor the name of an existing renderbuffer object.");
1126 	ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, -1);
1127 	ctx.expectError(GL_INVALID_OPERATION);
1128 	ctx.endSection();
1129 
1130 	ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
1131 	ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1132 	ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
1133 	ctx.expectError(GL_INVALID_OPERATION);
1134 	ctx.endSection();
1135 
1136 	ctx.glDeleteRenderbuffers(1, &rbo);
1137 	ctx.glDeleteFramebuffers(1, &fbo);
1138 }
1139 
framebuffer_texture(NegativeTestContext & ctx)1140 void framebuffer_texture (NegativeTestContext& ctx)
1141 {
1142 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
1143 	{
1144 		GLuint fbo = 0x1234;
1145 		GLuint texture[] = {0x1234, 0x1234};
1146 
1147 		ctx.glGenFramebuffers(1, &fbo);
1148 		ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1149 		ctx.glGenTextures(2, texture);
1150 		ctx.glBindTexture(GL_TEXTURE_2D, texture[0]);
1151 		ctx.glBindTexture(GL_TEXTURE_BUFFER, texture[1]);
1152 		ctx.expectError(GL_NO_ERROR);
1153 
1154 		ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
1155 		ctx.glFramebufferTexture(-1, GL_COLOR_ATTACHMENT0, texture[0], 0);
1156 		ctx.expectError(GL_INVALID_ENUM);
1157 		ctx.endSection();
1158 
1159 		ctx.beginSection("GL_INVALID_ENUM is generated if attachment is not one of the accepted tokens.");
1160 		ctx.glFramebufferTexture(GL_FRAMEBUFFER, -1, texture[0], 0);
1161 		ctx.expectError(GL_INVALID_ENUM);
1162 		ctx.endSection();
1163 
1164 		ctx.beginSection("GL_INVALID_OPERATION is generated if texture is neither 0 nor the name of an existing texture object.");
1165 		ctx.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, 0);
1166 		ctx.expectError(GL_INVALID_VALUE);
1167 		ctx.endSection();
1168 
1169 		ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
1170 		ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1171 		ctx.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 0, 0);
1172 		ctx.expectError(GL_INVALID_OPERATION);
1173 		ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1174 		ctx.endSection();
1175 
1176 		ctx.beginSection("GL_INVALID_OPERATION is generated by if texture is a buffer texture.");
1177 		ctx.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texture[1], 0);
1178 		ctx.expectError(GL_INVALID_OPERATION);
1179 		ctx.endSection();
1180 
1181 		ctx.glDeleteFramebuffers(1, &fbo);
1182 		ctx.glDeleteBuffers(2, texture);
1183 	}
1184 }
1185 
framebuffer_texture2d(NegativeTestContext & ctx)1186 void framebuffer_texture2d (NegativeTestContext& ctx)
1187 {
1188 	GLuint	fbo				= 0x1234;
1189 	GLuint	tex2D			= 0x1234;
1190 	GLuint	texCube			= 0x1234;
1191 	GLuint	tex2DMS			= 0x1234;
1192 	GLint	maxTexSize		= 0x1234;
1193 	GLint	maxTexCubeSize	= 0x1234;
1194 	int		maxSize			= 0x1234;
1195 
1196 	ctx.glGenFramebuffers(1, &fbo);
1197 	ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1198 	ctx.glGenTextures(1, &tex2D);
1199 	ctx.glBindTexture(GL_TEXTURE_2D, tex2D);
1200 	ctx.glGenTextures(1, &texCube);
1201 	ctx.glBindTexture(GL_TEXTURE_CUBE_MAP, texCube);
1202 	ctx.glGenTextures(1, &tex2DMS);
1203 	ctx.glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, tex2DMS);
1204 	ctx.glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTexSize);
1205 	ctx.glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &maxTexCubeSize);
1206 	ctx.expectError(GL_NO_ERROR);
1207 
1208 	ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
1209 	ctx.glFramebufferTexture2D(-1, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
1210 	ctx.expectError(GL_INVALID_ENUM);
1211 	ctx.endSection();
1212 
1213 	ctx.beginSection("GL_INVALID_ENUM is generated if textarget is not an accepted texture target.");
1214 	ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, tex2D, 0);
1215 	ctx.expectError(GL_INVALID_ENUM);
1216 	ctx.endSection();
1217 
1218 	ctx.beginSection("GL_INVALID_ENUM is generated if attachment is not an accepted token.");
1219 	ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, -1, GL_TEXTURE_2D, tex2D, 0);
1220 	ctx.expectError(GL_INVALID_ENUM);
1221 	ctx.endSection();
1222 
1223 	ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0 or larger than log_2 of maximum texture size.");
1224 	ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, -1);
1225 	ctx.expectError(GL_INVALID_VALUE);
1226 	maxSize = deLog2Floor32(maxTexSize) + 1;
1227 	ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, maxSize);
1228 	ctx.expectError(GL_INVALID_VALUE);
1229 	maxSize = deLog2Floor32(maxTexSize) + 1;
1230 	ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X, texCube, maxSize);
1231 	ctx.expectError(GL_INVALID_VALUE);
1232 	ctx.endSection();
1233 
1234 	ctx.beginSection("GL_INVALID_VALUE is generated if level is larger than maximum texture size.");
1235 	ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, maxTexSize + 1);
1236 	ctx.expectError(GL_INVALID_VALUE);
1237 	ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, -1);
1238 	ctx.expectError(GL_INVALID_VALUE);
1239 	ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_Z, texCube, maxTexCubeSize + 1);
1240 	ctx.expectError(GL_INVALID_VALUE);
1241 	ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_Z, texCube, -1);
1242 	ctx.expectError(GL_INVALID_VALUE);
1243 	ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, tex2DMS, 1);
1244 	ctx.expectError(GL_INVALID_VALUE);
1245 	ctx.endSection();
1246 
1247 	ctx.beginSection("GL_INVALID_OPERATION is generated if texture is neither 0 nor the name of an existing texture object.");
1248 	ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, -1, 0);
1249 	ctx.expectError(GL_INVALID_OPERATION);
1250 	ctx.endSection();
1251 
1252 	ctx.beginSection("GL_INVALID_OPERATION is generated if textarget and texture are not compatible.");
1253 	ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X, tex2D, 0);
1254 	ctx.expectError(GL_INVALID_OPERATION);
1255 	ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, tex2D, 0);
1256 	ctx.expectError(GL_INVALID_OPERATION);
1257 	ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texCube, 0);
1258 	ctx.expectError(GL_INVALID_OPERATION);
1259 	ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2DMS, 0);
1260 	ctx.expectError(GL_INVALID_OPERATION);
1261 	ctx.glDeleteTextures(1, &tex2D);
1262 	ctx.glDeleteTextures(1, &texCube);
1263 	ctx.glDeleteTextures(1, &tex2DMS);
1264 	ctx.endSection();
1265 
1266 	ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
1267 	ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1268 	ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
1269 	ctx.expectError(GL_INVALID_OPERATION);
1270 	ctx.endSection();
1271 
1272 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
1273 	{
1274 		GLuint texBuf = 0x1234;
1275 		ctx.beginSection("GL_INVALID_OPERATION error is generated if texture is the name of a buffer texture.");
1276 		ctx.glGenTextures(1, &texBuf);
1277 		ctx.glBindTexture(GL_TEXTURE_BUFFER, texBuf);
1278 		ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1279 		ctx.expectError(GL_NO_ERROR);
1280 		ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texBuf, 0);
1281 		ctx.expectError(GL_INVALID_OPERATION);
1282 		ctx.endSection();
1283 	}
1284 
1285 	ctx.glDeleteFramebuffers(1, &fbo);
1286 }
1287 
renderbuffer_storage(NegativeTestContext & ctx)1288 void renderbuffer_storage (NegativeTestContext& ctx)
1289 {
1290 	deUint32	rbo		= 0x1234;
1291 	GLint		maxSize	= 0x1234;
1292 
1293 	ctx.glGenRenderbuffers		(1, &rbo);
1294 	ctx.glBindRenderbuffer		(GL_RENDERBUFFER, rbo);
1295 
1296 	ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
1297 	ctx.glRenderbufferStorage	(-1, GL_RGBA4, 1, 1);
1298 	ctx.expectError				(GL_INVALID_ENUM);
1299 	ctx.glRenderbufferStorage	(GL_FRAMEBUFFER, GL_RGBA4, 1, 1);
1300 	ctx.expectError				(GL_INVALID_ENUM);
1301 	ctx.endSection();
1302 
1303 	ctx.beginSection("GL_INVALID_ENUM is generated if internalformat is not a color-renderable, depth-renderable, or stencil-renderable format.");
1304 	ctx.glRenderbufferStorage	(GL_RENDERBUFFER, -1, 1, 1);
1305 	ctx.expectError				(GL_INVALID_ENUM);
1306 
1307 	if (!ctx.isExtensionSupported("GL_EXT_color_buffer_half_float")) // GL_EXT_color_buffer_half_float disables error
1308 	{
1309 		ctx.glRenderbufferStorage	(GL_RENDERBUFFER, GL_RGB16F, 1, 1);
1310 		ctx.expectError				(GL_INVALID_ENUM);
1311 	}
1312 
1313 	if (!ctx.isExtensionSupported("GL_EXT_render_snorm")) // GL_EXT_render_snorm disables error
1314 	{
1315 		ctx.glRenderbufferStorage	(GL_RENDERBUFFER, GL_RGBA8_SNORM, 1, 1);
1316 		ctx.expectError				(GL_INVALID_ENUM);
1317 	}
1318 
1319 	ctx.endSection();
1320 
1321 	ctx.beginSection("GL_INVALID_VALUE is generated if width or height is less than zero.");
1322 	ctx.glRenderbufferStorage	(GL_RENDERBUFFER, GL_RGBA4, -1, 1);
1323 	ctx.expectError				(GL_INVALID_VALUE);
1324 	ctx.glRenderbufferStorage	(GL_RENDERBUFFER, GL_RGBA4, 1, -1);
1325 	ctx.expectError				(GL_INVALID_VALUE);
1326 	ctx.glRenderbufferStorage	(GL_RENDERBUFFER, GL_RGBA4, -1, -1);
1327 	ctx.expectError				(GL_INVALID_VALUE);
1328 	ctx.endSection();
1329 
1330 	ctx.beginSection("GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_RENDERBUFFER_SIZE.");
1331 	ctx.glGetIntegerv			(GL_MAX_RENDERBUFFER_SIZE, &maxSize);
1332 	ctx.glRenderbufferStorage	(GL_RENDERBUFFER, GL_RGBA4, 1, maxSize+1);
1333 	ctx.expectError				(GL_INVALID_VALUE);
1334 	ctx.glRenderbufferStorage	(GL_RENDERBUFFER, GL_RGBA4, maxSize+1, 1);
1335 	ctx.expectError				(GL_INVALID_VALUE);
1336 	ctx.glRenderbufferStorage	(GL_RENDERBUFFER, GL_RGBA4, maxSize+1, maxSize+1);
1337 	ctx.expectError				(GL_INVALID_VALUE);
1338 	ctx.endSection();
1339 
1340 	ctx.glDeleteRenderbuffers(1, &rbo);
1341 }
1342 
blit_framebuffer(NegativeTestContext & ctx)1343 void blit_framebuffer (NegativeTestContext& ctx)
1344 {
1345 	deUint32					fbo[2];
1346 	deUint32					rbo[2];
1347 	deUint32					texture[2];
1348 	deUint32					blankFrameBuffer;
1349 
1350 	ctx.glGenFramebuffers		(1, &blankFrameBuffer);
1351 	ctx.glGenFramebuffers		(2, fbo);
1352 	ctx.glGenTextures			(2, texture);
1353 	ctx.glGenRenderbuffers		(2, rbo);
1354 
1355 	ctx.glBindTexture			(GL_TEXTURE_2D, texture[0]);
1356 	ctx.glBindRenderbuffer		(GL_RENDERBUFFER, rbo[0]);
1357 	ctx.glBindFramebuffer		(GL_READ_FRAMEBUFFER, fbo[0]);
1358 
1359 	ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1360 	ctx.glRenderbufferStorage	(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 32, 32);
1361 	ctx.glFramebufferTexture2D	(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1362 	ctx.glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[0]);
1363 	ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER);
1364 
1365 	ctx.glBindTexture			(GL_TEXTURE_2D, texture[1]);
1366 	ctx.glBindRenderbuffer		(GL_RENDERBUFFER, rbo[1]);
1367 	ctx.glBindFramebuffer		(GL_DRAW_FRAMEBUFFER, fbo[1]);
1368 
1369 	ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1370 	ctx.glRenderbufferStorage	(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 32, 32);
1371 	ctx.glFramebufferTexture2D	(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[1], 0);
1372 	ctx.glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[1]);
1373 	ctx.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
1374 	ctx.expectError				(GL_NO_ERROR);
1375 
1376 	ctx.beginSection("GL_INVALID_VALUE is generated if mask contains any bits other than GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, or GL_STENCIL_BUFFER_BIT.");
1377 	ctx.glBlitFramebuffer		(0, 0, 16, 16, 0, 0, 16, 16, 1, GL_NEAREST);
1378 	ctx.expectError				(GL_INVALID_VALUE);
1379 	ctx.endSection();
1380 
1381 	ctx.beginSection("GL_INVALID_ENUM is generated if filter is not GL_LINEAR or GL_NEAREST.");
1382 	ctx.glBlitFramebuffer		(0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, 0);
1383 	ctx.expectError				(GL_INVALID_ENUM);
1384 	ctx.endSection();
1385 
1386 	ctx.beginSection("GL_INVALID_OPERATION is generated if mask contains any of the GL_DEPTH_BUFFER_BIT or GL_STENCIL_BUFFER_BIT and filter is not GL_NEAREST.");
1387 	ctx.glBlitFramebuffer		(0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_LINEAR);
1388 	ctx.expectError				(GL_INVALID_OPERATION);
1389 	ctx.glBlitFramebuffer		(0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_LINEAR);
1390 	ctx.expectError				(GL_INVALID_OPERATION);
1391 	ctx.glBlitFramebuffer		(0, 0, 16, 16, 0, 0, 16, 16, GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_LINEAR);
1392 	ctx.expectError				(GL_INVALID_OPERATION);
1393 	ctx.endSection();
1394 
1395 	ctx.beginSection("GL_INVALID_OPERATION is generated if mask contains GL_COLOR_BUFFER_BIT and read buffer format is incompatible with draw buffer format.");
1396 	ctx.glBindTexture			(GL_TEXTURE_2D, texture[0]);
1397 
1398 	ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
1399 	ctx.glFramebufferTexture2D	(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1400 	ctx.getLog() << TestLog::Message << "// Read buffer: GL_RGBA32UI, draw buffer: GL_RGBA" << TestLog::EndMessage;
1401 	ctx.glBlitFramebuffer		(0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1402 	ctx.expectError				(GL_INVALID_OPERATION);
1403 
1404 	ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL);
1405 	ctx.glFramebufferTexture2D	(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1406 	ctx.getLog() << TestLog::Message << "// Read buffer: GL_RGBA32I, draw buffer: GL_RGBA" << TestLog::EndMessage;
1407 	ctx.glBlitFramebuffer		(0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1408 	ctx.expectError				(GL_INVALID_OPERATION);
1409 
1410 	ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1411 	ctx.glFramebufferTexture2D	(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1412 	ctx.glBindTexture			(GL_TEXTURE_2D, texture[1]);
1413 	ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL);
1414 	ctx.glFramebufferTexture2D	(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[1], 0);
1415 	ctx.getLog() << TestLog::Message << "// Read buffer: GL_RGBA8, draw buffer: GL_RGBA32I" << TestLog::EndMessage;
1416 	ctx.glBlitFramebuffer		(0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1417 	ctx.expectError				(GL_INVALID_OPERATION);
1418 	ctx.endSection();
1419 
1420 	ctx.beginSection("GL_INVALID_OPERATION is generated if filter is GL_LINEAR and the read buffer contains integer data.");
1421 	ctx.glBindTexture			(GL_TEXTURE_2D, texture[0]);
1422 	ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
1423 	ctx.glFramebufferTexture2D	(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1424 	ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1425 	ctx.glFramebufferTexture2D	(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[1], 0);
1426 	ctx.getLog() << TestLog::Message << "// Read buffer: GL_RGBA32I, draw buffer: GL_RGBA8" << TestLog::EndMessage;
1427 	ctx.glBlitFramebuffer		(0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_LINEAR);
1428 	ctx.expectError				(GL_INVALID_OPERATION);
1429 	ctx.endSection();
1430 
1431 	ctx.beginSection("GL_INVALID_OPERATION is generated if mask contains GL_DEPTH_BUFFER_BIT or GL_STENCIL_BUFFER_BIT and the source and destination depth and stencil formats do not match.");
1432 	ctx.glBindRenderbuffer		(GL_RENDERBUFFER, rbo[0]);
1433 	ctx.glRenderbufferStorage	(GL_RENDERBUFFER, GL_DEPTH32F_STENCIL8, 32, 32);
1434 	ctx.glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[0]);
1435 	ctx.glBlitFramebuffer		(0, 0, 16, 16, 0, 0, 16, 16, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
1436 	ctx.expectError				(GL_INVALID_OPERATION);
1437 	ctx.glBlitFramebuffer		(0, 0, 16, 16, 0, 0, 16, 16, GL_STENCIL_BUFFER_BIT, GL_NEAREST);
1438 	ctx.expectError				(GL_INVALID_OPERATION);
1439 	ctx.endSection();
1440 
1441 	ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the read or draw framebuffer is not framebuffer complete.");
1442 	ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER);
1443 	ctx.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
1444 	ctx.glBlitFramebuffer		(0, 0, 16, 16, 0, 0, 16, 16, 0, GL_NEAREST);
1445 	ctx.expectError				(GL_NO_ERROR);
1446 	ctx.getLog() << TestLog::Message << "// incomplete read framebuffer" << TestLog::EndMessage;
1447 	ctx.glBindFramebuffer		(GL_READ_FRAMEBUFFER, blankFrameBuffer);
1448 	ctx.glBindFramebuffer		(GL_DRAW_FRAMEBUFFER, fbo[1]);
1449 	TCU_CHECK(ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE);
1450 	TCU_CHECK(ctx.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);
1451 	ctx.glBlitFramebuffer		(0, 0, 16, 16, 0, 0, 16, 16, 0, GL_NEAREST);
1452 	ctx.expectError				(GL_INVALID_FRAMEBUFFER_OPERATION);
1453 	ctx.getLog() << TestLog::Message << "// incomplete draw framebuffer" << TestLog::EndMessage;
1454 	ctx.glBindFramebuffer		(GL_READ_FRAMEBUFFER, fbo[1]);
1455 	ctx.glBindFramebuffer		(GL_DRAW_FRAMEBUFFER, blankFrameBuffer);
1456 	TCU_CHECK(ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);
1457 	TCU_CHECK(ctx.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE);
1458 	ctx.glBlitFramebuffer		(0, 0, 16, 16, 0, 0, 16, 16, 0, GL_NEAREST);
1459 	ctx.expectError				(GL_INVALID_FRAMEBUFFER_OPERATION);
1460 	ctx.getLog() << TestLog::Message << "// incomplete read and draw framebuffer" << TestLog::EndMessage;
1461 	ctx.glBindFramebuffer		(GL_READ_FRAMEBUFFER, blankFrameBuffer);
1462 	ctx.glBindFramebuffer		(GL_DRAW_FRAMEBUFFER, blankFrameBuffer);
1463 	TCU_CHECK(ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE);
1464 	TCU_CHECK(ctx.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE);
1465 	ctx.glBlitFramebuffer		(0, 0, 16, 16, 0, 0, 16, 16, 0, GL_NEAREST);
1466 	ctx.expectError				(GL_INVALID_FRAMEBUFFER_OPERATION);
1467 	// restore
1468 	ctx.glBindFramebuffer		(GL_READ_FRAMEBUFFER, fbo[0]);
1469 	ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER);
1470 	ctx.glBindFramebuffer		(GL_DRAW_FRAMEBUFFER, fbo[1]);
1471 	ctx.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
1472 	ctx.endSection();
1473 
1474 	ctx.beginSection("GL_INVALID_OPERATION is generated if the source and destination buffers are identical.");
1475 	ctx.glBindFramebuffer		(GL_DRAW_FRAMEBUFFER, fbo[0]);
1476 	ctx.expectError				(GL_NO_ERROR);
1477 	ctx.glBlitFramebuffer		(0, 0, 16, 16, 0, 0, 16, 16, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
1478 	ctx.expectError				(GL_INVALID_OPERATION);
1479 	// restore
1480 	ctx.glBindFramebuffer		(GL_DRAW_FRAMEBUFFER, fbo[1]);
1481 	ctx.endSection();
1482 
1483 	ctx.glBindFramebuffer		(GL_FRAMEBUFFER, 0);
1484 	ctx.glBindRenderbuffer		(GL_RENDERBUFFER, 0);
1485 	ctx.glDeleteFramebuffers	(2, fbo);
1486 	ctx.glDeleteFramebuffers	(1, &blankFrameBuffer);
1487 	ctx.glDeleteTextures		(2, texture);
1488 	ctx.glDeleteRenderbuffers	(2, rbo);
1489 }
1490 
blit_framebuffer_multisample(NegativeTestContext & ctx)1491 void blit_framebuffer_multisample (NegativeTestContext& ctx)
1492 {
1493 	deUint32							fbo[2];
1494 	deUint32							rbo[2];
1495 
1496 	ctx.glGenFramebuffers				(2, fbo);
1497 	ctx.glGenRenderbuffers				(2, rbo);
1498 
1499 	ctx.glBindRenderbuffer				(GL_RENDERBUFFER, rbo[0]);
1500 	ctx.glBindFramebuffer				(GL_READ_FRAMEBUFFER, fbo[0]);
1501 	ctx.glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA8, 32, 32);
1502 	ctx.glFramebufferRenderbuffer		(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[0]);
1503 	ctx.glCheckFramebufferStatus		(GL_READ_FRAMEBUFFER);
1504 
1505 	ctx.glBindRenderbuffer				(GL_RENDERBUFFER, rbo[1]);
1506 	ctx.glBindFramebuffer				(GL_DRAW_FRAMEBUFFER, fbo[1]);
1507 
1508 	ctx.expectError						(GL_NO_ERROR);
1509 
1510 	if (!ctx.isExtensionSupported("GL_NV_framebuffer_multisample"))
1511 	{
1512 		ctx.beginSection("GL_INVALID_OPERATION is generated if the value of GL_SAMPLE_BUFFERS for the draw buffer is greater than zero.");
1513 		ctx.glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA8, 32, 32);
1514 		ctx.glFramebufferRenderbuffer		(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[1]);
1515 		ctx.glBlitFramebuffer				(0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1516 		ctx.expectError						(GL_INVALID_OPERATION);
1517 		ctx.endSection();
1518 
1519 		ctx.beginSection("GL_INVALID_OPERATION is generated if GL_SAMPLE_BUFFERS for the read buffer is greater than zero and the formats of draw and read buffers are not identical.");
1520 		ctx.glRenderbufferStorage			(GL_RENDERBUFFER, GL_RGBA4, 32, 32);
1521 		ctx.glFramebufferRenderbuffer		(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[1]);
1522 		ctx.glBlitFramebuffer				(0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1523 		ctx.expectError						(GL_INVALID_OPERATION);
1524 		ctx.endSection();
1525 
1526 		ctx.beginSection("GL_INVALID_OPERATION is generated if GL_SAMPLE_BUFFERS for the read buffer is greater than zero and the source and destination rectangles are not defined with the same (X0, Y0) and (X1, Y1) bounds.");
1527 		ctx.glRenderbufferStorage			(GL_RENDERBUFFER, GL_RGBA8, 32, 32);
1528 		ctx.glFramebufferRenderbuffer		(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[1]);
1529 		ctx.glBlitFramebuffer				(0, 0, 16, 16, 2, 2, 18, 18, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1530 		ctx.expectError						(GL_INVALID_OPERATION);
1531 		ctx.endSection();
1532 	}
1533 
1534 	ctx.glBindFramebuffer				(GL_FRAMEBUFFER, 0);
1535 	ctx.glDeleteRenderbuffers			(2, rbo);
1536 	ctx.glDeleteFramebuffers			(2, fbo);
1537 }
1538 
framebuffer_texture_layer(NegativeTestContext & ctx)1539 void framebuffer_texture_layer (NegativeTestContext& ctx)
1540 {
1541 	deUint32						fbo					= 0x1234;
1542 	deUint32						tex3D				= 0x1234;
1543 	deUint32						tex2DArray			= 0x1234;
1544 	deUint32						tex2D				= 0x1234;
1545 	deUint32						tex2DMSArray		= 0x1234;
1546 	deUint32						texBuffer			= 0x1234;
1547 	int								max3DTexSize		= 0x1234;
1548 	int								maxTexSize			= 0x1234;
1549 	int								maxArrayTexLayers	= 0x1234;
1550 	int								log2Max3DTexSize	= 0x1234;
1551 	int								log2MaxTexSize		= 0x1234;
1552 
1553 	ctx.glGetIntegerv				(GL_MAX_3D_TEXTURE_SIZE, &max3DTexSize);
1554 	ctx.glGetIntegerv				(GL_MAX_TEXTURE_SIZE, &maxTexSize);
1555 	ctx.glGetIntegerv				(GL_MAX_ARRAY_TEXTURE_LAYERS, &maxArrayTexLayers);
1556 
1557 	ctx.glGenFramebuffers			(1, &fbo);
1558 	ctx.glGenTextures				(1, &tex3D);
1559 	ctx.glGenTextures				(1, &tex2DArray);
1560 	ctx.glGenTextures				(1, &tex2D);
1561 	ctx.glBindFramebuffer			(GL_FRAMEBUFFER, fbo);
1562 
1563 	ctx.glBindTexture				(GL_TEXTURE_3D, tex3D);
1564 	ctx.glTexImage3D				(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1565 	ctx.glBindTexture				(GL_TEXTURE_2D_ARRAY, tex2DArray);
1566 	ctx.glTexImage3D				(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1567 	ctx.glBindTexture				(GL_TEXTURE_2D, tex2D);
1568 	ctx.glTexImage2D				(GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1569 
1570 	ctx.expectError					(GL_NO_ERROR);
1571 
1572 	ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
1573 	ctx.glFramebufferTextureLayer	(-1, GL_COLOR_ATTACHMENT0, tex3D, 0, 1);
1574 	ctx.expectError					(GL_INVALID_ENUM);
1575 	ctx.glFramebufferTextureLayer	(GL_RENDERBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, 1);
1576 	ctx.expectError					(GL_INVALID_ENUM);
1577 	ctx.endSection();
1578 
1579 	ctx.beginSection("GL_INVALID_ENUM is generated if attachment is not one of the accepted tokens.");
1580 	ctx.glFramebufferTextureLayer	(GL_FRAMEBUFFER, -1, tex3D, 0, 1);
1581 	ctx.expectError					(GL_INVALID_ENUM);
1582 	ctx.glFramebufferTextureLayer	(GL_FRAMEBUFFER, GL_BACK, tex3D, 0, 1);
1583 	ctx.expectError					(GL_INVALID_ENUM);
1584 	ctx.endSection();
1585 
1586 	ctx.beginSection("GL_INVALID_OPERATION is generated if texture is non-zero and not the name of a 3D texture or 2D array texture, 2D multisample array texture or cube map array texture.");
1587 	ctx.glFramebufferTextureLayer	(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, 0, 0);
1588 	ctx.expectError					(GL_INVALID_OPERATION);
1589 	ctx.glFramebufferTextureLayer	(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2D, 0, 0);
1590 	ctx.expectError					(GL_INVALID_OPERATION);
1591 	ctx.endSection();
1592 
1593 	ctx.beginSection("GL_INVALID_VALUE is generated if texture is not zero and layer is negative.");
1594 	ctx.glFramebufferTextureLayer	(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, -1);
1595 	ctx.expectError					(GL_INVALID_VALUE);
1596 	ctx.endSection();
1597 
1598 	ctx.beginSection("GL_INVALID_VALUE is generated if texture is not zero and layer is greater than GL_MAX_3D_TEXTURE_SIZE-1 for a 3D texture.");
1599 	ctx.glFramebufferTextureLayer	(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, max3DTexSize);
1600 	ctx.expectError					(GL_INVALID_VALUE);
1601 	ctx.endSection();
1602 
1603 	ctx.beginSection("GL_INVALID_VALUE is generated if texture is not zero and layer is greater than GL_MAX_ARRAY_TEXTURE_LAYERS-1 for a 2D array texture.");
1604 	ctx.glFramebufferTextureLayer	(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2DArray, 0, maxArrayTexLayers);
1605 	ctx.expectError					(GL_INVALID_VALUE);
1606 	ctx.endSection();
1607 
1608 	ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
1609 	ctx.glBindFramebuffer			(GL_FRAMEBUFFER, 0);
1610 	ctx.glFramebufferTextureLayer	(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, 1);
1611 	ctx.expectError					(GL_INVALID_OPERATION);
1612 	ctx.glBindFramebuffer			(GL_FRAMEBUFFER, fbo);
1613 	ctx.endSection();
1614 
1615 	ctx.beginSection("GL_INVALID_VALUE is generated if texture is a 3D texture and level is less than 0 or greater than log2 of the value of GL_MAX_3D_TEXTURE_SIZE.");
1616 	log2Max3DTexSize	= deLog2Floor32(max3DTexSize);
1617 	ctx.glFramebufferTextureLayer	(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, -1, max3DTexSize - 1);
1618 	ctx.expectError					(GL_INVALID_VALUE);
1619 	ctx.glFramebufferTextureLayer	(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, log2Max3DTexSize + 1, max3DTexSize - 1);
1620 	ctx.expectError					(GL_INVALID_VALUE);
1621 	ctx.endSection();
1622 
1623 	ctx.beginSection("GL_INVALID_VALUE is generated if texture is a 2D array texture and level is less than 0 or greater than log2 of the value of GL_MAX_TEXTURE_SIZE.");
1624 	log2MaxTexSize		= deLog2Floor32(maxTexSize);
1625 	ctx.glFramebufferTextureLayer	(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2DArray, -1, maxArrayTexLayers - 1);
1626 	ctx.expectError					(GL_INVALID_VALUE);
1627 	ctx.glFramebufferTextureLayer	(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2DArray, log2MaxTexSize + 1, maxArrayTexLayers - 1);
1628 	ctx.expectError					(GL_INVALID_VALUE);
1629 	ctx.endSection();
1630 
1631 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
1632 	{
1633 		deUint32						texCubeArray		= 0x1234;
1634 		int								maxCubeTexSize		= 0x1234;
1635 		ctx.glGetIntegerv				(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &maxCubeTexSize);
1636 		ctx.glGenTextures				(1, &tex2DMSArray);
1637 		ctx.glGenTextures				(1, &texCubeArray);
1638 		ctx.glGenTextures				(1, &texBuffer);
1639 		ctx.glBindTexture				(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, tex2DMSArray);
1640 		ctx.glBindTexture				(GL_TEXTURE_CUBE_MAP_ARRAY, texCubeArray);
1641 		ctx.glBindTexture				(GL_TEXTURE_BUFFER, texBuffer);
1642 		ctx.expectError					(GL_NO_ERROR);
1643 
1644 		ctx.beginSection("GL_INVALID_VALUE is generated if texture is a 2D multisample array texture and level is not 0.");
1645 		ctx.glFramebufferTextureLayer	(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2DMSArray, -1, 0);
1646 		ctx.expectError					(GL_INVALID_VALUE);
1647 		ctx.glFramebufferTextureLayer	(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2DMSArray, 1, 0);
1648 		ctx.expectError					(GL_INVALID_VALUE);
1649 		ctx.endSection();
1650 
1651 		ctx.beginSection("GL_INVALID_VALUE is generated if texture is a cube map array texture and layer is larger than MAX_ARRAY_TEXTURE_LAYERS-1. (See Khronos bug 15968)");
1652 		ctx.glFramebufferTextureLayer	(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texCubeArray, 0, maxArrayTexLayers);
1653 		ctx.expectError					(GL_INVALID_VALUE);
1654 		ctx.endSection();
1655 
1656 		ctx.beginSection("GL_INVALID_OPERATION is generated if texture is the name of a buffer texture.");
1657 		ctx.glFramebufferTextureLayer	(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texBuffer, 0, 0);
1658 		ctx.expectError					(GL_INVALID_OPERATION);
1659 		ctx.endSection();
1660 
1661 		ctx.glDeleteTextures			(1, &tex2DMSArray);
1662 		ctx.glDeleteTextures			(1, &texCubeArray);
1663 		ctx.glDeleteTextures			(1, &texBuffer);
1664 	}
1665 
1666 	ctx.glDeleteTextures		(1, &tex3D);
1667 	ctx.glDeleteTextures		(1, &tex2DArray);
1668 	ctx.glDeleteTextures		(1, &tex2D);
1669 	ctx.glDeleteFramebuffers	(1, &fbo);
1670 }
1671 
invalidate_framebuffer(NegativeTestContext & ctx)1672 void invalidate_framebuffer (NegativeTestContext& ctx)
1673 {
1674 	deUint32	attachments[3];
1675 	deUint32	fbo					= 0x1234;
1676 	deUint32	texture				= 0x1234;
1677 	int			maxColorAttachments = 0x1234;
1678 
1679 	ctx.glGetIntegerv				(GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
1680 	attachments[0]					= GL_COLOR_ATTACHMENT0;
1681 	attachments[1]					= GL_COLOR_ATTACHMENT0 + maxColorAttachments;
1682 	attachments[2]					= GL_DEPTH_STENCIL_ATTACHMENT;
1683 
1684 	ctx.glGenFramebuffers			(1, &fbo);
1685 	ctx.glGenTextures				(1, &texture);
1686 	ctx.glBindFramebuffer			(GL_FRAMEBUFFER, fbo);
1687 	ctx.glBindTexture				(GL_TEXTURE_2D, texture);
1688 	ctx.glTexImage2D				(GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1689 	ctx.glFramebufferTexture2D		(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
1690 	ctx.glCheckFramebufferStatus	(GL_FRAMEBUFFER);
1691 	ctx.expectError					(GL_NO_ERROR);
1692 
1693 	ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_FRAMEBUFFER, GL_READ_FRAMEBUFFER or GL_DRAW_FRAMEBUFFER.");
1694 	ctx.glInvalidateFramebuffer		(-1, 1, &attachments[0]);
1695 	ctx.expectError					(GL_INVALID_ENUM);
1696 	ctx.glInvalidateFramebuffer		(GL_BACK, 1, &attachments[0]);
1697 	ctx.expectError					(GL_INVALID_ENUM);
1698 	ctx.endSection();
1699 
1700 	ctx.beginSection("GL_INVALID_OPERATION is generated if attachments contains GL_COLOR_ATTACHMENTm and m is greater than or equal to the value of GL_MAX_COLOR_ATTACHMENTS.");
1701 	ctx.glInvalidateFramebuffer		(GL_FRAMEBUFFER, 1, &attachments[1]);
1702 	ctx.expectError					(GL_INVALID_OPERATION);
1703 	ctx.endSection();
1704 
1705 	ctx.beginSection("GL_INVALID_VALUE is generated if numAttachments is negative.");
1706 	ctx.glInvalidateFramebuffer		(GL_FRAMEBUFFER, -1, &attachments[0]);
1707 	ctx.expectError					(GL_INVALID_VALUE);
1708 	ctx.endSection();
1709 
1710 	ctx.beginSection("GL_INVALID_ENUM is generated if the default framebuffer is bound to target and any elements of attachments are not one of the accepted attachments.");
1711 	ctx.glBindFramebuffer			(GL_FRAMEBUFFER, 0);
1712 	ctx.glInvalidateFramebuffer		(GL_FRAMEBUFFER, 1, &attachments[2]);
1713 	ctx.expectError					(GL_INVALID_ENUM);
1714 	ctx.endSection();
1715 
1716 
1717 	ctx.glDeleteTextures		(1, &texture);
1718 	ctx.glDeleteFramebuffers	(1, &fbo);
1719 }
1720 
invalidate_sub_framebuffer(NegativeTestContext & ctx)1721 void invalidate_sub_framebuffer (NegativeTestContext& ctx)
1722 {
1723 	deUint32	attachments[3];
1724 	deUint32	fbo					= 0x1234;
1725 	deUint32	texture				= 0x1234;
1726 	int			maxColorAttachments	= 0x1234;
1727 
1728 	ctx.glGetIntegerv				(GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
1729 	attachments[0]					= GL_COLOR_ATTACHMENT0;
1730 	attachments[1]					= GL_COLOR_ATTACHMENT0 + maxColorAttachments;
1731 	attachments[2]					= GL_DEPTH_STENCIL_ATTACHMENT;
1732 
1733 	ctx.glGenFramebuffers			(1, &fbo);
1734 	ctx.glGenTextures				(1, &texture);
1735 	ctx.glBindFramebuffer			(GL_FRAMEBUFFER, fbo);
1736 	ctx.glBindTexture				(GL_TEXTURE_2D, texture);
1737 	ctx.glTexImage2D				(GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1738 	ctx.glFramebufferTexture2D		(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
1739 	ctx.glCheckFramebufferStatus	(GL_FRAMEBUFFER);
1740 	ctx.expectError					(GL_NO_ERROR);
1741 
1742 	ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_FRAMEBUFFER, GL_READ_FRAMEBUFFER or GL_DRAW_FRAMEBUFFER.");
1743 	ctx.glInvalidateSubFramebuffer	(-1, 1, &attachments[0], 0, 0, 16, 16);
1744 	ctx.expectError					(GL_INVALID_ENUM);
1745 	ctx.glInvalidateSubFramebuffer	(GL_BACK, 1, &attachments[0], 0, 0, 16, 16);
1746 	ctx.expectError					(GL_INVALID_ENUM);
1747 	ctx.endSection();
1748 
1749 	ctx.beginSection("GL_INVALID_OPERATION is generated if attachments contains GL_COLOR_ATTACHMENTm and m is greater than or equal to the value of GL_MAX_COLOR_ATTACHMENTS.");
1750 	ctx.glInvalidateSubFramebuffer	(GL_FRAMEBUFFER, 1, &attachments[1], 0, 0, 16, 16);
1751 	ctx.expectError					(GL_INVALID_OPERATION);
1752 	ctx.endSection();
1753 
1754 	ctx.beginSection("GL_INVALID_VALUE is generated if numAttachments, width, or heigh is negative.");
1755 	ctx.glInvalidateSubFramebuffer	(GL_FRAMEBUFFER, -1, &attachments[0], 0, 0, 16, 16);
1756 	ctx.expectError					(GL_INVALID_VALUE);
1757 	ctx.glInvalidateSubFramebuffer	(GL_FRAMEBUFFER, -1, &attachments[0], 0, 0, -1, 16);
1758 	ctx.expectError					(GL_INVALID_VALUE);
1759 	ctx.glInvalidateSubFramebuffer	(GL_FRAMEBUFFER, -1, &attachments[0], 0, 0, 16, -1);
1760 	ctx.expectError					(GL_INVALID_VALUE);
1761 	ctx.glInvalidateSubFramebuffer	(GL_FRAMEBUFFER, -1, &attachments[0], 0, 0, -1, -1);
1762 	ctx.expectError					(GL_INVALID_VALUE);
1763 	ctx.glInvalidateSubFramebuffer	(GL_FRAMEBUFFER, 1, &attachments[0], 0, 0, -1, 16);
1764 	ctx.expectError					(GL_INVALID_VALUE);
1765 	ctx.glInvalidateSubFramebuffer	(GL_FRAMEBUFFER, 1, &attachments[0], 0, 0, 16, -1);
1766 	ctx.expectError					(GL_INVALID_VALUE);
1767 	ctx.glInvalidateSubFramebuffer	(GL_FRAMEBUFFER, 1, &attachments[0], 0, 0, -1, -1);
1768 	ctx.expectError					(GL_INVALID_VALUE);
1769 	ctx.endSection();
1770 
1771 	ctx.beginSection("GL_INVALID_ENUM is generated if the default framebuffer is bound to target and any elements of attachments are not one of the accepted attachments.");
1772 	ctx.glBindFramebuffer			(GL_FRAMEBUFFER, 0);
1773 	ctx.glInvalidateSubFramebuffer	(GL_FRAMEBUFFER, 1, &attachments[2], 0, 0, 16, 16);
1774 	ctx.expectError					(GL_INVALID_ENUM);
1775 	ctx.endSection();
1776 
1777 	ctx.glDeleteTextures		(1, &texture);
1778 	ctx.glDeleteFramebuffers	(1, &fbo);
1779 }
1780 
renderbuffer_storage_multisample(NegativeTestContext & ctx)1781 void renderbuffer_storage_multisample (NegativeTestContext& ctx)
1782 {
1783 	deUint32	rbo							= 0x1234;
1784 	int			maxSamplesSupportedRGBA4	= -1;
1785 	int			maxSamplesSupportedRGBA8UI	= -1;
1786 	GLint		maxSize						= 0x1234;
1787 
1788 	ctx.glGetInternalformativ				(GL_RENDERBUFFER, GL_RGBA4, GL_SAMPLES, 1, &maxSamplesSupportedRGBA4);
1789 	ctx.glGetInternalformativ				(GL_RENDERBUFFER, GL_RGBA8UI, GL_SAMPLES, 1, &maxSamplesSupportedRGBA8UI);
1790 
1791 	ctx.glGenRenderbuffers					(1, &rbo);
1792 	ctx.glBindRenderbuffer					(GL_RENDERBUFFER, rbo);
1793 
1794 	ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
1795 	ctx.glRenderbufferStorageMultisample	(-1, 2, GL_RGBA4, 1, 1);
1796 	ctx.expectError							(GL_INVALID_ENUM);
1797 	ctx.glRenderbufferStorageMultisample	(GL_FRAMEBUFFER, 2, GL_RGBA4, 1, 1);
1798 	ctx.expectError							(GL_INVALID_ENUM);
1799 	ctx.endSection();
1800 
1801 	ctx.beginSection("GL_INVALID_OPERATION is generated if samples is greater than the maximum number of samples supported for internalformat.");
1802 	ctx.glRenderbufferStorageMultisample	(GL_RENDERBUFFER, maxSamplesSupportedRGBA4+1, GL_RGBA4, 1, 1);
1803 	ctx.expectError							(GL_INVALID_OPERATION);
1804 	ctx.endSection();
1805 
1806 	ctx.beginSection("GL_INVALID_ENUM is generated if internalformat is not a color-renderable, depth-renderable, or stencil-renderable format.");
1807 	ctx.glRenderbufferStorageMultisample	(GL_RENDERBUFFER, 2, -1, 1, 1);
1808 	ctx.expectError							(GL_INVALID_ENUM);
1809 
1810 	if (!ctx.isExtensionSupported("GL_EXT_color_buffer_half_float")) // GL_EXT_color_buffer_half_float disables error
1811 	{
1812 		ctx.glRenderbufferStorageMultisample	(GL_RENDERBUFFER, 2, GL_RGB16F, 1, 1);
1813 		ctx.expectError							(GL_INVALID_ENUM);
1814 	}
1815 
1816 	if (!ctx.isExtensionSupported("GL_EXT_render_snorm")) // GL_EXT_render_snorm disables error
1817 	{
1818 		ctx.glRenderbufferStorageMultisample	(GL_RENDERBUFFER, 2, GL_RGBA8_SNORM, 1, 1);
1819 		ctx.expectError							(GL_INVALID_ENUM);
1820 	}
1821 
1822 	ctx.endSection();
1823 
1824 	ctx.beginSection("GL_INVALID_OPERATION is generated if samples is greater than the maximum number of samples supported for internalformat. (Unsigned integer format)");
1825 	ctx.glRenderbufferStorageMultisample	(GL_RENDERBUFFER, maxSamplesSupportedRGBA8UI+1, GL_RGBA8UI, 1, 1);
1826 	ctx.expectError							(GL_INVALID_OPERATION);
1827 	ctx.endSection();
1828 
1829 	ctx.beginSection("GL_INVALID_VALUE is generated if width or height is less than zero.");
1830 	ctx.glRenderbufferStorageMultisample	(GL_RENDERBUFFER, 2, GL_RGBA4, -1, 1);
1831 	ctx.expectError							(GL_INVALID_VALUE);
1832 	ctx.glRenderbufferStorageMultisample	(GL_RENDERBUFFER, 2, GL_RGBA4, 1, -1);
1833 	ctx.expectError							(GL_INVALID_VALUE);
1834 	ctx.glRenderbufferStorageMultisample	(GL_RENDERBUFFER, 2, GL_RGBA4, -1, -1);
1835 	ctx.expectError							(GL_INVALID_VALUE);
1836 	ctx.glRenderbufferStorageMultisample	(GL_RENDERBUFFER, -1, GL_RGBA4, 1, 1);
1837 	ctx.expectError							(GL_INVALID_VALUE);
1838 	ctx.glRenderbufferStorageMultisample	(GL_RENDERBUFFER, -1, GL_RGBA4, -1, 1);
1839 	ctx.expectError							(GL_INVALID_VALUE);
1840 	ctx.glRenderbufferStorageMultisample	(GL_RENDERBUFFER, -1, GL_RGBA4, 1, -1);
1841 	ctx.expectError							(GL_INVALID_VALUE);
1842 	ctx.glRenderbufferStorageMultisample	(GL_RENDERBUFFER, -1, GL_RGBA4, -1, -1);
1843 	ctx.expectError							(GL_INVALID_VALUE);
1844 	ctx.endSection();
1845 
1846 	ctx.beginSection("GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_RENDERBUFFER_SIZE.");
1847 	ctx.glGetIntegerv						(GL_MAX_RENDERBUFFER_SIZE, &maxSize);
1848 	ctx.glRenderbufferStorageMultisample	(GL_RENDERBUFFER, 4, GL_RGBA4, 1, maxSize+1);
1849 	ctx.expectError							(GL_INVALID_VALUE);
1850 	ctx.glRenderbufferStorageMultisample	(GL_RENDERBUFFER, 4, GL_RGBA4, maxSize+1, 1);
1851 	ctx.expectError							(GL_INVALID_VALUE);
1852 	ctx.glRenderbufferStorageMultisample	(GL_RENDERBUFFER, 4, GL_RGBA4, maxSize+1, maxSize+1);
1853 	ctx.expectError							(GL_INVALID_VALUE);
1854 	ctx.endSection();
1855 
1856 	ctx.glDeleteRenderbuffers(1, &rbo);
1857 }
1858 
copy_image_sub_data(NegativeTestContext & ctx)1859 void copy_image_sub_data (NegativeTestContext& ctx)
1860 {
1861 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
1862 	{
1863 		deUint32					texture[5];
1864 		deUint32					rbo = 0x1234;
1865 
1866 		ctx.glGenTextures			(5, texture);
1867 		ctx.glGenRenderbuffers		(1, &rbo);
1868 		ctx.glBindRenderbuffer		(GL_RENDERBUFFER, rbo);
1869 
1870 		ctx.glBindTexture			(GL_TEXTURE_2D, texture[0]);
1871 		ctx.glTexParameteri			(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1872 		ctx.glTexParameteri			(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1873 		ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1874 		ctx.glRenderbufferStorage	(GL_RENDERBUFFER, GL_RGBA8, 32, 32);
1875 		ctx.glBindTexture			(GL_TEXTURE_2D, texture[1]);
1876 		ctx.glTexParameteri			(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1877 		ctx.glTexParameteri			(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1878 		ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1879 		ctx.expectError				(GL_NO_ERROR);
1880 
1881 		ctx.glBindTexture			(GL_TEXTURE_3D, texture[2]);
1882 		ctx.glTexParameteri			(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1883 		ctx.glTexParameteri			(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1884 		ctx.glTexImage3D			(GL_TEXTURE_3D, 0, GL_RGBA8, 32, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1885 		ctx.expectError				(GL_NO_ERROR);
1886 
1887 		ctx.glBindTexture			(GL_TEXTURE_3D, texture[3]);
1888 		ctx.glTexImage3D			(GL_TEXTURE_3D, 0, GL_RGBA8, 32, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1889 		ctx.expectError				(GL_NO_ERROR);
1890 
1891 		ctx.glBindTexture			(GL_TEXTURE_2D, texture[4]);
1892 		ctx.glTexParameteri			(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1893 		ctx.glTexParameteri			(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1894 		ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA32F, 32, 32, 0, GL_RGBA, GL_FLOAT, NULL);
1895 		ctx.expectError				(GL_NO_ERROR);
1896 
1897 		ctx.beginSection("GL_INVALID_VALUE is generated if srcWidth, srcHeight, or srcDepth is negative.");
1898 		ctx.glCopyImageSubData		(texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, -1, 1, 1);
1899 		ctx.expectError				(GL_INVALID_VALUE);
1900 		ctx.glCopyImageSubData		(texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 1, -1, 1);
1901 		ctx.expectError				(GL_INVALID_VALUE);
1902 		ctx.glCopyImageSubData		(texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 1, 1, -1);
1903 		ctx.expectError				(GL_INVALID_VALUE);
1904 		ctx.glCopyImageSubData		(texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, -1, -1, 1);
1905 		ctx.expectError				(GL_INVALID_VALUE);
1906 		ctx.glCopyImageSubData		(texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, -1, 1, -1);
1907 		ctx.expectError				(GL_INVALID_VALUE);
1908 		ctx.glCopyImageSubData		(texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 1, -1, -1);
1909 		ctx.expectError				(GL_INVALID_VALUE);
1910 		ctx.glCopyImageSubData		(texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, -1, -1, -1);
1911 		ctx.expectError				(GL_INVALID_VALUE);
1912 		ctx.endSection();
1913 
1914 		ctx.beginSection("GL_INVALID_VALUE is generated if srcLevel and dstLevel are not valid levels for the corresponding images.");
1915 		ctx.glCopyImageSubData		(texture[0], GL_TEXTURE_2D, 1, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1916 		ctx.expectError				(GL_INVALID_VALUE);
1917 		ctx.glCopyImageSubData		(texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 1, 0, 0, 0, 0, 0, 1);
1918 		ctx.expectError				(GL_INVALID_VALUE);
1919 		ctx.glCopyImageSubData		(texture[0], GL_TEXTURE_2D, 1, 0, 0, 0, texture[1], GL_TEXTURE_2D, 1, 0, 0, 0, 0, 0, 1);
1920 		ctx.expectError				(GL_INVALID_VALUE);
1921 		ctx.glCopyImageSubData		(texture[0], GL_TEXTURE_2D, -1, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1922 		ctx.expectError				(GL_INVALID_VALUE);
1923 		ctx.glCopyImageSubData		(texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, -1, 0, 0, 0, 0, 0, 1);
1924 		ctx.expectError				(GL_INVALID_VALUE);
1925 		ctx.glCopyImageSubData		(texture[0], GL_TEXTURE_2D, -1, 0, 0, 0, texture[1], GL_TEXTURE_2D, -1, 0, 0, 0, 0, 0, 1);
1926 		ctx.expectError				(GL_INVALID_VALUE);
1927 		ctx.glCopyImageSubData		(rbo, GL_RENDERBUFFER, -1, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1928 		ctx.expectError				(GL_INVALID_VALUE);
1929 		ctx.glCopyImageSubData		(rbo, GL_RENDERBUFFER, 1, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1930 		ctx.expectError				(GL_INVALID_VALUE);
1931 		ctx.glCopyImageSubData		(texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, rbo, GL_RENDERBUFFER, -1, 0, 0, 0, 0, 0, 1);
1932 		ctx.expectError				(GL_INVALID_VALUE);
1933 		ctx.glCopyImageSubData		(texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, rbo, GL_RENDERBUFFER, 1, 0, 0, 0, 0, 0, 1);
1934 		ctx.expectError				(GL_INVALID_VALUE);
1935 		ctx.endSection();
1936 
1937 		ctx.beginSection("GL_INVALID_ENUM is generated if either target does not match the type of the object.");
1938 		// \note: This could be either:
1939 		//		1. GL_INVALID_ENUM is generated if either target does not match the type of the object.
1940 		//		2. GL_INVALID_VALUE is generated if either name does not correspond to a valid renderbuffer or texture object according to the corresponding target parameter.
1941 		ctx.glCopyImageSubData		(texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, 1);
1942 		ctx.expectError				(GL_INVALID_ENUM);
1943 		ctx.glCopyImageSubData		(texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[2], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1944 		ctx.expectError				(GL_INVALID_ENUM);
1945 		ctx.glCopyImageSubData		(texture[0], GL_TEXTURE_3D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1946 		ctx.expectError				(GL_INVALID_ENUM);
1947 		ctx.glCopyImageSubData		(texture[2], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1948 		ctx.expectError				(GL_INVALID_ENUM);
1949 		ctx.endSection();
1950 
1951 		ctx.beginSection("GL_INVALID_OPERATION is generated if either object is a texture and the texture is not complete.");
1952 		ctx.glCopyImageSubData		(texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[3], GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, 1);
1953 		ctx.expectError				(GL_INVALID_OPERATION);
1954 		ctx.glCopyImageSubData		(texture[3], GL_TEXTURE_3D, 0, 0, 0, 0, texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1955 		ctx.expectError				(GL_INVALID_OPERATION);
1956 		ctx.glCopyImageSubData		(texture[3], GL_TEXTURE_3D, 0, 0, 0, 0, texture[3], GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, 1);
1957 		ctx.expectError				(GL_INVALID_OPERATION);
1958 		ctx.endSection();
1959 
1960 		ctx.beginSection("GL_INVALID_VALUE is generated if the dimensions of either subregion exceeds the boundaries of the corresponding image object.");
1961 		ctx.glCopyImageSubData		(texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 33, 0, 1);
1962 		ctx.expectError				(GL_INVALID_VALUE);
1963 		ctx.glCopyImageSubData		(texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 33, 1);
1964 		ctx.expectError				(GL_INVALID_VALUE);
1965 		ctx.endSection();
1966 
1967 		ctx.beginSection("GL_INVALID_OPERATION error is generated if the source and destination internal formats are not compatible.");
1968 		ctx.glCopyImageSubData		(texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[4], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1969 		ctx.expectError				(GL_INVALID_OPERATION);
1970 		ctx.glCopyImageSubData		(texture[4], GL_TEXTURE_2D, 0, 0, 0, 0, texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1971 		ctx.expectError				(GL_INVALID_OPERATION);
1972 		ctx.endSection();
1973 
1974 		ctx.glDeleteTextures		(5, texture);
1975 		ctx.glDeleteRenderbuffers	(1, &rbo);
1976 	}
1977 }
1978 
getNegativeBufferApiTestFunctions()1979 std::vector<FunctionContainer> getNegativeBufferApiTestFunctions ()
1980 {
1981 	const FunctionContainer funcs[] =
1982 	{
1983 		{bind_buffer,						"bind_buffer",						"Invalid glBindBuffer() usage"						},
1984 		{delete_buffers,					"delete_buffers",					"Invalid glDeleteBuffers() usage"					},
1985 		{gen_buffers,						"gen_buffers",						"Invalid glGenBuffers() usage"						},
1986 		{buffer_data,						"buffer_data",						"Invalid glBufferData() usage"						},
1987 		{buffer_sub_data,					"buffer_sub_data",					"Invalid glBufferSubData() usage"					},
1988 		{buffer_sub_data_size_offset,		"buffer_sub_data_size_offset",		"Invalid glBufferSubData() usage"					},
1989 		{clear,								"clear",							"Invalid glClear() usage"							},
1990 		{read_pixels,						"read_pixels",						"Invalid glReadPixels() usage"						},
1991 		{readn_pixels,						"readn_pixels",						"Invalid glReadPixels() usage"						},
1992 		{read_pixels_format_mismatch,		"read_pixels_format_mismatch",		"Invalid glReadPixels() usage"						},
1993 		{read_pixels_fbo_format_mismatch,	"read_pixels_fbo_format_mismatch",	"Invalid glReadPixels() usage"						},
1994 		{bind_buffer_range,					"bind_buffer_range",				"Invalid glBindBufferRange() usage"					},
1995 		{bind_buffer_base,					"bind_buffer_base",					"Invalid glBindBufferBase() usage"					},
1996 		{clear_bufferiv,					"clear_bufferiv",					"Invalid glClearBufferiv() usage"					},
1997 		{clear_bufferuiv,					"clear_bufferuiv",					"Invalid glClearBufferuiv() usage"					},
1998 		{clear_bufferfv,					"clear_bufferfv",					"Invalid glClearBufferfv() usage"					},
1999 		{clear_bufferfi,					"clear_bufferfi",					"Invalid glClearBufferfi() usage"					},
2000 		{copy_buffer_sub_data,				"copy_buffer_sub_data",				"Invalid glCopyBufferSubData() usage"				},
2001 		{draw_buffers,						"draw_buffers",						"Invalid glDrawBuffers() usage"						},
2002 		{flush_mapped_buffer_range,			"flush_mapped_buffer_range",		"Invalid glFlushMappedBufferRange() usage"			},
2003 		{map_buffer_range,					"map_buffer_range",					"Invalid glMapBufferRange() usage"					},
2004 		{read_buffer,						"read_buffer",						"Invalid glReadBuffer() usage"						},
2005 		{unmap_buffer,						"unmap_buffer",						"Invalid glUnmapBuffer() usage"						},
2006 		{bind_framebuffer,					"bind_framebuffer",					"Invalid glBindFramebuffer() usage"					},
2007 		{bind_renderbuffer,					"bind_renderbuffer",				"Invalid glBindRenderbuffer() usage"				},
2008 		{check_framebuffer_status,			"check_framebuffer_status",			"Invalid glCheckFramebufferStatus() usage"			},
2009 		{gen_framebuffers,					"gen_framebuffers",					"Invalid glGenFramebuffers() usage"					},
2010 		{gen_renderbuffers,					"gen_renderbuffers",				"Invalid glGenRenderbuffers() usage"				},
2011 		{delete_framebuffers,				"delete_framebuffers",				"Invalid glDeleteFramebuffers() usage"				},
2012 		{delete_renderbuffers,				"delete_renderbuffers",				"Invalid glDeleteRenderbuffers() usage"				},
2013 		{framebuffer_renderbuffer,			"framebuffer_renderbuffer",			"Invalid glFramebufferRenderbuffer() usage"			},
2014 		{framebuffer_texture,				"framebuffer_texture",				"Invalid glFramebufferTexture() usage"				},
2015 		{framebuffer_texture2d,				"framebuffer_texture2d",			"Invalid glFramebufferTexture2D() usage"			},
2016 		{renderbuffer_storage,				"renderbuffer_storage",				"Invalid glRenderbufferStorage() usage"				},
2017 		{blit_framebuffer,					"blit_framebuffer",					"Invalid glBlitFramebuffer() usage"					},
2018 		{blit_framebuffer_multisample,		"blit_framebuffer_multisample",		"Invalid glBlitFramebuffer() usage"					},
2019 		{framebuffer_texture_layer,			"framebuffer_texture_layer",		"Invalid glFramebufferTextureLayer() usage"			},
2020 		{invalidate_framebuffer,			"invalidate_framebuffer",			"Invalid glInvalidateFramebuffer() usage"			},
2021 		{invalidate_sub_framebuffer,		"invalidate_sub_framebuffer",		"Invalid glInvalidateSubFramebuffer() usage"		},
2022 		{renderbuffer_storage_multisample,	"renderbuffer_storage_multisample",	"Invalid glRenderbufferStorageMultisample() usage"	},
2023 		{copy_image_sub_data,				"copy_image_sub_data",				"Invalid glCopyImageSubData() usage"				},
2024 	};
2025 
2026 	return std::vector<FunctionContainer>(DE_ARRAY_BEGIN(funcs), DE_ARRAY_END(funcs));
2027 }
2028 
2029 } // NegativeTestShared
2030 } // Functional
2031 } // gles31
2032 } // deqp
2033