1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 2.0 Module
3 * -------------------------------------------------
5 * Copyright 2014 The Android Open Source Project
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 * \brief Blend performance tests.
22 *//*--------------------------------------------------------------------*/
24 #include "es2pBlendTests.hpp"
25 #include "glsShaderPerformanceCase.hpp"
26 #include "tcuTestLog.hpp"
27 #include "gluStrUtil.hpp"
28 #include "glwEnums.hpp"
29 #include "glwFunctions.hpp"
39 using namespace glw; // GL types
43 class BlendCase : public ShaderPerformanceCase
46 BlendCase (Context& context, const char* name, const char* description, GLenum modeRGB, GLenum modeAlpha, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
52 void setupRenderState (void);
62 BlendCase::BlendCase (Context& context, const char* name, const char* description, GLenum modeRGB, GLenum modeAlpha, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
63 : ShaderPerformanceCase (context.getTestContext(), context.getRenderContext(), name, description, CASETYPE_FRAGMENT)
65 , m_modeAlpha (modeAlpha)
68 , m_srcAlpha (srcAlpha)
69 , m_dstAlpha (dstAlpha)
73 BlendCase::~BlendCase (void)
77 void BlendCase::init (void)
79 TestLog& log = m_testCtx.getLog();
81 log << TestLog::Message << "modeRGB: " << glu::getBlendEquationStr(m_modeRGB) << TestLog::EndMessage;
82 log << TestLog::Message << "modeAlpha: " << glu::getBlendEquationStr(m_modeAlpha) << TestLog::EndMessage;
83 log << TestLog::Message << "srcRGB: " << glu::getBlendFactorStr(m_srcRGB) << TestLog::EndMessage;
84 log << TestLog::Message << "dstRGB: " << glu::getBlendFactorStr(m_dstRGB) << TestLog::EndMessage;
85 log << TestLog::Message << "srcAlpha: " << glu::getBlendFactorStr(m_srcAlpha) << TestLog::EndMessage;
86 log << TestLog::Message << "dstAlpha: " << glu::getBlendFactorStr(m_dstAlpha) << TestLog::EndMessage;
89 "attribute highp vec4 a_position;\n"
90 "attribute mediump vec4 a_color;\n"
91 "varying mediump vec4 v_color;\n"
94 " gl_Position = a_position;\n"
95 " v_color = a_color;\n"
98 "varying mediump vec4 v_color;\n"
101 " gl_FragColor = v_color;\n"
104 m_attributes.push_back(AttribSpec("a_color", Vec4(0.0f, 0.5f, 0.5f, 1.0f),
105 Vec4(0.5f, 1.0f, 0.0f, 0.5f),
106 Vec4(0.5f, 0.0f, 1.0f, 0.5f),
107 Vec4(1.0f, 0.5f, 0.5f, 0.0f)));
109 ShaderPerformanceCase::init();
112 void BlendCase::setupRenderState (void)
114 const glw::Functions& gl = m_renderCtx.getFunctions();
117 gl.blendEquationSeparate(m_modeRGB, m_modeAlpha);
118 gl.blendFuncSeparate(m_srcRGB, m_dstRGB, m_srcAlpha, m_dstAlpha);
120 GLU_EXPECT_NO_ERROR(gl.getError(), "After render state setup");
123 BlendTests::BlendTests (Context& context)
124 : TestCaseGroup(context, "blend", "Blend Performance Tests")
128 BlendTests::~BlendTests (void)
132 void BlendTests::init (void)
145 // Single blend func, factor one.
146 { "add", GL_FUNC_ADD, GL_FUNC_ADD, GL_ONE, GL_ONE, GL_ONE, GL_ONE },
147 { "subtract", GL_FUNC_SUBTRACT, GL_FUNC_SUBTRACT, GL_ONE, GL_ONE, GL_ONE, GL_ONE },
148 { "reverse_subtract", GL_FUNC_REVERSE_SUBTRACT, GL_FUNC_REVERSE_SUBTRACT, GL_ONE, GL_ONE, GL_ONE, GL_ONE },
150 // Porter-duff modes that can be implemented.
151 { "dst_atop", GL_FUNC_ADD, GL_FUNC_ADD, GL_ONE_MINUS_DST_ALPHA, GL_SRC_ALPHA, GL_ONE, GL_ZERO },
152 { "dst_in", GL_FUNC_ADD, GL_FUNC_ADD, GL_ZERO, GL_SRC_ALPHA, GL_ZERO, GL_SRC_ALPHA },
153 { "dst_out", GL_FUNC_ADD, GL_FUNC_ADD, GL_ZERO, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ONE_MINUS_SRC_ALPHA },
154 { "dst_over", GL_FUNC_ADD, GL_FUNC_ADD, GL_ONE_MINUS_DST_ALPHA, GL_ONE, GL_ONE, GL_ONE_MINUS_SRC_ALPHA },
155 { "src_atop", GL_FUNC_ADD, GL_FUNC_ADD, GL_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ONE },
156 { "src_in", GL_FUNC_ADD, GL_FUNC_ADD, GL_DST_ALPHA, GL_ZERO, GL_DST_ALPHA, GL_ZERO },
157 { "src_out", GL_FUNC_ADD, GL_FUNC_ADD, GL_ONE_MINUS_DST_ALPHA, GL_ZERO, GL_ONE_MINUS_DST_ALPHA, GL_ZERO },
158 { "src_over", GL_FUNC_ADD, GL_FUNC_ADD, GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA },
159 { "multiply", GL_FUNC_ADD, GL_FUNC_ADD, GL_DST_COLOR, GL_ZERO, GL_DST_ALPHA, GL_ZERO },
160 { "screen", GL_FUNC_ADD, GL_FUNC_ADD, GL_ONE, GL_ONE_MINUS_SRC_COLOR, GL_ONE, GL_ONE_MINUS_SRC_ALPHA }
163 for (int caseNdx = 0; caseNdx < DE_LENGTH_OF_ARRAY(cases); caseNdx++)
164 addChild(new BlendCase(m_context, cases[caseNdx].name, "", cases[caseNdx].modeRGB, cases[caseNdx].modeAlpha, cases[caseNdx].srcRGB, cases[caseNdx].dstRGB, cases[caseNdx].srcAlpha, cases[caseNdx].dstAlpha));