xref: /aosp_15_r20/external/deqp/modules/gles31/functional/es31fNegativeAdvancedBlendEquationTests.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 2016 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 Negative Advanced Blend Equation Tests
22*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker 
24*35238bceSAndroid Build Coastguard Worker #include "es31fNegativeAdvancedBlendEquationTests.hpp"
25*35238bceSAndroid Build Coastguard Worker 
26*35238bceSAndroid Build Coastguard Worker #include "gluShaderProgram.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
28*35238bceSAndroid Build Coastguard Worker 
29*35238bceSAndroid Build Coastguard Worker namespace deqp
30*35238bceSAndroid Build Coastguard Worker {
31*35238bceSAndroid Build Coastguard Worker namespace gles31
32*35238bceSAndroid Build Coastguard Worker {
33*35238bceSAndroid Build Coastguard Worker namespace Functional
34*35238bceSAndroid Build Coastguard Worker {
35*35238bceSAndroid Build Coastguard Worker namespace NegativeTestShared
36*35238bceSAndroid Build Coastguard Worker {
37*35238bceSAndroid Build Coastguard Worker namespace
38*35238bceSAndroid Build Coastguard Worker {
39*35238bceSAndroid Build Coastguard Worker 
40*35238bceSAndroid Build Coastguard Worker enum BlendEquation
41*35238bceSAndroid Build Coastguard Worker {
42*35238bceSAndroid Build Coastguard Worker     BLEND_EQUATION_MULTIPLY = 0,
43*35238bceSAndroid Build Coastguard Worker     BLEND_EQUATION_SCREEN,
44*35238bceSAndroid Build Coastguard Worker     BLEND_EQUATION_OVERLAY,
45*35238bceSAndroid Build Coastguard Worker     BLEND_EQUATION_DARKEN,
46*35238bceSAndroid Build Coastguard Worker     BLEND_EQUATION_LIGHTEN,
47*35238bceSAndroid Build Coastguard Worker     BLEND_EQUATION_COLORDODGE,
48*35238bceSAndroid Build Coastguard Worker     BLEND_EQUATION_COLORBURN,
49*35238bceSAndroid Build Coastguard Worker     BLEND_EQUATION_HARDLIGHT,
50*35238bceSAndroid Build Coastguard Worker     BLEND_EQUATION_SOFTLIGHT,
51*35238bceSAndroid Build Coastguard Worker     BLEND_EQUATION_DIFFERENCE,
52*35238bceSAndroid Build Coastguard Worker     BLEND_EQUATION_EXCLUSION,
53*35238bceSAndroid Build Coastguard Worker     BLEND_EQUATION_HSL_HUE,
54*35238bceSAndroid Build Coastguard Worker     BLEND_EQUATION_HSL_SATURATION,
55*35238bceSAndroid Build Coastguard Worker     BLEND_EQUATION_HSL_COLOR,
56*35238bceSAndroid Build Coastguard Worker     BLEND_EQUATION_HSL_LUMINOSITY,
57*35238bceSAndroid Build Coastguard Worker     BLEND_EQUATION_ALL_EQUATIONS,
58*35238bceSAndroid Build Coastguard Worker 
59*35238bceSAndroid Build Coastguard Worker     BLEND_EQUATION_LAST
60*35238bceSAndroid Build Coastguard Worker };
61*35238bceSAndroid Build Coastguard Worker 
62*35238bceSAndroid Build Coastguard Worker static const BlendEquation s_equations[] = {
63*35238bceSAndroid Build Coastguard Worker     BLEND_EQUATION_MULTIPLY,       BLEND_EQUATION_SCREEN,     BLEND_EQUATION_OVERLAY,       BLEND_EQUATION_DARKEN,
64*35238bceSAndroid Build Coastguard Worker     BLEND_EQUATION_LIGHTEN,        BLEND_EQUATION_COLORDODGE, BLEND_EQUATION_COLORBURN,     BLEND_EQUATION_HARDLIGHT,
65*35238bceSAndroid Build Coastguard Worker     BLEND_EQUATION_SOFTLIGHT,      BLEND_EQUATION_DIFFERENCE, BLEND_EQUATION_EXCLUSION,     BLEND_EQUATION_HSL_HUE,
66*35238bceSAndroid Build Coastguard Worker     BLEND_EQUATION_HSL_SATURATION, BLEND_EQUATION_HSL_COLOR,  BLEND_EQUATION_HSL_LUMINOSITY};
67*35238bceSAndroid Build Coastguard Worker 
getShaderLayoutEquation(BlendEquation equation)68*35238bceSAndroid Build Coastguard Worker std::string getShaderLayoutEquation(BlendEquation equation)
69*35238bceSAndroid Build Coastguard Worker {
70*35238bceSAndroid Build Coastguard Worker     switch (equation)
71*35238bceSAndroid Build Coastguard Worker     {
72*35238bceSAndroid Build Coastguard Worker     case BLEND_EQUATION_MULTIPLY:
73*35238bceSAndroid Build Coastguard Worker         return "blend_support_multiply";
74*35238bceSAndroid Build Coastguard Worker     case BLEND_EQUATION_SCREEN:
75*35238bceSAndroid Build Coastguard Worker         return "blend_support_screen";
76*35238bceSAndroid Build Coastguard Worker     case BLEND_EQUATION_OVERLAY:
77*35238bceSAndroid Build Coastguard Worker         return "blend_support_overlay";
78*35238bceSAndroid Build Coastguard Worker     case BLEND_EQUATION_DARKEN:
79*35238bceSAndroid Build Coastguard Worker         return "blend_support_darken";
80*35238bceSAndroid Build Coastguard Worker     case BLEND_EQUATION_LIGHTEN:
81*35238bceSAndroid Build Coastguard Worker         return "blend_support_lighten";
82*35238bceSAndroid Build Coastguard Worker     case BLEND_EQUATION_COLORDODGE:
83*35238bceSAndroid Build Coastguard Worker         return "blend_support_colordodge";
84*35238bceSAndroid Build Coastguard Worker     case BLEND_EQUATION_COLORBURN:
85*35238bceSAndroid Build Coastguard Worker         return "blend_support_colorburn";
86*35238bceSAndroid Build Coastguard Worker     case BLEND_EQUATION_HARDLIGHT:
87*35238bceSAndroid Build Coastguard Worker         return "blend_support_hardlight";
88*35238bceSAndroid Build Coastguard Worker     case BLEND_EQUATION_SOFTLIGHT:
89*35238bceSAndroid Build Coastguard Worker         return "blend_support_softlight";
90*35238bceSAndroid Build Coastguard Worker     case BLEND_EQUATION_DIFFERENCE:
91*35238bceSAndroid Build Coastguard Worker         return "blend_support_difference";
92*35238bceSAndroid Build Coastguard Worker     case BLEND_EQUATION_EXCLUSION:
93*35238bceSAndroid Build Coastguard Worker         return "blend_support_exclusion";
94*35238bceSAndroid Build Coastguard Worker     case BLEND_EQUATION_HSL_HUE:
95*35238bceSAndroid Build Coastguard Worker         return "blend_support_hsl_hue";
96*35238bceSAndroid Build Coastguard Worker     case BLEND_EQUATION_HSL_SATURATION:
97*35238bceSAndroid Build Coastguard Worker         return "blend_support_hsl_saturation";
98*35238bceSAndroid Build Coastguard Worker     case BLEND_EQUATION_HSL_COLOR:
99*35238bceSAndroid Build Coastguard Worker         return "blend_support_hsl_color";
100*35238bceSAndroid Build Coastguard Worker     case BLEND_EQUATION_HSL_LUMINOSITY:
101*35238bceSAndroid Build Coastguard Worker         return "blend_support_hsl_luminosity";
102*35238bceSAndroid Build Coastguard Worker     case BLEND_EQUATION_ALL_EQUATIONS:
103*35238bceSAndroid Build Coastguard Worker         return "blend_support_all_equations";
104*35238bceSAndroid Build Coastguard Worker     default:
105*35238bceSAndroid Build Coastguard Worker         DE_FATAL("Equation not supported.");
106*35238bceSAndroid Build Coastguard Worker     }
107*35238bceSAndroid Build Coastguard Worker     return "";
108*35238bceSAndroid Build Coastguard Worker }
109*35238bceSAndroid Build Coastguard Worker 
getEquation(BlendEquation equation)110*35238bceSAndroid Build Coastguard Worker glw::GLenum getEquation(BlendEquation equation)
111*35238bceSAndroid Build Coastguard Worker {
112*35238bceSAndroid Build Coastguard Worker     switch (equation)
113*35238bceSAndroid Build Coastguard Worker     {
114*35238bceSAndroid Build Coastguard Worker     case BLEND_EQUATION_MULTIPLY:
115*35238bceSAndroid Build Coastguard Worker         return GL_MULTIPLY;
116*35238bceSAndroid Build Coastguard Worker     case BLEND_EQUATION_SCREEN:
117*35238bceSAndroid Build Coastguard Worker         return GL_SCREEN;
118*35238bceSAndroid Build Coastguard Worker     case BLEND_EQUATION_OVERLAY:
119*35238bceSAndroid Build Coastguard Worker         return GL_OVERLAY;
120*35238bceSAndroid Build Coastguard Worker     case BLEND_EQUATION_DARKEN:
121*35238bceSAndroid Build Coastguard Worker         return GL_DARKEN;
122*35238bceSAndroid Build Coastguard Worker     case BLEND_EQUATION_LIGHTEN:
123*35238bceSAndroid Build Coastguard Worker         return GL_LIGHTEN;
124*35238bceSAndroid Build Coastguard Worker     case BLEND_EQUATION_COLORDODGE:
125*35238bceSAndroid Build Coastguard Worker         return GL_COLORDODGE;
126*35238bceSAndroid Build Coastguard Worker     case BLEND_EQUATION_COLORBURN:
127*35238bceSAndroid Build Coastguard Worker         return GL_COLORBURN;
128*35238bceSAndroid Build Coastguard Worker     case BLEND_EQUATION_HARDLIGHT:
129*35238bceSAndroid Build Coastguard Worker         return GL_HARDLIGHT;
130*35238bceSAndroid Build Coastguard Worker     case BLEND_EQUATION_SOFTLIGHT:
131*35238bceSAndroid Build Coastguard Worker         return GL_SOFTLIGHT;
132*35238bceSAndroid Build Coastguard Worker     case BLEND_EQUATION_DIFFERENCE:
133*35238bceSAndroid Build Coastguard Worker         return GL_DIFFERENCE;
134*35238bceSAndroid Build Coastguard Worker     case BLEND_EQUATION_EXCLUSION:
135*35238bceSAndroid Build Coastguard Worker         return GL_EXCLUSION;
136*35238bceSAndroid Build Coastguard Worker     case BLEND_EQUATION_HSL_HUE:
137*35238bceSAndroid Build Coastguard Worker         return GL_HSL_HUE;
138*35238bceSAndroid Build Coastguard Worker     case BLEND_EQUATION_HSL_SATURATION:
139*35238bceSAndroid Build Coastguard Worker         return GL_HSL_SATURATION;
140*35238bceSAndroid Build Coastguard Worker     case BLEND_EQUATION_HSL_COLOR:
141*35238bceSAndroid Build Coastguard Worker         return GL_HSL_COLOR;
142*35238bceSAndroid Build Coastguard Worker     case BLEND_EQUATION_HSL_LUMINOSITY:
143*35238bceSAndroid Build Coastguard Worker         return GL_HSL_LUMINOSITY;
144*35238bceSAndroid Build Coastguard Worker     default:
145*35238bceSAndroid Build Coastguard Worker         DE_FATAL("Equation not supported.");
146*35238bceSAndroid Build Coastguard Worker     }
147*35238bceSAndroid Build Coastguard Worker     return DE_NULL;
148*35238bceSAndroid Build Coastguard Worker }
149*35238bceSAndroid Build Coastguard Worker 
generateVertexShaderSource(NegativeTestContext & ctx)150*35238bceSAndroid Build Coastguard Worker std::string generateVertexShaderSource(NegativeTestContext &ctx)
151*35238bceSAndroid Build Coastguard Worker {
152*35238bceSAndroid Build Coastguard Worker     const bool supportsES32        = contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2));
153*35238bceSAndroid Build Coastguard Worker     const glu::GLSLVersion version = supportsES32 ? glu::GLSL_VERSION_320_ES : glu::GLSL_VERSION_310_ES;
154*35238bceSAndroid Build Coastguard Worker     std::ostringstream source;
155*35238bceSAndroid Build Coastguard Worker 
156*35238bceSAndroid Build Coastguard Worker     source << glu::getGLSLVersionDeclaration(version) << "\n"
157*35238bceSAndroid Build Coastguard Worker            << "void main ()\n"
158*35238bceSAndroid Build Coastguard Worker            << "{\n"
159*35238bceSAndroid Build Coastguard Worker            << "    gl_Position = vec4(0.0);\n"
160*35238bceSAndroid Build Coastguard Worker            << "}\n";
161*35238bceSAndroid Build Coastguard Worker 
162*35238bceSAndroid Build Coastguard Worker     return source.str();
163*35238bceSAndroid Build Coastguard Worker }
164*35238bceSAndroid Build Coastguard Worker 
generateFragmentShaderSource(NegativeTestContext & ctx,BlendEquation equation)165*35238bceSAndroid Build Coastguard Worker std::string generateFragmentShaderSource(NegativeTestContext &ctx, BlendEquation equation)
166*35238bceSAndroid Build Coastguard Worker {
167*35238bceSAndroid Build Coastguard Worker     const bool supportsES32        = contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2));
168*35238bceSAndroid Build Coastguard Worker     const glu::GLSLVersion version = supportsES32 ? glu::GLSL_VERSION_320_ES : glu::GLSL_VERSION_310_ES;
169*35238bceSAndroid Build Coastguard Worker     std::ostringstream source;
170*35238bceSAndroid Build Coastguard Worker 
171*35238bceSAndroid Build Coastguard Worker     source << glu::getGLSLVersionDeclaration(version) << "\n"
172*35238bceSAndroid Build Coastguard Worker            << (supportsES32 ? "" : "#extension GL_KHR_blend_equation_advanced : enable\n") << "layout("
173*35238bceSAndroid Build Coastguard Worker            << getShaderLayoutEquation(equation) << ") out;\n"
174*35238bceSAndroid Build Coastguard Worker            << "layout(location=0) out mediump vec4 o_color;\n"
175*35238bceSAndroid Build Coastguard Worker            << "void main ()\n"
176*35238bceSAndroid Build Coastguard Worker            << "{\n"
177*35238bceSAndroid Build Coastguard Worker            << "    o_color = vec4(0);\n"
178*35238bceSAndroid Build Coastguard Worker            << "}\n";
179*35238bceSAndroid Build Coastguard Worker 
180*35238bceSAndroid Build Coastguard Worker     return source.str();
181*35238bceSAndroid Build Coastguard Worker }
182*35238bceSAndroid Build Coastguard Worker 
generateProgramSources(NegativeTestContext & ctx,BlendEquation equation)183*35238bceSAndroid Build Coastguard Worker glu::ProgramSources generateProgramSources(NegativeTestContext &ctx, BlendEquation equation)
184*35238bceSAndroid Build Coastguard Worker {
185*35238bceSAndroid Build Coastguard Worker     return glu::ProgramSources() << glu::VertexSource(generateVertexShaderSource(ctx))
186*35238bceSAndroid Build Coastguard Worker                                  << glu::FragmentSource(generateFragmentShaderSource(ctx, equation));
187*35238bceSAndroid Build Coastguard Worker }
188*35238bceSAndroid Build Coastguard Worker 
blend_qualifier_mismatch(NegativeTestContext & ctx)189*35238bceSAndroid Build Coastguard Worker void blend_qualifier_mismatch(NegativeTestContext &ctx)
190*35238bceSAndroid Build Coastguard Worker {
191*35238bceSAndroid Build Coastguard Worker     TCU_CHECK_AND_THROW(NotSupportedError,
192*35238bceSAndroid Build Coastguard Worker                         ctx.isExtensionSupported("GL_KHR_blend_equation_advanced") ||
193*35238bceSAndroid Build Coastguard Worker                             contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)),
194*35238bceSAndroid Build Coastguard Worker                         "This test requires support for the extension GL_KHR_blend_equation_advanced or context "
195*35238bceSAndroid Build Coastguard Worker                         "version 3.2 or higher.");
196*35238bceSAndroid Build Coastguard Worker 
197*35238bceSAndroid Build Coastguard Worker     glw::GLuint vao = 0;
198*35238bceSAndroid Build Coastguard Worker     bool isES       = glu::isContextTypeES(ctx.getRenderContext().getType());
199*35238bceSAndroid Build Coastguard Worker     if (!isES)
200*35238bceSAndroid Build Coastguard Worker     {
201*35238bceSAndroid Build Coastguard Worker         ctx.glGenVertexArrays(1, &vao);
202*35238bceSAndroid Build Coastguard Worker         ctx.glBindVertexArray(vao);
203*35238bceSAndroid Build Coastguard Worker     }
204*35238bceSAndroid Build Coastguard Worker 
205*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_OPERATION is generated if blending is enabled, and the blend qualifier is different "
206*35238bceSAndroid Build Coastguard Worker                      "from blend_support_all_equations and does not match the blend equation.");
207*35238bceSAndroid Build Coastguard Worker     for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_equations); ++ndx)
208*35238bceSAndroid Build Coastguard Worker     {
209*35238bceSAndroid Build Coastguard Worker         glu::ShaderProgram program(ctx.getRenderContext(), generateProgramSources(ctx, s_equations[ndx]));
210*35238bceSAndroid Build Coastguard Worker 
211*35238bceSAndroid Build Coastguard Worker         ctx.getLog() << program;
212*35238bceSAndroid Build Coastguard Worker         TCU_CHECK(program.isOk());
213*35238bceSAndroid Build Coastguard Worker 
214*35238bceSAndroid Build Coastguard Worker         ctx.glUseProgram(program.getProgram());
215*35238bceSAndroid Build Coastguard Worker         ctx.expectError(GL_NO_ERROR);
216*35238bceSAndroid Build Coastguard Worker 
217*35238bceSAndroid Build Coastguard Worker         for (int ndx2 = 0; ndx2 < DE_LENGTH_OF_ARRAY(s_equations); ++ndx2)
218*35238bceSAndroid Build Coastguard Worker         {
219*35238bceSAndroid Build Coastguard Worker             if (s_equations[ndx] == s_equations[ndx2])
220*35238bceSAndroid Build Coastguard Worker                 continue;
221*35238bceSAndroid Build Coastguard Worker 
222*35238bceSAndroid Build Coastguard Worker             ctx.glEnable(GL_BLEND);
223*35238bceSAndroid Build Coastguard Worker             ctx.glBlendEquation(getEquation(s_equations[ndx2]));
224*35238bceSAndroid Build Coastguard Worker             ctx.expectError(GL_NO_ERROR);
225*35238bceSAndroid Build Coastguard Worker             ctx.glDrawElements(GL_TRIANGLES, 0, GL_UNSIGNED_INT, 0);
226*35238bceSAndroid Build Coastguard Worker             ctx.expectError(GL_INVALID_OPERATION);
227*35238bceSAndroid Build Coastguard Worker 
228*35238bceSAndroid Build Coastguard Worker             ctx.glDisable(GL_BLEND);
229*35238bceSAndroid Build Coastguard Worker             ctx.glDrawElements(GL_TRIANGLES, 0, GL_UNSIGNED_INT, 0);
230*35238bceSAndroid Build Coastguard Worker             ctx.expectError(GL_NO_ERROR);
231*35238bceSAndroid Build Coastguard Worker         }
232*35238bceSAndroid Build Coastguard Worker     }
233*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
234*35238bceSAndroid Build Coastguard Worker 
235*35238bceSAndroid Build Coastguard Worker     if (!isES)
236*35238bceSAndroid Build Coastguard Worker         ctx.glDeleteVertexArrays(1, &vao);
237*35238bceSAndroid Build Coastguard Worker }
238*35238bceSAndroid Build Coastguard Worker 
attachment_advanced_equation(NegativeTestContext & ctx)239*35238bceSAndroid Build Coastguard Worker void attachment_advanced_equation(NegativeTestContext &ctx)
240*35238bceSAndroid Build Coastguard Worker {
241*35238bceSAndroid Build Coastguard Worker     TCU_CHECK_AND_THROW(NotSupportedError,
242*35238bceSAndroid Build Coastguard Worker                         ctx.isExtensionSupported("GL_KHR_blend_equation_advanced") ||
243*35238bceSAndroid Build Coastguard Worker                             contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)),
244*35238bceSAndroid Build Coastguard Worker                         "This test requires support for the extension GL_KHR_blend_equation_advanced or context "
245*35238bceSAndroid Build Coastguard Worker                         "version 3.2 or higher.");
246*35238bceSAndroid Build Coastguard Worker 
247*35238bceSAndroid Build Coastguard Worker     glw::GLuint vao                 = 0;
248*35238bceSAndroid Build Coastguard Worker     glw::GLuint fbo                 = 0x1234;
249*35238bceSAndroid Build Coastguard Worker     glw::GLuint texture             = 0x1234;
250*35238bceSAndroid Build Coastguard Worker     const glw::GLenum attachments[] = {GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1};
251*35238bceSAndroid Build Coastguard Worker     const bool isES                 = glu::isContextTypeES(ctx.getRenderContext().getType());
252*35238bceSAndroid Build Coastguard Worker 
253*35238bceSAndroid Build Coastguard Worker     if (!isES)
254*35238bceSAndroid Build Coastguard Worker     {
255*35238bceSAndroid Build Coastguard Worker         ctx.glGenVertexArrays(1, &vao);
256*35238bceSAndroid Build Coastguard Worker         ctx.glBindVertexArray(vao);
257*35238bceSAndroid Build Coastguard Worker     }
258*35238bceSAndroid Build Coastguard Worker 
259*35238bceSAndroid Build Coastguard Worker     ctx.glGenTextures(1, &texture);
260*35238bceSAndroid Build Coastguard Worker     ctx.glBindTexture(GL_TEXTURE_2D, texture);
261*35238bceSAndroid Build Coastguard Worker     ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
262*35238bceSAndroid Build Coastguard Worker     ctx.glGenFramebuffers(1, &fbo);
263*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
264*35238bceSAndroid Build Coastguard Worker     ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
265*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_NO_ERROR);
266*35238bceSAndroid Build Coastguard Worker     ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
267*35238bceSAndroid Build Coastguard Worker 
268*35238bceSAndroid Build Coastguard Worker     ctx.beginSection(
269*35238bceSAndroid Build Coastguard Worker         "GL_INVALID_OPERATION is generated if blending is enabled, advanced equations are used, and the draw buffer "
270*35238bceSAndroid Build Coastguard Worker         "for other color outputs is not NONE unless NVX_blend_equation_advanced_multi_draw_buffers is supported.");
271*35238bceSAndroid Build Coastguard Worker     for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_equations); ++ndx)
272*35238bceSAndroid Build Coastguard Worker     {
273*35238bceSAndroid Build Coastguard Worker         glu::ShaderProgram program(ctx.getRenderContext(), generateProgramSources(ctx, s_equations[ndx]));
274*35238bceSAndroid Build Coastguard Worker         ctx.getLog() << program;
275*35238bceSAndroid Build Coastguard Worker         TCU_CHECK(program.isOk());
276*35238bceSAndroid Build Coastguard Worker 
277*35238bceSAndroid Build Coastguard Worker         ctx.glUseProgram(program.getProgram());
278*35238bceSAndroid Build Coastguard Worker         ctx.glEnable(GL_BLEND);
279*35238bceSAndroid Build Coastguard Worker         ctx.glDrawBuffers(2, attachments);
280*35238bceSAndroid Build Coastguard Worker         ctx.expectError(GL_NO_ERROR);
281*35238bceSAndroid Build Coastguard Worker         ctx.glBlendEquation(getEquation(s_equations[ndx]));
282*35238bceSAndroid Build Coastguard Worker         ctx.glDrawElements(GL_TRIANGLES, 0, GL_UNSIGNED_INT, 0);
283*35238bceSAndroid Build Coastguard Worker         if (ctx.isExtensionSupported("GL_NVX_blend_equation_advanced_multi_draw_buffers"))
284*35238bceSAndroid Build Coastguard Worker             ctx.expectError(GL_NO_ERROR);
285*35238bceSAndroid Build Coastguard Worker         else
286*35238bceSAndroid Build Coastguard Worker             ctx.expectError(GL_INVALID_OPERATION);
287*35238bceSAndroid Build Coastguard Worker     }
288*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
289*35238bceSAndroid Build Coastguard Worker 
290*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_NO_ERROR is generated if no advanced blend equations are used.");
291*35238bceSAndroid Build Coastguard Worker     ctx.glBlendEquation(GL_FUNC_ADD);
292*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElements(GL_TRIANGLES, 0, GL_UNSIGNED_INT, 0);
293*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_NO_ERROR);
294*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
295*35238bceSAndroid Build Coastguard Worker 
296*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_NO_ERROR is generated if blending is disabled.");
297*35238bceSAndroid Build Coastguard Worker     ctx.glDisable(GL_BLEND);
298*35238bceSAndroid Build Coastguard Worker     for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_equations); ++ndx)
299*35238bceSAndroid Build Coastguard Worker     {
300*35238bceSAndroid Build Coastguard Worker         ctx.glBlendEquation(getEquation(s_equations[ndx]));
301*35238bceSAndroid Build Coastguard Worker         ctx.glDrawElements(GL_TRIANGLES, 0, GL_UNSIGNED_INT, 0);
302*35238bceSAndroid Build Coastguard Worker         ctx.expectError(GL_NO_ERROR);
303*35238bceSAndroid Build Coastguard Worker     }
304*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
305*35238bceSAndroid Build Coastguard Worker 
306*35238bceSAndroid Build Coastguard Worker     if (!isES)
307*35238bceSAndroid Build Coastguard Worker         ctx.glDeleteVertexArrays(1, &vao);
308*35238bceSAndroid Build Coastguard Worker 
309*35238bceSAndroid Build Coastguard Worker     ctx.glDeleteFramebuffers(1, &fbo);
310*35238bceSAndroid Build Coastguard Worker     ctx.glDeleteTextures(1, &texture);
311*35238bceSAndroid Build Coastguard Worker }
312*35238bceSAndroid Build Coastguard Worker 
313*35238bceSAndroid Build Coastguard Worker } // namespace
314*35238bceSAndroid Build Coastguard Worker 
getNegativeAdvancedBlendEquationTestFunctions(void)315*35238bceSAndroid Build Coastguard Worker std::vector<FunctionContainer> getNegativeAdvancedBlendEquationTestFunctions(void)
316*35238bceSAndroid Build Coastguard Worker {
317*35238bceSAndroid Build Coastguard Worker     const FunctionContainer funcs[] = {
318*35238bceSAndroid Build Coastguard Worker         {blend_qualifier_mismatch, "blend_qualifier_mismatch", "Test blend qualifier mismatch."},
319*35238bceSAndroid Build Coastguard Worker         {attachment_advanced_equation, "attachment_advanced_equation", "Test draw buffer for other color outputs."},
320*35238bceSAndroid Build Coastguard Worker     };
321*35238bceSAndroid Build Coastguard Worker 
322*35238bceSAndroid Build Coastguard Worker     return std::vector<FunctionContainer>(DE_ARRAY_BEGIN(funcs), DE_ARRAY_END(funcs));
323*35238bceSAndroid Build Coastguard Worker }
324*35238bceSAndroid Build Coastguard Worker 
325*35238bceSAndroid Build Coastguard Worker } // namespace NegativeTestShared
326*35238bceSAndroid Build Coastguard Worker } // namespace Functional
327*35238bceSAndroid Build Coastguard Worker } // namespace gles31
328*35238bceSAndroid Build Coastguard Worker } // namespace deqp
329