1e5c31af7Sopenharmony_ci/*------------------------------------------------------------------------- 2e5c31af7Sopenharmony_ci * drawElements Quality Program OpenGL ES 2.0 Module 3e5c31af7Sopenharmony_ci * ------------------------------------------------- 4e5c31af7Sopenharmony_ci * 5e5c31af7Sopenharmony_ci * Copyright 2015 The Android Open Source Project 6e5c31af7Sopenharmony_ci * 7e5c31af7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 8e5c31af7Sopenharmony_ci * you may not use this file except in compliance with the License. 9e5c31af7Sopenharmony_ci * You may obtain a copy of the License at 10e5c31af7Sopenharmony_ci * 11e5c31af7Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 12e5c31af7Sopenharmony_ci * 13e5c31af7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 14e5c31af7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 15e5c31af7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16e5c31af7Sopenharmony_ci * See the License for the specific language governing permissions and 17e5c31af7Sopenharmony_ci * limitations under the License. 18e5c31af7Sopenharmony_ci * 19e5c31af7Sopenharmony_ci *//*! 20e5c31af7Sopenharmony_ci * \file 21e5c31af7Sopenharmony_ci * \brief GL_EXT_debug_marker tests 22e5c31af7Sopenharmony_ci *//*--------------------------------------------------------------------*/ 23e5c31af7Sopenharmony_ci 24e5c31af7Sopenharmony_ci#include "es2fDebugMarkerTests.hpp" 25e5c31af7Sopenharmony_ci#include "gluContextInfo.hpp" 26e5c31af7Sopenharmony_ci#include "gluRenderContext.hpp" 27e5c31af7Sopenharmony_ci#include "glwFunctions.hpp" 28e5c31af7Sopenharmony_ci#include "glwEnums.hpp" 29e5c31af7Sopenharmony_ci#include "tcuTestLog.hpp" 30e5c31af7Sopenharmony_ci#include "deRandom.hpp" 31e5c31af7Sopenharmony_ci#include "deUniquePtr.hpp" 32e5c31af7Sopenharmony_ci 33e5c31af7Sopenharmony_cinamespace deqp 34e5c31af7Sopenharmony_ci{ 35e5c31af7Sopenharmony_cinamespace gles2 36e5c31af7Sopenharmony_ci{ 37e5c31af7Sopenharmony_cinamespace Functional 38e5c31af7Sopenharmony_ci{ 39e5c31af7Sopenharmony_ci 40e5c31af7Sopenharmony_cinamespace 41e5c31af7Sopenharmony_ci{ 42e5c31af7Sopenharmony_ci 43e5c31af7Sopenharmony_ciusing std::vector; 44e5c31af7Sopenharmony_ciusing tcu::TestLog; 45e5c31af7Sopenharmony_ci 46e5c31af7Sopenharmony_civoid checkSupport (const glu::ContextInfo& ctxInfo) 47e5c31af7Sopenharmony_ci{ 48e5c31af7Sopenharmony_ci if (!ctxInfo.isExtensionSupported("GL_EXT_debug_marker")) 49e5c31af7Sopenharmony_ci { 50e5c31af7Sopenharmony_ci#if (DE_OS == DE_OS_ANDROID) 51e5c31af7Sopenharmony_ci TCU_THROW(TestError, "Support for GL_EXT_debug_marker is mandatory on Android"); 52e5c31af7Sopenharmony_ci#else 53e5c31af7Sopenharmony_ci TCU_THROW(NotSupportedError, "GL_EXT_debug_marker is not supported"); 54e5c31af7Sopenharmony_ci#endif 55e5c31af7Sopenharmony_ci } 56e5c31af7Sopenharmony_ci // else no exception thrown 57e5c31af7Sopenharmony_ci} 58e5c31af7Sopenharmony_ci 59e5c31af7Sopenharmony_ciclass IsSupportedCase : public TestCase 60e5c31af7Sopenharmony_ci{ 61e5c31af7Sopenharmony_cipublic: 62e5c31af7Sopenharmony_ci IsSupportedCase (Context& context) 63e5c31af7Sopenharmony_ci : TestCase(context, "supported", "Is GL_EXT_debug_marker supported") 64e5c31af7Sopenharmony_ci { 65e5c31af7Sopenharmony_ci } 66e5c31af7Sopenharmony_ci 67e5c31af7Sopenharmony_ci IterateResult iterate (void) 68e5c31af7Sopenharmony_ci { 69e5c31af7Sopenharmony_ci checkSupport(m_context.getContextInfo()); 70e5c31af7Sopenharmony_ci m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "GL_EXT_debug_marker is supported"); 71e5c31af7Sopenharmony_ci return STOP; 72e5c31af7Sopenharmony_ci } 73e5c31af7Sopenharmony_ci}; 74e5c31af7Sopenharmony_ci 75e5c31af7Sopenharmony_civoid getSimpleRndString (vector<char>& dst, de::Random& rnd, int maxLen) 76e5c31af7Sopenharmony_ci{ 77e5c31af7Sopenharmony_ci const char s_chars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ -_"; 78e5c31af7Sopenharmony_ci 79e5c31af7Sopenharmony_ci dst.resize(rnd.getInt(0, (int)maxLen)); 80e5c31af7Sopenharmony_ci 81e5c31af7Sopenharmony_ci for (size_t ndx = 0; ndx < dst.size(); ndx++) 82e5c31af7Sopenharmony_ci dst[ndx] = rnd.choose<char>(DE_ARRAY_BEGIN(s_chars), DE_ARRAY_END(s_chars)); 83e5c31af7Sopenharmony_ci} 84e5c31af7Sopenharmony_ci 85e5c31af7Sopenharmony_civoid getComplexRndString (vector<char>& dst, de::Random& rnd, int maxLen) 86e5c31af7Sopenharmony_ci{ 87e5c31af7Sopenharmony_ci dst.resize(rnd.getInt(0, (int)maxLen)); 88e5c31af7Sopenharmony_ci 89e5c31af7Sopenharmony_ci for (size_t ndx = 0; ndx < dst.size(); ndx++) 90e5c31af7Sopenharmony_ci dst[ndx] = (char)rnd.getUint8(); 91e5c31af7Sopenharmony_ci} 92e5c31af7Sopenharmony_ci 93e5c31af7Sopenharmony_cienum CallType 94e5c31af7Sopenharmony_ci{ 95e5c31af7Sopenharmony_ci CALL_TYPE_PUSH_GROUP = 0, 96e5c31af7Sopenharmony_ci CALL_TYPE_POP_GROUP, 97e5c31af7Sopenharmony_ci CALL_TYPE_INSERT_MARKER, 98e5c31af7Sopenharmony_ci 99e5c31af7Sopenharmony_ci CALL_TYPE_LAST 100e5c31af7Sopenharmony_ci}; 101e5c31af7Sopenharmony_ci 102e5c31af7Sopenharmony_ciclass RandomCase : public TestCase 103e5c31af7Sopenharmony_ci{ 104e5c31af7Sopenharmony_cipublic: 105e5c31af7Sopenharmony_ci RandomCase (Context& context) 106e5c31af7Sopenharmony_ci : TestCase(context, "random", "Random GL_EXT_debug_marker usage") 107e5c31af7Sopenharmony_ci { 108e5c31af7Sopenharmony_ci } 109e5c31af7Sopenharmony_ci 110e5c31af7Sopenharmony_ci void init (void) 111e5c31af7Sopenharmony_ci { 112e5c31af7Sopenharmony_ci checkSupport(m_context.getContextInfo()); 113e5c31af7Sopenharmony_ci } 114e5c31af7Sopenharmony_ci 115e5c31af7Sopenharmony_ci IterateResult iterate (void) 116e5c31af7Sopenharmony_ci { 117e5c31af7Sopenharmony_ci const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 118e5c31af7Sopenharmony_ci const int numIters = 1000; 119e5c31af7Sopenharmony_ci const int maxMsgLen = 4096; 120e5c31af7Sopenharmony_ci de::Random rnd (0xaf829c0); 121e5c31af7Sopenharmony_ci 122e5c31af7Sopenharmony_ci for (int iterNdx = 0; iterNdx < numIters; iterNdx++) 123e5c31af7Sopenharmony_ci { 124e5c31af7Sopenharmony_ci const CallType callType = CallType(rnd.getInt(0, CALL_TYPE_LAST-1)); 125e5c31af7Sopenharmony_ci 126e5c31af7Sopenharmony_ci if (callType == CALL_TYPE_PUSH_GROUP || callType == CALL_TYPE_INSERT_MARKER) 127e5c31af7Sopenharmony_ci { 128e5c31af7Sopenharmony_ci const bool nullTerminate = rnd.getBool(); 129e5c31af7Sopenharmony_ci const bool passLength = rnd.getBool(); 130e5c31af7Sopenharmony_ci const bool complexMsg = rnd.getBool(); 131e5c31af7Sopenharmony_ci vector<char> message; 132e5c31af7Sopenharmony_ci 133e5c31af7Sopenharmony_ci if (complexMsg) 134e5c31af7Sopenharmony_ci getComplexRndString(message, rnd, maxMsgLen); 135e5c31af7Sopenharmony_ci else 136e5c31af7Sopenharmony_ci getSimpleRndString(message, rnd, maxMsgLen); 137e5c31af7Sopenharmony_ci 138e5c31af7Sopenharmony_ci if (nullTerminate) 139e5c31af7Sopenharmony_ci message.push_back(char(0)); 140e5c31af7Sopenharmony_ci 141e5c31af7Sopenharmony_ci { 142e5c31af7Sopenharmony_ci const glw::GLsizei length = passLength ? glw::GLsizei(nullTerminate ? message.size()-1 : message.size()) : 0; 143e5c31af7Sopenharmony_ci 144e5c31af7Sopenharmony_ci if (callType == CALL_TYPE_PUSH_GROUP) 145e5c31af7Sopenharmony_ci gl.pushGroupMarkerEXT(length, &message[0]); 146e5c31af7Sopenharmony_ci else 147e5c31af7Sopenharmony_ci gl.insertEventMarkerEXT(length, &message[0]); 148e5c31af7Sopenharmony_ci } 149e5c31af7Sopenharmony_ci } 150e5c31af7Sopenharmony_ci else 151e5c31af7Sopenharmony_ci gl.popGroupMarkerEXT(); 152e5c31af7Sopenharmony_ci } 153e5c31af7Sopenharmony_ci 154e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "Debug marker calls must not set error state"); 155e5c31af7Sopenharmony_ci 156e5c31af7Sopenharmony_ci m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "All calls passed"); 157e5c31af7Sopenharmony_ci return STOP; 158e5c31af7Sopenharmony_ci } 159e5c31af7Sopenharmony_ci}; 160e5c31af7Sopenharmony_ci 161e5c31af7Sopenharmony_ciclass InvalidCase : public TestCase 162e5c31af7Sopenharmony_ci{ 163e5c31af7Sopenharmony_cipublic: 164e5c31af7Sopenharmony_ci InvalidCase (Context& context) 165e5c31af7Sopenharmony_ci : TestCase(context, "invalid", "Invalid GL_EXT_debug_marker usage") 166e5c31af7Sopenharmony_ci { 167e5c31af7Sopenharmony_ci } 168e5c31af7Sopenharmony_ci 169e5c31af7Sopenharmony_ci void init (void) 170e5c31af7Sopenharmony_ci { 171e5c31af7Sopenharmony_ci checkSupport(m_context.getContextInfo()); 172e5c31af7Sopenharmony_ci } 173e5c31af7Sopenharmony_ci 174e5c31af7Sopenharmony_ci IterateResult iterate (void) 175e5c31af7Sopenharmony_ci { 176e5c31af7Sopenharmony_ci const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 177e5c31af7Sopenharmony_ci 178e5c31af7Sopenharmony_ci m_testCtx.getLog() << TestLog::Message << "Note: GL_EXT_debug_marker calls must not report an error even if invalid arguments are supplied." << TestLog::EndMessage; 179e5c31af7Sopenharmony_ci 180e5c31af7Sopenharmony_ci gl.pushGroupMarkerEXT(-1, "foo"); 181e5c31af7Sopenharmony_ci gl.insertEventMarkerEXT(-1, "foo"); 182e5c31af7Sopenharmony_ci gl.pushGroupMarkerEXT(0, DE_NULL); 183e5c31af7Sopenharmony_ci gl.insertEventMarkerEXT(0, DE_NULL); 184e5c31af7Sopenharmony_ci gl.pushGroupMarkerEXT(-1, DE_NULL); 185e5c31af7Sopenharmony_ci gl.insertEventMarkerEXT(-1, DE_NULL); 186e5c31af7Sopenharmony_ci 187e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "Debug marker calls must not set error state"); 188e5c31af7Sopenharmony_ci 189e5c31af7Sopenharmony_ci m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "All calls passed"); 190e5c31af7Sopenharmony_ci return STOP; 191e5c31af7Sopenharmony_ci } 192e5c31af7Sopenharmony_ci}; 193e5c31af7Sopenharmony_ci 194e5c31af7Sopenharmony_ci} // anonymous 195e5c31af7Sopenharmony_ci 196e5c31af7Sopenharmony_citcu::TestCaseGroup* createDebugMarkerTests (Context& context) 197e5c31af7Sopenharmony_ci{ 198e5c31af7Sopenharmony_ci de::MovePtr<tcu::TestCaseGroup> debugMarkerGroup (new tcu::TestCaseGroup(context.getTestContext(), "debug_marker", "GL_EXT_debug_marker tests")); 199e5c31af7Sopenharmony_ci 200e5c31af7Sopenharmony_ci debugMarkerGroup->addChild(new IsSupportedCase (context)); 201e5c31af7Sopenharmony_ci debugMarkerGroup->addChild(new RandomCase (context)); 202e5c31af7Sopenharmony_ci debugMarkerGroup->addChild(new InvalidCase (context)); 203e5c31af7Sopenharmony_ci 204e5c31af7Sopenharmony_ci return debugMarkerGroup.release(); 205e5c31af7Sopenharmony_ci} 206e5c31af7Sopenharmony_ci 207e5c31af7Sopenharmony_ci} // Functional 208e5c31af7Sopenharmony_ci} // gles2 209e5c31af7Sopenharmony_ci} // deqp 210