xref: /aosp_15_r20/external/deqp/modules/gles31/tes31Context.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program OpenGL ES 3.1 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.1 test context.
22  *//*--------------------------------------------------------------------*/
23 
24 #include "tes31Context.hpp"
25 #include "gluRenderConfig.hpp"
26 #include "gluFboRenderContext.hpp"
27 #include "gluContextInfo.hpp"
28 #include "gluDummyRenderContext.hpp"
29 #include "tcuCommandLine.hpp"
30 
31 namespace deqp
32 {
33 namespace gles31
34 {
35 
Context(tcu::TestContext & testCtx,glu::ApiType apiType)36 Context::Context(tcu::TestContext &testCtx, glu::ApiType apiType)
37     : m_testCtx(testCtx)
38     , m_renderCtx(DE_NULL)
39     , m_contextInfo(DE_NULL)
40     , m_apiType(apiType)
41 {
42     if (m_testCtx.getCommandLine().getRunMode() == tcu::RUNMODE_EXECUTE)
43         createRenderContext();
44     else
45     {
46         // \todo [2016-11-15 pyry] Many tests (erroneously) inspect context type
47         //                           during test hierarchy construction. We should fix that
48         //                           and revert empty context to advertise unknown context type.
49         m_renderCtx = new glu::EmptyRenderContext(glu::ContextType(glu::ApiType::es(3, 1)));
50     }
51 }
52 
~Context(void)53 Context::~Context(void)
54 {
55     destroyRenderContext();
56 }
57 
createRenderContext(void)58 void Context::createRenderContext(void)
59 {
60     DE_ASSERT(!m_renderCtx && !m_contextInfo);
61 
62     try
63     {
64         m_renderCtx   = glu::createDefaultRenderContext(m_testCtx.getPlatform(), m_testCtx.getCommandLine(), m_apiType);
65         m_contextInfo = glu::ContextInfo::create(*m_renderCtx);
66     }
67     catch (...)
68     {
69         destroyRenderContext();
70         throw;
71     }
72 }
73 
destroyRenderContext(void)74 void Context::destroyRenderContext(void)
75 {
76     delete m_contextInfo;
77     delete m_renderCtx;
78 
79     m_contextInfo = DE_NULL;
80     m_renderCtx   = DE_NULL;
81 }
82 
getRenderTarget(void) const83 const tcu::RenderTarget &Context::getRenderTarget(void) const
84 {
85     return m_renderCtx->getRenderTarget();
86 }
87 
88 } // namespace gles31
89 } // namespace deqp
90