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 #include "gluContextInfo.hpp"
28
29 #include "glwDefs.hpp"
30 #include "glwEnums.hpp"
31
32 namespace deqp
33 {
34 namespace gles31
35 {
36 namespace Functional
37 {
38 namespace NegativeTestShared
39 {
40
41 using tcu::TestLog;
42 using glu::CallLogWrapper;
43 using namespace glw;
44
45 // Buffers
bind_buffer(NegativeTestContext & ctx)46 void bind_buffer (NegativeTestContext& ctx)
47 {
48 ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the allowable values.");
49 ctx.glBindBuffer(-1, 0);
50 ctx.expectError(GL_INVALID_ENUM);
51 ctx.endSection();
52 }
53
delete_buffers(NegativeTestContext & ctx)54 void delete_buffers (NegativeTestContext& ctx)
55 {
56 ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
57 ctx.glDeleteBuffers(-1, 0);
58 ctx.expectError(GL_INVALID_VALUE);
59 ctx.endSection();
60 }
61
gen_buffers(NegativeTestContext & ctx)62 void gen_buffers (NegativeTestContext& ctx)
63 {
64 ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
65 ctx.glGenBuffers(-1, 0);
66 ctx.expectError(GL_INVALID_VALUE);
67 ctx.endSection();
68 }
69
buffer_data(NegativeTestContext & ctx)70 void buffer_data (NegativeTestContext& ctx)
71 {
72 GLuint buffer = 0x1234;
73 ctx.glGenBuffers(1, &buffer);
74 ctx.glBindBuffer(GL_ARRAY_BUFFER, buffer);
75
76 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER.");
77 ctx.glBufferData(-1, 0, NULL, GL_STREAM_DRAW);
78 ctx.expectError(GL_INVALID_ENUM);
79 ctx.endSection();
80
81 ctx.beginSection("GL_INVALID_ENUM is generated if usage is not GL_STREAM_DRAW, GL_STATIC_DRAW, or GL_DYNAMIC_DRAW.");
82 ctx.glBufferData(GL_ARRAY_BUFFER, 0, NULL, -1);
83 ctx.expectError(GL_INVALID_ENUM);
84 ctx.endSection();
85
86 ctx.beginSection("GL_INVALID_VALUE is generated if size is negative.");
87 ctx.glBufferData(GL_ARRAY_BUFFER, -1, NULL, GL_STREAM_DRAW);
88 ctx.expectError(GL_INVALID_VALUE);
89 ctx.endSection();
90
91 ctx.beginSection("GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.");
92 ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
93 ctx.glBufferData(GL_ARRAY_BUFFER, 0, NULL, GL_STREAM_DRAW);
94 ctx.expectError(GL_INVALID_OPERATION);
95 ctx.endSection();
96
97 ctx.glDeleteBuffers(1, &buffer);
98 }
99
buffer_sub_data(NegativeTestContext & ctx)100 void buffer_sub_data (NegativeTestContext& ctx)
101 {
102 GLuint buffer = 0x1234;
103 ctx.glGenBuffers(1, &buffer);
104 ctx.glBindBuffer(GL_ARRAY_BUFFER, buffer);
105 ctx.glBufferData(GL_ARRAY_BUFFER, 10, 0, GL_STREAM_DRAW);
106
107 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER.");
108 ctx.glBufferSubData(-1, 1, 1, 0);
109 ctx.expectError(GL_INVALID_ENUM);
110 ctx.endSection();
111
112 ctx.beginSection("GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.");
113 ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
114 ctx.glBufferSubData(GL_ARRAY_BUFFER, 1, 1, 0);
115 ctx.expectError(GL_INVALID_OPERATION);
116 ctx.endSection();
117
118 ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer object being updated is mapped.");
119 ctx.glBindBuffer(GL_ARRAY_BUFFER, buffer);
120 ctx.glMapBufferRange(GL_ARRAY_BUFFER, 0, 5, GL_MAP_READ_BIT);
121 ctx.expectError(GL_NO_ERROR);
122 ctx.glBufferSubData(GL_ARRAY_BUFFER, 1, 1, 0);
123 ctx.expectError(GL_INVALID_OPERATION);
124 ctx.endSection();
125
126 ctx.glDeleteBuffers(1, &buffer);
127 }
128
buffer_sub_data_size_offset(NegativeTestContext & ctx)129 void buffer_sub_data_size_offset (NegativeTestContext& ctx)
130 {
131 GLuint buffer = 0x1234;
132 ctx.glGenBuffers(1, &buffer);
133 ctx.glBindBuffer(GL_ARRAY_BUFFER, buffer);
134 ctx.glBufferData(GL_ARRAY_BUFFER, 10, 0, GL_STREAM_DRAW);
135
136 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.");
137 ctx.glBufferSubData(GL_ARRAY_BUFFER, -1, 1, 0);
138 ctx.expectError(GL_INVALID_VALUE);
139 ctx.glBufferSubData(GL_ARRAY_BUFFER, -1, -1, 0);
140 ctx.expectError(GL_INVALID_VALUE);
141 ctx.glBufferSubData(GL_ARRAY_BUFFER, 1, -1, 0);
142 ctx.expectError(GL_INVALID_VALUE);
143 ctx.glBufferSubData(GL_ARRAY_BUFFER, 15, 1, 0);
144 ctx.expectError(GL_INVALID_VALUE);
145 ctx.glBufferSubData(GL_ARRAY_BUFFER, 1, 15, 0);
146 ctx.expectError(GL_INVALID_VALUE);
147 ctx.glBufferSubData(GL_ARRAY_BUFFER, 8, 8, 0);
148 ctx.expectError(GL_INVALID_VALUE);
149 ctx.endSection();
150
151 ctx.glDeleteBuffers(1, &buffer);
152 }
153
clear(NegativeTestContext & ctx)154 void clear (NegativeTestContext& ctx)
155 {
156 ctx.beginSection("GL_INVALID_VALUE is generated if any bit other than the three defined bits is set in mask.");
157 ctx.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
158 ctx.expectError(GL_NO_ERROR);
159 ctx.glClear(0x00000200);
160 ctx.expectError(GL_INVALID_VALUE);
161 ctx.glClear(0x00001000);
162 ctx.expectError(GL_INVALID_VALUE);
163 ctx.glClear(0x00000010);
164 ctx.expectError(GL_INVALID_VALUE);
165 ctx.endSection();
166 }
167
read_pixels(NegativeTestContext & ctx)168 void read_pixels (NegativeTestContext& ctx)
169 {
170 std::vector<GLubyte> ubyteData(4);
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 GLuint fbo = 0x1234;
188 ctx.glGenFramebuffers(1, &fbo);
189 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
190 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
191 ctx.glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
192 ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
193 ctx.endSection();
194
195 ctx.glDeleteFramebuffers(1, &fbo);
196 }
197
read_pixels_format_mismatch(NegativeTestContext & ctx)198 void read_pixels_format_mismatch (NegativeTestContext& ctx)
199 {
200 std::vector<GLubyte> ubyteData(4);
201 std::vector<GLushort> ushortData(4);
202
203 ctx.beginSection("Unsupported combinations of format and type will generate an INVALID_OPERATION error.");
204 ctx.glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_SHORT_5_6_5, &ushortData[0]);
205 ctx.expectError(GL_INVALID_OPERATION);
206 ctx.glReadPixels(0, 0, 1, 1, GL_ALPHA, GL_UNSIGNED_SHORT_5_6_5, &ushortData[0]);
207 ctx.expectError(GL_INVALID_OPERATION);
208 ctx.glReadPixels(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, &ushortData[0]);
209 ctx.expectError(GL_INVALID_OPERATION);
210 ctx.glReadPixels(0, 0, 1, 1, GL_ALPHA, GL_UNSIGNED_SHORT_4_4_4_4, &ushortData[0]);
211 ctx.expectError(GL_INVALID_OPERATION);
212 ctx.glReadPixels(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, &ushortData[0]);
213 ctx.expectError(GL_INVALID_OPERATION);
214 ctx.glReadPixels(0, 0, 1, 1, GL_ALPHA, GL_UNSIGNED_SHORT_5_5_5_1, &ushortData[0]);
215 ctx.expectError(GL_INVALID_OPERATION);
216 ctx.endSection();
217
218 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.");
219 ctx.glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
220 ctx.expectError(GL_NO_ERROR);
221 GLint readFormat = 0x1234;
222 GLint readType = 0x1234;
223 ctx.glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &readFormat);
224 ctx.glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &readType);
225 ctx.glReadPixels(0, 0, 1, 1, readFormat, readType, &ubyteData[0]);
226 ctx.expectError(GL_NO_ERROR);
227 ctx.endSection();
228 }
229
read_pixels_fbo_format_mismatch(NegativeTestContext & ctx)230 void read_pixels_fbo_format_mismatch (NegativeTestContext& ctx)
231 {
232 std::vector<GLubyte> ubyteData(4);
233 std::vector<float> floatData(4);
234 deUint32 fbo = 0x1234;
235 deUint32 texture = 0x1234;
236
237 ctx.glGenTextures (1, &texture);
238 ctx.glBindTexture (GL_TEXTURE_2D, texture);
239 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
240 ctx.glGenFramebuffers (1, &fbo);
241 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
242 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
243 ctx.expectError (GL_NO_ERROR);
244
245 ctx.beginSection("GL_INVALID_OPERATION is generated if currently bound framebuffer format is incompatible with format and type.");
246
247 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
248 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
249 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
250 ctx.expectError (GL_NO_ERROR);
251 ctx.glReadPixels (0, 0, 1, 1, GL_RGBA, GL_FLOAT, &floatData[0]);
252 ctx.expectError (GL_INVALID_OPERATION);
253
254 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL);
255 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
256 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
257 ctx.expectError (GL_NO_ERROR);
258 ctx.glReadPixels (0, 0, 1, 1, GL_RGBA, GL_FLOAT, &floatData[0]);
259 ctx.expectError (GL_INVALID_OPERATION);
260
261 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
262 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
263 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
264 ctx.expectError (GL_NO_ERROR);
265 ctx.glReadPixels (0, 0, 1, 1, GL_RGBA, GL_FLOAT, &floatData[0]);
266 ctx.expectError (GL_INVALID_OPERATION);
267
268 ctx.endSection();
269
270 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.");
271
272 int binding = -1;
273 int sampleBuffers = 0x1234;
274 deUint32 rbo = 0x1234;
275
276 ctx.glGenRenderbuffers(1, &rbo);
277 ctx.glBindRenderbuffer(GL_RENDERBUFFER, rbo);
278 ctx.glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA8, 32, 32);
279 ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo);
280
281 ctx.glGetIntegerv (GL_READ_FRAMEBUFFER_BINDING, &binding);
282 ctx.getLog() << TestLog::Message << "// GL_READ_FRAMEBUFFER_BINDING: " << binding << TestLog::EndMessage;
283 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
284 ctx.glGetIntegerv (GL_SAMPLE_BUFFERS, &sampleBuffers);
285 ctx.getLog() << TestLog::Message << "// GL_SAMPLE_BUFFERS: " << sampleBuffers << TestLog::EndMessage;
286 ctx.expectError (GL_NO_ERROR);
287
288 if (binding == 0 || sampleBuffers <= 0)
289 {
290 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;
291 ctx.fail("Got invalid value");
292 }
293 else
294 {
295 ctx.glReadPixels (0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
296 ctx.expectError (GL_INVALID_OPERATION);
297 }
298
299 ctx.endSection();
300
301 ctx.glBindRenderbuffer (GL_RENDERBUFFER, 0);
302 ctx.glBindTexture (GL_TEXTURE_2D, 0);
303 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
304 ctx.glDeleteFramebuffers (1, &fbo);
305 ctx.glDeleteTextures (1, &texture);
306 ctx.glDeleteRenderbuffers (1, &rbo);
307 }
308
bind_buffer_range(NegativeTestContext & ctx)309 void bind_buffer_range (NegativeTestContext& ctx)
310 {
311 deUint32 bufU = 0x1234;
312 ctx.glGenBuffers(1, &bufU);
313 ctx.glBindBuffer(GL_UNIFORM_BUFFER, bufU);
314 ctx.glBufferData(GL_UNIFORM_BUFFER, 16, NULL, GL_STREAM_DRAW);
315
316 deUint32 bufTF = 0x1234;
317 ctx.glGenBuffers(1, &bufTF);
318 ctx.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, bufTF);
319 ctx.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 16, NULL, GL_STREAM_DRAW);
320
321 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_TRANSFORM_FEEDBACK_BUFFER or GL_UNIFORM_BUFFER.");
322 ctx.glBindBufferRange(GL_ARRAY_BUFFER, 0, bufU, 0, 4);
323 ctx.expectError(GL_INVALID_ENUM);
324 ctx.endSection();
325
326 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.");
327 int maxTFSize = 0x1234;
328 ctx.glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &maxTFSize);
329 ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, maxTFSize, bufTF, 0, 4);
330 ctx.expectError(GL_INVALID_VALUE);
331 ctx.endSection();
332
333 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.");
334 int maxUSize = 0x1234;
335 ctx.glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUSize);
336 ctx.glBindBufferRange(GL_UNIFORM_BUFFER, maxUSize, bufU, 0, 4);
337 ctx.expectError(GL_INVALID_VALUE);
338 ctx.endSection();
339
340 ctx.beginSection("GL_INVALID_VALUE is generated if size is less than or equal to zero.");
341 ctx.glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, 0, -1);
342 ctx.expectError(GL_INVALID_VALUE);
343 ctx.glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, 0, 0);
344 ctx.expectError(GL_INVALID_VALUE);
345 ctx.endSection();
346
347 ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_TRANSFORM_FEEDBACK_BUFFER and size or offset are not multiples of 4.");
348 ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, bufTF, 4, 5);
349 ctx.expectError(GL_INVALID_VALUE);
350 ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, bufTF, 5, 4);
351 ctx.expectError(GL_INVALID_VALUE);
352 ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, bufTF, 5, 7);
353 ctx.expectError(GL_INVALID_VALUE);
354 ctx.endSection();
355
356 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.");
357 int alignment = 0x1234;
358 ctx.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &alignment);
359 ctx.glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, alignment+1, 4);
360 ctx.expectError(GL_INVALID_VALUE);
361 ctx.endSection();
362
363 ctx.glDeleteBuffers(1, &bufU);
364 ctx.glDeleteBuffers(1, &bufTF);
365 }
366
bind_buffer_base(NegativeTestContext & ctx)367 void bind_buffer_base (NegativeTestContext& ctx)
368 {
369 deUint32 bufU = 0x1234;
370 ctx.glGenBuffers(1, &bufU);
371 ctx.glBindBuffer(GL_UNIFORM_BUFFER, bufU);
372 ctx.glBufferData(GL_UNIFORM_BUFFER, 16, NULL, GL_STREAM_DRAW);
373
374 deUint32 bufTF = 0x1234;
375 ctx.glGenBuffers(1, &bufTF);
376 ctx.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, bufTF);
377 ctx.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 16, NULL, GL_STREAM_DRAW);
378 ctx.expectError(GL_NO_ERROR);
379
380 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_TRANSFORM_FEEDBACK_BUFFER or GL_UNIFORM_BUFFER.");
381 ctx.glBindBufferBase(-1, 0, bufU);
382 ctx.expectError(GL_INVALID_ENUM);
383 ctx.glBindBufferBase(GL_ARRAY_BUFFER, 0, bufU);
384 ctx.expectError(GL_INVALID_ENUM);
385 ctx.endSection();
386
387 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.");
388 int maxUSize = 0x1234;
389 ctx.glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUSize);
390 ctx.glBindBufferBase(GL_UNIFORM_BUFFER, maxUSize, bufU);
391 ctx.expectError(GL_INVALID_VALUE);
392 ctx.endSection();
393
394 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.");
395 int maxTFSize = 0x1234;
396 ctx.glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &maxTFSize);
397 ctx.glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, maxTFSize, bufTF);
398 ctx.expectError(GL_INVALID_VALUE);
399 ctx.endSection();
400
401 ctx.glDeleteBuffers(1, &bufU);
402 ctx.glDeleteBuffers(1, &bufTF);
403 }
404
clear_bufferiv(NegativeTestContext & ctx)405 void clear_bufferiv (NegativeTestContext& ctx)
406 {
407 std::vector<int> data(32*32);
408 deUint32 fbo = 0x1234;
409 deUint32 texture = 0x1234;
410
411 ctx.glGenTextures (1, &texture);
412 ctx.glBindTexture (GL_TEXTURE_2D, texture);
413 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL);
414 ctx.glGenFramebuffers (1, &fbo);
415 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
416 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
417 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
418 ctx.expectError (GL_NO_ERROR);
419
420 ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not an accepted value.");
421 ctx.glClearBufferiv(-1, 0, &data[0]);
422 ctx.expectError(GL_INVALID_ENUM);
423 ctx.glClearBufferiv(GL_FRAMEBUFFER, 0, &data[0]);
424 ctx.expectError(GL_INVALID_ENUM);
425 ctx.endSection();
426
427 ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR, GL_FRONT, GL_BACK, GL_LEFT, GL_RIGHT, or GL_FRONT_AND_BACK and drawBuffer is greater than or equal to GL_MAX_DRAW_BUFFERS.");
428 int maxDrawBuffers = 0x1234;
429 ctx.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
430 ctx.glClearBufferiv(GL_COLOR, maxDrawBuffers, &data[0]);
431 ctx.expectError(GL_INVALID_VALUE);
432 ctx.endSection();
433
434 ctx.beginSection("GL_INVALID_ENUM is generated if buffer is GL_DEPTH or GL_DEPTH_STENCIL.");
435 ctx.glClearBufferiv(GL_DEPTH, 1, &data[0]);
436 ctx.expectError(GL_INVALID_ENUM);
437 ctx.glClearBufferiv(GL_DEPTH_STENCIL, 1, &data[0]);
438 ctx.expectError(GL_INVALID_ENUM);
439 ctx.endSection();
440
441 ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_STENCIL and drawBuffer is not zero.");
442 ctx.glClearBufferiv(GL_STENCIL, 1, &data[0]);
443 ctx.expectError(GL_INVALID_VALUE);
444 ctx.endSection();
445
446 ctx.glDeleteFramebuffers(1, &fbo);
447 ctx.glDeleteTextures(1, &texture);
448 }
449
clear_bufferuiv(NegativeTestContext & ctx)450 void clear_bufferuiv (NegativeTestContext& ctx)
451 {
452 std::vector<deUint32> data(32*32);
453 deUint32 fbo = 0x1234;
454 deUint32 texture = 0x1234;
455
456 ctx.glGenTextures (1, &texture);
457 ctx.glBindTexture (GL_TEXTURE_2D, texture);
458 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
459 ctx.glGenFramebuffers (1, &fbo);
460 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
461 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
462 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
463 ctx.expectError (GL_NO_ERROR);
464
465 ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not an accepted value.");
466 ctx.glClearBufferuiv(-1, 0, &data[0]);
467 ctx.expectError(GL_INVALID_ENUM);
468 ctx.glClearBufferuiv(GL_FRAMEBUFFER, 0, &data[0]);
469 ctx.expectError(GL_INVALID_ENUM);
470 ctx.endSection();
471
472 ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR, GL_FRONT, GL_BACK, GL_LEFT, GL_RIGHT, or GL_FRONT_AND_BACK and drawBuffer is greater than or equal to GL_MAX_DRAW_BUFFERS.");
473 int maxDrawBuffers = 0x1234;
474 ctx.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
475 ctx.glClearBufferuiv(GL_COLOR, maxDrawBuffers, &data[0]);
476 ctx.expectError(GL_INVALID_VALUE);
477 ctx.endSection();
478
479 ctx.beginSection("GL_INVALID_ENUM is generated if buffer is GL_DEPTH, GL_STENCIL or GL_DEPTH_STENCIL.");
480 ctx.glClearBufferuiv(GL_DEPTH, 1, &data[0]);
481 ctx.expectError(GL_INVALID_ENUM);
482 ctx.glClearBufferuiv(GL_STENCIL, 1, &data[0]);
483 ctx.expectError(GL_INVALID_ENUM);
484 ctx.glClearBufferuiv(GL_DEPTH_STENCIL, 1, &data[0]);
485 ctx.expectError(GL_INVALID_ENUM);
486 ctx.endSection();
487
488 ctx.glDeleteFramebuffers(1, &fbo);
489 ctx.glDeleteTextures(1, &texture);
490 }
491
clear_bufferfv(NegativeTestContext & ctx)492 void clear_bufferfv (NegativeTestContext& ctx)
493 {
494 std::vector<float> data(32*32);
495 deUint32 fbo = 0x1234;
496 deUint32 texture = 0x1234;
497
498 ctx.glGenTextures (1, &texture);
499 ctx.glBindTexture (GL_TEXTURE_2D, texture);
500 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32F, 32, 32, 0, GL_RGBA, GL_FLOAT, NULL);
501 ctx.glGenFramebuffers (1, &fbo);
502 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
503 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
504 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
505 ctx.expectError (GL_NO_ERROR);
506
507 ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not an accepted value.");
508 ctx.glClearBufferfv(-1, 0, &data[0]);
509 ctx.expectError(GL_INVALID_ENUM);
510 ctx.glClearBufferfv(GL_FRAMEBUFFER, 0, &data[0]);
511 ctx.expectError(GL_INVALID_ENUM);
512 ctx.endSection();
513
514 ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR, GL_FRONT, GL_BACK, GL_LEFT, GL_RIGHT, or GL_FRONT_AND_BACK and drawBuffer is greater than or equal to GL_MAX_DRAW_BUFFERS.");
515 int maxDrawBuffers = 0x1234;
516 ctx.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
517 ctx.glClearBufferfv(GL_COLOR, maxDrawBuffers, &data[0]);
518 ctx.expectError(GL_INVALID_VALUE);
519 ctx.endSection();
520
521 ctx.beginSection("GL_INVALID_ENUM is generated if buffer is GL_STENCIL or GL_DEPTH_STENCIL.");
522 ctx.glClearBufferfv(GL_STENCIL, 1, &data[0]);
523 ctx.expectError(GL_INVALID_ENUM);
524 ctx.glClearBufferfv(GL_DEPTH_STENCIL, 1, &data[0]);
525 ctx.expectError(GL_INVALID_ENUM);
526 ctx.endSection();
527
528 ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_DEPTH and drawBuffer is not zero.");
529 ctx.glClearBufferfv(GL_DEPTH, 1, &data[0]);
530 ctx.expectError(GL_INVALID_VALUE);
531 ctx.endSection();
532
533 ctx.glDeleteFramebuffers(1, &fbo);
534 ctx.glDeleteTextures(1, &texture);
535 }
536
clear_bufferfi(NegativeTestContext & ctx)537 void clear_bufferfi (NegativeTestContext& ctx)
538 {
539 ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not an accepted value.");
540 ctx.glClearBufferfi(-1, 0, 1.0f, 1);
541 ctx.expectError(GL_INVALID_ENUM);
542 ctx.glClearBufferfi(GL_FRAMEBUFFER, 0, 1.0f, 1);
543 ctx.expectError(GL_INVALID_ENUM);
544 ctx.endSection();
545
546 ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not GL_DEPTH_STENCIL.");
547 ctx.glClearBufferfi(GL_DEPTH, 0, 1.0f, 1);
548 ctx.expectError(GL_INVALID_ENUM);
549 ctx.glClearBufferfi(GL_STENCIL, 0, 1.0f, 1);
550 ctx.expectError(GL_INVALID_ENUM);
551 ctx.glClearBufferfi(GL_COLOR, 0, 1.0f, 1);
552 ctx.expectError(GL_INVALID_ENUM);
553 ctx.endSection();
554
555 ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_DEPTH_STENCIL and drawBuffer is not zero.");
556 ctx.glClearBufferfi(GL_DEPTH_STENCIL, 1, 1.0f, 1);
557 ctx.expectError(GL_INVALID_VALUE);
558 ctx.endSection();
559 }
560
copy_buffer_sub_data(NegativeTestContext & ctx)561 void copy_buffer_sub_data (NegativeTestContext& ctx)
562 {
563 deUint32 buf[2];
564 std::vector<float> data(32*32);
565
566 ctx.glGenBuffers (2, buf);
567 ctx.glBindBuffer (GL_COPY_READ_BUFFER, buf[0]);
568 ctx.glBufferData (GL_COPY_READ_BUFFER, 32, &data[0], GL_DYNAMIC_COPY);
569 ctx.glBindBuffer (GL_COPY_WRITE_BUFFER, buf[1]);
570 ctx.glBufferData (GL_COPY_WRITE_BUFFER, 32, &data[0], GL_DYNAMIC_COPY);
571 ctx.expectError (GL_NO_ERROR);
572
573 ctx.beginSection("GL_INVALID_VALUE is generated if any of readoffset, writeoffset or size is negative.");
574 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, -4);
575 ctx.expectError (GL_INVALID_VALUE);
576 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, -1, 0, 4);
577 ctx.expectError (GL_INVALID_VALUE);
578 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, -1, 4);
579 ctx.expectError (GL_INVALID_VALUE);
580 ctx.endSection();
581
582 ctx.beginSection("GL_INVALID_VALUE is generated if readoffset + size exceeds the size of the buffer object bound to readtarget.");
583 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 36);
584 ctx.expectError (GL_INVALID_VALUE);
585 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 24, 0, 16);
586 ctx.expectError (GL_INVALID_VALUE);
587 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 36, 0, 4);
588 ctx.expectError (GL_INVALID_VALUE);
589 ctx.endSection();
590
591 ctx.beginSection("GL_INVALID_VALUE is generated if writeoffset + size exceeds the size of the buffer object bound to writetarget.");
592 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 36);
593 ctx.expectError (GL_INVALID_VALUE);
594 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 24, 16);
595 ctx.expectError (GL_INVALID_VALUE);
596 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 36, 4);
597 ctx.expectError (GL_INVALID_VALUE);
598 ctx.endSection();
599
600 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.");
601 ctx.glBindBuffer (GL_COPY_WRITE_BUFFER, buf[0]);
602 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 16, 4);
603 ctx.expectError (GL_NO_ERROR);
604 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 4);
605 ctx.expectError (GL_INVALID_VALUE);
606 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 16, 18);
607 ctx.expectError (GL_INVALID_VALUE);
608 ctx.glBindBuffer (GL_COPY_WRITE_BUFFER, buf[1]);
609 ctx.endSection();
610
611 ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to readtarget or writetarget.");
612 ctx.glBindBuffer (GL_COPY_READ_BUFFER, 0);
613 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16);
614 ctx.expectError (GL_INVALID_OPERATION);
615
616 ctx.glBindBuffer (GL_COPY_READ_BUFFER, buf[0]);
617 ctx.glBindBuffer (GL_COPY_WRITE_BUFFER, 0);
618 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16);
619 ctx.expectError (GL_INVALID_OPERATION);
620
621 ctx.glBindBuffer (GL_COPY_WRITE_BUFFER, buf[1]);
622 ctx.endSection();
623
624 ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer object bound to either readtarget or writetarget is mapped.");
625 ctx.glMapBufferRange (GL_COPY_READ_BUFFER, 0, 4, GL_MAP_READ_BIT);
626 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16);
627 ctx.expectError (GL_INVALID_OPERATION);
628 ctx.glUnmapBuffer (GL_COPY_READ_BUFFER);
629
630 ctx.glMapBufferRange (GL_COPY_WRITE_BUFFER, 0, 4, GL_MAP_READ_BIT);
631 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16);
632 ctx.expectError (GL_INVALID_OPERATION);
633 ctx.glUnmapBuffer (GL_COPY_WRITE_BUFFER);
634 ctx.endSection();
635
636 ctx.glDeleteBuffers(2, buf);
637 }
638
draw_buffers(NegativeTestContext & ctx)639 void draw_buffers (NegativeTestContext& ctx)
640 {
641 deUint32 fbo = 0x1234;
642 deUint32 texture = 0x1234;
643 int maxDrawBuffers = 0x1234;
644 ctx.glGetIntegerv (GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
645 std::vector<deUint32> values(maxDrawBuffers+1);
646 values[0] = GL_NONE;
647 values[1] = GL_BACK;
648 values[2] = GL_COLOR_ATTACHMENT0;
649 values[3] = GL_DEPTH_ATTACHMENT;
650 std::vector<GLfloat> data(32*32);
651
652 ctx.glGenTextures (1, &texture);
653 ctx.glBindTexture (GL_TEXTURE_2D, texture);
654 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
655 ctx.glGenFramebuffers (1, &fbo);
656 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
657 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
658 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
659 ctx.expectError (GL_NO_ERROR);
660
661 ctx.beginSection("GL_INVALID_ENUM is generated if one of the values in bufs is not an accepted value.");
662 ctx.glDrawBuffers (2, &values[2]);
663 ctx.expectError (GL_INVALID_ENUM);
664 ctx.endSection();
665
666 ctx.beginSection("GL_INVALID_OPERATION is generated if the GL is bound to the default framebuffer and n is not 1.");
667 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
668 ctx.glDrawBuffers (2, &values[0]);
669 ctx.expectError (GL_INVALID_OPERATION);
670 ctx.endSection();
671
672 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.");
673 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
674 ctx.glDrawBuffers (1, &values[2]);
675 ctx.expectError (GL_INVALID_OPERATION);
676 ctx.endSection();
677
678 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.");
679 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
680 ctx.glDrawBuffers (1, &values[1]);
681 ctx.expectError (GL_INVALID_OPERATION);
682 ctx.endSection();
683
684 ctx.beginSection("GL_INVALID_VALUE is generated if n is less than 0 or greater than GL_MAX_DRAW_BUFFERS.");
685 ctx.glDrawBuffers (-1, &values[1]);
686 ctx.expectError (GL_INVALID_VALUE);
687 ctx.glDrawBuffers (maxDrawBuffers+1, &values[0]);
688 ctx.expectError (GL_INVALID_VALUE);
689 ctx.endSection();
690
691 ctx.glDeleteTextures(1, &texture);
692 ctx.glDeleteFramebuffers(1, &fbo);
693 }
694
flush_mapped_buffer_range(NegativeTestContext & ctx)695 void flush_mapped_buffer_range (NegativeTestContext& ctx)
696 {
697 deUint32 buf = 0x1234;
698 std::vector<GLfloat> data(32);
699
700 ctx.glGenBuffers (1, &buf);
701 ctx.glBindBuffer (GL_ARRAY_BUFFER, buf);
702 ctx.glBufferData (GL_ARRAY_BUFFER, 32, &data[0], GL_STATIC_READ);
703 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT);
704 ctx.expectError (GL_NO_ERROR);
705
706 ctx.beginSection("GL_INVALID_VALUE is generated if offset or length is negative, or if offset + length exceeds the size of the mapping.");
707 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, -1, 1);
708 ctx.expectError (GL_INVALID_VALUE);
709 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, -1);
710 ctx.expectError (GL_INVALID_VALUE);
711 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 12, 8);
712 ctx.expectError (GL_INVALID_VALUE);
713 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 24, 4);
714 ctx.expectError (GL_INVALID_VALUE);
715 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 24);
716 ctx.expectError (GL_INVALID_VALUE);
717 ctx.endSection();
718
719 ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
720 ctx.glBindBuffer (GL_ARRAY_BUFFER, 0);
721 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 8);
722 ctx.expectError (GL_INVALID_OPERATION);
723 ctx.endSection();
724
725 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.");
726 ctx.glBindBuffer (GL_ARRAY_BUFFER, buf);
727 ctx.glUnmapBuffer (GL_ARRAY_BUFFER);
728 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 8);
729 ctx.expectError (GL_INVALID_OPERATION);
730 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT);
731 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 8);
732 ctx.expectError (GL_INVALID_OPERATION);
733 ctx.endSection();
734
735 ctx.glUnmapBuffer (GL_ARRAY_BUFFER);
736 ctx.glDeleteBuffers (1, &buf);
737 }
738
map_buffer_range(NegativeTestContext & ctx)739 void map_buffer_range (NegativeTestContext& ctx)
740 {
741 deUint32 buf = 0x1234;
742 std::vector<GLfloat> data(32);
743
744 ctx.glGenBuffers (1, &buf);
745 ctx.glBindBuffer (GL_ARRAY_BUFFER, buf);
746 ctx.glBufferData (GL_ARRAY_BUFFER, 32, &data[0], GL_DYNAMIC_COPY);
747 ctx.expectError (GL_NO_ERROR);
748
749 ctx.beginSection("GL_INVALID_VALUE is generated if either of offset or length is negative.");
750 ctx.glMapBufferRange (GL_ARRAY_BUFFER, -1, 1, GL_MAP_READ_BIT);
751 ctx.expectError (GL_INVALID_VALUE);
752
753 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 1, -1, GL_MAP_READ_BIT);
754 ctx.expectError (GL_INVALID_VALUE);
755 ctx.endSection();
756
757 ctx.beginSection("GL_INVALID_VALUE is generated if offset + length is greater than the value of GL_BUFFER_SIZE.");
758 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 33, GL_MAP_READ_BIT);
759 ctx.expectError (GL_INVALID_VALUE);
760
761 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 32, 1, GL_MAP_READ_BIT);
762 ctx.expectError (GL_INVALID_VALUE);
763
764 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 16, 17, GL_MAP_READ_BIT);
765 ctx.expectError (GL_INVALID_VALUE);
766 ctx.endSection();
767
768 ctx.beginSection("GL_INVALID_VALUE is generated if access has any bits set other than those accepted.");
769 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | 0x1000);
770 ctx.expectError (GL_INVALID_VALUE);
771
772 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT | 0x1000);
773 ctx.expectError (GL_INVALID_VALUE);
774 ctx.endSection();
775
776 ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer is already in a mapped state.");
777 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT);
778 ctx.expectError (GL_NO_ERROR);
779 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 16, 8, GL_MAP_READ_BIT);
780 ctx.expectError (GL_INVALID_OPERATION);
781 ctx.glUnmapBuffer (GL_ARRAY_BUFFER);
782 ctx.endSection();
783
784 ctx.beginSection("GL_INVALID_OPERATION is generated if neither GL_MAP_READ_BIT or GL_MAP_WRITE_BIT is set.");
785 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_INVALIDATE_RANGE_BIT);
786 ctx.expectError (GL_INVALID_OPERATION);
787 ctx.endSection();
788
789 ctx.beginSection("GL_INVALID_OPERATION is generated if ");
790 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_INVALIDATE_RANGE_BIT);
791 ctx.expectError (GL_INVALID_OPERATION);
792 ctx.endSection();
793
794 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.");
795 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_INVALIDATE_RANGE_BIT);
796 ctx.expectError (GL_INVALID_OPERATION);
797
798 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
799 ctx.expectError (GL_INVALID_OPERATION);
800
801 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
802 ctx.expectError (GL_INVALID_OPERATION);
803 ctx.endSection();
804
805 ctx.beginSection("GL_INVALID_OPERATION is generated if GL_MAP_FLUSH_EXPLICIT_BIT is set and GL_MAP_WRITE_BIT is not set.");
806 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_FLUSH_EXPLICIT_BIT);
807 ctx.expectError (GL_INVALID_OPERATION);
808 ctx.endSection();
809
810 ctx.glDeleteBuffers (1, &buf);
811 }
812
read_buffer(NegativeTestContext & ctx)813 void read_buffer (NegativeTestContext& ctx)
814 {
815 deUint32 fbo = 0x1234;
816 deUint32 texture = 0x1234;
817 int maxColorAttachments = 0x1234;
818
819 ctx.glGetIntegerv (GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
820 ctx.glGenTextures (1, &texture);
821 ctx.glBindTexture (GL_TEXTURE_2D, texture);
822 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
823 ctx.glGenFramebuffers (1, &fbo);
824 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
825 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
826 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
827 ctx.expectError (GL_NO_ERROR);
828
829 ctx.beginSection("GL_INVALID_ENUM is generated if mode is not GL_BACK, GL_NONE, or GL_COLOR_ATTACHMENTi.");
830 ctx.glReadBuffer (GL_NONE);
831 ctx.expectError (GL_NO_ERROR);
832 ctx.glReadBuffer (1);
833 ctx.expectError (GL_INVALID_ENUM);
834 ctx.glReadBuffer (GL_FRAMEBUFFER);
835 ctx.expectError (GL_INVALID_ENUM);
836 ctx.glReadBuffer (GL_COLOR_ATTACHMENT0 - 1);
837 ctx.expectError (GL_INVALID_ENUM);
838 ctx.glReadBuffer (GL_FRONT);
839 ctx.expectError (GL_INVALID_ENUM);
840
841 // \ note Spec isn't actually clear here, but it is safe to assume that
842 // GL_DEPTH_ATTACHMENT can't be interpreted as GL_COLOR_ATTACHMENTm
843 // where m = (GL_DEPTH_ATTACHMENT - GL_COLOR_ATTACHMENT0).
844 ctx.glReadBuffer (GL_DEPTH_ATTACHMENT);
845 ctx.expectError (GL_INVALID_ENUM);
846 ctx.glReadBuffer (GL_STENCIL_ATTACHMENT);
847 ctx.expectError (GL_INVALID_ENUM);
848 ctx.glReadBuffer (GL_STENCIL_ATTACHMENT+1);
849 ctx.expectError (GL_INVALID_ENUM);
850 ctx.glReadBuffer (0xffffffffu);
851 ctx.expectError (GL_INVALID_ENUM);
852 ctx.endSection();
853
854 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.");
855 ctx.glReadBuffer (GL_BACK);
856 ctx.expectError (GL_INVALID_OPERATION);
857 ctx.glReadBuffer (GL_COLOR_ATTACHMENT0 + maxColorAttachments);
858 ctx.expectError (GL_INVALID_OPERATION);
859
860 if (GL_COLOR_ATTACHMENT0+maxColorAttachments < GL_DEPTH_ATTACHMENT-1)
861 {
862 ctx.glReadBuffer (GL_DEPTH_ATTACHMENT - 1);
863 ctx.expectError (GL_INVALID_OPERATION);
864 }
865
866 ctx.endSection();
867
868 ctx.beginSection("GL_INVALID_OPERATION is generated if the current framebuffer is the default framebuffer and mode is not GL_NONE or GL_BACK.");
869 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
870 ctx.glReadBuffer (GL_COLOR_ATTACHMENT0);
871 ctx.expectError (GL_INVALID_OPERATION);
872 ctx.endSection();
873
874 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.");
875 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
876 ctx.glReadBuffer (GL_BACK);
877 ctx.expectError (GL_INVALID_OPERATION);
878 ctx.endSection();
879
880 ctx.glDeleteTextures(1, &texture);
881 ctx.glDeleteFramebuffers(1, &fbo);
882 }
883
unmap_buffer(NegativeTestContext & ctx)884 void unmap_buffer (NegativeTestContext& ctx)
885 {
886 deUint32 buf = 0x1234;
887 std::vector<GLfloat> data(32);
888
889 ctx.glGenBuffers (1, &buf);
890 ctx.glBindBuffer (GL_ARRAY_BUFFER, buf);
891 ctx.glBufferData (GL_ARRAY_BUFFER, 32, &data[0], GL_DYNAMIC_COPY);
892 ctx.expectError (GL_NO_ERROR);
893
894 ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer data store is already in an unmapped state.");
895 ctx.glUnmapBuffer (GL_ARRAY_BUFFER);
896 ctx.expectError (GL_INVALID_OPERATION);
897 ctx.endSection();
898
899 ctx.glDeleteBuffers (1, &buf);
900 }
901 // Framebuffer Objects
902
bind_framebuffer(NegativeTestContext & ctx)903 void bind_framebuffer (NegativeTestContext& ctx)
904 {
905 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_FRAMEBUFFER.");
906 ctx.glBindFramebuffer(-1, 0);
907 ctx.expectError(GL_INVALID_ENUM);
908 ctx.glBindFramebuffer(GL_RENDERBUFFER, 0);
909 ctx.expectError(GL_INVALID_ENUM);
910 ctx.endSection();
911 }
912
bind_renderbuffer(NegativeTestContext & ctx)913 void bind_renderbuffer (NegativeTestContext& ctx)
914 {
915 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
916 ctx.glBindRenderbuffer(-1, 0);
917 ctx.expectError(GL_INVALID_ENUM);
918 ctx.glBindRenderbuffer(GL_FRAMEBUFFER, 0);
919 ctx.expectError(GL_INVALID_ENUM);
920 ctx.endSection();
921 }
922
check_framebuffer_status(NegativeTestContext & ctx)923 void check_framebuffer_status (NegativeTestContext& ctx)
924 {
925 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_FRAMEBUFFER.");
926 ctx.glCheckFramebufferStatus(-1);
927 ctx.expectError(GL_INVALID_ENUM);
928 ctx.glCheckFramebufferStatus(GL_RENDERBUFFER);
929 ctx.expectError(GL_INVALID_ENUM);
930 ctx.endSection();
931 }
932
gen_framebuffers(NegativeTestContext & ctx)933 void gen_framebuffers (NegativeTestContext& ctx)
934 {
935 ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
936 ctx.glGenFramebuffers(-1, 0);
937 ctx.expectError(GL_INVALID_VALUE);
938 ctx.endSection();
939 }
940
gen_renderbuffers(NegativeTestContext & ctx)941 void gen_renderbuffers (NegativeTestContext& ctx)
942 {
943 ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
944 ctx.glGenRenderbuffers(-1, 0);
945 ctx.expectError(GL_INVALID_VALUE);
946 ctx.endSection();
947 }
948
delete_framebuffers(NegativeTestContext & ctx)949 void delete_framebuffers (NegativeTestContext& ctx)
950 {
951 ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
952 ctx.glDeleteFramebuffers(-1, 0);
953 ctx.expectError(GL_INVALID_VALUE);
954 ctx.endSection();
955 }
956
delete_renderbuffers(NegativeTestContext & ctx)957 void delete_renderbuffers (NegativeTestContext& ctx)
958 {;
959 ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
960 ctx.glDeleteRenderbuffers(-1, 0);
961 ctx.expectError(GL_INVALID_VALUE);
962 ctx.endSection();
963 }
964
framebuffer_renderbuffer(NegativeTestContext & ctx)965 void framebuffer_renderbuffer (NegativeTestContext& ctx)
966 {
967 GLuint fbo = 0x1234;
968 GLuint rbo = 0x1234;
969 ctx.glGenFramebuffers(1, &fbo);
970 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
971 ctx.glGenRenderbuffers(1, &rbo);
972
973 ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
974 ctx.glFramebufferRenderbuffer(-1, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
975 ctx.expectError(GL_INVALID_ENUM);
976 ctx.endSection();
977
978 ctx.beginSection("GL_INVALID_ENUM is generated if renderbuffertarget is not GL_RENDERBUFFER.");
979 ctx.glBindRenderbuffer(GL_RENDERBUFFER, rbo);
980 ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, rbo);
981 ctx.expectError(GL_INVALID_ENUM);
982 ctx.glBindRenderbuffer(GL_RENDERBUFFER, 0);
983 ctx.endSection();
984
985 ctx.beginSection("GL_INVALID_OPERATION is generated if renderbuffer is neither 0 nor the name of an existing renderbuffer object.");
986 ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, -1);
987 ctx.expectError(GL_INVALID_OPERATION);
988 ctx.endSection();
989
990 ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
991 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
992 ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
993 ctx.expectError(GL_INVALID_OPERATION);
994 ctx.endSection();
995
996 ctx.glDeleteRenderbuffers(1, &rbo);
997 ctx.glDeleteFramebuffers(1, &fbo);
998 }
999
framebuffer_texture2d(NegativeTestContext & ctx)1000 void framebuffer_texture2d (NegativeTestContext& ctx)
1001 {
1002 GLuint fbo = 0x1234;
1003 GLuint tex2D = 0x1234;
1004 GLuint texCube = 0x1234;
1005 GLint maxTexSize = 0x1234;
1006 GLint maxTexCubeSize = 0x1234;
1007
1008 ctx.glGenFramebuffers(1, &fbo);
1009 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1010 ctx.glGenTextures(1, &tex2D);
1011 ctx.glBindTexture(GL_TEXTURE_2D, tex2D);
1012 ctx.glGenTextures(1, &texCube);
1013 ctx.glBindTexture(GL_TEXTURE_CUBE_MAP, texCube);
1014 ctx.glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTexSize);
1015 ctx.glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &maxTexCubeSize);
1016 ctx.expectError(GL_NO_ERROR);
1017
1018 ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
1019 ctx.glFramebufferTexture2D(-1, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
1020 ctx.expectError(GL_INVALID_ENUM);
1021 ctx.endSection();
1022
1023 ctx.beginSection("GL_INVALID_ENUM is generated if textarget is not an accepted texture target.");
1024 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, tex2D, 0);
1025 ctx.expectError(GL_INVALID_ENUM);
1026 ctx.endSection();
1027
1028 ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0 or larger than log_2 of maximum texture size.");
1029 int maxSize = 0x1234;
1030 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, -1);
1031 ctx.expectError(GL_INVALID_VALUE);
1032 maxSize = deLog2Floor32(maxTexSize) + 1;
1033 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, maxSize);
1034 ctx.expectError(GL_INVALID_VALUE);
1035 maxSize = deLog2Floor32(maxTexSize) + 1;
1036 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X, texCube, maxSize);
1037 ctx.expectError(GL_INVALID_VALUE);
1038 ctx.endSection();
1039
1040 ctx.beginSection("GL_INVALID_OPERATION is generated if texture is neither 0 nor the name of an existing texture object.");
1041 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, -1, 0);
1042 ctx.expectError(GL_INVALID_OPERATION);
1043 ctx.endSection();
1044
1045 ctx.beginSection("GL_INVALID_OPERATION is generated if textarget and texture are not compatible.");
1046 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X, tex2D, 0);
1047 ctx.expectError(GL_INVALID_OPERATION);
1048 ctx.glDeleteTextures(1, &tex2D);
1049
1050 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texCube, 0);
1051 ctx.expectError(GL_INVALID_OPERATION);
1052 ctx.glDeleteTextures(1, &texCube);
1053 ctx.endSection();
1054
1055 ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
1056 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1057 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
1058 ctx.expectError(GL_INVALID_OPERATION);
1059 ctx.endSection();
1060
1061 ctx.glDeleteFramebuffers(1, &fbo);
1062 }
1063
renderbuffer_storage(NegativeTestContext & ctx)1064 void renderbuffer_storage (NegativeTestContext& ctx)
1065 {
1066 deUint32 rbo = 0x1234;
1067 ctx.glGenRenderbuffers (1, &rbo);
1068 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo);
1069
1070 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
1071 ctx.glRenderbufferStorage (-1, GL_RGBA4, 1, 1);
1072 ctx.expectError (GL_INVALID_ENUM);
1073 ctx.glRenderbufferStorage (GL_FRAMEBUFFER, GL_RGBA4, 1, 1);
1074 ctx.expectError (GL_INVALID_ENUM);
1075 ctx.endSection();
1076
1077 ctx.beginSection("GL_INVALID_ENUM is generated if internalformat is not a color-renderable, depth-renderable, or stencil-renderable format.");
1078 ctx.glRenderbufferStorage (GL_RENDERBUFFER, -1, 1, 1);
1079 ctx.expectError (GL_INVALID_ENUM);
1080
1081 if (!ctx.getContextInfo().isExtensionSupported("GL_EXT_color_buffer_half_float")) // GL_EXT_color_buffer_half_float disables error
1082 {
1083 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGB16F, 1, 1);
1084 ctx.expectError (GL_INVALID_ENUM);
1085 }
1086
1087 if (!ctx.getContextInfo().isExtensionSupported("GL_EXT_render_snorm")) // GL_EXT_render_snorm disables error
1088 {
1089 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA8_SNORM, 1, 1);
1090 ctx.expectError (GL_INVALID_ENUM);
1091 }
1092
1093 ctx.endSection();
1094
1095 ctx.beginSection("GL_INVALID_VALUE is generated if width or height is less than zero.");
1096 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, -1, 1);
1097 ctx.expectError (GL_INVALID_VALUE);
1098 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, 1, -1);
1099 ctx.expectError (GL_INVALID_VALUE);
1100 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, -1, -1);
1101 ctx.expectError (GL_INVALID_VALUE);
1102 ctx.endSection();
1103
1104 ctx.beginSection("GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_RENDERBUFFER_SIZE.");
1105 GLint maxSize = 0x1234;
1106 ctx.glGetIntegerv (GL_MAX_RENDERBUFFER_SIZE, &maxSize);
1107 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, 1, maxSize+1);
1108 ctx.expectError (GL_INVALID_VALUE);
1109 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, maxSize+1, 1);
1110 ctx.expectError (GL_INVALID_VALUE);
1111 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, maxSize+1, maxSize+1);
1112 ctx.expectError (GL_INVALID_VALUE);
1113 ctx.endSection();
1114
1115 ctx.glDeleteRenderbuffers(1, &rbo);
1116 }
1117
blit_framebuffer(NegativeTestContext & ctx)1118 void blit_framebuffer (NegativeTestContext& ctx)
1119 {
1120 deUint32 fbo[2];
1121 deUint32 rbo[2];
1122 deUint32 texture[2];
1123
1124 ctx.glGenFramebuffers (2, fbo);
1125 ctx.glGenTextures (2, texture);
1126 ctx.glGenRenderbuffers (2, rbo);
1127
1128 ctx.glBindTexture (GL_TEXTURE_2D, texture[0]);
1129 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo[0]);
1130 ctx.glBindFramebuffer (GL_READ_FRAMEBUFFER, fbo[0]);
1131
1132 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1133 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 32, 32);
1134 ctx.glFramebufferTexture2D (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1135 ctx.glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[0]);
1136 ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER);
1137
1138 ctx.glBindTexture (GL_TEXTURE_2D, texture[1]);
1139 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo[1]);
1140 ctx.glBindFramebuffer (GL_DRAW_FRAMEBUFFER, fbo[1]);
1141
1142 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1143 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 32, 32);
1144 ctx.glFramebufferTexture2D (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[1], 0);
1145 ctx.glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[1]);
1146 ctx.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
1147 ctx.expectError (GL_NO_ERROR);
1148
1149 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.");
1150 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_LINEAR);
1151 ctx.expectError (GL_INVALID_OPERATION);
1152 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_LINEAR);
1153 ctx.expectError (GL_INVALID_OPERATION);
1154 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_LINEAR);
1155 ctx.expectError (GL_INVALID_OPERATION);
1156 ctx.endSection();
1157
1158 ctx.beginSection("GL_INVALID_OPERATION is generated if mask contains GL_COLOR_BUFFER_BIT and read buffer format is incompatible with draw buffer format.");
1159 ctx.glBindTexture (GL_TEXTURE_2D, texture[0]);
1160
1161 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
1162 ctx.glFramebufferTexture2D (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1163 ctx.getLog() << TestLog::Message << "// Read buffer: GL_RGBA32UI, draw buffer: GL_RGBA" << TestLog::EndMessage;
1164 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1165 ctx.expectError (GL_INVALID_OPERATION);
1166
1167 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL);
1168 ctx.glFramebufferTexture2D (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1169 ctx.getLog() << TestLog::Message << "// Read buffer: GL_RGBA32I, draw buffer: GL_RGBA" << TestLog::EndMessage;
1170 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1171 ctx.expectError (GL_INVALID_OPERATION);
1172
1173 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1174 ctx.glFramebufferTexture2D (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1175 ctx.glBindTexture (GL_TEXTURE_2D, texture[1]);
1176 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL);
1177 ctx.glFramebufferTexture2D (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[1], 0);
1178 ctx.getLog() << TestLog::Message << "// Read buffer: GL_RGBA8, draw buffer: GL_RGBA32I" << TestLog::EndMessage;
1179 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1180 ctx.expectError (GL_INVALID_OPERATION);
1181 ctx.endSection();
1182
1183 ctx.beginSection("GL_INVALID_OPERATION is generated if filter is GL_LINEAR and the read buffer contains integer data.");
1184 ctx.glBindTexture (GL_TEXTURE_2D, texture[0]);
1185 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
1186 ctx.glFramebufferTexture2D (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1187 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1188 ctx.glFramebufferTexture2D (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[1], 0);
1189 ctx.getLog() << TestLog::Message << "// Read buffer: GL_RGBA32I, draw buffer: GL_RGBA8" << TestLog::EndMessage;
1190 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_LINEAR);
1191 ctx.expectError (GL_INVALID_OPERATION);
1192 ctx.endSection();
1193
1194 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.");
1195 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo[0]);
1196 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH32F_STENCIL8, 32, 32);
1197 ctx.glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[0]);
1198 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
1199 ctx.expectError (GL_INVALID_OPERATION);
1200 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_STENCIL_BUFFER_BIT, GL_NEAREST);
1201 ctx.expectError (GL_INVALID_OPERATION);
1202 ctx.endSection();
1203
1204 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
1205 ctx.glDeleteFramebuffers (2, fbo);
1206 ctx.glDeleteTextures (2, texture);
1207 ctx.glDeleteRenderbuffers (2, rbo);
1208 }
1209
blit_framebuffer_multisample(NegativeTestContext & ctx)1210 void blit_framebuffer_multisample (NegativeTestContext& ctx)
1211 {
1212 deUint32 fbo[2];
1213 deUint32 rbo[2];
1214
1215 ctx.glGenFramebuffers (2, fbo);
1216 ctx.glGenRenderbuffers (2, rbo);
1217
1218 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo[0]);
1219 ctx.glBindFramebuffer (GL_READ_FRAMEBUFFER, fbo[0]);
1220 ctx.glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA8, 32, 32);
1221 ctx.glFramebufferRenderbuffer (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[0]);
1222 ctx.glCheckFramebufferStatus (GL_READ_FRAMEBUFFER);
1223
1224 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo[1]);
1225 ctx.glBindFramebuffer (GL_DRAW_FRAMEBUFFER, fbo[1]);
1226
1227 ctx.expectError (GL_NO_ERROR);
1228
1229 if (!ctx.getContextInfo().isExtensionSupported("GL_NV_framebuffer_multisample"))
1230 {
1231 ctx.beginSection("GL_INVALID_OPERATION is generated if the value of GL_SAMPLE_BUFFERS for the draw buffer is greater than zero.");
1232 ctx.glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA8, 32, 32);
1233 ctx.glFramebufferRenderbuffer (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[1]);
1234 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1235 ctx.expectError (GL_INVALID_OPERATION);
1236 ctx.endSection();
1237
1238 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.");
1239 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, 32, 32);
1240 ctx.glFramebufferRenderbuffer (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[1]);
1241 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1242 ctx.expectError (GL_INVALID_OPERATION);
1243 ctx.endSection();
1244
1245 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.");
1246 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA8, 32, 32);
1247 ctx.glFramebufferRenderbuffer (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[1]);
1248 ctx.glBlitFramebuffer (0, 0, 16, 16, 2, 2, 18, 18, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1249 ctx.expectError (GL_INVALID_OPERATION);
1250 ctx.endSection();
1251 }
1252
1253 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
1254 ctx.glDeleteRenderbuffers (2, rbo);
1255 ctx.glDeleteFramebuffers (2, fbo);
1256 }
1257
framebuffer_texture_layer(NegativeTestContext & ctx)1258 void framebuffer_texture_layer (NegativeTestContext& ctx)
1259 {
1260 deUint32 fbo = 0x1234;
1261 deUint32 tex3D;
1262 deUint32 tex2DArray;
1263 deUint32 tex2D;
1264
1265 ctx.glGenFramebuffers (1, &fbo);
1266 ctx.glGenTextures (1, &tex3D);
1267 ctx.glGenTextures (1, &tex2DArray);
1268 ctx.glGenTextures (1, &tex2D);
1269 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
1270
1271 ctx.glBindTexture (GL_TEXTURE_3D, tex3D);
1272 ctx.glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1273 ctx.glBindTexture (GL_TEXTURE_2D_ARRAY, tex2DArray);
1274 ctx.glTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1275 ctx.glBindTexture (GL_TEXTURE_2D, tex2D);
1276 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1277
1278 ctx.expectError (GL_NO_ERROR);
1279
1280 ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
1281 ctx.glFramebufferTextureLayer (-1, GL_COLOR_ATTACHMENT0, tex3D, 0, 1);
1282 ctx.expectError (GL_INVALID_ENUM);
1283 ctx.glFramebufferTextureLayer (GL_RENDERBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, 1);
1284 ctx.expectError (GL_INVALID_ENUM);
1285 ctx.endSection();
1286
1287 ctx.beginSection("GL_INVALID_ENUM is generated if attachment is not one of the accepted tokens.");
1288 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, -1, tex3D, 0, 1);
1289 ctx.expectError (GL_INVALID_ENUM);
1290 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_BACK, tex3D, 0, 1);
1291 ctx.expectError (GL_INVALID_ENUM);
1292 ctx.endSection();
1293
1294 ctx.beginSection("GL_INVALID_OPERATION is generated if texture is non-zero and not the name of a 3D texture or 2D array texture.");
1295 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, 0, 0);
1296 ctx.expectError (GL_INVALID_OPERATION);
1297 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2D, 0, 0);
1298 ctx.expectError (GL_INVALID_OPERATION);
1299 ctx.endSection();
1300
1301 ctx.beginSection("GL_INVALID_VALUE is generated if texture is not zero and layer is negative.");
1302 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, -1);
1303 ctx.expectError (GL_INVALID_VALUE);
1304 ctx.endSection();
1305
1306 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.");
1307 int max3DTexSize = 0x1234;
1308 ctx.glGetIntegerv (GL_MAX_3D_TEXTURE_SIZE, &max3DTexSize);
1309 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, max3DTexSize);
1310 ctx.expectError (GL_INVALID_VALUE);
1311 ctx.endSection();
1312
1313 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.");
1314 int maxArrayTexLayers = 0x1234;
1315 ctx.glGetIntegerv (GL_MAX_ARRAY_TEXTURE_LAYERS, &maxArrayTexLayers);
1316 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2DArray, 0, maxArrayTexLayers);
1317 ctx.expectError (GL_INVALID_VALUE);
1318 ctx.endSection();
1319
1320 ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
1321 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
1322 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, 1);
1323 ctx.expectError (GL_INVALID_OPERATION);
1324 ctx.endSection();
1325
1326 ctx.glDeleteTextures (1, &tex3D);
1327 ctx.glDeleteTextures (1, &tex2DArray);
1328 ctx.glDeleteTextures (1, &tex2D);
1329 ctx.glDeleteFramebuffers (1, &fbo);
1330 }
1331
invalidate_framebuffer(NegativeTestContext & ctx)1332 void invalidate_framebuffer (NegativeTestContext& ctx)
1333 {
1334 deUint32 fbo = 0x1234;
1335 deUint32 texture = 0x1234;
1336 deUint32 attachments[2];
1337 int maxColorAttachments = 0x1234;
1338 ctx.glGetIntegerv (GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
1339 attachments[0] = GL_COLOR_ATTACHMENT0;
1340 attachments[1] = GL_COLOR_ATTACHMENT0 + maxColorAttachments;
1341
1342 ctx.glGenFramebuffers (1, &fbo);
1343 ctx.glGenTextures (1, &texture);
1344 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
1345 ctx.glBindTexture (GL_TEXTURE_2D, texture);
1346 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1347 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
1348 ctx.glCheckFramebufferStatus (GL_FRAMEBUFFER);
1349 ctx.expectError (GL_NO_ERROR);
1350
1351 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_FRAMEBUFFER, GL_READ_FRAMEBUFFER or GL_DRAW_FRAMEBUFFER.");
1352 ctx.glInvalidateFramebuffer (-1, 1, &attachments[0]);
1353 ctx.expectError (GL_INVALID_ENUM);
1354 ctx.glInvalidateFramebuffer (GL_BACK, 1, &attachments[0]);
1355 ctx.expectError (GL_INVALID_ENUM);
1356 ctx.endSection();
1357
1358 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.");
1359 ctx.glInvalidateFramebuffer (GL_FRAMEBUFFER, 1, &attachments[1]);
1360 ctx.expectError (GL_INVALID_OPERATION);
1361 ctx.endSection();
1362
1363 ctx.glDeleteTextures (1, &texture);
1364 ctx.glDeleteFramebuffers (1, &fbo);
1365 }
1366
invalidate_sub_framebuffer(NegativeTestContext & ctx)1367 void invalidate_sub_framebuffer (NegativeTestContext& ctx)
1368 {
1369 deUint32 fbo = 0x1234;
1370 deUint32 texture = 0x1234;
1371 deUint32 attachments[2];
1372 int maxColorAttachments = 0x1234;
1373 ctx.glGetIntegerv (GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
1374 attachments[0] = GL_COLOR_ATTACHMENT0;
1375 attachments[1] = GL_COLOR_ATTACHMENT0 + maxColorAttachments;
1376
1377 ctx.glGenFramebuffers (1, &fbo);
1378 ctx.glGenTextures (1, &texture);
1379 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
1380 ctx.glBindTexture (GL_TEXTURE_2D, texture);
1381 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1382 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
1383 ctx.glCheckFramebufferStatus (GL_FRAMEBUFFER);
1384 ctx.expectError (GL_NO_ERROR);
1385
1386 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_FRAMEBUFFER, GL_READ_FRAMEBUFFER or GL_DRAW_FRAMEBUFFER.");
1387 ctx.glInvalidateSubFramebuffer (-1, 1, &attachments[0], 0, 0, 16, 16);
1388 ctx.expectError (GL_INVALID_ENUM);
1389 ctx.glInvalidateSubFramebuffer (GL_BACK, 1, &attachments[0], 0, 0, 16, 16);
1390 ctx.expectError (GL_INVALID_ENUM);
1391 ctx.endSection();
1392
1393 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.");
1394 ctx.glInvalidateSubFramebuffer (GL_FRAMEBUFFER, 1, &attachments[1], 0, 0, 16, 16);
1395 ctx.expectError (GL_INVALID_OPERATION);
1396 ctx.endSection();
1397
1398 ctx.glDeleteTextures (1, &texture);
1399 ctx.glDeleteFramebuffers (1, &fbo);
1400 }
1401
renderbuffer_storage_multisample(NegativeTestContext & ctx)1402 void renderbuffer_storage_multisample (NegativeTestContext& ctx)
1403 {
1404 deUint32 rbo = 0x1234;
1405 int maxSamplesSupportedRGBA4 = -1;
1406 int maxSamplesSupportedRGBA8UI = -1;
1407
1408 ctx.glGetInternalformativ (GL_RENDERBUFFER, GL_RGBA4, GL_SAMPLES, 1, &maxSamplesSupportedRGBA4);
1409 ctx.glGetInternalformativ (GL_RENDERBUFFER, GL_RGBA8UI, GL_SAMPLES, 1, &maxSamplesSupportedRGBA8UI);
1410
1411 ctx.glGenRenderbuffers (1, &rbo);
1412 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo);
1413
1414 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
1415 ctx.glRenderbufferStorageMultisample (-1, 2, GL_RGBA4, 1, 1);
1416 ctx.expectError (GL_INVALID_ENUM);
1417 ctx.glRenderbufferStorageMultisample (GL_FRAMEBUFFER, 2, GL_RGBA4, 1, 1);
1418 ctx.expectError (GL_INVALID_ENUM);
1419 ctx.endSection();
1420
1421 ctx.beginSection("GL_INVALID_OPERATION is generated if samples is greater than the maximum number of samples supported for internalformat.");
1422 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, maxSamplesSupportedRGBA4+1, GL_RGBA4, 1, 1);
1423 ctx.expectError (GL_INVALID_OPERATION);
1424 ctx.endSection();
1425
1426 ctx.beginSection("GL_INVALID_ENUM is generated if internalformat is not a color-renderable, depth-renderable, or stencil-renderable format.");
1427 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 2, -1, 1, 1);
1428 ctx.expectError (GL_INVALID_ENUM);
1429
1430 if (!ctx.getContextInfo().isExtensionSupported("GL_EXT_color_buffer_half_float")) // GL_EXT_color_buffer_half_float disables error
1431 {
1432 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 2, GL_RGB16F, 1, 1);
1433 ctx.expectError (GL_INVALID_ENUM);
1434 }
1435
1436 if (!ctx.getContextInfo().isExtensionSupported("GL_EXT_render_snorm")) // GL_EXT_render_snorm disables error
1437 {
1438 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 2, GL_RGBA8_SNORM, 1, 1);
1439 ctx.expectError (GL_INVALID_ENUM);
1440 }
1441
1442 ctx.endSection();
1443
1444 ctx.beginSection("GL_INVALID_OPERATION is generated if samples is greater than the maximum number of samples supported for internalformat. (Unsigned integer format)");
1445 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, maxSamplesSupportedRGBA8UI+1, GL_RGBA8UI, 1, 1);
1446 ctx.expectError (GL_INVALID_OPERATION);
1447 ctx.endSection();
1448
1449 ctx.beginSection("GL_INVALID_VALUE is generated if width or height is less than zero.");
1450 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 2, GL_RGBA4, -1, 1);
1451 ctx.expectError (GL_INVALID_VALUE);
1452 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 2, GL_RGBA4, 1, -1);
1453 ctx.expectError (GL_INVALID_VALUE);
1454 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 2, GL_RGBA4, -1, -1);
1455 ctx.expectError (GL_INVALID_VALUE);
1456 ctx.endSection();
1457
1458 ctx.beginSection("GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_RENDERBUFFER_SIZE.");
1459 GLint maxSize = 0x1234;
1460 ctx.glGetIntegerv (GL_MAX_RENDERBUFFER_SIZE, &maxSize);
1461 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 4, GL_RGBA4, 1, maxSize+1);
1462 ctx.expectError (GL_INVALID_VALUE);
1463 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 4, GL_RGBA4, maxSize+1, 1);
1464 ctx.expectError (GL_INVALID_VALUE);
1465 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 4, GL_RGBA4, maxSize+1, maxSize+1);
1466 ctx.expectError (GL_INVALID_VALUE);
1467 ctx.endSection();
1468
1469 ctx.glDeleteRenderbuffers(1, &rbo);
1470 }
1471
getNegativeBufferApiTestFunctions()1472 std::vector<FunctionContainer> getNegativeBufferApiTestFunctions ()
1473 {
1474 FunctionContainer funcs[] =
1475 {
1476 {bind_buffer, "bind_buffer", "Invalid glBindBuffer() usage" },
1477 {delete_buffers, "delete_buffers", "Invalid glDeleteBuffers() usage" },
1478 {gen_buffers, "gen_buffers", "Invalid glGenBuffers() usage" },
1479 {buffer_data, "buffer_data", "Invalid glBufferData() usage" },
1480 {buffer_sub_data, "buffer_sub_data", "Invalid glBufferSubData() usage" },
1481 {buffer_sub_data_size_offset, "buffer_sub_data_size_offset", "Invalid glBufferSubData() usage" },
1482 {clear, "clear", "Invalid glClear() usage" },
1483 {read_pixels, "read_pixels", "Invalid glReadPixels() usage" },
1484 {read_pixels_format_mismatch, "read_pixels_format_mismatch", "Invalid glReadPixels() usage" },
1485 {read_pixels_fbo_format_mismatch, "read_pixels_fbo_format_mismatch", "Invalid glReadPixels() usage" },
1486 {bind_buffer_range, "bind_buffer_range", "Invalid glBindBufferRange() usage" },
1487 {bind_buffer_base, "bind_buffer_base", "Invalid glBindBufferBase() usage" },
1488 {clear_bufferiv, "clear_bufferiv", "Invalid glClearBufferiv() usage" },
1489 {clear_bufferuiv, "clear_bufferuiv", "Invalid glClearBufferuiv() usage" },
1490 {clear_bufferfv, "clear_bufferfv", "Invalid glClearBufferfv() usage" },
1491 {clear_bufferfi, "clear_bufferfi", "Invalid glClearBufferfi() usage" },
1492 {copy_buffer_sub_data, "copy_buffer_sub_data", "Invalid glCopyBufferSubData() usage" },
1493 {draw_buffers, "draw_buffers", "Invalid glDrawBuffers() usage" },
1494 {flush_mapped_buffer_range, "flush_mapped_buffer_range", "Invalid glFlushMappedBufferRange() usage" },
1495 {map_buffer_range, "map_buffer_range", "Invalid glMapBufferRange() usage" },
1496 {read_buffer, "read_buffer", "Invalid glReadBuffer() usage" },
1497 {unmap_buffer, "unmap_buffer", "Invalid glUnmapBuffer() usage" },
1498 {bind_framebuffer, "bind_framebuffer", "Invalid glBindFramebuffer() usage" },
1499 {bind_renderbuffer, "bind_renderbuffer", "Invalid glBindRenderbuffer() usage" },
1500 {check_framebuffer_status, "check_framebuffer_status", "Invalid glCheckFramebufferStatus() usage" },
1501 {gen_framebuffers, "gen_framebuffers", "Invalid glGenFramebuffers() usage" },
1502 {gen_renderbuffers, "gen_renderbuffers", "Invalid glGenRenderbuffers() usage" },
1503 {delete_framebuffers, "delete_framebuffers", "Invalid glDeleteFramebuffers() usage" },
1504 {delete_renderbuffers, "delete_renderbuffers", "Invalid glDeleteRenderbuffers() usage" },
1505 {framebuffer_renderbuffer, "framebuffer_renderbuffer", "Invalid glFramebufferRenderbuffer() usage" },
1506 {framebuffer_texture2d, "framebuffer_texture2d", "Invalid glFramebufferTexture2D() usage" },
1507 {renderbuffer_storage, "renderbuffer_storage", "Invalid glRenderbufferStorage() usage" },
1508 {blit_framebuffer, "blit_framebuffer", "Invalid glBlitFramebuffer() usage" },
1509 {blit_framebuffer_multisample, "blit_framebuffer_multisample", "Invalid glBlitFramebuffer() usage" },
1510 {framebuffer_texture_layer, "framebuffer_texture_layer", "Invalid glFramebufferTextureLayer() usage" },
1511 {invalidate_framebuffer, "invalidate_framebuffer", "Invalid glInvalidateFramebuffer() usage" },
1512 {invalidate_sub_framebuffer, "invalidate_sub_framebuffer", "Invalid glInvalidateSubFramebuffer() usage" },
1513 {renderbuffer_storage_multisample, "renderbuffer_storage_multisample", "Invalid glRenderbufferStorageMultisample() usage"},
1514 };
1515
1516 return std::vector<FunctionContainer>(DE_ARRAY_BEGIN(funcs), DE_ARRAY_END(funcs));
1517 }
1518
1519 } // NegativeTestShared
1520 } // Functional
1521 } // gles31
1522 } // deqp
1523