xref: /aosp_15_r20/external/deqp/modules/gles31/functional/es31fShaderFramebufferFetchTests.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker  * drawElements Quality Program OpenGL ES 3.1 Module
3*35238bceSAndroid Build Coastguard Worker  * -------------------------------------------------
4*35238bceSAndroid Build Coastguard Worker  *
5*35238bceSAndroid Build Coastguard Worker  * Copyright 2017 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 EXT Shader Framebuffer Fetch Tests.
22*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker 
24*35238bceSAndroid Build Coastguard Worker #include "es31fShaderFramebufferFetchTests.hpp"
25*35238bceSAndroid Build Coastguard Worker #include "es31fFboTestUtil.hpp"
26*35238bceSAndroid Build Coastguard Worker 
27*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "tcuSurface.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "tcuTextureUtil.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "tcuImageCompare.hpp"
31*35238bceSAndroid Build Coastguard Worker #include "tcuVectorUtil.hpp"
32*35238bceSAndroid Build Coastguard Worker 
33*35238bceSAndroid Build Coastguard Worker #include "gluShaderProgram.hpp"
34*35238bceSAndroid Build Coastguard Worker #include "gluPixelTransfer.hpp"
35*35238bceSAndroid Build Coastguard Worker #include "gluTextureUtil.hpp"
36*35238bceSAndroid Build Coastguard Worker #include "gluContextInfo.hpp"
37*35238bceSAndroid Build Coastguard Worker #include "gluObjectWrapper.hpp"
38*35238bceSAndroid Build Coastguard Worker 
39*35238bceSAndroid Build Coastguard Worker #include "glwFunctions.hpp"
40*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
41*35238bceSAndroid Build Coastguard Worker 
42*35238bceSAndroid Build Coastguard Worker #include "deStringUtil.hpp"
43*35238bceSAndroid Build Coastguard Worker 
44*35238bceSAndroid Build Coastguard Worker #include <vector>
45*35238bceSAndroid Build Coastguard Worker 
46*35238bceSAndroid Build Coastguard Worker namespace deqp
47*35238bceSAndroid Build Coastguard Worker {
48*35238bceSAndroid Build Coastguard Worker namespace gles31
49*35238bceSAndroid Build Coastguard Worker {
50*35238bceSAndroid Build Coastguard Worker namespace Functional
51*35238bceSAndroid Build Coastguard Worker {
52*35238bceSAndroid Build Coastguard Worker namespace
53*35238bceSAndroid Build Coastguard Worker {
54*35238bceSAndroid Build Coastguard Worker 
55*35238bceSAndroid Build Coastguard Worker using std::string;
56*35238bceSAndroid Build Coastguard Worker using std::vector;
57*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
58*35238bceSAndroid Build Coastguard Worker 
59*35238bceSAndroid Build Coastguard Worker using namespace glw;
60*35238bceSAndroid Build Coastguard Worker using namespace FboTestUtil;
61*35238bceSAndroid Build Coastguard Worker 
checkExtensionSupport(Context & context,const char * extName)62*35238bceSAndroid Build Coastguard Worker static void checkExtensionSupport(Context &context, const char *extName)
63*35238bceSAndroid Build Coastguard Worker {
64*35238bceSAndroid Build Coastguard Worker     if (!context.getContextInfo().isExtensionSupported(extName))
65*35238bceSAndroid Build Coastguard Worker         throw tcu::NotSupportedError(string(extName) + " not supported");
66*35238bceSAndroid Build Coastguard Worker }
67*35238bceSAndroid Build Coastguard Worker 
checkFramebufferFetchSupport(Context & context)68*35238bceSAndroid Build Coastguard Worker static void checkFramebufferFetchSupport(Context &context)
69*35238bceSAndroid Build Coastguard Worker {
70*35238bceSAndroid Build Coastguard Worker     checkExtensionSupport(context, "GL_EXT_shader_framebuffer_fetch");
71*35238bceSAndroid Build Coastguard Worker }
72*35238bceSAndroid Build Coastguard Worker 
isRequiredFormat(uint32_t format,glu::RenderContext & renderContext)73*35238bceSAndroid Build Coastguard Worker static bool isRequiredFormat(uint32_t format, glu::RenderContext &renderContext)
74*35238bceSAndroid Build Coastguard Worker {
75*35238bceSAndroid Build Coastguard Worker     const bool isES32 = glu::contextSupports(renderContext.getType(), glu::ApiType::es(3, 2));
76*35238bceSAndroid Build Coastguard Worker     switch (format)
77*35238bceSAndroid Build Coastguard Worker     {
78*35238bceSAndroid Build Coastguard Worker     // Color-renderable formats
79*35238bceSAndroid Build Coastguard Worker     case GL_RGBA32I:
80*35238bceSAndroid Build Coastguard Worker     case GL_RGBA32UI:
81*35238bceSAndroid Build Coastguard Worker     case GL_RGBA16I:
82*35238bceSAndroid Build Coastguard Worker     case GL_RGBA16UI:
83*35238bceSAndroid Build Coastguard Worker     case GL_RGBA8:
84*35238bceSAndroid Build Coastguard Worker     case GL_RGBA8I:
85*35238bceSAndroid Build Coastguard Worker     case GL_RGBA8UI:
86*35238bceSAndroid Build Coastguard Worker     case GL_SRGB8_ALPHA8:
87*35238bceSAndroid Build Coastguard Worker     case GL_RGB10_A2:
88*35238bceSAndroid Build Coastguard Worker     case GL_RGB10_A2UI:
89*35238bceSAndroid Build Coastguard Worker     case GL_RGBA4:
90*35238bceSAndroid Build Coastguard Worker     case GL_RGB5_A1:
91*35238bceSAndroid Build Coastguard Worker     case GL_RGB8:
92*35238bceSAndroid Build Coastguard Worker     case GL_RGB565:
93*35238bceSAndroid Build Coastguard Worker     case GL_RG32I:
94*35238bceSAndroid Build Coastguard Worker     case GL_RG32UI:
95*35238bceSAndroid Build Coastguard Worker     case GL_RG16I:
96*35238bceSAndroid Build Coastguard Worker     case GL_RG16UI:
97*35238bceSAndroid Build Coastguard Worker     case GL_RG8:
98*35238bceSAndroid Build Coastguard Worker     case GL_RG8I:
99*35238bceSAndroid Build Coastguard Worker     case GL_RG8UI:
100*35238bceSAndroid Build Coastguard Worker     case GL_R32I:
101*35238bceSAndroid Build Coastguard Worker     case GL_R32UI:
102*35238bceSAndroid Build Coastguard Worker     case GL_R16I:
103*35238bceSAndroid Build Coastguard Worker     case GL_R16UI:
104*35238bceSAndroid Build Coastguard Worker     case GL_R8:
105*35238bceSAndroid Build Coastguard Worker     case GL_R8I:
106*35238bceSAndroid Build Coastguard Worker     case GL_R8UI:
107*35238bceSAndroid Build Coastguard Worker         return true;
108*35238bceSAndroid Build Coastguard Worker 
109*35238bceSAndroid Build Coastguard Worker     // Float format
110*35238bceSAndroid Build Coastguard Worker     case GL_RGBA32F:
111*35238bceSAndroid Build Coastguard Worker     case GL_RGB32F:
112*35238bceSAndroid Build Coastguard Worker     case GL_R11F_G11F_B10F:
113*35238bceSAndroid Build Coastguard Worker     case GL_RG32F:
114*35238bceSAndroid Build Coastguard Worker     case GL_R32F:
115*35238bceSAndroid Build Coastguard Worker         return isES32;
116*35238bceSAndroid Build Coastguard Worker 
117*35238bceSAndroid Build Coastguard Worker     default:
118*35238bceSAndroid Build Coastguard Worker         return false;
119*35238bceSAndroid Build Coastguard Worker     }
120*35238bceSAndroid Build Coastguard Worker }
121*35238bceSAndroid Build Coastguard Worker 
getReadPixelFormat(const tcu::TextureFormat & format)122*35238bceSAndroid Build Coastguard Worker tcu::TextureFormat getReadPixelFormat(const tcu::TextureFormat &format)
123*35238bceSAndroid Build Coastguard Worker {
124*35238bceSAndroid Build Coastguard Worker     switch (tcu::getTextureChannelClass(format.type))
125*35238bceSAndroid Build Coastguard Worker     {
126*35238bceSAndroid Build Coastguard Worker     case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
127*35238bceSAndroid Build Coastguard Worker         return tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNSIGNED_INT32);
128*35238bceSAndroid Build Coastguard Worker 
129*35238bceSAndroid Build Coastguard Worker     case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
130*35238bceSAndroid Build Coastguard Worker         return tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::SIGNED_INT32);
131*35238bceSAndroid Build Coastguard Worker 
132*35238bceSAndroid Build Coastguard Worker     case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
133*35238bceSAndroid Build Coastguard Worker     case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
134*35238bceSAndroid Build Coastguard Worker         return tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8);
135*35238bceSAndroid Build Coastguard Worker 
136*35238bceSAndroid Build Coastguard Worker     case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
137*35238bceSAndroid Build Coastguard Worker         return tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::FLOAT);
138*35238bceSAndroid Build Coastguard Worker 
139*35238bceSAndroid Build Coastguard Worker     default:
140*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(false);
141*35238bceSAndroid Build Coastguard Worker         return tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8);
142*35238bceSAndroid Build Coastguard Worker     }
143*35238bceSAndroid Build Coastguard Worker }
144*35238bceSAndroid Build Coastguard Worker 
getFixedPointFormatThreshold(const tcu::TextureFormat & sourceFormat,const tcu::TextureFormat & readPixelsFormat)145*35238bceSAndroid Build Coastguard Worker tcu::Vec4 getFixedPointFormatThreshold(const tcu::TextureFormat &sourceFormat,
146*35238bceSAndroid Build Coastguard Worker                                        const tcu::TextureFormat &readPixelsFormat)
147*35238bceSAndroid Build Coastguard Worker {
148*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(tcu::getTextureChannelClass(sourceFormat.type) != tcu::TEXTURECHANNELCLASS_FLOATING_POINT);
149*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(tcu::getTextureChannelClass(readPixelsFormat.type) != tcu::TEXTURECHANNELCLASS_FLOATING_POINT);
150*35238bceSAndroid Build Coastguard Worker 
151*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(tcu::getTextureChannelClass(sourceFormat.type) != tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER);
152*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(tcu::getTextureChannelClass(readPixelsFormat.type) != tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER);
153*35238bceSAndroid Build Coastguard Worker 
154*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(tcu::getTextureChannelClass(sourceFormat.type) != tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER);
155*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(tcu::getTextureChannelClass(readPixelsFormat.type) != tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER);
156*35238bceSAndroid Build Coastguard Worker 
157*35238bceSAndroid Build Coastguard Worker     const tcu::IVec4 srcBits  = tcu::getTextureFormatBitDepth(sourceFormat);
158*35238bceSAndroid Build Coastguard Worker     const tcu::IVec4 readBits = tcu::getTextureFormatBitDepth(readPixelsFormat);
159*35238bceSAndroid Build Coastguard Worker 
160*35238bceSAndroid Build Coastguard Worker     tcu::IVec4 bits;
161*35238bceSAndroid Build Coastguard Worker     for (uint32_t i = 0; i < 4; ++i)
162*35238bceSAndroid Build Coastguard Worker         bits[i] = srcBits[i] == 0 ? readBits[i] : de::min(srcBits[i], readBits[i]);
163*35238bceSAndroid Build Coastguard Worker     return tcu::Vec4(3.0f) /
164*35238bceSAndroid Build Coastguard Worker            ((tcu::Vector<uint64_t, 4>(1) << (bits.cast<uint64_t>())) - tcu::Vector<uint64_t, 4>(1)).cast<float>();
165*35238bceSAndroid Build Coastguard Worker }
166*35238bceSAndroid Build Coastguard Worker 
getFloatULPThreshold(const tcu::TextureFormat & sourceFormat,const tcu::TextureFormat & readPixelsFormat)167*35238bceSAndroid Build Coastguard Worker tcu::UVec4 getFloatULPThreshold(const tcu::TextureFormat &sourceFormat, const tcu::TextureFormat &readPixelsFormat)
168*35238bceSAndroid Build Coastguard Worker {
169*35238bceSAndroid Build Coastguard Worker     const tcu::IVec4 srcMantissaBits  = tcu::getTextureFormatMantissaBitDepth(sourceFormat);
170*35238bceSAndroid Build Coastguard Worker     const tcu::IVec4 readMantissaBits = tcu::getTextureFormatMantissaBitDepth(readPixelsFormat);
171*35238bceSAndroid Build Coastguard Worker     tcu::IVec4 ULPDiff(0);
172*35238bceSAndroid Build Coastguard Worker 
173*35238bceSAndroid Build Coastguard Worker     for (int i = 0; i < 4; i++)
174*35238bceSAndroid Build Coastguard Worker         if (readMantissaBits[i] >= srcMantissaBits[i])
175*35238bceSAndroid Build Coastguard Worker             ULPDiff[i] = readMantissaBits[i] - srcMantissaBits[i];
176*35238bceSAndroid Build Coastguard Worker 
177*35238bceSAndroid Build Coastguard Worker     return tcu::UVec4(4) * (tcu::UVec4(1) << (ULPDiff.cast<uint32_t>()));
178*35238bceSAndroid Build Coastguard Worker }
179*35238bceSAndroid Build Coastguard Worker 
isAnyExtensionSupported(Context & context,const std::vector<std::string> & requiredExts)180*35238bceSAndroid Build Coastguard Worker static bool isAnyExtensionSupported(Context &context, const std::vector<std::string> &requiredExts)
181*35238bceSAndroid Build Coastguard Worker {
182*35238bceSAndroid Build Coastguard Worker     for (std::vector<std::string>::const_iterator iter = requiredExts.begin(); iter != requiredExts.end(); iter++)
183*35238bceSAndroid Build Coastguard Worker     {
184*35238bceSAndroid Build Coastguard Worker         const std::string &extension = *iter;
185*35238bceSAndroid Build Coastguard Worker 
186*35238bceSAndroid Build Coastguard Worker         if (context.getContextInfo().isExtensionSupported(extension.c_str()))
187*35238bceSAndroid Build Coastguard Worker             return true;
188*35238bceSAndroid Build Coastguard Worker     }
189*35238bceSAndroid Build Coastguard Worker 
190*35238bceSAndroid Build Coastguard Worker     return false;
191*35238bceSAndroid Build Coastguard Worker }
192*35238bceSAndroid Build Coastguard Worker 
getColorOutputType(tcu::TextureFormat format)193*35238bceSAndroid Build Coastguard Worker static std::string getColorOutputType(tcu::TextureFormat format)
194*35238bceSAndroid Build Coastguard Worker {
195*35238bceSAndroid Build Coastguard Worker     switch (tcu::getTextureChannelClass(format.type))
196*35238bceSAndroid Build Coastguard Worker     {
197*35238bceSAndroid Build Coastguard Worker     case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
198*35238bceSAndroid Build Coastguard Worker         return "uvec4";
199*35238bceSAndroid Build Coastguard Worker     case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
200*35238bceSAndroid Build Coastguard Worker         return "ivec4";
201*35238bceSAndroid Build Coastguard Worker     case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
202*35238bceSAndroid Build Coastguard Worker     case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
203*35238bceSAndroid Build Coastguard Worker     case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
204*35238bceSAndroid Build Coastguard Worker         return "vec4";
205*35238bceSAndroid Build Coastguard Worker     default:
206*35238bceSAndroid Build Coastguard Worker         DE_FATAL("Unsupported TEXTURECHANNELCLASS");
207*35238bceSAndroid Build Coastguard Worker         return "";
208*35238bceSAndroid Build Coastguard Worker     }
209*35238bceSAndroid Build Coastguard Worker }
210*35238bceSAndroid Build Coastguard Worker 
getEnablingExtensions(uint32_t format,glu::RenderContext & renderContext)211*35238bceSAndroid Build Coastguard Worker static std::vector<std::string> getEnablingExtensions(uint32_t format, glu::RenderContext &renderContext)
212*35238bceSAndroid Build Coastguard Worker {
213*35238bceSAndroid Build Coastguard Worker     const bool isES32 = glu::contextSupports(renderContext.getType(), glu::ApiType::es(3, 2));
214*35238bceSAndroid Build Coastguard Worker     std::vector<std::string> out;
215*35238bceSAndroid Build Coastguard Worker 
216*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(!isRequiredFormat(format, renderContext));
217*35238bceSAndroid Build Coastguard Worker 
218*35238bceSAndroid Build Coastguard Worker     switch (format)
219*35238bceSAndroid Build Coastguard Worker     {
220*35238bceSAndroid Build Coastguard Worker     case GL_RGB16F:
221*35238bceSAndroid Build Coastguard Worker         out.push_back("GL_EXT_color_buffer_half_float");
222*35238bceSAndroid Build Coastguard Worker         break;
223*35238bceSAndroid Build Coastguard Worker 
224*35238bceSAndroid Build Coastguard Worker     case GL_RGBA16F:
225*35238bceSAndroid Build Coastguard Worker     case GL_RG16F:
226*35238bceSAndroid Build Coastguard Worker     case GL_R16F:
227*35238bceSAndroid Build Coastguard Worker         out.push_back("GL_EXT_color_buffer_half_float");
228*35238bceSAndroid Build Coastguard Worker         // Fallthrough
229*35238bceSAndroid Build Coastguard Worker 
230*35238bceSAndroid Build Coastguard Worker     case GL_RGBA32F:
231*35238bceSAndroid Build Coastguard Worker     case GL_RGB32F:
232*35238bceSAndroid Build Coastguard Worker     case GL_R11F_G11F_B10F:
233*35238bceSAndroid Build Coastguard Worker     case GL_RG32F:
234*35238bceSAndroid Build Coastguard Worker     case GL_R32F:
235*35238bceSAndroid Build Coastguard Worker         if (!isES32)
236*35238bceSAndroid Build Coastguard Worker             out.push_back("GL_EXT_color_buffer_float");
237*35238bceSAndroid Build Coastguard Worker         break;
238*35238bceSAndroid Build Coastguard Worker 
239*35238bceSAndroid Build Coastguard Worker     default:
240*35238bceSAndroid Build Coastguard Worker         break;
241*35238bceSAndroid Build Coastguard Worker     }
242*35238bceSAndroid Build Coastguard Worker 
243*35238bceSAndroid Build Coastguard Worker     return out;
244*35238bceSAndroid Build Coastguard Worker }
245*35238bceSAndroid Build Coastguard Worker 
checkFormatSupport(Context & context,uint32_t sizedFormat)246*35238bceSAndroid Build Coastguard Worker void checkFormatSupport(Context &context, uint32_t sizedFormat)
247*35238bceSAndroid Build Coastguard Worker {
248*35238bceSAndroid Build Coastguard Worker     const bool isCoreFormat = isRequiredFormat(sizedFormat, context.getRenderContext());
249*35238bceSAndroid Build Coastguard Worker     const std::vector<std::string> requiredExts =
250*35238bceSAndroid Build Coastguard Worker         (!isCoreFormat) ? getEnablingExtensions(sizedFormat, context.getRenderContext()) : std::vector<std::string>();
251*35238bceSAndroid Build Coastguard Worker 
252*35238bceSAndroid Build Coastguard Worker     // Check that we don't try to use invalid formats.
253*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(isCoreFormat || !requiredExts.empty());
254*35238bceSAndroid Build Coastguard Worker 
255*35238bceSAndroid Build Coastguard Worker     if (!requiredExts.empty() && !isAnyExtensionSupported(context, requiredExts))
256*35238bceSAndroid Build Coastguard Worker         throw tcu::NotSupportedError("Format not supported");
257*35238bceSAndroid Build Coastguard Worker }
258*35238bceSAndroid Build Coastguard Worker 
scaleColorValue(tcu::TextureFormat format,const tcu::Vec4 & color)259*35238bceSAndroid Build Coastguard Worker tcu::Vec4 scaleColorValue(tcu::TextureFormat format, const tcu::Vec4 &color)
260*35238bceSAndroid Build Coastguard Worker {
261*35238bceSAndroid Build Coastguard Worker     const tcu::TextureFormatInfo fmtInfo = tcu::getTextureFormatInfo(format);
262*35238bceSAndroid Build Coastguard Worker     const tcu::Vec4 cScale               = fmtInfo.valueMax - fmtInfo.valueMin;
263*35238bceSAndroid Build Coastguard Worker     const tcu::Vec4 cBias                = fmtInfo.valueMin;
264*35238bceSAndroid Build Coastguard Worker 
265*35238bceSAndroid Build Coastguard Worker     return tcu::RGBA(color).toVec() * cScale + cBias;
266*35238bceSAndroid Build Coastguard Worker }
267*35238bceSAndroid Build Coastguard Worker 
268*35238bceSAndroid Build Coastguard Worker // Base class for framebuffer fetch test cases
269*35238bceSAndroid Build Coastguard Worker 
270*35238bceSAndroid Build Coastguard Worker class FramebufferFetchTestCase : public TestCase
271*35238bceSAndroid Build Coastguard Worker {
272*35238bceSAndroid Build Coastguard Worker public:
273*35238bceSAndroid Build Coastguard Worker     FramebufferFetchTestCase(Context &context, const char *name, const char *desc, uint32_t format);
274*35238bceSAndroid Build Coastguard Worker     ~FramebufferFetchTestCase(void);
275*35238bceSAndroid Build Coastguard Worker 
276*35238bceSAndroid Build Coastguard Worker     void init(void);
277*35238bceSAndroid Build Coastguard Worker     void deinit(void);
278*35238bceSAndroid Build Coastguard Worker 
279*35238bceSAndroid Build Coastguard Worker protected:
280*35238bceSAndroid Build Coastguard Worker     string genPassThroughVertSource(void);
281*35238bceSAndroid Build Coastguard Worker     virtual glu::ProgramSources genShaderSources(void);
282*35238bceSAndroid Build Coastguard Worker 
283*35238bceSAndroid Build Coastguard Worker     void genFramebufferWithTexture(const tcu::Vec4 &color);
284*35238bceSAndroid Build Coastguard Worker     void genAttachementTexture(const tcu::Vec4 &color);
285*35238bceSAndroid Build Coastguard Worker     void genUniformColor(const tcu::Vec4 &color);
286*35238bceSAndroid Build Coastguard Worker 
287*35238bceSAndroid Build Coastguard Worker     void render(void);
288*35238bceSAndroid Build Coastguard Worker     void verifyRenderbuffer(TestLog &log, const tcu::TextureFormat &format, const tcu::TextureLevel &reference,
289*35238bceSAndroid Build Coastguard Worker                             const tcu::TextureLevel &result);
290*35238bceSAndroid Build Coastguard Worker 
291*35238bceSAndroid Build Coastguard Worker     const glw::Functions &m_gl;
292*35238bceSAndroid Build Coastguard Worker     const uint32_t m_format;
293*35238bceSAndroid Build Coastguard Worker 
294*35238bceSAndroid Build Coastguard Worker     glu::ShaderProgram *m_program;
295*35238bceSAndroid Build Coastguard Worker     GLuint m_framebuffer;
296*35238bceSAndroid Build Coastguard Worker     GLuint m_texColorBuffer;
297*35238bceSAndroid Build Coastguard Worker 
298*35238bceSAndroid Build Coastguard Worker     tcu::TextureFormat m_texFmt;
299*35238bceSAndroid Build Coastguard Worker     glu::TransferFormat m_transferFmt;
300*35238bceSAndroid Build Coastguard Worker     bool m_isFilterable;
301*35238bceSAndroid Build Coastguard Worker 
302*35238bceSAndroid Build Coastguard Worker     enum
303*35238bceSAndroid Build Coastguard Worker     {
304*35238bceSAndroid Build Coastguard Worker         VIEWPORT_WIDTH  = 64,
305*35238bceSAndroid Build Coastguard Worker         VIEWPORT_HEIGHT = 64,
306*35238bceSAndroid Build Coastguard Worker     };
307*35238bceSAndroid Build Coastguard Worker };
308*35238bceSAndroid Build Coastguard Worker 
FramebufferFetchTestCase(Context & context,const char * name,const char * desc,uint32_t format)309*35238bceSAndroid Build Coastguard Worker FramebufferFetchTestCase::FramebufferFetchTestCase(Context &context, const char *name, const char *desc,
310*35238bceSAndroid Build Coastguard Worker                                                    uint32_t format)
311*35238bceSAndroid Build Coastguard Worker     : TestCase(context, name, desc)
312*35238bceSAndroid Build Coastguard Worker     , m_gl(m_context.getRenderContext().getFunctions())
313*35238bceSAndroid Build Coastguard Worker     , m_format(format)
314*35238bceSAndroid Build Coastguard Worker     , m_program(DE_NULL)
315*35238bceSAndroid Build Coastguard Worker     , m_framebuffer(0)
316*35238bceSAndroid Build Coastguard Worker     , m_texColorBuffer(0)
317*35238bceSAndroid Build Coastguard Worker     , m_texFmt(glu::mapGLInternalFormat(m_format))
318*35238bceSAndroid Build Coastguard Worker     , m_transferFmt(glu::getTransferFormat(m_texFmt))
319*35238bceSAndroid Build Coastguard Worker     , m_isFilterable(glu::isGLInternalColorFormatFilterable(m_format))
320*35238bceSAndroid Build Coastguard Worker {
321*35238bceSAndroid Build Coastguard Worker }
322*35238bceSAndroid Build Coastguard Worker 
~FramebufferFetchTestCase(void)323*35238bceSAndroid Build Coastguard Worker FramebufferFetchTestCase::~FramebufferFetchTestCase(void)
324*35238bceSAndroid Build Coastguard Worker {
325*35238bceSAndroid Build Coastguard Worker     FramebufferFetchTestCase::deinit();
326*35238bceSAndroid Build Coastguard Worker }
327*35238bceSAndroid Build Coastguard Worker 
init(void)328*35238bceSAndroid Build Coastguard Worker void FramebufferFetchTestCase::init(void)
329*35238bceSAndroid Build Coastguard Worker {
330*35238bceSAndroid Build Coastguard Worker     checkFramebufferFetchSupport(m_context);
331*35238bceSAndroid Build Coastguard Worker     checkFormatSupport(m_context, m_format);
332*35238bceSAndroid Build Coastguard Worker 
333*35238bceSAndroid Build Coastguard Worker     if (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)) && tcu::isSRGB(m_texFmt))
334*35238bceSAndroid Build Coastguard Worker     {
335*35238bceSAndroid Build Coastguard Worker         m_gl.enable(GL_FRAMEBUFFER_SRGB);
336*35238bceSAndroid Build Coastguard Worker     }
337*35238bceSAndroid Build Coastguard Worker 
338*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(!m_program);
339*35238bceSAndroid Build Coastguard Worker     m_program = new glu::ShaderProgram(m_context.getRenderContext(), genShaderSources());
340*35238bceSAndroid Build Coastguard Worker 
341*35238bceSAndroid Build Coastguard Worker     m_testCtx.getLog() << *m_program;
342*35238bceSAndroid Build Coastguard Worker 
343*35238bceSAndroid Build Coastguard Worker     if (!m_program->isOk())
344*35238bceSAndroid Build Coastguard Worker     {
345*35238bceSAndroid Build Coastguard Worker         delete m_program;
346*35238bceSAndroid Build Coastguard Worker         m_program = DE_NULL;
347*35238bceSAndroid Build Coastguard Worker         TCU_FAIL("Failed to compile shader program");
348*35238bceSAndroid Build Coastguard Worker     }
349*35238bceSAndroid Build Coastguard Worker 
350*35238bceSAndroid Build Coastguard Worker     m_gl.useProgram(m_program->getProgram());
351*35238bceSAndroid Build Coastguard Worker }
352*35238bceSAndroid Build Coastguard Worker 
deinit(void)353*35238bceSAndroid Build Coastguard Worker void FramebufferFetchTestCase::deinit(void)
354*35238bceSAndroid Build Coastguard Worker {
355*35238bceSAndroid Build Coastguard Worker     delete m_program;
356*35238bceSAndroid Build Coastguard Worker     m_program = DE_NULL;
357*35238bceSAndroid Build Coastguard Worker 
358*35238bceSAndroid Build Coastguard Worker     if (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)))
359*35238bceSAndroid Build Coastguard Worker     {
360*35238bceSAndroid Build Coastguard Worker         m_gl.disable(GL_FRAMEBUFFER_SRGB);
361*35238bceSAndroid Build Coastguard Worker     }
362*35238bceSAndroid Build Coastguard Worker 
363*35238bceSAndroid Build Coastguard Worker     if (m_framebuffer)
364*35238bceSAndroid Build Coastguard Worker     {
365*35238bceSAndroid Build Coastguard Worker         m_gl.bindFramebuffer(GL_FRAMEBUFFER, 0);
366*35238bceSAndroid Build Coastguard Worker         m_gl.deleteFramebuffers(1, &m_framebuffer);
367*35238bceSAndroid Build Coastguard Worker         m_framebuffer = 0;
368*35238bceSAndroid Build Coastguard Worker     }
369*35238bceSAndroid Build Coastguard Worker 
370*35238bceSAndroid Build Coastguard Worker     if (m_texColorBuffer)
371*35238bceSAndroid Build Coastguard Worker     {
372*35238bceSAndroid Build Coastguard Worker         m_gl.deleteTextures(1, &m_texColorBuffer);
373*35238bceSAndroid Build Coastguard Worker         m_texColorBuffer = 0;
374*35238bceSAndroid Build Coastguard Worker     }
375*35238bceSAndroid Build Coastguard Worker }
376*35238bceSAndroid Build Coastguard Worker 
genPassThroughVertSource(void)377*35238bceSAndroid Build Coastguard Worker string FramebufferFetchTestCase::genPassThroughVertSource(void)
378*35238bceSAndroid Build Coastguard Worker {
379*35238bceSAndroid Build Coastguard Worker     std::ostringstream vertShaderSource;
380*35238bceSAndroid Build Coastguard Worker 
381*35238bceSAndroid Build Coastguard Worker     vertShaderSource << "#version 310 es\n"
382*35238bceSAndroid Build Coastguard Worker                      << "in highp vec4 a_position;\n"
383*35238bceSAndroid Build Coastguard Worker                      << "\n"
384*35238bceSAndroid Build Coastguard Worker                      << "void main (void)\n"
385*35238bceSAndroid Build Coastguard Worker                      << "{\n"
386*35238bceSAndroid Build Coastguard Worker                      << "    gl_Position = a_position;\n"
387*35238bceSAndroid Build Coastguard Worker                      << "}\n";
388*35238bceSAndroid Build Coastguard Worker 
389*35238bceSAndroid Build Coastguard Worker     return vertShaderSource.str();
390*35238bceSAndroid Build Coastguard Worker }
391*35238bceSAndroid Build Coastguard Worker 
genShaderSources(void)392*35238bceSAndroid Build Coastguard Worker glu::ProgramSources FramebufferFetchTestCase::genShaderSources(void)
393*35238bceSAndroid Build Coastguard Worker {
394*35238bceSAndroid Build Coastguard Worker     const string vecType = getColorOutputType(m_texFmt);
395*35238bceSAndroid Build Coastguard Worker     std::ostringstream fragShaderSource;
396*35238bceSAndroid Build Coastguard Worker     tcu::TextureChannelClass textureChannelClass = tcu::getTextureChannelClass(m_texFmt.type);
397*35238bceSAndroid Build Coastguard Worker     tcu::Vec4 maxValue                           = getTextureFormatInfo(m_texFmt).valueMax;
398*35238bceSAndroid Build Coastguard Worker     tcu::Vec4 minValue                           = getTextureFormatInfo(m_texFmt).valueMin;
399*35238bceSAndroid Build Coastguard Worker     string maxStr;
400*35238bceSAndroid Build Coastguard Worker     string minStr;
401*35238bceSAndroid Build Coastguard Worker 
402*35238bceSAndroid Build Coastguard Worker     if (textureChannelClass == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER)
403*35238bceSAndroid Build Coastguard Worker     {
404*35238bceSAndroid Build Coastguard Worker         maxStr = de::toString(maxValue.asUint());
405*35238bceSAndroid Build Coastguard Worker         minStr = de::toString(minValue.asUint());
406*35238bceSAndroid Build Coastguard Worker     }
407*35238bceSAndroid Build Coastguard Worker     else if (textureChannelClass == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER)
408*35238bceSAndroid Build Coastguard Worker     {
409*35238bceSAndroid Build Coastguard Worker         maxStr = de::toString(maxValue.asInt());
410*35238bceSAndroid Build Coastguard Worker         minStr = de::toString(minValue.asInt());
411*35238bceSAndroid Build Coastguard Worker     }
412*35238bceSAndroid Build Coastguard Worker     else
413*35238bceSAndroid Build Coastguard Worker     {
414*35238bceSAndroid Build Coastguard Worker         maxStr = de::toString(maxValue);
415*35238bceSAndroid Build Coastguard Worker         minStr = de::toString(minValue);
416*35238bceSAndroid Build Coastguard Worker     }
417*35238bceSAndroid Build Coastguard Worker 
418*35238bceSAndroid Build Coastguard Worker     fragShaderSource << "#version 310 es\n"
419*35238bceSAndroid Build Coastguard Worker                      << "#extension GL_EXT_shader_framebuffer_fetch : require\n"
420*35238bceSAndroid Build Coastguard Worker                      << "layout(location = 0) inout highp " << vecType << " o_color;\n"
421*35238bceSAndroid Build Coastguard Worker                      << "uniform highp " << vecType << " u_color;\n"
422*35238bceSAndroid Build Coastguard Worker                      << "\n"
423*35238bceSAndroid Build Coastguard Worker                      << "void main (void)\n"
424*35238bceSAndroid Build Coastguard Worker                      << "{\n"
425*35238bceSAndroid Build Coastguard Worker                      << "    o_color = clamp(o_color + u_color, " << vecType << minStr << ", " << vecType << maxStr
426*35238bceSAndroid Build Coastguard Worker                      << ");\n"
427*35238bceSAndroid Build Coastguard Worker                      << "}\n";
428*35238bceSAndroid Build Coastguard Worker 
429*35238bceSAndroid Build Coastguard Worker     return glu::makeVtxFragSources(genPassThroughVertSource(), fragShaderSource.str());
430*35238bceSAndroid Build Coastguard Worker }
431*35238bceSAndroid Build Coastguard Worker 
genFramebufferWithTexture(const tcu::Vec4 & color)432*35238bceSAndroid Build Coastguard Worker void FramebufferFetchTestCase::genFramebufferWithTexture(const tcu::Vec4 &color)
433*35238bceSAndroid Build Coastguard Worker {
434*35238bceSAndroid Build Coastguard Worker     m_gl.genFramebuffers(1, &m_framebuffer);
435*35238bceSAndroid Build Coastguard Worker     m_gl.bindFramebuffer(GL_FRAMEBUFFER, m_framebuffer);
436*35238bceSAndroid Build Coastguard Worker 
437*35238bceSAndroid Build Coastguard Worker     genAttachementTexture(color);
438*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(m_gl.getError(), "genAttachementTexture()");
439*35238bceSAndroid Build Coastguard Worker 
440*35238bceSAndroid Build Coastguard Worker     m_gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_texColorBuffer, 0);
441*35238bceSAndroid Build Coastguard Worker     TCU_CHECK(m_gl.checkFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);
442*35238bceSAndroid Build Coastguard Worker }
443*35238bceSAndroid Build Coastguard Worker 
genAttachementTexture(const tcu::Vec4 & color)444*35238bceSAndroid Build Coastguard Worker void FramebufferFetchTestCase::genAttachementTexture(const tcu::Vec4 &color)
445*35238bceSAndroid Build Coastguard Worker {
446*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel data(glu::mapGLTransferFormat(m_transferFmt.format, m_transferFmt.dataType), VIEWPORT_WIDTH,
447*35238bceSAndroid Build Coastguard Worker                            VIEWPORT_HEIGHT, 1);
448*35238bceSAndroid Build Coastguard Worker     tcu::TextureChannelClass textureChannelClass = tcu::getTextureChannelClass(m_texFmt.type);
449*35238bceSAndroid Build Coastguard Worker 
450*35238bceSAndroid Build Coastguard Worker     m_gl.genTextures(1, &m_texColorBuffer);
451*35238bceSAndroid Build Coastguard Worker     m_gl.bindTexture(GL_TEXTURE_2D, m_texColorBuffer);
452*35238bceSAndroid Build Coastguard Worker 
453*35238bceSAndroid Build Coastguard Worker     m_gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
454*35238bceSAndroid Build Coastguard Worker     m_gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
455*35238bceSAndroid Build Coastguard Worker     m_gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
456*35238bceSAndroid Build Coastguard Worker     m_gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_isFilterable ? GL_LINEAR : GL_NEAREST);
457*35238bceSAndroid Build Coastguard Worker     m_gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, m_isFilterable ? GL_LINEAR : GL_NEAREST);
458*35238bceSAndroid Build Coastguard Worker 
459*35238bceSAndroid Build Coastguard Worker     if (textureChannelClass == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER)
460*35238bceSAndroid Build Coastguard Worker         tcu::clear(data.getAccess(), color.asUint());
461*35238bceSAndroid Build Coastguard Worker     else if (textureChannelClass == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER)
462*35238bceSAndroid Build Coastguard Worker         tcu::clear(data.getAccess(), color.asInt());
463*35238bceSAndroid Build Coastguard Worker     else
464*35238bceSAndroid Build Coastguard Worker         tcu::clear(data.getAccess(), color);
465*35238bceSAndroid Build Coastguard Worker 
466*35238bceSAndroid Build Coastguard Worker     m_gl.texImage2D(GL_TEXTURE_2D, 0, m_format, VIEWPORT_WIDTH, VIEWPORT_HEIGHT, 0, m_transferFmt.format,
467*35238bceSAndroid Build Coastguard Worker                     m_transferFmt.dataType, data.getAccess().getDataPtr());
468*35238bceSAndroid Build Coastguard Worker     m_gl.bindTexture(GL_TEXTURE_2D, 0);
469*35238bceSAndroid Build Coastguard Worker }
470*35238bceSAndroid Build Coastguard Worker 
verifyRenderbuffer(TestLog & log,const tcu::TextureFormat & format,const tcu::TextureLevel & reference,const tcu::TextureLevel & result)471*35238bceSAndroid Build Coastguard Worker void FramebufferFetchTestCase::verifyRenderbuffer(TestLog &log, const tcu::TextureFormat &format,
472*35238bceSAndroid Build Coastguard Worker                                                   const tcu::TextureLevel &reference, const tcu::TextureLevel &result)
473*35238bceSAndroid Build Coastguard Worker {
474*35238bceSAndroid Build Coastguard Worker     m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
475*35238bceSAndroid Build Coastguard Worker 
476*35238bceSAndroid Build Coastguard Worker     switch (tcu::getTextureChannelClass(format.type))
477*35238bceSAndroid Build Coastguard Worker     {
478*35238bceSAndroid Build Coastguard Worker     case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
479*35238bceSAndroid Build Coastguard Worker     {
480*35238bceSAndroid Build Coastguard Worker         const string name          = "Renderbuffer";
481*35238bceSAndroid Build Coastguard Worker         const string desc          = "Compare renderbuffer (floating_point)";
482*35238bceSAndroid Build Coastguard Worker         const tcu::UVec4 threshold = getFloatULPThreshold(format, result.getFormat());
483*35238bceSAndroid Build Coastguard Worker 
484*35238bceSAndroid Build Coastguard Worker         if (!tcu::floatUlpThresholdCompare(log, name.c_str(), desc.c_str(), reference, result, threshold,
485*35238bceSAndroid Build Coastguard Worker                                            tcu::COMPARE_LOG_RESULT))
486*35238bceSAndroid Build Coastguard Worker             m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
487*35238bceSAndroid Build Coastguard Worker 
488*35238bceSAndroid Build Coastguard Worker         break;
489*35238bceSAndroid Build Coastguard Worker     }
490*35238bceSAndroid Build Coastguard Worker 
491*35238bceSAndroid Build Coastguard Worker     case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
492*35238bceSAndroid Build Coastguard Worker     case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
493*35238bceSAndroid Build Coastguard Worker     {
494*35238bceSAndroid Build Coastguard Worker         const string name = "Renderbuffer";
495*35238bceSAndroid Build Coastguard Worker         const string desc = "Compare renderbuffer (integer)";
496*35238bceSAndroid Build Coastguard Worker         const tcu::UVec4 threshold(1, 1, 1, 1);
497*35238bceSAndroid Build Coastguard Worker 
498*35238bceSAndroid Build Coastguard Worker         if (!tcu::intThresholdCompare(log, name.c_str(), desc.c_str(), reference, result, threshold,
499*35238bceSAndroid Build Coastguard Worker                                       tcu::COMPARE_LOG_RESULT))
500*35238bceSAndroid Build Coastguard Worker             m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
501*35238bceSAndroid Build Coastguard Worker 
502*35238bceSAndroid Build Coastguard Worker         break;
503*35238bceSAndroid Build Coastguard Worker     }
504*35238bceSAndroid Build Coastguard Worker 
505*35238bceSAndroid Build Coastguard Worker     case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
506*35238bceSAndroid Build Coastguard Worker     case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
507*35238bceSAndroid Build Coastguard Worker     {
508*35238bceSAndroid Build Coastguard Worker         const string name         = "Renderbuffer";
509*35238bceSAndroid Build Coastguard Worker         const string desc         = "Compare renderbuffer (fixed point)";
510*35238bceSAndroid Build Coastguard Worker         const tcu::Vec4 threshold = getFixedPointFormatThreshold(format, result.getFormat());
511*35238bceSAndroid Build Coastguard Worker 
512*35238bceSAndroid Build Coastguard Worker         if (!tcu::floatThresholdCompare(log, name.c_str(), desc.c_str(), reference, result, threshold,
513*35238bceSAndroid Build Coastguard Worker                                         tcu::COMPARE_LOG_RESULT))
514*35238bceSAndroid Build Coastguard Worker             m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
515*35238bceSAndroid Build Coastguard Worker 
516*35238bceSAndroid Build Coastguard Worker         break;
517*35238bceSAndroid Build Coastguard Worker     }
518*35238bceSAndroid Build Coastguard Worker 
519*35238bceSAndroid Build Coastguard Worker     default:
520*35238bceSAndroid Build Coastguard Worker     {
521*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(false);
522*35238bceSAndroid Build Coastguard Worker         m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
523*35238bceSAndroid Build Coastguard Worker     }
524*35238bceSAndroid Build Coastguard Worker     }
525*35238bceSAndroid Build Coastguard Worker }
526*35238bceSAndroid Build Coastguard Worker 
genUniformColor(const tcu::Vec4 & color)527*35238bceSAndroid Build Coastguard Worker void FramebufferFetchTestCase::genUniformColor(const tcu::Vec4 &color)
528*35238bceSAndroid Build Coastguard Worker {
529*35238bceSAndroid Build Coastguard Worker     const GLuint colorLocation = m_gl.getUniformLocation(m_program->getProgram(), "u_color");
530*35238bceSAndroid Build Coastguard Worker 
531*35238bceSAndroid Build Coastguard Worker     switch (tcu::getTextureChannelClass(m_texFmt.type))
532*35238bceSAndroid Build Coastguard Worker     {
533*35238bceSAndroid Build Coastguard Worker     case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
534*35238bceSAndroid Build Coastguard Worker     {
535*35238bceSAndroid Build Coastguard Worker         m_gl.uniform4uiv(colorLocation, 1, color.asUint().getPtr());
536*35238bceSAndroid Build Coastguard Worker         break;
537*35238bceSAndroid Build Coastguard Worker     }
538*35238bceSAndroid Build Coastguard Worker 
539*35238bceSAndroid Build Coastguard Worker     case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
540*35238bceSAndroid Build Coastguard Worker     {
541*35238bceSAndroid Build Coastguard Worker         m_gl.uniform4iv(colorLocation, 1, color.asInt().getPtr());
542*35238bceSAndroid Build Coastguard Worker         break;
543*35238bceSAndroid Build Coastguard Worker     }
544*35238bceSAndroid Build Coastguard Worker     case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
545*35238bceSAndroid Build Coastguard Worker     case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
546*35238bceSAndroid Build Coastguard Worker     case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
547*35238bceSAndroid Build Coastguard Worker     {
548*35238bceSAndroid Build Coastguard Worker         m_gl.uniform4fv(colorLocation, 1, color.asFloat().getPtr());
549*35238bceSAndroid Build Coastguard Worker         break;
550*35238bceSAndroid Build Coastguard Worker     }
551*35238bceSAndroid Build Coastguard Worker     default:
552*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(false);
553*35238bceSAndroid Build Coastguard Worker     }
554*35238bceSAndroid Build Coastguard Worker 
555*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(m_gl.getError(), "genUniformColor()");
556*35238bceSAndroid Build Coastguard Worker }
557*35238bceSAndroid Build Coastguard Worker 
render(void)558*35238bceSAndroid Build Coastguard Worker void FramebufferFetchTestCase::render(void)
559*35238bceSAndroid Build Coastguard Worker {
560*35238bceSAndroid Build Coastguard Worker     const GLfloat coords[] = {
561*35238bceSAndroid Build Coastguard Worker         -1.0f, -1.0f, +1.0f, -1.0f, +1.0f, +1.0f, -1.0f, +1.0f,
562*35238bceSAndroid Build Coastguard Worker     };
563*35238bceSAndroid Build Coastguard Worker 
564*35238bceSAndroid Build Coastguard Worker     const GLushort indices[] = {
565*35238bceSAndroid Build Coastguard Worker         0, 1, 2, 2, 3, 0,
566*35238bceSAndroid Build Coastguard Worker     };
567*35238bceSAndroid Build Coastguard Worker 
568*35238bceSAndroid Build Coastguard Worker     GLuint vaoID;
569*35238bceSAndroid Build Coastguard Worker     m_gl.genVertexArrays(1, &vaoID);
570*35238bceSAndroid Build Coastguard Worker     m_gl.bindVertexArray(vaoID);
571*35238bceSAndroid Build Coastguard Worker 
572*35238bceSAndroid Build Coastguard Worker     const GLuint coordLocation = m_gl.getAttribLocation(m_program->getProgram(), "a_position");
573*35238bceSAndroid Build Coastguard Worker 
574*35238bceSAndroid Build Coastguard Worker     m_gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
575*35238bceSAndroid Build Coastguard Worker 
576*35238bceSAndroid Build Coastguard Worker     glu::Buffer coordinatesBuffer(m_context.getRenderContext());
577*35238bceSAndroid Build Coastguard Worker     glu::Buffer elementsBuffer(m_context.getRenderContext());
578*35238bceSAndroid Build Coastguard Worker 
579*35238bceSAndroid Build Coastguard Worker     m_gl.bindBuffer(GL_ARRAY_BUFFER, *coordinatesBuffer);
580*35238bceSAndroid Build Coastguard Worker     m_gl.bufferData(GL_ARRAY_BUFFER, (GLsizeiptr)sizeof(coords), coords, GL_STATIC_DRAW);
581*35238bceSAndroid Build Coastguard Worker     m_gl.enableVertexAttribArray(coordLocation);
582*35238bceSAndroid Build Coastguard Worker     m_gl.vertexAttribPointer(coordLocation, 2, GL_FLOAT, GL_FALSE, 0, DE_NULL);
583*35238bceSAndroid Build Coastguard Worker 
584*35238bceSAndroid Build Coastguard Worker     m_gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, *elementsBuffer);
585*35238bceSAndroid Build Coastguard Worker     m_gl.bufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)sizeof(indices), &indices[0], GL_STATIC_DRAW);
586*35238bceSAndroid Build Coastguard Worker 
587*35238bceSAndroid Build Coastguard Worker     m_gl.drawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, DE_NULL);
588*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(m_gl.getError(), "render()");
589*35238bceSAndroid Build Coastguard Worker 
590*35238bceSAndroid Build Coastguard Worker     m_gl.deleteVertexArrays(1, &vaoID);
591*35238bceSAndroid Build Coastguard Worker }
592*35238bceSAndroid Build Coastguard Worker 
593*35238bceSAndroid Build Coastguard Worker // Test description:
594*35238bceSAndroid Build Coastguard Worker // - Attach texture containing solid color to framebuffer.
595*35238bceSAndroid Build Coastguard Worker // - Draw full quad covering the entire viewport.
596*35238bceSAndroid Build Coastguard Worker // - Sum framebuffer read color with passed in uniform color.
597*35238bceSAndroid Build Coastguard Worker // - Compare resulting surface with reference.
598*35238bceSAndroid Build Coastguard Worker 
599*35238bceSAndroid Build Coastguard Worker class TextureFormatTestCase : public FramebufferFetchTestCase
600*35238bceSAndroid Build Coastguard Worker {
601*35238bceSAndroid Build Coastguard Worker public:
602*35238bceSAndroid Build Coastguard Worker     TextureFormatTestCase(Context &context, const char *name, const char *desc, uint32_t format);
~TextureFormatTestCase(void)603*35238bceSAndroid Build Coastguard Worker     ~TextureFormatTestCase(void)
604*35238bceSAndroid Build Coastguard Worker     {
605*35238bceSAndroid Build Coastguard Worker     }
606*35238bceSAndroid Build Coastguard Worker 
607*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void);
608*35238bceSAndroid Build Coastguard Worker 
609*35238bceSAndroid Build Coastguard Worker private:
610*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel genReferenceTexture(const tcu::Vec4 &fbColor, const tcu::Vec4 &uniformColor);
611*35238bceSAndroid Build Coastguard Worker };
612*35238bceSAndroid Build Coastguard Worker 
TextureFormatTestCase(Context & context,const char * name,const char * desc,uint32_t format)613*35238bceSAndroid Build Coastguard Worker TextureFormatTestCase::TextureFormatTestCase(Context &context, const char *name, const char *desc, uint32_t format)
614*35238bceSAndroid Build Coastguard Worker     : FramebufferFetchTestCase(context, name, desc, format)
615*35238bceSAndroid Build Coastguard Worker {
616*35238bceSAndroid Build Coastguard Worker }
617*35238bceSAndroid Build Coastguard Worker 
genReferenceTexture(const tcu::Vec4 & fbColor,const tcu::Vec4 & uniformColor)618*35238bceSAndroid Build Coastguard Worker tcu::TextureLevel TextureFormatTestCase::genReferenceTexture(const tcu::Vec4 &fbColor, const tcu::Vec4 &uniformColor)
619*35238bceSAndroid Build Coastguard Worker {
620*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel reference(glu::mapGLTransferFormat(m_transferFmt.format, m_transferFmt.dataType), VIEWPORT_WIDTH,
621*35238bceSAndroid Build Coastguard Worker                                 VIEWPORT_HEIGHT, 1);
622*35238bceSAndroid Build Coastguard Worker     tcu::TextureChannelClass textureChannelClass = tcu::getTextureChannelClass(m_texFmt.type);
623*35238bceSAndroid Build Coastguard Worker 
624*35238bceSAndroid Build Coastguard Worker     tcu::Vec4 formatMaxValue = getTextureFormatInfo(m_texFmt).valueMax;
625*35238bceSAndroid Build Coastguard Worker     tcu::Vec4 formatMinValue = getTextureFormatInfo(m_texFmt).valueMin;
626*35238bceSAndroid Build Coastguard Worker 
627*35238bceSAndroid Build Coastguard Worker     if (textureChannelClass == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER)
628*35238bceSAndroid Build Coastguard Worker     {
629*35238bceSAndroid Build Coastguard Worker         tcu::clear(reference.getAccess(), tcu::clamp(fbColor.asUint() + uniformColor.asUint(), formatMinValue.asUint(),
630*35238bceSAndroid Build Coastguard Worker                                                      formatMaxValue.asUint()));
631*35238bceSAndroid Build Coastguard Worker     }
632*35238bceSAndroid Build Coastguard Worker     else if (textureChannelClass == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER)
633*35238bceSAndroid Build Coastguard Worker     {
634*35238bceSAndroid Build Coastguard Worker         tcu::IVec4 clearColor;
635*35238bceSAndroid Build Coastguard Worker 
636*35238bceSAndroid Build Coastguard Worker         // Calculate using 64 bits to avoid signed integer overflow.
637*35238bceSAndroid Build Coastguard Worker         for (int i = 0; i < 4; i++)
638*35238bceSAndroid Build Coastguard Worker             clearColor[i] = static_cast<int>(
639*35238bceSAndroid Build Coastguard Worker                 (static_cast<int64_t>(fbColor.asInt()[i]) + static_cast<int64_t>(uniformColor.asInt()[i])) &
640*35238bceSAndroid Build Coastguard Worker                 0xffffffff);
641*35238bceSAndroid Build Coastguard Worker 
642*35238bceSAndroid Build Coastguard Worker         tcu::clear(reference.getAccess(), clearColor);
643*35238bceSAndroid Build Coastguard Worker     }
644*35238bceSAndroid Build Coastguard Worker     else
645*35238bceSAndroid Build Coastguard Worker     {
646*35238bceSAndroid Build Coastguard Worker         if (tcu::isSRGB(m_texFmt))
647*35238bceSAndroid Build Coastguard Worker         {
648*35238bceSAndroid Build Coastguard Worker             const tcu::Vec4 fragmentColor =
649*35238bceSAndroid Build Coastguard Worker                 tcu::clamp(tcu::sRGBToLinear(fbColor) + uniformColor, formatMinValue, formatMaxValue);
650*35238bceSAndroid Build Coastguard Worker             tcu::clear(reference.getAccess(), tcu::linearToSRGB(fragmentColor));
651*35238bceSAndroid Build Coastguard Worker         }
652*35238bceSAndroid Build Coastguard Worker         else
653*35238bceSAndroid Build Coastguard Worker         {
654*35238bceSAndroid Build Coastguard Worker             tcu::clear(reference.getAccess(), tcu::clamp(fbColor + uniformColor, formatMinValue, formatMaxValue));
655*35238bceSAndroid Build Coastguard Worker         }
656*35238bceSAndroid Build Coastguard Worker     }
657*35238bceSAndroid Build Coastguard Worker 
658*35238bceSAndroid Build Coastguard Worker     return reference;
659*35238bceSAndroid Build Coastguard Worker }
660*35238bceSAndroid Build Coastguard Worker 
iterate(void)661*35238bceSAndroid Build Coastguard Worker TextureFormatTestCase::IterateResult TextureFormatTestCase::iterate(void)
662*35238bceSAndroid Build Coastguard Worker {
663*35238bceSAndroid Build Coastguard Worker     const tcu::Vec4 uniformColor = scaleColorValue(m_texFmt, tcu::Vec4(0.1f, 0.1f, 0.1f, 1.0f));
664*35238bceSAndroid Build Coastguard Worker     const tcu::Vec4 fbColor      = scaleColorValue(m_texFmt, tcu::Vec4(0.5f, 0.0f, 0.0f, 1.0f));
665*35238bceSAndroid Build Coastguard Worker 
666*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel reference = genReferenceTexture(fbColor, uniformColor);
667*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel result(getReadPixelFormat(m_texFmt), VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
668*35238bceSAndroid Build Coastguard Worker 
669*35238bceSAndroid Build Coastguard Worker     genFramebufferWithTexture(fbColor);
670*35238bceSAndroid Build Coastguard Worker     genUniformColor(uniformColor);
671*35238bceSAndroid Build Coastguard Worker     render();
672*35238bceSAndroid Build Coastguard Worker 
673*35238bceSAndroid Build Coastguard Worker     glu::readPixels(m_context.getRenderContext(), 0, 0, result.getAccess());
674*35238bceSAndroid Build Coastguard Worker     verifyRenderbuffer(m_testCtx.getLog(), m_texFmt, reference, result);
675*35238bceSAndroid Build Coastguard Worker 
676*35238bceSAndroid Build Coastguard Worker     return STOP;
677*35238bceSAndroid Build Coastguard Worker }
678*35238bceSAndroid Build Coastguard Worker 
679*35238bceSAndroid Build Coastguard Worker // Test description:
680*35238bceSAndroid Build Coastguard Worker // - Attach multiple textures containing solid colors to framebuffer.
681*35238bceSAndroid Build Coastguard Worker // - Draw full quad covering the entire viewport.
682*35238bceSAndroid Build Coastguard Worker // - For each render target sum framebuffer read color with passed in uniform color.
683*35238bceSAndroid Build Coastguard Worker // - Compare resulting surfaces with references.
684*35238bceSAndroid Build Coastguard Worker 
685*35238bceSAndroid Build Coastguard Worker class MultipleRenderTargetsTestCase : public FramebufferFetchTestCase
686*35238bceSAndroid Build Coastguard Worker {
687*35238bceSAndroid Build Coastguard Worker public:
688*35238bceSAndroid Build Coastguard Worker     MultipleRenderTargetsTestCase(Context &context, const char *name, const char *desc, uint32_t format);
689*35238bceSAndroid Build Coastguard Worker     ~MultipleRenderTargetsTestCase(void);
690*35238bceSAndroid Build Coastguard Worker 
691*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void);
692*35238bceSAndroid Build Coastguard Worker     void deinit(void);
693*35238bceSAndroid Build Coastguard Worker 
694*35238bceSAndroid Build Coastguard Worker private:
695*35238bceSAndroid Build Coastguard Worker     void genFramebufferWithTextures(const vector<tcu::Vec4> &colors);
696*35238bceSAndroid Build Coastguard Worker     void genAttachmentTextures(const vector<tcu::Vec4> &colors);
697*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel genReferenceTexture(const tcu::Vec4 &fbColor, const tcu::Vec4 &uniformColor);
698*35238bceSAndroid Build Coastguard Worker     glu::ProgramSources genShaderSources(void);
699*35238bceSAndroid Build Coastguard Worker 
700*35238bceSAndroid Build Coastguard Worker     enum
701*35238bceSAndroid Build Coastguard Worker     {
702*35238bceSAndroid Build Coastguard Worker         MAX_COLOR_BUFFERS = 4
703*35238bceSAndroid Build Coastguard Worker     };
704*35238bceSAndroid Build Coastguard Worker 
705*35238bceSAndroid Build Coastguard Worker     GLuint m_texColorBuffers[MAX_COLOR_BUFFERS];
706*35238bceSAndroid Build Coastguard Worker     GLenum m_colorBuffers[MAX_COLOR_BUFFERS];
707*35238bceSAndroid Build Coastguard Worker };
708*35238bceSAndroid Build Coastguard Worker 
MultipleRenderTargetsTestCase(Context & context,const char * name,const char * desc,uint32_t format)709*35238bceSAndroid Build Coastguard Worker MultipleRenderTargetsTestCase::MultipleRenderTargetsTestCase(Context &context, const char *name, const char *desc,
710*35238bceSAndroid Build Coastguard Worker                                                              uint32_t format)
711*35238bceSAndroid Build Coastguard Worker     : FramebufferFetchTestCase(context, name, desc, format)
712*35238bceSAndroid Build Coastguard Worker     , m_texColorBuffers()
713*35238bceSAndroid Build Coastguard Worker {
714*35238bceSAndroid Build Coastguard Worker     m_colorBuffers[0] = GL_COLOR_ATTACHMENT0;
715*35238bceSAndroid Build Coastguard Worker     m_colorBuffers[1] = GL_COLOR_ATTACHMENT1;
716*35238bceSAndroid Build Coastguard Worker     m_colorBuffers[2] = GL_COLOR_ATTACHMENT2;
717*35238bceSAndroid Build Coastguard Worker     m_colorBuffers[3] = GL_COLOR_ATTACHMENT3;
718*35238bceSAndroid Build Coastguard Worker }
719*35238bceSAndroid Build Coastguard Worker 
~MultipleRenderTargetsTestCase(void)720*35238bceSAndroid Build Coastguard Worker MultipleRenderTargetsTestCase::~MultipleRenderTargetsTestCase(void)
721*35238bceSAndroid Build Coastguard Worker {
722*35238bceSAndroid Build Coastguard Worker     MultipleRenderTargetsTestCase::deinit();
723*35238bceSAndroid Build Coastguard Worker }
724*35238bceSAndroid Build Coastguard Worker 
deinit(void)725*35238bceSAndroid Build Coastguard Worker void MultipleRenderTargetsTestCase::deinit(void)
726*35238bceSAndroid Build Coastguard Worker {
727*35238bceSAndroid Build Coastguard Worker     // Clean up texture data
728*35238bceSAndroid Build Coastguard Worker     for (int i = 0; i < DE_LENGTH_OF_ARRAY(m_texColorBuffers); ++i)
729*35238bceSAndroid Build Coastguard Worker     {
730*35238bceSAndroid Build Coastguard Worker         if (m_texColorBuffers[i])
731*35238bceSAndroid Build Coastguard Worker             m_context.getRenderContext().getFunctions().deleteTextures(1, &m_texColorBuffers[i]);
732*35238bceSAndroid Build Coastguard Worker     }
733*35238bceSAndroid Build Coastguard Worker 
734*35238bceSAndroid Build Coastguard Worker     FramebufferFetchTestCase::deinit();
735*35238bceSAndroid Build Coastguard Worker }
736*35238bceSAndroid Build Coastguard Worker 
genFramebufferWithTextures(const vector<tcu::Vec4> & colors)737*35238bceSAndroid Build Coastguard Worker void MultipleRenderTargetsTestCase::genFramebufferWithTextures(const vector<tcu::Vec4> &colors)
738*35238bceSAndroid Build Coastguard Worker {
739*35238bceSAndroid Build Coastguard Worker     m_gl.genFramebuffers(1, &m_framebuffer);
740*35238bceSAndroid Build Coastguard Worker     m_gl.bindFramebuffer(GL_FRAMEBUFFER, m_framebuffer);
741*35238bceSAndroid Build Coastguard Worker 
742*35238bceSAndroid Build Coastguard Worker     genAttachmentTextures(colors);
743*35238bceSAndroid Build Coastguard Worker 
744*35238bceSAndroid Build Coastguard Worker     for (int i = 0; i < DE_LENGTH_OF_ARRAY(m_texColorBuffers); ++i)
745*35238bceSAndroid Build Coastguard Worker         m_gl.framebufferTexture2D(GL_FRAMEBUFFER, m_colorBuffers[i], GL_TEXTURE_2D, m_texColorBuffers[i], 0);
746*35238bceSAndroid Build Coastguard Worker 
747*35238bceSAndroid Build Coastguard Worker     TCU_CHECK(m_gl.checkFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);
748*35238bceSAndroid Build Coastguard Worker 
749*35238bceSAndroid Build Coastguard Worker     m_gl.drawBuffers((glw::GLsizei)MAX_COLOR_BUFFERS, &m_colorBuffers[0]);
750*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(m_gl.getError(), "genFramebufferWithTextures()");
751*35238bceSAndroid Build Coastguard Worker }
752*35238bceSAndroid Build Coastguard Worker 
genAttachmentTextures(const vector<tcu::Vec4> & colors)753*35238bceSAndroid Build Coastguard Worker void MultipleRenderTargetsTestCase::genAttachmentTextures(const vector<tcu::Vec4> &colors)
754*35238bceSAndroid Build Coastguard Worker {
755*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel data(glu::mapGLTransferFormat(m_transferFmt.format, m_transferFmt.dataType), VIEWPORT_WIDTH,
756*35238bceSAndroid Build Coastguard Worker                            VIEWPORT_HEIGHT, 1);
757*35238bceSAndroid Build Coastguard Worker 
758*35238bceSAndroid Build Coastguard Worker     m_gl.genTextures(MAX_COLOR_BUFFERS, m_texColorBuffers);
759*35238bceSAndroid Build Coastguard Worker 
760*35238bceSAndroid Build Coastguard Worker     for (int i = 0; i < DE_LENGTH_OF_ARRAY(m_texColorBuffers); ++i)
761*35238bceSAndroid Build Coastguard Worker     {
762*35238bceSAndroid Build Coastguard Worker         m_gl.bindTexture(GL_TEXTURE_2D, m_texColorBuffers[i]);
763*35238bceSAndroid Build Coastguard Worker 
764*35238bceSAndroid Build Coastguard Worker         m_gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
765*35238bceSAndroid Build Coastguard Worker         m_gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
766*35238bceSAndroid Build Coastguard Worker         m_gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
767*35238bceSAndroid Build Coastguard Worker         m_gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_isFilterable ? GL_LINEAR : GL_NEAREST);
768*35238bceSAndroid Build Coastguard Worker         m_gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, m_isFilterable ? GL_LINEAR : GL_NEAREST);
769*35238bceSAndroid Build Coastguard Worker 
770*35238bceSAndroid Build Coastguard Worker         clear(data.getAccess(), colors[i]);
771*35238bceSAndroid Build Coastguard Worker         m_gl.texImage2D(GL_TEXTURE_2D, 0, m_format, VIEWPORT_WIDTH, VIEWPORT_HEIGHT, 0, m_transferFmt.format,
772*35238bceSAndroid Build Coastguard Worker                         m_transferFmt.dataType, data.getAccess().getDataPtr());
773*35238bceSAndroid Build Coastguard Worker     }
774*35238bceSAndroid Build Coastguard Worker 
775*35238bceSAndroid Build Coastguard Worker     m_gl.bindTexture(GL_TEXTURE_2D, 0);
776*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(m_gl.getError(), "genAttachmentTextures()");
777*35238bceSAndroid Build Coastguard Worker }
778*35238bceSAndroid Build Coastguard Worker 
genReferenceTexture(const tcu::Vec4 & fbColor,const tcu::Vec4 & uniformColor)779*35238bceSAndroid Build Coastguard Worker tcu::TextureLevel MultipleRenderTargetsTestCase::genReferenceTexture(const tcu::Vec4 &fbColor,
780*35238bceSAndroid Build Coastguard Worker                                                                      const tcu::Vec4 &uniformColor)
781*35238bceSAndroid Build Coastguard Worker {
782*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel reference(glu::mapGLTransferFormat(m_transferFmt.format, m_transferFmt.dataType), VIEWPORT_WIDTH,
783*35238bceSAndroid Build Coastguard Worker                                 VIEWPORT_HEIGHT, 1);
784*35238bceSAndroid Build Coastguard Worker     tcu::clear(reference.getAccess(), fbColor + uniformColor);
785*35238bceSAndroid Build Coastguard Worker 
786*35238bceSAndroid Build Coastguard Worker     return reference;
787*35238bceSAndroid Build Coastguard Worker }
788*35238bceSAndroid Build Coastguard Worker 
genShaderSources(void)789*35238bceSAndroid Build Coastguard Worker glu::ProgramSources MultipleRenderTargetsTestCase::genShaderSources(void)
790*35238bceSAndroid Build Coastguard Worker {
791*35238bceSAndroid Build Coastguard Worker     const string vecType = getColorOutputType(m_texFmt);
792*35238bceSAndroid Build Coastguard Worker     std::ostringstream fragShaderSource;
793*35238bceSAndroid Build Coastguard Worker 
794*35238bceSAndroid Build Coastguard Worker     fragShaderSource << "#version 310 es\n"
795*35238bceSAndroid Build Coastguard Worker                      << "#extension GL_EXT_shader_framebuffer_fetch : require\n"
796*35238bceSAndroid Build Coastguard Worker                      << "layout(location = 0) inout highp " << vecType << " o_color0;\n"
797*35238bceSAndroid Build Coastguard Worker                      << "layout(location = 1) inout highp " << vecType << " o_color1;\n"
798*35238bceSAndroid Build Coastguard Worker                      << "layout(location = 2) inout highp " << vecType << " o_color2;\n"
799*35238bceSAndroid Build Coastguard Worker                      << "layout(location = 3) inout highp " << vecType << " o_color3;\n"
800*35238bceSAndroid Build Coastguard Worker                      << "uniform highp " << vecType << " u_color;\n"
801*35238bceSAndroid Build Coastguard Worker                      << "\n"
802*35238bceSAndroid Build Coastguard Worker                      << "void main (void)\n"
803*35238bceSAndroid Build Coastguard Worker                      << "{\n"
804*35238bceSAndroid Build Coastguard Worker                      << "    o_color0 += u_color;\n"
805*35238bceSAndroid Build Coastguard Worker                      << "    o_color1 += u_color;\n"
806*35238bceSAndroid Build Coastguard Worker                      << "    o_color2 += u_color;\n"
807*35238bceSAndroid Build Coastguard Worker                      << "    o_color3 += u_color;\n"
808*35238bceSAndroid Build Coastguard Worker                      << "}\n";
809*35238bceSAndroid Build Coastguard Worker 
810*35238bceSAndroid Build Coastguard Worker     return glu::makeVtxFragSources(genPassThroughVertSource(), fragShaderSource.str());
811*35238bceSAndroid Build Coastguard Worker }
812*35238bceSAndroid Build Coastguard Worker 
iterate(void)813*35238bceSAndroid Build Coastguard Worker MultipleRenderTargetsTestCase::IterateResult MultipleRenderTargetsTestCase::iterate(void)
814*35238bceSAndroid Build Coastguard Worker {
815*35238bceSAndroid Build Coastguard Worker     const tcu::Vec4 uniformColor = scaleColorValue(m_texFmt, tcu::Vec4(0.1f, 0.1f, 0.1f, 1.0f));
816*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel result(getReadPixelFormat(m_texFmt), VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
817*35238bceSAndroid Build Coastguard Worker 
818*35238bceSAndroid Build Coastguard Worker     vector<tcu::Vec4> colors;
819*35238bceSAndroid Build Coastguard Worker     colors.push_back(scaleColorValue(m_texFmt, tcu::Vec4(0.9f, 0.0f, 0.0f, 1.0f)));
820*35238bceSAndroid Build Coastguard Worker     colors.push_back(scaleColorValue(m_texFmt, tcu::Vec4(0.0f, 0.9f, 0.0f, 1.0f)));
821*35238bceSAndroid Build Coastguard Worker     colors.push_back(scaleColorValue(m_texFmt, tcu::Vec4(0.0f, 0.0f, 0.9f, 1.0f)));
822*35238bceSAndroid Build Coastguard Worker     colors.push_back(scaleColorValue(m_texFmt, tcu::Vec4(0.0f, 0.9f, 0.9f, 1.0f)));
823*35238bceSAndroid Build Coastguard Worker 
824*35238bceSAndroid Build Coastguard Worker     genFramebufferWithTextures(colors);
825*35238bceSAndroid Build Coastguard Worker     genUniformColor(uniformColor);
826*35238bceSAndroid Build Coastguard Worker     render();
827*35238bceSAndroid Build Coastguard Worker 
828*35238bceSAndroid Build Coastguard Worker     for (int i = 0; i < DE_LENGTH_OF_ARRAY(m_colorBuffers); ++i)
829*35238bceSAndroid Build Coastguard Worker     {
830*35238bceSAndroid Build Coastguard Worker         tcu::TextureLevel reference = genReferenceTexture(colors[i], uniformColor);
831*35238bceSAndroid Build Coastguard Worker 
832*35238bceSAndroid Build Coastguard Worker         m_gl.readBuffer(m_colorBuffers[i]);
833*35238bceSAndroid Build Coastguard Worker         glu::readPixels(m_context.getRenderContext(), 0, 0, result.getAccess());
834*35238bceSAndroid Build Coastguard Worker         verifyRenderbuffer(m_testCtx.getLog(), m_texFmt, reference, result);
835*35238bceSAndroid Build Coastguard Worker     }
836*35238bceSAndroid Build Coastguard Worker 
837*35238bceSAndroid Build Coastguard Worker     return STOP;
838*35238bceSAndroid Build Coastguard Worker }
839*35238bceSAndroid Build Coastguard Worker 
840*35238bceSAndroid Build Coastguard Worker // Test description:
841*35238bceSAndroid Build Coastguard Worker // - Same as TextureFormatTestCase except uses built-in fragment output of ES 2.0
842*35238bceSAndroid Build Coastguard Worker 
843*35238bceSAndroid Build Coastguard Worker class LastFragDataTestCase : public FramebufferFetchTestCase
844*35238bceSAndroid Build Coastguard Worker {
845*35238bceSAndroid Build Coastguard Worker public:
846*35238bceSAndroid Build Coastguard Worker     LastFragDataTestCase(Context &context, const char *name, const char *desc, uint32_t format);
~LastFragDataTestCase(void)847*35238bceSAndroid Build Coastguard Worker     ~LastFragDataTestCase(void)
848*35238bceSAndroid Build Coastguard Worker     {
849*35238bceSAndroid Build Coastguard Worker     }
850*35238bceSAndroid Build Coastguard Worker 
851*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void);
852*35238bceSAndroid Build Coastguard Worker 
853*35238bceSAndroid Build Coastguard Worker private:
854*35238bceSAndroid Build Coastguard Worker     glu::ProgramSources genShaderSources(void);
855*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel genReferenceTexture(const tcu::Vec4 &fbColor, const tcu::Vec4 &uniformColor);
856*35238bceSAndroid Build Coastguard Worker };
857*35238bceSAndroid Build Coastguard Worker 
LastFragDataTestCase(Context & context,const char * name,const char * desc,uint32_t format)858*35238bceSAndroid Build Coastguard Worker LastFragDataTestCase::LastFragDataTestCase(Context &context, const char *name, const char *desc, uint32_t format)
859*35238bceSAndroid Build Coastguard Worker     : FramebufferFetchTestCase(context, name, desc, format)
860*35238bceSAndroid Build Coastguard Worker {
861*35238bceSAndroid Build Coastguard Worker }
862*35238bceSAndroid Build Coastguard Worker 
genShaderSources(void)863*35238bceSAndroid Build Coastguard Worker glu::ProgramSources LastFragDataTestCase::genShaderSources(void)
864*35238bceSAndroid Build Coastguard Worker {
865*35238bceSAndroid Build Coastguard Worker     const string vecType = getColorOutputType(m_texFmt);
866*35238bceSAndroid Build Coastguard Worker     std::ostringstream vertShaderSource;
867*35238bceSAndroid Build Coastguard Worker     std::ostringstream fragShaderSource;
868*35238bceSAndroid Build Coastguard Worker 
869*35238bceSAndroid Build Coastguard Worker     vertShaderSource << "#version 100\n"
870*35238bceSAndroid Build Coastguard Worker                      << "attribute vec4 a_position;\n"
871*35238bceSAndroid Build Coastguard Worker                      << "\n"
872*35238bceSAndroid Build Coastguard Worker                      << "void main (void)\n"
873*35238bceSAndroid Build Coastguard Worker                      << "{\n"
874*35238bceSAndroid Build Coastguard Worker                      << "    gl_Position = a_position;\n"
875*35238bceSAndroid Build Coastguard Worker                      << "}\n";
876*35238bceSAndroid Build Coastguard Worker 
877*35238bceSAndroid Build Coastguard Worker     fragShaderSource << "#version 100\n"
878*35238bceSAndroid Build Coastguard Worker                      << "#extension GL_EXT_shader_framebuffer_fetch : require\n"
879*35238bceSAndroid Build Coastguard Worker                      << "uniform highp " << vecType << " u_color;\n"
880*35238bceSAndroid Build Coastguard Worker                      << "\n"
881*35238bceSAndroid Build Coastguard Worker                      << "void main (void)\n"
882*35238bceSAndroid Build Coastguard Worker                      << "{\n"
883*35238bceSAndroid Build Coastguard Worker                      << "    gl_FragColor = u_color + gl_LastFragData[0];\n"
884*35238bceSAndroid Build Coastguard Worker                      << "}\n";
885*35238bceSAndroid Build Coastguard Worker 
886*35238bceSAndroid Build Coastguard Worker     return glu::makeVtxFragSources(vertShaderSource.str(), fragShaderSource.str());
887*35238bceSAndroid Build Coastguard Worker }
888*35238bceSAndroid Build Coastguard Worker 
genReferenceTexture(const tcu::Vec4 & fbColor,const tcu::Vec4 & uniformColor)889*35238bceSAndroid Build Coastguard Worker tcu::TextureLevel LastFragDataTestCase::genReferenceTexture(const tcu::Vec4 &fbColor, const tcu::Vec4 &uniformColor)
890*35238bceSAndroid Build Coastguard Worker {
891*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel reference(glu::mapGLTransferFormat(m_transferFmt.format, m_transferFmt.dataType), VIEWPORT_WIDTH,
892*35238bceSAndroid Build Coastguard Worker                                 VIEWPORT_HEIGHT, 1);
893*35238bceSAndroid Build Coastguard Worker     tcu::clear(reference.getAccess(), fbColor + uniformColor);
894*35238bceSAndroid Build Coastguard Worker 
895*35238bceSAndroid Build Coastguard Worker     return reference;
896*35238bceSAndroid Build Coastguard Worker }
897*35238bceSAndroid Build Coastguard Worker 
iterate(void)898*35238bceSAndroid Build Coastguard Worker LastFragDataTestCase::IterateResult LastFragDataTestCase::iterate(void)
899*35238bceSAndroid Build Coastguard Worker {
900*35238bceSAndroid Build Coastguard Worker     const tcu::Vec4 uniformColor = scaleColorValue(m_texFmt, tcu::Vec4(0.1f, 0.1f, 0.1f, 1.0f));
901*35238bceSAndroid Build Coastguard Worker     const tcu::Vec4 fbColor      = scaleColorValue(m_texFmt, tcu::Vec4(0.5f, 0.0f, 0.0f, 1.0f));
902*35238bceSAndroid Build Coastguard Worker 
903*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel reference = genReferenceTexture(fbColor, uniformColor);
904*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel result(getReadPixelFormat(m_texFmt), VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
905*35238bceSAndroid Build Coastguard Worker 
906*35238bceSAndroid Build Coastguard Worker     genFramebufferWithTexture(fbColor);
907*35238bceSAndroid Build Coastguard Worker     genUniformColor(uniformColor);
908*35238bceSAndroid Build Coastguard Worker     render();
909*35238bceSAndroid Build Coastguard Worker 
910*35238bceSAndroid Build Coastguard Worker     glu::readPixels(m_context.getRenderContext(), 0, 0, result.getAccess());
911*35238bceSAndroid Build Coastguard Worker     verifyRenderbuffer(m_testCtx.getLog(), m_texFmt, reference, result);
912*35238bceSAndroid Build Coastguard Worker 
913*35238bceSAndroid Build Coastguard Worker     return STOP;
914*35238bceSAndroid Build Coastguard Worker }
915*35238bceSAndroid Build Coastguard Worker 
916*35238bceSAndroid Build Coastguard Worker // Test description:
917*35238bceSAndroid Build Coastguard Worker // - Attach texture containing solid color to framebuffer.
918*35238bceSAndroid Build Coastguard Worker // - Create one 2D texture for sampler with a grid pattern
919*35238bceSAndroid Build Coastguard Worker // - Draw full screen quad covering the entire viewport.
920*35238bceSAndroid Build Coastguard Worker // - Sum color values taken from framebuffer texture and sampled texture
921*35238bceSAndroid Build Coastguard Worker // - Compare resulting surface with reference.
922*35238bceSAndroid Build Coastguard Worker 
923*35238bceSAndroid Build Coastguard Worker class TexelFetchTestCase : public FramebufferFetchTestCase
924*35238bceSAndroid Build Coastguard Worker {
925*35238bceSAndroid Build Coastguard Worker public:
926*35238bceSAndroid Build Coastguard Worker     TexelFetchTestCase(Context &context, const char *name, const char *desc, uint32_t format);
~TexelFetchTestCase(void)927*35238bceSAndroid Build Coastguard Worker     ~TexelFetchTestCase(void)
928*35238bceSAndroid Build Coastguard Worker     {
929*35238bceSAndroid Build Coastguard Worker     }
930*35238bceSAndroid Build Coastguard Worker 
931*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void);
932*35238bceSAndroid Build Coastguard Worker 
933*35238bceSAndroid Build Coastguard Worker private:
934*35238bceSAndroid Build Coastguard Worker     glu::ProgramSources genShaderSources(void);
935*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel genReferenceTexture(const tcu::Vec4 &colorEven, const tcu::Vec4 &colorOdd,
936*35238bceSAndroid Build Coastguard Worker                                           const tcu::Vec4 &fbColor);
937*35238bceSAndroid Build Coastguard Worker     void genSamplerTexture(const tcu::Vec4 &colorEven, const tcu::Vec4 &colorOdd);
938*35238bceSAndroid Build Coastguard Worker 
939*35238bceSAndroid Build Coastguard Worker     GLuint m_samplerTexture;
940*35238bceSAndroid Build Coastguard Worker };
941*35238bceSAndroid Build Coastguard Worker 
TexelFetchTestCase(Context & context,const char * name,const char * desc,uint32_t format)942*35238bceSAndroid Build Coastguard Worker TexelFetchTestCase::TexelFetchTestCase(Context &context, const char *name, const char *desc, uint32_t format)
943*35238bceSAndroid Build Coastguard Worker     : FramebufferFetchTestCase(context, name, desc, format)
944*35238bceSAndroid Build Coastguard Worker     , m_samplerTexture(0)
945*35238bceSAndroid Build Coastguard Worker {
946*35238bceSAndroid Build Coastguard Worker }
947*35238bceSAndroid Build Coastguard Worker 
genSamplerTexture(const tcu::Vec4 & colorEven,const tcu::Vec4 & colorOdd)948*35238bceSAndroid Build Coastguard Worker void TexelFetchTestCase::genSamplerTexture(const tcu::Vec4 &colorEven, const tcu::Vec4 &colorOdd)
949*35238bceSAndroid Build Coastguard Worker {
950*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel data(glu::mapGLTransferFormat(m_transferFmt.format, m_transferFmt.dataType), VIEWPORT_WIDTH,
951*35238bceSAndroid Build Coastguard Worker                            VIEWPORT_HEIGHT, 1);
952*35238bceSAndroid Build Coastguard Worker 
953*35238bceSAndroid Build Coastguard Worker     m_gl.activeTexture(GL_TEXTURE1);
954*35238bceSAndroid Build Coastguard Worker 
955*35238bceSAndroid Build Coastguard Worker     m_gl.genTextures(1, &m_samplerTexture);
956*35238bceSAndroid Build Coastguard Worker     m_gl.bindTexture(GL_TEXTURE_2D, m_texColorBuffer);
957*35238bceSAndroid Build Coastguard Worker     m_gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
958*35238bceSAndroid Build Coastguard Worker     m_gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
959*35238bceSAndroid Build Coastguard Worker 
960*35238bceSAndroid Build Coastguard Worker     tcu::fillWithGrid(data.getAccess(), 8, colorEven, colorOdd);
961*35238bceSAndroid Build Coastguard Worker 
962*35238bceSAndroid Build Coastguard Worker     m_gl.texImage2D(GL_TEXTURE_2D, 0, m_format, VIEWPORT_WIDTH, VIEWPORT_HEIGHT, 0, m_transferFmt.format,
963*35238bceSAndroid Build Coastguard Worker                     m_transferFmt.dataType, data.getAccess().getDataPtr());
964*35238bceSAndroid Build Coastguard Worker     m_gl.bindTexture(GL_TEXTURE_2D, 0);
965*35238bceSAndroid Build Coastguard Worker 
966*35238bceSAndroid Build Coastguard Worker     const GLuint samplerLocation = m_gl.getUniformLocation(m_program->getProgram(), "u_sampler");
967*35238bceSAndroid Build Coastguard Worker     m_gl.uniform1i(samplerLocation, 1);
968*35238bceSAndroid Build Coastguard Worker 
969*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(m_gl.getError(), "genSamplerTexture()");
970*35238bceSAndroid Build Coastguard Worker }
971*35238bceSAndroid Build Coastguard Worker 
genShaderSources(void)972*35238bceSAndroid Build Coastguard Worker glu::ProgramSources TexelFetchTestCase::genShaderSources(void)
973*35238bceSAndroid Build Coastguard Worker {
974*35238bceSAndroid Build Coastguard Worker     const string vecType = getColorOutputType(m_texFmt);
975*35238bceSAndroid Build Coastguard Worker     std::ostringstream fragShaderSource;
976*35238bceSAndroid Build Coastguard Worker 
977*35238bceSAndroid Build Coastguard Worker     fragShaderSource << "#version 310 es\n"
978*35238bceSAndroid Build Coastguard Worker                      << "#extension GL_EXT_shader_framebuffer_fetch : require\n"
979*35238bceSAndroid Build Coastguard Worker                      << "layout(location = 0) inout highp " << vecType << " o_color;\n"
980*35238bceSAndroid Build Coastguard Worker                      << "\n"
981*35238bceSAndroid Build Coastguard Worker                      << "uniform sampler2D u_sampler;\n"
982*35238bceSAndroid Build Coastguard Worker                      << "void main (void)\n"
983*35238bceSAndroid Build Coastguard Worker                      << "{\n"
984*35238bceSAndroid Build Coastguard Worker                      << "    o_color += texelFetch(u_sampler, ivec2(gl_FragCoord), 0);\n"
985*35238bceSAndroid Build Coastguard Worker                      << "}\n";
986*35238bceSAndroid Build Coastguard Worker 
987*35238bceSAndroid Build Coastguard Worker     return glu::makeVtxFragSources(genPassThroughVertSource(), fragShaderSource.str());
988*35238bceSAndroid Build Coastguard Worker }
989*35238bceSAndroid Build Coastguard Worker 
genReferenceTexture(const tcu::Vec4 & colorEven,const tcu::Vec4 & colorOdd,const tcu::Vec4 & fbColor)990*35238bceSAndroid Build Coastguard Worker tcu::TextureLevel TexelFetchTestCase::genReferenceTexture(const tcu::Vec4 &colorEven, const tcu::Vec4 &colorOdd,
991*35238bceSAndroid Build Coastguard Worker                                                           const tcu::Vec4 &fbColor)
992*35238bceSAndroid Build Coastguard Worker {
993*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel reference(glu::mapGLTransferFormat(m_transferFmt.format, m_transferFmt.dataType), VIEWPORT_WIDTH,
994*35238bceSAndroid Build Coastguard Worker                                 VIEWPORT_HEIGHT, 1);
995*35238bceSAndroid Build Coastguard Worker     tcu::fillWithGrid(reference.getAccess(), 8, colorEven + fbColor, colorOdd + fbColor);
996*35238bceSAndroid Build Coastguard Worker 
997*35238bceSAndroid Build Coastguard Worker     return reference;
998*35238bceSAndroid Build Coastguard Worker }
999*35238bceSAndroid Build Coastguard Worker 
iterate(void)1000*35238bceSAndroid Build Coastguard Worker TexelFetchTestCase::IterateResult TexelFetchTestCase::iterate(void)
1001*35238bceSAndroid Build Coastguard Worker {
1002*35238bceSAndroid Build Coastguard Worker     const tcu::Vec4 fbColor   = scaleColorValue(m_texFmt, tcu::Vec4(0.5f, 0.0f, 0.5f, 1.0f));
1003*35238bceSAndroid Build Coastguard Worker     const tcu::Vec4 colorEven = scaleColorValue(m_texFmt, tcu::Vec4(0.5f, 0.5f, 0.0f, 1.0f));
1004*35238bceSAndroid Build Coastguard Worker     const tcu::Vec4 colorOdd  = scaleColorValue(m_texFmt, tcu::Vec4(0.5f, 0.0f, 0.5f, 1.0f));
1005*35238bceSAndroid Build Coastguard Worker 
1006*35238bceSAndroid Build Coastguard Worker     genSamplerTexture(colorEven, colorOdd);
1007*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel reference = genReferenceTexture(colorEven, colorOdd, fbColor);
1008*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel result(getReadPixelFormat(m_texFmt), VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
1009*35238bceSAndroid Build Coastguard Worker 
1010*35238bceSAndroid Build Coastguard Worker     genFramebufferWithTexture(fbColor);
1011*35238bceSAndroid Build Coastguard Worker     render();
1012*35238bceSAndroid Build Coastguard Worker 
1013*35238bceSAndroid Build Coastguard Worker     glu::readPixels(m_context.getRenderContext(), 0, 0, result.getAccess());
1014*35238bceSAndroid Build Coastguard Worker     verifyRenderbuffer(m_testCtx.getLog(), m_texFmt, reference, result);
1015*35238bceSAndroid Build Coastguard Worker 
1016*35238bceSAndroid Build Coastguard Worker     // cleanup
1017*35238bceSAndroid Build Coastguard Worker     m_gl.deleteTextures(1, &m_samplerTexture);
1018*35238bceSAndroid Build Coastguard Worker 
1019*35238bceSAndroid Build Coastguard Worker     return STOP;
1020*35238bceSAndroid Build Coastguard Worker }
1021*35238bceSAndroid Build Coastguard Worker 
1022*35238bceSAndroid Build Coastguard Worker // Test description:
1023*35238bceSAndroid Build Coastguard Worker // - Attach texture containing solid color to framebuffer.
1024*35238bceSAndroid Build Coastguard Worker // - Draw full screen quad covering the entire viewport.
1025*35238bceSAndroid Build Coastguard Worker // - Multiple assignments are made to the output color for fragments on the right vertical half of the screen.
1026*35238bceSAndroid Build Coastguard Worker // - A single assignment is made to the output color for fragments on the left vertical centre of the screen.
1027*35238bceSAndroid Build Coastguard Worker // - Values are calculated using the sum of the passed in uniform color and the previous framebuffer color.
1028*35238bceSAndroid Build Coastguard Worker // - Compare resulting surface with reference.
1029*35238bceSAndroid Build Coastguard Worker 
1030*35238bceSAndroid Build Coastguard Worker class MultipleAssignmentTestCase : public FramebufferFetchTestCase
1031*35238bceSAndroid Build Coastguard Worker {
1032*35238bceSAndroid Build Coastguard Worker public:
1033*35238bceSAndroid Build Coastguard Worker     MultipleAssignmentTestCase(Context &context, const char *name, const char *desc, uint32_t format);
~MultipleAssignmentTestCase(void)1034*35238bceSAndroid Build Coastguard Worker     ~MultipleAssignmentTestCase(void)
1035*35238bceSAndroid Build Coastguard Worker     {
1036*35238bceSAndroid Build Coastguard Worker     }
1037*35238bceSAndroid Build Coastguard Worker 
1038*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void);
1039*35238bceSAndroid Build Coastguard Worker 
1040*35238bceSAndroid Build Coastguard Worker private:
1041*35238bceSAndroid Build Coastguard Worker     glu::ProgramSources genShaderSources(void);
1042*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel genReferenceTexture(const tcu::Vec4 &fbColor, const tcu::Vec4 &uniformColor);
1043*35238bceSAndroid Build Coastguard Worker };
1044*35238bceSAndroid Build Coastguard Worker 
MultipleAssignmentTestCase(Context & context,const char * name,const char * desc,uint32_t format)1045*35238bceSAndroid Build Coastguard Worker MultipleAssignmentTestCase::MultipleAssignmentTestCase(Context &context, const char *name, const char *desc,
1046*35238bceSAndroid Build Coastguard Worker                                                        uint32_t format)
1047*35238bceSAndroid Build Coastguard Worker     : FramebufferFetchTestCase(context, name, desc, format)
1048*35238bceSAndroid Build Coastguard Worker {
1049*35238bceSAndroid Build Coastguard Worker }
1050*35238bceSAndroid Build Coastguard Worker 
genShaderSources(void)1051*35238bceSAndroid Build Coastguard Worker glu::ProgramSources MultipleAssignmentTestCase::genShaderSources(void)
1052*35238bceSAndroid Build Coastguard Worker {
1053*35238bceSAndroid Build Coastguard Worker     const string vecType = getColorOutputType(m_texFmt);
1054*35238bceSAndroid Build Coastguard Worker     std::ostringstream vertShaderSource;
1055*35238bceSAndroid Build Coastguard Worker     std::ostringstream fragShaderSource;
1056*35238bceSAndroid Build Coastguard Worker 
1057*35238bceSAndroid Build Coastguard Worker     vertShaderSource << "#version 310 es\n"
1058*35238bceSAndroid Build Coastguard Worker                      << "in highp vec4 a_position;\n"
1059*35238bceSAndroid Build Coastguard Worker                      << "out highp vec4 v_position;\n"
1060*35238bceSAndroid Build Coastguard Worker                      << "\n"
1061*35238bceSAndroid Build Coastguard Worker                      << "void main (void)\n"
1062*35238bceSAndroid Build Coastguard Worker                      << "{\n"
1063*35238bceSAndroid Build Coastguard Worker                      << "    gl_Position = a_position;\n"
1064*35238bceSAndroid Build Coastguard Worker                      << "    v_position  = gl_Position;\n"
1065*35238bceSAndroid Build Coastguard Worker                      << "}\n";
1066*35238bceSAndroid Build Coastguard Worker 
1067*35238bceSAndroid Build Coastguard Worker     fragShaderSource << "#version 310 es\n"
1068*35238bceSAndroid Build Coastguard Worker                      << "#extension GL_EXT_shader_framebuffer_fetch : require\n"
1069*35238bceSAndroid Build Coastguard Worker                      << "in highp vec4 v_position;\n"
1070*35238bceSAndroid Build Coastguard Worker                      << "layout(location = 0) inout highp " << vecType << " o_color;\n"
1071*35238bceSAndroid Build Coastguard Worker                      << "uniform highp " << vecType << " u_color;\n"
1072*35238bceSAndroid Build Coastguard Worker                      << "\n"
1073*35238bceSAndroid Build Coastguard Worker                      << "void main (void)\n"
1074*35238bceSAndroid Build Coastguard Worker                      << "{\n"
1075*35238bceSAndroid Build Coastguard Worker                      << "    if (v_position.x > 0.0f)\n"
1076*35238bceSAndroid Build Coastguard Worker                      << "        o_color += u_color;\n"
1077*35238bceSAndroid Build Coastguard Worker                      << "\n"
1078*35238bceSAndroid Build Coastguard Worker                      << "    o_color += u_color;\n"
1079*35238bceSAndroid Build Coastguard Worker                      << "}\n";
1080*35238bceSAndroid Build Coastguard Worker 
1081*35238bceSAndroid Build Coastguard Worker     return glu::makeVtxFragSources(vertShaderSource.str(), fragShaderSource.str());
1082*35238bceSAndroid Build Coastguard Worker }
1083*35238bceSAndroid Build Coastguard Worker 
genReferenceTexture(const tcu::Vec4 & fbColor,const tcu::Vec4 & uniformColor)1084*35238bceSAndroid Build Coastguard Worker tcu::TextureLevel MultipleAssignmentTestCase::genReferenceTexture(const tcu::Vec4 &fbColor,
1085*35238bceSAndroid Build Coastguard Worker                                                                   const tcu::Vec4 &uniformColor)
1086*35238bceSAndroid Build Coastguard Worker {
1087*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel reference(glu::mapGLTransferFormat(m_transferFmt.format, m_transferFmt.dataType), VIEWPORT_WIDTH,
1088*35238bceSAndroid Build Coastguard Worker                                 VIEWPORT_HEIGHT, 1);
1089*35238bceSAndroid Build Coastguard Worker 
1090*35238bceSAndroid Build Coastguard Worker     int width  = reference.getAccess().getWidth();
1091*35238bceSAndroid Build Coastguard Worker     int height = reference.getAccess().getHeight();
1092*35238bceSAndroid Build Coastguard Worker     int left   = width / 2;
1093*35238bceSAndroid Build Coastguard Worker     int top    = height / 2;
1094*35238bceSAndroid Build Coastguard Worker 
1095*35238bceSAndroid Build Coastguard Worker     tcu::Vec4 compositeColor(uniformColor * 2.0f);
1096*35238bceSAndroid Build Coastguard Worker 
1097*35238bceSAndroid Build Coastguard Worker     tcu::clear(getSubregion(reference.getAccess(), left, 0, 0, width - left, top, 1), fbColor + compositeColor);
1098*35238bceSAndroid Build Coastguard Worker     tcu::clear(getSubregion(reference.getAccess(), 0, top, 0, left, height - top, 1), fbColor + uniformColor);
1099*35238bceSAndroid Build Coastguard Worker     tcu::clear(getSubregion(reference.getAccess(), left, top, 0, width - left, height - top, 1),
1100*35238bceSAndroid Build Coastguard Worker                fbColor + compositeColor);
1101*35238bceSAndroid Build Coastguard Worker     tcu::clear(getSubregion(reference.getAccess(), 0, 0, 0, left, top, 1), fbColor + uniformColor);
1102*35238bceSAndroid Build Coastguard Worker 
1103*35238bceSAndroid Build Coastguard Worker     return reference;
1104*35238bceSAndroid Build Coastguard Worker }
1105*35238bceSAndroid Build Coastguard Worker 
iterate(void)1106*35238bceSAndroid Build Coastguard Worker MultipleAssignmentTestCase::IterateResult MultipleAssignmentTestCase::iterate(void)
1107*35238bceSAndroid Build Coastguard Worker {
1108*35238bceSAndroid Build Coastguard Worker     const tcu::Vec4 fbColor      = scaleColorValue(m_texFmt, tcu::Vec4(0.5f, 0.0f, 0.0f, 1.0f));
1109*35238bceSAndroid Build Coastguard Worker     const tcu::Vec4 uniformColor = scaleColorValue(m_texFmt, tcu::Vec4(0.25f, 0.0f, 0.0f, 1.0f));
1110*35238bceSAndroid Build Coastguard Worker 
1111*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel reference = genReferenceTexture(fbColor, uniformColor);
1112*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel result(getReadPixelFormat(m_texFmt), VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
1113*35238bceSAndroid Build Coastguard Worker 
1114*35238bceSAndroid Build Coastguard Worker     genFramebufferWithTexture(fbColor);
1115*35238bceSAndroid Build Coastguard Worker     genUniformColor(uniformColor);
1116*35238bceSAndroid Build Coastguard Worker     render();
1117*35238bceSAndroid Build Coastguard Worker 
1118*35238bceSAndroid Build Coastguard Worker     glu::readPixels(m_context.getRenderContext(), 0, 0, result.getAccess());
1119*35238bceSAndroid Build Coastguard Worker     verifyRenderbuffer(m_testCtx.getLog(), m_texFmt, reference, result);
1120*35238bceSAndroid Build Coastguard Worker 
1121*35238bceSAndroid Build Coastguard Worker     return STOP;
1122*35238bceSAndroid Build Coastguard Worker }
1123*35238bceSAndroid Build Coastguard Worker 
1124*35238bceSAndroid Build Coastguard Worker // Test description:
1125*35238bceSAndroid Build Coastguard Worker // - Attach texture containing grid pattern to framebuffer.
1126*35238bceSAndroid Build Coastguard Worker // - Using framebuffer reads discard odd squares in the grid.
1127*35238bceSAndroid Build Coastguard Worker // - The even squares framebuffer color is added to the passed in uniform color.
1128*35238bceSAndroid Build Coastguard Worker 
1129*35238bceSAndroid Build Coastguard Worker class FragmentDiscardTestCase : public FramebufferFetchTestCase
1130*35238bceSAndroid Build Coastguard Worker {
1131*35238bceSAndroid Build Coastguard Worker public:
1132*35238bceSAndroid Build Coastguard Worker     FragmentDiscardTestCase(Context &context, const char *name, const char *desc, uint32_t format);
~FragmentDiscardTestCase(void)1133*35238bceSAndroid Build Coastguard Worker     ~FragmentDiscardTestCase(void)
1134*35238bceSAndroid Build Coastguard Worker     {
1135*35238bceSAndroid Build Coastguard Worker     }
1136*35238bceSAndroid Build Coastguard Worker 
1137*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void);
1138*35238bceSAndroid Build Coastguard Worker 
1139*35238bceSAndroid Build Coastguard Worker private:
1140*35238bceSAndroid Build Coastguard Worker     glu::ProgramSources genShaderSources(void);
1141*35238bceSAndroid Build Coastguard Worker     void genFramebufferWithGrid(const tcu::Vec4 &fbColorEven, const tcu::Vec4 &fbColorOdd);
1142*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel genReferenceTexture(const tcu::Vec4 &fbColorEven, const tcu::Vec4 &fbColorOdd);
1143*35238bceSAndroid Build Coastguard Worker };
1144*35238bceSAndroid Build Coastguard Worker 
FragmentDiscardTestCase(Context & context,const char * name,const char * desc,uint32_t format)1145*35238bceSAndroid Build Coastguard Worker FragmentDiscardTestCase::FragmentDiscardTestCase(Context &context, const char *name, const char *desc, uint32_t format)
1146*35238bceSAndroid Build Coastguard Worker     : FramebufferFetchTestCase(context, name, desc, format)
1147*35238bceSAndroid Build Coastguard Worker {
1148*35238bceSAndroid Build Coastguard Worker }
1149*35238bceSAndroid Build Coastguard Worker 
genShaderSources(void)1150*35238bceSAndroid Build Coastguard Worker glu::ProgramSources FragmentDiscardTestCase::genShaderSources(void)
1151*35238bceSAndroid Build Coastguard Worker {
1152*35238bceSAndroid Build Coastguard Worker     const string vecType = getColorOutputType(m_texFmt);
1153*35238bceSAndroid Build Coastguard Worker     std::ostringstream fragShaderSource;
1154*35238bceSAndroid Build Coastguard Worker 
1155*35238bceSAndroid Build Coastguard Worker     fragShaderSource << "#version 310 es\n"
1156*35238bceSAndroid Build Coastguard Worker                      << "#extension GL_EXT_shader_framebuffer_fetch : require\n"
1157*35238bceSAndroid Build Coastguard Worker                      << "layout(location = 0) inout highp " << vecType << " o_color;\n"
1158*35238bceSAndroid Build Coastguard Worker                      << "uniform highp " << vecType << " u_color;\n"
1159*35238bceSAndroid Build Coastguard Worker                      << "\n"
1160*35238bceSAndroid Build Coastguard Worker                      << "void main (void)\n"
1161*35238bceSAndroid Build Coastguard Worker                      << "{\n"
1162*35238bceSAndroid Build Coastguard Worker                      << "    const highp float threshold = 0.0005f;\n"
1163*35238bceSAndroid Build Coastguard Worker                      << "    bool valuesEqual = all(lessThan(abs(o_color - u_color), vec4(threshold)));\n\n"
1164*35238bceSAndroid Build Coastguard Worker                      << "    if (valuesEqual)\n"
1165*35238bceSAndroid Build Coastguard Worker                      << "        o_color += u_color;\n"
1166*35238bceSAndroid Build Coastguard Worker                      << "    else\n"
1167*35238bceSAndroid Build Coastguard Worker                      << "        discard;\n"
1168*35238bceSAndroid Build Coastguard Worker                      << "}\n";
1169*35238bceSAndroid Build Coastguard Worker 
1170*35238bceSAndroid Build Coastguard Worker     return glu::makeVtxFragSources(genPassThroughVertSource(), fragShaderSource.str());
1171*35238bceSAndroid Build Coastguard Worker }
1172*35238bceSAndroid Build Coastguard Worker 
genFramebufferWithGrid(const tcu::Vec4 & fbColorEven,const tcu::Vec4 & fbColorOdd)1173*35238bceSAndroid Build Coastguard Worker void FragmentDiscardTestCase::genFramebufferWithGrid(const tcu::Vec4 &fbColorEven, const tcu::Vec4 &fbColorOdd)
1174*35238bceSAndroid Build Coastguard Worker {
1175*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel data(glu::mapGLTransferFormat(m_transferFmt.format, m_transferFmt.dataType), VIEWPORT_WIDTH,
1176*35238bceSAndroid Build Coastguard Worker                            VIEWPORT_HEIGHT, 1);
1177*35238bceSAndroid Build Coastguard Worker 
1178*35238bceSAndroid Build Coastguard Worker     m_gl.genFramebuffers(1, &m_framebuffer);
1179*35238bceSAndroid Build Coastguard Worker     m_gl.bindFramebuffer(GL_FRAMEBUFFER, m_framebuffer);
1180*35238bceSAndroid Build Coastguard Worker 
1181*35238bceSAndroid Build Coastguard Worker     m_gl.genTextures(1, &m_texColorBuffer);
1182*35238bceSAndroid Build Coastguard Worker     m_gl.bindTexture(GL_TEXTURE_2D, m_texColorBuffer);
1183*35238bceSAndroid Build Coastguard Worker 
1184*35238bceSAndroid Build Coastguard Worker     tcu::fillWithGrid(data.getAccess(), 8, fbColorEven, fbColorOdd);
1185*35238bceSAndroid Build Coastguard Worker 
1186*35238bceSAndroid Build Coastguard Worker     m_gl.texImage2D(GL_TEXTURE_2D, 0, m_format, VIEWPORT_WIDTH, VIEWPORT_HEIGHT, 0, m_transferFmt.format,
1187*35238bceSAndroid Build Coastguard Worker                     m_transferFmt.dataType, data.getAccess().getDataPtr());
1188*35238bceSAndroid Build Coastguard Worker     m_gl.bindTexture(GL_TEXTURE_2D, 0);
1189*35238bceSAndroid Build Coastguard Worker 
1190*35238bceSAndroid Build Coastguard Worker     m_gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_texColorBuffer, 0);
1191*35238bceSAndroid Build Coastguard Worker     TCU_CHECK(m_gl.checkFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);
1192*35238bceSAndroid Build Coastguard Worker }
1193*35238bceSAndroid Build Coastguard Worker 
genReferenceTexture(const tcu::Vec4 & fbColorEven,const tcu::Vec4 & fbColorOdd)1194*35238bceSAndroid Build Coastguard Worker tcu::TextureLevel FragmentDiscardTestCase::genReferenceTexture(const tcu::Vec4 &fbColorEven,
1195*35238bceSAndroid Build Coastguard Worker                                                                const tcu::Vec4 &fbColorOdd)
1196*35238bceSAndroid Build Coastguard Worker {
1197*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel reference(glu::mapGLTransferFormat(m_transferFmt.format, m_transferFmt.dataType), VIEWPORT_WIDTH,
1198*35238bceSAndroid Build Coastguard Worker                                 VIEWPORT_HEIGHT, 1);
1199*35238bceSAndroid Build Coastguard Worker     tcu::fillWithGrid(reference.getAccess(), 8, fbColorEven + fbColorEven, fbColorOdd);
1200*35238bceSAndroid Build Coastguard Worker 
1201*35238bceSAndroid Build Coastguard Worker     return reference;
1202*35238bceSAndroid Build Coastguard Worker }
1203*35238bceSAndroid Build Coastguard Worker 
iterate(void)1204*35238bceSAndroid Build Coastguard Worker FragmentDiscardTestCase::IterateResult FragmentDiscardTestCase::iterate(void)
1205*35238bceSAndroid Build Coastguard Worker {
1206*35238bceSAndroid Build Coastguard Worker     const tcu::Vec4 fbColorEven = scaleColorValue(m_texFmt, tcu::Vec4(0.5f, 0.0f, 1.0f, 1.0f));
1207*35238bceSAndroid Build Coastguard Worker     const tcu::Vec4 fbColorOdd  = scaleColorValue(m_texFmt, tcu::Vec4(0.0f, 1.0f, 1.0f, 1.0f));
1208*35238bceSAndroid Build Coastguard Worker 
1209*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel reference = genReferenceTexture(fbColorEven, fbColorOdd);
1210*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel result(getReadPixelFormat(m_texFmt), VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
1211*35238bceSAndroid Build Coastguard Worker     genFramebufferWithGrid(fbColorEven, fbColorOdd);
1212*35238bceSAndroid Build Coastguard Worker 
1213*35238bceSAndroid Build Coastguard Worker     genUniformColor(fbColorEven);
1214*35238bceSAndroid Build Coastguard Worker     render();
1215*35238bceSAndroid Build Coastguard Worker 
1216*35238bceSAndroid Build Coastguard Worker     glu::readPixels(m_context.getRenderContext(), 0, 0, result.getAccess());
1217*35238bceSAndroid Build Coastguard Worker     verifyRenderbuffer(m_testCtx.getLog(), m_texFmt, reference, result);
1218*35238bceSAndroid Build Coastguard Worker 
1219*35238bceSAndroid Build Coastguard Worker     return STOP;
1220*35238bceSAndroid Build Coastguard Worker }
1221*35238bceSAndroid Build Coastguard Worker 
1222*35238bceSAndroid Build Coastguard Worker // Test description:
1223*35238bceSAndroid Build Coastguard Worker // - Create 2D texture array containing three mipmaps.
1224*35238bceSAndroid Build Coastguard Worker // - Each mipmap level is assigned a different color.
1225*35238bceSAndroid Build Coastguard Worker // - Attach single mipmap level to framebuffer and draw full screen quad.
1226*35238bceSAndroid Build Coastguard Worker // - Sum framebuffer read color with passed in uniform color.
1227*35238bceSAndroid Build Coastguard Worker // - Compare resulting surface with reference.
1228*35238bceSAndroid Build Coastguard Worker // - Repeat for subsequent mipmap levels.
1229*35238bceSAndroid Build Coastguard Worker 
1230*35238bceSAndroid Build Coastguard Worker class TextureLevelTestCase : public FramebufferFetchTestCase
1231*35238bceSAndroid Build Coastguard Worker {
1232*35238bceSAndroid Build Coastguard Worker public:
1233*35238bceSAndroid Build Coastguard Worker     TextureLevelTestCase(Context &context, const char *name, const char *desc, uint32_t format);
~TextureLevelTestCase(void)1234*35238bceSAndroid Build Coastguard Worker     ~TextureLevelTestCase(void)
1235*35238bceSAndroid Build Coastguard Worker     {
1236*35238bceSAndroid Build Coastguard Worker     }
1237*35238bceSAndroid Build Coastguard Worker 
1238*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void);
1239*35238bceSAndroid Build Coastguard Worker 
1240*35238bceSAndroid Build Coastguard Worker private:
1241*35238bceSAndroid Build Coastguard Worker     void create2DTextureArrayMipMaps(const vector<tcu::Vec4> &colors);
1242*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel genReferenceTexture(int level, const vector<tcu::Vec4> &colors, const tcu::Vec4 &uniformColor);
1243*35238bceSAndroid Build Coastguard Worker     void genReferenceMipmap(const tcu::Vec4 &color, tcu::TextureLevel &reference);
1244*35238bceSAndroid Build Coastguard Worker };
1245*35238bceSAndroid Build Coastguard Worker 
TextureLevelTestCase(Context & context,const char * name,const char * desc,uint32_t format)1246*35238bceSAndroid Build Coastguard Worker TextureLevelTestCase::TextureLevelTestCase(Context &context, const char *name, const char *desc, uint32_t format)
1247*35238bceSAndroid Build Coastguard Worker     : FramebufferFetchTestCase(context, name, desc, format)
1248*35238bceSAndroid Build Coastguard Worker {
1249*35238bceSAndroid Build Coastguard Worker }
1250*35238bceSAndroid Build Coastguard Worker 
create2DTextureArrayMipMaps(const vector<tcu::Vec4> & colors)1251*35238bceSAndroid Build Coastguard Worker void TextureLevelTestCase::create2DTextureArrayMipMaps(const vector<tcu::Vec4> &colors)
1252*35238bceSAndroid Build Coastguard Worker {
1253*35238bceSAndroid Build Coastguard Worker     int numLevels = (int)colors.size();
1254*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel levelData(glu::mapGLTransferFormat(m_transferFmt.format, m_transferFmt.dataType));
1255*35238bceSAndroid Build Coastguard Worker 
1256*35238bceSAndroid Build Coastguard Worker     m_gl.genTextures(1, &m_texColorBuffer);
1257*35238bceSAndroid Build Coastguard Worker     m_gl.bindTexture(GL_TEXTURE_2D_ARRAY, m_texColorBuffer);
1258*35238bceSAndroid Build Coastguard Worker 
1259*35238bceSAndroid Build Coastguard Worker     m_gl.texImage3D(GL_TEXTURE_2D_ARRAY, 0, m_format, VIEWPORT_WIDTH, VIEWPORT_HEIGHT, 1, 0, m_transferFmt.format,
1260*35238bceSAndroid Build Coastguard Worker                     m_transferFmt.dataType, DE_NULL);
1261*35238bceSAndroid Build Coastguard Worker     m_gl.generateMipmap(GL_TEXTURE_2D_ARRAY);
1262*35238bceSAndroid Build Coastguard Worker 
1263*35238bceSAndroid Build Coastguard Worker     for (int level = 0; level < numLevels; level++)
1264*35238bceSAndroid Build Coastguard Worker     {
1265*35238bceSAndroid Build Coastguard Worker         int levelW = de::max(1, VIEWPORT_WIDTH >> level);
1266*35238bceSAndroid Build Coastguard Worker         int levelH = de::max(1, VIEWPORT_HEIGHT >> level);
1267*35238bceSAndroid Build Coastguard Worker 
1268*35238bceSAndroid Build Coastguard Worker         levelData.setSize(levelW, levelH, 1);
1269*35238bceSAndroid Build Coastguard Worker 
1270*35238bceSAndroid Build Coastguard Worker         clear(levelData.getAccess(), colors[level]);
1271*35238bceSAndroid Build Coastguard Worker         m_gl.texImage3D(GL_TEXTURE_2D_ARRAY, level, m_format, levelW, levelH, 1, 0, m_transferFmt.format,
1272*35238bceSAndroid Build Coastguard Worker                         m_transferFmt.dataType, levelData.getAccess().getDataPtr());
1273*35238bceSAndroid Build Coastguard Worker     }
1274*35238bceSAndroid Build Coastguard Worker 
1275*35238bceSAndroid Build Coastguard Worker     m_gl.bindTexture(GL_TEXTURE_2D_ARRAY, 0);
1276*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(m_gl.getError(), "create2DTextureArrayMipMaps()");
1277*35238bceSAndroid Build Coastguard Worker }
1278*35238bceSAndroid Build Coastguard Worker 
genReferenceTexture(int level,const vector<tcu::Vec4> & colors,const tcu::Vec4 & uniformColor)1279*35238bceSAndroid Build Coastguard Worker tcu::TextureLevel TextureLevelTestCase::genReferenceTexture(int level, const vector<tcu::Vec4> &colors,
1280*35238bceSAndroid Build Coastguard Worker                                                             const tcu::Vec4 &uniformColor)
1281*35238bceSAndroid Build Coastguard Worker {
1282*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel reference(glu::mapGLTransferFormat(m_transferFmt.format, m_transferFmt.dataType),
1283*35238bceSAndroid Build Coastguard Worker                                 VIEWPORT_WIDTH >> level, VIEWPORT_HEIGHT >> level, 1);
1284*35238bceSAndroid Build Coastguard Worker 
1285*35238bceSAndroid Build Coastguard Worker     genReferenceMipmap(colors[level] + uniformColor, reference);
1286*35238bceSAndroid Build Coastguard Worker 
1287*35238bceSAndroid Build Coastguard Worker     return reference;
1288*35238bceSAndroid Build Coastguard Worker }
1289*35238bceSAndroid Build Coastguard Worker 
genReferenceMipmap(const tcu::Vec4 & color,tcu::TextureLevel & reference)1290*35238bceSAndroid Build Coastguard Worker void TextureLevelTestCase::genReferenceMipmap(const tcu::Vec4 &color, tcu::TextureLevel &reference)
1291*35238bceSAndroid Build Coastguard Worker {
1292*35238bceSAndroid Build Coastguard Worker     const int width  = reference.getAccess().getWidth();
1293*35238bceSAndroid Build Coastguard Worker     const int height = reference.getAccess().getHeight();
1294*35238bceSAndroid Build Coastguard Worker     const int left   = width / 2;
1295*35238bceSAndroid Build Coastguard Worker     const int top    = height / 2;
1296*35238bceSAndroid Build Coastguard Worker 
1297*35238bceSAndroid Build Coastguard Worker     clear(getSubregion(reference.getAccess(), left, 0, 0, width - left, top, 1), color);
1298*35238bceSAndroid Build Coastguard Worker     clear(getSubregion(reference.getAccess(), 0, top, 0, left, height - top, 1), color);
1299*35238bceSAndroid Build Coastguard Worker     clear(getSubregion(reference.getAccess(), left, top, 0, width - left, height - top, 1), color);
1300*35238bceSAndroid Build Coastguard Worker     clear(getSubregion(reference.getAccess(), 0, 0, 0, left, top, 1), color);
1301*35238bceSAndroid Build Coastguard Worker }
1302*35238bceSAndroid Build Coastguard Worker 
iterate(void)1303*35238bceSAndroid Build Coastguard Worker TextureLevelTestCase::IterateResult TextureLevelTestCase::iterate(void)
1304*35238bceSAndroid Build Coastguard Worker {
1305*35238bceSAndroid Build Coastguard Worker     const tcu::Vec4 uniformColor = scaleColorValue(m_texFmt, tcu::Vec4(0.1f, 0.0f, 0.0f, 1.0f));
1306*35238bceSAndroid Build Coastguard Worker     vector<tcu::Vec4> levelColors;
1307*35238bceSAndroid Build Coastguard Worker 
1308*35238bceSAndroid Build Coastguard Worker     levelColors.push_back(scaleColorValue(m_texFmt, tcu::Vec4(0.4f, 0.0f, 0.0f, 1.0f)));
1309*35238bceSAndroid Build Coastguard Worker     levelColors.push_back(scaleColorValue(m_texFmt, tcu::Vec4(0.2f, 0.0f, 0.0f, 1.0f)));
1310*35238bceSAndroid Build Coastguard Worker     levelColors.push_back(scaleColorValue(m_texFmt, tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f)));
1311*35238bceSAndroid Build Coastguard Worker 
1312*35238bceSAndroid Build Coastguard Worker     m_gl.genFramebuffers(1, &m_framebuffer);
1313*35238bceSAndroid Build Coastguard Worker     m_gl.bindFramebuffer(GL_FRAMEBUFFER, m_framebuffer);
1314*35238bceSAndroid Build Coastguard Worker 
1315*35238bceSAndroid Build Coastguard Worker     create2DTextureArrayMipMaps(levelColors);
1316*35238bceSAndroid Build Coastguard Worker 
1317*35238bceSAndroid Build Coastguard Worker     // attach successive mipmap layers to framebuffer and render
1318*35238bceSAndroid Build Coastguard Worker     for (int level = 0; level < (int)levelColors.size(); ++level)
1319*35238bceSAndroid Build Coastguard Worker     {
1320*35238bceSAndroid Build Coastguard Worker         std::ostringstream name, desc;
1321*35238bceSAndroid Build Coastguard Worker         name << "Level " << level;
1322*35238bceSAndroid Build Coastguard Worker         desc << "Mipmap level " << level;
1323*35238bceSAndroid Build Coastguard Worker 
1324*35238bceSAndroid Build Coastguard Worker         const tcu::ScopedLogSection section(m_testCtx.getLog(), name.str(), desc.str());
1325*35238bceSAndroid Build Coastguard Worker         tcu::TextureLevel result(getReadPixelFormat(m_texFmt), VIEWPORT_WIDTH >> level, VIEWPORT_HEIGHT >> level);
1326*35238bceSAndroid Build Coastguard Worker         tcu::TextureLevel reference = genReferenceTexture(level, levelColors, uniformColor);
1327*35238bceSAndroid Build Coastguard Worker 
1328*35238bceSAndroid Build Coastguard Worker         m_gl.framebufferTextureLayer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_texColorBuffer, level, 0);
1329*35238bceSAndroid Build Coastguard Worker 
1330*35238bceSAndroid Build Coastguard Worker         genUniformColor(uniformColor);
1331*35238bceSAndroid Build Coastguard Worker         render();
1332*35238bceSAndroid Build Coastguard Worker 
1333*35238bceSAndroid Build Coastguard Worker         glu::readPixels(m_context.getRenderContext(), 0, 0, result.getAccess());
1334*35238bceSAndroid Build Coastguard Worker         verifyRenderbuffer(m_testCtx.getLog(), m_texFmt, reference, result);
1335*35238bceSAndroid Build Coastguard Worker 
1336*35238bceSAndroid Build Coastguard Worker         if (m_testCtx.getTestResult() != QP_TEST_RESULT_PASS)
1337*35238bceSAndroid Build Coastguard Worker             return STOP;
1338*35238bceSAndroid Build Coastguard Worker     }
1339*35238bceSAndroid Build Coastguard Worker 
1340*35238bceSAndroid Build Coastguard Worker     return STOP;
1341*35238bceSAndroid Build Coastguard Worker }
1342*35238bceSAndroid Build Coastguard Worker 
1343*35238bceSAndroid Build Coastguard Worker class TextureLayerTestCase : public FramebufferFetchTestCase
1344*35238bceSAndroid Build Coastguard Worker {
1345*35238bceSAndroid Build Coastguard Worker public:
1346*35238bceSAndroid Build Coastguard Worker     TextureLayerTestCase(Context &context, const char *name, const char *desc, uint32_t format);
~TextureLayerTestCase(void)1347*35238bceSAndroid Build Coastguard Worker     ~TextureLayerTestCase(void)
1348*35238bceSAndroid Build Coastguard Worker     {
1349*35238bceSAndroid Build Coastguard Worker     }
1350*35238bceSAndroid Build Coastguard Worker 
1351*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void);
1352*35238bceSAndroid Build Coastguard Worker 
1353*35238bceSAndroid Build Coastguard Worker private:
1354*35238bceSAndroid Build Coastguard Worker     void create2DTextureArrayLayers(const vector<tcu::Vec4> &colors);
1355*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel genReferenceTexture(int layer, const vector<tcu::Vec4> &colors, const tcu::Vec4 &uniformColor);
1356*35238bceSAndroid Build Coastguard Worker };
1357*35238bceSAndroid Build Coastguard Worker 
TextureLayerTestCase(Context & context,const char * name,const char * desc,uint32_t format)1358*35238bceSAndroid Build Coastguard Worker TextureLayerTestCase::TextureLayerTestCase(Context &context, const char *name, const char *desc, uint32_t format)
1359*35238bceSAndroid Build Coastguard Worker     : FramebufferFetchTestCase(context, name, desc, format)
1360*35238bceSAndroid Build Coastguard Worker {
1361*35238bceSAndroid Build Coastguard Worker }
1362*35238bceSAndroid Build Coastguard Worker 
create2DTextureArrayLayers(const vector<tcu::Vec4> & colors)1363*35238bceSAndroid Build Coastguard Worker void TextureLayerTestCase::create2DTextureArrayLayers(const vector<tcu::Vec4> &colors)
1364*35238bceSAndroid Build Coastguard Worker {
1365*35238bceSAndroid Build Coastguard Worker     int numLayers = (int)colors.size();
1366*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel layerData(glu::mapGLTransferFormat(m_transferFmt.format, m_transferFmt.dataType));
1367*35238bceSAndroid Build Coastguard Worker 
1368*35238bceSAndroid Build Coastguard Worker     m_gl.genTextures(1, &m_texColorBuffer);
1369*35238bceSAndroid Build Coastguard Worker     m_gl.bindTexture(GL_TEXTURE_2D_ARRAY, m_texColorBuffer);
1370*35238bceSAndroid Build Coastguard Worker     m_gl.texStorage3D(GL_TEXTURE_2D_ARRAY, 1, m_format, VIEWPORT_WIDTH, VIEWPORT_HEIGHT, numLayers);
1371*35238bceSAndroid Build Coastguard Worker     m_gl.bindImageTexture(0, m_texColorBuffer, 0, GL_FALSE, 0, GL_READ_ONLY, m_format);
1372*35238bceSAndroid Build Coastguard Worker 
1373*35238bceSAndroid Build Coastguard Worker     layerData.setSize(VIEWPORT_WIDTH, VIEWPORT_HEIGHT, numLayers);
1374*35238bceSAndroid Build Coastguard Worker 
1375*35238bceSAndroid Build Coastguard Worker     for (int layer = 0; layer < numLayers; layer++)
1376*35238bceSAndroid Build Coastguard Worker     {
1377*35238bceSAndroid Build Coastguard Worker         clear(layerData.getAccess(), colors[layer]);
1378*35238bceSAndroid Build Coastguard Worker         m_gl.texSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, layer, VIEWPORT_WIDTH, VIEWPORT_HEIGHT, 1,
1379*35238bceSAndroid Build Coastguard Worker                            m_transferFmt.format, m_transferFmt.dataType, layerData.getAccess().getDataPtr());
1380*35238bceSAndroid Build Coastguard Worker     }
1381*35238bceSAndroid Build Coastguard Worker 
1382*35238bceSAndroid Build Coastguard Worker     m_gl.bindTexture(GL_TEXTURE_2D_ARRAY, 0);
1383*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(m_gl.getError(), "create2DTextureArrayLayers()");
1384*35238bceSAndroid Build Coastguard Worker }
1385*35238bceSAndroid Build Coastguard Worker 
genReferenceTexture(int layer,const vector<tcu::Vec4> & colors,const tcu::Vec4 & uniformColor)1386*35238bceSAndroid Build Coastguard Worker tcu::TextureLevel TextureLayerTestCase::genReferenceTexture(int layer, const vector<tcu::Vec4> &colors,
1387*35238bceSAndroid Build Coastguard Worker                                                             const tcu::Vec4 &uniformColor)
1388*35238bceSAndroid Build Coastguard Worker {
1389*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel reference(glu::mapGLTransferFormat(m_transferFmt.format, m_transferFmt.dataType), VIEWPORT_WIDTH,
1390*35238bceSAndroid Build Coastguard Worker                                 VIEWPORT_HEIGHT, 1);
1391*35238bceSAndroid Build Coastguard Worker     clear(reference.getAccess(), colors[layer] + uniformColor);
1392*35238bceSAndroid Build Coastguard Worker 
1393*35238bceSAndroid Build Coastguard Worker     return reference;
1394*35238bceSAndroid Build Coastguard Worker }
1395*35238bceSAndroid Build Coastguard Worker 
1396*35238bceSAndroid Build Coastguard Worker // Test description
1397*35238bceSAndroid Build Coastguard Worker // - Create 2D texture array containing three layers.
1398*35238bceSAndroid Build Coastguard Worker // - Each layer is assigned a different color.
1399*35238bceSAndroid Build Coastguard Worker // - Attach single layer to framebuffer and draw full screen quad.
1400*35238bceSAndroid Build Coastguard Worker // - Sum framebuffer read color with passed in uniform color.
1401*35238bceSAndroid Build Coastguard Worker // - Compare resulting surface with reference.
1402*35238bceSAndroid Build Coastguard Worker // - Repeat for subsequent texture layers.
1403*35238bceSAndroid Build Coastguard Worker 
iterate(void)1404*35238bceSAndroid Build Coastguard Worker TextureLayerTestCase::IterateResult TextureLayerTestCase::iterate(void)
1405*35238bceSAndroid Build Coastguard Worker {
1406*35238bceSAndroid Build Coastguard Worker     const tcu::Vec4 uniformColor = scaleColorValue(m_texFmt, tcu::Vec4(0.1f, 0.1f, 0.1f, 1.0f));
1407*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel result(getReadPixelFormat(m_texFmt), VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
1408*35238bceSAndroid Build Coastguard Worker     vector<tcu::Vec4> layerColors;
1409*35238bceSAndroid Build Coastguard Worker 
1410*35238bceSAndroid Build Coastguard Worker     layerColors.push_back(scaleColorValue(m_texFmt, tcu::Vec4(0.4f, 0.0f, 0.0f, 1.0f)));
1411*35238bceSAndroid Build Coastguard Worker     layerColors.push_back(scaleColorValue(m_texFmt, tcu::Vec4(0.2f, 0.0f, 0.0f, 1.0f)));
1412*35238bceSAndroid Build Coastguard Worker     layerColors.push_back(scaleColorValue(m_texFmt, tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f)));
1413*35238bceSAndroid Build Coastguard Worker 
1414*35238bceSAndroid Build Coastguard Worker     m_gl.genFramebuffers(1, &m_framebuffer);
1415*35238bceSAndroid Build Coastguard Worker     m_gl.bindFramebuffer(GL_FRAMEBUFFER, m_framebuffer);
1416*35238bceSAndroid Build Coastguard Worker 
1417*35238bceSAndroid Build Coastguard Worker     create2DTextureArrayLayers(layerColors);
1418*35238bceSAndroid Build Coastguard Worker 
1419*35238bceSAndroid Build Coastguard Worker     for (int layer = 0; layer < (int)layerColors.size(); ++layer)
1420*35238bceSAndroid Build Coastguard Worker     {
1421*35238bceSAndroid Build Coastguard Worker         std::ostringstream name, desc;
1422*35238bceSAndroid Build Coastguard Worker         name << "Layer " << layer;
1423*35238bceSAndroid Build Coastguard Worker         desc << "Layer " << layer;
1424*35238bceSAndroid Build Coastguard Worker 
1425*35238bceSAndroid Build Coastguard Worker         const tcu::ScopedLogSection section(m_testCtx.getLog(), name.str(), desc.str());
1426*35238bceSAndroid Build Coastguard Worker         tcu::TextureLevel reference = genReferenceTexture(layer, layerColors, uniformColor);
1427*35238bceSAndroid Build Coastguard Worker 
1428*35238bceSAndroid Build Coastguard Worker         m_gl.framebufferTextureLayer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_texColorBuffer, 0, layer);
1429*35238bceSAndroid Build Coastguard Worker 
1430*35238bceSAndroid Build Coastguard Worker         genUniformColor(uniformColor);
1431*35238bceSAndroid Build Coastguard Worker         render();
1432*35238bceSAndroid Build Coastguard Worker 
1433*35238bceSAndroid Build Coastguard Worker         glu::readPixels(m_context.getRenderContext(), 0, 0, result.getAccess());
1434*35238bceSAndroid Build Coastguard Worker         verifyRenderbuffer(m_testCtx.getLog(), m_texFmt, reference, result);
1435*35238bceSAndroid Build Coastguard Worker 
1436*35238bceSAndroid Build Coastguard Worker         if (m_testCtx.getTestResult() != QP_TEST_RESULT_PASS)
1437*35238bceSAndroid Build Coastguard Worker             return STOP;
1438*35238bceSAndroid Build Coastguard Worker     }
1439*35238bceSAndroid Build Coastguard Worker 
1440*35238bceSAndroid Build Coastguard Worker     return STOP;
1441*35238bceSAndroid Build Coastguard Worker }
1442*35238bceSAndroid Build Coastguard Worker 
1443*35238bceSAndroid Build Coastguard Worker } // namespace
1444*35238bceSAndroid Build Coastguard Worker 
ShaderFramebufferFetchTests(Context & context)1445*35238bceSAndroid Build Coastguard Worker ShaderFramebufferFetchTests::ShaderFramebufferFetchTests(Context &context)
1446*35238bceSAndroid Build Coastguard Worker     : TestCaseGroup(context, "framebuffer_fetch", "GL_EXT_shader_framebuffer_fetch tests")
1447*35238bceSAndroid Build Coastguard Worker {
1448*35238bceSAndroid Build Coastguard Worker }
1449*35238bceSAndroid Build Coastguard Worker 
~ShaderFramebufferFetchTests(void)1450*35238bceSAndroid Build Coastguard Worker ShaderFramebufferFetchTests::~ShaderFramebufferFetchTests(void)
1451*35238bceSAndroid Build Coastguard Worker {
1452*35238bceSAndroid Build Coastguard Worker }
1453*35238bceSAndroid Build Coastguard Worker 
init(void)1454*35238bceSAndroid Build Coastguard Worker void ShaderFramebufferFetchTests::init(void)
1455*35238bceSAndroid Build Coastguard Worker {
1456*35238bceSAndroid Build Coastguard Worker     tcu::TestCaseGroup *const basicTestGroup =
1457*35238bceSAndroid Build Coastguard Worker         new tcu::TestCaseGroup(m_testCtx, "basic", "Basic framebuffer shader fetch tests");
1458*35238bceSAndroid Build Coastguard Worker     tcu::TestCaseGroup *const framebufferFormatTestGroup =
1459*35238bceSAndroid Build Coastguard Worker         new tcu::TestCaseGroup(m_testCtx, "framebuffer_format", "Texture render target formats tests");
1460*35238bceSAndroid Build Coastguard Worker 
1461*35238bceSAndroid Build Coastguard Worker     // basic
1462*35238bceSAndroid Build Coastguard Worker     {
1463*35238bceSAndroid Build Coastguard Worker         basicTestGroup->addChild(new TexelFetchTestCase(
1464*35238bceSAndroid Build Coastguard Worker             m_context, "texel_fetch", "Framebuffer fetches in conjunction with shader texel fetches", GL_RGBA8));
1465*35238bceSAndroid Build Coastguard Worker         basicTestGroup->addChild(new LastFragDataTestCase(
1466*35238bceSAndroid Build Coastguard Worker             m_context, "last_frag_data", "Framebuffer fetches with built-in fragment output of ES 2.0", GL_RGBA8));
1467*35238bceSAndroid Build Coastguard Worker         basicTestGroup->addChild(new FragmentDiscardTestCase(
1468*35238bceSAndroid Build Coastguard Worker             m_context, "fragment_discard", "Framebuffer fetches in combination with fragment discards", GL_RGBA8));
1469*35238bceSAndroid Build Coastguard Worker         basicTestGroup->addChild(new MultipleAssignmentTestCase(
1470*35238bceSAndroid Build Coastguard Worker             m_context, "multiple_assignment", "Multiple assignments to fragment color inout", GL_RGBA8));
1471*35238bceSAndroid Build Coastguard Worker         basicTestGroup->addChild(new MultipleRenderTargetsTestCase(
1472*35238bceSAndroid Build Coastguard Worker             m_context, "multiple_render_targets",
1473*35238bceSAndroid Build Coastguard Worker             "Framebuffer fetches used in combination with multiple render targets", GL_RGBA8));
1474*35238bceSAndroid Build Coastguard Worker         basicTestGroup->addChild(
1475*35238bceSAndroid Build Coastguard Worker             new TextureLevelTestCase(m_context, "framebuffer_texture_level",
1476*35238bceSAndroid Build Coastguard Worker                                      "Framebuffer fetches with individual texture render target mipmaps", GL_RGBA8));
1477*35238bceSAndroid Build Coastguard Worker         basicTestGroup->addChild(
1478*35238bceSAndroid Build Coastguard Worker             new TextureLayerTestCase(m_context, "framebuffer_texture_layer",
1479*35238bceSAndroid Build Coastguard Worker                                      "Framebuffer fetches with individual texture render target layers", GL_RGBA8));
1480*35238bceSAndroid Build Coastguard Worker     }
1481*35238bceSAndroid Build Coastguard Worker 
1482*35238bceSAndroid Build Coastguard Worker     // framebuffer formats
1483*35238bceSAndroid Build Coastguard Worker     {
1484*35238bceSAndroid Build Coastguard Worker         static const uint32_t colorFormats[] = {
1485*35238bceSAndroid Build Coastguard Worker             // RGBA formats
1486*35238bceSAndroid Build Coastguard Worker             GL_RGBA32I, GL_RGBA32UI, GL_RGBA16I, GL_RGBA16UI, GL_RGBA8, GL_RGBA8I, GL_RGBA8UI, GL_SRGB8_ALPHA8,
1487*35238bceSAndroid Build Coastguard Worker             GL_RGB10_A2, GL_RGB10_A2UI, GL_RGBA4, GL_RGB5_A1,
1488*35238bceSAndroid Build Coastguard Worker 
1489*35238bceSAndroid Build Coastguard Worker             // RGB formats
1490*35238bceSAndroid Build Coastguard Worker             GL_RGB8, GL_RGB565,
1491*35238bceSAndroid Build Coastguard Worker 
1492*35238bceSAndroid Build Coastguard Worker             // RG formats
1493*35238bceSAndroid Build Coastguard Worker             GL_RG32I, GL_RG32UI, GL_RG16I, GL_RG16UI, GL_RG8, GL_RG8I, GL_RG8UI,
1494*35238bceSAndroid Build Coastguard Worker 
1495*35238bceSAndroid Build Coastguard Worker             // R formats
1496*35238bceSAndroid Build Coastguard Worker             GL_R32I, GL_R32UI, GL_R16I, GL_R16UI, GL_R8, GL_R8I, GL_R8UI,
1497*35238bceSAndroid Build Coastguard Worker 
1498*35238bceSAndroid Build Coastguard Worker             // GL_EXT_color_buffer_float
1499*35238bceSAndroid Build Coastguard Worker             GL_RGBA32F, GL_RGBA16F, GL_R11F_G11F_B10F, GL_RG32F, GL_RG16F, GL_R32F, GL_R16F,
1500*35238bceSAndroid Build Coastguard Worker 
1501*35238bceSAndroid Build Coastguard Worker             // GL_EXT_color_buffer_half_float
1502*35238bceSAndroid Build Coastguard Worker             GL_RGB16F};
1503*35238bceSAndroid Build Coastguard Worker 
1504*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(colorFormats); ndx++)
1505*35238bceSAndroid Build Coastguard Worker             framebufferFormatTestGroup->addChild(new TextureFormatTestCase(
1506*35238bceSAndroid Build Coastguard Worker                 m_context, getFormatName(colorFormats[ndx]),
1507*35238bceSAndroid Build Coastguard Worker                 "Framebuffer fetches from texture attachments with varying formats", colorFormats[ndx]));
1508*35238bceSAndroid Build Coastguard Worker     }
1509*35238bceSAndroid Build Coastguard Worker 
1510*35238bceSAndroid Build Coastguard Worker     addChild(basicTestGroup);
1511*35238bceSAndroid Build Coastguard Worker     addChild(framebufferFormatTestGroup);
1512*35238bceSAndroid Build Coastguard Worker }
1513*35238bceSAndroid Build Coastguard Worker 
1514*35238bceSAndroid Build Coastguard Worker } // namespace Functional
1515*35238bceSAndroid Build Coastguard Worker } // namespace gles31
1516*35238bceSAndroid Build Coastguard Worker } // namespace deqp
1517