1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 3.0 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 Pixel Buffer Object tests
22 *//*--------------------------------------------------------------------*/
23
24 #include "es3fPixelBufferObjectTests.hpp"
25
26 #include "tcuTexture.hpp"
27 #include "tcuTextureUtil.hpp"
28 #include "tcuImageCompare.hpp"
29 #include "tcuTestLog.hpp"
30 #include "tcuRenderTarget.hpp"
31
32 #include "gluTextureUtil.hpp"
33 #include "gluPixelTransfer.hpp"
34 #include "gluShaderProgram.hpp"
35
36 #include "deRandom.hpp"
37 #include "deString.h"
38
39 #include <string>
40 #include <sstream>
41
42 #include "glw.h"
43
44 using std::string;
45 using std::stringstream;
46
47 namespace deqp
48 {
49 namespace gles3
50 {
51 namespace Functional
52 {
53
54 namespace
55 {
56
57 class ReadPixelsTest : public TestCase
58 {
59 public:
60 struct TestSpec
61 {
62 enum FramebufferType
63 {
64 FRAMEBUFFERTYPE_NATIVE = 0,
65 FRAMEBUFFERTYPE_RENDERBUFFER
66 };
67
68 string name;
69 string description;
70
71 bool useColorClear;
72 bool renderTriangles;
73
74 FramebufferType framebufferType;
75 GLenum renderbufferFormat;
76 };
77
78 ReadPixelsTest (Context& context, const TestSpec& spec);
79 ~ReadPixelsTest (void);
80
81 void init (void);
82 void deinit (void);
83
84 IterateResult iterate (void);
85
86 private:
87 void renderTriangle (const tcu::Vec3& a, const tcu::Vec3& b, const tcu::Vec3& c);
88 void clearColor (float r, float g, float b, float a);
89
90 de::Random m_random;
91 tcu::TestLog& m_log;
92 glu::ShaderProgram* m_program;
93
94 TestSpec::FramebufferType m_framebuffeType;
95
96 GLenum m_renderbufferFormat;
97 tcu::TextureChannelClass m_texChannelClass;
98
99 bool m_useColorClears;
100 bool m_renderTriangles;
101
102 GLfloat m_colorScale;
103 };
104
105
ReadPixelsTest(Context & context,const TestSpec & spec)106 ReadPixelsTest::ReadPixelsTest (Context& context, const TestSpec& spec)
107 : TestCase (context, spec.name.c_str(), spec.description.c_str())
108 , m_random (deStringHash(spec.name.c_str()))
109 , m_log (m_testCtx.getLog())
110 , m_program (NULL)
111 , m_framebuffeType (spec.framebufferType)
112 , m_renderbufferFormat (spec.renderbufferFormat)
113 , m_texChannelClass (tcu::TEXTURECHANNELCLASS_LAST)
114 , m_useColorClears (spec.useColorClear)
115 , m_renderTriangles (spec.renderTriangles)
116 , m_colorScale (1.0f)
117 {
118
119 if (m_framebuffeType == TestSpec::FRAMEBUFFERTYPE_NATIVE)
120 {
121 m_colorScale = 1.0f;
122 }
123 else if (m_framebuffeType == TestSpec::FRAMEBUFFERTYPE_RENDERBUFFER)
124 {
125 m_texChannelClass = tcu::getTextureChannelClass(glu::mapGLInternalFormat(spec.renderbufferFormat).type);
126 switch (m_texChannelClass)
127 {
128 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
129 m_colorScale = 1.0f;
130 break;
131
132 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
133 m_colorScale = 100.0f;
134 break;
135
136 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
137 m_colorScale = 100.0f;
138 break;
139
140 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
141 m_colorScale = 100.0f;
142 break;
143
144 default:
145 DE_ASSERT(false);
146 }
147 }
148 else
149 DE_ASSERT(false);
150 }
151
~ReadPixelsTest(void)152 ReadPixelsTest::~ReadPixelsTest (void)
153 {
154 }
155
init(void)156 void ReadPixelsTest::init (void)
157 {
158 // Check extensions
159 if (m_framebuffeType == TestSpec::FRAMEBUFFERTYPE_RENDERBUFFER)
160 {
161 bool supported = false;
162
163 if (m_renderbufferFormat == GL_RGBA16F
164 || m_renderbufferFormat == GL_RG16F)
165 {
166 std::istringstream extensions(std::string((const char*)glGetString(GL_EXTENSIONS)));
167 std::string extension;
168
169 while (std::getline(extensions, extension, ' '))
170 {
171 if (extension=="GL_EXT_color_buffer_half_float")
172 {
173 supported = true;
174 break;
175 }
176 if (extension=="GL_EXT_color_buffer_float")
177 {
178 supported = true;
179 break;
180 }
181 }
182 }
183 else if (m_renderbufferFormat == GL_RGBA32F
184 || m_renderbufferFormat == GL_RG32F
185 || m_renderbufferFormat == GL_R11F_G11F_B10F)
186 {
187 std::istringstream extensions(std::string((const char*)glGetString(GL_EXTENSIONS)));
188 std::string extension;
189
190 while (std::getline(extensions, extension, ' '))
191 {
192 if (extension=="GL_EXT_color_buffer_float")
193 {
194 supported = true;
195 break;
196 }
197 }
198 }
199 else
200 supported = true;
201
202 if (!supported)
203 throw tcu::NotSupportedError("Renderbuffer format not supported", "", __FILE__, __LINE__);
204 }
205
206 std::string outtype = "";
207
208 if (m_framebuffeType == TestSpec::FRAMEBUFFERTYPE_NATIVE)
209 outtype = "vec4";
210 else if (m_framebuffeType == TestSpec::FRAMEBUFFERTYPE_RENDERBUFFER)
211 {
212 switch (m_texChannelClass)
213 {
214 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
215 outtype = "vec4";
216 break;
217
218 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
219 outtype = "ivec4";
220 break;
221
222 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
223 outtype = "uvec4";
224 break;
225
226 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
227 outtype = "vec4";
228 break;
229
230 default:
231 DE_ASSERT(false);
232 }
233 }
234 else
235 DE_ASSERT(false);
236
237
238 const char* vertexShaderSource =
239 "#version 300 es\n"
240 "in mediump vec3 a_position;\n"
241 "in mediump vec4 a_color;\n"
242 "uniform mediump float u_colorScale;\n"
243 "out mediump vec4 v_color;\n"
244 "void main(void)\n"
245 "{\n"
246 "\tgl_Position = vec4(a_position, 1.0);\n"
247 "\tv_color = u_colorScale * a_color;\n"
248 "}";
249
250 stringstream fragmentShaderSource;
251
252 fragmentShaderSource <<
253 "#version 300 es\n"
254 "in mediump vec4 v_color;\n";
255
256
257 fragmentShaderSource << "layout (location = 0) out mediump " << outtype << " o_color;\n"
258 "void main(void)\n"
259 "{\n"
260 "\to_color = " << outtype << "(v_color);\n"
261 "}";
262
263 m_program = new glu::ShaderProgram(m_context.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource.str()));
264
265 if (!m_program->isOk())
266 {
267 m_log << *m_program;
268 TCU_FAIL("Failed to compile shader");
269 }
270 }
271
deinit(void)272 void ReadPixelsTest::deinit (void)
273 {
274 if (m_program)
275 delete m_program;
276 m_program = NULL;
277 }
278
renderTriangle(const tcu::Vec3 & a,const tcu::Vec3 & b,const tcu::Vec3 & c)279 void ReadPixelsTest::renderTriangle (const tcu::Vec3& a, const tcu::Vec3& b, const tcu::Vec3& c)
280 {
281 float positions[3*3];
282
283 positions[0] = a.x();
284 positions[1] = a.y();
285 positions[2] = a.z();
286
287 positions[3] = b.x();
288 positions[4] = b.y();
289 positions[5] = b.z();
290
291 positions[6] = c.x();
292 positions[7] = c.y();
293 positions[8] = c.z();
294
295 float colors[] = {
296 1.0f, 0.0f, 0.0f, 1.0f,
297 0.0f, 1.0f, 0.0f, 1.0f,
298 0.0f, 0.0f, 1.0f, 1.0f
299 };
300
301 GLU_CHECK_CALL(glUseProgram(m_program->getProgram()));
302
303 GLuint coordLoc = (GLuint)-1;
304 GLuint colorLoc = (GLuint)-1;
305 GLuint colorScaleLoc = (GLuint)-1;
306
307 colorScaleLoc = glGetUniformLocation(m_program->getProgram(), "u_colorScale");
308 TCU_CHECK(colorScaleLoc != (GLuint)-1);
309
310 GLU_CHECK_CALL(glUniform1f(colorScaleLoc, m_colorScale));
311
312 coordLoc = glGetAttribLocation(m_program->getProgram(), "a_position");
313 TCU_CHECK(coordLoc != (GLuint)-1);
314
315 colorLoc = glGetAttribLocation(m_program->getProgram(), "a_color");
316 TCU_CHECK(colorLoc != (GLuint)-1);
317
318 GLU_CHECK_CALL(glEnableVertexAttribArray(colorLoc));
319 GLU_CHECK_CALL(glEnableVertexAttribArray(coordLoc));
320
321 GLU_CHECK_CALL(glVertexAttribPointer(coordLoc, 3, GL_FLOAT, GL_FALSE, 0, positions));
322 GLU_CHECK_CALL(glVertexAttribPointer(colorLoc, 4, GL_FLOAT, GL_FALSE, 0, colors));
323
324 GLU_CHECK_CALL(glDrawArrays(GL_TRIANGLES, 0, 3));
325
326 GLU_CHECK_CALL(glDisableVertexAttribArray(colorLoc));
327 GLU_CHECK_CALL(glDisableVertexAttribArray(coordLoc));
328
329 }
330
331
clearColor(float r,float g,float b,float a)332 void ReadPixelsTest::clearColor (float r, float g, float b, float a)
333 {
334 if (m_framebuffeType == TestSpec::FRAMEBUFFERTYPE_NATIVE)
335 {
336 GLU_CHECK_CALL(glClearColor(r, g, b, a));
337 GLU_CHECK_CALL(glClear(GL_COLOR_BUFFER_BIT));
338 }
339 else if (m_framebuffeType == TestSpec::FRAMEBUFFERTYPE_RENDERBUFFER)
340 {
341 switch (m_texChannelClass)
342 {
343 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
344 {
345 GLU_CHECK_CALL(glClearColor(r, g, b, a));
346 GLU_CHECK_CALL(glClear(GL_COLOR_BUFFER_BIT));
347 break;
348 }
349
350 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
351 {
352 GLint color[4] = { (GLint)r, (GLint)g, (GLint)b, (GLint)a };
353
354 GLU_CHECK_CALL(glClearBufferiv(GL_COLOR, 0, color));
355 break;
356 }
357
358 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
359 {
360 GLuint color[4] = { (GLuint)r, (GLuint)g, (GLuint)b, (GLuint)a };
361
362 GLU_CHECK_CALL(glClearBufferuiv(GL_COLOR, 0, color));
363 break;
364 }
365
366 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
367 {
368 GLfloat color[4] = { (GLfloat)r, (GLfloat)g, (GLfloat)b, (GLfloat)a };
369
370 GLU_CHECK_CALL(glClearBufferfv(GL_COLOR, 0, color));
371 break;
372 }
373
374 default:
375 DE_ASSERT(false);
376 }
377 }
378 else
379 DE_ASSERT(false);
380
381 }
382
iterate(void)383 TestCase::IterateResult ReadPixelsTest::iterate(void)
384 {
385 int width = m_context.getRenderTarget().getWidth();
386 int height = m_context.getRenderTarget().getHeight();
387
388 GLuint framebuffer = 0;
389 GLuint renderbuffer = 0;
390
391 switch (m_framebuffeType)
392 {
393 case TestSpec::FRAMEBUFFERTYPE_NATIVE:
394 GLU_CHECK_CALL(glBindFramebuffer(GL_FRAMEBUFFER, framebuffer));
395 break;
396
397 case TestSpec::FRAMEBUFFERTYPE_RENDERBUFFER:
398 {
399 GLU_CHECK_CALL(glGenFramebuffers(1, &framebuffer));
400 GLU_CHECK_CALL(glGenRenderbuffers(1, &renderbuffer));
401
402 GLU_CHECK_CALL(glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer));
403 GLU_CHECK_CALL(glRenderbufferStorage(GL_RENDERBUFFER, m_renderbufferFormat, width, height));
404
405 GLU_CHECK_CALL(glBindFramebuffer(GL_FRAMEBUFFER, framebuffer));
406 GLU_CHECK_CALL(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderbuffer));
407
408 break;
409 }
410
411 default:
412 DE_ASSERT(false);
413 }
414
415 clearColor(m_colorScale * 0.4f, m_colorScale * 1.0f, m_colorScale * 0.5f, m_colorScale * 1.0f);
416
417 if (m_useColorClears)
418 {
419 const int maxClearCount = 10;
420 const int minClearCount = 6;
421 const int minClearSize = 15;
422
423 int clearCount = m_random.getInt(minClearCount, maxClearCount);
424
425 for (int clearNdx = 0; clearNdx < clearCount; clearNdx++)
426 {
427 int clearX = m_random.getInt(0, width - minClearSize);
428 int clearY = m_random.getInt(0, height - minClearSize);
429
430 int clearWidth = m_random.getInt(minClearSize, width - clearX);
431 int clearHeight = m_random.getInt(minClearSize, height - clearY);
432
433 float clearRed = m_colorScale * m_random.getFloat();
434 float clearGreen = m_colorScale * m_random.getFloat();
435 float clearBlue = m_colorScale * m_random.getFloat();
436 float clearAlpha = m_colorScale * (0.5f + 0.5f * m_random.getFloat());
437
438 GLU_CHECK_CALL(glEnable(GL_SCISSOR_TEST));
439 GLU_CHECK_CALL(glScissor(clearX, clearY, clearWidth, clearHeight));
440
441 clearColor(clearRed, clearGreen, clearBlue, clearAlpha);
442 }
443
444 GLU_CHECK_CALL(glDisable(GL_SCISSOR_TEST));
445 }
446
447 if (m_renderTriangles)
448 {
449 const int minTriangleCount = 4;
450 const int maxTriangleCount = 10;
451
452 int triangleCount = m_random.getInt(minTriangleCount, maxTriangleCount);
453
454 for (int triangleNdx = 0; triangleNdx < triangleCount; triangleNdx++)
455 {
456 float x1 = 2.0f * m_random.getFloat() - 1.0f;
457 float y1 = 2.0f * m_random.getFloat() - 1.0f;
458 float z1 = 2.0f * m_random.getFloat() - 1.0f;
459
460 float x2 = 2.0f * m_random.getFloat() - 1.0f;
461 float y2 = 2.0f * m_random.getFloat() - 1.0f;
462 float z2 = 2.0f * m_random.getFloat() - 1.0f;
463
464 float x3 = 2.0f * m_random.getFloat() - 1.0f;
465 float y3 = 2.0f * m_random.getFloat() - 1.0f;
466 float z3 = 2.0f * m_random.getFloat() - 1.0f;
467
468 renderTriangle(tcu::Vec3(x1, y1, z1), tcu::Vec3(x2, y2, z2), tcu::Vec3(x3, y3, z3));
469 }
470 }
471
472 tcu::TextureFormat readFormat;
473 GLenum readPixelsFormat;
474 GLenum readPixelsType;
475 bool floatCompare;
476
477
478 if (m_framebuffeType == TestSpec::FRAMEBUFFERTYPE_NATIVE)
479 {
480 readFormat = glu::mapGLTransferFormat(GL_RGBA, GL_UNSIGNED_BYTE);
481 readPixelsFormat = GL_RGBA;
482 readPixelsType = GL_UNSIGNED_BYTE;
483 floatCompare = false;
484 }
485 else if (m_framebuffeType == TestSpec::FRAMEBUFFERTYPE_RENDERBUFFER)
486 {
487 switch (m_texChannelClass)
488 {
489 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
490 readFormat = glu::mapGLTransferFormat(GL_RGBA, GL_UNSIGNED_BYTE);
491 readPixelsFormat = GL_RGBA;
492 readPixelsType = GL_UNSIGNED_BYTE;
493 floatCompare = true;
494 break;
495
496 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
497 readFormat = glu::mapGLTransferFormat(GL_RGBA_INTEGER, GL_INT);
498 readPixelsFormat = GL_RGBA_INTEGER;
499 readPixelsType = GL_INT;
500 floatCompare = false;
501 break;
502
503 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
504 readFormat = glu::mapGLTransferFormat(GL_RGBA_INTEGER, GL_UNSIGNED_INT);
505 readPixelsFormat = GL_RGBA_INTEGER;
506 readPixelsType = GL_UNSIGNED_INT;
507 floatCompare = false;
508 break;
509
510 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
511 readFormat = glu::mapGLTransferFormat(GL_RGBA, GL_FLOAT);
512 readPixelsFormat = GL_RGBA;
513 readPixelsType = GL_FLOAT;
514 floatCompare = true;
515 break;
516
517 default:
518 DE_ASSERT(false);
519 // Silence warnings
520 readFormat = glu::mapGLTransferFormat(GL_RGBA, GL_FLOAT);
521 readPixelsFormat = GL_RGBA;
522 readPixelsType = GL_FLOAT;
523 floatCompare = true;
524 }
525 }
526 else
527 {
528 // Silence warnings
529 readFormat = glu::mapGLTransferFormat(GL_RGBA, GL_FLOAT);
530 readPixelsFormat = GL_RGBA;
531 readPixelsType = GL_FLOAT;
532 floatCompare = true;
533 DE_ASSERT(false);
534 }
535
536 tcu::Texture2D readRefrence (readFormat, width, height);
537 const int readDataSize = readRefrence.getWidth() * readRefrence.getHeight() * readFormat.getPixelSize();
538
539 readRefrence.allocLevel(0);
540
541 GLuint pixelBuffer = (GLuint)-1;
542
543 GLU_CHECK_CALL(glGenBuffers(1, &pixelBuffer));
544 GLU_CHECK_CALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, pixelBuffer));
545 GLU_CHECK_CALL(glBufferData(GL_PIXEL_PACK_BUFFER, readDataSize, NULL, GL_STREAM_READ));
546
547 GLU_CHECK_CALL(glReadPixels(0, 0, width, height, readPixelsFormat, readPixelsType, 0));
548
549 const deUint8* bufferData = (const deUint8*)glMapBufferRange(GL_PIXEL_PACK_BUFFER, 0, readDataSize, GL_MAP_READ_BIT);
550 GLU_CHECK_MSG("glMapBufferRange() failed");
551
552 tcu::ConstPixelBufferAccess readResult(readFormat, width, height, 1, bufferData);
553
554 GLU_CHECK_CALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, 0));
555
556 GLU_CHECK_CALL(glReadPixels(0, 0, width, height, readPixelsFormat, readPixelsType, readRefrence.getLevel(0).getDataPtr()));
557
558 if (framebuffer)
559 GLU_CHECK_CALL(glDeleteFramebuffers(1, &framebuffer));
560
561 if (renderbuffer)
562 GLU_CHECK_CALL(glDeleteRenderbuffers(1, &renderbuffer));
563
564
565 bool isOk = false;
566
567 if (floatCompare)
568 {
569 const tcu::IVec4 formatBitDepths = tcu::getTextureFormatBitDepth(readFormat);
570 const float redThreshold = 2.0f / (float)(1 << deMin32(m_context.getRenderTarget().getPixelFormat().redBits, formatBitDepths.x()));
571 const float greenThreshold = 2.0f / (float)(1 << deMin32(m_context.getRenderTarget().getPixelFormat().greenBits, formatBitDepths.y()));
572 const float blueThreshold = 2.0f / (float)(1 << deMin32(m_context.getRenderTarget().getPixelFormat().blueBits, formatBitDepths.z()));
573 const float alphaThreshold = 2.0f / (float)(1 << deMin32(m_context.getRenderTarget().getPixelFormat().alphaBits, formatBitDepths.w()));
574
575 isOk = tcu::floatThresholdCompare(m_log, "Result comparision", "Result of read pixels to memory compared with result of read pixels to buffer", readRefrence.getLevel(0), readResult, tcu::Vec4(redThreshold, greenThreshold, blueThreshold, alphaThreshold), tcu::COMPARE_LOG_RESULT);
576 }
577 else
578 {
579 isOk = tcu::intThresholdCompare(m_log, "Result comparision", "Result of read pixels to memory compared with result of read pixels to buffer", readRefrence.getLevel(0), readResult, tcu::UVec4(0, 0, 0, 0), tcu::COMPARE_LOG_RESULT);
580 }
581
582 GLU_CHECK_CALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, pixelBuffer));
583 GLU_CHECK_CALL(glUnmapBuffer(GL_PIXEL_PACK_BUFFER));
584 GLU_CHECK_CALL(glDeleteBuffers(1, &pixelBuffer));
585
586 if (isOk)
587 {
588 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
589 return STOP;
590 }
591 else
592 {
593 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
594 return STOP;
595 }
596 }
597
598 } // anonymous
599
PixelBufferObjectTests(Context & context)600 PixelBufferObjectTests::PixelBufferObjectTests (Context& context)
601 : TestCaseGroup (context, "pbo", "Pixel buffer objects tests")
602 {
603 }
604
~PixelBufferObjectTests(void)605 PixelBufferObjectTests::~PixelBufferObjectTests (void)
606 {
607 }
608
init(void)609 void PixelBufferObjectTests::init (void)
610 {
611 TestCaseGroup* nativeFramebufferGroup = new TestCaseGroup(m_context, "native", "Tests with reading from native framebuffer");
612
613 ReadPixelsTest::TestSpec nativeFramebufferTests[] = {
614 {
615 "clears",
616 "Simple read pixels test with color clears",
617 true,
618 false,
619 ReadPixelsTest::TestSpec::FRAMEBUFFERTYPE_NATIVE,
620 GL_NONE
621 },
622 {
623 "triangles",
624 "Simple read pixels test rendering triangles",
625 false,
626 true,
627 ReadPixelsTest::TestSpec::FRAMEBUFFERTYPE_NATIVE,
628 GL_NONE
629 }
630 };
631
632 for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(nativeFramebufferTests); testNdx++)
633 {
634 nativeFramebufferGroup->addChild(new ReadPixelsTest(m_context, nativeFramebufferTests[testNdx]));
635 }
636
637 addChild(nativeFramebufferGroup);
638
639 TestCaseGroup* renderbufferGroup = new TestCaseGroup(m_context, "renderbuffer", "Tests with reading from renderbuffer");
640
641 GLenum renderbufferFormats[] = {
642 GL_RGBA8,
643 GL_RGBA8I,
644 GL_RGBA8UI,
645 GL_RGBA16F,
646 GL_RGBA16I,
647 GL_RGBA16UI,
648 GL_RGBA32F,
649 GL_RGBA32I,
650 GL_RGBA32UI,
651
652 GL_SRGB8_ALPHA8,
653 GL_RGB10_A2,
654 GL_RGB10_A2UI,
655 GL_RGBA4,
656 GL_RGB5_A1,
657
658 GL_RGB8,
659 GL_RGB565,
660
661 GL_R11F_G11F_B10F,
662
663 GL_RG8,
664 GL_RG8I,
665 GL_RG8UI,
666 GL_RG16F,
667 GL_RG16I,
668 GL_RG16UI,
669 GL_RG32F,
670 GL_RG32I,
671 GL_RG32UI
672 };
673
674 const char* renderbufferFormatsStr[] = {
675 "rgba8",
676 "rgba8i",
677 "rgba8ui",
678 "rgba16f",
679 "rgba16i",
680 "rgba16ui",
681 "rgba32f",
682 "rgba32i",
683 "rgba32ui",
684
685 "srgb8_alpha8",
686 "rgb10_a2",
687 "rgb10_a2ui",
688 "rgba4",
689 "rgb5_a1",
690
691 "rgb8",
692 "rgb565",
693
694 "r11f_g11f_b10f",
695
696 "rg8",
697 "rg8i",
698 "rg8ui",
699 "rg16f",
700 "rg16i",
701 "rg16ui",
702 "rg32f",
703 "rg32i",
704 "rg32ui"
705 };
706
707 DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(renderbufferFormatsStr) == DE_LENGTH_OF_ARRAY(renderbufferFormats));
708
709 for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(renderbufferFormats); formatNdx++)
710 {
711 for (int trianglesClears = 0; trianglesClears < 2; trianglesClears++)
712 {
713 ReadPixelsTest::TestSpec testSpec;
714
715 testSpec.name = string(renderbufferFormatsStr [formatNdx]) + "_" + (trianglesClears == 0 ? "triangles" : "clears"),
716 testSpec.description = testSpec.name;
717 testSpec.useColorClear = trianglesClears == 1,
718 testSpec.renderTriangles = trianglesClears == 0,
719 testSpec.framebufferType = ReadPixelsTest::TestSpec::FRAMEBUFFERTYPE_RENDERBUFFER,
720 testSpec.renderbufferFormat = renderbufferFormats[formatNdx];
721
722 renderbufferGroup->addChild(new ReadPixelsTest(m_context, testSpec));
723 }
724 }
725
726 addChild(renderbufferGroup);
727 }
728
729 } // Functional
730 } // gles3
731 } // deqp
732