1 /*-------------------------------------------------------------------------
2 * OpenGL Conformance Test Suite
3 * -----------------------------
4 *
5 * Copyright (c) 2016 Google Inc.
6 * Copyright (c) 2016 The Khronos Group Inc.
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 *
20 */ /*!
21 * \file
22 * \brief OpenGL test context.
23 */ /*-------------------------------------------------------------------*/
24
25 #include "glcContext.hpp"
26 #include "gluContextInfo.hpp"
27 #include "gluDummyRenderContext.hpp"
28 #include "gluFboRenderContext.hpp"
29 #include "gluRenderConfig.hpp"
30 #include "gluRenderContext.hpp"
31 #include "glwWrapper.hpp"
32 #include "tcuCommandLine.hpp"
33
34 namespace deqp
35 {
36
Context(tcu::TestContext & testCtx,glu::ContextType contextType)37 Context::Context(tcu::TestContext &testCtx, glu::ContextType contextType)
38 : m_testCtx(testCtx)
39 , m_renderCtx(DE_NULL)
40 , m_contextInfo(DE_NULL)
41 {
42 createRenderContext(contextType);
43 }
44
~Context(void)45 Context::~Context(void)
46 {
47 destroyRenderContext();
48 }
49
createRenderContext(glu::ContextType & contextType,glu::ContextFlags ctxFlags)50 void Context::createRenderContext(glu::ContextType &contextType, glu::ContextFlags ctxFlags)
51 {
52 DE_ASSERT(!m_renderCtx && !m_contextInfo);
53
54 try
55 {
56 glu::RenderConfig renderCfg(glu::ContextType(contextType.getAPI(), contextType.getFlags() | ctxFlags));
57 if (m_testCtx.getCommandLine().isTerminateOnDeviceLostEnabled())
58 {
59 renderCfg.resetNotificationStrategy = glu::RESET_NOTIFICATION_STRATEGY_LOSE_CONTEXT_ON_RESET;
60 }
61
62 glu::parseRenderConfig(&renderCfg, m_testCtx.getCommandLine());
63
64 m_renderCtx = glu::createRenderContext(m_testCtx.getPlatform(), m_testCtx.getCommandLine(), renderCfg);
65 m_contextInfo = glu::ContextInfo::create(*m_renderCtx);
66
67 glw::setCurrentThreadFunctions(&m_renderCtx->getFunctions());
68 }
69 catch (...)
70 {
71 destroyRenderContext();
72 throw;
73 }
74 }
75
destroyRenderContext(void)76 void Context::destroyRenderContext(void)
77 {
78 delete m_contextInfo;
79 delete m_renderCtx;
80
81 m_contextInfo = DE_NULL;
82 m_renderCtx = DE_NULL;
83 }
84
getRenderTarget(void) const85 const tcu::RenderTarget &Context::getRenderTarget(void) const
86 {
87 return m_renderCtx->getRenderTarget();
88 }
89
90 } // namespace deqp
91