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