xref: /aosp_15_r20/external/deqp/modules/gles3/functional/es3fBlendTests.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker  * drawElements Quality Program OpenGL ES 3.0 Module
3*35238bceSAndroid Build Coastguard Worker  * -------------------------------------------------
4*35238bceSAndroid Build Coastguard Worker  *
5*35238bceSAndroid Build Coastguard Worker  * Copyright 2014 The Android Open Source Project
6*35238bceSAndroid Build Coastguard Worker  *
7*35238bceSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
8*35238bceSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
9*35238bceSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
10*35238bceSAndroid Build Coastguard Worker  *
11*35238bceSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
12*35238bceSAndroid Build Coastguard Worker  *
13*35238bceSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
14*35238bceSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
15*35238bceSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16*35238bceSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
17*35238bceSAndroid Build Coastguard Worker  * limitations under the License.
18*35238bceSAndroid Build Coastguard Worker  *
19*35238bceSAndroid Build Coastguard Worker  *//*!
20*35238bceSAndroid Build Coastguard Worker  * \file
21*35238bceSAndroid Build Coastguard Worker  * \brief Blend tests.
22*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker 
24*35238bceSAndroid Build Coastguard Worker #include "es3fBlendTests.hpp"
25*35238bceSAndroid Build Coastguard Worker #include "gluStrUtil.hpp"
26*35238bceSAndroid Build Coastguard Worker #include "glsFragmentOpUtil.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "gluPixelTransfer.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "tcuPixelFormat.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "tcuTexture.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "tcuTextureUtil.hpp"
31*35238bceSAndroid Build Coastguard Worker #include "tcuImageCompare.hpp"
32*35238bceSAndroid Build Coastguard Worker #include "tcuRenderTarget.hpp"
33*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
34*35238bceSAndroid Build Coastguard Worker #include "deRandom.hpp"
35*35238bceSAndroid Build Coastguard Worker #include "rrFragmentOperations.hpp"
36*35238bceSAndroid Build Coastguard Worker #include "sglrReferenceUtils.hpp"
37*35238bceSAndroid Build Coastguard Worker 
38*35238bceSAndroid Build Coastguard Worker #include <string>
39*35238bceSAndroid Build Coastguard Worker #include <vector>
40*35238bceSAndroid Build Coastguard Worker 
41*35238bceSAndroid Build Coastguard Worker #include "glw.h"
42*35238bceSAndroid Build Coastguard Worker 
43*35238bceSAndroid Build Coastguard Worker namespace deqp
44*35238bceSAndroid Build Coastguard Worker {
45*35238bceSAndroid Build Coastguard Worker 
46*35238bceSAndroid Build Coastguard Worker using gls::FragmentOpUtil::IntegerQuad;
47*35238bceSAndroid Build Coastguard Worker using gls::FragmentOpUtil::Quad;
48*35238bceSAndroid Build Coastguard Worker using gls::FragmentOpUtil::QuadRenderer;
49*35238bceSAndroid Build Coastguard Worker using gls::FragmentOpUtil::ReferenceQuadRenderer;
50*35238bceSAndroid Build Coastguard Worker using glu::getBlendEquationName;
51*35238bceSAndroid Build Coastguard Worker using glu::getBlendFactorName;
52*35238bceSAndroid Build Coastguard Worker using std::string;
53*35238bceSAndroid Build Coastguard Worker using std::vector;
54*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
55*35238bceSAndroid Build Coastguard Worker using tcu::TextureFormat;
56*35238bceSAndroid Build Coastguard Worker using tcu::TextureLevel;
57*35238bceSAndroid Build Coastguard Worker using tcu::UVec4;
58*35238bceSAndroid Build Coastguard Worker using tcu::Vec4;
59*35238bceSAndroid Build Coastguard Worker 
60*35238bceSAndroid Build Coastguard Worker namespace gles3
61*35238bceSAndroid Build Coastguard Worker {
62*35238bceSAndroid Build Coastguard Worker namespace Functional
63*35238bceSAndroid Build Coastguard Worker {
64*35238bceSAndroid Build Coastguard Worker 
65*35238bceSAndroid Build Coastguard Worker static const int MAX_VIEWPORT_WIDTH  = 64;
66*35238bceSAndroid Build Coastguard Worker static const int MAX_VIEWPORT_HEIGHT = 64;
67*35238bceSAndroid Build Coastguard Worker 
68*35238bceSAndroid Build Coastguard Worker // \note src and dst can point to same memory as long as there is 1-to-1 correspondence between
69*35238bceSAndroid Build Coastguard Worker //         pixels.
sRGBAToLinear(const tcu::PixelBufferAccess & dst,const tcu::ConstPixelBufferAccess & src)70*35238bceSAndroid Build Coastguard Worker static void sRGBAToLinear(const tcu::PixelBufferAccess &dst, const tcu::ConstPixelBufferAccess &src)
71*35238bceSAndroid Build Coastguard Worker {
72*35238bceSAndroid Build Coastguard Worker     const int width  = src.getWidth();
73*35238bceSAndroid Build Coastguard Worker     const int height = src.getHeight();
74*35238bceSAndroid Build Coastguard Worker 
75*35238bceSAndroid Build Coastguard Worker     for (int y = 0; y < height; y++)
76*35238bceSAndroid Build Coastguard Worker         for (int x = 0; x < width; x++)
77*35238bceSAndroid Build Coastguard Worker             dst.setPixel(tcu::sRGBToLinear(src.getPixel(x, y)), x, y);
78*35238bceSAndroid Build Coastguard Worker }
79*35238bceSAndroid Build Coastguard Worker 
80*35238bceSAndroid Build Coastguard Worker struct BlendParams
81*35238bceSAndroid Build Coastguard Worker {
82*35238bceSAndroid Build Coastguard Worker     GLenum equationRGB;
83*35238bceSAndroid Build Coastguard Worker     GLenum srcFuncRGB;
84*35238bceSAndroid Build Coastguard Worker     GLenum dstFuncRGB;
85*35238bceSAndroid Build Coastguard Worker     GLenum equationAlpha;
86*35238bceSAndroid Build Coastguard Worker     GLenum srcFuncAlpha;
87*35238bceSAndroid Build Coastguard Worker     GLenum dstFuncAlpha;
88*35238bceSAndroid Build Coastguard Worker     Vec4 blendColor;
89*35238bceSAndroid Build Coastguard Worker 
BlendParamsdeqp::gles3::Functional::BlendParams90*35238bceSAndroid Build Coastguard Worker     BlendParams(GLenum equationRGB_, GLenum srcFuncRGB_, GLenum dstFuncRGB_, GLenum equationAlpha_,
91*35238bceSAndroid Build Coastguard Worker                 GLenum srcFuncAlpha_, GLenum dstFuncAlpha_, Vec4 blendColor_)
92*35238bceSAndroid Build Coastguard Worker         : equationRGB(equationRGB_)
93*35238bceSAndroid Build Coastguard Worker         , srcFuncRGB(srcFuncRGB_)
94*35238bceSAndroid Build Coastguard Worker         , dstFuncRGB(dstFuncRGB_)
95*35238bceSAndroid Build Coastguard Worker         , equationAlpha(equationAlpha_)
96*35238bceSAndroid Build Coastguard Worker         , srcFuncAlpha(srcFuncAlpha_)
97*35238bceSAndroid Build Coastguard Worker         , dstFuncAlpha(dstFuncAlpha_)
98*35238bceSAndroid Build Coastguard Worker         , blendColor(blendColor_)
99*35238bceSAndroid Build Coastguard Worker     {
100*35238bceSAndroid Build Coastguard Worker     }
101*35238bceSAndroid Build Coastguard Worker };
102*35238bceSAndroid Build Coastguard Worker 
103*35238bceSAndroid Build Coastguard Worker class BlendCase : public TestCase
104*35238bceSAndroid Build Coastguard Worker {
105*35238bceSAndroid Build Coastguard Worker public:
106*35238bceSAndroid Build Coastguard Worker     BlendCase(Context &context, const char *name, const char *desc, const vector<BlendParams> &paramSets,
107*35238bceSAndroid Build Coastguard Worker               bool useSrgbFbo);
108*35238bceSAndroid Build Coastguard Worker 
109*35238bceSAndroid Build Coastguard Worker     ~BlendCase(void);
110*35238bceSAndroid Build Coastguard Worker 
111*35238bceSAndroid Build Coastguard Worker     void init(void);
112*35238bceSAndroid Build Coastguard Worker     void deinit(void);
113*35238bceSAndroid Build Coastguard Worker 
114*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void);
115*35238bceSAndroid Build Coastguard Worker 
116*35238bceSAndroid Build Coastguard Worker private:
117*35238bceSAndroid Build Coastguard Worker     BlendCase(const BlendCase &other);
118*35238bceSAndroid Build Coastguard Worker     BlendCase &operator=(const BlendCase &other);
119*35238bceSAndroid Build Coastguard Worker 
120*35238bceSAndroid Build Coastguard Worker     vector<BlendParams> m_paramSets;
121*35238bceSAndroid Build Coastguard Worker     int m_curParamSetNdx;
122*35238bceSAndroid Build Coastguard Worker 
123*35238bceSAndroid Build Coastguard Worker     bool m_useSrgbFbo;
124*35238bceSAndroid Build Coastguard Worker     uint32_t m_colorRbo;
125*35238bceSAndroid Build Coastguard Worker     uint32_t m_fbo;
126*35238bceSAndroid Build Coastguard Worker 
127*35238bceSAndroid Build Coastguard Worker     QuadRenderer *m_renderer;
128*35238bceSAndroid Build Coastguard Worker     ReferenceQuadRenderer *m_referenceRenderer;
129*35238bceSAndroid Build Coastguard Worker     TextureLevel *m_refColorBuffer;
130*35238bceSAndroid Build Coastguard Worker     Quad m_firstQuad;
131*35238bceSAndroid Build Coastguard Worker     Quad m_secondQuad;
132*35238bceSAndroid Build Coastguard Worker     IntegerQuad m_firstQuadInt;
133*35238bceSAndroid Build Coastguard Worker     IntegerQuad m_secondQuadInt;
134*35238bceSAndroid Build Coastguard Worker 
135*35238bceSAndroid Build Coastguard Worker     int m_renderWidth;
136*35238bceSAndroid Build Coastguard Worker     int m_renderHeight;
137*35238bceSAndroid Build Coastguard Worker     int m_viewportWidth;
138*35238bceSAndroid Build Coastguard Worker     int m_viewportHeight;
139*35238bceSAndroid Build Coastguard Worker };
140*35238bceSAndroid Build Coastguard Worker 
BlendCase(Context & context,const char * name,const char * desc,const vector<BlendParams> & paramSets,bool useSrgbFbo)141*35238bceSAndroid Build Coastguard Worker BlendCase::BlendCase(Context &context, const char *name, const char *desc, const vector<BlendParams> &paramSets,
142*35238bceSAndroid Build Coastguard Worker                      bool useSrgbFbo)
143*35238bceSAndroid Build Coastguard Worker     : TestCase(context, name, desc)
144*35238bceSAndroid Build Coastguard Worker     , m_paramSets(paramSets)
145*35238bceSAndroid Build Coastguard Worker     , m_curParamSetNdx(0)
146*35238bceSAndroid Build Coastguard Worker     , m_useSrgbFbo(useSrgbFbo)
147*35238bceSAndroid Build Coastguard Worker     , m_colorRbo(0)
148*35238bceSAndroid Build Coastguard Worker     , m_fbo(0)
149*35238bceSAndroid Build Coastguard Worker     , m_renderer(DE_NULL)
150*35238bceSAndroid Build Coastguard Worker     , m_referenceRenderer(DE_NULL)
151*35238bceSAndroid Build Coastguard Worker     , m_refColorBuffer(DE_NULL)
152*35238bceSAndroid Build Coastguard Worker     , m_renderWidth(m_useSrgbFbo ? 2 * MAX_VIEWPORT_WIDTH : m_context.getRenderTarget().getWidth())
153*35238bceSAndroid Build Coastguard Worker     , m_renderHeight(m_useSrgbFbo ? 2 * MAX_VIEWPORT_HEIGHT : m_context.getRenderTarget().getHeight())
154*35238bceSAndroid Build Coastguard Worker     , m_viewportWidth(0)
155*35238bceSAndroid Build Coastguard Worker     , m_viewportHeight(0)
156*35238bceSAndroid Build Coastguard Worker {
157*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(!m_paramSets.empty());
158*35238bceSAndroid Build Coastguard Worker }
159*35238bceSAndroid Build Coastguard Worker 
init(void)160*35238bceSAndroid Build Coastguard Worker void BlendCase::init(void)
161*35238bceSAndroid Build Coastguard Worker {
162*35238bceSAndroid Build Coastguard Worker     bool useRGB = !m_useSrgbFbo && m_context.getRenderTarget().getPixelFormat().alphaBits == 0;
163*35238bceSAndroid Build Coastguard Worker 
164*35238bceSAndroid Build Coastguard Worker     static const Vec4 baseGradientColors[4] = {Vec4(0.0f, 0.5f, 1.0f, 0.5f), Vec4(0.5f, 0.0f, 0.5f, 1.0f),
165*35238bceSAndroid Build Coastguard Worker                                                Vec4(0.5f, 1.0f, 0.5f, 0.0f), Vec4(1.0f, 0.5f, 0.0f, 0.5f)};
166*35238bceSAndroid Build Coastguard Worker 
167*35238bceSAndroid Build Coastguard Worker     DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(m_firstQuad.color) == DE_LENGTH_OF_ARRAY(m_firstQuadInt.color));
168*35238bceSAndroid Build Coastguard Worker     for (int i = 0; i < DE_LENGTH_OF_ARRAY(m_firstQuad.color); i++)
169*35238bceSAndroid Build Coastguard Worker     {
170*35238bceSAndroid Build Coastguard Worker         m_firstQuad.color[i]    = (baseGradientColors[i] - 0.5f) * 0.2f + 0.5f;
171*35238bceSAndroid Build Coastguard Worker         m_firstQuadInt.color[i] = m_firstQuad.color[i];
172*35238bceSAndroid Build Coastguard Worker 
173*35238bceSAndroid Build Coastguard Worker         m_secondQuad.color[i]    = (Vec4(1.0f) - baseGradientColors[i] - 0.5f) * 1.0f + 0.5f;
174*35238bceSAndroid Build Coastguard Worker         m_secondQuadInt.color[i] = m_secondQuad.color[i];
175*35238bceSAndroid Build Coastguard Worker     }
176*35238bceSAndroid Build Coastguard Worker 
177*35238bceSAndroid Build Coastguard Worker     m_viewportWidth  = de::min<int>(m_renderWidth, MAX_VIEWPORT_WIDTH);
178*35238bceSAndroid Build Coastguard Worker     m_viewportHeight = de::min<int>(m_renderHeight, MAX_VIEWPORT_HEIGHT);
179*35238bceSAndroid Build Coastguard Worker 
180*35238bceSAndroid Build Coastguard Worker     m_firstQuadInt.posA  = tcu::IVec2(0, 0);
181*35238bceSAndroid Build Coastguard Worker     m_secondQuadInt.posA = tcu::IVec2(0, 0);
182*35238bceSAndroid Build Coastguard Worker     m_firstQuadInt.posB  = tcu::IVec2(m_viewportWidth - 1, m_viewportHeight - 1);
183*35238bceSAndroid Build Coastguard Worker     m_secondQuadInt.posB = tcu::IVec2(m_viewportWidth - 1, m_viewportHeight - 1);
184*35238bceSAndroid Build Coastguard Worker 
185*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(!m_renderer);
186*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(!m_referenceRenderer);
187*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(!m_refColorBuffer);
188*35238bceSAndroid Build Coastguard Worker 
189*35238bceSAndroid Build Coastguard Worker     m_renderer          = new QuadRenderer(m_context.getRenderContext(), glu::GLSL_VERSION_300_ES);
190*35238bceSAndroid Build Coastguard Worker     m_referenceRenderer = new ReferenceQuadRenderer;
191*35238bceSAndroid Build Coastguard Worker     m_refColorBuffer    = new TextureLevel(TextureFormat(m_useSrgbFbo ? TextureFormat::sRGBA :
192*35238bceSAndroid Build Coastguard Worker                                                          useRGB       ? TextureFormat::RGB :
193*35238bceSAndroid Build Coastguard Worker                                                                         TextureFormat::RGBA,
194*35238bceSAndroid Build Coastguard Worker                                                          TextureFormat::UNORM_INT8),
195*35238bceSAndroid Build Coastguard Worker                                            m_viewportWidth, m_viewportHeight);
196*35238bceSAndroid Build Coastguard Worker 
197*35238bceSAndroid Build Coastguard Worker     m_curParamSetNdx = 0;
198*35238bceSAndroid Build Coastguard Worker 
199*35238bceSAndroid Build Coastguard Worker     if (m_useSrgbFbo)
200*35238bceSAndroid Build Coastguard Worker     {
201*35238bceSAndroid Build Coastguard Worker         m_testCtx.getLog() << TestLog::Message << "Using FBO of size (" << m_renderWidth << ", " << m_renderHeight
202*35238bceSAndroid Build Coastguard Worker                            << ") with format GL_SRGB8_ALPHA8" << TestLog::EndMessage;
203*35238bceSAndroid Build Coastguard Worker 
204*35238bceSAndroid Build Coastguard Worker         GLU_CHECK_CALL(glGenRenderbuffers(1, &m_colorRbo));
205*35238bceSAndroid Build Coastguard Worker         GLU_CHECK_CALL(glBindRenderbuffer(GL_RENDERBUFFER, m_colorRbo));
206*35238bceSAndroid Build Coastguard Worker         GLU_CHECK_CALL(glRenderbufferStorage(GL_RENDERBUFFER, GL_SRGB8_ALPHA8, m_renderWidth, m_renderHeight));
207*35238bceSAndroid Build Coastguard Worker 
208*35238bceSAndroid Build Coastguard Worker         GLU_CHECK_CALL(glGenFramebuffers(1, &m_fbo));
209*35238bceSAndroid Build Coastguard Worker         GLU_CHECK_CALL(glBindFramebuffer(GL_FRAMEBUFFER, m_fbo));
210*35238bceSAndroid Build Coastguard Worker         GLU_CHECK_CALL(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_colorRbo));
211*35238bceSAndroid Build Coastguard Worker     }
212*35238bceSAndroid Build Coastguard Worker }
213*35238bceSAndroid Build Coastguard Worker 
~BlendCase(void)214*35238bceSAndroid Build Coastguard Worker BlendCase::~BlendCase(void)
215*35238bceSAndroid Build Coastguard Worker {
216*35238bceSAndroid Build Coastguard Worker     BlendCase::deinit();
217*35238bceSAndroid Build Coastguard Worker }
218*35238bceSAndroid Build Coastguard Worker 
deinit(void)219*35238bceSAndroid Build Coastguard Worker void BlendCase::deinit(void)
220*35238bceSAndroid Build Coastguard Worker {
221*35238bceSAndroid Build Coastguard Worker     delete m_renderer;
222*35238bceSAndroid Build Coastguard Worker     delete m_referenceRenderer;
223*35238bceSAndroid Build Coastguard Worker     delete m_refColorBuffer;
224*35238bceSAndroid Build Coastguard Worker 
225*35238bceSAndroid Build Coastguard Worker     m_renderer          = DE_NULL;
226*35238bceSAndroid Build Coastguard Worker     m_referenceRenderer = DE_NULL;
227*35238bceSAndroid Build Coastguard Worker     m_refColorBuffer    = DE_NULL;
228*35238bceSAndroid Build Coastguard Worker 
229*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_CALL(glBindRenderbuffer(GL_RENDERBUFFER, 0));
230*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_CALL(glBindFramebuffer(GL_FRAMEBUFFER, 0));
231*35238bceSAndroid Build Coastguard Worker 
232*35238bceSAndroid Build Coastguard Worker     if (m_colorRbo != 0)
233*35238bceSAndroid Build Coastguard Worker     {
234*35238bceSAndroid Build Coastguard Worker         GLU_CHECK_CALL(glDeleteRenderbuffers(1, &m_colorRbo));
235*35238bceSAndroid Build Coastguard Worker         m_colorRbo = 0;
236*35238bceSAndroid Build Coastguard Worker     }
237*35238bceSAndroid Build Coastguard Worker     if (m_fbo != 0)
238*35238bceSAndroid Build Coastguard Worker     {
239*35238bceSAndroid Build Coastguard Worker         GLU_CHECK_CALL(glDeleteFramebuffers(1, &m_fbo));
240*35238bceSAndroid Build Coastguard Worker         m_fbo = 0;
241*35238bceSAndroid Build Coastguard Worker     }
242*35238bceSAndroid Build Coastguard Worker }
243*35238bceSAndroid Build Coastguard Worker 
iterate(void)244*35238bceSAndroid Build Coastguard Worker BlendCase::IterateResult BlendCase::iterate(void)
245*35238bceSAndroid Build Coastguard Worker {
246*35238bceSAndroid Build Coastguard Worker     de::Random rnd(deStringHash(getName()) ^ deInt32Hash(m_curParamSetNdx));
247*35238bceSAndroid Build Coastguard Worker     int viewportX = rnd.getInt(0, m_renderWidth - m_viewportWidth);
248*35238bceSAndroid Build Coastguard Worker     int viewportY = rnd.getInt(0, m_renderHeight - m_viewportHeight);
249*35238bceSAndroid Build Coastguard Worker     TextureLevel renderedImg(
250*35238bceSAndroid Build Coastguard Worker         TextureFormat(m_useSrgbFbo ? TextureFormat::sRGBA : TextureFormat::RGBA, TextureFormat::UNORM_INT8),
251*35238bceSAndroid Build Coastguard Worker         m_viewportWidth, m_viewportHeight);
252*35238bceSAndroid Build Coastguard Worker     TextureLevel referenceImg(renderedImg.getFormat(), m_viewportWidth, m_viewportHeight);
253*35238bceSAndroid Build Coastguard Worker     TestLog &log(m_testCtx.getLog());
254*35238bceSAndroid Build Coastguard Worker     const BlendParams &paramSet = m_paramSets[m_curParamSetNdx];
255*35238bceSAndroid Build Coastguard Worker     rr::FragmentOperationState referenceState;
256*35238bceSAndroid Build Coastguard Worker 
257*35238bceSAndroid Build Coastguard Worker     // Log the blend parameters.
258*35238bceSAndroid Build Coastguard Worker 
259*35238bceSAndroid Build Coastguard Worker     log << TestLog::Message << "RGB equation = " << getBlendEquationName(paramSet.equationRGB) << TestLog::EndMessage;
260*35238bceSAndroid Build Coastguard Worker     log << TestLog::Message << "RGB src func = " << getBlendFactorName(paramSet.srcFuncRGB) << TestLog::EndMessage;
261*35238bceSAndroid Build Coastguard Worker     log << TestLog::Message << "RGB dst func = " << getBlendFactorName(paramSet.dstFuncRGB) << TestLog::EndMessage;
262*35238bceSAndroid Build Coastguard Worker     log << TestLog::Message << "Alpha equation = " << getBlendEquationName(paramSet.equationAlpha)
263*35238bceSAndroid Build Coastguard Worker         << TestLog::EndMessage;
264*35238bceSAndroid Build Coastguard Worker     log << TestLog::Message << "Alpha src func = " << getBlendFactorName(paramSet.srcFuncAlpha) << TestLog::EndMessage;
265*35238bceSAndroid Build Coastguard Worker     log << TestLog::Message << "Alpha dst func = " << getBlendFactorName(paramSet.dstFuncAlpha) << TestLog::EndMessage;
266*35238bceSAndroid Build Coastguard Worker     log << TestLog::Message << "Blend color = (" << paramSet.blendColor.x() << ", " << paramSet.blendColor.y() << ", "
267*35238bceSAndroid Build Coastguard Worker         << paramSet.blendColor.z() << ", " << paramSet.blendColor.w() << ")" << TestLog::EndMessage;
268*35238bceSAndroid Build Coastguard Worker 
269*35238bceSAndroid Build Coastguard Worker     // Set GL state.
270*35238bceSAndroid Build Coastguard Worker 
271*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_CALL(glBlendEquationSeparate(paramSet.equationRGB, paramSet.equationAlpha));
272*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_CALL(
273*35238bceSAndroid Build Coastguard Worker         glBlendFuncSeparate(paramSet.srcFuncRGB, paramSet.dstFuncRGB, paramSet.srcFuncAlpha, paramSet.dstFuncAlpha));
274*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_CALL(glBlendColor(paramSet.blendColor.x(), paramSet.blendColor.y(), paramSet.blendColor.z(),
275*35238bceSAndroid Build Coastguard Worker                                 paramSet.blendColor.w()));
276*35238bceSAndroid Build Coastguard Worker 
277*35238bceSAndroid Build Coastguard Worker     // Set reference state.
278*35238bceSAndroid Build Coastguard Worker 
279*35238bceSAndroid Build Coastguard Worker     referenceState.blendRGBState.equation = sglr::rr_util::mapGLBlendEquation(paramSet.equationRGB);
280*35238bceSAndroid Build Coastguard Worker     referenceState.blendRGBState.srcFunc  = sglr::rr_util::mapGLBlendFunc(paramSet.srcFuncRGB);
281*35238bceSAndroid Build Coastguard Worker     referenceState.blendRGBState.dstFunc  = sglr::rr_util::mapGLBlendFunc(paramSet.dstFuncRGB);
282*35238bceSAndroid Build Coastguard Worker     referenceState.blendAState.equation   = sglr::rr_util::mapGLBlendEquation(paramSet.equationAlpha);
283*35238bceSAndroid Build Coastguard Worker     referenceState.blendAState.srcFunc    = sglr::rr_util::mapGLBlendFunc(paramSet.srcFuncAlpha);
284*35238bceSAndroid Build Coastguard Worker     referenceState.blendAState.dstFunc    = sglr::rr_util::mapGLBlendFunc(paramSet.dstFuncAlpha);
285*35238bceSAndroid Build Coastguard Worker     referenceState.blendColor             = paramSet.blendColor;
286*35238bceSAndroid Build Coastguard Worker 
287*35238bceSAndroid Build Coastguard Worker     // Render with GL.
288*35238bceSAndroid Build Coastguard Worker 
289*35238bceSAndroid Build Coastguard Worker     glDisable(GL_BLEND);
290*35238bceSAndroid Build Coastguard Worker     glViewport(viewportX, viewportY, m_viewportWidth, m_viewportHeight);
291*35238bceSAndroid Build Coastguard Worker     m_renderer->render(m_firstQuad);
292*35238bceSAndroid Build Coastguard Worker     glEnable(GL_BLEND);
293*35238bceSAndroid Build Coastguard Worker     m_renderer->render(m_secondQuad);
294*35238bceSAndroid Build Coastguard Worker     glFlush();
295*35238bceSAndroid Build Coastguard Worker 
296*35238bceSAndroid Build Coastguard Worker     // Render reference.
297*35238bceSAndroid Build Coastguard Worker 
298*35238bceSAndroid Build Coastguard Worker     const tcu::PixelBufferAccess nullAccess = tcu::PixelBufferAccess();
299*35238bceSAndroid Build Coastguard Worker 
300*35238bceSAndroid Build Coastguard Worker     referenceState.blendMode = rr::BLENDMODE_NONE;
301*35238bceSAndroid Build Coastguard Worker     m_referenceRenderer->render(gls::FragmentOpUtil::getMultisampleAccess(m_refColorBuffer->getAccess()),
302*35238bceSAndroid Build Coastguard Worker                                 nullAccess /* no depth */, nullAccess /* no stencil */, m_firstQuadInt, referenceState);
303*35238bceSAndroid Build Coastguard Worker     referenceState.blendMode = rr::BLENDMODE_STANDARD;
304*35238bceSAndroid Build Coastguard Worker     m_referenceRenderer->render(gls::FragmentOpUtil::getMultisampleAccess(m_refColorBuffer->getAccess()),
305*35238bceSAndroid Build Coastguard Worker                                 nullAccess /* no depth */, nullAccess /* no stencil */, m_secondQuadInt,
306*35238bceSAndroid Build Coastguard Worker                                 referenceState);
307*35238bceSAndroid Build Coastguard Worker 
308*35238bceSAndroid Build Coastguard Worker     // Copy to reference (expansion to RGBA happens here if necessary)
309*35238bceSAndroid Build Coastguard Worker     copy(referenceImg, m_refColorBuffer->getAccess());
310*35238bceSAndroid Build Coastguard Worker 
311*35238bceSAndroid Build Coastguard Worker     // Read GL image.
312*35238bceSAndroid Build Coastguard Worker 
313*35238bceSAndroid Build Coastguard Worker     glu::readPixels(m_context.getRenderContext(), viewportX, viewportY, renderedImg.getAccess());
314*35238bceSAndroid Build Coastguard Worker 
315*35238bceSAndroid Build Coastguard Worker     // Compare images.
316*35238bceSAndroid Build Coastguard Worker     // \note In sRGB cases, convert to linear space for comparison.
317*35238bceSAndroid Build Coastguard Worker 
318*35238bceSAndroid Build Coastguard Worker     if (m_useSrgbFbo)
319*35238bceSAndroid Build Coastguard Worker     {
320*35238bceSAndroid Build Coastguard Worker         sRGBAToLinear(renderedImg, renderedImg);
321*35238bceSAndroid Build Coastguard Worker         sRGBAToLinear(referenceImg, referenceImg);
322*35238bceSAndroid Build Coastguard Worker     }
323*35238bceSAndroid Build Coastguard Worker 
324*35238bceSAndroid Build Coastguard Worker     UVec4 compareThreshold =
325*35238bceSAndroid Build Coastguard Worker         (m_useSrgbFbo ? tcu::PixelFormat(8, 8, 8, 8) : m_context.getRenderTarget().getPixelFormat())
326*35238bceSAndroid Build Coastguard Worker                 .getColorThreshold()
327*35238bceSAndroid Build Coastguard Worker                 .toIVec()
328*35238bceSAndroid Build Coastguard Worker                 .asUint() *
329*35238bceSAndroid Build Coastguard Worker             UVec4(5) / UVec4(2) +
330*35238bceSAndroid Build Coastguard Worker         UVec4(
331*35238bceSAndroid Build Coastguard Worker             m_useSrgbFbo ?
332*35238bceSAndroid Build Coastguard Worker                 5 :
333*35238bceSAndroid Build Coastguard Worker                 3); // \note Non-scientific ad hoc formula. Need big threshold when few color bits; blending brings extra inaccuracy.
334*35238bceSAndroid Build Coastguard Worker 
335*35238bceSAndroid Build Coastguard Worker     bool comparePass = tcu::intThresholdCompare(m_testCtx.getLog(), "CompareResult", "Image Comparison Result",
336*35238bceSAndroid Build Coastguard Worker                                                 referenceImg.getAccess(), renderedImg.getAccess(), compareThreshold,
337*35238bceSAndroid Build Coastguard Worker                                                 tcu::COMPARE_LOG_RESULT);
338*35238bceSAndroid Build Coastguard Worker 
339*35238bceSAndroid Build Coastguard Worker     // Fail now if images don't match.
340*35238bceSAndroid Build Coastguard Worker 
341*35238bceSAndroid Build Coastguard Worker     if (!comparePass)
342*35238bceSAndroid Build Coastguard Worker     {
343*35238bceSAndroid Build Coastguard Worker         m_context.getTestContext().setTestResult(QP_TEST_RESULT_FAIL, "Image compare failed");
344*35238bceSAndroid Build Coastguard Worker         return STOP;
345*35238bceSAndroid Build Coastguard Worker     }
346*35238bceSAndroid Build Coastguard Worker 
347*35238bceSAndroid Build Coastguard Worker     // Continue if param sets still remain in m_paramSets; otherwise stop.
348*35238bceSAndroid Build Coastguard Worker 
349*35238bceSAndroid Build Coastguard Worker     m_curParamSetNdx++;
350*35238bceSAndroid Build Coastguard Worker 
351*35238bceSAndroid Build Coastguard Worker     if (m_curParamSetNdx < (int)m_paramSets.size())
352*35238bceSAndroid Build Coastguard Worker         return CONTINUE;
353*35238bceSAndroid Build Coastguard Worker     else
354*35238bceSAndroid Build Coastguard Worker     {
355*35238bceSAndroid Build Coastguard Worker         m_context.getTestContext().setTestResult(QP_TEST_RESULT_PASS, "Passed");
356*35238bceSAndroid Build Coastguard Worker         return STOP;
357*35238bceSAndroid Build Coastguard Worker     }
358*35238bceSAndroid Build Coastguard Worker }
359*35238bceSAndroid Build Coastguard Worker 
BlendTests(Context & context)360*35238bceSAndroid Build Coastguard Worker BlendTests::BlendTests(Context &context) : TestCaseGroup(context, "blend", "Blend tests")
361*35238bceSAndroid Build Coastguard Worker {
362*35238bceSAndroid Build Coastguard Worker }
363*35238bceSAndroid Build Coastguard Worker 
~BlendTests(void)364*35238bceSAndroid Build Coastguard Worker BlendTests::~BlendTests(void)
365*35238bceSAndroid Build Coastguard Worker {
366*35238bceSAndroid Build Coastguard Worker }
367*35238bceSAndroid Build Coastguard Worker 
init(void)368*35238bceSAndroid Build Coastguard Worker void BlendTests::init(void)
369*35238bceSAndroid Build Coastguard Worker {
370*35238bceSAndroid Build Coastguard Worker     struct EnumGL
371*35238bceSAndroid Build Coastguard Worker     {
372*35238bceSAndroid Build Coastguard Worker         GLenum glValue;
373*35238bceSAndroid Build Coastguard Worker         const char *nameStr;
374*35238bceSAndroid Build Coastguard Worker     };
375*35238bceSAndroid Build Coastguard Worker 
376*35238bceSAndroid Build Coastguard Worker     static const EnumGL blendEquations[] = {{GL_FUNC_ADD, "add"},
377*35238bceSAndroid Build Coastguard Worker                                             {GL_FUNC_SUBTRACT, "subtract"},
378*35238bceSAndroid Build Coastguard Worker                                             {GL_FUNC_REVERSE_SUBTRACT, "reverse_subtract"},
379*35238bceSAndroid Build Coastguard Worker                                             {GL_MIN, "min"},
380*35238bceSAndroid Build Coastguard Worker                                             {GL_MAX, "max"}};
381*35238bceSAndroid Build Coastguard Worker 
382*35238bceSAndroid Build Coastguard Worker     static const EnumGL blendFunctions[] = {{GL_ZERO, "zero"},
383*35238bceSAndroid Build Coastguard Worker                                             {GL_ONE, "one"},
384*35238bceSAndroid Build Coastguard Worker                                             {GL_SRC_COLOR, "src_color"},
385*35238bceSAndroid Build Coastguard Worker                                             {GL_ONE_MINUS_SRC_COLOR, "one_minus_src_color"},
386*35238bceSAndroid Build Coastguard Worker                                             {GL_DST_COLOR, "dst_color"},
387*35238bceSAndroid Build Coastguard Worker                                             {GL_ONE_MINUS_DST_COLOR, "one_minus_dst_color"},
388*35238bceSAndroid Build Coastguard Worker                                             {GL_SRC_ALPHA, "src_alpha"},
389*35238bceSAndroid Build Coastguard Worker                                             {GL_ONE_MINUS_SRC_ALPHA, "one_minus_src_alpha"},
390*35238bceSAndroid Build Coastguard Worker                                             {GL_DST_ALPHA, "dst_alpha"},
391*35238bceSAndroid Build Coastguard Worker                                             {GL_ONE_MINUS_DST_ALPHA, "one_minus_dst_alpha"},
392*35238bceSAndroid Build Coastguard Worker                                             {GL_CONSTANT_COLOR, "constant_color"},
393*35238bceSAndroid Build Coastguard Worker                                             {GL_ONE_MINUS_CONSTANT_COLOR, "one_minus_constant_color"},
394*35238bceSAndroid Build Coastguard Worker                                             {GL_CONSTANT_ALPHA, "constant_alpha"},
395*35238bceSAndroid Build Coastguard Worker                                             {GL_ONE_MINUS_CONSTANT_ALPHA, "one_minus_constant_alpha"},
396*35238bceSAndroid Build Coastguard Worker                                             {GL_SRC_ALPHA_SATURATE, "src_alpha_saturate"}};
397*35238bceSAndroid Build Coastguard Worker 
398*35238bceSAndroid Build Coastguard Worker     const Vec4 defaultBlendColor(0.2f, 0.4f, 0.6f, 0.8f);
399*35238bceSAndroid Build Coastguard Worker 
400*35238bceSAndroid Build Coastguard Worker     for (int useSrgbFboI = 0; useSrgbFboI <= 1; useSrgbFboI++)
401*35238bceSAndroid Build Coastguard Worker     {
402*35238bceSAndroid Build Coastguard Worker         bool useSrgbFbo = useSrgbFboI != 0;
403*35238bceSAndroid Build Coastguard Worker         TestCaseGroup *fbGroup =
404*35238bceSAndroid Build Coastguard Worker             new TestCaseGroup(m_context, useSrgbFbo ? "fbo_srgb" : "default_framebuffer",
405*35238bceSAndroid Build Coastguard Worker                               useSrgbFbo ? "Use a FBO with GL_SRGB8_ALPHA8" : "Use the default framebuffer");
406*35238bceSAndroid Build Coastguard Worker         addChild(fbGroup);
407*35238bceSAndroid Build Coastguard Worker 
408*35238bceSAndroid Build Coastguard Worker         // Test all blend equation, src blend function, dst blend function combinations. RGB and alpha modes are the same.
409*35238bceSAndroid Build Coastguard Worker 
410*35238bceSAndroid Build Coastguard Worker         {
411*35238bceSAndroid Build Coastguard Worker             TestCaseGroup *group = new TestCaseGroup(m_context, "equation_src_func_dst_func",
412*35238bceSAndroid Build Coastguard Worker                                                      "Combinations of Blend Equations and Functions");
413*35238bceSAndroid Build Coastguard Worker             fbGroup->addChild(group);
414*35238bceSAndroid Build Coastguard Worker 
415*35238bceSAndroid Build Coastguard Worker             for (int equationNdx = 0; equationNdx < DE_LENGTH_OF_ARRAY(blendEquations); equationNdx++)
416*35238bceSAndroid Build Coastguard Worker                 for (int srcFuncNdx = 0; srcFuncNdx < DE_LENGTH_OF_ARRAY(blendFunctions); srcFuncNdx++)
417*35238bceSAndroid Build Coastguard Worker                     for (int dstFuncNdx = 0; dstFuncNdx < DE_LENGTH_OF_ARRAY(blendFunctions); dstFuncNdx++)
418*35238bceSAndroid Build Coastguard Worker                     {
419*35238bceSAndroid Build Coastguard Worker                         const EnumGL &eq  = blendEquations[equationNdx];
420*35238bceSAndroid Build Coastguard Worker                         const EnumGL &src = blendFunctions[srcFuncNdx];
421*35238bceSAndroid Build Coastguard Worker                         const EnumGL &dst = blendFunctions[dstFuncNdx];
422*35238bceSAndroid Build Coastguard Worker 
423*35238bceSAndroid Build Coastguard Worker                         if ((eq.glValue == GL_MIN || eq.glValue == GL_MAX) &&
424*35238bceSAndroid Build Coastguard Worker                             (srcFuncNdx > 0 || dstFuncNdx > 0)) // MIN and MAX don't depend on factors.
425*35238bceSAndroid Build Coastguard Worker                             continue;
426*35238bceSAndroid Build Coastguard Worker 
427*35238bceSAndroid Build Coastguard Worker                         string name        = eq.nameStr;
428*35238bceSAndroid Build Coastguard Worker                         string description = string("") + "Equations " + getBlendEquationName(eq.glValue) +
429*35238bceSAndroid Build Coastguard Worker                                              ", src funcs " + getBlendFactorName(src.glValue) + ", dst funcs " +
430*35238bceSAndroid Build Coastguard Worker                                              getBlendFactorName(dst.glValue);
431*35238bceSAndroid Build Coastguard Worker 
432*35238bceSAndroid Build Coastguard Worker                         if (eq.glValue != GL_MIN && eq.glValue != GL_MAX)
433*35238bceSAndroid Build Coastguard Worker                             name += string("") + "_" + src.nameStr + "_" + dst.nameStr;
434*35238bceSAndroid Build Coastguard Worker 
435*35238bceSAndroid Build Coastguard Worker                         vector<BlendParams> paramSets;
436*35238bceSAndroid Build Coastguard Worker                         paramSets.push_back(BlendParams(eq.glValue, src.glValue, dst.glValue, eq.glValue, src.glValue,
437*35238bceSAndroid Build Coastguard Worker                                                         dst.glValue, defaultBlendColor));
438*35238bceSAndroid Build Coastguard Worker 
439*35238bceSAndroid Build Coastguard Worker                         group->addChild(
440*35238bceSAndroid Build Coastguard Worker                             new BlendCase(m_context, name.c_str(), description.c_str(), paramSets, useSrgbFbo));
441*35238bceSAndroid Build Coastguard Worker                     }
442*35238bceSAndroid Build Coastguard Worker         }
443*35238bceSAndroid Build Coastguard Worker 
444*35238bceSAndroid Build Coastguard Worker         // Test all RGB src, alpha src and RGB dst, alpha dst combinations. Equations are ADD.
445*35238bceSAndroid Build Coastguard Worker         // \note For all RGB src, alpha src combinations, also test a couple of different RGBA dst functions, and vice versa.
446*35238bceSAndroid Build Coastguard Worker 
447*35238bceSAndroid Build Coastguard Worker         {
448*35238bceSAndroid Build Coastguard Worker             TestCaseGroup *mainGroup =
449*35238bceSAndroid Build Coastguard Worker                 new TestCaseGroup(m_context, "rgb_func_alpha_func", "Combinations of RGB and Alpha Functions");
450*35238bceSAndroid Build Coastguard Worker             fbGroup->addChild(mainGroup);
451*35238bceSAndroid Build Coastguard Worker             TestCaseGroup *srcGroup = new TestCaseGroup(m_context, "src", "Source functions");
452*35238bceSAndroid Build Coastguard Worker             TestCaseGroup *dstGroup = new TestCaseGroup(m_context, "dst", "Destination functions");
453*35238bceSAndroid Build Coastguard Worker             mainGroup->addChild(srcGroup);
454*35238bceSAndroid Build Coastguard Worker             mainGroup->addChild(dstGroup);
455*35238bceSAndroid Build Coastguard Worker 
456*35238bceSAndroid Build Coastguard Worker             for (int isDstI = 0; isDstI <= 1; isDstI++)
457*35238bceSAndroid Build Coastguard Worker                 for (int rgbFuncNdx = 0; rgbFuncNdx < DE_LENGTH_OF_ARRAY(blendFunctions); rgbFuncNdx++)
458*35238bceSAndroid Build Coastguard Worker                     for (int alphaFuncNdx = 0; alphaFuncNdx < DE_LENGTH_OF_ARRAY(blendFunctions); alphaFuncNdx++)
459*35238bceSAndroid Build Coastguard Worker                     {
460*35238bceSAndroid Build Coastguard Worker                         bool isSrc              = isDstI == 0;
461*35238bceSAndroid Build Coastguard Worker                         TestCaseGroup *curGroup = isSrc ? srcGroup : dstGroup;
462*35238bceSAndroid Build Coastguard Worker                         const EnumGL &funcRGB   = blendFunctions[rgbFuncNdx];
463*35238bceSAndroid Build Coastguard Worker                         const EnumGL &funcAlpha = blendFunctions[alphaFuncNdx];
464*35238bceSAndroid Build Coastguard Worker                         const char *dstOrSrcStr = isSrc ? "src" : "dst";
465*35238bceSAndroid Build Coastguard Worker 
466*35238bceSAndroid Build Coastguard Worker                         string name        = string("") + funcRGB.nameStr + "_" + funcAlpha.nameStr;
467*35238bceSAndroid Build Coastguard Worker                         string description = string("") + "RGB " + dstOrSrcStr + " func " +
468*35238bceSAndroid Build Coastguard Worker                                              getBlendFactorName(funcRGB.glValue) + ", alpha " + dstOrSrcStr + " func " +
469*35238bceSAndroid Build Coastguard Worker                                              getBlendFactorName(funcAlpha.glValue);
470*35238bceSAndroid Build Coastguard Worker 
471*35238bceSAndroid Build Coastguard Worker                         // First, make param sets as if this was a src case.
472*35238bceSAndroid Build Coastguard Worker 
473*35238bceSAndroid Build Coastguard Worker                         vector<BlendParams> paramSets;
474*35238bceSAndroid Build Coastguard Worker                         paramSets.push_back(BlendParams(GL_FUNC_ADD, funcRGB.glValue, GL_ONE, GL_FUNC_ADD,
475*35238bceSAndroid Build Coastguard Worker                                                         funcAlpha.glValue, GL_ONE, defaultBlendColor));
476*35238bceSAndroid Build Coastguard Worker                         paramSets.push_back(BlendParams(GL_FUNC_ADD, funcRGB.glValue, GL_ZERO, GL_FUNC_ADD,
477*35238bceSAndroid Build Coastguard Worker                                                         funcAlpha.glValue, GL_ZERO, defaultBlendColor));
478*35238bceSAndroid Build Coastguard Worker                         paramSets.push_back(BlendParams(GL_FUNC_ADD, funcRGB.glValue, GL_SRC_COLOR, GL_FUNC_ADD,
479*35238bceSAndroid Build Coastguard Worker                                                         funcAlpha.glValue, GL_SRC_COLOR, defaultBlendColor));
480*35238bceSAndroid Build Coastguard Worker                         paramSets.push_back(BlendParams(GL_FUNC_ADD, funcRGB.glValue, GL_DST_COLOR, GL_FUNC_ADD,
481*35238bceSAndroid Build Coastguard Worker                                                         funcAlpha.glValue, GL_DST_COLOR, defaultBlendColor));
482*35238bceSAndroid Build Coastguard Worker 
483*35238bceSAndroid Build Coastguard Worker                         // Swap src and dst params if this is a dst case.
484*35238bceSAndroid Build Coastguard Worker 
485*35238bceSAndroid Build Coastguard Worker                         if (!isSrc)
486*35238bceSAndroid Build Coastguard Worker                         {
487*35238bceSAndroid Build Coastguard Worker                             for (int i = 0; i < (int)paramSets.size(); i++)
488*35238bceSAndroid Build Coastguard Worker                             {
489*35238bceSAndroid Build Coastguard Worker                                 std::swap(paramSets[i].srcFuncRGB, paramSets[i].dstFuncRGB);
490*35238bceSAndroid Build Coastguard Worker                                 std::swap(paramSets[i].srcFuncAlpha, paramSets[i].dstFuncAlpha);
491*35238bceSAndroid Build Coastguard Worker                             }
492*35238bceSAndroid Build Coastguard Worker                         }
493*35238bceSAndroid Build Coastguard Worker 
494*35238bceSAndroid Build Coastguard Worker                         curGroup->addChild(
495*35238bceSAndroid Build Coastguard Worker                             new BlendCase(m_context, name.c_str(), description.c_str(), paramSets, useSrgbFbo));
496*35238bceSAndroid Build Coastguard Worker                     }
497*35238bceSAndroid Build Coastguard Worker         }
498*35238bceSAndroid Build Coastguard Worker 
499*35238bceSAndroid Build Coastguard Worker         // Test all RGB and alpha equation combinations. Src and dst funcs are ONE for both.
500*35238bceSAndroid Build Coastguard Worker 
501*35238bceSAndroid Build Coastguard Worker         {
502*35238bceSAndroid Build Coastguard Worker             TestCaseGroup *group = new TestCaseGroup(m_context, "rgb_equation_alpha_equation",
503*35238bceSAndroid Build Coastguard Worker                                                      "Combinations of RGB and Alpha Equation Combinations");
504*35238bceSAndroid Build Coastguard Worker             fbGroup->addChild(group);
505*35238bceSAndroid Build Coastguard Worker 
506*35238bceSAndroid Build Coastguard Worker             for (int equationRGBNdx = 0; equationRGBNdx < DE_LENGTH_OF_ARRAY(blendEquations); equationRGBNdx++)
507*35238bceSAndroid Build Coastguard Worker                 for (int equationAlphaNdx = 0; equationAlphaNdx < DE_LENGTH_OF_ARRAY(blendEquations);
508*35238bceSAndroid Build Coastguard Worker                      equationAlphaNdx++)
509*35238bceSAndroid Build Coastguard Worker                 {
510*35238bceSAndroid Build Coastguard Worker                     const EnumGL &eqRGB   = blendEquations[equationRGBNdx];
511*35238bceSAndroid Build Coastguard Worker                     const EnumGL &eqAlpha = blendEquations[equationAlphaNdx];
512*35238bceSAndroid Build Coastguard Worker 
513*35238bceSAndroid Build Coastguard Worker                     string name        = string("") + eqRGB.nameStr + "_" + eqAlpha.nameStr;
514*35238bceSAndroid Build Coastguard Worker                     string description = string("") + "RGB equation " + getBlendEquationName(eqRGB.glValue) +
515*35238bceSAndroid Build Coastguard Worker                                          ", alpha equation " + getBlendEquationName(eqAlpha.glValue);
516*35238bceSAndroid Build Coastguard Worker 
517*35238bceSAndroid Build Coastguard Worker                     vector<BlendParams> paramSets;
518*35238bceSAndroid Build Coastguard Worker                     paramSets.push_back(
519*35238bceSAndroid Build Coastguard Worker                         BlendParams(eqRGB.glValue, GL_ONE, GL_ONE, eqAlpha.glValue, GL_ONE, GL_ONE, defaultBlendColor));
520*35238bceSAndroid Build Coastguard Worker 
521*35238bceSAndroid Build Coastguard Worker                     group->addChild(new BlendCase(m_context, name.c_str(), description.c_str(), paramSets, useSrgbFbo));
522*35238bceSAndroid Build Coastguard Worker                 }
523*35238bceSAndroid Build Coastguard Worker         }
524*35238bceSAndroid Build Coastguard Worker     }
525*35238bceSAndroid Build Coastguard Worker }
526*35238bceSAndroid Build Coastguard Worker 
527*35238bceSAndroid Build Coastguard Worker } // namespace Functional
528*35238bceSAndroid Build Coastguard Worker } // namespace gles3
529*35238bceSAndroid Build Coastguard Worker } // namespace deqp
530