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 Framebuffer Object Tests. 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es3fFboRenderTest.hpp" 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "sglrContextUtil.hpp" 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "sglrGLContext.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "sglrReferenceContext.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es3fFboTestUtil.hpp" 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuSurface.hpp" 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuImageCompare.hpp" 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTextureUtil.hpp" 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuVectorUtil.hpp" 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuRenderTarget.hpp" 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluPixelTransfer.hpp" 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluTextureUtil.hpp" 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluStrUtil.hpp" 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deRandom.h" 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deString.h" 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwDefs.hpp" 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp" 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <sstream> 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::vector; 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::string; 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestLog; 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::Vec2; 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::Vec3; 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::Vec4; 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::IVec2; 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::IVec3; 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::IVec4; 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::RGBA; 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::Surface; 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles3 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Functional 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing glw::GLenum; 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace FboTestUtil; 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass FboConfig 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FboConfig (deUint32 buffers_, deUint32 colorType_, deUint32 colorFormat_, deUint32 depthStencilType_, deUint32 depthStencilFormat_, int width_ = 0, int height_ = 0, int samples_ = 0) 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : buffers (buffers_) 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , colorType (colorType_) 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , colorFormat (colorFormat_) 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , depthStencilType (depthStencilType_) 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , depthStencilFormat (depthStencilFormat_) 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , width (width_) 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , height (height_) 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , samples (samples_) 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FboConfig (void) 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : buffers (0) 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , colorType (GL_NONE) 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , colorFormat (GL_NONE) 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , depthStencilType (GL_NONE) 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , depthStencilFormat (GL_NONE) 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , width (0) 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , height (0) 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , samples (0) 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::string getName (void) const; 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 buffers; //!< Buffer bit mask (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|...) 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLenum colorType; //!< GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP, GL_RENDERBUFFER 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLenum colorFormat; //!< Internal format for color buffer texture or renderbuffer 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLenum depthStencilType; 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLenum depthStencilFormat; 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int width; 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int height; 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int samples; 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const char* getTypeName (GLenum type) 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (type) 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_TEXTURE_2D: return "tex2d"; 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_RENDERBUFFER: return "rbo"; 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_FAIL("Unknown type"); 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::string FboConfig::getName (void) const 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::ostringstream name; 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(buffers & GL_COLOR_BUFFER_BIT); 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry name << getTypeName(colorType) << "_" << getFormatName(colorFormat); 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (buffers & GL_DEPTH_BUFFER_BIT) 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry name << "_depth"; 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (buffers & GL_STENCIL_BUFFER_BIT) 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry name << "_stencil"; 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (buffers & (GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT)) 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry name << "_" << getTypeName(depthStencilType) << "_" << getFormatName(depthStencilFormat); 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return name.str(); 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Framebuffer 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Framebuffer (sglr::Context& context, const FboConfig& config, int width, int height, deUint32 fbo = 0, deUint32 colorBuffer = 0, deUint32 depthStencilBuffer = 0); 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~Framebuffer (void); 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const FboConfig& getConfig (void) const { return m_config; } 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 getFramebuffer (void) const { return m_framebuffer; } 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 getColorBuffer (void) const { return m_colorBuffer; } 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 getDepthStencilBuffer (void) const { return m_depthStencilBuffer; } 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void checkCompleteness (void); 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 createTex2D (deUint32 name, GLenum format, int width, int height); 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 createRbo (deUint32 name, GLenum format, int width, int height); 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void destroyBuffer (deUint32 name, GLenum type); 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FboConfig m_config; 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::Context& m_context; 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_framebuffer; 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_colorBuffer; 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_depthStencilBuffer; 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic std::vector<std::string> getEnablingExtensions (deUint32 format) 1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<std::string> out; 1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (format) 1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_RGB16F: 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry out.push_back("GL_EXT_color_buffer_half_float"); 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_RGBA16F: 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_RG16F: 1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_R16F: 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry out.push_back("GL_EXT_color_buffer_half_float"); 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_RGBA32F: 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_RGB32F: 1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_R11F_G11F_B10F: 1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_RG32F: 1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_R32F: 1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry out.push_back("GL_EXT_color_buffer_float"); 1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: 1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return out; 1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic bool isExtensionSupported (sglr::Context& context, const char* name) 1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::istringstream extensions(context.getString(GL_EXTENSIONS)); 1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::string extension; 1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry while (std::getline(extensions, extension, ' ')) 1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (extension == name) 1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return true; 2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return false; 2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic bool isAnyExtensionSupported (sglr::Context& context, const std::vector<std::string>& requiredExts) 2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (requiredExts.empty()) 2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return true; 2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (std::vector<std::string>::const_iterator iter = requiredExts.begin(); iter != requiredExts.end(); iter++) 2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string& extension = *iter; 2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (isExtensionSupported(context, extension.c_str())) 2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return true; 2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return false; 2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate<typename T> 2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic std::string join (const std::vector<T>& list, const std::string& sep) 2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::ostringstream out; 2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (typename std::vector<T>::const_iterator iter = list.begin(); iter != list.end(); iter++) 2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (iter != list.begin()) 2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry out << sep; 2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry out << *iter; 2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return out.str(); 2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void checkColorFormatSupport (sglr::Context& context, deUint32 sizedFormat) 2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::vector<std::string> requiredExts = getEnablingExtensions(sizedFormat); 2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!isAnyExtensionSupported(context, requiredExts)) 2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::string errMsg = "Format not supported, requires " 2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry + ((requiredExts.size() == 1) ? requiredExts[0] : " one of the following: " + join(requiredExts, ", ")); 2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::NotSupportedError(errMsg); 2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2493c827367444ee418f129b2c238299f49d3264554Jarkko PoyryFramebuffer::Framebuffer (sglr::Context& context, const FboConfig& config, int width, int height, deUint32 fbo, deUint32 colorBufferName, deUint32 depthStencilBufferName) 2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : m_config (config) 2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_context (context) 2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_framebuffer (fbo) 2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_colorBuffer (0) 2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_depthStencilBuffer (0) 2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Verify that color format is supported 2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry checkColorFormatSupport(context, config.colorFormat); 2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_framebuffer == 0) 2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.genFramebuffers(1, &m_framebuffer); 2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindFramebuffer(GL_FRAMEBUFFER, m_framebuffer); 2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_config.buffers & (GL_COLOR_BUFFER_BIT)) 2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (m_config.colorType) 2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_TEXTURE_2D: 2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_colorBuffer = createTex2D(colorBufferName, m_config.colorFormat, width, height); 2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_colorBuffer, 0); 2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_RENDERBUFFER: 2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_colorBuffer = createRbo(colorBufferName, m_config.colorFormat, width, height); 2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_colorBuffer); 2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: 2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_FAIL("Unsupported type"); 2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_config.buffers & (GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT)) 2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (m_config.depthStencilType) 2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_TEXTURE_2D: m_depthStencilBuffer = createTex2D(depthStencilBufferName, m_config.depthStencilFormat, width, height); break; 2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_RENDERBUFFER: m_depthStencilBuffer = createRbo(depthStencilBufferName, m_config.depthStencilFormat, width, height); break; 2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: 2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_FAIL("Unsupported type"); 2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < 2; ndx++) 2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 bit = ndx ? GL_STENCIL_BUFFER_BIT : GL_DEPTH_BUFFER_BIT; 2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 point = ndx ? GL_STENCIL_ATTACHMENT : GL_DEPTH_ATTACHMENT; 2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((m_config.buffers & bit) == 0) 2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; /* Not used. */ 3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (m_config.depthStencilType) 3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_TEXTURE_2D: context.framebufferTexture2D(GL_FRAMEBUFFER, point, GL_TEXTURE_2D, m_depthStencilBuffer, 0); break; 3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_RENDERBUFFER: context.framebufferRenderbuffer(GL_FRAMEBUFFER, point, GL_RENDERBUFFER, m_depthStencilBuffer); break; 3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: 3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLenum err = m_context.getError(); 3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (err != GL_NO_ERROR) 3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw glu::Error(err, glu::getErrorStr(err).toString().c_str(), "", __FILE__, __LINE__); 3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindFramebuffer(GL_FRAMEBUFFER, 0); 3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3173c827367444ee418f129b2c238299f49d3264554Jarkko PoyryFramebuffer::~Framebuffer (void) 3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.deleteFramebuffers(1, &m_framebuffer); 3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry destroyBuffer(m_colorBuffer, m_config.colorType); 3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry destroyBuffer(m_depthStencilBuffer, m_config.depthStencilType); 3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid Framebuffer::checkCompleteness (void) 3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.bindFramebuffer(GL_FRAMEBUFFER, m_framebuffer); 3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLenum status = m_context.checkFramebufferStatus(GL_FRAMEBUFFER); 3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.bindFramebuffer(GL_FRAMEBUFFER, 0); 3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (status != GL_FRAMEBUFFER_COMPLETE) 3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw FboIncompleteException(status, __FILE__, __LINE__); 3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3333c827367444ee418f129b2c238299f49d3264554Jarkko PoyrydeUint32 Framebuffer::createTex2D (deUint32 name, GLenum format, int width, int height) 3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (name == 0) 3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.genTextures(1, &name); 3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.bindTexture(GL_TEXTURE_2D, name); 3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.texImage2D(GL_TEXTURE_2D, 0, format, width, height); 3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!deIsPowerOfTwo32(width) || !deIsPowerOfTwo32(height)) 3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Set wrap mode to clamp for NPOT FBOs 3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return name; 3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3543c827367444ee418f129b2c238299f49d3264554Jarkko PoyrydeUint32 Framebuffer::createRbo (deUint32 name, GLenum format, int width, int height) 3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (name == 0) 3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.genRenderbuffers(1, &name); 3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.bindRenderbuffer(GL_RENDERBUFFER, name); 3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.renderbufferStorage(GL_RENDERBUFFER, format, width, height); 3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return name; 3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid Framebuffer::destroyBuffer (deUint32 name, GLenum type) 3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (type == GL_TEXTURE_2D || type == GL_TEXTURE_CUBE_MAP) 3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.deleteTextures(1, &name); 3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (type == GL_RENDERBUFFER) 3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.deleteRenderbuffers(1, &name); 3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(type == GL_NONE); 3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void createMetaballsTex2D (sglr::Context& context, deUint32 name, GLenum format, GLenum dataType, int width, int height) 3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureFormat texFormat = glu::mapGLTransferFormat(format, dataType); 3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureLevel level (texFormat, width, height); 3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::fillWithMetaballs(level.getAccess(), 5, name ^ width ^ height); 3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindTexture(GL_TEXTURE_2D, name); 3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.texImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format, dataType, level.getAccess().getDataPtr()); 3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void createQuadsTex2D (sglr::Context& context, deUint32 name, GLenum format, GLenum dataType, int width, int height) 3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureFormat texFormat = glu::mapGLTransferFormat(format, dataType); 3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureLevel level (texFormat, width, height); 3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::fillWithRGBAQuads(level.getAccess()); 3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindTexture(GL_TEXTURE_2D, name); 3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.texImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format, dataType, level.getAccess().getDataPtr()); 3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass FboRenderCase : public TestCase 4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FboRenderCase (Context& context, const char* name, const char* description, const FboConfig& config); 4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~FboRenderCase (void) {} 4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual IterateResult iterate (void); 4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void render (sglr::Context& fboContext, Surface& dst) = DE_NULL; 4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool compare (const tcu::Surface& reference, const tcu::Surface& result); 4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected: 4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const FboConfig m_config; 4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4143c827367444ee418f129b2c238299f49d3264554Jarkko PoyryFboRenderCase::FboRenderCase (Context& context, const char* name, const char* description, const FboConfig& config) 4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase (context, name, description) 4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_config (config) 4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4203c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTestCase::IterateResult FboRenderCase::iterate (void) 4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4 clearColor = tcu::Vec4(0.125f, 0.25f, 0.5f, 1.0f); 4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::RenderContext& renderCtx = m_context.getRenderContext(); 4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::RenderTarget& renderTarget = renderCtx.getRenderTarget(); 4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestLog& log = m_testCtx.getLog(); 4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* failReason = DE_NULL; 4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Position & size for context 4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deRandom rnd; 4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deRandom_init(&rnd, deStringHash(getName())); 4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int width = deMin32(renderTarget.getWidth(), 128); 4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int height = deMin32(renderTarget.getHeight(), 128); 4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int xMax = renderTarget.getWidth()-width+1; 4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int yMax = renderTarget.getHeight()-height+1; 4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int x = deRandom_getUint32(&rnd) % xMax; 4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int y = deRandom_getUint32(&rnd) % yMax; 4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface gles3Frame (width, height); 4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface refFrame (width, height); 4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLenum gles3Error; 4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLenum refError; 4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Render using GLES3 4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry try 4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::GLContext context(renderCtx, log, sglr::GLCONTEXT_LOG_CALLS, tcu::IVec4(x, y, width, height)); 4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clearColor(clearColor.x(), clearColor.y(), clearColor.z(), clearColor.w()); 4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); 4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry render(context, gles3Frame); // Call actual render func 4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gles3Error = context.getError(); 4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry catch (const FboIncompleteException& e) 4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (e.getReason() == GL_FRAMEBUFFER_UNSUPPORTED) 4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Mark test case as unsupported 4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << e; 4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not supported"); 4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw; // Propagate error 4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Render reference image 4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::ReferenceContextBuffers buffers (tcu::PixelFormat(8,8,8,renderTarget.getPixelFormat().alphaBits?8:0), renderTarget.getDepthBits(), renderTarget.getStencilBits(), width, height); 4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::ReferenceContext context (sglr::ReferenceContextLimits(renderCtx), buffers.getColorbuffer(), buffers.getDepthbuffer(), buffers.getStencilbuffer()); 4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clearColor(clearColor.x(), clearColor.y(), clearColor.z(), clearColor.w()); 4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); 4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry render(context, refFrame); 4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry refError = context.getError(); 4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Compare error codes 4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool errorCodesOk = (gles3Error == refError); 4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!errorCodesOk) 4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::Message << "Error code mismatch: got " << glu::getErrorStr(gles3Error) << ", expected " << glu::getErrorStr(refError) << tcu::TestLog::EndMessage; 4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry failReason = "Got unexpected error"; 4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Compare images 4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool imagesOk = compare(refFrame, gles3Frame); 4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!imagesOk && !failReason) 4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry failReason = "Image comparison failed"; 4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Store test result 4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool isOk = errorCodesOk && imagesOk; 4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(isOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL, 4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry isOk ? "Pass" : failReason); 4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool FboRenderCase::compare (const tcu::Surface& reference, const tcu::Surface& result) 5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::RGBA threshold (tcu::max(getFormatThreshold(m_config.colorFormat), tcu::RGBA(12, 12, 12, 12))); 5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return tcu::bilinearCompare(m_testCtx.getLog(), "ComparisonResult", "Image comparison result", reference.getAccess(), result.getAccess(), threshold, tcu::COMPARE_LOG_RESULT); 5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace FboCases 5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass StencilClearsTest : public FboRenderCase 5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry StencilClearsTest (Context& context, const FboConfig& config); 5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~StencilClearsTest (void) {}; 5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void render (sglr::Context& context, Surface& dst); 5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5223c827367444ee418f129b2c238299f49d3264554Jarkko PoyryStencilClearsTest::StencilClearsTest (Context& context, const FboConfig& config) 5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : FboRenderCase (context, config.getName().c_str(), "Stencil clears", config) 5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid StencilClearsTest::render (sglr::Context& context, Surface& dst) 5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureFormat colorFormat = glu::mapGLInternalFormat(m_config.colorFormat); 5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::DataType fboSamplerType = glu::getSampler2DType(colorFormat); 5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::DataType fboOutputType = getFragmentOutputType(colorFormat); 5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureFormatInfo fboRangeInfo = tcu::getTextureFormatInfo(colorFormat); 5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 fboOutScale = fboRangeInfo.valueMax - fboRangeInfo.valueMin; 5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 fboOutBias = fboRangeInfo.valueMin; 5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture2DShader texToFboShader (DataTypes() << glu::TYPE_SAMPLER_2D, fboOutputType); 5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture2DShader texFromFboShader (DataTypes() << fboSamplerType, glu::TYPE_FLOAT_VEC4); 5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 texToFboShaderID = context.createProgram(&texToFboShader); 5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 texFromFboShaderID = context.createProgram(&texFromFboShader); 5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 metaballsTex = 1; 5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 quadsTex = 2; 5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int width = 128; 5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int height = 128; 5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry texToFboShader.setOutScaleBias(fboOutScale, fboOutBias); 5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry texFromFboShader.setTexScaleBias(0, fboRangeInfo.lookupScale, fboRangeInfo.lookupBias); 5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry createQuadsTex2D(context, quadsTex, GL_RGBA, GL_UNSIGNED_BYTE, width, height); 5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry createMetaballsTex2D(context, metaballsTex, GL_RGBA, GL_UNSIGNED_BYTE, width, height); 5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Framebuffer fbo(context, m_config, width, height); 5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fbo.checkCompleteness(); 5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Bind framebuffer and clear 5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindFramebuffer(GL_FRAMEBUFFER, fbo.getFramebuffer()); 5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.viewport(0, 0, width, height); 5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clearColor(0.0f, 0.0f, 0.0f, 1.0f); 5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); 5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Do stencil clears 5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.enable(GL_SCISSOR_TEST); 5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.scissor(10, 16, 32, 120); 5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clearStencil(1); 5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clear(GL_STENCIL_BUFFER_BIT); 5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.scissor(16, 32, 100, 64); 5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clearStencil(2); 5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clear(GL_STENCIL_BUFFER_BIT); 5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.disable(GL_SCISSOR_TEST); 5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Draw 2 textures with stecil tests 5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.enable(GL_STENCIL_TEST); 5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindTexture(GL_TEXTURE_2D, quadsTex); 5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.stencilFunc(GL_EQUAL, 1, 0xffu); 5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry texToFboShader.setUniforms(context, texToFboShaderID); 5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::drawQuad(context, texToFboShaderID, Vec3(-1.0f, -1.0f, 0.0f), Vec3(+1.0f, +1.0f, 0.0f)); 5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindTexture(GL_TEXTURE_2D, metaballsTex); 5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.stencilFunc(GL_EQUAL, 2, 0xffu); 5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry texToFboShader.setUniforms(context, texToFboShaderID); 5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::drawQuad(context, texToFboShaderID, Vec3(-1.0f, -1.0f, 0.0f), Vec3(+1.0f, +1.0f, 0.0f)); 5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.disable(GL_STENCIL_TEST); 5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (fbo.getConfig().colorType == GL_TEXTURE_2D) 5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindFramebuffer(GL_FRAMEBUFFER, 0); 5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindTexture(GL_TEXTURE_2D, fbo.getColorBuffer()); 5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.viewport(0, 0, context.getWidth(), context.getHeight()); 5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry texFromFboShader.setUniforms(context, texFromFboShaderID); 5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::drawQuad(context, texFromFboShaderID, Vec3(-1.0f, -1.0f, 0.0f), Vec3(1.0f, 1.0f, 0.0f)); 5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.readPixels(dst, 0, 0, context.getWidth(), context.getHeight()); 5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 6013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry readPixels(context, dst, 0, 0, width, height, colorFormat, fboRangeInfo.lookupScale, fboRangeInfo.lookupBias); 6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass SharedColorbufferTest : public FboRenderCase 6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SharedColorbufferTest (Context& context, const FboConfig& config); 6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~SharedColorbufferTest (void) {}; 6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void render (sglr::Context& context, Surface& dst); 6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 6123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6133c827367444ee418f129b2c238299f49d3264554Jarkko PoyrySharedColorbufferTest::SharedColorbufferTest (Context& context, const FboConfig& config) 6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : FboRenderCase (context, config.getName().c_str(), "Shared colorbuffer", config) 6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid SharedColorbufferTest::render (sglr::Context& context, Surface& dst) 6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture2DShader texShader (DataTypes() << glu::TYPE_SAMPLER_2D, glu::TYPE_FLOAT_VEC4); 6213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FlatColorShader flatShader (glu::TYPE_FLOAT_VEC4); 6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 texShaderID = context.createProgram(&texShader); 6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 flatShaderID = context.createProgram(&flatShader); 6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int width = 128; 6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int height = 128; 6273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 quadsTex = 1; 6283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 metaballsTex = 2; 6293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool stencil = (m_config.buffers & GL_STENCIL_BUFFER_BIT) != 0; 6303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.disable(GL_DITHER); 6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Textures 6343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry createQuadsTex2D(context, quadsTex, GL_RGB, GL_UNSIGNED_BYTE, 64, 64); 6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry createMetaballsTex2D(context, metaballsTex, GL_RGBA, GL_UNSIGNED_BYTE, 64, 64); 6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.viewport(0, 0, width, height); 6383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Fbo A 6403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Framebuffer fboA(context, m_config, width, height); 6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fboA.checkCompleteness(); 6423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Fbo B - don't create colorbuffer 6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FboConfig cfg = m_config; 6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry cfg.buffers &= ~GL_COLOR_BUFFER_BIT; 6463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry cfg.colorType = GL_NONE; 6473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry cfg.colorFormat = GL_NONE; 6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Framebuffer fboB(context, cfg, width, height); 6493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Attach color buffer from fbo A 6513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindFramebuffer(GL_FRAMEBUFFER, fboB.getFramebuffer()); 6523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (m_config.colorType) 6533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_TEXTURE_2D: 6553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fboA.getColorBuffer(), 0); 6563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 6573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_RENDERBUFFER: 6593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, fboA.getColorBuffer()); 6603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 6613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: 6633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(DE_FALSE); 6643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Clear depth and stencil in fbo B 6673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clear(GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); 6683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Render quads to fbo 1, with depth 0.0 6703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindFramebuffer(GL_FRAMEBUFFER, fboA.getFramebuffer()); 6713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindTexture(GL_TEXTURE_2D, quadsTex); 6723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clearColor(0.0f, 0.0f, 0.0f, 1.0f); 6733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); 6743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (stencil) 6763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Stencil to 1 in fbo A 6783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clearStencil(1); 6793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clear(GL_STENCIL_BUFFER_BIT); 6803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry texShader.setUniforms(context, texShaderID); 6833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.enable(GL_DEPTH_TEST); 6853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::drawQuad(context, texShaderID, Vec3(-1.0f, -1.0f, 0.0f), Vec3(1.0f, 1.0f, 0.0f)); 6863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.disable(GL_DEPTH_TEST); 6873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Blend metaballs to fbo 2 6893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindFramebuffer(GL_FRAMEBUFFER, fboB.getFramebuffer()); 6903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindTexture(GL_TEXTURE_2D, metaballsTex); 6913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.enable(GL_BLEND); 6923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ONE); 6933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::drawQuad(context, texShaderID, Vec3(-1.0f, -1.0f, 0.0f), Vec3(1.0f, 1.0f, 0.0f)); 6943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Render small quad that is only visible if depth buffer is not shared with fbo A - or there is no depth bits 6963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindTexture(GL_TEXTURE_2D, quadsTex); 6973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.enable(GL_DEPTH_TEST); 6983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::drawQuad(context, texShaderID, Vec3(0.5f, 0.5f, 0.5f), Vec3(1.0f, 1.0f, 0.5f)); 6993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.disable(GL_DEPTH_TEST); 7003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (stencil) 7023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry flatShader.setColor(context, flatShaderID, Vec4(0.0f, 1.0f, 0.0f, 1.0f)); 7043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Clear subset of stencil buffer to 1 7063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.enable(GL_SCISSOR_TEST); 7073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.scissor(10, 10, 12, 25); 7083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clearStencil(1); 7093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clear(GL_STENCIL_BUFFER_BIT); 7103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.disable(GL_SCISSOR_TEST); 7113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Render quad with stencil mask == 1 7133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.enable(GL_STENCIL_TEST); 7143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.stencilFunc(GL_EQUAL, 1, 0xffu); 7153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::drawQuad(context, flatShaderID, Vec3(-1.0f, -1.0f, 0.0f), Vec3(1.0f, 1.0f, 0.0f)); 7163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.disable(GL_STENCIL_TEST); 7173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Get results 7203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (fboA.getConfig().colorType == GL_TEXTURE_2D) 7213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry texShader.setUniforms(context, texShaderID); 7233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindFramebuffer(GL_FRAMEBUFFER, 0); 7253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindTexture(GL_TEXTURE_2D, fboA.getColorBuffer()); 7263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.viewport(0, 0, context.getWidth(), context.getHeight()); 7273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::drawQuad(context, texShaderID, Vec3(-1.0f, -1.0f, 0.0f), Vec3(1.0f, 1.0f, 0.0f)); 7283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.readPixels(dst, 0, 0, context.getWidth(), context.getHeight()); 7293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 7313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry readPixels(context, dst, 0, 0, width, height, glu::mapGLInternalFormat(fboA.getConfig().colorFormat), Vec4(1.0f), Vec4(0.0f)); 7323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 7333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7343c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass SharedColorbufferClearsTest : public FboRenderCase 7353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7363c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 7373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SharedColorbufferClearsTest (Context& context, const FboConfig& config); 7383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~SharedColorbufferClearsTest (void) {} 7393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void render (sglr::Context& context, Surface& dst); 7413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 7423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7433c827367444ee418f129b2c238299f49d3264554Jarkko PoyrySharedColorbufferClearsTest::SharedColorbufferClearsTest (Context& context, const FboConfig& config) 7443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : FboRenderCase (context, config.getName().c_str(), "Shared colorbuffer clears", config) 7453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 7473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7483c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid SharedColorbufferClearsTest::render (sglr::Context& context, Surface& dst) 7493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureFormat colorFormat = glu::mapGLInternalFormat(m_config.colorFormat); 7513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::DataType fboSamplerType = glu::getSampler2DType(colorFormat); 7523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int width = 128; 7533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int height = 128; 7543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 colorbuffer = 1; 7553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Check for format support. 7573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry checkColorFormatSupport(context, m_config.colorFormat); 7583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Single colorbuffer 7603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_config.colorType == GL_TEXTURE_2D) 7613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindTexture(GL_TEXTURE_2D, colorbuffer); 7633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.texImage2D(GL_TEXTURE_2D, 0, m_config.colorFormat, width, height); 7643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 7653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 7663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 7683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_config.colorType == GL_RENDERBUFFER); 7703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindRenderbuffer(GL_RENDERBUFFER, colorbuffer); 7713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.renderbufferStorage(GL_RENDERBUFFER, m_config.colorFormat, width, height); 7723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Multiple framebuffers sharing the colorbuffer 7753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int fbo = 1; fbo <= 3; fbo++) 7763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindFramebuffer(GL_FRAMEBUFFER, fbo); 7783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_config.colorType == GL_TEXTURE_2D) 7803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0); 7813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 7823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorbuffer); 7833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindFramebuffer(GL_FRAMEBUFFER, 1); 7863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Check completeness 7883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLenum status = context.checkFramebufferStatus(GL_FRAMEBUFFER); 7903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (status != GL_FRAMEBUFFER_COMPLETE) 7913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw FboIncompleteException(status, __FILE__, __LINE__); 7923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Render to them 7953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.viewport(0, 0, width, height); 7963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clearColor(0.0f, 0.0f, 1.0f, 1.0f); 7973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clear(GL_COLOR_BUFFER_BIT); 7983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.enable(GL_SCISSOR_TEST); 8003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindFramebuffer(GL_FRAMEBUFFER, 2); 8023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clearColor(0.6f, 0.0f, 0.0f, 1.0f); 8033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.scissor(10, 10, 64, 64); 8043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clear(GL_COLOR_BUFFER_BIT); 8053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clearColor(0.0f, 0.6f, 0.0f, 1.0f); 8063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.scissor(60, 60, 40, 20); 8073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clear(GL_COLOR_BUFFER_BIT); 8083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindFramebuffer(GL_FRAMEBUFFER, 3); 8103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clearColor(0.0f, 0.0f, 0.6f, 1.0f); 8113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.scissor(20, 20, 100, 10); 8123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clear(GL_COLOR_BUFFER_BIT); 8133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindFramebuffer(GL_FRAMEBUFFER, 1); 8153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clearColor(0.6f, 0.0f, 0.6f, 1.0f); 8163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.scissor(20, 20, 5, 100); 8173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clear(GL_COLOR_BUFFER_BIT); 8183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.disable(GL_SCISSOR_TEST); 8203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_config.colorType == GL_TEXTURE_2D) 8223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 8233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture2DShader shader(DataTypes() << fboSamplerType, glu::TYPE_FLOAT_VEC4); 8243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 shaderID = context.createProgram(&shader); 8253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry shader.setUniforms(context, shaderID); 8273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindFramebuffer(GL_FRAMEBUFFER, 0); 8293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.viewport(0, 0, context.getWidth(), context.getHeight()); 8303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::drawQuad(context, shaderID, Vec3(-0.9f, -0.9f, 0.0f), Vec3(0.9f, 0.9f, 0.0f)); 8313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.readPixels(dst, 0, 0, context.getWidth(), context.getHeight()); 8323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 8333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 8343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry readPixels(context, dst, 0, 0, width, height, colorFormat, Vec4(1.0f), Vec4(0.0f)); 8353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 8363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8373c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass SharedDepthStencilTest : public FboRenderCase 8383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8393c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 8403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SharedDepthStencilTest (Context& context, const FboConfig& config); 8413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~SharedDepthStencilTest (void) {}; 8423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static bool isConfigSupported (const FboConfig& config); 8443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void render (sglr::Context& context, Surface& dst); 8453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 8463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8473c827367444ee418f129b2c238299f49d3264554Jarkko PoyrySharedDepthStencilTest::SharedDepthStencilTest (Context& context, const FboConfig& config) 8483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : FboRenderCase (context, config.getName().c_str(), "Shared depth/stencilbuffer", config) 8493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 8513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8523c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool SharedDepthStencilTest::isConfigSupported (const FboConfig& config) 8533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return (config.buffers & (GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT)) != 0; 8553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 8563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8573c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid SharedDepthStencilTest::render (sglr::Context& context, Surface& dst) 8583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture2DShader texShader (DataTypes() << glu::TYPE_SAMPLER_2D, glu::TYPE_FLOAT_VEC4); 8603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FlatColorShader flatShader (glu::TYPE_FLOAT_VEC4); 8613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 texShaderID = context.createProgram(&texShader); 8623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 flatShaderID = context.createProgram(&flatShader); 8633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int width = 128; 8643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int height = 128; 8653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// bool depth = (m_config.buffers & GL_DEPTH_BUFFER_BIT) != 0; 8663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool stencil = (m_config.buffers & GL_STENCIL_BUFFER_BIT) != 0; 8673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Textures 8693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 metaballsTex = 5; 8703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 quadsTex = 6; 8713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry createMetaballsTex2D(context, metaballsTex, GL_RGB, GL_UNSIGNED_BYTE, 64, 64); 8723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry createQuadsTex2D(context, quadsTex, GL_RGB, GL_UNSIGNED_BYTE, 64, 64); 8733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.viewport(0, 0, width, height); 8753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Fbo A 8773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Framebuffer fboA(context, m_config, width, height); 8783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fboA.checkCompleteness(); 8793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Fbo B 8813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FboConfig cfg = m_config; 8823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry cfg.buffers &= ~(GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); 8833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry cfg.depthStencilType = GL_NONE; 8843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry cfg.depthStencilFormat = GL_NONE; 8853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Framebuffer fboB(context, cfg, width, height); 8863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Bind depth/stencil buffers from fbo A to fbo B 8883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindFramebuffer(GL_FRAMEBUFFER, fboB.getFramebuffer()); 8893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < 2; ndx++) 8903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 8913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 bit = ndx ? GL_STENCIL_BUFFER_BIT : GL_DEPTH_BUFFER_BIT; 8923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 point = ndx ? GL_STENCIL_ATTACHMENT : GL_DEPTH_ATTACHMENT; 8933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((m_config.buffers & bit) == 0) 8953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 8963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (m_config.depthStencilType) 8983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 8993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_TEXTURE_2D: context.framebufferTexture2D(GL_FRAMEBUFFER, point, GL_TEXTURE_2D, fboA.getDepthStencilBuffer(), 0); break; 9003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_RENDERBUFFER: context.framebufferRenderbuffer(GL_FRAMEBUFFER, point, GL_RENDERBUFFER, fboA.getDepthStencilBuffer()); break; 9013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: 9023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_FAIL("Not implemented"); 9033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 9043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 9053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Setup uniforms 9073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry texShader.setUniforms(context, texShaderID); 9083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Clear color to red and stencil to 1 in fbo B. 9103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clearColor(1.0f, 0.0f, 0.0f, 1.0f); 9113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clearStencil(1); 9123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); 9133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.enable(GL_DEPTH_TEST); 9153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Render quad to fbo A 9173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindFramebuffer(GL_FRAMEBUFFER, fboA.getFramebuffer()); 9183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindTexture(GL_TEXTURE_2D, quadsTex); 9193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::drawQuad(context, texShaderID, Vec3(-1.0f, -1.0f, 0.0f), Vec3(1.0f, 1.0f, 0.0f)); 9203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (stencil) 9223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 9233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Clear subset of stencil buffer to 0 in fbo A 9243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.enable(GL_SCISSOR_TEST); 9253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.scissor(10, 10, 12, 25); 9263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clearStencil(0); 9273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clear(GL_STENCIL_BUFFER_BIT); 9283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.disable(GL_SCISSOR_TEST); 9293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 9303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Render metaballs to fbo B 9323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindFramebuffer(GL_FRAMEBUFFER, fboB.getFramebuffer()); 9333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindTexture(GL_TEXTURE_2D, metaballsTex); 9343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::drawQuad(context, texShaderID, Vec3(-1.0f, -1.0f, -1.0f), Vec3(1.0f, 1.0f, 1.0f)); 9353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.disable(GL_DEPTH_TEST); 9373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (stencil) 9393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 9403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Render quad with stencil mask == 0 9413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.enable(GL_STENCIL_TEST); 9423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.stencilFunc(GL_EQUAL, 0, 0xffu); 9433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.useProgram(flatShaderID); 9443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry flatShader.setColor(context, flatShaderID, Vec4(0.0f, 1.0f, 0.0f, 1.0f)); 9453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::drawQuad(context, flatShaderID, Vec3(-1.0f, -1.0f, 0.0f), Vec3(+1.0f, +1.0f, 0.0f)); 9463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.disable(GL_STENCIL_TEST); 9473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 9483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_config.colorType == GL_TEXTURE_2D) 9503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 9513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Render both to screen 9523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindFramebuffer(GL_FRAMEBUFFER, 0); 9533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.viewport(0, 0, context.getWidth(), context.getHeight()); 9543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindTexture(GL_TEXTURE_2D, fboA.getColorBuffer()); 9553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::drawQuad(context, texShaderID, Vec3(-1.0f, -1.0f, 0.0f), Vec3(0.0f, 1.0f, 0.0f)); 9563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindTexture(GL_TEXTURE_2D, fboB.getColorBuffer()); 9573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::drawQuad(context, texShaderID, Vec3(0.0f, -1.0f, 0.0f), Vec3(1.0f, 1.0f, 0.0f)); 9583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.readPixels(dst, 0, 0, context.getWidth(), context.getHeight()); 9603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 9613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 9623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 9633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Read results from fbo B 9643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry readPixels(context, dst, 0, 0, width, height, glu::mapGLInternalFormat(m_config.colorFormat), Vec4(1.0f), Vec4(0.0f)); 9653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 9663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 9673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#if 0 9693c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexSubImageAfterRenderTest : public FboRenderCase 9703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9713c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 9723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TexSubImageAfterRenderTest (Context& context, const FboConfig& config); 9733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~TexSubImageAfterRenderTest (void) {} 9743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void render (sglr::Context& context, Surface& dst); 9763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 9773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9783c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTexSubImageAfterRenderTest::TexSubImageAfterRenderTest (Context& context, const FboConfig& config) 9793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : FboRenderCase(context, (string("after_render_") + config.getName()).c_str(), "TexSubImage after rendering to texture", config) 9803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 9823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9833c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TexSubImageAfterRenderTest::render (sglr::Context& context, Surface& dst) 9843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using sglr::TexturedQuadOp; 9863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool isRGBA = true; 9883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Surface fourQuads(Surface::PIXELFORMAT_RGB, 64, 64); 9903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::SurfaceUtil::fillWithFourQuads(fourQuads); 9913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Surface metaballs(isRGBA ? Surface::PIXELFORMAT_RGBA : Surface::PIXELFORMAT_RGB, 64, 64); 9933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::SurfaceUtil::fillWithMetaballs(metaballs, 5, 3); 9943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 fourQuadsTex = 1; 9963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindTexture(GL_TEXTURE_2D, fourQuadsTex); 9973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 9983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.texImage2D(GL_TEXTURE_2D, 0, GL_RGB, fourQuads); 9993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindFramebuffer(GL_FRAMEBUFFER, 1); 10013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 fboTex = 2; 10033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindTexture(GL_TEXTURE_2D, fboTex); 10043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.texImage2D(GL_TEXTURE_2D, 0, isRGBA ? GL_RGBA : GL_RGB, 128, 128); 10053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 10063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fboTex, 0); 10073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Render to fbo 10093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.viewport(0, 0, 128, 128); 10103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindTexture(GL_TEXTURE_2D, fourQuadsTex); 10113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.draw(TexturedQuadOp(-1.0f, -1.0f, 1.0f, 1.0f, 0)); 10123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Update texture using TexSubImage2D 10143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindTexture(GL_TEXTURE_2D, fboTex); 10153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.texSubImage2D(GL_TEXTURE_2D, 0, 32, 32, metaballs); 10163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Draw to screen 10183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindFramebuffer(GL_FRAMEBUFFER, 0); 10193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.viewport(0, 0, context.getWidth(), context.getHeight()); 10203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.draw(TexturedQuadOp(-1.0f, -1.0f, 1.0f, 1.0f, 0)); 10213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.readPixels(dst, 0, 0, context.getWidth(), context.getHeight()); 10223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 10233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10243c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexSubImageBetweenRenderTest : public FboRenderCase 10253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 10263c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 10273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TexSubImageBetweenRenderTest (Context& context, const FboConfig& config); 10283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~TexSubImageBetweenRenderTest (void) {} 10293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void render (sglr::Context& context, Surface& dst); 10313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 10323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10333c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTexSubImageBetweenRenderTest::TexSubImageBetweenRenderTest (Context& context, const FboConfig& config) 10343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : FboRenderCase(context, (string("between_render_") + config.getName()).c_str(), "TexSubImage between rendering calls", config) 10353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 10363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 10373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TexSubImageBetweenRenderTest::render (sglr::Context& context, Surface& dst) 10393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 10403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using sglr::TexturedQuadOp; 10413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using sglr::BlendTextureOp; 10423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool isRGBA = true; 10443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Surface fourQuads(Surface::PIXELFORMAT_RGB, 64, 64); 10463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::SurfaceUtil::fillWithFourQuads(fourQuads); 10473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Surface metaballs(isRGBA ? Surface::PIXELFORMAT_RGBA : Surface::PIXELFORMAT_RGB, 64, 64); 10493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::SurfaceUtil::fillWithMetaballs(metaballs, 5, 3); 10503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Surface metaballs2(Surface::PIXELFORMAT_RGBA, 64, 64); 10523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::SurfaceUtil::fillWithMetaballs(metaballs2, 5, 4); 10533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 metaballsTex = 3; 10553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindTexture(GL_TEXTURE_2D, metaballsTex); 10563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 10573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, metaballs2); 10583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 fourQuadsTex = 1; 10603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindTexture(GL_TEXTURE_2D, fourQuadsTex); 10613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 10623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.texImage2D(GL_TEXTURE_2D, 0, GL_RGB, fourQuads); 10633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindFramebuffer(GL_FRAMEBUFFER, 1); 10653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 fboTex = 2; 10673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindTexture(GL_TEXTURE_2D, fboTex); 10683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.texImage2D(GL_TEXTURE_2D, 0, isRGBA ? GL_RGBA : GL_RGB, 128, 128); 10693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 10703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fboTex, 0); 10713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Render to fbo 10733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.viewport(0, 0, 128, 128); 10743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindTexture(GL_TEXTURE_2D, fourQuadsTex); 10753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.draw(TexturedQuadOp(-1.0f, -1.0f, 1.0f, 1.0f, 0)); 10763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Update texture using TexSubImage2D 10783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindTexture(GL_TEXTURE_2D, fboTex); 10793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.texSubImage2D(GL_TEXTURE_2D, 0, 32, 32, metaballs); 10803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Render again to fbo 10823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindTexture(GL_TEXTURE_2D, metaballsTex); 10833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.draw(BlendTextureOp(0)); 10843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Draw to screen 10863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindFramebuffer(GL_FRAMEBUFFER, 0); 10873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.viewport(0, 0, context.getWidth(), context.getHeight()); 10883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindTexture(GL_TEXTURE_2D, fboTex); 10893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.draw(TexturedQuadOp(-1.0f, -1.0f, 1.0f, 1.0f, 0)); 10903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.readPixels(dst, 0, 0, context.getWidth(), context.getHeight()); 10923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 10933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif 10943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10953c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ResizeTest : public FboRenderCase 10963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 10973c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 10983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ResizeTest (Context& context, const FboConfig& config); 10993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~ResizeTest (void) {} 11003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void render (sglr::Context& context, Surface& dst); 11023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 11033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11043c827367444ee418f129b2c238299f49d3264554Jarkko PoyryResizeTest::ResizeTest (Context& context, const FboConfig& config) 11053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : FboRenderCase (context, config.getName().c_str(), "Resize framebuffer", config) 11063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 11073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 11083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11093c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ResizeTest::render (sglr::Context& context, Surface& dst) 11103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 11113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureFormat colorFormat = glu::mapGLInternalFormat(m_config.colorFormat); 11123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::DataType fboSamplerType = glu::getSampler2DType(colorFormat); 11133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::DataType fboOutputType = getFragmentOutputType(colorFormat); 11143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureFormatInfo fboRangeInfo = tcu::getTextureFormatInfo(colorFormat); 11153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 fboOutScale = fboRangeInfo.valueMax - fboRangeInfo.valueMin; 11163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 fboOutBias = fboRangeInfo.valueMin; 11173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture2DShader texToFboShader (DataTypes() << glu::TYPE_SAMPLER_2D, fboOutputType); 11193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture2DShader texFromFboShader (DataTypes() << fboSamplerType, glu::TYPE_FLOAT_VEC4); 11203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FlatColorShader flatShader (fboOutputType); 11213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 texToFboShaderID = context.createProgram(&texToFboShader); 11223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 texFromFboShaderID = context.createProgram(&texFromFboShader); 11233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 flatShaderID = context.createProgram(&flatShader); 11243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 quadsTex = 1; 11263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 metaballsTex = 2; 11273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool depth = (m_config.buffers & GL_DEPTH_BUFFER_BIT) != 0; 11283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool stencil = (m_config.buffers & GL_STENCIL_BUFFER_BIT) != 0; 11293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int initialWidth = 128; 11303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int initialHeight = 128; 11313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int newWidth = 64; 11323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int newHeight = 32; 11333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry texToFboShader.setOutScaleBias(fboOutScale, fboOutBias); 11353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry texFromFboShader.setTexScaleBias(0, fboRangeInfo.lookupScale, fboRangeInfo.lookupBias); 11363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry createQuadsTex2D(context, quadsTex, GL_RGB, GL_UNSIGNED_BYTE, 64, 64); 11383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry createMetaballsTex2D(context, metaballsTex, GL_RGB, GL_UNSIGNED_BYTE, 32, 32); 11393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Framebuffer fbo(context, m_config, initialWidth, initialHeight); 11413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fbo.checkCompleteness(); 11423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Setup shaders 11443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry texToFboShader.setUniforms (context, texToFboShaderID); 11453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry texFromFboShader.setUniforms(context, texFromFboShaderID); 11463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry flatShader.setColor (context, flatShaderID, Vec4(0.0f, 1.0f, 0.0f, 1.0f) * fboOutScale + fboOutBias); 11473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Render quads 11493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindFramebuffer(GL_FRAMEBUFFER, fbo.getFramebuffer()); 11503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.viewport(0, 0, initialWidth, initialHeight); 11513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry clearColorBuffer(context, colorFormat, tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f)); 11523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clear(GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); 11533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindTexture(GL_TEXTURE_2D, quadsTex); 11543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::drawQuad(context, texToFboShaderID, Vec3(-1.0f, -1.0f, 0.0f), Vec3(1.0f, 1.0f, 0.0f)); 11553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (fbo.getConfig().colorType == GL_TEXTURE_2D) 11573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 11583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Render fbo to screen 11593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindFramebuffer(GL_FRAMEBUFFER, 0); 11603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.viewport(0, 0, context.getWidth(), context.getHeight()); 11613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindTexture(GL_TEXTURE_2D, fbo.getColorBuffer()); 11623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::drawQuad(context, texFromFboShaderID, Vec3(-1.0f, -1.0f, 0.0f), Vec3(1.0f, 1.0f, 0.0f)); 11633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Restore binding 11653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindFramebuffer(GL_FRAMEBUFFER, fbo.getFramebuffer()); 11663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 11673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Resize buffers 11693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (fbo.getConfig().colorType) 11703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 11713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_TEXTURE_2D: 11723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindTexture(GL_TEXTURE_2D, fbo.getColorBuffer()); 11733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.texImage2D(GL_TEXTURE_2D, 0, fbo.getConfig().colorFormat, newWidth, newHeight); 11743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 11753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_RENDERBUFFER: 11773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindRenderbuffer(GL_RENDERBUFFER, fbo.getColorBuffer()); 11783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.renderbufferStorage(GL_RENDERBUFFER, fbo.getConfig().colorFormat, newWidth, newHeight); 11793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 11803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: 11823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(DE_FALSE); 11833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 11843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (depth || stencil) 11863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 11873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (fbo.getConfig().depthStencilType) 11883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 11893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_TEXTURE_2D: 11903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindTexture(GL_TEXTURE_2D, fbo.getDepthStencilBuffer()); 11913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.texImage2D(GL_TEXTURE_2D, 0, fbo.getConfig().depthStencilFormat, newWidth, newHeight); 11923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 11933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_RENDERBUFFER: 11953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindRenderbuffer(GL_RENDERBUFFER, fbo.getDepthStencilBuffer()); 11963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.renderbufferStorage(GL_RENDERBUFFER, fbo.getConfig().depthStencilFormat, newWidth, newHeight); 11973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 11983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: 12003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 12013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 12023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 12033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Render to resized fbo 12053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.viewport(0, 0, newWidth, newHeight); 12063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry clearColorBuffer(context, colorFormat, tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f)); 12073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clear(GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); 12083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.enable(GL_DEPTH_TEST); 12103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindTexture(GL_TEXTURE_2D, metaballsTex); 12123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::drawQuad(context, texToFboShaderID, Vec3(-1.0f, -1.0f, 0.0f), Vec3(+1.0f, +1.0f, 0.0f)); 12133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindTexture(GL_TEXTURE_2D, quadsTex); 12153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::drawQuad(context, texToFboShaderID, Vec3(0.0f, 0.0f, -1.0f), Vec3(+1.0f, +1.0f, 1.0f)); 12163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.disable(GL_DEPTH_TEST); 12183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (stencil) 12203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 12213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.enable(GL_SCISSOR_TEST); 12223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clearStencil(1); 12233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.scissor(10, 10, 5, 15); 12243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clear(GL_STENCIL_BUFFER_BIT); 12253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.disable(GL_SCISSOR_TEST); 12263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.enable(GL_STENCIL_TEST); 12283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.stencilFunc(GL_EQUAL, 1, 0xffu); 12293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::drawQuad(context, flatShaderID, Vec3(-1.0f, -1.0f, 0.0f), Vec3(+1.0f, +1.0f, 0.0f)); 12303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.disable(GL_STENCIL_TEST); 12313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 12323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_config.colorType == GL_TEXTURE_2D) 12343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 12353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindFramebuffer(GL_FRAMEBUFFER, 0); 12363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.viewport(0, 0, context.getWidth(), context.getHeight()); 12373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.bindTexture(GL_TEXTURE_2D, fbo.getColorBuffer()); 12383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::drawQuad(context, texFromFboShaderID, Vec3(-0.5f, -0.5f, 0.0f), Vec3(0.5f, 0.5f, 0.0f)); 12393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.readPixels(dst, 0, 0, context.getWidth(), context.getHeight()); 12403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 12413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 12423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry readPixels(context, dst, 0, 0, newWidth, newHeight, colorFormat, fboRangeInfo.lookupScale, fboRangeInfo.lookupBias); 12433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 12443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12453c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass RecreateBuffersTest : public FboRenderCase 12463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 12473c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 12483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RecreateBuffersTest (Context& context, const FboConfig& config, deUint32 buffers, bool rebind); 12493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~RecreateBuffersTest (void) {} 12503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void render (sglr::Context& context, Surface& dst); 12523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12533c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 12543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_buffers; 12553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool m_rebind; 12563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 12573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12583c827367444ee418f129b2c238299f49d3264554Jarkko PoyryRecreateBuffersTest::RecreateBuffersTest (Context& context, const FboConfig& config, deUint32 buffers, bool rebind) 12593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : FboRenderCase (context, (string(config.getName()) + (rebind ? "" : "_no_rebind")).c_str(), "Recreate buffers", config) 12603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_buffers (buffers) 12613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_rebind (rebind) 12623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 12633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 12643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12653c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid RecreateBuffersTest::render (sglr::Context& ctx, Surface& dst) 12663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 12673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureFormat colorFormat = glu::mapGLInternalFormat(m_config.colorFormat); 12683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::DataType fboSamplerType = glu::getSampler2DType(colorFormat); 12693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::DataType fboOutputType = getFragmentOutputType(colorFormat); 12703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureFormatInfo fboRangeInfo = tcu::getTextureFormatInfo(colorFormat); 12713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 fboOutScale = fboRangeInfo.valueMax - fboRangeInfo.valueMin; 12723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 fboOutBias = fboRangeInfo.valueMin; 12733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture2DShader texToFboShader (DataTypes() << glu::TYPE_SAMPLER_2D, fboOutputType); 12753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture2DShader texFromFboShader (DataTypes() << fboSamplerType, glu::TYPE_FLOAT_VEC4); 12763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FlatColorShader flatShader (fboOutputType); 12773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 texToFboShaderID = ctx.createProgram(&texToFboShader); 12783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 texFromFboShaderID = ctx.createProgram(&texFromFboShader); 12793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 flatShaderID = ctx.createProgram(&flatShader); 12803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int width = 128; 12823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int height = 128; 12833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 metaballsTex = 1; 12843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 quadsTex = 2; 12853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool stencil = (m_config.buffers & GL_STENCIL_BUFFER_BIT) != 0; 12863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry createQuadsTex2D(ctx, quadsTex, GL_RGB, GL_UNSIGNED_BYTE, 64, 64); 12883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry createMetaballsTex2D(ctx, metaballsTex, GL_RGB, GL_UNSIGNED_BYTE, 64, 64); 12893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Framebuffer fbo(ctx, m_config, width, height); 12913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fbo.checkCompleteness(); 12923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Setup shaders 12943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry texToFboShader.setOutScaleBias(fboOutScale, fboOutBias); 12953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry texFromFboShader.setTexScaleBias(0, fboRangeInfo.lookupScale, fboRangeInfo.lookupBias); 12963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry texToFboShader.setUniforms (ctx, texToFboShaderID); 12973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry texFromFboShader.setUniforms(ctx, texFromFboShaderID); 12983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry flatShader.setColor (ctx, flatShaderID, Vec4(0.0f, 0.0f, 1.0f, 1.0f) * fboOutScale + fboOutBias); 12993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Draw scene 13013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.bindFramebuffer(GL_FRAMEBUFFER, fbo.getFramebuffer()); 13023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.viewport(0, 0, width, height); 13033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry clearColorBuffer(ctx, colorFormat, tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f)); 13043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.clear(GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); 13053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.enable(GL_DEPTH_TEST); 13073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.bindTexture(GL_TEXTURE_2D, quadsTex); 13093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::drawQuad(ctx, texToFboShaderID, Vec3(-1.0f, -1.0f, 0.0f), Vec3(1.0f, 1.0f, 0.0f)); 13103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.disable(GL_DEPTH_TEST); 13123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (stencil) 13143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 13153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.enable(GL_SCISSOR_TEST); 13163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.scissor(width/4, height/4, width/2, height/2); 13173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.clearStencil(1); 13183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.clear(GL_STENCIL_BUFFER_BIT); 13193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.disable(GL_SCISSOR_TEST); 13203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 13213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Recreate buffers 13233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!m_rebind) 13243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.bindFramebuffer(GL_FRAMEBUFFER, 0); 13253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT((m_buffers & (GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT)) == 0 || 13273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (m_buffers & (GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT)) == (m_config.buffers & (GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT))); 13283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Recreate. 13303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < 2; ndx++) 13313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 13323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 bit = ndx == 0 ? GL_COLOR_BUFFER_BIT 13333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : (GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); 13343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 type = ndx == 0 ? fbo.getConfig().colorType 13353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : fbo.getConfig().depthStencilType; 13363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 format = ndx == 0 ? fbo.getConfig().colorFormat 13373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : fbo.getConfig().depthStencilFormat; 13383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 buf = ndx == 0 ? fbo.getColorBuffer() 13393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : fbo.getDepthStencilBuffer(); 13403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((m_buffers & bit) == 0) 13423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 13433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (type) 13453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 13463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_TEXTURE_2D: 13473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.deleteTextures(1, &buf); 13483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.bindTexture(GL_TEXTURE_2D, buf); 13493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.texImage2D(GL_TEXTURE_2D, 0, format, width, height); 13503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 13513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 13523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 13533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_RENDERBUFFER: 13553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.deleteRenderbuffers(1, &buf); 13563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.bindRenderbuffer(GL_RENDERBUFFER, buf); 13573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.renderbufferStorage(GL_RENDERBUFFER, format, width, height); 13583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 13593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: 13613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 13623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 13633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 13643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Rebind. 13663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_rebind) 13673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 13683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < 3; ndx++) 13693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 13703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 bit = ndx == 0 ? GL_COLOR_BUFFER_BIT : 13713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ndx == 1 ? GL_DEPTH_BUFFER_BIT : 13723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ndx == 2 ? GL_STENCIL_BUFFER_BIT : 0; 13733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 point = ndx == 0 ? GL_COLOR_ATTACHMENT0 : 13743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ndx == 1 ? GL_DEPTH_ATTACHMENT : 13753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ndx == 2 ? GL_STENCIL_ATTACHMENT : 0; 13763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 type = ndx == 0 ? fbo.getConfig().colorType 13773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : fbo.getConfig().depthStencilType; 13783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 buf = ndx == 0 ? fbo.getColorBuffer() 13793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : fbo.getDepthStencilBuffer(); 13803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((m_buffers & bit) == 0) 13823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 13833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (type) 13853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 13863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_TEXTURE_2D: 13873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.framebufferTexture2D(GL_FRAMEBUFFER, point, GL_TEXTURE_2D, buf, 0); 13883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 13893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_RENDERBUFFER: 13913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.framebufferRenderbuffer(GL_FRAMEBUFFER, point, GL_RENDERBUFFER, buf); 13923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 13933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: 13953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 13963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 13973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 13983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 13993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!m_rebind) 14013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.bindFramebuffer(GL_FRAMEBUFFER, fbo.getFramebuffer()); 14023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.clearStencil(0); 14043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.clear(m_buffers & (GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT)); // \note Clear only buffers that were re-created 14053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_buffers & GL_COLOR_BUFFER_BIT) 14063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 14073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Clearing of integer buffers is undefined so do clearing by rendering flat color. 14083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::drawQuad(ctx, flatShaderID, Vec3(-1.0f, -1.0f, 0.0f), Vec3(1.0f, 1.0f, 0.0f)); 14093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 14103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.enable(GL_DEPTH_TEST); 14123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (stencil) 14143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 14153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // \note Stencil test enabled only if we have stencil buffer 14163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.enable(GL_STENCIL_TEST); 14173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.stencilFunc(GL_EQUAL, 0, 0xffu); 14183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 14193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.bindTexture(GL_TEXTURE_2D, metaballsTex); 14203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::drawQuad(ctx, texToFboShaderID, Vec3(-1.0f, -1.0f, 1.0f), Vec3(1.0f, 1.0f, -1.0f)); 14213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (stencil) 14223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.disable(GL_STENCIL_TEST); 14233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.disable(GL_DEPTH_TEST); 14253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (fbo.getConfig().colorType == GL_TEXTURE_2D) 14273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 14283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Unbind fbo 14293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.bindFramebuffer(GL_FRAMEBUFFER, 0); 14303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Draw to screen 14323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.bindTexture(GL_TEXTURE_2D, fbo.getColorBuffer()); 14333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.viewport(0, 0, ctx.getWidth(), ctx.getHeight()); 14343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::drawQuad(ctx, texFromFboShaderID, Vec3(-1.0f, -1.0f, 0.0f), Vec3(1.0f, 1.0f, 0.0f)); 14353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Read from screen 14373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.readPixels(dst, 0, 0, ctx.getWidth(), ctx.getHeight()); 14383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 14393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 14403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 14413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Read from fbo 14423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry readPixels(ctx, dst, 0, 0, width, height, colorFormat, fboRangeInfo.lookupScale, fboRangeInfo.lookupBias); 14433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 14443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 14453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // FboCases 14473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14483c827367444ee418f129b2c238299f49d3264554Jarkko PoyryFboRenderTestGroup::FboRenderTestGroup (Context& context) 14493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup(context, "render", "Rendering Tests") 14503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 14513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 14523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14533c827367444ee418f129b2c238299f49d3264554Jarkko PoyryFboRenderTestGroup::~FboRenderTestGroup (void) 14543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 14553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 14563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14573c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid FboRenderTestGroup::init (void) 14583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 14593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const deUint32 objectTypes[] = 14603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 14613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GL_TEXTURE_2D, 14623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GL_RENDERBUFFER 14633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 14643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum FormatType 14663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 14673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FORMATTYPE_FLOAT = 0, 14683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FORMATTYPE_FIXED, 14693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FORMATTYPE_INT, 14703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FORMATTYPE_UINT, 14713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FORMATTYPE_LAST 14733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 14743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Required by specification. 14763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct 14773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 14783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 format; 14793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FormatType type; 14803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } colorFormats[] = 14813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 14823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_RGBA32F, FORMATTYPE_FLOAT }, 14833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_RGBA32I, FORMATTYPE_INT }, 14843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_RGBA32UI, FORMATTYPE_UINT }, 14853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_RGBA16F, FORMATTYPE_FLOAT }, 14863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_RGBA16I, FORMATTYPE_INT }, 14873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_RGBA16UI, FORMATTYPE_UINT }, 14883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_RGB16F, FORMATTYPE_FLOAT }, 14893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_RGBA8, FORMATTYPE_FIXED }, 14903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_RGBA8I, FORMATTYPE_INT }, 14913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_RGBA8UI, FORMATTYPE_UINT }, 14923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_SRGB8_ALPHA8, FORMATTYPE_FIXED }, 14933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_RGB10_A2, FORMATTYPE_FIXED }, 14943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_RGB10_A2UI, FORMATTYPE_UINT }, 14953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_RGBA4, FORMATTYPE_FIXED }, 14963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_RGB5_A1, FORMATTYPE_FIXED }, 14973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_RGB8, FORMATTYPE_FIXED }, 14983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_RGB565, FORMATTYPE_FIXED }, 14993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_R11F_G11F_B10F, FORMATTYPE_FLOAT }, 15003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_RG32F, FORMATTYPE_FLOAT }, 15013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_RG32I, FORMATTYPE_INT }, 15023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_RG32UI, FORMATTYPE_UINT }, 15033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_RG16F, FORMATTYPE_FLOAT }, 15043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_RG16I, FORMATTYPE_INT }, 15053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_RG16UI, FORMATTYPE_UINT }, 15063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_RG8, FORMATTYPE_FLOAT }, 15073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_RG8I, FORMATTYPE_INT }, 15083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_RG8UI, FORMATTYPE_UINT }, 15093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_R32F, FORMATTYPE_FLOAT }, 15103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_R32I, FORMATTYPE_INT }, 15113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_R32UI, FORMATTYPE_UINT }, 15123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_R16F, FORMATTYPE_FLOAT }, 15133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_R16I, FORMATTYPE_INT }, 15143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_R16UI, FORMATTYPE_UINT }, 15153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_R8, FORMATTYPE_FLOAT }, 15163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_R8I, FORMATTYPE_INT }, 15173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_R8UI, FORMATTYPE_UINT } 15183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 15193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct 15213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 15223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 format; 15233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool depth; 15243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool stencil; 15253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } depthStencilFormats[] = 15263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 15273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_DEPTH_COMPONENT32F, true, false }, 15283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_DEPTH_COMPONENT24, true, false }, 15293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_DEPTH_COMPONENT16, true, false }, 15303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_DEPTH32F_STENCIL8, true, true }, 15313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_DEPTH24_STENCIL8, true, true }, 15323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_STENCIL_INDEX8, false, true } 15333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 15343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using namespace FboCases; 15363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .stencil_clear 15383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* stencilClearGroup = new tcu::TestCaseGroup(m_testCtx, "stencil_clear", "Stencil buffer clears"); 15393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(stencilClearGroup); 15403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int fmtNdx = 0; fmtNdx < DE_LENGTH_OF_ARRAY(depthStencilFormats); fmtNdx++) 15413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 15423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 colorType = GL_TEXTURE_2D; 15433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 stencilType = GL_RENDERBUFFER; 15443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 colorFmt = GL_RGBA8; 15453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!depthStencilFormats[fmtNdx].stencil) 15473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 15483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FboConfig config(GL_COLOR_BUFFER_BIT|GL_STENCIL_BUFFER_BIT, colorType, colorFmt, stencilType, depthStencilFormats[fmtNdx].format); 15503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stencilClearGroup->addChild(new StencilClearsTest(m_context, config)); 15513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 15523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .shared_colorbuffer_clear 15543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* sharedColorbufferClearGroup = new tcu::TestCaseGroup(m_testCtx, "shared_colorbuffer_clear", "Shader colorbuffer clears"); 15553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(sharedColorbufferClearGroup); 15563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int colorFmtNdx = 0; colorFmtNdx < DE_LENGTH_OF_ARRAY(colorFormats); colorFmtNdx++) 15573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 15583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Clearing of integer buffers is undefined. 15593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (colorFormats[colorFmtNdx].type == FORMATTYPE_INT || colorFormats[colorFmtNdx].type == FORMATTYPE_UINT) 15603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 15613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(objectTypes); typeNdx++) 15633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 15643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FboConfig config(GL_COLOR_BUFFER_BIT, objectTypes[typeNdx], colorFormats[colorFmtNdx].format, GL_NONE, GL_NONE); 15653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sharedColorbufferClearGroup->addChild(new SharedColorbufferClearsTest(m_context, config)); 15663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 15673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 15683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .shared_colorbuffer 15703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* sharedColorbufferGroup = new tcu::TestCaseGroup(m_testCtx, "shared_colorbuffer", "Shared colorbuffer tests"); 15713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(sharedColorbufferGroup); 15723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int colorFmtNdx = 0; colorFmtNdx < DE_LENGTH_OF_ARRAY(colorFormats); colorFmtNdx++) 15733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 15743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 depthStencilType = GL_RENDERBUFFER; 15753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 depthStencilFormat = GL_DEPTH24_STENCIL8; 15763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Blending with integer buffers and fp32 targets is not supported. 15783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (colorFormats[colorFmtNdx].type == FORMATTYPE_INT || 15793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry colorFormats[colorFmtNdx].type == FORMATTYPE_UINT || 15803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry colorFormats[colorFmtNdx].format == GL_RGBA32F || 15813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry colorFormats[colorFmtNdx].format == GL_RGB32F || 15823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry colorFormats[colorFmtNdx].format == GL_RG32F || 15833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry colorFormats[colorFmtNdx].format == GL_R32F) 15843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 15853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(objectTypes); typeNdx++) 15873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 15883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FboConfig colorOnlyConfig (GL_COLOR_BUFFER_BIT, objectTypes[typeNdx], colorFormats[colorFmtNdx].format, GL_NONE, GL_NONE); 15893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FboConfig colorDepthConfig (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT, objectTypes[typeNdx], colorFormats[colorFmtNdx].format, depthStencilType, depthStencilFormat); 15903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FboConfig colorDepthStencilConfig (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT, objectTypes[typeNdx], colorFormats[colorFmtNdx].format, depthStencilType, depthStencilFormat); 15913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sharedColorbufferGroup->addChild(new SharedColorbufferTest(m_context, colorOnlyConfig)); 15933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sharedColorbufferGroup->addChild(new SharedColorbufferTest(m_context, colorDepthConfig)); 15943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sharedColorbufferGroup->addChild(new SharedColorbufferTest(m_context, colorDepthStencilConfig)); 15953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 15963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 15973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .shared_depth_stencil 15993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* sharedDepthStencilGroup = new tcu::TestCaseGroup(m_testCtx, "shared_depth_stencil", "Shared depth and stencil buffers"); 16003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(sharedDepthStencilGroup); 16013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int fmtNdx = 0; fmtNdx < DE_LENGTH_OF_ARRAY(depthStencilFormats); fmtNdx++) 16023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 16033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 colorType = GL_TEXTURE_2D; 16043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 colorFmt = GL_RGBA8; 16053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool depth = depthStencilFormats[fmtNdx].depth; 16063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool stencil = depthStencilFormats[fmtNdx].stencil; 16073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!depth) 16093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; // Not verified. 16103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Depth and stencil: both rbo and textures 16123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(objectTypes); typeNdx++) 16133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 16143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FboConfig config(GL_COLOR_BUFFER_BIT|(depth ? GL_DEPTH_BUFFER_BIT : 0)|(stencil ? GL_STENCIL_BUFFER_BIT : 0), colorType, colorFmt, objectTypes[typeNdx], depthStencilFormats[fmtNdx].format); 16153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sharedDepthStencilGroup->addChild(new SharedDepthStencilTest(m_context, config)); 16163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 16173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 16183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .resize 16203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* resizeGroup = new tcu::TestCaseGroup(m_testCtx, "resize", "FBO resize tests"); 16213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(resizeGroup); 16223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int colorFmtNdx = 0; colorFmtNdx < DE_LENGTH_OF_ARRAY(colorFormats); colorFmtNdx++) 16233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 16243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 colorFormat = colorFormats[colorFmtNdx].format; 16253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Color-only. 16273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(objectTypes); typeNdx++) 16283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 16293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FboConfig config(GL_COLOR_BUFFER_BIT, objectTypes[typeNdx], colorFormat, GL_NONE, GL_NONE); 16303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry resizeGroup->addChild(new ResizeTest(m_context, config)); 16313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 16323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // For selected color formats tests depth & stencil variants. 16343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (colorFormat == GL_RGBA8 || colorFormat == GL_RGBA16F) 16353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 16363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int depthStencilFmtNdx = 0; depthStencilFmtNdx < DE_LENGTH_OF_ARRAY(depthStencilFormats); depthStencilFmtNdx++) 16373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 16383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 colorType = GL_TEXTURE_2D; 16393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool depth = depthStencilFormats[depthStencilFmtNdx].depth; 16403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool stencil = depthStencilFormats[depthStencilFmtNdx].stencil; 16413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Depth and stencil: both rbo and textures 16433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(objectTypes); typeNdx++) 16443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 16453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!depth && objectTypes[typeNdx] != GL_RENDERBUFFER) 16463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; // Not supported. 16473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FboConfig config(GL_COLOR_BUFFER_BIT|(depth ? GL_DEPTH_BUFFER_BIT : 0)|(stencil ? GL_STENCIL_BUFFER_BIT : 0), 16493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry colorType, colorFormat, 16503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry objectTypes[typeNdx], depthStencilFormats[depthStencilFmtNdx].format); 16513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry resizeGroup->addChild(new ResizeTest(m_context, config)); 16523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 16533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 16543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 16553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 16563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .recreate_color 16583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* recreateColorGroup = new tcu::TestCaseGroup(m_testCtx, "recreate_color", "Recreate colorbuffer tests"); 16593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(recreateColorGroup); 16603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int colorFmtNdx = 0; colorFmtNdx < DE_LENGTH_OF_ARRAY(colorFormats); colorFmtNdx++) 16613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 16623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 colorFormat = colorFormats[colorFmtNdx].format; 16633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 depthStencilFormat = GL_DEPTH24_STENCIL8; 16643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 depthStencilType = GL_RENDERBUFFER; 16653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Color-only. 16673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(objectTypes); typeNdx++) 16683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 16693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FboConfig config(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT, objectTypes[typeNdx], colorFormat, depthStencilType, depthStencilFormat); 16703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry recreateColorGroup->addChild(new RecreateBuffersTest(m_context, config, GL_COLOR_BUFFER_BIT, true /* rebind */)); 16713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 16723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 16733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .recreate_depth_stencil 16753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* recreateDepthStencilGroup = new tcu::TestCaseGroup(m_testCtx, "recreate_depth_stencil", "Recreate depth and stencil buffers"); 16763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(recreateDepthStencilGroup); 16773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int fmtNdx = 0; fmtNdx < DE_LENGTH_OF_ARRAY(depthStencilFormats); fmtNdx++) 16783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 16793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 colorType = GL_TEXTURE_2D; 16803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 colorFmt = GL_RGBA8; 16813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool depth = depthStencilFormats[fmtNdx].depth; 16823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool stencil = depthStencilFormats[fmtNdx].stencil; 16833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Depth and stencil: both rbo and textures 16853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(objectTypes); typeNdx++) 16863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 16873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!depth && objectTypes[typeNdx] != GL_RENDERBUFFER) 16883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 16893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FboConfig config(GL_COLOR_BUFFER_BIT|(depth ? GL_DEPTH_BUFFER_BIT : 0)|(stencil ? GL_STENCIL_BUFFER_BIT : 0), colorType, colorFmt, objectTypes[typeNdx], depthStencilFormats[fmtNdx].format); 16913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry recreateDepthStencilGroup->addChild(new RecreateBuffersTest(m_context, config, (depth ? GL_DEPTH_BUFFER_BIT : 0)|(stencil ? GL_STENCIL_BUFFER_BIT : 0), true /* rebind */)); 16923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 16933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 16943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 16953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional 16973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles3 16983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp 1699