13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES 3.0 Module 33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * ------------------------------------------------- 43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project 63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License"); 83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License. 93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at 103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * http://www.apache.org/licenses/LICENSE-2.0 123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software 143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS, 153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and 173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License. 183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*! 203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file 213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Read pixels tests 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es3fReadPixelsTests.hpp" 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTexture.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTextureUtil.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuImageCompare.hpp" 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestLog.hpp" 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuRenderTarget.hpp" 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deRandom.hpp" 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deMath.h" 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deString.h" 350fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry#include "deStringUtil.hpp" 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluDefs.hpp" 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluShaderProgram.hpp" 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluStrUtil.hpp" 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluTextureUtil.hpp" 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <cstring> 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <sstream> 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glw.h" 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::vector; 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles3 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Functional 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ReadPixelsTest : public TestCase 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 620fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry enum 630fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry { 640fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry FLAG_NO_FLAGS = 0x0, 650fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry FLAG_CHOOSE_FORMAT = 0x1, 660fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry FLAG_USE_RBO = 0x2, 670fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry }; 680fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry 690fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry ReadPixelsTest (Context& context, const char* name, const char* description, int flags, int alignment, GLint rowLength, GLint skipRows, GLint skipPixels, GLenum format = GL_RGBA, GLenum type = GL_UNSIGNED_BYTE); 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IterateResult iterate (void); 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void render (tcu::Texture2D& reference); 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_seed; 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool m_chooseFormat; 770fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry bool m_useRenderBuffer; 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_alignment; 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLint m_rowLength; 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLint m_skipRows; 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLint m_skipPixels; 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLint m_format; 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLint m_type; 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int m_width; 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int m_height; 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 88115e0bf114f70d2c8caec6ff7a85aa7536ac713fMika Isojärvi void getFormatInfo (tcu::TextureFormat& format, int& pixelSize); 89115e0bf114f70d2c8caec6ff7a85aa7536ac713fMika Isojärvi void clearColor (tcu::Texture2D& reference, vector<deUint8>& pixelData, int pixelSize); 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 920fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko PöyryReadPixelsTest::ReadPixelsTest (Context& context, const char* name, const char* description, int flags, int alignment, GLint rowLength, GLint skipRows, GLint skipPixels, GLenum format, GLenum type) 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase (context, name, description) 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_seed (deStringHash(name)) 950fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry , m_chooseFormat ((flags & FLAG_CHOOSE_FORMAT) != 0) 960fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry , m_useRenderBuffer ((flags & FLAG_USE_RBO) != 0) 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_alignment (alignment) 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_rowLength (rowLength) 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_skipRows (skipRows) 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_skipPixels (skipPixels) 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_format (format) 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_type (type) 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_width (13) 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_height (13) 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ReadPixelsTest::render (tcu::Texture2D& reference) 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Create program 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* vertexSource = 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "#version 300 es\n" 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "in mediump vec2 i_coord;\n" 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "void main (void)\n" 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "{\n" 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "\tgl_Position = vec4(i_coord, 0.0, 1.0);\n" 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "}\n"; 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::stringstream fragmentSource; 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fragmentSource << 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "#version 300 es\n"; 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (reference.getFormat().type == tcu::TextureFormat::SIGNED_INT32) 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fragmentSource << "layout(location = 0) out mediump ivec4 o_color;\n"; 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (reference.getFormat().type == tcu::TextureFormat::UNSIGNED_INT32) 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fragmentSource << "layout(location = 0) out mediump uvec4 o_color;\n"; 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fragmentSource << "layout(location = 0) out mediump vec4 o_color;\n"; 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fragmentSource << 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "void main (void)\n" 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "{\n"; 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (reference.getFormat().type == tcu::TextureFormat::UNSIGNED_INT32) 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fragmentSource << "\to_color = uvec4(0, 0, 0, 1000);\n"; 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (reference.getFormat().type == tcu::TextureFormat::SIGNED_INT32) 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fragmentSource << "\to_color = ivec4(0, 0, 0, 1000);\n"; 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fragmentSource << "\to_color = vec4(0.0, 0.0, 0.0, 1.0);\n"; 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fragmentSource << 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "}\n"; 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(vertexSource, fragmentSource.str())); 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << program; 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK(program.isOk()); 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_CALL(glUseProgram(program.getProgram())); 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Render 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float coords[] = 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry -0.5f, -0.5f, 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 0.5f, -0.5f, 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 0.5f, 0.5f, 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 0.5f, 0.5f, 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry -0.5f, 0.5f, 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry -0.5f, -0.5f 1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLuint coordLoc; 1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry coordLoc = glGetAttribLocation(program.getProgram(), "i_coord"); 1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_MSG("glGetAttribLocation()"); 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_CALL(glEnableVertexAttribArray(coordLoc)); 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_CALL(glVertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, coords)); 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_CALL(glDrawArrays(GL_TRIANGLES, 0, 6)); 1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_CALL(glDisableVertexAttribArray(coordLoc)); 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Render reference 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 179fe0290aa6f03b7418900a98f758472c1a69a87bdJarkko Pöyry const int coordX1 = (int)((-0.5f * (float)reference.getWidth() / 2.0f) + (float)reference.getWidth() / 2.0f); 180fe0290aa6f03b7418900a98f758472c1a69a87bdJarkko Pöyry const int coordY1 = (int)((-0.5f * (float)reference.getHeight() / 2.0f) + (float)reference.getHeight() / 2.0f); 181fe0290aa6f03b7418900a98f758472c1a69a87bdJarkko Pöyry const int coordX2 = (int)(( 0.5f * (float)reference.getWidth() / 2.0f) + (float)reference.getWidth() / 2.0f); 182fe0290aa6f03b7418900a98f758472c1a69a87bdJarkko Pöyry const int coordY2 = (int)(( 0.5f * (float)reference.getHeight() / 2.0f) + (float)reference.getHeight() / 2.0f); 1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int x = 0; x < reference.getWidth(); x++) 1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (x < coordX1 || x > coordX2) 1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int y = 0; y < reference.getHeight(); y++) 1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (y >= coordY1 && y <= coordY2) 1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (reference.getFormat().type == tcu::TextureFormat::SIGNED_INT32) 1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry reference.getLevel(0).setPixel(tcu::IVec4(0, 0, 0, 1000), x, y); 1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (reference.getFormat().type == tcu::TextureFormat::UNSIGNED_INT32) 1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry reference.getLevel(0).setPixel(tcu::UVec4(0, 0, 0, 1000), x, y); 1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry reference.getLevel(0).setPixel(tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f), x, y); 1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 204115e0bf114f70d2c8caec6ff7a85aa7536ac713fMika Isojärvivoid ReadPixelsTest::getFormatInfo (tcu::TextureFormat& format, int& pixelSize) 2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_chooseFormat) 2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_CALL(glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &m_format)); 2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_CALL(glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &m_type)); 2100fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry 2110fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry if (m_format != GL_RGBA && m_format != GL_BGRA && m_format != GL_RGB) 212b2e583dfcd8aa0d4ef254f841213fcf724b2b193Jarkko Pöyry TCU_THROW(NotSupportedError, ("Unsupported IMPLEMENTATION_COLOR_READ_FORMAT: " + de::toString(glu::getTextureFormatStr(m_format))).c_str()); 2130fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry if (glu::getTypeName(m_type) == DE_NULL) 2140fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry TCU_THROW(NotSupportedError, ("Unsupported GL_IMPLEMENTATION_COLOR_READ_TYPE: " + de::toString(tcu::Format::Hex<4>(m_type))).c_str()); 2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry format = glu::mapGLTransferFormat(m_format, m_type); 2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry pixelSize = format.getPixelSize(); 2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 221115e0bf114f70d2c8caec6ff7a85aa7536ac713fMika Isojärvivoid ReadPixelsTest::clearColor (tcu::Texture2D& reference, vector<deUint8>& pixelData, int pixelSize) 2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::Random rnd(m_seed); 2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLuint framebuffer = 0; 2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLuint renderbuffer = 0; 2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2270fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry if (m_useRenderBuffer) 2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_type == GL_UNSIGNED_INT) 2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_CALL(glGenRenderbuffers(1, &renderbuffer)); 2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_CALL(glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer)); 2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_CALL(glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA32UI, m_width, m_height)); 2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_type == GL_INT) 2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_CALL(glGenRenderbuffers(1, &renderbuffer)); 2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_CALL(glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer)); 2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_CALL(glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA32I, m_width, m_height)); 2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_CALL(glBindRenderbuffer(GL_RENDERBUFFER, 0)); 2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_CALL(glGenFramebuffers(1, &framebuffer)); 2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_CALL(glBindFramebuffer(GL_FRAMEBUFFER, framebuffer)); 2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_CALL(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderbuffer)); 2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_format == GL_RGBA || m_format == GL_BGRA || m_format == GL_RGB) 2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Empty 2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_CALL(glViewport(0, 0, reference.getWidth(), reference.getHeight())); 2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Clear color 2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_format == GL_RGBA || m_format == GL_BGRA || m_format == GL_RGB) 2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float red = rnd.getFloat(); 2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float green = rnd.getFloat(); 2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float blue = rnd.getFloat(); 2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float alpha = rnd.getFloat(); 2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const GLfloat color[] = { red, green, blue, alpha }; 2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Clear target 2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_CALL(glClearColor(red, green, blue, alpha)); 2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "ClearColor: (" << red << ", " << green << ", " << blue << ")" << tcu::TestLog::EndMessage; 2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_CALL(glClearBufferfv(GL_COLOR, 0, color)); 2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 273e0f21cf5f2ee3a06c497f32a4392d23e4bbcd573Mika Isojärvi tcu::clear(reference.getLevel(0), tcu::Vec4(red, green, blue, alpha)); 2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_format == GL_RGBA_INTEGER) 2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_type == GL_INT) 2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const GLint red = rnd.getUint32(); 2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const GLint green = rnd.getUint32(); 2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const GLint blue = rnd.getUint32(); 2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const GLint alpha = rnd.getUint32(); 2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const GLint color[] = { red, green, blue, alpha }; 2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "ClearColor: (" << red << ", " << green << ", " << blue << ")" << tcu::TestLog::EndMessage; 2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_CALL(glClearBufferiv(GL_COLOR, 0, color)); 2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 289e0f21cf5f2ee3a06c497f32a4392d23e4bbcd573Mika Isojärvi tcu::clear(reference.getLevel(0), tcu::IVec4(red, green, blue, alpha)); 2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_type == GL_UNSIGNED_INT) 2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const GLuint red = rnd.getUint32(); 2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const GLuint green = rnd.getUint32(); 2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const GLuint blue = rnd.getUint32(); 2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const GLuint alpha = rnd.getUint32(); 2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const GLuint color[] = { red, green, blue, alpha }; 2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "ClearColor: (" << red << ", " << green << ", " << blue << ")" << tcu::TestLog::EndMessage; 3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_CALL(glClearBufferuiv(GL_COLOR, 0, color)); 3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 303e0f21cf5f2ee3a06c497f32a4392d23e4bbcd573Mika Isojärvi tcu::clear(reference.getLevel(0), tcu::UVec4(red, green, blue, alpha)); 3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry render(reference); 3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int rowWidth = (m_rowLength == 0 ? m_width : m_rowLength) + m_skipPixels; 314fe0290aa6f03b7418900a98f758472c1a69a87bdJarkko Pöyry const int rowPitch = m_alignment * deCeilFloatToInt32(float(pixelSize * rowWidth) / (float)m_alignment); 3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry pixelData.resize(rowPitch * (m_height + m_skipRows), 0); 3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_CALL(glReadPixels(0, 0, m_width, m_height, m_format, m_type, &(pixelData[0]))); 3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (framebuffer) 3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_CALL(glDeleteFramebuffers(1, &framebuffer)); 3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (renderbuffer) 3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_CALL(glDeleteRenderbuffers(1, &renderbuffer)); 3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3273c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTestCase::IterateResult ReadPixelsTest::iterate (void) 3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureFormat format(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8); 3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int pixelSize; 3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 332115e0bf114f70d2c8caec6ff7a85aa7536ac713fMika Isojärvi getFormatInfo(format, pixelSize); 333b2e583dfcd8aa0d4ef254f841213fcf724b2b193Jarkko Pöyry m_testCtx.getLog() << tcu::TestLog::Message << "Format: " << glu::getTextureFormatStr(m_format) << ", Type: " << glu::getTypeStr(m_type) << tcu::TestLog::EndMessage; 3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Texture2D reference(format, m_width, m_height); 3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry reference.allocLevel(0); 3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_CALL(glPixelStorei(GL_PACK_ALIGNMENT, m_alignment)); 3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "GL_PACK_ALIGNMENT: " << m_alignment << tcu::TestLog::EndMessage; 3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_CALL(glPixelStorei(GL_PACK_ROW_LENGTH, m_rowLength)); 3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "GL_PACK_ROW_LENGTH: " << m_rowLength << tcu::TestLog::EndMessage; 3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_CALL(glPixelStorei(GL_PACK_SKIP_ROWS, m_skipRows)); 3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "GL_PACK_SKIP_ROWS: " << m_skipRows << tcu::TestLog::EndMessage; 3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_CALL(glPixelStorei(GL_PACK_SKIP_PIXELS, m_skipPixels)); 3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "GL_PACK_SKIP_PIXELS: " << m_skipPixels << tcu::TestLog::EndMessage; 3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_CALL(glViewport(0, 0, m_width, m_height)); 3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<deUint8> pixelData; 353115e0bf114f70d2c8caec6ff7a85aa7536ac713fMika Isojärvi clearColor(reference, pixelData, pixelSize); 3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3550fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry const int rowWidth = (m_rowLength == 0 ? m_width : m_rowLength); 356638ea76205115934d300d714070e956995bb2e92Jarkko Pöyry const int rowPitch = m_alignment * deCeilFloatToInt32((float)(pixelSize * rowWidth) / (float)m_alignment); 3570fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry const tcu::ConstPixelBufferAccess resultAccess = tcu::ConstPixelBufferAccess(format, m_width, m_height, 1, rowPitch, 0, &(pixelData[pixelSize * m_skipPixels + m_skipRows * rowPitch])); 3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3590fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry // \note Renderbuffers are never multisampled 3600fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry if (!m_useRenderBuffer && m_context.getRenderTarget().getNumSamples() > 1) 3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::IVec4 formatBitDepths = tcu::getTextureFormatBitDepth(format); 363fe0290aa6f03b7418900a98f758472c1a69a87bdJarkko Pöyry const deUint8 redThreshold = (deUint8)deCeilFloatToInt32(256.0f * (2.0f / (float)(1 << deMin32(m_context.getRenderTarget().getPixelFormat().redBits, formatBitDepths.x())))); 364fe0290aa6f03b7418900a98f758472c1a69a87bdJarkko Pöyry const deUint8 greenThreshold = (deUint8)deCeilFloatToInt32(256.0f * (2.0f / (float)(1 << deMin32(m_context.getRenderTarget().getPixelFormat().greenBits, formatBitDepths.y())))); 365fe0290aa6f03b7418900a98f758472c1a69a87bdJarkko Pöyry const deUint8 blueThreshold = (deUint8)deCeilFloatToInt32(256.0f * (2.0f / (float)(1 << deMin32(m_context.getRenderTarget().getPixelFormat().blueBits, formatBitDepths.z())))); 366fe0290aa6f03b7418900a98f758472c1a69a87bdJarkko Pöyry const deUint8 alphaThreshold = (deUint8)deCeilFloatToInt32(256.0f * (2.0f / (float)(1 << deMin32(m_context.getRenderTarget().getPixelFormat().alphaBits, formatBitDepths.w())))); 3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3680fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry // bilinearCompare only accepts RGBA, UINT8 3690fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry tcu::Texture2D referenceRGBA8 (tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), m_width, m_height); 3700fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry tcu::Texture2D resultRGBA8 (tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), m_width, m_height); 3710fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry 3720fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry referenceRGBA8.allocLevel(0); 3730fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry resultRGBA8.allocLevel(0); 3740fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry 3750fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry tcu::copy(referenceRGBA8.getLevel(0), reference.getLevel(0)); 3760fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry tcu::copy(resultRGBA8.getLevel(0), resultAccess); 3770fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry 3780fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry if (tcu::bilinearCompare(m_testCtx.getLog(), "Result", "Result", referenceRGBA8.getLevel(0), resultRGBA8.getLevel(0), tcu::RGBA(redThreshold, greenThreshold, blueThreshold, alphaThreshold), tcu::COMPARE_LOG_RESULT)) 3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); 3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail"); 3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::IVec4 formatBitDepths = tcu::getTextureFormatBitDepth(format); 386fe0290aa6f03b7418900a98f758472c1a69a87bdJarkko Pöyry const float redThreshold = 2.0f / (float)(1 << deMin32(m_context.getRenderTarget().getPixelFormat().redBits, formatBitDepths.x())); 387fe0290aa6f03b7418900a98f758472c1a69a87bdJarkko Pöyry const float greenThreshold = 2.0f / (float)(1 << deMin32(m_context.getRenderTarget().getPixelFormat().greenBits, formatBitDepths.y())); 388fe0290aa6f03b7418900a98f758472c1a69a87bdJarkko Pöyry const float blueThreshold = 2.0f / (float)(1 << deMin32(m_context.getRenderTarget().getPixelFormat().blueBits, formatBitDepths.z())); 389fe0290aa6f03b7418900a98f758472c1a69a87bdJarkko Pöyry const float alphaThreshold = 2.0f / (float)(1 << deMin32(m_context.getRenderTarget().getPixelFormat().alphaBits, formatBitDepths.w())); 3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Compare 3920fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry if (tcu::floatThresholdCompare(m_testCtx.getLog(), "Result", "Result", reference.getLevel(0), resultAccess, tcu::Vec4(redThreshold, greenThreshold, blueThreshold, alphaThreshold), tcu::COMPARE_LOG_RESULT)) 3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); 3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail"); 3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // anonymous 4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4033c827367444ee418f129b2c238299f49d3264554Jarkko PoyryReadPixelsTests::ReadPixelsTests (Context& context) 4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup(context, "read_pixels", "ReadPixel tests") 4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ReadPixelsTests::init (void) 4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestCaseGroup* group = new TestCaseGroup(m_context, "alignment", "Read pixels pack alignment parameter tests"); 4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4130fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_ubyte_1", "", ReadPixelsTest::FLAG_NO_FLAGS, 1, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE)); 4140fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_ubyte_2", "", ReadPixelsTest::FLAG_NO_FLAGS, 2, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE)); 4150fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_ubyte_4", "", ReadPixelsTest::FLAG_NO_FLAGS, 4, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE)); 4160fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_ubyte_8", "", ReadPixelsTest::FLAG_NO_FLAGS, 8, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE)); 4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4180fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_int_1", "", ReadPixelsTest::FLAG_USE_RBO, 1, 0, 0, 0, GL_RGBA_INTEGER, GL_INT)); 4190fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_int_2", "", ReadPixelsTest::FLAG_USE_RBO, 2, 0, 0, 0, GL_RGBA_INTEGER, GL_INT)); 4200fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_int_4", "", ReadPixelsTest::FLAG_USE_RBO, 4, 0, 0, 0, GL_RGBA_INTEGER, GL_INT)); 4210fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_int_8", "", ReadPixelsTest::FLAG_USE_RBO, 8, 0, 0, 0, GL_RGBA_INTEGER, GL_INT)); 4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4230fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_uint_1", "", ReadPixelsTest::FLAG_USE_RBO, 1, 0, 0, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT)); 4240fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_uint_2", "", ReadPixelsTest::FLAG_USE_RBO, 2, 0, 0, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT)); 4250fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_uint_4", "", ReadPixelsTest::FLAG_USE_RBO, 4, 0, 0, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT)); 4260fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_uint_8", "", ReadPixelsTest::FLAG_USE_RBO, 8, 0, 0, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT)); 4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4280fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "choose_1", "", ReadPixelsTest::FLAG_CHOOSE_FORMAT, 1, 0, 0, 0)); 4290fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "choose_2", "", ReadPixelsTest::FLAG_CHOOSE_FORMAT, 2, 0, 0, 0)); 4300fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "choose_4", "", ReadPixelsTest::FLAG_CHOOSE_FORMAT, 4, 0, 0, 0)); 4310fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "choose_8", "", ReadPixelsTest::FLAG_CHOOSE_FORMAT, 8, 0, 0, 0)); 4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(group); 4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestCaseGroup* group = new TestCaseGroup(m_context, "rowlength", "Read pixels rowlength test"); 4380fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_ubyte_17", "", ReadPixelsTest::FLAG_NO_FLAGS, 4, 17, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE)); 4390fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_ubyte_19", "", ReadPixelsTest::FLAG_NO_FLAGS, 4, 19, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE)); 4400fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_ubyte_23", "", ReadPixelsTest::FLAG_NO_FLAGS, 4, 23, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE)); 4410fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_ubyte_29", "", ReadPixelsTest::FLAG_NO_FLAGS, 4, 29, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE)); 4420fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry 4430fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_int_17", "", ReadPixelsTest::FLAG_USE_RBO, 4, 17, 0, 0, GL_RGBA_INTEGER, GL_INT)); 4440fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_int_19", "", ReadPixelsTest::FLAG_USE_RBO, 4, 19, 0, 0, GL_RGBA_INTEGER, GL_INT)); 4450fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_int_23", "", ReadPixelsTest::FLAG_USE_RBO, 4, 23, 0, 0, GL_RGBA_INTEGER, GL_INT)); 4460fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_int_29", "", ReadPixelsTest::FLAG_USE_RBO, 4, 29, 0, 0, GL_RGBA_INTEGER, GL_INT)); 4470fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry 4480fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_uint_17", "", ReadPixelsTest::FLAG_USE_RBO, 4, 17, 0, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT)); 4490fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_uint_19", "", ReadPixelsTest::FLAG_USE_RBO, 4, 19, 0, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT)); 4500fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_uint_23", "", ReadPixelsTest::FLAG_USE_RBO, 4, 23, 0, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT)); 4510fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_uint_29", "", ReadPixelsTest::FLAG_USE_RBO, 4, 29, 0, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT)); 4520fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry 4530fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "choose_17", "", ReadPixelsTest::FLAG_CHOOSE_FORMAT, 4, 17, 0, 0)); 4540fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "choose_19", "", ReadPixelsTest::FLAG_CHOOSE_FORMAT, 4, 19, 0, 0)); 4550fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "choose_23", "", ReadPixelsTest::FLAG_CHOOSE_FORMAT, 4, 23, 0, 0)); 4560fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "choose_29", "", ReadPixelsTest::FLAG_CHOOSE_FORMAT, 4, 29, 0, 0)); 4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(group); 4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestCaseGroup* group = new TestCaseGroup(m_context, "skip", "Read pixels skip pixels and rows test"); 4630fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_ubyte_0_3", "", ReadPixelsTest::FLAG_NO_FLAGS, 4, 17, 0, 3, GL_RGBA, GL_UNSIGNED_BYTE)); 4640fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_ubyte_3_0", "", ReadPixelsTest::FLAG_NO_FLAGS, 4, 17, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE)); 4650fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_ubyte_3_3", "", ReadPixelsTest::FLAG_NO_FLAGS, 4, 17, 3, 3, GL_RGBA, GL_UNSIGNED_BYTE)); 4660fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_ubyte_3_5", "", ReadPixelsTest::FLAG_NO_FLAGS, 4, 17, 3, 5, GL_RGBA, GL_UNSIGNED_BYTE)); 4670fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry 4680fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_int_0_3", "", ReadPixelsTest::FLAG_USE_RBO, 4, 17, 0, 3, GL_RGBA_INTEGER, GL_INT)); 4690fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_int_3_0", "", ReadPixelsTest::FLAG_USE_RBO, 4, 17, 3, 0, GL_RGBA_INTEGER, GL_INT)); 4700fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_int_3_3", "", ReadPixelsTest::FLAG_USE_RBO, 4, 17, 3, 3, GL_RGBA_INTEGER, GL_INT)); 4710fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_int_3_5", "", ReadPixelsTest::FLAG_USE_RBO, 4, 17, 3, 5, GL_RGBA_INTEGER, GL_INT)); 4720fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry 4730fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_uint_0_3", "", ReadPixelsTest::FLAG_USE_RBO, 4, 17, 0, 3, GL_RGBA_INTEGER, GL_UNSIGNED_INT)); 4740fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_uint_3_0", "", ReadPixelsTest::FLAG_USE_RBO, 4, 17, 3, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT)); 4750fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_uint_3_3", "", ReadPixelsTest::FLAG_USE_RBO, 4, 17, 3, 3, GL_RGBA_INTEGER, GL_UNSIGNED_INT)); 4760fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "rgba_uint_3_5", "", ReadPixelsTest::FLAG_USE_RBO, 4, 17, 3, 5, GL_RGBA_INTEGER, GL_UNSIGNED_INT)); 4770fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry 4780fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "choose_0_3", "", ReadPixelsTest::FLAG_CHOOSE_FORMAT, 4, 17, 0, 3)); 4790fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "choose_3_0", "", ReadPixelsTest::FLAG_CHOOSE_FORMAT, 4, 17, 3, 0)); 4800fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "choose_3_3", "", ReadPixelsTest::FLAG_CHOOSE_FORMAT, 4, 17, 3, 3)); 4810fe53277c5a9fe323fc38f9de747af9ca4178b44Jarkko Pöyry group->addChild(new ReadPixelsTest(m_context, "choose_3_5", "", ReadPixelsTest::FLAG_CHOOSE_FORMAT, 4, 17, 3, 5)); 4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(group); 4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional 4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles3 4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp 490