18852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry/*------------------------------------------------------------------------- 28852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * drawElements Quality Program OpenGL ES 3.1 Module 38852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * ------------------------------------------------- 48852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * 58852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * Copyright 2014 The Android Open Source Project 68852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * 78852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License"); 88852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * you may not use this file except in compliance with the License. 98852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * You may obtain a copy of the License at 108852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * 118852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * http://www.apache.org/licenses/LICENSE-2.0 128852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * 138852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * Unless required by applicable law or agreed to in writing, software 148852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS, 158852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 168852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * See the License for the specific language governing permissions and 178852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * limitations under the License. 188852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * 198852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry *//*! 208852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * \file 218852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * \brief Base class for FBO tests. 228852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry *//*--------------------------------------------------------------------*/ 238852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 248852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry#include "es31fFboTestCase.hpp" 258852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry#include "es31fFboTestUtil.hpp" 268852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry#include "tcuTestLog.hpp" 278852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry#include "tcuImageCompare.hpp" 288852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry#include "tcuRenderTarget.hpp" 298852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry#include "sglrGLContext.hpp" 308852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry#include "sglrReferenceContext.hpp" 318852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry#include "gluStrUtil.hpp" 328852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry#include "gluContextInfo.hpp" 338852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry#include "deRandom.hpp" 348852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry#include "glwEnums.hpp" 358852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry#include "glwFunctions.hpp" 368852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 378852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry#include <algorithm> 388852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 398852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrynamespace deqp 408852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 418852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrynamespace gles31 428852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 438852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrynamespace Functional 448852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 458852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 468852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryusing tcu::TestLog; 478852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryusing std::string; 488852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 498852c82a1ffa4760985c17cc6875d5d521daf343Jarkko PoyryFboTestCase::FboTestCase (Context& context, const char* name, const char* description, bool useScreenSizedViewport) 508852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry : TestCase (context, name, description) 518852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry , m_viewportWidth (useScreenSizedViewport ? context.getRenderTarget().getWidth() : 128) 528852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry , m_viewportHeight (useScreenSizedViewport ? context.getRenderTarget().getHeight() : 128) 538852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 548852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 558852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 568852c82a1ffa4760985c17cc6875d5d521daf343Jarkko PoyryFboTestCase::~FboTestCase (void) 578852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 588852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 598852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 608852c82a1ffa4760985c17cc6875d5d521daf343Jarkko PoyryFboTestCase::IterateResult FboTestCase::iterate (void) 618852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 628852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry glu::RenderContext& renderCtx = TestCase::m_context.getRenderContext(); 638852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const tcu::RenderTarget& renderTarget = renderCtx.getRenderTarget(); 648852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry TestLog& log = m_testCtx.getLog(); 658852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 668852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Viewport. 678852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry de::Random rnd (deStringHash(getName())); 688852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry int width = deMin32(renderTarget.getWidth(), m_viewportWidth); 698852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry int height = deMin32(renderTarget.getHeight(), m_viewportHeight); 708852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry int x = rnd.getInt(0, renderTarget.getWidth() - width); 718852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry int y = rnd.getInt(0, renderTarget.getHeight() - height); 728852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 738852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Surface format and storage is choosen by render(). 748852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry tcu::Surface reference; 758852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry tcu::Surface result; 768852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 778852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Call preCheck() that can throw exception if some requirement is not met. 788852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry preCheck(); 798852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 808852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Rendering with GL driver" << TestLog::EndMessage; 818852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 828852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Render using GLES3.1 838852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry try 848852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 858852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry sglr::GLContext context(renderCtx, log, 0, tcu::IVec4(x, y, width, height)); 868852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry setContext(&context); 878852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry render(result); 888852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 898852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Check error. 908852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry deUint32 err = glGetError(); 918852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry if (err != GL_NO_ERROR) 928852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry throw glu::Error(err, glu::getErrorStr(err).toString().c_str(), DE_NULL, __FILE__, __LINE__); 938852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 948852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry setContext(DE_NULL); 958852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 968852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry catch (const FboTestUtil::FboIncompleteException& e) 978852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 988852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry if (e.getReason() == GL_FRAMEBUFFER_UNSUPPORTED) 998852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 1008852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << e; 1018852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not supported"); 1028852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return STOP; 1038852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 1048852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry else 1058852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry throw; 1068852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 1078852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 1088852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Rendering reference image" << TestLog::EndMessage; 1098852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 1108852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Render reference. 1118852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 1128852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry sglr::ReferenceContextBuffers buffers (tcu::PixelFormat(8,8,8,renderTarget.getPixelFormat().alphaBits?8:0), renderTarget.getDepthBits(), renderTarget.getStencilBits(), width, height); 1138852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry sglr::ReferenceContext context (sglr::ReferenceContextLimits(renderCtx), buffers.getColorbuffer(), buffers.getDepthbuffer(), buffers.getStencilbuffer()); 1148852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 1158852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry setContext(&context); 1168852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry render(reference); 1178852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry setContext(DE_NULL); 1188852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 1198852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 1208852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry bool isOk = compare(reference, result); 1218852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry m_testCtx.setTestResult(isOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL, 1228852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry isOk ? "Pass" : "Image comparison failed"); 1238852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return STOP; 1248852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 1258852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 1268852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrybool FboTestCase::compare (const tcu::Surface& reference, const tcu::Surface& result) 1278852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 1288852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return tcu::fuzzyCompare(m_testCtx.getLog(), "Result", "Image comparison result", reference, result, 0.05f, tcu::COMPARE_LOG_RESULT); 1298852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 1308852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 1318852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryvoid FboTestCase::readPixels (tcu::Surface& dst, int x, int y, int width, int height, const tcu::TextureFormat& format, const tcu::Vec4& scale, const tcu::Vec4& bias) 1328852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 1338852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry FboTestUtil::readPixels(*getCurrentContext(), dst, x, y, width, height, format, scale, bias); 1348852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 1358852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 1368852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryvoid FboTestCase::readPixels (tcu::Surface& dst, int x, int y, int width, int height) 1378852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 1388852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry getCurrentContext()->readPixels(dst, x, y, width, height); 1398852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 1408852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 1418852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryvoid FboTestCase::checkFramebufferStatus (deUint32 target) 1428852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 1438852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry deUint32 status = glCheckFramebufferStatus(target); 1448852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry if (status != GL_FRAMEBUFFER_COMPLETE) 1458852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry throw FboTestUtil::FboIncompleteException(status, __FILE__, __LINE__); 1468852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 1478852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 1488852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryvoid FboTestCase::checkError (void) 1498852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 1508852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry deUint32 err = glGetError(); 1518852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry if (err != GL_NO_ERROR) 1528852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry throw glu::Error((int)err, (string("Got ") + glu::getErrorStr(err).toString()).c_str(), DE_NULL, __FILE__, __LINE__); 1538852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 1548852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 1555ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppestatic bool isRequiredFormat (deUint32 format, glu::RenderContext& renderContext) 1568852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 157cb24d85a6dae33dd3a658b831cd5f0c34918126aPyry Haulos const bool supportsES32 = glu::contextSupports(renderContext.getType(), glu::ApiType::es(3, 2)); 1588852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry switch (format) 1598852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 1608852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Color-renderable formats 1618852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RGBA32I: 1628852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RGBA32UI: 1638852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RGBA16I: 1648852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RGBA16UI: 1658852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RGBA8: 1668852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RGBA8I: 1678852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RGBA8UI: 1688852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_SRGB8_ALPHA8: 1698852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RGB10_A2: 1708852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RGB10_A2UI: 1718852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RGBA4: 1728852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RGB5_A1: 1738852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RGB8: 1748852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RGB565: 1758852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RG32I: 1768852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RG32UI: 1778852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RG16I: 1788852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RG16UI: 1798852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RG8: 1808852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RG8I: 1818852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RG8UI: 1828852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_R32I: 1838852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_R32UI: 1848852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_R16I: 1858852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_R16UI: 1868852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_R8: 1878852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_R8I: 1888852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_R8UI: 1898852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return true; 1908852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 1918852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Depth formats 1928852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_DEPTH_COMPONENT32F: 1938852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_DEPTH_COMPONENT24: 1948852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_DEPTH_COMPONENT16: 1958852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return true; 1968852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 1978852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Depth+stencil formats 1988852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_DEPTH32F_STENCIL8: 1998852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_DEPTH24_STENCIL8: 2008852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return true; 2018852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 2028852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Stencil formats 2038852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_STENCIL_INDEX8: 2048852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return true; 2058852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 2065ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe // Float format 2075ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe case GL_RGBA32F: 2085ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe case GL_R11F_G11F_B10F: 2095ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe case GL_RG32F: 2105ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe case GL_R32F: 211cb24d85a6dae33dd3a658b831cd5f0c34918126aPyry Haulos case GL_RGBA16F: 212cb24d85a6dae33dd3a658b831cd5f0c34918126aPyry Haulos case GL_RG16F: 213cb24d85a6dae33dd3a658b831cd5f0c34918126aPyry Haulos case GL_R16F: 214cb24d85a6dae33dd3a658b831cd5f0c34918126aPyry Haulos return supportsES32; 2155ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe 2168852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry default: 2178852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return false; 2188852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 2198852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 2208852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 2215ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppestatic std::vector<std::string> getEnablingExtensions (deUint32 format, glu::RenderContext& renderContext) 2228852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 223cb24d85a6dae33dd3a658b831cd5f0c34918126aPyry Haulos const bool supportsES32 = glu::contextSupports(renderContext.getType(), glu::ApiType::es(3, 2)); 224653ad0e8a4209754304cbd5b5ceb4fdc7b29c01aPyry Haulos std::vector<std::string> out; 2258852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 2265ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe DE_ASSERT(!isRequiredFormat(format, renderContext)); 2278852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 2288852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry switch (format) 2298852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 230cb24d85a6dae33dd3a658b831cd5f0c34918126aPyry Haulos case GL_RGB16F: 231fa6c55f1e7083c5b5474424af7ed9d7845885915Alexander Galazin out.push_back("GL_EXT_color_buffer_half_float"); 232fa6c55f1e7083c5b5474424af7ed9d7845885915Alexander Galazin break; 233fa6c55f1e7083c5b5474424af7ed9d7845885915Alexander Galazin 234fa6c55f1e7083c5b5474424af7ed9d7845885915Alexander Galazin case GL_RGB32F: 235fa6c55f1e7083c5b5474424af7ed9d7845885915Alexander Galazin out.push_back("GL_EXT_color_buffer_float"); 236fa6c55f1e7083c5b5474424af7ed9d7845885915Alexander Galazin break; 237fa6c55f1e7083c5b5474424af7ed9d7845885915Alexander Galazin 238fa6c55f1e7083c5b5474424af7ed9d7845885915Alexander Galazin case GL_RGBA16F: 2398852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RG16F: 2408852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_R16F: 241cb24d85a6dae33dd3a658b831cd5f0c34918126aPyry Haulos if (!supportsES32) 242cb24d85a6dae33dd3a658b831cd5f0c34918126aPyry Haulos out.push_back("GL_EXT_color_buffer_half_float"); 243cb24d85a6dae33dd3a658b831cd5f0c34918126aPyry Haulos break; 2448852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 2458852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RGBA32F: 2468852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_R11F_G11F_B10F: 2478852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RG32F: 2488852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_R32F: 249cb24d85a6dae33dd3a658b831cd5f0c34918126aPyry Haulos if (!supportsES32) 2505ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe out.push_back("GL_EXT_color_buffer_float"); 2518852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry break; 2528852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 2538852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry default: 2548852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry break; 2558852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 2568852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 2578852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return out; 2588852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 2598852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 2608852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrystatic bool isAnyExtensionSupported (Context& context, const std::vector<std::string>& requiredExts) 2618852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 2628852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry for (std::vector<std::string>::const_iterator iter = requiredExts.begin(); iter != requiredExts.end(); iter++) 2638852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 2648852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const std::string& extension = *iter; 2658852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 2668852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry if (context.getContextInfo().isExtensionSupported(extension.c_str())) 2678852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return true; 2688852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 2698852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 2708852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return false; 2718852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 2728852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 2738852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryvoid FboTestCase::checkFormatSupport (deUint32 sizedFormat) 2748852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 2755ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe const bool isCoreFormat = isRequiredFormat(sizedFormat, m_context.getRenderContext()); 2765ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe const std::vector<std::string> requiredExts = (!isCoreFormat) ? getEnablingExtensions(sizedFormat, m_context.getRenderContext()) : std::vector<std::string>(); 2778852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 2788852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Check that we don't try to use invalid formats. 2798852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry DE_ASSERT(isCoreFormat || !requiredExts.empty()); 2808852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 2818852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry if (!requiredExts.empty() && !isAnyExtensionSupported(m_context, requiredExts)) 2828852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry throw tcu::NotSupportedError("Format not supported"); 2838852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 2848852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 2858852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrystatic int getMinimumSampleCount (deUint32 format) 2868852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 2878852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry switch (format) 2888852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 2898852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Core formats 2908852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RGBA32I: 2918852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RGBA32UI: 2928852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RGBA16I: 2938852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RGBA16UI: 2948852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RGBA8: 2958852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RGBA8I: 2968852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RGBA8UI: 2978852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_SRGB8_ALPHA8: 2988852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RGB10_A2: 2998852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RGB10_A2UI: 3008852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RGBA4: 3018852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RGB5_A1: 3028852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RGB8: 3038852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RGB565: 3048852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RG32I: 3058852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RG32UI: 3068852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RG16I: 3078852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RG16UI: 3088852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RG8: 3098852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RG8I: 3108852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RG8UI: 3118852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_R32I: 3128852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_R32UI: 3138852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_R16I: 3148852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_R16UI: 3158852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_R8: 3168852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_R8I: 3178852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_R8UI: 3188852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_DEPTH_COMPONENT32F: 3198852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_DEPTH_COMPONENT24: 3208852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_DEPTH_COMPONENT16: 3218852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_DEPTH32F_STENCIL8: 3228852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_DEPTH24_STENCIL8: 3238852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_STENCIL_INDEX8: 3248852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return 4; 3258852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 3268852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // GL_EXT_color_buffer_float 3278852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_R11F_G11F_B10F: 3288852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RG16F: 3298852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_R16F: 3308852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return 4; 3318852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 3328852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RGBA32F: 3338852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RGBA16F: 3348852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RG32F: 3358852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_R32F: 3368852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return 0; 3378852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 3388852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // GL_EXT_color_buffer_half_float 3398852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case GL_RGB16F: 3408852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return 0; 3418852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 3428852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry default: 3431cc61b7d03cad727bbddd00cea8d78f4f6cc9047Jarkko Pöyry DE_FATAL("Unknown format"); 3448852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return 0; 3458852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 3468852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 3478852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 3488852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrystatic std::vector<int> querySampleCounts (const glw::Functions& gl, deUint32 format) 3498852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 3508852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry int numSampleCounts = 0; 3518852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry std::vector<int> sampleCounts; 3528852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 3538852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.getInternalformativ(GL_RENDERBUFFER, format, GL_NUM_SAMPLE_COUNTS, 1, &numSampleCounts); 3548852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 3558852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry if (numSampleCounts > 0) 3568852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 3578852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry sampleCounts.resize(numSampleCounts); 3588852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.getInternalformativ(GL_RENDERBUFFER, format, GL_SAMPLES, (glw::GLsizei)sampleCounts.size(), &sampleCounts[0]); 3598852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 3608852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 3618852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to query sample counts for format"); 3628852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 3638852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return sampleCounts; 3648852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 3658852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 3668852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryvoid FboTestCase::checkSampleCount (deUint32 sizedFormat, int numSamples) 3678852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 3688852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const int minSampleCount = getMinimumSampleCount(sizedFormat); 3698852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 3708852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry if (numSamples > minSampleCount) 3718852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 3728852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Exceeds spec-mandated minimum - need to check. 3738852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const std::vector<int> supportedSampleCounts = querySampleCounts(m_context.getRenderContext().getFunctions(), sizedFormat); 3748852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 3758852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry if (std::find(supportedSampleCounts.begin(), supportedSampleCounts.end(), numSamples) == supportedSampleCounts.end()) 3768852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry throw tcu::NotSupportedError("Sample count not supported"); 3778852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 3788852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 3798852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 3808852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryvoid FboTestCase::clearColorBuffer (const tcu::TextureFormat& format, const tcu::Vec4& value) 3818852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 3828852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry FboTestUtil::clearColorBuffer(*getCurrentContext(), format, value); 3838852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 3848852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 3858852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} // Functional 3868852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} // gles31 3878852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} // deqp 388