13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES 3.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 Prerequisite tests. 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es3fPrerequisiteTests.hpp" 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deRandom.h" 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuRGBA.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuSurface.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTextureUtil.hpp" 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestLog.hpp" 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuRenderTarget.hpp" 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluPixelTransfer.hpp" 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluStateReset.hpp" 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glw.h" 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::RGBA; 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::Surface; 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestLog; 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles3 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Functional 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass StateResetCase : public TestCase 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry StateResetCase (Context& context); 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~StateResetCase (void); 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual TestCase::IterateResult iterate (void); 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 553c827367444ee418f129b2c238299f49d3264554Jarkko PoyryStateResetCase::StateResetCase (Context& context) 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase(context, "state_reset", "State Reset Test") 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 603c827367444ee418f129b2c238299f49d3264554Jarkko PoyryStateResetCase::~StateResetCase (void) 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 643c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTestCase::IterateResult StateResetCase::iterate (void) 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry try 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::resetState(m_context.getRenderContext()); 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry catch (const tcu::TestError& e) 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << e; 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail"); 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return TestCase::STOP; 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ClearColorCase : public TestCase 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ClearColorCase (Context& context); 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~ClearColorCase (void); 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual TestCase::IterateResult iterate (void); 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RGBA m_clearColor; 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_numIters; 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_curIter; 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 933c827367444ee418f129b2c238299f49d3264554Jarkko PoyryClearColorCase::ClearColorCase (Context& context) 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase (context, "clear_color", "glClearColor test") 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_numIters (10) 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_curIter (0) 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1003c827367444ee418f129b2c238299f49d3264554Jarkko PoyryClearColorCase::~ClearColorCase (void) 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1043c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTestCase::IterateResult ClearColorCase::iterate (void) 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int r = 0; 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int g = 0; 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int b = 0; 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int a = 255; 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (m_curIter) 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 0: 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Black, skip 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 1: 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry r = 255; 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry g = 255; 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry b = 255; 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 2: 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry r = 255; 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 3: 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry g = 255; 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 4: 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry b = 255; 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deRandom rnd; 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deRandom_init(&rnd, deInt32Hash(m_curIter)); 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry r = (int)(deRandom_getUint32(&rnd) & 0xFF); 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry g = (int)(deRandom_getUint32(&rnd) & 0xFF); 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry b = (int)(deRandom_getUint32(&rnd) & 0xFF); 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry a = (int)(deRandom_getUint32(&rnd) & 0xFF); 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glClearColor(r/255.0f, g/255.0f, b/255.0f, a/255.0f); 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glClear(GL_COLOR_BUFFER_BIT); 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_MSG("CLES2 ClearColor failed."); 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return (++m_curIter < m_numIters) ? CONTINUE : STOP; 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ReadPixelsCase : public TestCase 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ReadPixelsCase (Context& context); 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~ReadPixelsCase (void); 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual TestCase::IterateResult iterate (void); 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_numIters; 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_curIter; 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1633c827367444ee418f129b2c238299f49d3264554Jarkko PoyryReadPixelsCase::ReadPixelsCase (Context& context) 1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase(context, "read_pixels", "Read pixels test") 1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_numIters(20) 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_curIter(0) 1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1703c827367444ee418f129b2c238299f49d3264554Jarkko PoyryReadPixelsCase::~ReadPixelsCase (void) 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1743c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTestCase::IterateResult ReadPixelsCase::iterate (void) 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::RenderTarget& renderTarget = m_context.getRenderTarget(); 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::PixelFormat pixelFormat = renderTarget.getPixelFormat(); 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int targetWidth = renderTarget.getWidth(); 1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int targetHeight = renderTarget.getHeight(); 1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int x = 0; 1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int y = 0; 1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int imageWidth = 0; 1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int imageHeight = 0; 1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deRandom rnd; 1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deRandom_init(&rnd, deInt32Hash(m_curIter)); 1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (m_curIter) 1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 0: 1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Fullscreen 1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry x = 0; 1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry y = 0; 1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry imageWidth = targetWidth; 1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry imageHeight = targetHeight; 1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 1: 1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Upper left corner 1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry x = 0; 2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry y = 0; 2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry imageWidth = targetWidth / 2; 2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry imageHeight = targetHeight / 2; 2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 2: 2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Lower right corner 2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry x = targetWidth / 2; 2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry y = targetHeight / 2; 2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry imageWidth = targetWidth - x; 2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry imageHeight = targetHeight - y; 2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: 2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry x = deRandom_getUint32(&rnd) % (targetWidth - 1); 2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry y = deRandom_getUint32(&rnd) % (targetHeight - 1); 2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry imageWidth = 1 + (deRandom_getUint32(&rnd) % (targetWidth - x - 1)); 2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry imageHeight = 1 + (deRandom_getUint32(&rnd) % (targetHeight - y - 1)); 2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Surface resImage(imageWidth, imageHeight); 2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Surface refImage(imageWidth, imageHeight); 2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Surface diffImage(imageWidth, imageHeight); 2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int r = (int)(deRandom_getUint32(&rnd) & 0xFF); 2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int g = (int)(deRandom_getUint32(&rnd) & 0xFF); 2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int b = (int)(deRandom_getUint32(&rnd) & 0xFF); 2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::clear(refImage.getAccess(), tcu::IVec4(r, g, b, 255)); 2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glClearColor(r/255.0f, g/255.0f, b/255.0f, 1.0f); 2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glClear(GL_COLOR_BUFFER_BIT); 2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::readPixels(m_context.getRenderContext(), x, y, resImage.getAccess()); 2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_MSG("glReadPixels() failed."); 2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RGBA colorThreshold = pixelFormat.getColorThreshold(); 2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RGBA matchColor(0, 255, 0, 255); 2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RGBA diffColor(255, 0, 0, 255); 2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool isImageOk = true; 2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int j = 0; j < imageHeight; j++) 2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int i = 0; i < imageWidth; i++) 2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RGBA resRGBA = resImage.getPixel(i, j); 2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RGBA refRGBA = refImage.getPixel(i, j); 2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool isPixelOk = compareThreshold(refRGBA, resRGBA, colorThreshold); 2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry diffImage.setPixel(i, j, isPixelOk ? matchColor : diffColor); 2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry isImageOk = isImageOk && isPixelOk; 2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (isImageOk) 2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); 2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail"); 2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << TestLog::ImageSet("Result", "Resulting framebuffer") 2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::Image("Result", "Resulting framebuffer", resImage) 2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::Image("Reference", "Reference image", refImage) 2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::Image("DiffMask", "Failing pixels", diffImage) 2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::EndImageSet; 2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return (++m_curIter < m_numIters) ? CONTINUE : STOP; 2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2683c827367444ee418f129b2c238299f49d3264554Jarkko PoyryPrerequisiteTests::PrerequisiteTests (Context& context) 2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup(context, "prerequisite", "Prerequisite Test Cases") 2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2733c827367444ee418f129b2c238299f49d3264554Jarkko PoyryPrerequisiteTests::~PrerequisiteTests (void) 2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid PrerequisiteTests::init (void) 2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new StateResetCase(m_context)); 2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new ClearColorCase(m_context)); 2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new ReadPixelsCase(m_context)); 2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional 2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles3 2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp 287