xref: /aosp_15_r20/external/deqp/modules/gles2/functional/es2fReadPixelsTests.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker  * drawElements Quality Program OpenGL ES 2.0 Module
3*35238bceSAndroid Build Coastguard Worker  * -------------------------------------------------
4*35238bceSAndroid Build Coastguard Worker  *
5*35238bceSAndroid Build Coastguard Worker  * Copyright 2014 The Android Open Source Project
6*35238bceSAndroid Build Coastguard Worker  *
7*35238bceSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
8*35238bceSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
9*35238bceSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
10*35238bceSAndroid Build Coastguard Worker  *
11*35238bceSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
12*35238bceSAndroid Build Coastguard Worker  *
13*35238bceSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
14*35238bceSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
15*35238bceSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16*35238bceSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
17*35238bceSAndroid Build Coastguard Worker  * limitations under the License.
18*35238bceSAndroid Build Coastguard Worker  *
19*35238bceSAndroid Build Coastguard Worker  *//*!
20*35238bceSAndroid Build Coastguard Worker  * \file
21*35238bceSAndroid Build Coastguard Worker  * \brief Read pixels tests
22*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker 
24*35238bceSAndroid Build Coastguard Worker #include "es2fReadPixelsTests.hpp"
25*35238bceSAndroid Build Coastguard Worker 
26*35238bceSAndroid Build Coastguard Worker #include "tcuTexture.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "tcuTextureUtil.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "tcuImageCompare.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "tcuRenderTarget.hpp"
31*35238bceSAndroid Build Coastguard Worker 
32*35238bceSAndroid Build Coastguard Worker #include "deRandom.hpp"
33*35238bceSAndroid Build Coastguard Worker #include "deMath.h"
34*35238bceSAndroid Build Coastguard Worker #include "deString.h"
35*35238bceSAndroid Build Coastguard Worker #include "deStringUtil.hpp"
36*35238bceSAndroid Build Coastguard Worker 
37*35238bceSAndroid Build Coastguard Worker #include "gluDefs.hpp"
38*35238bceSAndroid Build Coastguard Worker #include "gluShaderProgram.hpp"
39*35238bceSAndroid Build Coastguard Worker #include "gluStrUtil.hpp"
40*35238bceSAndroid Build Coastguard Worker #include "gluTextureUtil.hpp"
41*35238bceSAndroid Build Coastguard Worker 
42*35238bceSAndroid Build Coastguard Worker #include "glw.h"
43*35238bceSAndroid Build Coastguard Worker 
44*35238bceSAndroid Build Coastguard Worker #include <cstring>
45*35238bceSAndroid Build Coastguard Worker 
46*35238bceSAndroid Build Coastguard Worker namespace deqp
47*35238bceSAndroid Build Coastguard Worker {
48*35238bceSAndroid Build Coastguard Worker namespace gles2
49*35238bceSAndroid Build Coastguard Worker {
50*35238bceSAndroid Build Coastguard Worker namespace Functional
51*35238bceSAndroid Build Coastguard Worker {
52*35238bceSAndroid Build Coastguard Worker 
53*35238bceSAndroid Build Coastguard Worker class ReadPixelsTest : public TestCase
54*35238bceSAndroid Build Coastguard Worker {
55*35238bceSAndroid Build Coastguard Worker public:
56*35238bceSAndroid Build Coastguard Worker     ReadPixelsTest(Context &context, const char *name, const char *description, bool chooseFormat, int alignment);
57*35238bceSAndroid Build Coastguard Worker 
58*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void);
59*35238bceSAndroid Build Coastguard Worker     void render(tcu::Texture2D &reference);
60*35238bceSAndroid Build Coastguard Worker 
61*35238bceSAndroid Build Coastguard Worker private:
62*35238bceSAndroid Build Coastguard Worker     bool m_chooseFormat;
63*35238bceSAndroid Build Coastguard Worker     int m_alignment;
64*35238bceSAndroid Build Coastguard Worker     int m_seed;
65*35238bceSAndroid Build Coastguard Worker 
66*35238bceSAndroid Build Coastguard Worker     void getFormatInfo(tcu::TextureFormat &format, GLint &glFormat, GLint &glType, int &pixelSize);
67*35238bceSAndroid Build Coastguard Worker };
68*35238bceSAndroid Build Coastguard Worker 
ReadPixelsTest(Context & context,const char * name,const char * description,bool chooseFormat,int alignment)69*35238bceSAndroid Build Coastguard Worker ReadPixelsTest::ReadPixelsTest(Context &context, const char *name, const char *description, bool chooseFormat,
70*35238bceSAndroid Build Coastguard Worker                                int alignment)
71*35238bceSAndroid Build Coastguard Worker     : TestCase(context, name, description)
72*35238bceSAndroid Build Coastguard Worker     , m_chooseFormat(chooseFormat)
73*35238bceSAndroid Build Coastguard Worker     , m_alignment(alignment)
74*35238bceSAndroid Build Coastguard Worker     , m_seed(deStringHash(name))
75*35238bceSAndroid Build Coastguard Worker {
76*35238bceSAndroid Build Coastguard Worker }
77*35238bceSAndroid Build Coastguard Worker 
render(tcu::Texture2D & reference)78*35238bceSAndroid Build Coastguard Worker void ReadPixelsTest::render(tcu::Texture2D &reference)
79*35238bceSAndroid Build Coastguard Worker {
80*35238bceSAndroid Build Coastguard Worker     // Create program
81*35238bceSAndroid Build Coastguard Worker     const char *vertexSource = "attribute mediump vec2 a_coord;\n"
82*35238bceSAndroid Build Coastguard Worker                                "void main (void)\n"
83*35238bceSAndroid Build Coastguard Worker                                "{\n"
84*35238bceSAndroid Build Coastguard Worker                                "\tgl_Position = vec4(a_coord, 0.0, 1.0);\n"
85*35238bceSAndroid Build Coastguard Worker                                "}\n";
86*35238bceSAndroid Build Coastguard Worker 
87*35238bceSAndroid Build Coastguard Worker     const char *fragmentSource = "void main (void)\n"
88*35238bceSAndroid Build Coastguard Worker                                  "{\n"
89*35238bceSAndroid Build Coastguard Worker                                  "\tgl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n"
90*35238bceSAndroid Build Coastguard Worker                                  "}\n";
91*35238bceSAndroid Build Coastguard Worker 
92*35238bceSAndroid Build Coastguard Worker     glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(vertexSource, fragmentSource));
93*35238bceSAndroid Build Coastguard Worker 
94*35238bceSAndroid Build Coastguard Worker     m_testCtx.getLog() << program;
95*35238bceSAndroid Build Coastguard Worker     TCU_CHECK(program.isOk());
96*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_CALL(glUseProgram(program.getProgram()));
97*35238bceSAndroid Build Coastguard Worker 
98*35238bceSAndroid Build Coastguard Worker     // Render
99*35238bceSAndroid Build Coastguard Worker     {
100*35238bceSAndroid Build Coastguard Worker         const float coords[] = {-0.5f, -0.5f, 0.5f,  -0.5f, 0.5f,  0.5f,
101*35238bceSAndroid Build Coastguard Worker 
102*35238bceSAndroid Build Coastguard Worker                                 0.5f,  0.5f,  -0.5f, 0.5f,  -0.5f, -0.5f};
103*35238bceSAndroid Build Coastguard Worker         GLuint coordLoc;
104*35238bceSAndroid Build Coastguard Worker 
105*35238bceSAndroid Build Coastguard Worker         coordLoc = glGetAttribLocation(program.getProgram(), "a_coord");
106*35238bceSAndroid Build Coastguard Worker         GLU_CHECK_MSG("glGetAttribLocation()");
107*35238bceSAndroid Build Coastguard Worker 
108*35238bceSAndroid Build Coastguard Worker         GLU_CHECK_CALL(glEnableVertexAttribArray(coordLoc));
109*35238bceSAndroid Build Coastguard Worker 
110*35238bceSAndroid Build Coastguard Worker         GLU_CHECK_CALL(glVertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, coords));
111*35238bceSAndroid Build Coastguard Worker 
112*35238bceSAndroid Build Coastguard Worker         GLU_CHECK_CALL(glDrawArrays(GL_TRIANGLES, 0, 6));
113*35238bceSAndroid Build Coastguard Worker         GLU_CHECK_CALL(glDisableVertexAttribArray(coordLoc));
114*35238bceSAndroid Build Coastguard Worker     }
115*35238bceSAndroid Build Coastguard Worker 
116*35238bceSAndroid Build Coastguard Worker     // Render reference
117*35238bceSAndroid Build Coastguard Worker 
118*35238bceSAndroid Build Coastguard Worker     const int coordX1 = (int)((-0.5f * (float)reference.getWidth() / 2.0f) + (float)reference.getWidth() / 2.0f);
119*35238bceSAndroid Build Coastguard Worker     const int coordY1 = (int)((-0.5f * (float)reference.getHeight() / 2.0f) + (float)reference.getHeight() / 2.0f);
120*35238bceSAndroid Build Coastguard Worker     const int coordX2 = (int)((0.5f * (float)reference.getWidth() / 2.0f) + (float)reference.getWidth() / 2.0f);
121*35238bceSAndroid Build Coastguard Worker     const int coordY2 = (int)((0.5f * (float)reference.getHeight() / 2.0f) + (float)reference.getHeight() / 2.0f);
122*35238bceSAndroid Build Coastguard Worker 
123*35238bceSAndroid Build Coastguard Worker     for (int x = 0; x < reference.getWidth(); x++)
124*35238bceSAndroid Build Coastguard Worker     {
125*35238bceSAndroid Build Coastguard Worker         if (x < coordX1 || x > coordX2)
126*35238bceSAndroid Build Coastguard Worker             continue;
127*35238bceSAndroid Build Coastguard Worker 
128*35238bceSAndroid Build Coastguard Worker         for (int y = 0; y < reference.getHeight(); y++)
129*35238bceSAndroid Build Coastguard Worker         {
130*35238bceSAndroid Build Coastguard Worker             if (y >= coordY1 && y <= coordY2)
131*35238bceSAndroid Build Coastguard Worker                 reference.getLevel(0).setPixel(tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f), x, y);
132*35238bceSAndroid Build Coastguard Worker         }
133*35238bceSAndroid Build Coastguard Worker     }
134*35238bceSAndroid Build Coastguard Worker }
135*35238bceSAndroid Build Coastguard Worker 
getFormatInfo(tcu::TextureFormat & format,GLint & glFormat,GLint & glType,int & pixelSize)136*35238bceSAndroid Build Coastguard Worker void ReadPixelsTest::getFormatInfo(tcu::TextureFormat &format, GLint &glFormat, GLint &glType, int &pixelSize)
137*35238bceSAndroid Build Coastguard Worker {
138*35238bceSAndroid Build Coastguard Worker     if (m_chooseFormat)
139*35238bceSAndroid Build Coastguard Worker     {
140*35238bceSAndroid Build Coastguard Worker         GLU_CHECK_CALL(glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &glFormat));
141*35238bceSAndroid Build Coastguard Worker         GLU_CHECK_CALL(glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &glType));
142*35238bceSAndroid Build Coastguard Worker 
143*35238bceSAndroid Build Coastguard Worker         if (glFormat != GL_RGBA && glFormat != GL_BGRA && glFormat != GL_RGB)
144*35238bceSAndroid Build Coastguard Worker             TCU_THROW(NotSupportedError, ("Unsupported IMPLEMENTATION_COLOR_READ_FORMAT: " +
145*35238bceSAndroid Build Coastguard Worker                                           de::toString(glu::getTextureFormatStr(glFormat)))
146*35238bceSAndroid Build Coastguard Worker                                              .c_str());
147*35238bceSAndroid Build Coastguard Worker         if (glu::getTypeName(glType) == DE_NULL)
148*35238bceSAndroid Build Coastguard Worker             TCU_THROW(NotSupportedError,
149*35238bceSAndroid Build Coastguard Worker                       ("Unsupported GL_IMPLEMENTATION_COLOR_READ_TYPE: " + de::toString(tcu::Format::Hex<4>(glType)))
150*35238bceSAndroid Build Coastguard Worker                           .c_str());
151*35238bceSAndroid Build Coastguard Worker 
152*35238bceSAndroid Build Coastguard Worker         format    = glu::mapGLTransferFormat(glFormat, glType);
153*35238bceSAndroid Build Coastguard Worker         pixelSize = format.getPixelSize();
154*35238bceSAndroid Build Coastguard Worker     }
155*35238bceSAndroid Build Coastguard Worker     else
156*35238bceSAndroid Build Coastguard Worker     {
157*35238bceSAndroid Build Coastguard Worker         format    = tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8);
158*35238bceSAndroid Build Coastguard Worker         pixelSize = 1 * 4;
159*35238bceSAndroid Build Coastguard Worker         glFormat  = GL_RGBA;
160*35238bceSAndroid Build Coastguard Worker         glType    = GL_UNSIGNED_BYTE;
161*35238bceSAndroid Build Coastguard Worker     }
162*35238bceSAndroid Build Coastguard Worker }
163*35238bceSAndroid Build Coastguard Worker 
iterate(void)164*35238bceSAndroid Build Coastguard Worker TestCase::IterateResult ReadPixelsTest::iterate(void)
165*35238bceSAndroid Build Coastguard Worker {
166*35238bceSAndroid Build Coastguard Worker     // Create reference
167*35238bceSAndroid Build Coastguard Worker     const int width  = 13;
168*35238bceSAndroid Build Coastguard Worker     const int height = 13;
169*35238bceSAndroid Build Coastguard Worker 
170*35238bceSAndroid Build Coastguard Worker     de::Random rnd(m_seed);
171*35238bceSAndroid Build Coastguard Worker 
172*35238bceSAndroid Build Coastguard Worker     tcu::TextureFormat format(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8);
173*35238bceSAndroid Build Coastguard Worker     int pixelSize;
174*35238bceSAndroid Build Coastguard Worker     GLint glFormat;
175*35238bceSAndroid Build Coastguard Worker     GLint glType;
176*35238bceSAndroid Build Coastguard Worker 
177*35238bceSAndroid Build Coastguard Worker     getFormatInfo(format, glFormat, glType, pixelSize);
178*35238bceSAndroid Build Coastguard Worker     m_testCtx.getLog() << tcu::TestLog::Message << "Format: " << glu::getTextureFormatStr(glFormat)
179*35238bceSAndroid Build Coastguard Worker                        << ", Type: " << glu::getTypeStr(glType) << tcu::TestLog::EndMessage;
180*35238bceSAndroid Build Coastguard Worker 
181*35238bceSAndroid Build Coastguard Worker     tcu::Texture2D reference(format, width, height, glu::isES2Context(m_context.getRenderContext().getType()));
182*35238bceSAndroid Build Coastguard Worker     reference.allocLevel(0);
183*35238bceSAndroid Build Coastguard Worker 
184*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_CALL(glViewport(0, 0, width, height));
185*35238bceSAndroid Build Coastguard Worker 
186*35238bceSAndroid Build Coastguard Worker     // Clear color
187*35238bceSAndroid Build Coastguard Worker     {
188*35238bceSAndroid Build Coastguard Worker         const float red   = rnd.getFloat();
189*35238bceSAndroid Build Coastguard Worker         const float green = rnd.getFloat();
190*35238bceSAndroid Build Coastguard Worker         const float blue  = rnd.getFloat();
191*35238bceSAndroid Build Coastguard Worker         const float alpha = 1.0f;
192*35238bceSAndroid Build Coastguard Worker 
193*35238bceSAndroid Build Coastguard Worker         m_testCtx.getLog() << tcu::TestLog::Message << "Clear color: (" << red << ", " << green << ", " << blue << ", "
194*35238bceSAndroid Build Coastguard Worker                            << alpha << ")" << tcu::TestLog::EndMessage;
195*35238bceSAndroid Build Coastguard Worker 
196*35238bceSAndroid Build Coastguard Worker         // Clear target
197*35238bceSAndroid Build Coastguard Worker         GLU_CHECK_CALL(glClearColor(red, green, blue, alpha));
198*35238bceSAndroid Build Coastguard Worker         GLU_CHECK_CALL(glClear(GL_COLOR_BUFFER_BIT));
199*35238bceSAndroid Build Coastguard Worker 
200*35238bceSAndroid Build Coastguard Worker         tcu::clear(reference.getLevel(0), tcu::Vec4(red, green, blue, alpha));
201*35238bceSAndroid Build Coastguard Worker     }
202*35238bceSAndroid Build Coastguard Worker 
203*35238bceSAndroid Build Coastguard Worker     render(reference);
204*35238bceSAndroid Build Coastguard Worker 
205*35238bceSAndroid Build Coastguard Worker     std::vector<uint8_t> pixelData;
206*35238bceSAndroid Build Coastguard Worker     const int rowPitch = m_alignment * deCeilFloatToInt32(float(pixelSize * width) / (float)m_alignment);
207*35238bceSAndroid Build Coastguard Worker 
208*35238bceSAndroid Build Coastguard Worker     pixelData.resize(rowPitch * height, 0);
209*35238bceSAndroid Build Coastguard Worker 
210*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_CALL(glPixelStorei(GL_PACK_ALIGNMENT, m_alignment));
211*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_CALL(glReadPixels(0, 0, width, height, glFormat, glType, &(pixelData[0])));
212*35238bceSAndroid Build Coastguard Worker 
213*35238bceSAndroid Build Coastguard Worker     if (m_context.getRenderTarget().getNumSamples() > 1)
214*35238bceSAndroid Build Coastguard Worker     {
215*35238bceSAndroid Build Coastguard Worker         const tcu::IVec4 formatBitDepths = tcu::getTextureFormatBitDepth(format);
216*35238bceSAndroid Build Coastguard Worker         const uint8_t redThreshold       = (uint8_t)deCeilFloatToInt32(
217*35238bceSAndroid Build Coastguard Worker             256.0f *
218*35238bceSAndroid Build Coastguard Worker             (2.0f / (float)(1 << deMin32(m_context.getRenderTarget().getPixelFormat().redBits, formatBitDepths.x()))));
219*35238bceSAndroid Build Coastguard Worker         const uint8_t greenThreshold = (uint8_t)deCeilFloatToInt32(
220*35238bceSAndroid Build Coastguard Worker             256.0f * (2.0f / (float)(1 << deMin32(m_context.getRenderTarget().getPixelFormat().greenBits,
221*35238bceSAndroid Build Coastguard Worker                                                   formatBitDepths.y()))));
222*35238bceSAndroid Build Coastguard Worker         const uint8_t blueThreshold = (uint8_t)deCeilFloatToInt32(
223*35238bceSAndroid Build Coastguard Worker             256.0f *
224*35238bceSAndroid Build Coastguard Worker             (2.0f / (float)(1 << deMin32(m_context.getRenderTarget().getPixelFormat().blueBits, formatBitDepths.z()))));
225*35238bceSAndroid Build Coastguard Worker         const uint8_t alphaThreshold = (uint8_t)deCeilFloatToInt32(
226*35238bceSAndroid Build Coastguard Worker             256.0f * (2.0f / (float)(1 << deMin32(m_context.getRenderTarget().getPixelFormat().alphaBits,
227*35238bceSAndroid Build Coastguard Worker                                                   formatBitDepths.w()))));
228*35238bceSAndroid Build Coastguard Worker 
229*35238bceSAndroid Build Coastguard Worker         // bilinearCompare only accepts RGBA, UINT8
230*35238bceSAndroid Build Coastguard Worker         tcu::Texture2D referenceRGBA8(tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8),
231*35238bceSAndroid Build Coastguard Worker                                       width, height, glu::isES2Context(m_context.getRenderContext().getType()));
232*35238bceSAndroid Build Coastguard Worker         tcu::Texture2D resultRGBA8(tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), width,
233*35238bceSAndroid Build Coastguard Worker                                    height, glu::isES2Context(m_context.getRenderContext().getType()));
234*35238bceSAndroid Build Coastguard Worker 
235*35238bceSAndroid Build Coastguard Worker         referenceRGBA8.allocLevel(0);
236*35238bceSAndroid Build Coastguard Worker         resultRGBA8.allocLevel(0);
237*35238bceSAndroid Build Coastguard Worker 
238*35238bceSAndroid Build Coastguard Worker         tcu::copy(referenceRGBA8.getLevel(0), reference.getLevel(0));
239*35238bceSAndroid Build Coastguard Worker         tcu::copy(resultRGBA8.getLevel(0),
240*35238bceSAndroid Build Coastguard Worker                   tcu::PixelBufferAccess(format, width, height, 1, rowPitch, 0, &(pixelData[0])));
241*35238bceSAndroid Build Coastguard Worker 
242*35238bceSAndroid Build Coastguard Worker         if (tcu::bilinearCompare(
243*35238bceSAndroid Build Coastguard Worker                 m_testCtx.getLog(), "Result", "Result", referenceRGBA8.getLevel(0), resultRGBA8.getLevel(0),
244*35238bceSAndroid Build Coastguard Worker                 tcu::RGBA(redThreshold, greenThreshold, blueThreshold, alphaThreshold), tcu::COMPARE_LOG_RESULT))
245*35238bceSAndroid Build Coastguard Worker             m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
246*35238bceSAndroid Build Coastguard Worker         else
247*35238bceSAndroid Build Coastguard Worker             m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
248*35238bceSAndroid Build Coastguard Worker     }
249*35238bceSAndroid Build Coastguard Worker     else
250*35238bceSAndroid Build Coastguard Worker     {
251*35238bceSAndroid Build Coastguard Worker         const tcu::IVec4 formatBitDepths = tcu::getTextureFormatBitDepth(format);
252*35238bceSAndroid Build Coastguard Worker         const float redThreshold =
253*35238bceSAndroid Build Coastguard Worker             2.0f / (float)(1 << deMin32(m_context.getRenderTarget().getPixelFormat().redBits, formatBitDepths.x()));
254*35238bceSAndroid Build Coastguard Worker         const float greenThreshold =
255*35238bceSAndroid Build Coastguard Worker             2.0f / (float)(1 << deMin32(m_context.getRenderTarget().getPixelFormat().greenBits, formatBitDepths.y()));
256*35238bceSAndroid Build Coastguard Worker         const float blueThreshold =
257*35238bceSAndroid Build Coastguard Worker             2.0f / (float)(1 << deMin32(m_context.getRenderTarget().getPixelFormat().blueBits, formatBitDepths.z()));
258*35238bceSAndroid Build Coastguard Worker         const float alphaThreshold =
259*35238bceSAndroid Build Coastguard Worker             2.0f / (float)(1 << deMin32(m_context.getRenderTarget().getPixelFormat().alphaBits, formatBitDepths.w()));
260*35238bceSAndroid Build Coastguard Worker 
261*35238bceSAndroid Build Coastguard Worker         // Compare
262*35238bceSAndroid Build Coastguard Worker         if (tcu::floatThresholdCompare(m_testCtx.getLog(), "Result", "Result", reference.getLevel(0),
263*35238bceSAndroid Build Coastguard Worker                                        tcu::PixelBufferAccess(format, width, height, 1, rowPitch, 0, &(pixelData[0])),
264*35238bceSAndroid Build Coastguard Worker                                        tcu::Vec4(redThreshold, greenThreshold, blueThreshold, alphaThreshold),
265*35238bceSAndroid Build Coastguard Worker                                        tcu::COMPARE_LOG_RESULT))
266*35238bceSAndroid Build Coastguard Worker             m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
267*35238bceSAndroid Build Coastguard Worker         else
268*35238bceSAndroid Build Coastguard Worker             m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
269*35238bceSAndroid Build Coastguard Worker     }
270*35238bceSAndroid Build Coastguard Worker 
271*35238bceSAndroid Build Coastguard Worker     return STOP;
272*35238bceSAndroid Build Coastguard Worker }
273*35238bceSAndroid Build Coastguard Worker 
ReadPixelsTests(Context & context)274*35238bceSAndroid Build Coastguard Worker ReadPixelsTests::ReadPixelsTests(Context &context) : TestCaseGroup(context, "read_pixels", "ReadPixel tests")
275*35238bceSAndroid Build Coastguard Worker {
276*35238bceSAndroid Build Coastguard Worker }
277*35238bceSAndroid Build Coastguard Worker 
init(void)278*35238bceSAndroid Build Coastguard Worker void ReadPixelsTests::init(void)
279*35238bceSAndroid Build Coastguard Worker {
280*35238bceSAndroid Build Coastguard Worker     addChild(new ReadPixelsTest(m_context, "rgba_ubyte_align_1", "", false, 1));
281*35238bceSAndroid Build Coastguard Worker     addChild(new ReadPixelsTest(m_context, "rgba_ubyte_align_2", "", false, 2));
282*35238bceSAndroid Build Coastguard Worker     addChild(new ReadPixelsTest(m_context, "rgba_ubyte_align_4", "", false, 4));
283*35238bceSAndroid Build Coastguard Worker     addChild(new ReadPixelsTest(m_context, "rgba_ubyte_align_8", "", false, 8));
284*35238bceSAndroid Build Coastguard Worker 
285*35238bceSAndroid Build Coastguard Worker     addChild(new ReadPixelsTest(m_context, "choose_align_1", "", true, 1));
286*35238bceSAndroid Build Coastguard Worker     addChild(new ReadPixelsTest(m_context, "choose_align_2", "", true, 2));
287*35238bceSAndroid Build Coastguard Worker     addChild(new ReadPixelsTest(m_context, "choose_align_4", "", true, 4));
288*35238bceSAndroid Build Coastguard Worker     addChild(new ReadPixelsTest(m_context, "choose_align_8", "", true, 8));
289*35238bceSAndroid Build Coastguard Worker }
290*35238bceSAndroid Build Coastguard Worker 
291*35238bceSAndroid Build Coastguard Worker } // namespace Functional
292*35238bceSAndroid Build Coastguard Worker } // namespace gles2
293*35238bceSAndroid Build Coastguard Worker } // namespace deqp
294