13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*-------------------------------------------------------------------------
23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL (ES) 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 completeness tests.
223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glsFboCompletenessTests.hpp"
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluStrUtil.hpp"
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluObjectWrapper.hpp"
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deStringUtil.hpp"
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <cctype>
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <iterator>
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <algorithm>
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace glw;
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing glu::RenderContext;
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing glu::getFramebufferStatusName;
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing glu::getPixelFormatName;
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing glu::getTypeName;
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing glu::getErrorName;
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing glu::Framebuffer;
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestCase;
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestCaseGroup;
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestLog;
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::MessageBuilder;
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestNode;
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::string;
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing de::toString;
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace deqp::gls::FboUtil;
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace deqp::gls::FboUtil::config;
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytypedef TestCase::IterateResult IterateResult;
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gls
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace fboc
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace details
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// \todo [2013-12-04 lauri] Place in deStrUtil.hpp?
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystring toLower (const string& str)
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	string ret;
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::transform(str.begin(), str.end(), std::inserter(ret, ret.begin()), ::tolower);
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return ret;
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// The following extensions are applicable both to ES2 and ES3.
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// GL_OES_depth_texture
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const FormatKey s_oesDepthTextureFormats[] =
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLS_UNSIZED_FORMATKEY(GL_DEPTH_COMPONENT,	GL_UNSIGNED_SHORT),
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLS_UNSIZED_FORMATKEY(GL_DEPTH_COMPONENT,	GL_UNSIGNED_INT),
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// GL_OES_packed_depth_stencil
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const FormatKey s_oesPackedDepthStencilSizedFormats[] =
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GL_DEPTH24_STENCIL8,
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const FormatKey s_oesPackedDepthStencilTexFormats[] =
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLS_UNSIZED_FORMATKEY(GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8),
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// GL_OES_required_internalformat
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const FormatKey s_oesRequiredInternalFormatColorFormats[] =
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Same as ES2 RBO formats, plus RGBA8 (even without OES_rgb8_rgba8)
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GL_RGB5_A1, GL_RGBA8, GL_RGBA4, GL_RGB565
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const FormatKey s_oesRequiredInternalFormatDepthFormats[] =
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GL_DEPTH_COMPONENT16,
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// GL_EXT_color_buffer_half_float
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const FormatKey s_extColorBufferHalfFloatFormats[] =
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GL_RGBA16F, GL_RGB16F, GL_RG16F, GL_R16F,
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const FormatKey s_oesDepth24SizedFormats[] =
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GL_DEPTH_COMPONENT24
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const FormatKey s_oesDepth32SizedFormats[] =
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GL_DEPTH_COMPONENT32
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const FormatKey s_oesRgb8Rgba8RboFormats[] =
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GL_RGB8,
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GL_RGBA8,
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const FormatKey s_oesRequiredInternalFormatRgb8ColorFormat[] =
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GL_RGB8,
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const FormatKey s_extTextureType2101010RevFormats[] =
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLS_UNSIZED_FORMATKEY(GL_RGBA,	GL_UNSIGNED_INT_2_10_10_10_REV),
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLS_UNSIZED_FORMATKEY(GL_RGB,	GL_UNSIGNED_INT_2_10_10_10_REV),
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const FormatKey s_oesRequiredInternalFormat10bitColorFormats[] =
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GL_RGB10_A2, GL_RGB10,
1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const FormatKey s_extTextureRgRboFormats[] =
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GL_R8, GL_RG8,
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const FormatKey s_extTextureRgTexFormats[] =
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLS_UNSIZED_FORMATKEY(GL_RED,	GL_UNSIGNED_BYTE),
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLS_UNSIZED_FORMATKEY(GL_RG,	GL_UNSIGNED_BYTE),
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const FormatKey s_extTextureRgFloatTexFormats[] =
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLS_UNSIZED_FORMATKEY(GL_RED,	GL_FLOAT),
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLS_UNSIZED_FORMATKEY(GL_RG,	GL_FLOAT),
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const FormatKey s_extTextureRgHalfFloatTexFormats[] =
1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLS_UNSIZED_FORMATKEY(GL_RED,	GL_HALF_FLOAT_OES),
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLS_UNSIZED_FORMATKEY(GL_RG,	GL_HALF_FLOAT_OES),
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const FormatKey s_nvPackedFloatRboFormats[] =
1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GL_R11F_G11F_B10F,
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const FormatKey s_nvPackedFloatTexFormats[] =
1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLS_UNSIZED_FORMATKEY(GL_RGB,	GL_UNSIGNED_INT_10F_11F_11F_REV),
1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const FormatKey s_extSrgbRboFormats[] =
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GL_SRGB8_ALPHA8,
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
178ef47bf903439ca2c12640ec0f397d29e8bd4f197Jarkko Pöyrystatic const FormatKey s_extSrgbRenderableTexFormats[] =
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLS_UNSIZED_FORMATKEY(GL_SRGB_ALPHA,	GL_UNSIGNED_BYTE),
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
183ef47bf903439ca2c12640ec0f397d29e8bd4f197Jarkko Pöyrystatic const FormatKey s_extSrgbNonRenderableTexFormats[] =
184ef47bf903439ca2c12640ec0f397d29e8bd4f197Jarkko Pöyry{
185ef47bf903439ca2c12640ec0f397d29e8bd4f197Jarkko Pöyry	GLS_UNSIZED_FORMATKEY(GL_SRGB,			GL_UNSIGNED_BYTE),
186ef47bf903439ca2c12640ec0f397d29e8bd4f197Jarkko Pöyry	GL_SRGB8,
187ef47bf903439ca2c12640ec0f397d29e8bd4f197Jarkko Pöyry};
188ef47bf903439ca2c12640ec0f397d29e8bd4f197Jarkko Pöyry
1891029ba1f311daab764fa4e54f0c2a57124522ad0Jarkko Pöyrystatic const FormatKey s_nvSrgbFormatsRboFormats[] =
1901029ba1f311daab764fa4e54f0c2a57124522ad0Jarkko Pöyry{
1911029ba1f311daab764fa4e54f0c2a57124522ad0Jarkko Pöyry	GL_SRGB8,
1921029ba1f311daab764fa4e54f0c2a57124522ad0Jarkko Pöyry};
1931029ba1f311daab764fa4e54f0c2a57124522ad0Jarkko Pöyry
1941029ba1f311daab764fa4e54f0c2a57124522ad0Jarkko Pöyrystatic const FormatKey s_nvSrgbFormatsTextureFormats[] =
195ef47bf903439ca2c12640ec0f397d29e8bd4f197Jarkko Pöyry{
196ef47bf903439ca2c12640ec0f397d29e8bd4f197Jarkko Pöyry	GL_SRGB8,
1976105d36c20b890fe795a9a412db4bdb0ed6f1198Jarkko Pöyry
1986105d36c20b890fe795a9a412db4bdb0ed6f1198Jarkko Pöyry	// The extension does not actually require any unsized format
1996105d36c20b890fe795a9a412db4bdb0ed6f1198Jarkko Pöyry	// to be renderable. However, the renderablility of unsized
2006105d36c20b890fe795a9a412db4bdb0ed6f1198Jarkko Pöyry	// SRGB,UBYTE internalformat-type pair is implied.
2016105d36c20b890fe795a9a412db4bdb0ed6f1198Jarkko Pöyry	GLS_UNSIZED_FORMATKEY(GL_SRGB,			GL_UNSIGNED_BYTE),
202ef47bf903439ca2c12640ec0f397d29e8bd4f197Jarkko Pöyry};
203ef47bf903439ca2c12640ec0f397d29e8bd4f197Jarkko Pöyry
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const FormatKey s_oesRgb8Rgba8TexFormats[] =
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLS_UNSIZED_FORMATKEY(GL_RGB,		GL_UNSIGNED_BYTE),
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLS_UNSIZED_FORMATKEY(GL_RGBA,		GL_UNSIGNED_BYTE),
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const FormatExtEntry s_esExtFormats[] =
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"GL_OES_depth_texture",
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		REQUIRED_RENDERABLE | DEPTH_RENDERABLE | TEXTURE_VALID,
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLS_ARRAY_RANGE(s_oesDepthTextureFormats),
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	},
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"GL_OES_packed_depth_stencil",
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		REQUIRED_RENDERABLE | DEPTH_RENDERABLE | STENCIL_RENDERABLE | RENDERBUFFER_VALID,
2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLS_ARRAY_RANGE(s_oesPackedDepthStencilSizedFormats)
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	},
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"GL_OES_packed_depth_stencil GL_OES_required_internalformat",
2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TEXTURE_VALID,
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLS_ARRAY_RANGE(s_oesPackedDepthStencilSizedFormats)
2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	},
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"GL_OES_packed_depth_stencil",
2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DEPTH_RENDERABLE | STENCIL_RENDERABLE | TEXTURE_VALID,
2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLS_ARRAY_RANGE(s_oesPackedDepthStencilTexFormats)
2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	},
2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// \todo [2013-12-10 lauri] Find out if OES_texture_half_float is really a
2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// requirement on ES3 also. Or is color_buffer_half_float applicatble at
2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// all on ES3, since there's also EXT_color_buffer_float?
2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"GL_OES_texture_half_float GL_EXT_color_buffer_half_float",
2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		REQUIRED_RENDERABLE | COLOR_RENDERABLE | RENDERBUFFER_VALID,
2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLS_ARRAY_RANGE(s_extColorBufferHalfFloatFormats)
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	},
2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// OES_required_internalformat doesn't actually specify that these are renderable,
2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// since it was written against ES 1.1.
2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"GL_OES_required_internalformat",
2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		 // Allow but don't require RGBA8 to be color-renderable if
2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		 // OES_rgb8_rgba8 is not present.
2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		COLOR_RENDERABLE | TEXTURE_VALID,
2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLS_ARRAY_RANGE(s_oesRequiredInternalFormatColorFormats)
2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	},
2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"GL_OES_required_internalformat",
2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DEPTH_RENDERABLE | TEXTURE_VALID,
2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLS_ARRAY_RANGE(s_oesRequiredInternalFormatDepthFormats)
2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	},
2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"GL_EXT_texture_rg",
2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		REQUIRED_RENDERABLE | COLOR_RENDERABLE | RENDERBUFFER_VALID,
2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLS_ARRAY_RANGE(s_extTextureRgRboFormats)
2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	},
2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// These are not specified to be color-renderable, but the wording is
2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// exactly as ambiguous as the wording in the ES2 spec.
2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"GL_EXT_texture_rg",
2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		COLOR_RENDERABLE | TEXTURE_VALID,
2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLS_ARRAY_RANGE(s_extTextureRgTexFormats)
2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	},
2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"GL_EXT_texture_rg GL_OES_texture_float",
2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		COLOR_RENDERABLE | TEXTURE_VALID,
2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLS_ARRAY_RANGE(s_extTextureRgFloatTexFormats)
2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	},
2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"GL_EXT_texture_rg GL_OES_texture_half_float",
2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		COLOR_RENDERABLE | TEXTURE_VALID,
2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLS_ARRAY_RANGE(s_extTextureRgHalfFloatTexFormats)
2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	},
2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"GL_NV_packed_float",
2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		COLOR_RENDERABLE | TEXTURE_VALID,
2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLS_ARRAY_RANGE(s_nvPackedFloatTexFormats)
2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	},
2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"GL_NV_packed_float GL_EXT_color_buffer_half_float",
2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		REQUIRED_RENDERABLE | COLOR_RENDERABLE | RENDERBUFFER_VALID,
2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLS_ARRAY_RANGE(s_nvPackedFloatRboFormats)
2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	},
2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Some Tegra drivers report GL_EXT_packed_float even for ES. Treat it as
2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// a synonym for the NV_ version.
2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"GL_EXT_packed_float",
2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		COLOR_RENDERABLE | TEXTURE_VALID,
2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLS_ARRAY_RANGE(s_nvPackedFloatTexFormats)
2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	},
2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"GL_EXT_packed_float GL_EXT_color_buffer_half_float",
2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		REQUIRED_RENDERABLE | COLOR_RENDERABLE | RENDERBUFFER_VALID,
2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLS_ARRAY_RANGE(s_nvPackedFloatRboFormats)
3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	},
3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"GL_EXT_sRGB",
3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		COLOR_RENDERABLE | TEXTURE_VALID,
305ef47bf903439ca2c12640ec0f397d29e8bd4f197Jarkko Pöyry		GLS_ARRAY_RANGE(s_extSrgbRenderableTexFormats)
306ef47bf903439ca2c12640ec0f397d29e8bd4f197Jarkko Pöyry	},
307ef47bf903439ca2c12640ec0f397d29e8bd4f197Jarkko Pöyry	{
308ef47bf903439ca2c12640ec0f397d29e8bd4f197Jarkko Pöyry		"GL_EXT_sRGB",
309ef47bf903439ca2c12640ec0f397d29e8bd4f197Jarkko Pöyry		TEXTURE_VALID,
310ef47bf903439ca2c12640ec0f397d29e8bd4f197Jarkko Pöyry		GLS_ARRAY_RANGE(s_extSrgbNonRenderableTexFormats)
3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	},
3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"GL_EXT_sRGB",
3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		REQUIRED_RENDERABLE | COLOR_RENDERABLE | RENDERBUFFER_VALID,
3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLS_ARRAY_RANGE(s_extSrgbRboFormats)
3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	},
317ef47bf903439ca2c12640ec0f397d29e8bd4f197Jarkko Pöyry	{
318ef47bf903439ca2c12640ec0f397d29e8bd4f197Jarkko Pöyry		"GL_NV_sRGB_formats",
3191029ba1f311daab764fa4e54f0c2a57124522ad0Jarkko Pöyry		REQUIRED_RENDERABLE | COLOR_RENDERABLE | RENDERBUFFER_VALID,
3201029ba1f311daab764fa4e54f0c2a57124522ad0Jarkko Pöyry		GLS_ARRAY_RANGE(s_nvSrgbFormatsRboFormats)
3211029ba1f311daab764fa4e54f0c2a57124522ad0Jarkko Pöyry	},
3221029ba1f311daab764fa4e54f0c2a57124522ad0Jarkko Pöyry	{
3231029ba1f311daab764fa4e54f0c2a57124522ad0Jarkko Pöyry		"GL_NV_sRGB_formats",
3241029ba1f311daab764fa4e54f0c2a57124522ad0Jarkko Pöyry		REQUIRED_RENDERABLE | COLOR_RENDERABLE | TEXTURE_VALID,
3251029ba1f311daab764fa4e54f0c2a57124522ad0Jarkko Pöyry		GLS_ARRAY_RANGE(s_nvSrgbFormatsTextureFormats)
326ef47bf903439ca2c12640ec0f397d29e8bd4f197Jarkko Pöyry	},
3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	 // In Khronos bug 7333 discussion, the consensus is that these texture
3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	 // formats, at least, should be color-renderable. Still, that cannot be
3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	 // found in any extension specs, so only allow it, not require it.
3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"GL_OES_rgb8_rgba8",
3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		COLOR_RENDERABLE | TEXTURE_VALID,
3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLS_ARRAY_RANGE(s_oesRgb8Rgba8TexFormats)
3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	},
3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"GL_OES_rgb8_rgba8",
3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		REQUIRED_RENDERABLE | COLOR_RENDERABLE | RENDERBUFFER_VALID,
3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLS_ARRAY_RANGE(s_oesRgb8Rgba8RboFormats)
3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	},
3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"GL_OES_rgb8_rgba8 GL_OES_required_internalformat",
3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TEXTURE_VALID,
3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLS_ARRAY_RANGE(s_oesRequiredInternalFormatRgb8ColorFormat)
3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	},
3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// The depth-renderability of the depth RBO formats is not explicitly
3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// spelled out, but all renderbuffer formats are meant to be renderable.
3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"GL_OES_depth24",
3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		REQUIRED_RENDERABLE | DEPTH_RENDERABLE | RENDERBUFFER_VALID,
3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLS_ARRAY_RANGE(s_oesDepth24SizedFormats)
3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	},
3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"GL_OES_depth24 GL_OES_required_internalformat GL_OES_depth_texture",
3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TEXTURE_VALID,
3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLS_ARRAY_RANGE(s_oesDepth24SizedFormats)
3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	},
3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"GL_OES_depth32",
3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		REQUIRED_RENDERABLE | DEPTH_RENDERABLE | RENDERBUFFER_VALID,
3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLS_ARRAY_RANGE(s_oesDepth32SizedFormats)
3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	},
3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"GL_OES_depth32 GL_OES_required_internalformat GL_OES_depth_texture",
3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TEXTURE_VALID,
3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLS_ARRAY_RANGE(s_oesDepth32SizedFormats)
3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	},
3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"GL_EXT_texture_type_2_10_10_10_REV",
3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TEXTURE_VALID, // explicitly unrenderable
3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLS_ARRAY_RANGE(s_extTextureType2101010RevFormats)
3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	},
3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"GL_EXT_texture_type_2_10_10_10_REV GL_OES_required_internalformat",
3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TEXTURE_VALID, // explicitly unrenderable
3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLS_ARRAY_RANGE(s_oesRequiredInternalFormat10bitColorFormats)
3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	},
3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3833c827367444ee418f129b2c238299f49d3264554Jarkko PoyryContext::Context (TestContext& testCtx,
3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				  RenderContext& renderCtx,
3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				  CheckerFactory& factory)
3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: m_testCtx				(testCtx)
3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_renderCtx			(renderCtx)
3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_verifier			(m_ctxFormats, factory)
3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_haveMultiColorAtts	(false)
3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FormatExtEntries extRange = GLS_ARRAY_RANGE(s_esExtFormats);
3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addExtFormats(extRange);
3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid Context::addFormats (FormatEntries fmtRange)
3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FboUtil::addFormats(m_minFormats, fmtRange);
3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FboUtil::addFormats(m_ctxFormats, fmtRange);
3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FboUtil::addFormats(m_maxFormats, fmtRange);
4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid Context::addExtFormats (FormatExtEntries extRange)
4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FboUtil::addExtFormats(m_ctxFormats, extRange, &m_renderCtx);
4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FboUtil::addExtFormats(m_maxFormats, extRange, DE_NULL);
4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TestBase::pass (void)
4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TestBase::qualityWarning (const char* msg)
4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_testCtx.setTestResult(QP_TEST_RESULT_QUALITY_WARNING, msg);
4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TestBase::fail (const char* msg)
4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, msg);
4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic string statusName (GLenum status)
4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const char* errorName = getErrorName(status);
4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (status != GL_NO_ERROR && errorName != DE_NULL)
4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return string(errorName) + " (during FBO initialization)";
4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const char* fbStatusName = getFramebufferStatusName(status);
4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (fbStatusName != DE_NULL)
4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return fbStatusName;
4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return "unknown value (" + toString(status) + ")";
4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyryconst glw::Functions& gl (const TestBase& test)
4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return test.getContext().getRenderContext().getFunctions();
4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4413c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIterateResult TestBase::iterate (void)
4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::Framebuffer fbo(m_ctx.getRenderContext());
4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FboBuilder builder(*fbo, GL_FRAMEBUFFER, gl(*this));
4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const IterateResult ret = build(builder);
4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const StatusCodes statuses = m_ctx.getVerifier().validStatusCodes(builder);
4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLenum glStatus = builder.getError();
4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (glStatus == GL_NO_ERROR)
4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glStatus = gl(*this).checkFramebufferStatus(GL_FRAMEBUFFER);
4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// \todo [2013-12-04 lauri] Check if drawing operations succeed.
4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StatusCodes::const_iterator it = statuses.begin();
4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLenum err = *it++;
4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	logFramebufferConfig(builder, m_testCtx.getLog());
4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	MessageBuilder msg(&m_testCtx.getLog());
4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	msg << "Expected ";
4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (it != statuses.end())
4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		msg << "one of ";
4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		while (it != statuses.end())
4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			msg << statusName(err);
4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			err = *it++;
4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			msg << (it == statuses.end() ? " or " : ", ");
4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	msg << statusName(err) << "." << TestLog::EndMessage;
4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_testCtx.getLog() << TestLog::Message << "Received " << statusName(glStatus)
4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			 << "." << TestLog::EndMessage;
4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!contains(statuses, glStatus))
4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// The returned status value was not acceptable.
4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (glStatus == GL_FRAMEBUFFER_COMPLETE)
4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			fail("Framebuffer checked as complete, expected incomplete");
4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		else if (statuses.size() == 1 && contains(statuses, GL_FRAMEBUFFER_COMPLETE))
4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			fail("Framebuffer checked is incomplete, expected complete");
4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		else
4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// An incomplete status is allowed, but not _this_ incomplete status.
4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			fail("Framebuffer checked as incomplete, but with wrong status");
4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	else if (glStatus != GL_FRAMEBUFFER_COMPLETE &&
4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			 contains(statuses, GL_FRAMEBUFFER_COMPLETE))
4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		qualityWarning("Framebuffer object could have checked as complete but did not.");
4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	else
4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		pass();
4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return ret;
4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4973c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIterateResult TestBase::build (FboBuilder& builder)
4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_UNREF(builder);
5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return STOP;
5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5033c827367444ee418f129b2c238299f49d3264554Jarkko PoyryImageFormat TestBase::getDefaultFormat (GLenum attPoint, GLenum bufType) const
5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (bufType == GL_NONE)
5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return ImageFormat::none();
5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Prefer a standard format, if there is one, but if not, use a format
5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// provided by an extension.
5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Formats formats = m_ctx.getMinFormats().getFormats(formatFlag(attPoint) |
5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														 formatFlag(bufType));
5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Formats::const_iterator it = formats.begin();
5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (it == formats.end())
5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		formats = m_ctx.getCtxFormats().getFormats(formatFlag(attPoint) |
5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry													 formatFlag(bufType));
5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		it = formats.begin();
5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (it == formats.end())
5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw tcu::NotSupportedError("Unsupported attachment kind for attachment point",
5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									 "", __FILE__, __LINE__);
5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return *it;
5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5273c827367444ee418f129b2c238299f49d3264554Jarkko PoyryImage* makeImage (GLenum bufType, ImageFormat format,
5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				  GLsizei width, GLsizei height, FboBuilder& builder)
5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Image* image = DE_NULL;
5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	switch (bufType)
5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case GL_NONE:
5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return DE_NULL;
5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case GL_RENDERBUFFER:
5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			image = &builder.makeConfig<Renderbuffer>();
5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			break;
5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case GL_TEXTURE:
5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			image = &builder.makeConfig<Texture2D>();
5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			break;
5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		default:
5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			DE_ASSERT(!"Impossible case");
5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	image->internalFormat = format;
5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	image->width = width;
5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	image->height = height;
5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return image;
5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5503c827367444ee418f129b2c238299f49d3264554Jarkko PoyryAttachment* makeAttachment (GLenum bufType, ImageFormat format,
5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							GLsizei width, GLsizei height, FboBuilder& builder)
5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Image* const imgCfg = makeImage (bufType, format, width, height, builder);
5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Attachment* att = DE_NULL;
5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint img = 0;
5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (Renderbuffer* rboCfg = dynamic_cast<Renderbuffer*>(imgCfg))
5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		img = builder.glCreateRbo(*rboCfg);
5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		att = &builder.makeConfig<RenderbufferAttachment>();
5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	else if (Texture2D* texCfg = dynamic_cast<Texture2D*>(imgCfg))
5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		img = builder.glCreateTexture(*texCfg);
5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TextureFlatAttachment& texAtt = builder.makeConfig<TextureFlatAttachment>();
5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		texAtt.texTarget = GL_TEXTURE_2D;
5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		att = &texAtt;
5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	else
5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(imgCfg == DE_NULL);
5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return DE_NULL;
5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	att->imageName = img;
5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return att;
5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TestBase::attachTargetToNew (GLenum target, GLenum bufType, ImageFormat format,
5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  GLsizei width, GLsizei height, FboBuilder& builder)
5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ImageFormat imgFmt = format;
5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (imgFmt.format == GL_NONE)
5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		imgFmt = getDefaultFormat(target, bufType);
5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const Attachment* const att = makeAttachment(bufType, imgFmt, width, height, builder);
5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	builder.glAttach(target, att);
5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic string formatName (ImageFormat format)
5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const string s = getPixelFormatName(format.format);
5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const string fmtStr = toLower(s.substr(3));
5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (format.unsizedType != GL_NONE)
5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const string typeStr = getTypeName(format.unsizedType);
5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return fmtStr + "_" + toLower(typeStr.substr(3));
5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return fmtStr;
6013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic string formatDesc (ImageFormat format)
6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const string fmtStr = getPixelFormatName(format.format);
6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (format.unsizedType != GL_NONE)
6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const string typeStr = getTypeName(format.unsizedType);
6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return fmtStr + " with type " + typeStr;
6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return fmtStr;
6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct RenderableParams
6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLenum				attPoint;
6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLenum				bufType;
6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ImageFormat 		format;
6213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static string		getName				(const RenderableParams& params)
6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return formatName(params.format);
6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static string		getDescription		(const RenderableParams& params)
6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return formatDesc(params.format);
6283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
6303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6313c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass RenderableTest : public ParamTest<RenderableParams>
6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6333c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
6343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					RenderableTest		(Context& group, const Params& params)
6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						: ParamTest<RenderableParams> (group, params) {}
6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IterateResult	build				(FboBuilder& builder);
6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
6383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6393c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIterateResult RenderableTest::build (FboBuilder& builder)
6403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	attachTargetToNew(m_params.attPoint, m_params.bufType, m_params.format, 64, 64, builder);
6423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return STOP;
6433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystring attTypeName (GLenum bufType)
6463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	switch (bufType)
6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case GL_NONE:
6503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return "none";
6513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case GL_RENDERBUFFER:
6523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return "rbo";
6533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case GL_TEXTURE:
6543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return "tex";
6553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		default:
6563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			DE_ASSERT(!"Impossible case");
6573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return ""; // Shut up compiler
6593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6613c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct AttachmentParams
6623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLenum						color0Kind;
6643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLenum						colornKind;
6653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLenum						depthKind;
6663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLenum						stencilKind;
6673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static string		getName			(const AttachmentParams& params);
6693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static string		getDescription	(const AttachmentParams& params)
6703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return getName(params);
6723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
6743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6753c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystring AttachmentParams::getName (const AttachmentParams& params)
6763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return (attTypeName(params.color0Kind) + "_" +
6783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			attTypeName(params.colornKind) + "_" +
6793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			attTypeName(params.depthKind) + "_" +
6803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			attTypeName(params.stencilKind));
6813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//! Test for combinations of different kinds of attachments
6843c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass AttachmentTest : public ParamTest<AttachmentParams>
6853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6863c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
6873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					AttachmentTest		(Context& group, Params& params)
6883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						: ParamTest<AttachmentParams> (group, params) {}
6893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6903c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
6913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IterateResult 	build				(FboBuilder& builder);
6923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void			makeDepthAndStencil	(FboBuilder& builder);
6933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
6943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6963c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid AttachmentTest::makeDepthAndStencil (FboBuilder& builder)
6973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (m_params.stencilKind == m_params.depthKind)
6993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
7003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// If there is a common stencil+depth -format, try to use a common
7013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// image for both attachments.
7023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const FormatFlags flags =
7033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			DEPTH_RENDERABLE | STENCIL_RENDERABLE | formatFlag(m_params.stencilKind);
7043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const Formats& formats = m_ctx.getMinFormats().getFormats(flags);
7053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		Formats::const_iterator it = formats.begin();
7063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (it != formats.end())
7073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
7083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const ImageFormat format = *it;
7093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Attachment* att = makeAttachment(m_params.depthKind, format, 64, 64, builder);
7103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			builder.glAttach(GL_DEPTH_ATTACHMENT, att);
7113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			builder.glAttach(GL_STENCIL_ATTACHMENT, att);
7123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return;
7133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
7143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
7153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Either the kinds were separate, or a suitable format was not found.
7163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Create separate images.
7173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	attachTargetToNew(GL_STENCIL_ATTACHMENT, m_params.stencilKind, ImageFormat::none(),
7183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					  64, 64, builder);
7193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	attachTargetToNew(GL_DEPTH_ATTACHMENT, m_params.depthKind, ImageFormat::none(),
7203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					  64, 64, builder);
7213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7233c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIterateResult AttachmentTest::build (FboBuilder& builder)
7243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	attachTargetToNew(GL_COLOR_ATTACHMENT0, m_params.color0Kind, ImageFormat::none(),
7263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					  64, 64, builder);
7273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (m_params.colornKind != GL_NONE)
7293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
7303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TCU_CHECK_AND_THROW(NotSupportedError, m_ctx.haveMultiColorAtts(),
7313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							"Multiple attachments not supported");
7323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLint maxAttachments = 1;
7333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl(*this).getIntegerv(GL_MAX_COLOR_ATTACHMENTS, &maxAttachments);
7343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(
7353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			gl(*this).getError(), "Couldn't read GL_MAX_COLOR_ATTACHMENTS");
7363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int i = 1; i < maxAttachments; i++)
7383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
7393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			attachTargetToNew(GL_COLOR_ATTACHMENT0 + i, m_params.colornKind,
7403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							  ImageFormat::none(), 64, 64, builder);
7413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
7423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
7433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	makeDepthAndStencil(builder);
7453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return STOP;
7473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7493c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass EmptyImageTest : public TestBase
7503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7513c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
7523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					EmptyImageTest	(Context& group,
7533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									 const char* name, const char* desc)
7543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						: TestBase	(group, name, desc) {}
7553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IterateResult	build			(FboBuilder& builder);
7573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
7583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7593c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIterateResult EmptyImageTest::build (FboBuilder& builder)
7603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	attachTargetToNew(GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, ImageFormat::none(),
7623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					  0, 0, builder);
7633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return STOP;
7643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7673c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass DistinctSizeTest : public TestBase
7683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7693c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
7703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					DistinctSizeTest	(Context& group,
7713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										 const char* name, const char* desc)
7723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						: TestBase		(group, name, desc) {}
7733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IterateResult	build				(FboBuilder& builder);
7753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
7763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7773c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIterateResult DistinctSizeTest::build (FboBuilder& builder)
7783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	attachTargetToNew(GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, ImageFormat::none(),
7803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					  64, 64, builder);
7813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	attachTargetToNew(GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, ImageFormat::none(),
7823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					  128, 128, builder);
7833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return STOP;
7843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7863c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTestCaseGroup* Context::createRenderableTests (void)
7873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TestCaseGroup* const renderableTests = new TestCaseGroup(
7893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_testCtx, "renderable", "Tests for support of renderable image formats");
7903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TestCaseGroup* const rbRenderableTests = new TestCaseGroup(
7923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_testCtx, "renderbuffer", "Tests for renderbuffer formats");
7933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TestCaseGroup* const texRenderableTests = new TestCaseGroup(
7953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_testCtx, "texture", "Tests for texture formats");
7963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static const struct AttPoint {
7983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLenum 			attPoint;
7993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const char* 	name;
8003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const char* 	desc;
8013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	} attPoints[] =
8023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ GL_COLOR_ATTACHMENT0,		"color0",	"Tests for color attachments"	},
8043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ GL_STENCIL_ATTACHMENT,	"stencil",	"Tests for stencil attachments" },
8053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ GL_DEPTH_ATTACHMENT,		"depth",	"Tests for depth attachments"	},
8063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
8073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// At each attachment point, iterate through all the possible formats to
8093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// detect both false positives and false negatives.
8103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const Formats rboFmts = m_maxFormats.getFormats(ANY_FORMAT);
8113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const Formats texFmts = m_maxFormats.getFormats(ANY_FORMAT);
8123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (const AttPoint* it = DE_ARRAY_BEGIN(attPoints); it != DE_ARRAY_END(attPoints); it++)
8143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TestCaseGroup* const rbAttTests = new TestCaseGroup(m_testCtx, it->name, it->desc);
8163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TestCaseGroup* const texAttTests = new TestCaseGroup(m_testCtx, it->name, it->desc);
8173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (Formats::const_iterator it2 = rboFmts.begin(); it2 != rboFmts.end(); it2++)
8193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
8203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const RenderableParams params = { it->attPoint, GL_RENDERBUFFER, *it2 };
8213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			rbAttTests->addChild(new RenderableTest(*this, params));
8223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
8233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		rbRenderableTests->addChild(rbAttTests);
8243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (Formats::const_iterator it2 = texFmts.begin(); it2 != texFmts.end(); it2++)
8263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
8273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const RenderableParams params = { it->attPoint, GL_TEXTURE, *it2 };
8283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			texAttTests->addChild(new RenderableTest(*this, params));
8293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
8303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		texRenderableTests->addChild(texAttTests);
8313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
8323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	renderableTests->addChild(rbRenderableTests);
8333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	renderableTests->addChild(texRenderableTests);
8343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return renderableTests;
8363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
8373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8383c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTestCaseGroup* Context::createAttachmentTests (void)
8393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TestCaseGroup* const attCombTests = new TestCaseGroup(
8413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_testCtx, "attachment_combinations", "Tests for attachment combinations");
8423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static const GLenum s_bufTypes[] = { GL_NONE, GL_RENDERBUFFER, GL_TEXTURE };
8443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static const Range<GLenum> s_kinds = GLS_ARRAY_RANGE(s_bufTypes);
8453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (const GLenum* col0 = s_kinds.begin(); col0 != s_kinds.end(); ++col0)
8473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (const GLenum* coln = s_kinds.begin(); coln != s_kinds.end(); ++coln)
8483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (const GLenum* dep = s_kinds.begin(); dep != s_kinds.end(); ++dep)
8493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				for (const GLenum* stc = s_kinds.begin(); stc != s_kinds.end(); ++stc)
8503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
8513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					AttachmentParams params = { *col0, *coln, *dep, *stc };
8523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					attCombTests->addChild(new AttachmentTest(*this, params));
8533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
8543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return attCombTests;
8563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
8573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8583c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTestCaseGroup* Context::createSizeTests (void)
8593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TestCaseGroup* const sizeTests = new TestCaseGroup(
8613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_testCtx, "size", "Tests for attachment sizes");
8623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	sizeTests->addChild(new EmptyImageTest(
8633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							*this, "zero",
8643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							"Test for zero-sized image attachment"));
8653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	sizeTests->addChild(new DistinctSizeTest(
8663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							*this, "distinct",
8673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							"Test for attachments with different sizes"));
8683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return sizeTests;
8703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
8713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // details
8733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // fboc
8753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gls
8763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp
877