Merge "Fix color change verification in dithering tests" into nougat-cts-dev am:...
[platform/upstream/VK-GL-CTS.git] / modules / glshared / glsFboCompletenessTests.hpp
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
35 namespace deqp
36 {
37 namespace gls
38 {
39 namespace fboc
40 {
41
42 namespace details
43 {
44
45 using glu::RenderContext;
46 using tcu::TestCase;
47 using tcu::TestContext;
48 typedef TestCase::IterateResult IterateResult;
49 using tcu::TestCaseGroup;
50 using tcu::TestLog;
51 using std::string;
52
53 using namespace glw;
54 using namespace deqp::gls::FboUtil;
55 using namespace deqp::gls::FboUtil::config;
56
57 class Context
58 {
59 public:
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&                 getCoreFormats                  (void) const { return m_coreFormats; }
67         const FormatDB&                 getCtxFormats                   (void) const { return m_ctxFormats; }
68         const FormatDB&                 getAllFormats                   (void) const { return m_allFormats; }
69         bool                                    haveMultiColorAtts              (void) const { return m_haveMultiColorAtts; }
70         void                                    setHaveMulticolorAtts   (bool have) { m_haveMultiColorAtts = have; }
71         void                                    addFormats                              (FormatEntries fmtRange);
72         void                                    addExtFormats                   (FormatExtEntries extRange);
73         TestCaseGroup*                  createRenderableTests   (void);
74         TestCaseGroup*                  createAttachmentTests   (void);
75         TestCaseGroup*                  createSizeTests                 (void);
76 private:
77         TestContext&                    m_testCtx;
78         RenderContext&                  m_renderCtx;
79         FormatDB                                m_coreFormats;
80         FormatDB                                m_ctxFormats;
81         FormatDB                                m_allFormats;
82         FboVerifier                             m_verifier;
83         bool                                    m_haveMultiColorAtts;
84 };
85
86 class TestBase : public TestCase
87 {
88 public:
89         Context&                                getContext                      (void) const { return m_ctx; }
90
91 protected:
92
93                                                         TestBase                        (Context& ctx,
94                                                                                                  const string& name, const string& desc)
95                                                                 : TestCase              (ctx.getTestContext(),
96                                                                                                  name.c_str(), desc.c_str())
97                                                                 , m_ctx                 (ctx) {}
98         void                                    fail                            (const char* msg);
99         void                                    qualityWarning          (const char* msg);
100         void                                    pass                            (void);
101         void                                    checkFbo                        (FboBuilder& builder);
102         ImageFormat                             getDefaultFormat        (GLenum attPoint, GLenum bufType) const;
103
104         IterateResult                   iterate                         (void);
105
106         virtual IterateResult   build                           (FboBuilder& builder);
107
108         void                                    attachTargetToNew       (GLenum target, GLenum bufType,
109                                                                                                  ImageFormat format,
110                                                                                                  GLsizei width, GLsizei height,
111                                                                                                  FboBuilder& builder);
112         Context&                                m_ctx;
113 };
114
115         // Utilities for building
116 Image*                          makeImage                       (GLenum bufType, ImageFormat format,
117                                                                                  GLsizei width, GLsizei height, FboBuilder& builder);
118 Attachment*                     makeAttachment          (GLenum bufType, ImageFormat format,
119                                                                                  GLsizei width, GLsizei height, FboBuilder& builder);
120
121 template <typename P>
122 class ParamTest : public TestBase
123 {
124 public:
125         typedef P       Params;
126                                 ParamTest               (Context& ctx, const Params& params)
127                                         : TestBase      (ctx, Params::getName(params), Params::getDescription(params))
128                                         , m_params      (params) {}
129
130 protected:
131         Params          m_params;
132 };
133
134 // Shorthand utility
135 const glw::Functions& gl (const TestBase& test);
136
137 } // details
138
139 using details::Context;
140 using details::TestBase;
141 using details::ParamTest;
142 using details::gl;
143
144 } // fboc
145 } // gls
146 } // deqp
147
148 #endif // _GLSFBOCOMPLETENESSTESTS_HPP