13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#ifndef _GLSFBOUTIL_HPP 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define _GLSFBOUTIL_HPP 33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL (ES) Module 63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * ----------------------------------------------- 73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project 93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License"); 113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License. 123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at 133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * http://www.apache.org/licenses/LICENSE-2.0 153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software 173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS, 183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and 203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License. 213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*! 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Utilities for framebuffer objects. 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluRenderContext.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluContextInfo.hpp" 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwDefs.hpp" 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp" 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwFunctions.hpp" 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluTextureUtil.hpp" 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestLog.hpp" 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuDefs.hpp" 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <map> 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <set> 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <vector> 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <algorithm> 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <iterator> 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gls 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//! A pair of iterators to present a range. 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//! \note This must be POD to allow static initialization. 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//! \todo [2013-12-03 lauri] Move this to decpp? 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename T> 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Range 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typedef const T* const_iterator; 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const T* m_begin; 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const T* m_end; 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const T* begin (void) const { return m_begin; } 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const T* end (void) const { return m_end; } 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define GLS_ARRAY_RANGE(ARR) { DE_ARRAY_BEGIN(ARR), DE_ARRAY_END(ARR) } 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define GLS_NULL_RANGE { DE_NULL, DE_NULL } 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//! A pair type that, unlike stl::pair, is POD so it can be statically initialized. 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename T1, typename T2> 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Pair 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typedef T1 first_type; 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typedef T2 second_type; 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry T1 first; 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry T2 second; 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace FboUtil 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//! Configurations for framebuffer objects and their attachments. 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass FboVerifier; 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass FboBuilder; 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytypedef deUint32 FormatKey; 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define GLS_UNSIZED_FORMATKEY(FORMAT, TYPE) \ 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (deUint32(TYPE) << 16 | deUint32(FORMAT)) 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytypedef Range<FormatKey> FormatKeys; 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct ImageFormat 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLenum format; 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry //! Type if format is unsized, GL_NONE if sized. 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLenum unsizedType; 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 99b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry bool operator< (const ImageFormat& other) const 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return (format < other.format || 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (format == other.format && unsizedType < other.unsizedType)); 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static ImageFormat none (void) 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ImageFormat fmt = { GL_NONE, GL_NONE }; 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return fmt; 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 112b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyrystd::ostream& operator<< (std::ostream& stream, const ImageFormat& format); 113b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic inline ImageFormat formatKeyInfo(FormatKey key) 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ImageFormat fmt = { key & 0xffff, key >> 16 }; 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return fmt; 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum FormatFlags 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ANY_FORMAT = 0, 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry COLOR_RENDERABLE = 1 << 0, 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DEPTH_RENDERABLE = 1 << 1, 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry STENCIL_RENDERABLE = 1 << 2, 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RENDERBUFFER_VALID = 1 << 3, 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TEXTURE_VALID = 1 << 4, 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry REQUIRED_RENDERABLE = 1 << 5, //< Without this, renderability is allowed, not required. 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic inline FormatFlags operator|(FormatFlags f1, FormatFlags f2) 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return FormatFlags(deUint32(f1) | deUint32(f2)); 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1363c827367444ee418f129b2c238299f49d3264554Jarkko PoyryFormatFlags formatFlag(glw::GLenum context); 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytypedef std::set<ImageFormat> Formats; 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass FormatDB 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 143b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry void addCoreFormat (ImageFormat format, FormatFlags flags); 144b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry void addExtensionFormat (ImageFormat format, FormatFlags flags, const std::set<std::string>& requiredExtensions); 145b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry 146b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry Formats getFormats (FormatFlags requirements) const; 147b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry bool isKnownFormat (ImageFormat format) const; 148b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry FormatFlags getFormatInfo (ImageFormat format) const; 149b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry std::set<std::set<std::string> > getFormatFeatureExtensions (ImageFormat format, FormatFlags requirements) const; 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 152b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry struct ExtensionInfo 153b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry { 154b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry FormatFlags flags; 155b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry std::set<std::string> requiredExtensions; 156b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry 157b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry bool operator< (const ExtensionInfo& other) const; 158b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry }; 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 160b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry typedef std::map<ImageFormat, FormatFlags> FormatMap; 161b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry typedef std::map<ImageFormat, std::set<ExtensionInfo> > FormatExtensionMap; 162b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry 163b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry FormatMap m_formatFlags; 164b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry FormatExtensionMap m_formatExtensions; 1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytypedef Pair<FormatFlags, FormatKeys> FormatEntry; 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytypedef Range<FormatEntry> FormatEntries; 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// \todo [2013-12-20 lauri] It turns out that format properties in extensions 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// are actually far too fine-grained for this bundling to be reasonable, 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// especially given the syntactic cumbersomeness of static arrays. It's better 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// to list each entry separately. 1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct FormatExtEntry 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* extensions; 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 flags; 1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Range<FormatKey> formats; 1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytypedef Range<FormatExtEntry> FormatExtEntries; 1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1844e5dbcc5c6db2408970d1e9bec76c3936aeee204Jarkko Pöyry// Check support for GL_* and DEQP_* extensions 1854e5dbcc5c6db2408970d1e9bec76c3936aeee204Jarkko Pöyrybool checkExtensionSupport (const glu::RenderContext& ctx, const std::string& extension); 1864e5dbcc5c6db2408970d1e9bec76c3936aeee204Jarkko Pöyry 187bf845c4e3814b85e1a3e23a27f50c8f888f4bd2dJarkko Pöyry// Accepts GL_* and DEQP_* extension strings and converts DEQP_* strings to a human readable string 188bf845c4e3814b85e1a3e23a27f50c8f888f4bd2dJarkko Pöyrystd::string getExtensionDescription (const std::string& extensionName); 189bf845c4e3814b85e1a3e23a27f50c8f888f4bd2dJarkko Pöyry 190bf845c4e3814b85e1a3e23a27f50c8f888f4bd2dJarkko Pöyryvoid addFormats (FormatDB& db, FormatEntries stdFmts); 191bf845c4e3814b85e1a3e23a27f50c8f888f4bd2dJarkko Pöyryvoid addExtFormats (FormatDB& db, FormatExtEntries extFmts, const glu::RenderContext* ctx); 192bf845c4e3814b85e1a3e23a27f50c8f888f4bd2dJarkko Pöyryglu::TransferFormat transferImageFormat (const ImageFormat& imgFormat); 1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace config 1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Config 1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 199b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry virtual ~Config (void) {}; 2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Image : public Config 2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ImageFormat internalFormat; 2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLsizei width; 2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLsizei height; 2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected: 2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Image (void) 2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : internalFormat (ImageFormat::none()) 2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , width (0) 2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , height (0) {} 2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Renderbuffer : public Image 2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Renderbuffer (void) : numSamples(0) {} 2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLsizei numSamples; 2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Texture : public Image 2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture (void) : numLevels(1) {} 2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 226b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry glw::GLint numLevels; 2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct TextureFlat : public Texture 2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Texture2D : public TextureFlat 2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct TextureCubeMap : public TextureFlat 2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct TextureLayered : public Texture 2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureLayered (void) : numLayers(1) {} 2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLsizei numLayers; 2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Texture3D : public TextureLayered 2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Texture2DArray : public TextureLayered 2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Attachment : public Config 2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Attachment (void) : target(GL_FRAMEBUFFER), imageName(0) {} 2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 259b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry glw::GLenum target; 260b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry glw::GLuint imageName; 2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry //! Returns `true` iff this attachment is "framebuffer attachment 2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry //! complete" when bound to attachment point `attPoint`, and the current 2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry //! image with name `imageName` is `image`, using `vfr` to check format 2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry //! renderability. 2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool isComplete (glw::GLenum attPoint, const Image* image, 2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const FboVerifier& vfr) const; 2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct RenderbufferAttachment : public Attachment 2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RenderbufferAttachment (void) 2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : renderbufferTarget(GL_RENDERBUFFER) {} 2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLenum renderbufferTarget; 2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct TextureAttachment : public Attachment 2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureAttachment (void) : level(0) {} 2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLint level; 2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct TextureFlatAttachment : public TextureAttachment 2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureFlatAttachment (void) : texTarget(GL_NONE) {} 2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLenum texTarget; 2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct TextureLayerAttachment : public TextureAttachment 2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureLayerAttachment (void) : layer(0) {} 2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLsizei layer; 2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyryglw::GLenum attachmentType (const Attachment& att); 3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyryglw::GLsizei imageNumSamples (const Image& img); 3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//! Mapping from attachment points to attachment configurations. 3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytypedef std::map<glw::GLenum, const Attachment*> AttachmentMap; 3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//! Mapping from object names to texture configurations. 3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytypedef std::map<glw::GLuint, const Texture*> TextureMap; 3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//! Mapping from object names to renderbuffer configurations. 3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytypedef std::map<glw::GLuint, const Renderbuffer*> RboMap; 3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//! A framebuffer configuration. 3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Framebuffer 3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry AttachmentMap attachments; 3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureMap textures; 3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RboMap rbos; 3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void attach (glw::GLenum attPoint, const Attachment* att); 3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void setTexture (glw::GLuint texName, const Texture& texCfg); 3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void setRbo (glw::GLuint rbName, const Renderbuffer& rbCfg); 3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const Image* getImage (glw::GLenum type, glw::GLuint imgName) const; 3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // config 3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass FboBuilder : public config::Framebuffer 3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void glAttach (glw::GLenum attPoint, 3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const config::Attachment* att); 3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLuint glCreateTexture (const config::Texture& texCfg); 3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLuint glCreateRbo (const config::Renderbuffer& rbCfg); 3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FboBuilder (glw::GLuint fbo, glw::GLenum target, 3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl); 3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~FboBuilder (void); 3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLenum getError (void) { return m_error; } 3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry //! Allocate a new configuration of type `Config` (which must be a 3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry //! subclass of `config::Config`), and return a referenc to it. The newly 3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry //! allocated object will be freed when this builder object is destroyed. 3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry template<typename Config> 3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Config& makeConfig (void) 3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Config* cfg = new Config(); 3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_configs.insert(cfg); 3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return *cfg; 3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typedef std::set<config::Config*> Configs; 3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void checkError (void); 3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLenum m_error; //< The first GL error encountered. 3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLenum m_target; 3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& m_gl; 3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Configs m_configs; 3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 360b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyrystruct ValidStatusCodes 361b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry{ 362b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry ValidStatusCodes (void); 363b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry 364b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry bool isFBOStatusValid (glw::GLenum fboStatus) const; 365b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry bool isFBOStatusRequired (glw::GLenum fboStatus) const; 366b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry bool isErrorCodeValid (glw::GLenum errorCode) const; 367b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry bool isErrorCodeRequired (glw::GLenum errorCode) const; 368b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry 369b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry void addErrorCode (glw::GLenum error, const char* description); 370b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry void addFBOErrorStatus (glw::GLenum status, const char* description); 371b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry void setAllowComplete (bool); 372b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry 373b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry void logLegalResults (tcu::TestLog& log) const; 374b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry void logRules (tcu::TestLog& log) const; 375b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry 376b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyryprivate: 377b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry struct RuleViolation 378b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry { 379b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry glw::GLenum errorCode; 380b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry std::set<std::string> rules; 381b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry }; 382b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry 383b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry void logRule (tcu::TestLog& log, const std::string& ruleName, const std::set<std::string>& rules) const; 384b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry void addViolation (std::vector<RuleViolation>& dst, glw::GLenum code, const char* description) const; 385b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry 386b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry std::vector<RuleViolation> m_errorCodes; //!< Allowed GL errors, GL_NO_ERROR is not allowed 387b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry std::vector<RuleViolation> m_errorStatuses; //!< Allowed FBO error statuses, GL_FRAMEBUFFER_COMPLETE is not allowed 388b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry bool m_allowComplete; //!< true if (GL_NO_ERROR && GL_FRAMEBUFFER_COMPLETE) is allowed 389b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry}; 390b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry 391b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyryvoid logFramebufferConfig (const config::Framebuffer& cfg, tcu::TestLog& log); 3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Checker 3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 3964e5dbcc5c6db2408970d1e9bec76c3936aeee204Jarkko Pöyry Checker (const glu::RenderContext&); 3974e5dbcc5c6db2408970d1e9bec76c3936aeee204Jarkko Pöyry virtual ~Checker (void) {} 398b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry 3994e5dbcc5c6db2408970d1e9bec76c3936aeee204Jarkko Pöyry void addGLError (glw::GLenum error, const char* description); 4004e5dbcc5c6db2408970d1e9bec76c3936aeee204Jarkko Pöyry void addPotentialGLError (glw::GLenum error, const char* description); 4014e5dbcc5c6db2408970d1e9bec76c3936aeee204Jarkko Pöyry void addFBOStatus (glw::GLenum status, const char* description); 4024e5dbcc5c6db2408970d1e9bec76c3936aeee204Jarkko Pöyry void addPotentialFBOStatus (glw::GLenum status, const char* description); 403b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry 4044e5dbcc5c6db2408970d1e9bec76c3936aeee204Jarkko Pöyry ValidStatusCodes getStatusCodes (void) { return m_statusCodes; } 405b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry 4064e5dbcc5c6db2408970d1e9bec76c3936aeee204Jarkko Pöyry virtual void check (glw::GLenum attPoint, 4074e5dbcc5c6db2408970d1e9bec76c3936aeee204Jarkko Pöyry const config::Attachment& att, 4084e5dbcc5c6db2408970d1e9bec76c3936aeee204Jarkko Pöyry const config::Image* image) = 0; 4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4104e5dbcc5c6db2408970d1e9bec76c3936aeee204Jarkko Pöyryprotected: 4114e5dbcc5c6db2408970d1e9bec76c3936aeee204Jarkko Pöyry const glu::RenderContext& m_renderCtx; 4124e5dbcc5c6db2408970d1e9bec76c3936aeee204Jarkko Pöyry 4134e5dbcc5c6db2408970d1e9bec76c3936aeee204Jarkko Pöyryprivate: 4144e5dbcc5c6db2408970d1e9bec76c3936aeee204Jarkko Pöyry ValidStatusCodes m_statusCodes; //< Allowed return values for glCheckFramebufferStatus. 4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass CheckerFactory 4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 4204e5dbcc5c6db2408970d1e9bec76c3936aeee204Jarkko Pöyry virtual Checker* createChecker (const glu::RenderContext&) = 0; 4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytypedef std::set<glw::GLenum> AttachmentPoints; 4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytypedef std::set<ImageFormat> Formats; 4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass FboVerifier 4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 4294e5dbcc5c6db2408970d1e9bec76c3936aeee204Jarkko Pöyry FboVerifier (const FormatDB& formats, 4304e5dbcc5c6db2408970d1e9bec76c3936aeee204Jarkko Pöyry CheckerFactory& factory, 4314e5dbcc5c6db2408970d1e9bec76c3936aeee204Jarkko Pöyry const glu::RenderContext& renderCtx); 4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 433b5c60b02e542a61a2b658272034c830f92b4c766Jarkko Pöyry ValidStatusCodes validStatusCodes (const config::Framebuffer& cfg) const; 4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const FormatDB& m_formats; 4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CheckerFactory& m_factory; 4384e5dbcc5c6db2408970d1e9bec76c3936aeee204Jarkko Pöyry const glu::RenderContext& m_renderCtx; 4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // FboUtil 4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gls 4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp 4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif // _GLSFBOUTIL_HPP 446