xref: /aosp_15_r20/external/deqp/modules/gles31/functional/es31fNegativeTestShared.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 Shared structures for ES 3.1 negative API tests
22  *//*--------------------------------------------------------------------*/
23 
24 #include "es31fNegativeTestShared.hpp"
25 
26 #include "tcuResultCollector.hpp"
27 
28 #include "gluContextInfo.hpp"
29 #include "gluRenderContext.hpp"
30 #include "glwFunctions.hpp"
31 
32 namespace deqp
33 {
34 namespace gles31
35 {
36 namespace Functional
37 {
38 namespace NegativeTestShared
39 {
40 
41 using glw::GLenum;
42 using std::string;
43 using tcu::TestLog;
44 
ErrorCase(Context & ctx,const char * name,const char * desc)45 ErrorCase::ErrorCase(Context &ctx, const char *name, const char *desc) : TestCase(ctx, name, desc)
46 {
47 }
48 
NegativeTestContext(ErrorCase & host,glu::RenderContext & renderCtx,const glu::ContextInfo & ctxInfo,tcu::TestLog & log,tcu::ResultCollector & results,bool enableLogging_)49 NegativeTestContext::NegativeTestContext(ErrorCase &host, glu::RenderContext &renderCtx,
50                                          const glu::ContextInfo &ctxInfo, tcu::TestLog &log,
51                                          tcu::ResultCollector &results, bool enableLogging_)
52     : glu::CallLogWrapper(renderCtx.getFunctions(), log)
53     , m_host(host)
54     , m_renderCtx(renderCtx)
55     , m_ctxInfo(ctxInfo)
56     , m_results(results)
57     , m_openSections(0)
58 {
59     enableLogging(enableLogging_);
60 }
61 
~NegativeTestContext()62 NegativeTestContext::~NegativeTestContext()
63 {
64     while (m_openSections--)
65         getLog() << TestLog::EndSection;
66 }
67 
fail(const string & msg)68 void NegativeTestContext::fail(const string &msg)
69 {
70     m_results.addResult(QP_TEST_RESULT_FAIL, msg);
71 }
72 
getInteger(GLenum pname) const73 int NegativeTestContext::getInteger(GLenum pname) const
74 {
75     int retval = 0;
76     m_renderCtx.getFunctions().getIntegerv(pname, &retval);
77     return retval;
78 }
79 
beginSection(const string & desc)80 void NegativeTestContext::beginSection(const string &desc)
81 {
82     if (isLoggingEnabled())
83     {
84         getLog() << TestLog::Section("callstream", desc);
85         m_openSections++;
86     }
87 }
88 
endSection(void)89 void NegativeTestContext::endSection(void)
90 {
91     if (isLoggingEnabled())
92     {
93         DE_ASSERT(m_openSections > 0);
94         getLog() << TestLog::EndSection;
95         m_openSections--;
96     }
97 }
98 
expectError(GLenum error)99 void NegativeTestContext::expectError(GLenum error)
100 {
101     m_host.expectError(error, error);
102 }
103 
expectError(GLenum error0,GLenum error1)104 void NegativeTestContext::expectError(GLenum error0, GLenum error1)
105 {
106     m_host.expectError(error0, error1);
107 }
108 
isShaderSupported(glu::ShaderType shaderType)109 bool NegativeTestContext::isShaderSupported(glu::ShaderType shaderType)
110 {
111     if (contextSupports(getRenderContext().getType(), glu::ApiType::es(3, 2)))
112         return true;
113 
114     switch (shaderType)
115     {
116     case glu::SHADERTYPE_GEOMETRY:
117         return getContextInfo().isExtensionSupported("GL_EXT_geometry_shader");
118     case glu::SHADERTYPE_TESSELLATION_CONTROL:
119     case glu::SHADERTYPE_TESSELLATION_EVALUATION:
120         return getContextInfo().isExtensionSupported("GL_EXT_tessellation_shader");
121     default:
122         return true;
123     }
124 }
125 
isExtensionSupported(std::string extension)126 bool NegativeTestContext::isExtensionSupported(std::string extension)
127 {
128     return getContextInfo().isExtensionSupported(extension.c_str());
129 }
130 
131 } // namespace NegativeTestShared
132 } // namespace Functional
133 } // namespace gles31
134 } // namespace deqp
135