1#ifndef _GLSFBOCOMPLETENESSTESTS_HPP
2#define _GLSFBOCOMPLETENESSTESTS_HPP
3
4/*-------------------------------------------------------------------------
5 * drawElements Quality Program OpenGL (ES) Module
6 * -----------------------------------------------
7 *
8 * Copyright 2014 The Android Open Source Project
9 *
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
13 *
14 *      http://www.apache.org/licenses/LICENSE-2.0
15 *
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 *
22 *//*!
23 * \file
24 * \brief Common parts for ES2/3 framebuffer completeness tests.
25 *//*--------------------------------------------------------------------*/
26
27#include "tcuTestCase.hpp"
28#include "gluRenderContext.hpp"
29#include "glsFboUtil.hpp"
30#include "glwDefs.hpp"
31#include "glwEnums.hpp"
32#include "tcuTestCase.hpp"
33#include "tcuTestLog.hpp"
34
35namespace deqp
36{
37namespace gls
38{
39namespace fboc
40{
41
42namespace details
43{
44
45using glu::RenderContext;
46using tcu::TestCase;
47using tcu::TestContext;
48typedef TestCase::IterateResult IterateResult;
49using tcu::TestCaseGroup;
50using tcu::TestLog;
51using std::string;
52
53using namespace glw;
54using namespace deqp::gls::FboUtil;
55using namespace deqp::gls::FboUtil::config;
56
57class Context
58{
59public:
60							Context					(TestContext& testCtx,
61													 RenderContext& renderCtx,
62													 CheckerFactory& factory);
63	RenderContext&			getRenderContext		(void) const { return m_renderCtx; }
64	TestContext&			getTestContext			(void) const { return m_testCtx; }
65	const FboVerifier&		getVerifier				(void) const { return m_verifier; }
66	const FormatDB&			getMinFormats			(void) const { return m_minFormats; }
67	const FormatDB&			getCtxFormats			(void) const { return m_ctxFormats; }
68	bool					haveMultiColorAtts		(void) const { return m_haveMultiColorAtts; }
69	void					setHaveMulticolorAtts	(bool have) { m_haveMultiColorAtts = have; }
70	void					addFormats				(FormatEntries fmtRange);
71	void					addExtFormats			(FormatExtEntries extRange);
72	TestCaseGroup*			createRenderableTests	(void);
73	TestCaseGroup*			createAttachmentTests	(void);
74	TestCaseGroup*			createSizeTests			(void);
75private:
76	TestContext&			m_testCtx;
77	RenderContext&			m_renderCtx;
78	FormatDB				m_minFormats;
79	FormatDB				m_ctxFormats;
80	FormatDB				m_maxFormats;
81	FboVerifier				m_verifier;
82	bool					m_haveMultiColorAtts;
83};
84
85class TestBase : public TestCase
86{
87public:
88	Context&				getContext			(void) const { return m_ctx; }
89
90protected:
91
92							TestBase			(Context& ctx,
93												 const string& name, const string& desc)
94								: TestCase		(ctx.getTestContext(),
95												 name.c_str(), desc.c_str())
96								, m_ctx			(ctx) {}
97	void					fail				(const char* msg);
98	void					qualityWarning		(const char* msg);
99	void					pass				(void);
100	void					checkFbo			(FboBuilder& builder);
101	ImageFormat				getDefaultFormat	(GLenum attPoint, GLenum bufType) const;
102
103	IterateResult			iterate				(void);
104
105	virtual IterateResult	build				(FboBuilder& builder);
106
107	void					attachTargetToNew	(GLenum target, GLenum bufType,
108												 ImageFormat format,
109												 GLsizei width, GLsizei height,
110												 FboBuilder& builder);
111	Context&				m_ctx;
112};
113
114	// Utilities for building
115Image* 				makeImage			(GLenum bufType, ImageFormat format,
116										 GLsizei width, GLsizei height, FboBuilder& builder);
117Attachment*			makeAttachment		(GLenum bufType, ImageFormat format,
118										 GLsizei width, GLsizei height, FboBuilder& builder);
119
120template <typename P>
121class ParamTest : public TestBase
122{
123public:
124	typedef P	Params;
125				ParamTest		(Context& ctx, const Params& params)
126					: TestBase	(ctx, Params::getName(params), Params::getDescription(params))
127					, m_params	(params) {}
128
129protected:
130	Params		m_params;
131};
132
133// Shorthand utility
134const glw::Functions& gl (const TestBase& test);
135
136} // details
137
138using details::Context;
139using details::TestBase;
140using details::ParamTest;
141using details::gl;
142
143} // fboc
144} // gls
145} // deqp
146
147#endif // _GLSFBOCOMPLETENESSTESTS_HPP
148