xref: /aosp_15_r20/external/deqp/modules/gles3/tes3InfoTests.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 Platform Information and Capability Tests.
22  *//*--------------------------------------------------------------------*/
23 
24 #include "tes3InfoTests.hpp"
25 #include "tcuTestLog.hpp"
26 #include "gluDefs.hpp"
27 #include "gluContextInfo.hpp"
28 #include "gluRenderContext.hpp"
29 #include "tcuRenderTarget.hpp"
30 
31 #include "glwFunctions.hpp"
32 #include "glwEnums.hpp"
33 
34 #include <string>
35 #include <vector>
36 
37 using std::string;
38 using std::vector;
39 
40 namespace deqp
41 {
42 namespace gles3
43 {
44 
45 class QueryStringCase : public TestCase
46 {
47 public:
QueryStringCase(Context & context,const char * name,const char * description,uint32_t query)48     QueryStringCase(Context &context, const char *name, const char *description, uint32_t query)
49         : TestCase(context, name, description)
50         , m_query(query)
51     {
52     }
53 
iterate(void)54     IterateResult iterate(void)
55     {
56         const glw::Functions &gl = m_context.getRenderContext().getFunctions();
57         const char *result       = (const char *)gl.getString(m_query);
58 
59         GLU_EXPECT_NO_ERROR(gl.getError(), "glGetString() failed");
60 
61         m_testCtx.getLog() << tcu::TestLog::Message << result << tcu::TestLog::EndMessage;
62         m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
63 
64         return STOP;
65     }
66 
67 private:
68     uint32_t m_query;
69 };
70 
71 class QueryExtensionsCase : public TestCase
72 {
73 public:
QueryExtensionsCase(Context & context)74     QueryExtensionsCase(Context &context) : TestCase(context, "extensions", "Supported Extensions")
75     {
76     }
77 
iterate(void)78     IterateResult iterate(void)
79     {
80         const vector<string> extensions = m_context.getContextInfo().getExtensions();
81 
82         for (vector<string>::const_iterator i = extensions.begin(); i != extensions.end(); i++)
83             m_testCtx.getLog() << tcu::TestLog::Message << *i << tcu::TestLog::EndMessage;
84 
85         m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
86 
87         return STOP;
88     }
89 };
90 
91 class RenderTargetInfoCase : public TestCase
92 {
93 public:
RenderTargetInfoCase(Context & context)94     RenderTargetInfoCase(Context &context) : TestCase(context, "render_target", "Render Target Info")
95     {
96     }
97 
iterate(void)98     IterateResult iterate(void)
99     {
100         const tcu::RenderTarget &rt = m_context.getRenderTarget();
101         const tcu::PixelFormat &pf  = rt.getPixelFormat();
102 
103         m_testCtx.getLog() << tcu::TestLog::Integer("RedBits", "Red channel bits", "", QP_KEY_TAG_NONE, pf.redBits)
104                            << tcu::TestLog::Integer("GreenBits", "Green channel bits", "", QP_KEY_TAG_NONE,
105                                                     pf.greenBits)
106                            << tcu::TestLog::Integer("BlueBits", "Blue channel bits", "", QP_KEY_TAG_NONE, pf.blueBits)
107                            << tcu::TestLog::Integer("AlphaBits", "Alpha channel bits", "", QP_KEY_TAG_NONE,
108                                                     pf.alphaBits)
109                            << tcu::TestLog::Integer("DepthBits", "Depth bits", "", QP_KEY_TAG_NONE, rt.getDepthBits())
110                            << tcu::TestLog::Integer("StencilBits", "Stencil bits", "", QP_KEY_TAG_NONE,
111                                                     rt.getStencilBits())
112                            << tcu::TestLog::Integer("NumSamples", "Number of samples", "", QP_KEY_TAG_NONE,
113                                                     rt.getNumSamples())
114                            << tcu::TestLog::Integer("Width", "Width", "", QP_KEY_TAG_NONE, rt.getWidth())
115                            << tcu::TestLog::Integer("Height", "Height", "", QP_KEY_TAG_NONE, rt.getHeight());
116 
117         m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
118         return STOP;
119     }
120 };
121 
InfoTests(Context & context)122 InfoTests::InfoTests(Context &context) : TestCaseGroup(context, "info", "Platform information queries")
123 {
124 }
125 
~InfoTests(void)126 InfoTests::~InfoTests(void)
127 {
128 }
129 
init(void)130 void InfoTests::init(void)
131 {
132     addChild(new QueryStringCase(m_context, "vendor", "Vendor String", GL_VENDOR));
133     addChild(new QueryStringCase(m_context, "renderer", "Renderer String", GL_RENDERER));
134     addChild(new QueryStringCase(m_context, "version", "Version String", GL_VERSION));
135     addChild(new QueryStringCase(m_context, "shading_language_version", "Shading Language Version String",
136                                  GL_SHADING_LANGUAGE_VERSION));
137     addChild(new QueryExtensionsCase(m_context));
138     addChild(new RenderTargetInfoCase(m_context));
139 }
140 
141 } // namespace gles3
142 } // namespace deqp
143