1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 2.0 Module
3 * -------------------------------------------------
5 * Copyright 2015 The Android Open Source Project
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 * \brief GL_EXT_debug_marker tests
22 *//*--------------------------------------------------------------------*/
24 #include "es2fDebugMarkerTests.hpp"
25 #include "gluContextInfo.hpp"
26 #include "gluRenderContext.hpp"
27 #include "glwFunctions.hpp"
28 #include "glwEnums.hpp"
29 #include "tcuTestLog.hpp"
30 #include "deRandom.hpp"
31 #include "deUniquePtr.hpp"
46 void checkSupport (const glu::ContextInfo& ctxInfo)
48 if (!ctxInfo.isExtensionSupported("GL_EXT_debug_marker"))
50 #if (DE_OS == DE_OS_ANDROID)
51 TCU_THROW(TestError, "Support for GL_EXT_debug_marker is mandatory on Android");
53 TCU_THROW(NotSupportedError, "GL_EXT_debug_marker is not supported");
56 // else no exception thrown
59 class IsSupportedCase : public TestCase
62 IsSupportedCase (Context& context)
63 : TestCase(context, "supported", "Is GL_EXT_debug_marker supported")
67 IterateResult iterate (void)
69 checkSupport(m_context.getContextInfo());
70 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "GL_EXT_debug_marker is supported");
75 void getSimpleRndString (vector<char>& dst, de::Random& rnd, int maxLen)
77 const char s_chars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ -_";
79 dst.resize(rnd.getInt(0, (int)maxLen));
81 for (size_t ndx = 0; ndx < dst.size(); ndx++)
82 dst[ndx] = rnd.choose<char>(DE_ARRAY_BEGIN(s_chars), DE_ARRAY_END(s_chars));
85 void getComplexRndString (vector<char>& dst, de::Random& rnd, int maxLen)
87 dst.resize(rnd.getInt(0, (int)maxLen));
89 for (size_t ndx = 0; ndx < dst.size(); ndx++)
90 dst[ndx] = (char)rnd.getUint8();
95 CALL_TYPE_PUSH_GROUP = 0,
97 CALL_TYPE_INSERT_MARKER,
102 class RandomCase : public TestCase
105 RandomCase (Context& context)
106 : TestCase(context, "random", "Random GL_EXT_debug_marker usage")
112 checkSupport(m_context.getContextInfo());
115 IterateResult iterate (void)
117 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
118 const int numIters = 1000;
119 const int maxMsgLen = 4096;
120 de::Random rnd (0xaf829c0);
122 for (int iterNdx = 0; iterNdx < numIters; iterNdx++)
124 const CallType callType = CallType(rnd.getInt(0, CALL_TYPE_LAST-1));
126 if (callType == CALL_TYPE_PUSH_GROUP || callType == CALL_TYPE_INSERT_MARKER)
128 const bool nullTerminate = rnd.getBool();
129 const bool passLength = rnd.getBool();
130 const bool complexMsg = rnd.getBool();
131 vector<char> message;
134 getComplexRndString(message, rnd, maxMsgLen);
136 getSimpleRndString(message, rnd, maxMsgLen);
139 message.push_back(char(0));
142 const glw::GLsizei length = passLength ? glw::GLsizei(nullTerminate ? message.size()-1 : message.size()) : 0;
144 if (callType == CALL_TYPE_PUSH_GROUP)
145 gl.pushGroupMarkerEXT(length, &message[0]);
147 gl.insertEventMarkerEXT(length, &message[0]);
151 gl.popGroupMarkerEXT();
154 GLU_EXPECT_NO_ERROR(gl.getError(), "Debug marker calls must not set error state");
156 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "All calls passed");
161 class InvalidCase : public TestCase
164 InvalidCase (Context& context)
165 : TestCase(context, "invalid", "Invalid GL_EXT_debug_marker usage")
171 checkSupport(m_context.getContextInfo());
174 IterateResult iterate (void)
176 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
178 m_testCtx.getLog() << TestLog::Message << "Note: GL_EXT_debug_marker calls must not report an error even if invalid arguments are supplied." << TestLog::EndMessage;
180 gl.pushGroupMarkerEXT(-1, "foo");
181 gl.insertEventMarkerEXT(-1, "foo");
182 gl.pushGroupMarkerEXT(0, DE_NULL);
183 gl.insertEventMarkerEXT(0, DE_NULL);
184 gl.pushGroupMarkerEXT(-1, DE_NULL);
185 gl.insertEventMarkerEXT(-1, DE_NULL);
187 GLU_EXPECT_NO_ERROR(gl.getError(), "Debug marker calls must not set error state");
189 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "All calls passed");
196 tcu::TestCaseGroup* createDebugMarkerTests (Context& context)
198 de::MovePtr<tcu::TestCaseGroup> debugMarkerGroup (new tcu::TestCaseGroup(context.getTestContext(), "debug_marker", "GL_EXT_debug_marker tests"));
200 debugMarkerGroup->addChild(new IsSupportedCase (context));
201 debugMarkerGroup->addChild(new RandomCase (context));
202 debugMarkerGroup->addChild(new InvalidCase (context));
204 return debugMarkerGroup.release();