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 std::string; 50 using tcu::TestCaseGroup; 51 using tcu::TestLog; 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, RenderContext &renderCtx, CheckerFactory &factory); getRenderContext(void) const61 RenderContext &getRenderContext(void) const 62 { 63 return m_renderCtx; 64 } getTestContext(void) const65 TestContext &getTestContext(void) const 66 { 67 return m_testCtx; 68 } getVerifier(void) const69 const FboVerifier &getVerifier(void) const 70 { 71 return m_verifier; 72 } getCoreFormats(void) const73 const FormatDB &getCoreFormats(void) const 74 { 75 return m_coreFormats; 76 } getCtxFormats(void) const77 const FormatDB &getCtxFormats(void) const 78 { 79 return m_ctxFormats; 80 } getAllFormats(void) const81 const FormatDB &getAllFormats(void) const 82 { 83 return m_allFormats; 84 } haveMultiColorAtts(void) const85 bool haveMultiColorAtts(void) const 86 { 87 return m_haveMultiColorAtts; 88 } setHaveMulticolorAtts(bool have)89 void setHaveMulticolorAtts(bool have) 90 { 91 m_haveMultiColorAtts = have; 92 } 93 void addFormats(FormatEntries fmtRange); 94 void addExtFormats(FormatExtEntries extRange); 95 TestCaseGroup *createRenderableTests(void); 96 TestCaseGroup *createAttachmentTests(void); 97 TestCaseGroup *createSizeTests(void); 98 99 private: 100 TestContext &m_testCtx; 101 RenderContext &m_renderCtx; 102 FormatDB m_coreFormats; 103 FormatDB m_ctxFormats; 104 FormatDB m_allFormats; 105 FboVerifier m_verifier; 106 bool m_haveMultiColorAtts; 107 }; 108 109 class TestBase : public TestCase 110 { 111 public: getContext(void) const112 Context &getContext(void) const 113 { 114 return m_ctx; 115 } 116 117 protected: TestBase(Context & ctx,const string & name,const string & desc)118 TestBase(Context &ctx, const string &name, const string &desc) 119 : TestCase(ctx.getTestContext(), name.c_str(), desc.c_str()) 120 , m_ctx(ctx) 121 { 122 } 123 void fail(const char *msg); 124 void qualityWarning(const char *msg); 125 void pass(void); 126 void checkFbo(FboBuilder &builder); 127 ImageFormat getDefaultFormat(GLenum attPoint, GLenum bufType) const; 128 129 IterateResult iterate(void); 130 131 virtual IterateResult build(FboBuilder &builder); 132 133 void attachTargetToNew(GLenum target, GLenum bufType, ImageFormat format, GLsizei width, GLsizei height, 134 FboBuilder &builder); 135 Context &m_ctx; 136 }; 137 138 // Utilities for building 139 Image *makeImage(GLenum bufType, ImageFormat format, GLsizei width, GLsizei height, FboBuilder &builder); 140 Attachment *makeAttachment(GLenum bufType, ImageFormat format, GLsizei width, GLsizei height, FboBuilder &builder); 141 142 template <typename P> 143 class ParamTest : public TestBase 144 { 145 public: 146 typedef P Params; ParamTest(Context & ctx,const Params & params)147 ParamTest(Context &ctx, const Params ¶ms) 148 : TestBase(ctx, Params::getName(params), Params::getDescription(params)) 149 , m_params(params) 150 { 151 } 152 153 protected: 154 Params m_params; 155 }; 156 157 // Shorthand utility 158 const glw::Functions &gl(const TestBase &test); 159 160 } // namespace details 161 162 using details::Context; 163 using details::gl; 164 using details::ParamTest; 165 using details::TestBase; 166 167 } // namespace fboc 168 } // namespace gls 169 } // namespace deqp 170 171 #endif // _GLSFBOCOMPLETENESSTESTS_HPP 172