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// Utilities for standard containers. \todo [2013-12-10 lauri] Move to decpp? 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//! A pair of iterators to present a range. 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//! \note This must be POD to allow static initialization. 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//! \todo [2013-12-03 lauri] Move this to decpp? 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename T> 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Range 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typedef const T* const_iterator; 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const T* m_begin; 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const T* m_end; 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const T* begin (void) const { return m_begin; } 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const T* end (void) const { return m_end; } 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define GLS_ARRAY_RANGE(ARR) { DE_ARRAY_BEGIN(ARR), DE_ARRAY_END(ARR) } 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define GLS_NULL_RANGE { DE_NULL, DE_NULL } 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//! A pair type that, unlike stl::pair, is POD so it can be statically initialized. 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename T1, typename T2> 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Pair 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typedef T1 first_type; 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typedef T2 second_type; 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry T1 first; 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry T2 second; 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate<typename C> 803c827367444ee418f129b2c238299f49d3264554Jarkko PoyryC intersection(const C& s1, const C& s2) 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry C ret; 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::set_intersection(s1.begin(), s1.end(), s2.begin(), s2.end(), 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::insert_iterator<C>(ret, ret.begin())); 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return ret; 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// \todo [2013-12-03 lauri] move to decpp? 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate<typename C> 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline bool isMember (const typename C::key_type& key, const C& container) 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typename C::const_iterator it = container.find(key); 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return (it != container.end()); 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename M> inline 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyryconst typename M::mapped_type* lookupMaybe (const M& map, 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const typename M::key_type& key) 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typename M::const_iterator it = map.find(key); 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (it == map.end()) 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return DE_NULL; 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return &it->second; 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate<typename M> inline 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyryconst typename M::mapped_type& lookupDefault (const M& map, 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const typename M::key_type& key, 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const typename M::mapped_type& fallback) 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const typename M::mapped_type* ptr = lookupMaybe(map, key); 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return ptr == DE_NULL ? fallback : *ptr; 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate<typename M> 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyryconst typename M::mapped_type& lookup (const M& map, 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const typename M::key_type& key) 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const typename M::mapped_type* ptr = lookupMaybe(map, key); 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (ptr == DE_NULL) 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw std::out_of_range("key not found in map"); 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return *ptr; 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate<typename C> 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline bool contains (const C& container, const typename C::value_type& item) 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const typename C::const_iterator it = container.find(item); 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return (it != container.end()); 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate<typename M> static inline 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool insert(const typename M::key_type& key, const typename M::mapped_type& value, M& map) 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typename M::value_type entry(key, value); 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::pair<typename M::iterator,bool> ret = map.insert(entry); 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return ret.second; 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::vector<std::string> splitString(const std::string& s); 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace FboUtil 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//! Configurations for framebuffer objects and their attachments. 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass FboVerifier; 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass FboBuilder; 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytypedef deUint32 FormatKey; 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define GLS_UNSIZED_FORMATKEY(FORMAT, TYPE) \ 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (deUint32(TYPE) << 16 | deUint32(FORMAT)) 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytypedef Range<FormatKey> FormatKeys; 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct ImageFormat 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLenum format; 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry //! Type if format is unsized, GL_NONE if sized. 1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLenum unsizedType; 1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool operator< (const ImageFormat& other) const 1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return (format < other.format || 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (format == other.format && unsizedType < other.unsizedType)); 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static ImageFormat none (void) 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ImageFormat fmt = { GL_NONE, GL_NONE }; 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return fmt; 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic inline ImageFormat formatKeyInfo(FormatKey key) 1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ImageFormat fmt = { key & 0xffff, key >> 16 }; 1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return fmt; 1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum FormatFlags 1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ANY_FORMAT = 0, 1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry COLOR_RENDERABLE = 1 << 0, 1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DEPTH_RENDERABLE = 1 << 1, 1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry STENCIL_RENDERABLE = 1 << 2, 1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RENDERBUFFER_VALID = 1 << 3, 1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TEXTURE_VALID = 1 << 4, 1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry REQUIRED_RENDERABLE = 1 << 5, //< Without this, renderability is allowed, not required. 1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic inline FormatFlags operator|(FormatFlags f1, FormatFlags f2) 1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return FormatFlags(deUint32(f1) | deUint32(f2)); 1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2013c827367444ee418f129b2c238299f49d3264554Jarkko PoyryFormatFlags formatFlag(glw::GLenum context); 2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytypedef std::set<ImageFormat> Formats; 2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass FormatDB 2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void addFormat (ImageFormat format, FormatFlags flags); 2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Formats getFormats (FormatFlags requirements) const; 2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FormatFlags getFormatInfo (ImageFormat format, 2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FormatFlags fallback) const; 2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typedef std::map<ImageFormat, FormatFlags> FormatMap; 2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FormatMap m_map; 2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytypedef Pair<FormatFlags, FormatKeys> FormatEntry; 2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytypedef Range<FormatEntry> FormatEntries; 2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// \todo [2013-12-20 lauri] It turns out that format properties in extensions 2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// are actually far too fine-grained for this bundling to be reasonable, 2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// especially given the syntactic cumbersomeness of static arrays. It's better 2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// to list each entry separately. 2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct FormatExtEntry 2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* extensions; 2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 flags; 2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Range<FormatKey> formats; 2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytypedef Range<FormatExtEntry> FormatExtEntries; 2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid addFormats (FormatDB& db, FormatEntries stdFmts); 2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid addExtFormats (FormatDB& db, FormatExtEntries extFmts, 2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glu::RenderContext* ctx); 2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyryglu::TransferFormat transferImageFormat (const ImageFormat& imgFormat); 2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace config 2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Config 2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~Config (void) {}; 2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Image : public Config 2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ImageFormat internalFormat; 2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLsizei width; 2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLsizei height; 2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected: 2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Image (void) 2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : internalFormat (ImageFormat::none()) 2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , width (0) 2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , height (0) {} 2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Renderbuffer : public Image 2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Renderbuffer (void) : numSamples(0) {} 2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLsizei numSamples; 2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Texture : public Image 2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture (void) : numLevels(1) {} 2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLint numLevels; 2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct TextureFlat : public Texture 2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Texture2D : public TextureFlat 2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct TextureCubeMap : public TextureFlat 2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct TextureLayered : public Texture 2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureLayered (void) : numLayers(1) {} 2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLsizei numLayers; 2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Texture3D : public TextureLayered 2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Texture2DArray : public TextureLayered 2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Attachment : public Config 3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Attachment (void) : target(GL_FRAMEBUFFER), imageName(0) {} 3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLenum target; 3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLuint imageName; 3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry //! Returns `true` iff this attachment is "framebuffer attachment 3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry //! complete" when bound to attachment point `attPoint`, and the current 3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry //! image with name `imageName` is `image`, using `vfr` to check format 3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry //! renderability. 3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool isComplete (glw::GLenum attPoint, const Image* image, 3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const FboVerifier& vfr) const; 3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct RenderbufferAttachment : public Attachment 3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RenderbufferAttachment (void) 3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : renderbufferTarget(GL_RENDERBUFFER) {} 3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLenum renderbufferTarget; 3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct TextureAttachment : public Attachment 3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureAttachment (void) : level(0) {} 3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLint level; 3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct TextureFlatAttachment : public TextureAttachment 3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureFlatAttachment (void) : texTarget(GL_NONE) {} 3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLenum texTarget; 3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct TextureLayerAttachment : public TextureAttachment 3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureLayerAttachment (void) : layer(0) {} 3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLsizei layer; 3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyryglw::GLenum attachmentType (const Attachment& att); 3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyryglw::GLsizei imageNumSamples (const Image& img); 3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//! Mapping from attachment points to attachment configurations. 3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytypedef std::map<glw::GLenum, const Attachment*> AttachmentMap; 3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//! Mapping from object names to texture configurations. 3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytypedef std::map<glw::GLuint, const Texture*> TextureMap; 3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//! Mapping from object names to renderbuffer configurations. 3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytypedef std::map<glw::GLuint, const Renderbuffer*> RboMap; 3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//! A framebuffer configuration. 3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Framebuffer 3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry AttachmentMap attachments; 3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureMap textures; 3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RboMap rbos; 3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void attach (glw::GLenum attPoint, const Attachment* att); 3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void setTexture (glw::GLuint texName, const Texture& texCfg); 3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void setRbo (glw::GLuint rbName, const Renderbuffer& rbCfg); 3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const Image* getImage (glw::GLenum type, glw::GLuint imgName) const; 3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // config 3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid logFramebufferConfig(const config::Framebuffer& cfg, tcu::TestLog& log); 3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass FboBuilder : public config::Framebuffer 3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void glAttach (glw::GLenum attPoint, 3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const config::Attachment* att); 3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLuint glCreateTexture (const config::Texture& texCfg); 3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLuint glCreateRbo (const config::Renderbuffer& rbCfg); 3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FboBuilder (glw::GLuint fbo, glw::GLenum target, 3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl); 3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~FboBuilder (void); 3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLenum getError (void) { return m_error; } 3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry //! Allocate a new configuration of type `Config` (which must be a 3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry //! subclass of `config::Config`), and return a referenc to it. The newly 3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry //! allocated object will be freed when this builder object is destroyed. 3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry template<typename Config> 3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Config& makeConfig (void) 3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Config* cfg = new Config(); 3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_configs.insert(cfg); 3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return *cfg; 3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typedef std::set<config::Config*> Configs; 4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void checkError (void); 4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLenum m_error; //< The first GL error encountered. 4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLenum m_target; 4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& m_gl; 4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Configs m_configs; 4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytypedef std::set<glw::GLenum> StatusCodes; 4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Checker 4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Checker (void) { m_statusCodes.insert(GL_FRAMEBUFFER_COMPLETE); } 4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~Checker (void) {} 4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void require (bool condition, glw::GLenum error); 4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void canRequire (bool condition, glw::GLenum error); 4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry StatusCodes getStatusCodes (void) { return m_statusCodes; } 4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void check (glw::GLenum attPoint, const config::Attachment& att, 4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const config::Image* image) = 0; 4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry StatusCodes m_statusCodes; //< Allowed return values for glCheckFramebufferStatus. 4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass CheckerFactory 4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual Checker* createChecker (void) = 0; 4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytypedef std::set<glw::GLenum> AttachmentPoints; 4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytypedef std::set<ImageFormat> Formats; 4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass FboVerifier 4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FboVerifier (const FormatDB& formats, 4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CheckerFactory& factory); 4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry StatusCodes validStatusCodes (const config::Framebuffer& cfg) const; 4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const FormatDB& m_formats; 4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CheckerFactory& m_factory; 4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // FboUtil 4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gls 4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp 4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif // _GLSFBOUTIL_HPP 453