13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES 2.0 Module 33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * ------------------------------------------------- 43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project 63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License"); 83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License. 93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at 103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * http://www.apache.org/licenses/LICENSE-2.0 123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software 143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS, 153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and 173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License. 183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*! 203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file 213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Blend tests. 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es2fBlendTests.hpp" 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glsFragmentOpUtil.hpp" 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluPixelTransfer.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluStrUtil.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuSurface.hpp" 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuImageCompare.hpp" 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuRenderTarget.hpp" 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestLog.hpp" 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deRandom.hpp" 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "rrFragmentOperations.hpp" 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "sglrReferenceUtils.hpp" 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glw.h" 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <string> 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <vector> 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing gls::FragmentOpUtil::Quad; 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing gls::FragmentOpUtil::IntegerQuad; 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing gls::FragmentOpUtil::QuadRenderer; 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing gls::FragmentOpUtil::ReferenceQuadRenderer; 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing glu::getBlendEquationName; 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing glu::getBlendFactorName; 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::Vec4; 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::UVec4; 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestLog; 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::Surface; 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TextureFormat; 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TextureLevel; 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::string; 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::vector; 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles2 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Functional 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const int MAX_VIEWPORT_WIDTH = 64; 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const int MAX_VIEWPORT_HEIGHT = 64; 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct BlendParams 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLenum equationRGB; 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLenum srcFuncRGB; 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLenum dstFuncRGB; 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLenum equationAlpha; 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLenum srcFuncAlpha; 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLenum dstFuncAlpha; 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 blendColor; 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BlendParams (GLenum equationRGB_, 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLenum srcFuncRGB_, 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLenum dstFuncRGB_, 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLenum equationAlpha_, 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLenum srcFuncAlpha_, 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLenum dstFuncAlpha_, 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 blendColor_) 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : equationRGB (equationRGB_) 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , srcFuncRGB (srcFuncRGB_) 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , dstFuncRGB (dstFuncRGB_) 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , equationAlpha (equationAlpha_) 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , srcFuncAlpha (srcFuncAlpha_) 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , dstFuncAlpha (dstFuncAlpha_) 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , blendColor (blendColor_) 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BlendCase : public TestCase 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BlendCase (Context& context, 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name, 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* desc, 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const vector<BlendParams>& paramSets); 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~BlendCase (void); 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void deinit (void); 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IterateResult iterate (void); 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BlendCase (const BlendCase& other); 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BlendCase& operator= (const BlendCase& other); 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<BlendParams> m_paramSets; 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_curParamSetNdx; 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry QuadRenderer* m_renderer; 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ReferenceQuadRenderer* m_referenceRenderer; 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureLevel* m_refColorBuffer; 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Quad m_firstQuad; 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Quad m_secondQuad; 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IntegerQuad m_firstQuadInt; 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IntegerQuad m_secondQuadInt; 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_viewportW; 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_viewportH; 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1293c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBlendCase::BlendCase (Context& context, 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name, 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* desc, 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const vector<BlendParams>& paramSets) 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase (context, name, desc) 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_paramSets (paramSets) 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_curParamSetNdx (0) 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_renderer (DE_NULL) 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_referenceRenderer (DE_NULL) 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_refColorBuffer (DE_NULL) 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_viewportW (0) 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_viewportH (0) 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(!m_paramSets.empty()); 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int i = 0; i < (int)m_paramSets.size(); i++) 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_paramSets[i].dstFuncRGB != GL_SRC_ALPHA_SATURATE && m_paramSets[i].dstFuncAlpha != GL_SRC_ALPHA_SATURATE); 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BlendCase::init (void) 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool useRGB = m_context.getRenderTarget().getPixelFormat().alphaBits == 0; 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const Vec4 baseGradientColors[4] = 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4(0.0f, 0.5f, 1.0f, 0.5f), 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4(0.5f, 0.0f, 0.5f, 1.0f), 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4(0.5f, 1.0f, 0.5f, 0.0f), 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4(1.0f, 0.5f, 0.0f, 0.5f) 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(m_firstQuad.color) == DE_LENGTH_OF_ARRAY(m_firstQuadInt.color)); 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int i = 0; i < DE_LENGTH_OF_ARRAY(m_firstQuad.color); i++) 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_firstQuad.color[i] = (baseGradientColors[i] - 0.5f) * 0.2f + 0.5f; 1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_firstQuadInt.color[i] = m_firstQuad.color[i]; 1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_secondQuad.color[i] = (Vec4(1.0f) - baseGradientColors[i] - 0.5f) * 1.0f + 0.5f; 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_secondQuadInt.color[i] = m_secondQuad.color[i]; 1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_viewportW = de::min<int>(m_context.getRenderTarget().getWidth(), MAX_VIEWPORT_WIDTH); 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_viewportH = de::min<int>(m_context.getRenderTarget().getHeight(), MAX_VIEWPORT_HEIGHT); 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_firstQuadInt.posA = tcu::IVec2(0, 0); 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_secondQuadInt.posA = tcu::IVec2(0, 0); 1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_firstQuadInt.posB = tcu::IVec2(m_viewportW-1, m_viewportH-1); 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_secondQuadInt.posB = tcu::IVec2(m_viewportW-1, m_viewportH-1); 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(!m_renderer); 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(!m_referenceRenderer); 1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(!m_refColorBuffer); 1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_renderer = new QuadRenderer(m_context.getRenderContext(), glu::GLSL_VERSION_100_ES); 1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_referenceRenderer = new ReferenceQuadRenderer; 1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_refColorBuffer = new TextureLevel(TextureFormat(useRGB ? TextureFormat::RGB : TextureFormat::RGBA, TextureFormat::UNORM_INT8), 1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_viewportW, m_viewportH); 1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_curParamSetNdx = 0; 1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1893c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBlendCase::~BlendCase (void) 1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_renderer; 1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_referenceRenderer; 1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_refColorBuffer; 1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BlendCase::deinit (void) 1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_renderer; 1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_referenceRenderer; 2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_refColorBuffer; 2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_renderer = DE_NULL; 2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_referenceRenderer = DE_NULL; 2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_refColorBuffer = DE_NULL; 2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2073c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBlendCase::IterateResult BlendCase::iterate (void) 2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::Random rnd (deStringHash(getName()) ^ deInt32Hash(m_curParamSetNdx)); 2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int viewportX = rnd.getInt(0, m_context.getRenderTarget().getWidth() - m_viewportW); 2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int viewportY = rnd.getInt(0, m_context.getRenderTarget().getHeight() - m_viewportH); 2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface renderedImg (m_viewportW, m_viewportH); 2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestLog& log (m_testCtx.getLog()); 2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const BlendParams& paramSet = m_paramSets[m_curParamSetNdx]; 2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry rr::FragmentOperationState referenceState; 2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Log the blend parameters. 2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "RGB equation = " << getBlendEquationName(paramSet.equationRGB) << TestLog::EndMessage; 2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "RGB src func = " << getBlendFactorName(paramSet.srcFuncRGB) << TestLog::EndMessage; 2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "RGB dst func = " << getBlendFactorName(paramSet.dstFuncRGB) << TestLog::EndMessage; 2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Alpha equation = " << getBlendEquationName(paramSet.equationAlpha) << TestLog::EndMessage; 2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Alpha src func = " << getBlendFactorName(paramSet.srcFuncAlpha) << TestLog::EndMessage; 2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Alpha dst func = " << getBlendFactorName(paramSet.dstFuncAlpha) << TestLog::EndMessage; 2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Blend color = (" << paramSet.blendColor.x() << ", " << paramSet.blendColor.y() << ", " << paramSet.blendColor.z() << ", " << paramSet.blendColor.w() << ")" << TestLog::EndMessage; 2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Set GL state. 2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_CALL(glBlendEquationSeparate(paramSet.equationRGB, paramSet.equationAlpha)); 2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_CALL(glBlendFuncSeparate(paramSet.srcFuncRGB, paramSet.dstFuncRGB, paramSet.srcFuncAlpha, paramSet.dstFuncAlpha)); 2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_CALL(glBlendColor(paramSet.blendColor.x(), paramSet.blendColor.y(), paramSet.blendColor.z(), paramSet.blendColor.w())); 2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Set reference state. 2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry referenceState.blendRGBState.equation = sglr::rr_util::mapGLBlendEquation(paramSet.equationRGB); 2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry referenceState.blendRGBState.srcFunc = sglr::rr_util::mapGLBlendFunc(paramSet.srcFuncRGB); 2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry referenceState.blendRGBState.dstFunc = sglr::rr_util::mapGLBlendFunc(paramSet.dstFuncRGB); 2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry referenceState.blendAState.equation = sglr::rr_util::mapGLBlendEquation(paramSet.equationAlpha); 2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry referenceState.blendAState.srcFunc = sglr::rr_util::mapGLBlendFunc(paramSet.srcFuncAlpha); 2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry referenceState.blendAState.dstFunc = sglr::rr_util::mapGLBlendFunc(paramSet.dstFuncAlpha); 2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry referenceState.blendColor = paramSet.blendColor; 2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Render with GL. 2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glDisable(GL_BLEND); 2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glViewport(viewportX, viewportY, m_viewportW, m_viewportH); 2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_renderer->render(m_firstQuad); 2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glEnable(GL_BLEND); 2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_renderer->render(m_secondQuad); 2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glFlush(); 2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Render reference. 2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::PixelBufferAccess nullAccess(TextureFormat(), 0, 0, 0, DE_NULL); 2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry referenceState.blendMode = rr::BLENDMODE_NONE; 2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_referenceRenderer->render(gls::FragmentOpUtil::getMultisampleAccess(m_refColorBuffer->getAccess()), nullAccess /* no depth */, nullAccess /* no stencil */, m_firstQuadInt, referenceState); 2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry referenceState.blendMode = rr::BLENDMODE_STANDARD; 2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_referenceRenderer->render(gls::FragmentOpUtil::getMultisampleAccess(m_refColorBuffer->getAccess()), nullAccess /* no depth */, nullAccess /* no stencil */, m_secondQuadInt, referenceState); 2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Read GL image. 2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::readPixels(m_context.getRenderContext(), viewportX, viewportY, renderedImg.getAccess()); 2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Compare images. 2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UVec4 compareThreshold = m_context.getRenderTarget().getPixelFormat().getColorThreshold().toIVec().asUint() 2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * UVec4(5) / UVec4(2) + UVec4(2); // \note Non-scientific ad hoc formula. Need big threshold when few color bits; blending brings extra inaccuracy. 2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool comparePass = tcu::intThresholdCompare(m_testCtx.getLog(), "CompareResult", "Image Comparison Result", m_refColorBuffer->getAccess(), renderedImg.getAccess(), compareThreshold, tcu::COMPARE_LOG_RESULT); 2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Fail now if images don't match. 2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!comparePass) 2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.getTestContext().setTestResult(QP_TEST_RESULT_FAIL, "Image compare failed"); 2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Continue if param sets still remain in m_paramSets; otherwise stop. 2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_curParamSetNdx++; 2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_curParamSetNdx < (int)m_paramSets.size()) 2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return CONTINUE; 2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.getTestContext().setTestResult(QP_TEST_RESULT_PASS, "Passed"); 2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2933c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBlendTests::BlendTests (Context& context) 2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup(context, "blend", "Blend tests") 2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2983c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBlendTests::~BlendTests (void) 2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BlendTests::init (void) 3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry struct EnumGL 3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLenum glValue; 3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* nameStr; 3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const EnumGL blendEquations[] = 3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_FUNC_ADD, "add" }, 3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_FUNC_SUBTRACT, "subtract" }, 3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_FUNC_REVERSE_SUBTRACT, "reverse_subtract" } 3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const EnumGL blendFunctions[] = 3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_ZERO, "zero" }, 3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_ONE, "one" }, 3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_SRC_COLOR, "src_color" }, 3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_ONE_MINUS_SRC_COLOR, "one_minus_src_color" }, 3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_DST_COLOR, "dst_color" }, 3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_ONE_MINUS_DST_COLOR, "one_minus_dst_color" }, 3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_SRC_ALPHA, "src_alpha" }, 3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_ONE_MINUS_SRC_ALPHA, "one_minus_src_alpha" }, 3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_DST_ALPHA, "dst_alpha" }, 3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_ONE_MINUS_DST_ALPHA, "one_minus_dst_alpha" }, 3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_CONSTANT_COLOR, "constant_color" }, 3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_ONE_MINUS_CONSTANT_COLOR, "one_minus_constant_color" }, 3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_CONSTANT_ALPHA, "constant_alpha" }, 3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_ONE_MINUS_CONSTANT_ALPHA, "one_minus_constant_alpha" }, 3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_SRC_ALPHA_SATURATE, "src_alpha_saturate" } 3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const Vec4 defaultBlendColor(0.2f, 0.4f, 0.6f, 0.8f); 3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Test all blend equation, src blend function, dst blend function combinations. RGB and alpha modes are the same. 3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestCaseGroup* group = new TestCaseGroup(m_context, "equation_src_func_dst_func", "Combinations of Blend Equations and Functions"); 3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(group); 3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int equationNdx = 0; equationNdx < DE_LENGTH_OF_ARRAY(blendEquations); equationNdx++) 3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int srcFuncNdx = 0; srcFuncNdx < DE_LENGTH_OF_ARRAY(blendFunctions); srcFuncNdx++) 3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int dstFuncNdx = 0; dstFuncNdx < DE_LENGTH_OF_ARRAY(blendFunctions); dstFuncNdx++) 3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const EnumGL& eq = blendEquations[equationNdx]; 3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const EnumGL& src = blendFunctions[srcFuncNdx]; 3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const EnumGL& dst = blendFunctions[dstFuncNdx]; 3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (dst.glValue == GL_SRC_ALPHA_SATURATE) // SRC_ALPHA_SATURATE is only valid for src func. 3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry string name = string("") + eq.nameStr + "_" + src.nameStr + "_" + dst.nameStr; 3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry string description = string("") + 3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "Equations " + getBlendEquationName(eq.glValue) + 3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ", src funcs " + getBlendFactorName(src.glValue) + 3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ", dst funcs " + getBlendFactorName(dst.glValue); 3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<BlendParams> paramSets; 3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry paramSets.push_back(BlendParams(eq.glValue, src.glValue, dst.glValue, eq.glValue, src.glValue, dst.glValue, defaultBlendColor)); 3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry group->addChild(new BlendCase(m_context, name.c_str(), description.c_str(), paramSets)); 3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Test all RGB src, alpha src and RGB dst, alpha dst combinations. Equations are ADD. 3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // \note For all RGB src, alpha src combinations, also test a couple of different RGBA dst functions, and vice versa. 3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestCaseGroup* mainGroup = new TestCaseGroup(m_context, "rgb_func_alpha_func", "Combinations of RGB and Alpha Functions"); 3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(mainGroup); 3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestCaseGroup* srcGroup = new TestCaseGroup(m_context, "src", "Source functions"); 3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestCaseGroup* dstGroup = new TestCaseGroup(m_context, "dst", "Destination functions"); 3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry mainGroup->addChild(srcGroup); 3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry mainGroup->addChild(dstGroup); 3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int isDstI = 0; isDstI <= 1; isDstI++) 3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int rgbFuncNdx = 0; rgbFuncNdx < DE_LENGTH_OF_ARRAY(blendFunctions); rgbFuncNdx++) 3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int alphaFuncNdx = 0; alphaFuncNdx < DE_LENGTH_OF_ARRAY(blendFunctions); alphaFuncNdx++) 3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool isSrc = isDstI == 0; 3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestCaseGroup* curGroup = isSrc ? srcGroup : dstGroup; 3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const EnumGL& funcRGB = blendFunctions[rgbFuncNdx]; 3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const EnumGL& funcAlpha = blendFunctions[alphaFuncNdx]; 3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* dstOrSrcStr = isSrc ? "src" : "dst"; 3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!isSrc && (funcRGB.glValue == GL_SRC_ALPHA_SATURATE || funcAlpha.glValue == GL_SRC_ALPHA_SATURATE)) // SRC_ALPHA_SATURATE is only valid for src func. 3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry string name = string("") + funcRGB.nameStr + "_" + funcAlpha.nameStr; 3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry string description = string("") + 3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "RGB " + dstOrSrcStr + " func " + getBlendFactorName(funcRGB.glValue) + 3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ", alpha " + dstOrSrcStr + " func " + getBlendFactorName(funcAlpha.glValue); 3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // First, make param sets as if this was a src case. 3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<BlendParams> paramSets; 4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry paramSets.push_back(BlendParams(GL_FUNC_ADD, funcRGB.glValue, GL_ONE, GL_FUNC_ADD, funcAlpha.glValue, GL_ONE, defaultBlendColor)); 4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry paramSets.push_back(BlendParams(GL_FUNC_ADD, funcRGB.glValue, GL_ZERO, GL_FUNC_ADD, funcAlpha.glValue, GL_ZERO, defaultBlendColor)); 4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry paramSets.push_back(BlendParams(GL_FUNC_ADD, funcRGB.glValue, GL_SRC_COLOR, GL_FUNC_ADD, funcAlpha.glValue, GL_SRC_COLOR, defaultBlendColor)); 4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry paramSets.push_back(BlendParams(GL_FUNC_ADD, funcRGB.glValue, GL_DST_COLOR, GL_FUNC_ADD, funcAlpha.glValue, GL_DST_COLOR, defaultBlendColor)); 4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Swap src and dst params if this is a dst case. 4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!isSrc) 4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int i = 0; i < (int)paramSets.size(); i++) 4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::swap(paramSets[i].srcFuncRGB, paramSets[i].dstFuncRGB); 4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::swap(paramSets[i].srcFuncAlpha, paramSets[i].dstFuncAlpha); 4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry curGroup->addChild(new BlendCase(m_context, name.c_str(), description.c_str(), paramSets)); 4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Test all RGB and alpha equation combinations. Src and dst funcs are ONE for both. 4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestCaseGroup* group = new TestCaseGroup(m_context, "rgb_equation_alpha_equation", "Combinations of RGB and Alpha Equation Combinations"); 4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(group); 4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int equationRGBNdx = 0; equationRGBNdx < DE_LENGTH_OF_ARRAY(blendEquations); equationRGBNdx++) 4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int equationAlphaNdx = 0; equationAlphaNdx < DE_LENGTH_OF_ARRAY(blendEquations); equationAlphaNdx++) 4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const EnumGL& eqRGB = blendEquations[equationRGBNdx]; 4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const EnumGL& eqAlpha = blendEquations[equationAlphaNdx]; 4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry string name = string("") + eqRGB.nameStr + "_" + eqAlpha.nameStr; 4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry string description = string("") + 4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "RGB equation " + getBlendEquationName(eqRGB.glValue) + 4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ", alpha equation " + getBlendEquationName(eqAlpha.glValue); 4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<BlendParams> paramSets; 4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry paramSets.push_back(BlendParams(eqRGB.glValue, GL_ONE, GL_ONE, eqAlpha.glValue, GL_ONE, GL_ONE, defaultBlendColor)); 4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry group->addChild(new BlendCase(m_context, name.c_str(), description.c_str(), paramSets)); 4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional 4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles2 4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp 448