xref: /aosp_15_r20/external/deqp/modules/gles3/tes3Context.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program OpenGL ES 3.0 Module
3  * -------------------------------------------------
4  *
5  * Copyright 2014 The Android Open Source Project
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  *//*!
20  * \file
21  * \brief OpenGL ES 3.0 test context.
22  *//*--------------------------------------------------------------------*/
23 
24 #include "tes3Context.hpp"
25 #include "gluRenderContext.hpp"
26 #include "gluRenderConfig.hpp"
27 #include "gluFboRenderContext.hpp"
28 #include "gluContextInfo.hpp"
29 #include "tcuCommandLine.hpp"
30 #include "glwWrapper.hpp"
31 
32 namespace deqp
33 {
34 namespace gles3
35 {
36 
Context(tcu::TestContext & testCtx,glu::ApiType apiType)37 Context::Context(tcu::TestContext &testCtx, glu::ApiType apiType)
38     : m_testCtx(testCtx)
39     , m_renderCtx(DE_NULL)
40     , m_contextInfo(DE_NULL)
41     , m_apiType(apiType)
42 {
43     try
44     {
45         m_renderCtx   = glu::createDefaultRenderContext(m_testCtx.getPlatform(), m_testCtx.getCommandLine(), m_apiType);
46         m_contextInfo = glu::ContextInfo::create(*m_renderCtx);
47 
48         // Set up function table for transparent wrapper.
49         glw::setCurrentThreadFunctions(&m_renderCtx->getFunctions());
50     }
51     catch (...)
52     {
53         glw::setCurrentThreadFunctions(DE_NULL);
54 
55         delete m_contextInfo;
56         delete m_renderCtx;
57 
58         throw;
59     }
60 }
61 
~Context(void)62 Context::~Context(void)
63 {
64     // Remove functions from wrapper.
65     glw::setCurrentThreadFunctions(DE_NULL);
66 
67     delete m_contextInfo;
68     delete m_renderCtx;
69 }
70 
getRenderTarget(void) const71 const tcu::RenderTarget &Context::getRenderTarget(void) const
72 {
73     return m_renderCtx->getRenderTarget();
74 }
75 
76 } // namespace gles3
77 } // namespace deqp
78