1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 3.1 Module
3 * -------------------------------------------------
5 * Copyright 2014 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 Debug output (KHR_debug) tests
22 *//*--------------------------------------------------------------------*/
24 #include "es31fDebugTests.hpp"
26 #include "es31fNegativeTestShared.hpp"
27 #include "es31fNegativeBufferApiTests.hpp"
28 #include "es31fNegativeTextureApiTests.hpp"
29 #include "es31fNegativeShaderApiTests.hpp"
30 #include "es31fNegativeFragmentApiTests.hpp"
31 #include "es31fNegativeVertexArrayApiTests.hpp"
32 #include "es31fNegativeStateApiTests.hpp"
33 #include "es31fNegativeAtomicCounterTests.hpp"
34 #include "es31fNegativeShaderImageLoadStoreTests.hpp"
35 #include "es31fNegativeShaderFunctionTests.hpp"
36 #include "es31fNegativeShaderDirectiveTests.hpp"
37 #include "es31fNegativeSSBOBlockTests.hpp"
38 #include "es31fNegativePreciseTests.hpp"
39 #include "es31fNegativeAdvancedBlendEquationTests.hpp"
40 #include "es31fNegativeShaderStorageTests.hpp"
41 #include "es31fNegativeTessellationTests.hpp"
43 #include "deUniquePtr.hpp"
44 #include "deRandom.hpp"
45 #include "deStringUtil.hpp"
46 #include "deSTLUtil.hpp"
47 #include "deMutex.hpp"
50 #include "gluRenderContext.hpp"
51 #include "gluContextInfo.hpp"
52 #include "gluCallLogWrapper.hpp"
53 #include "gluStrUtil.hpp"
55 #include "glwDefs.hpp"
56 #include "glwEnums.hpp"
57 #include "glwFunctions.hpp"
59 #include "tes31Context.hpp"
60 #include "tcuTestContext.hpp"
61 #include "tcuCommandLine.hpp"
62 #include "tcuResultCollector.hpp"
64 #include "glsStateQueryUtil.hpp"
82 using tcu::ResultCollector;
84 using glu::CallLogWrapper;
86 using NegativeTestShared::NegativeTestContext;
88 static const GLenum s_debugTypes[] =
91 GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR,
92 GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR,
93 GL_DEBUG_TYPE_PORTABILITY,
94 GL_DEBUG_TYPE_PERFORMANCE,
97 GL_DEBUG_TYPE_PUSH_GROUP,
98 GL_DEBUG_TYPE_POP_GROUP,
101 static const GLenum s_debugSeverities[] =
103 GL_DEBUG_SEVERITY_HIGH,
104 GL_DEBUG_SEVERITY_MEDIUM,
105 GL_DEBUG_SEVERITY_LOW,
106 GL_DEBUG_SEVERITY_NOTIFICATION,
109 static bool isKHRDebugSupported (Context& ctx)
111 const bool isES32 = glu::contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2));
112 return isES32 || ctx.getContextInfo().isExtensionSupported("GL_KHR_debug");
117 class DebugMessageTestContext : public NegativeTestContext
120 DebugMessageTestContext (BaseCase& host,
121 glu::RenderContext& renderCtx,
122 const glu::ContextInfo& ctxInfo,
124 tcu::ResultCollector& results,
126 ~DebugMessageTestContext (void);
128 void expectMessage (GLenum source, GLenum type);
131 BaseCase& m_debugHost;
134 class TestFunctionWrapper
137 typedef void (*CoreTestFunc)(NegativeTestContext& ctx);
138 typedef void (*DebugTestFunc)(DebugMessageTestContext& ctx);
140 TestFunctionWrapper (void);
141 explicit TestFunctionWrapper (CoreTestFunc func);
142 explicit TestFunctionWrapper (DebugTestFunc func);
144 void call (DebugMessageTestContext& ctx) const;
158 DebugTestFunc debugFn;
162 TestFunctionWrapper::TestFunctionWrapper (void)
167 TestFunctionWrapper::TestFunctionWrapper (CoreTestFunc func)
170 m_func.coreFn = func;
173 TestFunctionWrapper::TestFunctionWrapper (DebugTestFunc func)
176 m_func.debugFn = func;
179 void TestFunctionWrapper::call (DebugMessageTestContext& ctx) const
181 if (m_type == TYPE_CORE)
182 m_func.coreFn(static_cast<NegativeTestContext&>(ctx));
183 else if (m_type == TYPE_DEBUG)
189 void emitMessages (DebugMessageTestContext& ctx, GLenum source)
191 for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(s_debugTypes); typeNdx++)
193 for (int severityNdx = 0; severityNdx < DE_LENGTH_OF_ARRAY(s_debugSeverities); severityNdx++)
195 const GLenum type = s_debugTypes[typeNdx];
196 const GLenum severity = s_debugSeverities[severityNdx];
197 const string msg = string("Application generated message with type ") + glu::getDebugMessageTypeName(type)
198 + " and severity " + glu::getDebugMessageSeverityName(severity);
200 // Use severity as ID, guaranteed unique
201 ctx.glDebugMessageInsert(source, type, severity, severity, -1, msg.c_str());
202 ctx.expectMessage(source, type);
207 void application_messages (DebugMessageTestContext& ctx)
209 ctx.beginSection("Messages with source of GL_DEBUG_SOURCE_APPLICATION");
210 emitMessages(ctx, GL_DEBUG_SOURCE_APPLICATION);
214 void thirdparty_messages (DebugMessageTestContext& ctx)
216 ctx.beginSection("Messages with source of GL_DEBUG_SOURCE_THIRD_PARTY");
217 emitMessages(ctx, GL_DEBUG_SOURCE_THIRD_PARTY);
221 void push_pop_messages (DebugMessageTestContext& ctx)
223 ctx.beginSection("Push/Pop Debug Group");
225 ctx.glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 1, -1, "Application group 1");
226 ctx.expectMessage(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PUSH_GROUP);
227 ctx.glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 2, -1, "Application group 1-1");
228 ctx.expectMessage(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PUSH_GROUP);
229 ctx.glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 3, -1, "Application group 1-1-1");
230 ctx.expectMessage(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PUSH_GROUP);
231 ctx.glPopDebugGroup();
232 ctx.expectMessage(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_POP_GROUP);
233 ctx.glPopDebugGroup();
234 ctx.expectMessage(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_POP_GROUP);
236 ctx.glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 4, -1, "Application group 1-2");
237 ctx.expectMessage(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PUSH_GROUP);
238 ctx.glPopDebugGroup();
239 ctx.expectMessage(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_POP_GROUP);
241 ctx.glPushDebugGroup(GL_DEBUG_SOURCE_THIRD_PARTY, 4, -1, "3rd Party group 1-3");
242 ctx.expectMessage(GL_DEBUG_SOURCE_THIRD_PARTY, GL_DEBUG_TYPE_PUSH_GROUP);
243 ctx.glPopDebugGroup();
244 ctx.expectMessage(GL_DEBUG_SOURCE_THIRD_PARTY, GL_DEBUG_TYPE_POP_GROUP);
245 ctx.glPopDebugGroup();
246 ctx.expectMessage(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_POP_GROUP);
248 ctx.glPushDebugGroup(GL_DEBUG_SOURCE_THIRD_PARTY, 4, -1, "3rd Party group 2");
249 ctx.expectMessage(GL_DEBUG_SOURCE_THIRD_PARTY, GL_DEBUG_TYPE_PUSH_GROUP);
250 ctx.glPopDebugGroup();
251 ctx.expectMessage(GL_DEBUG_SOURCE_THIRD_PARTY, GL_DEBUG_TYPE_POP_GROUP);
256 struct FunctionContainer
258 TestFunctionWrapper function;
263 vector<FunctionContainer> getUserMessageFuncs (void)
265 FunctionContainer funcs[] =
267 { TestFunctionWrapper(application_messages), "application_messages", "Externally generated messages from the application" },
268 { TestFunctionWrapper(thirdparty_messages), "third_party_messages", "Externally generated messages from a third party" },
269 { TestFunctionWrapper(push_pop_messages), "push_pop_stack", "Messages from pushing/popping debug groups" },
272 return std::vector<FunctionContainer>(DE_ARRAY_BEGIN(funcs), DE_ARRAY_END(funcs));
275 // Data required to uniquely identify a debug message
282 MessageID (void) : source(GL_NONE), type(GL_NONE), id(0) {}
283 MessageID (GLenum source_, GLenum type_, GLuint id_) : source(source_), type(type_), id(id_) {}
285 bool operator== (const MessageID& rhs) const { return source == rhs.source && type == rhs.type && id == rhs.id;}
286 bool operator!= (const MessageID& rhs) const { return source != rhs.source || type != rhs.type || id != rhs.id;}
287 bool operator< (const MessageID& rhs) const
289 return source < rhs.source || (source == rhs.source && (type < rhs.type || (type == rhs.type && id < rhs.id)));
293 std::ostream& operator<< (std::ostream& str, const MessageID &id)
295 return str << glu::getDebugMessageSourceStr(id.source) << ", " << glu::getDebugMessageTypeStr(id.type) << ", " << id.id;
298 // All info from a single debug message
305 MessageData (void) : id(MessageID()), severity(GL_NONE) {}
306 MessageData (const MessageID& id_, GLenum severity_, const string& message_) : id(id_) , severity(severity_) , message(message_) {}
309 extern "C" typedef void GLW_APIENTRY DebugCallbackFunc(GLenum, GLenum, GLuint, GLenum, GLsizei, const char*, void*);
312 class BaseCase : public NegativeTestShared::ErrorCase
315 BaseCase (Context& ctx,
318 virtual ~BaseCase (void) {}
320 virtual IterateResult iterate (void) = 0;
322 virtual void expectMessage (GLenum source, GLenum type);
323 virtual void expectError (GLenum error0, GLenum error1);
326 struct VerificationResult {
327 const qpTestResult result;
328 const string resultMessage;
329 const string logMessage;
331 VerificationResult (qpTestResult result_, const string& resultMessage_, const string& logMessage_)
332 : result(result_), resultMessage(resultMessage_), logMessage(logMessage_) {}
335 static DebugCallbackFunc callbackHandle;
336 virtual void callback (GLenum source, GLenum type, GLuint id, GLenum severity, const std::string& message);
339 VerificationResult verifyMessageCount (const MessageID& id, GLenum severity, int refCount, int resCount, bool messageEnabled) const;
341 // Verify a single message instance against expected attributes
342 void verifyMessage (const MessageData& message, GLenum source, GLenum type, GLuint id, GLenum severity);
343 void verifyMessage (const MessageData& message, GLenum source, GLenum type);
345 bool verifyMessageExists (const MessageData& message, GLenum source, GLenum type);
346 void verifyMessageGroup (const MessageData& message, GLenum source, GLenum type);
347 void verifyMessageString (const MessageData& message);
349 bool isDebugContext (void) const;
351 tcu::ResultCollector m_results;
354 void BaseCase::callbackHandle (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const char* message, void* userParam)
356 static_cast<BaseCase*>(userParam)->callback(source, type, id, severity, string(message, &message[length]));
359 BaseCase::BaseCase (Context& ctx, const char* name, const char* desc)
360 : ErrorCase(ctx, name, desc)
364 void BaseCase::expectMessage (GLenum source, GLenum type)
370 void BaseCase::expectError (GLenum error0, GLenum error1)
372 if (error0 != GL_NO_ERROR || error1 != GL_NO_ERROR)
373 expectMessage(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_ERROR);
375 expectMessage(GL_DONT_CARE, GL_DONT_CARE);
378 void BaseCase::callback (GLenum source, GLenum type, GLuint id, GLenum severity, const string& message)
387 BaseCase::VerificationResult BaseCase::verifyMessageCount (const MessageID& id, GLenum severity, int refCount, int resCount, bool messageEnabled) const
389 std::stringstream log;
391 // This message should not be filtered out
394 if (resCount != refCount)
397 * Technically nothing requires the implementation to be consistent in terms
398 * of the messages it produces in most situations, allowing the set of messages
399 * produced to vary between executions. This function splits messages
400 * into deterministic and non-deterministic to facilitate handling of such messages.
402 * Non-deterministic messages that are present in differing quantities in filtered and
403 * unfiltered runs will not fail the test case unless in direct violation of a filter:
404 * the implementation may produce an arbitrary number of such messages when they are
405 * not filtered out and none when they are filtered.
407 * A list of error source/type combinations with their assumed behaviour and
408 * the rationale for expecting such behaviour follows
410 * For API/shader messages we assume that the following types are deterministic:
411 * DEBUG_TYPE_ERROR Errors specified by spec and should always be produced
413 * For API messages the following types are assumed to be non-deterministic
414 * and treated as quality warnings since the underlying reported issue does not change between calls:
415 * DEBUG_TYPE_DEPRECATED_BEHAVIOR Reasonable to only report first instance
416 * DEBUG_TYPE_UNDEFINED_BEHAVIOR Reasonable to only report first instance
417 * DEBUG_TYPE_PORTABILITY Reasonable to only report first instance
419 * For API messages the following types are assumed to be non-deterministic
420 * and do not affect test results.
421 * DEBUG_TYPE_PERFORMANCE May be tied to arbitrary factors, reasonable to report only first instance
422 * DEBUG_TYPE_OTHER Definition allows arbitrary contents
424 * For 3rd party and application messages the following types are deterministic:
425 * DEBUG_TYPE_MARKER Only generated by test
426 * DEBUG_TYPE_PUSH_GROUP Only generated by test
427 * DEBUG_TYPE_POP_GROUP Only generated by test
428 * All others Only generated by test
430 * All messages with category of window system or other are treated as non-deterministic
431 * and do not effect test results since they can be assumed to be outside control of
432 * both the implementation and test case
436 const bool isDeterministic = id.source == GL_DEBUG_SOURCE_APPLICATION ||
437 id.source == GL_DEBUG_SOURCE_THIRD_PARTY ||
438 ((id.source == GL_DEBUG_SOURCE_API || id.source == GL_DEBUG_SOURCE_SHADER_COMPILER) && id.type == GL_DEBUG_TYPE_ERROR);
440 const bool canIgnore = id.source == GL_DEBUG_SOURCE_WINDOW_SYSTEM || id.source == GL_DEBUG_SOURCE_OTHER;
444 if (resCount > refCount)
446 log << "Extra instances of message were found: (" << id << ") with "
447 << glu::getDebugMessageSeverityStr(severity)
448 << " (got " << resCount << ", expected " << refCount << ")";
449 return VerificationResult(QP_TEST_RESULT_FAIL, "Extra instances of a deterministic message were present", log.str());
453 log << "Instances of message were missing: (" << id << ") with "
454 << glu::getDebugMessageSeverityStr(severity)
455 << " (got " << resCount << ", expected " << refCount << ")";
456 return VerificationResult(QP_TEST_RESULT_FAIL, "Message missing", log.str());
461 if (resCount > refCount)
463 log << "Extra instances of message were found but the message is non-deterministic(warning): (" << id << ") with "
464 << glu::getDebugMessageSeverityStr(severity)
465 << " (got " << resCount << ", expected " << refCount << ")";
466 return VerificationResult(QP_TEST_RESULT_QUALITY_WARNING, "Extra instances of a message were present", log.str());
470 log << "Instances of message were missing but the message is non-deterministic(warning): (" << id << ") with "
471 << glu::getDebugMessageSeverityStr(severity)
472 << " (got " << resCount << ", expected " << refCount << ")";
473 return VerificationResult(QP_TEST_RESULT_QUALITY_WARNING, "Message missing", log.str());
478 if (resCount > refCount)
480 log << "Extra instances of message were found but the message is non-deterministic(ignored): (" << id << ") with "
481 << glu::getDebugMessageSeverityStr(severity)
482 << " (got " << resCount << ", expected " << refCount << ")";
483 return VerificationResult(QP_TEST_RESULT_PASS, "", log.str());
487 log << "Instances of message were missing but the message is non-deterministic(ignored): (" << id << ") with "
488 << glu::getDebugMessageSeverityStr(severity)
489 << " (got " << resCount << ", expected " << refCount << ")";
490 return VerificationResult(QP_TEST_RESULT_PASS, "", log.str());
494 else // Passed as appropriate
496 log << "Message was found when expected: ("<< id << ") with "
497 << glu::getDebugMessageSeverityStr(severity);
498 return VerificationResult(QP_TEST_RESULT_PASS, "", log.str());
501 // Message should be filtered out
507 log << "Message was excluded correctly: (" << id << ") with "
508 << glu::getDebugMessageSeverityStr(severity);
509 return VerificationResult(QP_TEST_RESULT_PASS, "", log.str());
511 // Only present in filtered run (ERROR)
512 else if (resCount > 0 && refCount == 0)
514 log << "A message was not excluded as it should have been: (" << id << ") with "
515 << glu::getDebugMessageSeverityStr(severity)
516 << ". This message was not present in the reference run";
517 return VerificationResult(QP_TEST_RESULT_FAIL, "A message was not filtered out", log.str());
519 // Present in both runs (ERROR)
522 log << "A message was not excluded as it should have been: (" << id << ") with "
523 << glu::getDebugMessageSeverityStr(severity);
524 return VerificationResult(QP_TEST_RESULT_FAIL, "A message was not filtered out", log.str());
529 // Return true if message needs further verification
530 bool BaseCase::verifyMessageExists (const MessageData& message, GLenum source, GLenum type)
532 TestLog& log = m_testCtx.getLog();
534 if (source == GL_DONT_CARE || type == GL_DONT_CARE)
536 else if (message.id.source == GL_NONE || message.id.type == GL_NONE)
538 if (isDebugContext())
540 m_results.addResult(QP_TEST_RESULT_FAIL, "Message was not reported as expected");
541 log << TestLog::Message << "A message was expected but none was reported" << TestLog::EndMessage;
545 m_results.addResult(QP_TEST_RESULT_QUALITY_WARNING, "Verification accuracy is lacking without a debug context");
546 log << TestLog::Message << "A message was expected but none was reported. Running without a debug context" << TestLog::EndMessage;
554 void BaseCase::verifyMessageGroup (const MessageData& message, GLenum source, GLenum type)
556 TestLog& log = m_testCtx.getLog();
558 if (message.id.source != source)
560 m_results.addResult(QP_TEST_RESULT_FAIL, "Incorrect message source");
561 log << TestLog::Message << "Message source was " << glu::getDebugMessageSourceStr(message.id.source)
562 << " when it should have been " << glu::getDebugMessageSourceStr(source) << TestLog::EndMessage;
565 if (message.id.type != type)
567 m_results.addResult(QP_TEST_RESULT_FAIL, "Incorrect message type");
568 log << TestLog::Message << "Message type was " << glu::getDebugMessageTypeStr(message.id.type)
569 << " when it should have been " << glu::getDebugMessageTypeStr(type) << TestLog::EndMessage;
573 void BaseCase::verifyMessageString (const MessageData& message)
575 TestLog& log = m_testCtx.getLog();
577 log << TestLog::Message << "Driver says: \"" << message.message << "\"" << TestLog::EndMessage;
579 if (message.message.empty())
581 m_results.addResult(QP_TEST_RESULT_QUALITY_WARNING, "Empty message");
582 log << TestLog::Message << "Message message was empty" << TestLog::EndMessage;
586 void BaseCase::verifyMessage (const MessageData& message, GLenum source, GLenum type)
588 if (verifyMessageExists(message, source, type))
590 verifyMessageString(message);
591 verifyMessageGroup(message, source, type);
595 void BaseCase::verifyMessage (const MessageData& message, GLenum source, GLenum type, GLuint id, GLenum severity)
597 TestLog& log = m_testCtx.getLog();
599 if (verifyMessageExists(message, source, type))
601 verifyMessageString(message);
602 verifyMessageGroup(message, source, type);
604 if (message.id.id != id)
606 m_results.addResult(QP_TEST_RESULT_FAIL, "Incorrect message id");
607 log << TestLog::Message << "Message id was " << message.id.id
608 << " when it should have been " << id << TestLog::EndMessage;
611 if (message.severity != severity)
613 m_results.addResult(QP_TEST_RESULT_FAIL, "Incorrect message severity");
614 log << TestLog::Message << "Message severity was " << glu::getDebugMessageSeverityStr(message.severity)
615 << " when it should have been " << glu::getDebugMessageSeverityStr(severity) << TestLog::EndMessage;
620 bool BaseCase::isDebugContext (void) const
622 return (m_context.getRenderContext().getType().getFlags() & glu::CONTEXT_DEBUG) != 0;
625 // Generate errors, verify that each error results in a callback call
626 class CallbackErrorCase : public BaseCase
629 CallbackErrorCase (Context& ctx,
632 TestFunctionWrapper errorFunc);
633 virtual ~CallbackErrorCase (void) {}
635 virtual IterateResult iterate (void);
637 virtual void expectMessage (GLenum source, GLenum type);
640 virtual void callback (GLenum source, GLenum type, GLuint id, GLenum severity, const string& message);
642 const TestFunctionWrapper m_errorFunc;
643 MessageData m_lastMessage;
646 CallbackErrorCase::CallbackErrorCase (Context& ctx,
649 TestFunctionWrapper errorFunc)
650 : BaseCase (ctx, name, desc)
651 , m_errorFunc (errorFunc)
655 CallbackErrorCase::IterateResult CallbackErrorCase::iterate (void)
657 TCU_CHECK_AND_THROW(NotSupportedError, isKHRDebugSupported(m_context), "GL_KHR_debug is not supported");
659 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
660 tcu::TestLog& log = m_testCtx.getLog();
661 DebugMessageTestContext context = DebugMessageTestContext(*this, m_context.getRenderContext(), m_context.getContextInfo(), log, m_results, true);
663 gl.enable(GL_DEBUG_OUTPUT);
664 gl.enable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
665 gl.debugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, DE_NULL, false); // disable all
666 gl.debugMessageControl(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_ERROR, GL_DONT_CARE, 0, DE_NULL, true); // enable API errors
667 gl.debugMessageControl(GL_DEBUG_SOURCE_APPLICATION, GL_DONT_CARE, GL_DONT_CARE, 0, DE_NULL, true); // enable application messages
668 gl.debugMessageControl(GL_DEBUG_SOURCE_THIRD_PARTY, GL_DONT_CARE, GL_DONT_CARE, 0, DE_NULL, true); // enable third party messages
669 gl.debugMessageCallback(callbackHandle, this);
671 m_errorFunc.call(context);
673 gl.debugMessageCallback(DE_NULL, DE_NULL);
674 gl.disable(GL_DEBUG_OUTPUT);
676 m_results.setTestContextResult(m_testCtx);
681 void CallbackErrorCase::expectMessage (GLenum source, GLenum type)
683 verifyMessage(m_lastMessage, source, type);
684 m_lastMessage = MessageData();
686 // Reset error so that code afterwards (such as glu::ShaderProgram) doesn't break because of
687 // lingering error state.
688 m_context.getRenderContext().getFunctions().getError();
691 void CallbackErrorCase::callback (GLenum source, GLenum type, GLuint id, GLenum severity, const string& message)
693 m_lastMessage = MessageData(MessageID(source, type, id), severity, message);
696 // Generate errors, verify that each error results in a log entry
697 class LogErrorCase : public BaseCase
700 LogErrorCase (Context& context,
703 TestFunctionWrapper errorFunc);
704 virtual ~LogErrorCase (void) {}
706 virtual IterateResult iterate (void);
708 virtual void expectMessage (GLenum source, GLenum type);
711 const TestFunctionWrapper m_errorFunc;
712 MessageData m_lastMessage;
715 LogErrorCase::LogErrorCase (Context& ctx,
718 TestFunctionWrapper errorFunc)
719 : BaseCase (ctx, name, desc)
720 , m_errorFunc (errorFunc)
724 LogErrorCase::IterateResult LogErrorCase::iterate (void)
726 TCU_CHECK_AND_THROW(NotSupportedError, isKHRDebugSupported(m_context), "GL_KHR_debug is not supported");
728 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
729 tcu::TestLog& log = m_testCtx.getLog();
730 DebugMessageTestContext context = DebugMessageTestContext(*this, m_context.getRenderContext(), m_context.getContextInfo(), log, m_results, true);
733 gl.enable(GL_DEBUG_OUTPUT);
734 gl.enable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
735 gl.debugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, DE_NULL, false); // disable all
736 gl.debugMessageControl(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_ERROR, GL_DONT_CARE, 0, DE_NULL, true); // enable API errors
737 gl.debugMessageCallback(DE_NULL, DE_NULL); // enable logging
738 gl.getIntegerv(GL_DEBUG_LOGGED_MESSAGES, &numMsg);
739 gl.getDebugMessageLog(numMsg, 0, DE_NULL, DE_NULL, DE_NULL, DE_NULL, DE_NULL, DE_NULL); // clear log
741 m_errorFunc.call(context);
743 gl.disable(GL_DEBUG_OUTPUT);
744 m_results.setTestContextResult(m_testCtx);
749 void LogErrorCase::expectMessage (GLenum source, GLenum type)
751 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
753 TestLog& log = m_testCtx.getLog();
756 if (source == GL_DONT_CARE || type == GL_DONT_CARE)
759 gl.getIntegerv(GL_DEBUG_LOGGED_MESSAGES, &numMsg);
763 if (isDebugContext())
765 m_results.addResult(QP_TEST_RESULT_FAIL, "Error was not reported as expected");
766 log << TestLog::Message << "A message was expected but none was reported (empty message log)" << TestLog::EndMessage;
770 m_results.addResult(QP_TEST_RESULT_QUALITY_WARNING, "Verification accuracy is lacking without a debug context");
771 log << TestLog::Message << "A message was expected but none was reported (empty message log). Running without a debug context" << TestLog::EndMessage;
776 // There may be messages other than the error we are looking for in the log.
777 // Strictly nothing prevents the implementation from producing more than the
778 // required error from an API call with a defined error. however we assume that
779 // since calls that produce an error should not change GL state the implementation
780 // should have nothing else to report.
782 gl.getDebugMessageLog(numMsg-1, 0, DE_NULL, DE_NULL, DE_NULL, DE_NULL, DE_NULL, DE_NULL); // Clear all but last
786 gl.getIntegerv(GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH, &msgLen);
788 TCU_CHECK_MSG(msgLen >= 0, "Negative message length");
789 TCU_CHECK_MSG(msgLen < 100000, "Excessively long message");
791 lastMsg.message.resize(msgLen);
792 gl.getDebugMessageLog(1, msgLen, &lastMsg.id.source, &lastMsg.id.type, &lastMsg.id.id, &lastMsg.severity, &msgLen, &lastMsg.message[0]);
795 log << TestLog::Message << "Driver says: \"" << lastMsg.message << "\"" << TestLog::EndMessage;
797 verifyMessage(lastMsg, source, type);
799 // Reset error so that code afterwards (such as glu::ShaderProgram) doesn't break because of
800 // lingering error state.
801 m_context.getRenderContext().getFunctions().getError();
804 // Generate errors, verify that calling glGetError afterwards produces desired result
805 class GetErrorCase : public BaseCase
808 GetErrorCase (Context& ctx,
811 TestFunctionWrapper errorFunc);
812 virtual ~GetErrorCase (void) {}
814 virtual IterateResult iterate (void);
816 virtual void expectMessage (GLenum source, GLenum type);
817 virtual void expectError (glw::GLenum error0, glw::GLenum error1);
820 const TestFunctionWrapper m_errorFunc;
823 GetErrorCase::GetErrorCase (Context& ctx,
826 TestFunctionWrapper errorFunc)
827 : BaseCase (ctx, name, desc)
828 , m_errorFunc (errorFunc)
832 GetErrorCase::IterateResult GetErrorCase::iterate (void)
834 tcu::TestLog& log = m_testCtx.getLog();
835 DebugMessageTestContext context = DebugMessageTestContext(*this, m_context.getRenderContext(), m_context.getContextInfo(), log, m_results, true);
837 m_errorFunc.call(context);
839 m_results.setTestContextResult(m_testCtx);
844 void GetErrorCase::expectMessage (GLenum source, GLenum type)
848 DE_FATAL("GetErrorCase cannot handle anything other than error codes");
851 void GetErrorCase::expectError (glw::GLenum error0, glw::GLenum error1)
853 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
854 TestLog& log = m_testCtx.getLog();
856 const GLenum result = gl.getError();
858 if (result != error0 && result != error1)
860 m_results.addResult(QP_TEST_RESULT_FAIL, "Incorrect error was reported");
861 if (error0 == error1)
862 log << TestLog::Message
863 << glu::getErrorStr(error0) << " was expected but got "
864 << glu::getErrorStr(result)
865 << TestLog::EndMessage;
867 log << TestLog::Message
868 << glu::getErrorStr(error0) << " or "
869 << glu::getErrorStr(error1) << " was expected but got "
870 << glu::getErrorStr(result)
871 << TestLog::EndMessage;
876 // Generate errors, log the types, disable some, regenerate errors, verify correct errors (not)reported
877 class FilterCase : public BaseCase
880 FilterCase (Context& ctx,
883 const vector<TestFunctionWrapper>& errorFuncs);
884 virtual ~FilterCase (void) {}
886 virtual IterateResult iterate (void);
888 virtual void expectMessage (GLenum source, GLenum type);
893 MessageFilter() : source(GL_DONT_CARE), type(GL_DONT_CARE), severity(GL_DONT_CARE), enabled(true) {} // Default to enable all
894 MessageFilter(GLenum source_, GLenum type_, GLenum severity_, const vector<GLuint>& ids_, bool enabled_) : source(source_), type(type_), severity(severity_), ids(ids_), enabled(enabled_) {}
903 virtual void callback (GLenum source, GLenum type, GLuint id, GLenum severity, const string& message);
905 vector<MessageData> genMessages (bool uselog, const string& desc);
907 vector<MessageFilter> genFilters (const vector<MessageData>& messages, const vector<MessageFilter>& initial, deUint32 seed, int iterations) const;
908 void applyFilters (const vector<MessageFilter>& filters) const;
909 bool isEnabled (const vector<MessageFilter>& filters, const MessageData& message) const;
911 void verify (const vector<MessageData>& refMessages,
912 const vector<MessageData>& filteredMessages,
913 const vector<MessageFilter>& filters);
915 const vector<TestFunctionWrapper> m_errorFuncs;
917 vector<MessageData>* m_currentErrors;
920 FilterCase::FilterCase (Context& ctx,
923 const vector<TestFunctionWrapper>& errorFuncs)
924 : BaseCase (ctx, name, desc)
925 , m_errorFuncs (errorFuncs)
926 , m_currentErrors (DE_NULL)
930 FilterCase::IterateResult FilterCase::iterate (void)
932 TCU_CHECK_AND_THROW(NotSupportedError, isKHRDebugSupported(m_context), "GL_KHR_debug is not supported");
934 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
936 gl.enable(GL_DEBUG_OUTPUT);
937 gl.enable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
938 gl.debugMessageCallback(callbackHandle, this);
942 gl.debugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, DE_NULL, true);
945 const vector<MessageData> refMessages = genMessages(true, "Reference run");
946 const MessageFilter baseFilter (GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, vector<GLuint>(), true);
947 const deUint32 baseSeed = deStringHash(getName()) ^ m_testCtx.getCommandLine().getBaseSeed();
948 const vector<MessageFilter> filters = genFilters(refMessages, vector<MessageFilter>(1, baseFilter), baseSeed, 4);
949 vector<MessageData> filteredMessages;
951 applyFilters(filters);
954 filteredMessages = genMessages(false, "Filtered run");
957 verify(refMessages, filteredMessages, filters);
959 if (!isDebugContext() && refMessages.empty())
960 m_results.addResult(QP_TEST_RESULT_QUALITY_WARNING, "Verification accuracy is lacking without a debug context");
965 gl.disable(GL_DEBUG_OUTPUT);
966 gl.debugMessageCallback(DE_NULL, DE_NULL);
970 gl.disable(GL_DEBUG_OUTPUT);
971 gl.debugMessageCallback(DE_NULL, DE_NULL);
972 m_results.setTestContextResult(m_testCtx);
977 void FilterCase::expectMessage (GLenum source, GLenum type)
983 void FilterCase::callback (GLenum source, GLenum type, GLuint id, GLenum severity, const string& message)
986 m_currentErrors->push_back(MessageData(MessageID(source, type, id), severity, message));
989 vector<MessageData> FilterCase::genMessages (bool uselog, const string& desc)
991 tcu::TestLog& log = m_testCtx.getLog();
992 DebugMessageTestContext context = DebugMessageTestContext(*this, m_context.getRenderContext(), m_context.getContextInfo(), log, m_results, uselog);
993 tcu::ScopedLogSection section (log, "message gen", desc);
994 vector<MessageData> messages;
996 m_currentErrors = &messages;
998 for (int ndx = 0; ndx < int(m_errorFuncs.size()); ndx++)
999 m_errorFuncs[ndx].call(context);
1001 m_currentErrors = DE_NULL;
1006 vector<FilterCase::MessageFilter> FilterCase::genFilters (const vector<MessageData>& messages, const vector<MessageFilter>& initial, deUint32 seed, int iterations) const
1008 de::Random rng (seed ^ deInt32Hash(deStringHash(getName())));
1010 set<MessageID> tempMessageIds;
1011 set<GLenum> tempSources;
1012 set<GLenum> tempTypes;
1013 set<GLenum> tempSeverities;
1015 if (messages.empty())
1018 for (int ndx = 0; ndx < int(messages.size()); ndx++)
1020 const MessageData& msg = messages[ndx];
1022 tempMessageIds.insert(msg.id);
1023 tempSources.insert(msg.id.source);
1024 tempTypes.insert(msg.id.type);
1025 tempSeverities.insert(msg.severity);
1029 // Fetchable by index
1030 const vector<MessageID> messageIds (tempMessageIds.begin(), tempMessageIds.end());
1031 const vector<GLenum> sources (tempSources.begin(), tempSources.end());
1032 const vector<GLenum> types (tempTypes.begin(), tempTypes.end());
1033 const vector<GLenum> severities (tempSeverities.begin(), tempSeverities.end());
1035 vector<MessageFilter> filters = initial;
1037 for (int iteration = 0; iteration < iterations; iteration++)
1039 switch(rng.getInt(0, 8)) // Distribute so that per-message randomization (the default branch) is prevalent
1043 const GLenum source = sources[rng.getInt(0, int(sources.size()-1))];
1044 const bool enabled = rng.getBool();
1046 filters.push_back(MessageFilter(source, GL_DONT_CARE, GL_DONT_CARE, vector<GLuint>(), enabled));
1052 const GLenum type = types[rng.getUint32()%types.size()];
1053 const bool enabled = rng.getBool();
1055 filters.push_back(MessageFilter(GL_DONT_CARE, type, GL_DONT_CARE, vector<GLuint>(), enabled));
1061 const GLenum severity = severities[rng.getUint32()%severities.size()];
1062 const bool enabled = rng.getBool();
1064 filters.push_back(MessageFilter(GL_DONT_CARE, GL_DONT_CARE, severity, vector<GLuint>(), enabled));
1070 const int start = rng.getInt(0, int(messageIds.size()));
1072 for (int itr = 0; itr < 4; itr++)
1074 const MessageID& id = messageIds[(start+itr)%messageIds.size()];
1075 const bool enabled = rng.getBool();
1077 filters.push_back(MessageFilter(id.source, id.type, GL_DONT_CARE, vector<GLuint>(1, id.id), enabled));
1087 void FilterCase::applyFilters (const vector<MessageFilter>& filters) const
1089 TestLog& log = m_testCtx.getLog();
1090 const tcu::ScopedLogSection section (log, "", "Setting message filters");
1091 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1093 for (size_t filterNdx = 0; filterNdx < filters.size(); filterNdx++)
1095 const MessageFilter& filter = filters[filterNdx];
1097 if (filter.ids.empty())
1098 log << TestLog::Message << "Setting messages with"
1099 << " source " << glu::getDebugMessageSourceStr(filter.source)
1100 << ", type " << glu::getDebugMessageTypeStr(filter.type)
1101 << " and severity " << glu::getDebugMessageSeverityStr(filter.severity)
1102 << (filter.enabled ? " to enabled" : " to disabled")
1103 << TestLog::EndMessage;
1106 for (size_t ndx = 0; ndx < filter.ids.size(); ndx++)
1107 log << TestLog::Message << "Setting message (" << MessageID(filter.source, filter.type, filter.ids[ndx]) << ") to " << (filter.enabled ? "enabled" : "disabled") << TestLog::EndMessage;
1110 gl.debugMessageControl(filter.source, filter.type, filter.severity, GLsizei(filter.ids.size()), filter.ids.empty() ? DE_NULL : &filter.ids[0], filter.enabled);
1114 bool FilterCase::isEnabled (const vector<MessageFilter>& filters, const MessageData& message) const
1118 for (size_t filterNdx = 0; filterNdx < filters.size(); filterNdx++)
1120 const MessageFilter& filter = filters[filterNdx];
1122 if (filter.ids.empty())
1124 if (filter.source != GL_DONT_CARE && filter.source != message.id.source)
1127 if (filter.type != GL_DONT_CARE && filter.type != message.id.type)
1130 if (filter.severity != GL_DONT_CARE && filter.severity != message.severity)
1135 DE_ASSERT(filter.source != GL_DONT_CARE);
1136 DE_ASSERT(filter.type != GL_DONT_CARE);
1137 DE_ASSERT(filter.severity == GL_DONT_CARE);
1139 if (filter.source != message.id.source || filter.type != message.id.type)
1142 if (!de::contains(filter.ids.begin(), filter.ids.end(), message.id.id))
1146 retval = filter.enabled;
1158 MessageMeta (void) : refCount(0), resCount(0), severity(GL_NONE) {}
1161 void FilterCase::verify (const vector<MessageData>& refMessages, const vector<MessageData>& resMessages, const vector<MessageFilter>& filters)
1163 TestLog& log = m_testCtx.getLog();
1164 map<MessageID, MessageMeta> counts;
1166 log << TestLog::Section("verification", "Verifying");
1168 // Gather message counts & severities, report severity mismatches if found
1169 for (size_t refNdx = 0; refNdx < refMessages.size(); refNdx++)
1171 const MessageData& msg = refMessages[refNdx];
1172 MessageMeta& meta = counts[msg.id];
1174 if (meta.severity != GL_NONE && meta.severity != msg.severity)
1176 log << TestLog::Message << "A message has variable severity between instances: (" << msg.id << ") with severity "
1177 << glu::getDebugMessageSeverityStr(meta.severity) << " and " << glu::getDebugMessageSeverityStr(msg.severity) << TestLog::EndMessage;
1178 m_results.addResult(QP_TEST_RESULT_FAIL, "Message severity changed between instances of the same message");
1182 meta.severity = msg.severity;
1185 for (size_t resNdx = 0; resNdx < resMessages.size(); resNdx++)
1187 const MessageData& msg = resMessages[resNdx];
1188 MessageMeta& meta = counts[msg.id];
1190 if (meta.severity != GL_NONE && meta.severity != msg.severity)
1192 log << TestLog::Message << "A message has variable severity between instances: (" << msg.id << ") with severity "
1193 << glu::getDebugMessageSeverityStr(meta.severity) << " and " << glu::getDebugMessageSeverityStr(msg.severity) << TestLog::EndMessage;
1194 m_results.addResult(QP_TEST_RESULT_FAIL, "Message severity changed between instances of the same message");
1198 meta.severity = msg.severity;
1201 for (map<MessageID, MessageMeta>::const_iterator itr = counts.begin(); itr != counts.end(); itr++)
1203 const MessageID& id = itr->first;
1204 const GLenum severity = itr->second.severity;
1206 const int refCount = itr->second.refCount;
1207 const int resCount = itr->second.resCount;
1208 const bool enabled = isEnabled(filters, MessageData(id, severity, ""));
1210 VerificationResult result = verifyMessageCount(id, severity, refCount, resCount, enabled);
1212 log << TestLog::Message << result.logMessage << TestLog::EndMessage;
1214 if (result.result != QP_TEST_RESULT_PASS)
1215 m_results.addResult(result.result, result.resultMessage);
1218 log << TestLog::EndSection;
1221 // Filter case that uses debug groups
1222 class GroupFilterCase : public FilterCase
1225 GroupFilterCase (Context& ctx,
1228 const vector<TestFunctionWrapper>& errorFuncs);
1229 virtual ~GroupFilterCase (void) {}
1231 virtual IterateResult iterate (void);
1234 GroupFilterCase::GroupFilterCase (Context& ctx,
1237 const vector<TestFunctionWrapper>& errorFuncs)
1238 : FilterCase(ctx, name, desc, errorFuncs)
1242 template<typename T>
1243 vector<T> join(const vector<T>& a, const vector<T>&b)
1247 retval.reserve(a.size()+b.size());
1248 retval.insert(retval.end(), a.begin(), a.end());
1249 retval.insert(retval.end(), b.begin(), b.end());
1253 GroupFilterCase::IterateResult GroupFilterCase::iterate (void)
1255 TCU_CHECK_AND_THROW(NotSupportedError, isKHRDebugSupported(m_context), "GL_KHR_debug is not supported");
1257 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1258 tcu::TestLog& log = m_testCtx.getLog();
1260 gl.enable(GL_DEBUG_OUTPUT);
1261 gl.enable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
1262 gl.debugMessageCallback(callbackHandle, this);
1266 gl.debugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, DE_NULL, true);
1270 // Generate reference (all errors)
1271 const vector<MessageData> refMessages = genMessages(true, "Reference run");
1272 const deUint32 baseSeed = deStringHash(getName()) ^ m_testCtx.getCommandLine().getBaseSeed();
1273 const MessageFilter baseFilter (GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, vector<GLuint>(), true);
1274 const vector<MessageFilter> filter0 = genFilters(refMessages, vector<MessageFilter>(1, baseFilter), baseSeed, 4);
1275 vector<MessageData> resMessages0;
1277 applyFilters(filter0);
1279 resMessages0 = genMessages(false, "Filtered run, default debug group");
1281 // Initial verification
1282 verify(refMessages, resMessages0, filter0);
1285 // Generate reference (filters inherited from parent)
1286 const vector<MessageFilter> filter1base = genFilters(refMessages, vector<MessageFilter>(), baseSeed ^ 0xDEADBEEF, 4);
1287 const vector<MessageFilter> filter1full = join(filter0, filter1base);
1288 tcu::ScopedLogSection section1 (log, "", "Pushing Debug Group");
1289 vector<MessageData> resMessages1;
1291 gl.pushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 1, -1, "Test Group");
1292 applyFilters(filter1base);
1294 // First nested verification
1295 resMessages1 = genMessages(false, "Filtered run, pushed one debug group");
1296 verify(refMessages, resMessages1, filter1full);
1299 // Generate reference (filters iherited again)
1300 const vector<MessageFilter> filter2base = genFilters(refMessages, vector<MessageFilter>(), baseSeed ^ 0x43211234, 4);
1301 const vector<MessageFilter> filter2full = join(filter1full, filter2base);
1302 tcu::ScopedLogSection section2 (log, "", "Pushing Debug Group");
1303 vector<MessageData> resMessages2;
1305 gl.pushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 1, -1, "Nested Test Group");
1306 applyFilters(filter2base);
1308 // Second nested verification
1309 resMessages2 = genMessages(false, "Filtered run, pushed two debug groups");
1310 verify(refMessages, resMessages2, filter2full);
1315 // First restore verification
1316 resMessages1 = genMessages(false, "Filtered run, popped second debug group");
1317 verify(refMessages, resMessages1, filter1full);
1322 // restore verification
1323 resMessages0 = genMessages(false, "Filtered run, popped first debug group");
1324 verify(refMessages, resMessages0, filter0);
1326 if (!isDebugContext() && refMessages.empty())
1327 m_results.addResult(QP_TEST_RESULT_QUALITY_WARNING, "Verification accuracy is lacking without a debug context");
1332 gl.disable(GL_DEBUG_OUTPUT);
1333 gl.debugMessageCallback(DE_NULL, DE_NULL);
1337 gl.disable(GL_DEBUG_OUTPUT);
1338 gl.debugMessageCallback(DE_NULL, DE_NULL);
1339 m_results.setTestContextResult(m_testCtx);
1343 // Basic grouping functionality
1344 class GroupCase : public BaseCase
1347 GroupCase (Context& ctx,
1350 virtual ~GroupCase () {}
1352 virtual IterateResult iterate (void);
1355 virtual void callback (GLenum source, GLenum type, GLuint id, GLenum severity, const string& message);
1357 MessageData m_lastMessage;
1360 GroupCase::GroupCase (Context& ctx,
1363 : BaseCase(ctx, name, desc)
1367 GroupCase::IterateResult GroupCase::iterate (void)
1369 TCU_CHECK_AND_THROW(NotSupportedError, isKHRDebugSupported(m_context), "GL_KHR_debug is not supported");
1371 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1372 tcu::TestLog& log = m_testCtx.getLog();
1373 glu::CallLogWrapper wrapper (gl, log);
1375 gl.enable(GL_DEBUG_OUTPUT);
1376 gl.enable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
1377 gl.debugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, DE_NULL, false); // disable all
1378 gl.debugMessageControl(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_ERROR, GL_DONT_CARE, 0, DE_NULL, true); // enable API errors
1379 gl.debugMessageControl(GL_DEBUG_SOURCE_APPLICATION, GL_DONT_CARE, GL_DONT_CARE, 0, DE_NULL, true); // enable application messages
1380 gl.debugMessageControl(GL_DEBUG_SOURCE_THIRD_PARTY, GL_DONT_CARE, GL_DONT_CARE, 0, DE_NULL, true); // enable third party messages
1381 gl.debugMessageCallback(callbackHandle, this);
1383 wrapper.enableLogging(true);
1384 wrapper.glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 1234, -1, "Pushed debug stack");
1385 verifyMessage(m_lastMessage, GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PUSH_GROUP, 1234, GL_DEBUG_SEVERITY_NOTIFICATION);
1386 wrapper.glPopDebugGroup();
1387 verifyMessage(m_lastMessage, GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_POP_GROUP, 1234, GL_DEBUG_SEVERITY_NOTIFICATION);
1389 wrapper.glPushDebugGroup(GL_DEBUG_SOURCE_THIRD_PARTY, 4231, -1, "Pushed debug stack");
1390 verifyMessage(m_lastMessage, GL_DEBUG_SOURCE_THIRD_PARTY, GL_DEBUG_TYPE_PUSH_GROUP, 4231, GL_DEBUG_SEVERITY_NOTIFICATION);
1391 wrapper.glPopDebugGroup();
1392 verifyMessage(m_lastMessage, GL_DEBUG_SOURCE_THIRD_PARTY, GL_DEBUG_TYPE_POP_GROUP, 4231, GL_DEBUG_SEVERITY_NOTIFICATION);
1394 gl.debugMessageCallback(DE_NULL, DE_NULL);
1395 gl.disable(GL_DEBUG_OUTPUT);
1397 m_results.setTestContextResult(m_testCtx);
1402 void GroupCase::callback (GLenum source, GLenum type, GLuint id, GLenum severity, const string& message)
1404 m_lastMessage = MessageData(MessageID(source, type, id), severity, message);
1407 // Asynchronous debug output
1408 class AsyncCase : public BaseCase
1411 AsyncCase (Context& ctx,
1414 const vector<TestFunctionWrapper>& errorFuncs,
1416 virtual ~AsyncCase (void) {}
1418 virtual IterateResult iterate (void);
1420 virtual void expectMessage (glw::GLenum source, glw::GLenum type);
1428 MessageCount(void) : received(0), expected(0) {}
1430 typedef map<MessageID, MessageCount> MessageCounter;
1441 virtual void callback (glw::GLenum source, glw::GLenum type, glw::GLuint id, glw::GLenum severity, const std::string& message);
1442 VerifyState verify (bool uselog);
1443 void fetchLogMessages (void);
1445 const vector<TestFunctionWrapper> m_errorFuncs;
1446 const bool m_useCallbacks;
1448 MessageCounter m_counts;
1453 AsyncCase::AsyncCase (Context& ctx,
1456 const vector<TestFunctionWrapper>& errorFuncs,
1458 : BaseCase (ctx, name, desc)
1459 , m_errorFuncs (errorFuncs)
1460 , m_useCallbacks (useCallbacks)
1464 AsyncCase::IterateResult AsyncCase::iterate (void)
1466 TCU_CHECK_AND_THROW(NotSupportedError, isKHRDebugSupported(m_context), "GL_KHR_debug is not supported");
1468 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1469 tcu::TestLog& log = m_testCtx.getLog();
1470 DebugMessageTestContext context = DebugMessageTestContext(*this, m_context.getRenderContext(), m_context.getContextInfo(), log, m_results, true);
1471 const int maxWait = 10000; // ms
1472 const int warnWait = 100;
1474 // Clear log from earlier messages
1476 GLint numMessages = 0;
1477 gl.getIntegerv(GL_DEBUG_LOGGED_MESSAGES, &numMessages);
1478 gl.getDebugMessageLog(numMessages, 0, DE_NULL, DE_NULL, DE_NULL, DE_NULL, DE_NULL, DE_NULL);
1481 gl.enable(GL_DEBUG_OUTPUT);
1482 gl.enable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
1483 gl.debugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, DE_NULL, false);
1485 // Some messages could be dependent on the value of DEBUG_OUTPUT_SYNCHRONOUS so only use API errors which should be generated in all cases
1486 gl.debugMessageControl(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_ERROR, GL_DONT_CARE, 0, DE_NULL, true);
1488 if (m_useCallbacks) // will use log otherwise
1489 gl.debugMessageCallback(callbackHandle, this);
1491 gl.debugMessageCallback(DE_NULL, DE_NULL);
1493 // Reference run (synchoronous)
1495 tcu::ScopedLogSection section(log, "reference run", "Reference run (synchronous)");
1497 for (int ndx = 0; ndx < int(m_errorFuncs.size()); ndx++)
1498 m_errorFuncs[ndx].call(context);
1501 if (m_counts.empty())
1503 if (!isDebugContext())
1504 m_results.addResult(QP_TEST_RESULT_QUALITY_WARNING, "Need debug context to guarantee implementation behaviour (see command line options)");
1506 log << TestLog::Message << "Reference run produced no messages, nothing to verify" << TestLog::EndMessage;
1508 gl.debugMessageCallback(DE_NULL, DE_NULL);
1509 gl.disable(GL_DEBUG_OUTPUT);
1511 m_results.setTestContextResult(m_testCtx);
1515 for (MessageCounter::iterator itr = m_counts.begin(); itr != m_counts.end(); itr++)
1517 itr->second.expected = itr->second.received;
1518 itr->second.received = 0;
1521 gl.disable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
1523 // Result run (async)
1524 for (int ndx = 0; ndx < int(m_errorFuncs.size()); ndx++)
1525 m_errorFuncs[ndx].call(context);
1527 // Repatedly try verification, new results may be added to m_receivedMessages at any time
1529 tcu::ScopedLogSection section (log, "result run", "Result run (asynchronous)");
1530 VerifyState lastTimelyState = VERIFY_FAIL;
1532 for (int waited = 0;;)
1534 const VerifyState pass = verify(false);
1535 const int wait = de::max(50, waited>>2);
1537 // Pass (possibly due to time limit)
1538 if (pass == VERIFY_PASS || (pass == VERIFY_MINIMUM && waited >= maxWait))
1540 verify(true); // log
1542 // State changed late
1543 if (waited >= warnWait && lastTimelyState != pass)
1544 m_results.addResult(QP_TEST_RESULT_QUALITY_WARNING, "Async messages were returned to application somewhat slowly");
1546 log << TestLog::Message << "Passed after ~" << waited << "ms of waiting" << TestLog::EndMessage;
1550 else if (waited >= maxWait)
1552 verify(true); // log
1554 log << TestLog::Message << "Waited for ~" << waited << "ms without getting all expected messages" << TestLog::EndMessage;
1555 m_results.addResult(QP_TEST_RESULT_FAIL, "Async messages were not returned to application within a reasonable timeframe");
1559 if (waited < warnWait)
1560 lastTimelyState = pass;
1565 if (!m_useCallbacks)
1570 gl.debugMessageCallback(DE_NULL, DE_NULL);
1572 gl.disable(GL_DEBUG_OUTPUT);
1573 m_results.setTestContextResult(m_testCtx);
1578 void AsyncCase::expectMessage (GLenum source, GLenum type)
1580 // Good time to clean up the queue as this should be called after most messages are generated
1581 if (!m_useCallbacks)
1588 void AsyncCase::callback (GLenum source, GLenum type, GLuint id, GLenum severity, const string& message)
1590 DE_ASSERT(m_useCallbacks);
1594 de::ScopedLock lock(m_mutex);
1596 m_counts[MessageID(source, type, id)].received++;
1599 // Note that we can never guarantee getting all messages back when using logs/fetching as the GL may create more than its log size limit during an arbitrary period of time
1600 void AsyncCase::fetchLogMessages (void)
1602 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1605 gl.getIntegerv(GL_DEBUG_LOGGED_MESSAGES, &numMsg);
1607 for(int msgNdx = 0; msgNdx < numMsg; msgNdx++)
1612 gl.getIntegerv(GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH, &msgLen);
1614 TCU_CHECK_MSG(msgLen >= 0, "Negative message length");
1615 TCU_CHECK_MSG(msgLen < 100000, "Excessively long message");
1617 msg.message.resize(msgLen);
1618 gl.getDebugMessageLog(1, msgLen, &msg.id.source, &msg.id.type, &msg.id.id, &msg.severity, &msgLen, &msg.message[0]);
1621 const de::ScopedLock lock(m_mutex); // Don't block during API call
1623 m_counts[MessageID(msg.id)].received++;
1628 AsyncCase::VerifyState AsyncCase::verify (bool uselog)
1632 VerifyState retval = VERIFY_PASS;
1633 TestLog& log = m_testCtx.getLog();
1635 const de::ScopedLock lock(m_mutex);
1637 for (map<MessageID, MessageCount>::const_iterator itr = m_counts.begin(); itr != m_counts.end(); itr++)
1639 const MessageID& id = itr->first;
1641 const int refCount = itr->second.expected;
1642 const int resCount = itr->second.received;
1643 const bool enabled = true;
1645 VerificationResult result = verifyMessageCount(id, GL_DONT_CARE, refCount, resCount, enabled);
1648 log << TestLog::Message << result.logMessage << TestLog::EndMessage;
1650 if (result.result == QP_TEST_RESULT_FAIL)
1651 retval = VERIFY_FAIL;
1652 else if (result.result != QP_TEST_RESULT_PASS && retval == VERIFY_PASS)
1653 retval = VERIFY_MINIMUM;
1659 // Tests debug labels
1660 class LabelCase : public TestCase
1663 LabelCase (Context& ctx,
1667 virtual ~LabelCase (void) {}
1669 virtual IterateResult iterate (void);
1672 GLenum m_identifier;
1675 LabelCase::LabelCase (Context& ctx,
1679 : TestCase (ctx, name, desc)
1680 , m_identifier (identifier)
1684 LabelCase::IterateResult LabelCase::iterate (void)
1686 TCU_CHECK_AND_THROW(NotSupportedError, isKHRDebugSupported(m_context), "GL_KHR_debug is not supported");
1688 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1689 const char* const msg = "This is a debug label";
1694 switch(m_identifier)
1697 gl.genBuffers(1, &object);
1698 gl.bindBuffer(GL_ARRAY_BUFFER, object);
1699 gl.bindBuffer(GL_ARRAY_BUFFER, 0);
1703 object = gl.createShader(GL_FRAGMENT_SHADER);
1707 object = gl.createProgram();
1711 gl.genQueries(1, &object);
1712 gl.beginQuery(GL_ANY_SAMPLES_PASSED, object); // Create
1713 gl.endQuery(GL_ANY_SAMPLES_PASSED); // Cleanup
1716 case GL_PROGRAM_PIPELINE:
1717 gl.genProgramPipelines(1, &object);
1718 gl.bindProgramPipeline(object); // Create
1719 gl.bindProgramPipeline(0); // Cleanup
1722 case GL_TRANSFORM_FEEDBACK:
1723 gl.genTransformFeedbacks(1, &object);
1724 gl.bindTransformFeedback(GL_TRANSFORM_FEEDBACK, object);
1725 gl.bindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0);
1729 gl.genSamplers(1, &object);
1730 gl.bindSampler(0, object);
1731 gl.bindSampler(0, 0);
1735 gl.genTextures(1, &object);
1736 gl.bindTexture(GL_TEXTURE_2D, object);
1737 gl.bindTexture(GL_TEXTURE_2D, 0);
1740 case GL_RENDERBUFFER:
1741 gl.genRenderbuffers(1, &object);
1742 gl.bindRenderbuffer(GL_RENDERBUFFER, object);
1743 gl.bindRenderbuffer(GL_RENDERBUFFER, 0);
1746 case GL_FRAMEBUFFER:
1747 gl.genFramebuffers(1, &object);
1748 gl.bindFramebuffer(GL_DRAW_FRAMEBUFFER, object);
1749 gl.bindFramebuffer(GL_DRAW_FRAMEBUFFER, m_context.getRenderContext().getDefaultFramebuffer());
1753 DE_FATAL("Invalid identifier");
1756 gl.objectLabel(m_identifier, object, -1, msg);
1758 deMemset(buffer, 'X', sizeof(buffer));
1759 gl.getObjectLabel(m_identifier, object, sizeof(buffer), &outlen, buffer);
1762 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to query debug label from object");
1763 else if (deStringEqual(msg, buffer))
1765 m_testCtx.getLog() << TestLog::Message << "Query returned string: \"" << buffer << "\"" << TestLog::EndMessage;
1766 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1770 buffer[63] = '\0'; // make sure buffer is null terminated before printing
1771 m_testCtx.getLog() << TestLog::Message << "Query returned wrong string: expected \"" << msg << "\" but got \"" << buffer << "\"" << TestLog::EndMessage;
1772 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Query returned wrong label");
1775 switch(m_identifier)
1777 case GL_BUFFER: gl.deleteBuffers(1, &object); break;
1778 case GL_SHADER: gl.deleteShader(object); break;
1779 case GL_PROGRAM: gl.deleteProgram(object); break;
1780 case GL_QUERY: gl.deleteQueries(1, &object); break;
1781 case GL_PROGRAM_PIPELINE: gl.deleteProgramPipelines(1, &object); break;
1782 case GL_TRANSFORM_FEEDBACK: gl.deleteTransformFeedbacks(1, &object); break;
1783 case GL_SAMPLER: gl.deleteSamplers(1, &object); break;
1784 case GL_TEXTURE: gl.deleteTextures(1, &object); break;
1785 case GL_RENDERBUFFER: gl.deleteRenderbuffers(1, &object); break;
1786 case GL_FRAMEBUFFER: gl.deleteFramebuffers(1, &object); break;
1789 DE_FATAL("Invalid identifier");
1796 DebugMessageTestContext::DebugMessageTestContext (BaseCase& host,
1797 glu::RenderContext& renderCtx,
1798 const glu::ContextInfo& ctxInfo,
1800 tcu::ResultCollector& results,
1802 : NegativeTestContext (host, renderCtx, ctxInfo, log, results, enableLog)
1803 , m_debugHost (host)
1807 DebugMessageTestContext::~DebugMessageTestContext (void)
1811 void DebugMessageTestContext::expectMessage (GLenum source, GLenum type)
1813 m_debugHost.expectMessage(source, type);
1816 class SyncLabelCase : public TestCase
1819 SyncLabelCase (Context& ctx, const char* name, const char* desc);
1820 virtual IterateResult iterate (void);
1823 SyncLabelCase::SyncLabelCase (Context& ctx, const char* name, const char* desc)
1824 : TestCase(ctx, name, desc)
1828 SyncLabelCase::IterateResult SyncLabelCase::iterate (void)
1830 TCU_CHECK_AND_THROW(NotSupportedError, isKHRDebugSupported(m_context), "GL_KHR_debug is not supported");
1832 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1833 const char* const msg = "This is a debug label";
1837 glw::GLsync sync = gl.fenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
1838 GLU_EXPECT_NO_ERROR(gl.getError(), "fenceSync");
1840 gl.objectPtrLabel(sync, -1, msg);
1842 deMemset(buffer, 'X', sizeof(buffer));
1843 gl.getObjectPtrLabel(sync, sizeof(buffer), &outlen, buffer);
1846 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to query debug label from object");
1847 else if (deStringEqual(msg, buffer))
1849 m_testCtx.getLog() << TestLog::Message << "Query returned string: \"" << buffer << "\"" << TestLog::EndMessage;
1850 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1854 buffer[63] = '\0'; // make sure buffer is null terminated before printing
1855 m_testCtx.getLog() << TestLog::Message << "Query returned wrong string: expected \"" << msg << "\" but got \"" << buffer << "\"" << TestLog::EndMessage;
1856 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Query returned wrong label");
1859 gl.deleteSync(sync);
1864 class InitialLabelCase : public TestCase
1867 InitialLabelCase (Context& ctx, const char* name, const char* desc);
1868 virtual IterateResult iterate (void);
1871 InitialLabelCase::InitialLabelCase (Context& ctx, const char* name, const char* desc)
1872 : TestCase(ctx, name, desc)
1876 InitialLabelCase::IterateResult InitialLabelCase::iterate (void)
1878 TCU_CHECK_AND_THROW(NotSupportedError, isKHRDebugSupported(m_context), "GL_KHR_debug is not supported");
1880 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1881 tcu::ResultCollector result (m_testCtx.getLog(), " // ERROR: ");
1887 sync = gl.fenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
1888 GLS_COLLECT_GL_ERROR(result, gl.getError(), "fenceSync");
1890 shader = gl.createShader(GL_FRAGMENT_SHADER);
1891 GLS_COLLECT_GL_ERROR(result, gl.getError(), "createShader");
1894 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Shader", "Shader object");
1895 m_testCtx.getLog() << TestLog::Message << "Querying initial value" << TestLog::EndMessage;
1899 gl.getObjectLabel(GL_SHADER, shader, sizeof(buffer), &outlen, buffer);
1900 GLS_COLLECT_GL_ERROR(result, gl.getError(), "getObjectLabel");
1903 result.fail("'length' was not zero, got " + de::toString(outlen));
1904 else if (buffer[0] != '\0')
1905 result.fail("label was not null terminated");
1907 m_testCtx.getLog() << TestLog::Message << "Got 0-sized null-terminated string." << TestLog::EndMessage;
1911 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Sync", "Sync object");
1912 m_testCtx.getLog() << TestLog::Message << "Querying initial value" << TestLog::EndMessage;
1916 gl.getObjectPtrLabel(sync, sizeof(buffer), &outlen, buffer);
1917 GLS_COLLECT_GL_ERROR(result, gl.getError(), "getObjectPtrLabel");
1920 result.fail("'length' was not zero, got " + de::toString(outlen));
1921 else if (buffer[0] != '\0')
1922 result.fail("label was not null terminated");
1924 m_testCtx.getLog() << TestLog::Message << "Got 0-sized null-terminated string." << TestLog::EndMessage;
1927 gl.deleteShader(shader);
1928 gl.deleteSync(sync);
1930 result.setTestContextResult(m_testCtx);
1934 class ClearLabelCase : public TestCase
1937 ClearLabelCase (Context& ctx, const char* name, const char* desc);
1938 virtual IterateResult iterate (void);
1941 ClearLabelCase::ClearLabelCase (Context& ctx, const char* name, const char* desc)
1942 : TestCase(ctx, name, desc)
1946 ClearLabelCase::IterateResult ClearLabelCase::iterate (void)
1948 TCU_CHECK_AND_THROW(NotSupportedError, isKHRDebugSupported(m_context), "GL_KHR_debug is not supported");
1952 const char* description;
1954 } s_clearMethods[] =
1956 { " with NULL label and 0 length", 0 },
1957 { " with NULL label and 1 length", 1 },
1958 { " with NULL label and negative length", -1 },
1961 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1962 tcu::ResultCollector result (m_testCtx.getLog(), " // ERROR: ");
1963 const char* const msg = "This is a debug label";
1969 sync = gl.fenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
1970 GLS_COLLECT_GL_ERROR(result, gl.getError(), "fenceSync");
1972 shader = gl.createShader(GL_FRAGMENT_SHADER);
1973 GLS_COLLECT_GL_ERROR(result, gl.getError(), "createShader");
1976 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Shader", "Shader object");
1978 for (int methodNdx = 0; methodNdx < DE_LENGTH_OF_ARRAY(s_clearMethods); ++methodNdx)
1980 m_testCtx.getLog() << TestLog::Message << "Setting label to string: \"" << msg << "\"" << TestLog::EndMessage;
1981 gl.objectLabel(GL_SHADER, shader, -2, msg);
1982 GLS_COLLECT_GL_ERROR(result, gl.getError(), "objectLabel");
1984 m_testCtx.getLog() << TestLog::Message << "Clearing label " << s_clearMethods[methodNdx].description << TestLog::EndMessage;
1985 gl.objectLabel(GL_SHADER, shader, s_clearMethods[methodNdx].length, DE_NULL);
1986 GLS_COLLECT_GL_ERROR(result, gl.getError(), "objectLabel");
1988 m_testCtx.getLog() << TestLog::Message << "Querying label" << TestLog::EndMessage;
1991 gl.getObjectLabel(GL_SHADER, shader, sizeof(buffer), &outlen, buffer);
1992 GLS_COLLECT_GL_ERROR(result, gl.getError(), "getObjectLabel");
1995 result.fail("'length' was not zero, got " + de::toString(outlen));
1996 else if (buffer[0] != '\0')
1997 result.fail("label was not null terminated");
1999 m_testCtx.getLog() << TestLog::Message << "Got 0-sized null-terminated string." << TestLog::EndMessage;
2004 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Sync", "Sync object");
2006 for (int methodNdx = 0; methodNdx < DE_LENGTH_OF_ARRAY(s_clearMethods); ++methodNdx)
2008 m_testCtx.getLog() << TestLog::Message << "Setting label to string: \"" << msg << "\"" << TestLog::EndMessage;
2009 gl.objectPtrLabel(sync, -2, msg);
2010 GLS_COLLECT_GL_ERROR(result, gl.getError(), "objectPtrLabel");
2012 m_testCtx.getLog() << TestLog::Message << "Clearing label " << s_clearMethods[methodNdx].description << TestLog::EndMessage;
2013 gl.objectPtrLabel(sync, s_clearMethods[methodNdx].length, DE_NULL);
2014 GLS_COLLECT_GL_ERROR(result, gl.getError(), "objectPtrLabel");
2016 m_testCtx.getLog() << TestLog::Message << "Querying label" << TestLog::EndMessage;
2019 gl.getObjectPtrLabel(sync, sizeof(buffer), &outlen, buffer);
2020 GLS_COLLECT_GL_ERROR(result, gl.getError(), "getObjectPtrLabel");
2023 result.fail("'length' was not zero, got " + de::toString(outlen));
2024 else if (buffer[0] != '\0')
2025 result.fail("label was not null terminated");
2027 m_testCtx.getLog() << TestLog::Message << "Got 0-sized null-terminated string." << TestLog::EndMessage;
2031 gl.deleteShader(shader);
2032 gl.deleteSync(sync);
2034 result.setTestContextResult(m_testCtx);
2038 class SpecifyWithLengthCase : public TestCase
2041 SpecifyWithLengthCase (Context& ctx, const char* name, const char* desc);
2042 virtual IterateResult iterate (void);
2045 SpecifyWithLengthCase::SpecifyWithLengthCase (Context& ctx, const char* name, const char* desc)
2046 : TestCase(ctx, name, desc)
2050 SpecifyWithLengthCase::IterateResult SpecifyWithLengthCase::iterate (void)
2052 TCU_CHECK_AND_THROW(NotSupportedError, isKHRDebugSupported(m_context), "GL_KHR_debug is not supported");
2054 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2055 tcu::ResultCollector result (m_testCtx.getLog(), " // ERROR: ");
2056 const char* const msg = "This is a debug label";
2057 const char* const clipMsg = "This is a de";
2063 sync = gl.fenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
2064 GLS_COLLECT_GL_ERROR(result, gl.getError(), "fenceSync");
2066 shader = gl.createShader(GL_FRAGMENT_SHADER);
2067 GLS_COLLECT_GL_ERROR(result, gl.getError(), "createShader");
2070 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Shader", "Shader object");
2072 m_testCtx.getLog() << TestLog::Message << "Setting label to string: \"" << msg << "\" with length 12" << TestLog::EndMessage;
2073 gl.objectLabel(GL_SHADER, shader, 12, msg);
2074 GLS_COLLECT_GL_ERROR(result, gl.getError(), "objectLabel");
2076 m_testCtx.getLog() << TestLog::Message << "Querying label" << TestLog::EndMessage;
2077 deMemset(buffer, 'X', sizeof(buffer));
2078 gl.getObjectLabel(GL_SHADER, shader, sizeof(buffer), &outlen, buffer);
2079 GLS_COLLECT_GL_ERROR(result, gl.getError(), "getObjectLabel");
2082 result.fail("'length' was not 12, got " + de::toString(outlen));
2083 else if (deStringEqual(clipMsg, buffer))
2085 m_testCtx.getLog() << TestLog::Message << "Query returned string: \"" << buffer << "\"" << TestLog::EndMessage;
2089 buffer[63] = '\0'; // make sure buffer is null terminated before printing
2090 m_testCtx.getLog() << TestLog::Message << "Query returned wrong string: expected \"" << clipMsg << "\" but got \"" << buffer << "\"" << TestLog::EndMessage;
2091 result.fail("Query returned wrong label");
2096 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Sync", "Sync object");
2098 m_testCtx.getLog() << TestLog::Message << "Setting label to string: \"" << msg << "\" with length 12" << TestLog::EndMessage;
2099 gl.objectPtrLabel(sync, 12, msg);
2100 GLS_COLLECT_GL_ERROR(result, gl.getError(), "objectPtrLabel");
2102 m_testCtx.getLog() << TestLog::Message << "Querying label" << TestLog::EndMessage;
2103 deMemset(buffer, 'X', sizeof(buffer));
2104 gl.getObjectPtrLabel(sync, sizeof(buffer), &outlen, buffer);
2105 GLS_COLLECT_GL_ERROR(result, gl.getError(), "getObjectPtrLabel");
2108 result.fail("'length' was not 12, got " + de::toString(outlen));
2109 else if (deStringEqual(clipMsg, buffer))
2111 m_testCtx.getLog() << TestLog::Message << "Query returned string: \"" << buffer << "\"" << TestLog::EndMessage;
2115 buffer[63] = '\0'; // make sure buffer is null terminated before printing
2116 m_testCtx.getLog() << TestLog::Message << "Query returned wrong string: expected \"" << clipMsg << "\" but got \"" << buffer << "\"" << TestLog::EndMessage;
2117 result.fail("Query returned wrong label");
2122 const tcu::ScopedLogSection section(m_testCtx.getLog(), "ZeroSized", "ZeroSized");
2124 m_testCtx.getLog() << TestLog::Message << "Setting label to string: \"" << msg << "\" with length 0" << TestLog::EndMessage;
2125 gl.objectLabel(GL_SHADER, shader, 0, msg);
2126 GLS_COLLECT_GL_ERROR(result, gl.getError(), "objectLabel");
2128 m_testCtx.getLog() << TestLog::Message << "Querying label" << TestLog::EndMessage;
2129 deMemset(buffer, 'X', sizeof(buffer));
2130 gl.getObjectLabel(GL_SHADER, shader, sizeof(buffer), &outlen, buffer);
2131 GLS_COLLECT_GL_ERROR(result, gl.getError(), "getObjectLabel");
2134 result.fail("'length' was not zero, got " + de::toString(outlen));
2135 else if (buffer[0] != '\0')
2136 result.fail("label was not null terminated");
2138 m_testCtx.getLog() << TestLog::Message << "Got 0-sized null-terminated string." << TestLog::EndMessage;
2141 gl.deleteShader(shader);
2142 gl.deleteSync(sync);
2144 result.setTestContextResult(m_testCtx);
2148 class BufferLimitedLabelCase : public TestCase
2151 BufferLimitedLabelCase (Context& ctx, const char* name, const char* desc);
2152 virtual IterateResult iterate (void);
2155 BufferLimitedLabelCase::BufferLimitedLabelCase (Context& ctx, const char* name, const char* desc)
2156 : TestCase(ctx, name, desc)
2160 BufferLimitedLabelCase::IterateResult BufferLimitedLabelCase::iterate (void)
2162 TCU_CHECK_AND_THROW(NotSupportedError, isKHRDebugSupported(m_context), "GL_KHR_debug is not supported");
2164 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2165 tcu::ResultCollector result (m_testCtx.getLog(), " // ERROR: ");
2166 const char* const msg = "This is a debug label";
2172 sync = gl.fenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
2173 GLS_COLLECT_GL_ERROR(result, gl.getError(), "fenceSync");
2175 shader = gl.createShader(GL_FRAGMENT_SHADER);
2176 GLS_COLLECT_GL_ERROR(result, gl.getError(), "createShader");
2179 const tcu::ScopedLogSection superSection(m_testCtx.getLog(), "Shader", "Shader object");
2181 m_testCtx.getLog() << TestLog::Message << "Setting label to string: \"" << msg << "\"" << TestLog::EndMessage;
2182 gl.objectLabel(GL_SHADER, shader, -1, msg);
2183 GLS_COLLECT_GL_ERROR(result, gl.getError(), "objectLabel");
2186 const tcu::ScopedLogSection section(m_testCtx.getLog(), "QueryAll", "Query All");
2188 m_testCtx.getLog() << TestLog::Message << "Querying whole label, buffer size = 22" << TestLog::EndMessage;
2189 deMemset(buffer, 'X', sizeof(buffer));
2190 gl.getObjectLabel(GL_SHADER, shader, 22, &outlen, buffer);
2191 GLS_COLLECT_GL_ERROR(result, gl.getError(), "getObjectLabel");
2194 result.fail("'length' was not 21, got " + de::toString(outlen));
2195 else if (buffer[outlen] != '\0')
2196 result.fail("Buffer was not null-terminated");
2197 else if (buffer[outlen+1] != 'X')
2198 result.fail("Query wrote over buffer bound");
2199 else if (!deStringEqual(msg, buffer))
2201 buffer[63] = '\0'; // make sure buffer is null terminated before printing
2202 m_testCtx.getLog() << TestLog::Message << "Query returned string: \"" << buffer << "\"" << TestLog::EndMessage;
2203 result.fail("Query returned wrong label");
2206 m_testCtx.getLog() << TestLog::Message << "Query returned string: \"" << buffer << "\"" << TestLog::EndMessage;
2209 const tcu::ScopedLogSection section(m_testCtx.getLog(), "QueryAllNoSize", "Query all without size");
2211 m_testCtx.getLog() << TestLog::Message << "Querying whole label, buffer size = 22" << TestLog::EndMessage;
2212 deMemset(buffer, 'X', sizeof(buffer));
2213 gl.getObjectLabel(GL_SHADER, shader, 22, DE_NULL, buffer);
2214 GLS_COLLECT_GL_ERROR(result, gl.getError(), "getObjectLabel");
2216 buffer[63] = '\0'; // make sure buffer is null terminated before strlen
2218 if (strlen(buffer) != 21)
2219 result.fail("Buffer length was not 21");
2220 else if (buffer[21] != '\0')
2221 result.fail("Buffer was not null-terminated");
2222 else if (buffer[22] != 'X')
2223 result.fail("Query wrote over buffer bound");
2224 else if (!deStringEqual(msg, buffer))
2226 m_testCtx.getLog() << TestLog::Message << "Query returned string: \"" << buffer << "\"" << TestLog::EndMessage;
2227 result.fail("Query returned wrong label");
2230 m_testCtx.getLog() << TestLog::Message << "Query returned string: \"" << buffer << "\"" << TestLog::EndMessage;
2233 const tcu::ScopedLogSection section(m_testCtx.getLog(), "QueryLess", "Query substring");
2235 m_testCtx.getLog() << TestLog::Message << "Querying whole label, buffer size = 2" << TestLog::EndMessage;
2236 deMemset(buffer, 'X', sizeof(buffer));
2237 gl.getObjectLabel(GL_SHADER, shader, 2, &outlen, buffer);
2238 GLS_COLLECT_GL_ERROR(result, gl.getError(), "getObjectLabel");
2241 result.fail("'length' was not 1, got " + de::toString(outlen));
2242 else if (buffer[outlen] != '\0')
2243 result.fail("Buffer was not null-terminated");
2244 else if (buffer[outlen+1] != 'X')
2245 result.fail("Query wrote over buffer bound");
2246 else if (!deStringBeginsWith(msg, buffer))
2248 buffer[63] = '\0'; // make sure buffer is null terminated before printing
2249 m_testCtx.getLog() << TestLog::Message << "Query returned string: \"" << buffer << "\"" << TestLog::EndMessage;
2250 result.fail("Query returned wrong label");
2253 m_testCtx.getLog() << TestLog::Message << "Query returned string: \"" << buffer << "\"" << TestLog::EndMessage;
2256 const tcu::ScopedLogSection section(m_testCtx.getLog(), "QueryNone", "Query one character");
2258 m_testCtx.getLog() << TestLog::Message << "Querying whole label, buffer size = 1" << TestLog::EndMessage;
2259 deMemset(buffer, 'X', sizeof(buffer));
2260 gl.getObjectLabel(GL_SHADER, shader, 1, &outlen, buffer);
2261 GLS_COLLECT_GL_ERROR(result, gl.getError(), "getObjectLabel");
2264 result.fail("'length' was not 0, got " + de::toString(outlen));
2265 else if (buffer[outlen] != '\0')
2266 result.fail("Buffer was not null-terminated");
2267 else if (buffer[outlen+1] != 'X')
2268 result.fail("Query wrote over buffer bound");
2270 m_testCtx.getLog() << TestLog::Message << "Query returned zero-sized null-terminated string" << TestLog::EndMessage;
2275 const tcu::ScopedLogSection superSection(m_testCtx.getLog(), "Sync", "Sync object");
2277 m_testCtx.getLog() << TestLog::Message << "Setting label to string: \"" << msg << "\"" << TestLog::EndMessage;
2278 gl.objectPtrLabel(sync, -1, msg);
2279 GLS_COLLECT_GL_ERROR(result, gl.getError(), "objectPtrLabel");
2282 const tcu::ScopedLogSection section(m_testCtx.getLog(), "QueryAll", "Query All");
2284 m_testCtx.getLog() << TestLog::Message << "Querying whole label, buffer size = 22" << TestLog::EndMessage;
2285 deMemset(buffer, 'X', sizeof(buffer));
2286 gl.getObjectPtrLabel(sync, 22, &outlen, buffer);
2287 GLS_COLLECT_GL_ERROR(result, gl.getError(), "getObjectPtrLabel");
2290 result.fail("'length' was not 21, got " + de::toString(outlen));
2291 else if (buffer[outlen] != '\0')
2292 result.fail("Buffer was not null-terminated");
2293 else if (buffer[outlen+1] != 'X')
2294 result.fail("Query wrote over buffer bound");
2295 else if (!deStringEqual(msg, buffer))
2297 buffer[63] = '\0'; // make sure buffer is null terminated before printing
2298 m_testCtx.getLog() << TestLog::Message << "Query returned string: \"" << buffer << "\"" << TestLog::EndMessage;
2299 result.fail("Query returned wrong label");
2302 m_testCtx.getLog() << TestLog::Message << "Query returned string: \"" << buffer << "\"" << TestLog::EndMessage;
2305 const tcu::ScopedLogSection section(m_testCtx.getLog(), "QueryAllNoSize", "Query all without size");
2307 m_testCtx.getLog() << TestLog::Message << "Querying whole label, buffer size = 22" << TestLog::EndMessage;
2308 deMemset(buffer, 'X', sizeof(buffer));
2309 gl.getObjectPtrLabel(sync, 22, DE_NULL, buffer);
2310 GLS_COLLECT_GL_ERROR(result, gl.getError(), "getObjectPtrLabel");
2312 buffer[63] = '\0'; // make sure buffer is null terminated before strlen
2314 if (strlen(buffer) != 21)
2315 result.fail("Buffer length was not 21");
2316 else if (buffer[21] != '\0')
2317 result.fail("Buffer was not null-terminated");
2318 else if (buffer[22] != 'X')
2319 result.fail("Query wrote over buffer bound");
2320 else if (!deStringEqual(msg, buffer))
2322 m_testCtx.getLog() << TestLog::Message << "Query returned string: \"" << buffer << "\"" << TestLog::EndMessage;
2323 result.fail("Query returned wrong label");
2326 m_testCtx.getLog() << TestLog::Message << "Query returned string: \"" << buffer << "\"" << TestLog::EndMessage;
2329 const tcu::ScopedLogSection section(m_testCtx.getLog(), "QueryLess", "Query substring");
2331 m_testCtx.getLog() << TestLog::Message << "Querying whole label, buffer size = 2" << TestLog::EndMessage;
2332 deMemset(buffer, 'X', sizeof(buffer));
2333 gl.getObjectPtrLabel(sync, 2, &outlen, buffer);
2334 GLS_COLLECT_GL_ERROR(result, gl.getError(), "getObjectPtrLabel");
2337 result.fail("'length' was not 1, got " + de::toString(outlen));
2338 else if (buffer[outlen] != '\0')
2339 result.fail("Buffer was not null-terminated");
2340 else if (buffer[outlen+1] != 'X')
2341 result.fail("Query wrote over buffer bound");
2342 else if (!deStringBeginsWith(msg, buffer))
2344 buffer[63] = '\0'; // make sure buffer is null terminated before printing
2345 m_testCtx.getLog() << TestLog::Message << "Query returned string: \"" << buffer << "\"" << TestLog::EndMessage;
2346 result.fail("Query returned wrong label");
2349 m_testCtx.getLog() << TestLog::Message << "Query returned string: \"" << buffer << "\"" << TestLog::EndMessage;
2352 const tcu::ScopedLogSection section(m_testCtx.getLog(), "QueryNone", "Query one character");
2354 m_testCtx.getLog() << TestLog::Message << "Querying whole label, buffer size = 1" << TestLog::EndMessage;
2355 deMemset(buffer, 'X', sizeof(buffer));
2356 gl.getObjectPtrLabel(sync, 1, &outlen, buffer);
2357 GLS_COLLECT_GL_ERROR(result, gl.getError(), "getObjectPtrLabel");
2360 result.fail("'length' was not 0, got " + de::toString(outlen));
2361 else if (buffer[outlen] != '\0')
2362 result.fail("Buffer was not null-terminated");
2363 else if (buffer[outlen+1] != 'X')
2364 result.fail("Query wrote over buffer bound");
2366 m_testCtx.getLog() << TestLog::Message << "Query returned zero-sized null-terminated string" << TestLog::EndMessage;
2370 gl.deleteShader(shader);
2371 gl.deleteSync(sync);
2373 result.setTestContextResult(m_testCtx);
2377 class LabelMaxSizeCase : public TestCase
2380 LabelMaxSizeCase (Context& ctx, const char* name, const char* desc);
2381 virtual IterateResult iterate (void);
2384 LabelMaxSizeCase::LabelMaxSizeCase (Context& ctx, const char* name, const char* desc)
2385 : TestCase(ctx, name, desc)
2389 LabelMaxSizeCase::IterateResult LabelMaxSizeCase::iterate (void)
2391 TCU_CHECK_AND_THROW(NotSupportedError, isKHRDebugSupported(m_context), "GL_KHR_debug is not supported");
2393 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2394 tcu::ResultCollector result (m_testCtx.getLog(), " // ERROR: ");
2395 int maxLabelLen = -1;
2400 gl.getIntegerv(GL_MAX_LABEL_LENGTH, &maxLabelLen);
2401 GLS_COLLECT_GL_ERROR(result, gl.getError(), "GL_MAX_LABEL_LENGTH");
2403 m_testCtx.getLog() << TestLog::Message << "GL_MAX_LABEL_LENGTH = " << maxLabelLen << TestLog::EndMessage;
2405 if (maxLabelLen < 256)
2406 throw tcu::TestError("maxLabelLen was less than required (256)");
2407 if (maxLabelLen > 8192)
2411 << "GL_MAX_LABEL_LENGTH is very large. Application having larger labels is unlikely, skipping test."
2412 << TestLog::EndMessage;
2413 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
2417 sync = gl.fenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
2418 GLS_COLLECT_GL_ERROR(result, gl.getError(), "fenceSync");
2420 shader = gl.createShader(GL_FRAGMENT_SHADER);
2421 GLS_COLLECT_GL_ERROR(result, gl.getError(), "createShader");
2424 const tcu::ScopedLogSection section (m_testCtx.getLog(), "Shader", "Shader object");
2425 std::vector<char> buffer (maxLabelLen, 'X');
2426 std::vector<char> readBuffer (maxLabelLen, 'X');
2428 buffer[maxLabelLen-1] = '\0';
2430 m_testCtx.getLog() << TestLog::Message << "Setting max length label, with implicit size. (length = -1)" << TestLog::EndMessage;
2431 gl.objectLabel(GL_SHADER, shader, -1, &buffer[0]);
2432 GLS_COLLECT_GL_ERROR(result, gl.getError(), "objectLabel");
2434 m_testCtx.getLog() << TestLog::Message << "Querying label back" << TestLog::EndMessage;
2436 gl.getObjectLabel(GL_SHADER, shader, maxLabelLen, &outlen, &readBuffer[0]);
2437 GLS_COLLECT_GL_ERROR(result, gl.getError(), "getObjectLabel");
2439 if (outlen != maxLabelLen-1)
2440 result.fail("'length' was not " + de::toString(maxLabelLen-1) + ", got " + de::toString(outlen));
2441 else if (readBuffer[outlen] != '\0')
2442 result.fail("Buffer was not null-terminated");
2444 m_testCtx.getLog() << TestLog::Message << "Setting max length label, with explicit size. (length = " << (maxLabelLen-1) << ")" << TestLog::EndMessage;
2445 gl.objectLabel(GL_SHADER, shader, maxLabelLen-1, &buffer[0]);
2446 GLS_COLLECT_GL_ERROR(result, gl.getError(), "objectLabel");
2448 m_testCtx.getLog() << TestLog::Message << "Querying label back" << TestLog::EndMessage;
2450 readBuffer[maxLabelLen-1] = 'X';
2451 gl.getObjectLabel(GL_SHADER, shader, maxLabelLen, &outlen, &readBuffer[0]);
2452 GLS_COLLECT_GL_ERROR(result, gl.getError(), "getObjectLabel");
2454 if (outlen != maxLabelLen-1)
2455 result.fail("'length' was not " + de::toString(maxLabelLen-1) + ", got " + de::toString(outlen));
2456 else if (readBuffer[outlen] != '\0')
2457 result.fail("Buffer was not null-terminated");
2461 const tcu::ScopedLogSection section (m_testCtx.getLog(), "Sync", "Sync object");
2462 std::vector<char> buffer (maxLabelLen, 'X');
2463 std::vector<char> readBuffer (maxLabelLen, 'X');
2465 buffer[maxLabelLen-1] = '\0';
2467 m_testCtx.getLog() << TestLog::Message << "Setting max length label, with implicit size. (length = -1)" << TestLog::EndMessage;
2468 gl.objectPtrLabel(sync, -1, &buffer[0]);
2469 GLS_COLLECT_GL_ERROR(result, gl.getError(), "objectPtrLabel");
2471 m_testCtx.getLog() << TestLog::Message << "Querying label back" << TestLog::EndMessage;
2473 gl.getObjectPtrLabel(sync, maxLabelLen, &outlen, &readBuffer[0]);
2474 GLS_COLLECT_GL_ERROR(result, gl.getError(), "getObjectPtrLabel");
2476 if (outlen != maxLabelLen-1)
2477 result.fail("'length' was not " + de::toString(maxLabelLen-1) + ", got " + de::toString(outlen));
2478 else if (readBuffer[outlen] != '\0')
2479 result.fail("Buffer was not null-terminated");
2481 m_testCtx.getLog() << TestLog::Message << "Setting max length label, with explicit size. (length = " << (maxLabelLen-1) << ")" << TestLog::EndMessage;
2482 gl.objectPtrLabel(sync, maxLabelLen-1, &buffer[0]);
2483 GLS_COLLECT_GL_ERROR(result, gl.getError(), "objectPtrLabel");
2485 m_testCtx.getLog() << TestLog::Message << "Querying label back" << TestLog::EndMessage;
2487 readBuffer[maxLabelLen-1] = 'X';
2488 gl.getObjectPtrLabel(sync, maxLabelLen, &outlen, &readBuffer[0]);
2489 GLS_COLLECT_GL_ERROR(result, gl.getError(), "getObjectPtrLabel");
2491 if (outlen != maxLabelLen-1)
2492 result.fail("'length' was not " + de::toString(maxLabelLen-1) + ", got " + de::toString(outlen));
2493 else if (readBuffer[outlen] != '\0')
2494 result.fail("Buffer was not null-terminated");
2497 gl.deleteShader(shader);
2498 gl.deleteSync(sync);
2500 result.setTestContextResult(m_testCtx);
2504 class LabelLengthCase : public TestCase
2507 LabelLengthCase (Context& ctx, const char* name, const char* desc);
2508 virtual IterateResult iterate (void);
2511 LabelLengthCase::LabelLengthCase (Context& ctx, const char* name, const char* desc)
2512 : TestCase(ctx, name, desc)
2516 LabelLengthCase::IterateResult LabelLengthCase::iterate (void)
2518 TCU_CHECK_AND_THROW(NotSupportedError, isKHRDebugSupported(m_context), "GL_KHR_debug is not supported");
2520 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2521 tcu::ResultCollector result (m_testCtx.getLog(), " // ERROR: ");
2522 const char* const msg = "This is a debug label";
2527 sync = gl.fenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
2528 GLS_COLLECT_GL_ERROR(result, gl.getError(), "fenceSync");
2530 shader = gl.createShader(GL_FRAGMENT_SHADER);
2531 GLS_COLLECT_GL_ERROR(result, gl.getError(), "createShader");
2534 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Shader", "Shader object");
2536 m_testCtx.getLog() << TestLog::Message << "Querying label length" << TestLog::EndMessage;
2538 gl.getObjectLabel(GL_SHADER, shader, 0, &outlen, DE_NULL);
2539 GLS_COLLECT_GL_ERROR(result, gl.getError(), "getObjectLabel");
2542 result.fail("'length' was not 0, got " + de::toString(outlen));
2544 m_testCtx.getLog() << TestLog::Message << "Query returned length: " << outlen << TestLog::EndMessage;
2546 m_testCtx.getLog() << TestLog::Message << "Setting label to string: \"" << msg << "\"" << TestLog::EndMessage;
2547 gl.objectLabel(GL_SHADER, shader, -1, msg);
2548 GLS_COLLECT_GL_ERROR(result, gl.getError(), "objectLabel");
2550 m_testCtx.getLog() << TestLog::Message << "Querying label length" << TestLog::EndMessage;
2552 gl.getObjectLabel(GL_SHADER, shader, 0, &outlen, DE_NULL);
2553 GLS_COLLECT_GL_ERROR(result, gl.getError(), "getObjectLabel");
2556 result.fail("'length' was not 21, got " + de::toString(outlen));
2558 m_testCtx.getLog() << TestLog::Message << "Query returned length: " << outlen << TestLog::EndMessage;
2562 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Sync", "Sync object");
2564 m_testCtx.getLog() << TestLog::Message << "Querying label length" << TestLog::EndMessage;
2566 gl.getObjectPtrLabel(sync, 0, &outlen, DE_NULL);
2567 GLS_COLLECT_GL_ERROR(result, gl.getError(), "getObjectPtrLabel");
2570 result.fail("'length' was not 0, got " + de::toString(outlen));
2572 m_testCtx.getLog() << TestLog::Message << "Query returned length: " << outlen << TestLog::EndMessage;
2574 m_testCtx.getLog() << TestLog::Message << "Setting label to string: \"" << msg << "\"" << TestLog::EndMessage;
2575 gl.objectPtrLabel(sync, -1, msg);
2576 GLS_COLLECT_GL_ERROR(result, gl.getError(), "objectPtrLabel");
2578 m_testCtx.getLog() << TestLog::Message << "Querying label length" << TestLog::EndMessage;
2580 gl.getObjectPtrLabel(sync, 0, &outlen, DE_NULL);
2581 GLS_COLLECT_GL_ERROR(result, gl.getError(), "getObjectPtrLabel");
2584 result.fail("'length' was not 21, got " + de::toString(outlen));
2586 m_testCtx.getLog() << TestLog::Message << "Query returned length: " << outlen << TestLog::EndMessage;
2589 gl.deleteShader(shader);
2590 gl.deleteSync(sync);
2592 result.setTestContextResult(m_testCtx);
2596 class LimitQueryCase : public TestCase
2599 LimitQueryCase (Context& context,
2601 const char* description,
2604 gls::StateQueryUtil::QueryType type);
2606 IterateResult iterate (void);
2608 const gls::StateQueryUtil::QueryType m_type;
2610 const glw::GLenum m_target;
2613 LimitQueryCase::LimitQueryCase (Context& context,
2615 const char* description,
2618 gls::StateQueryUtil::QueryType type)
2619 : TestCase (context, name, description)
2626 LimitQueryCase::IterateResult LimitQueryCase::iterate (void)
2628 TCU_CHECK_AND_THROW(NotSupportedError, isKHRDebugSupported(m_context), "GL_KHR_debug is not supported");
2630 glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
2631 tcu::ResultCollector result (m_testCtx.getLog(), " // ERROR: ");
2633 gl.enableLogging(true);
2634 gls::StateQueryUtil::verifyStateIntegerMin(result, gl, m_target, m_limit, m_type);
2636 result.setTestContextResult(m_testCtx);
2640 class IsEnabledCase : public TestCase
2645 INITIAL_CTX_IS_DEBUG = 0,
2649 IsEnabledCase (Context& context,
2651 const char* description,
2653 InitialValue initial,
2654 gls::StateQueryUtil::QueryType type);
2656 IterateResult iterate (void);
2658 const gls::StateQueryUtil::QueryType m_type;
2659 const glw::GLenum m_target;
2660 const InitialValue m_initial;
2663 IsEnabledCase::IsEnabledCase (Context& context,
2665 const char* description,
2667 InitialValue initial,
2668 gls::StateQueryUtil::QueryType type)
2669 : TestCase (context, name, description)
2672 , m_initial (initial)
2676 IsEnabledCase::IterateResult IsEnabledCase::iterate (void)
2678 TCU_CHECK_AND_THROW(NotSupportedError, isKHRDebugSupported(m_context), "GL_KHR_debug is not supported");
2680 glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
2681 tcu::ResultCollector result (m_testCtx.getLog(), " // ERROR: ");
2684 gl.enableLogging(true);
2686 if (m_initial == INITIAL_FALSE)
2690 DE_ASSERT(m_initial == INITIAL_CTX_IS_DEBUG);
2691 initial = (m_context.getRenderContext().getType().getFlags() & glu::CONTEXT_DEBUG) != 0;
2694 // check inital value
2695 gls::StateQueryUtil::verifyStateBoolean(result, gl, m_target, initial, m_type);
2699 gl.glEnable(m_target);
2700 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glEnable");
2702 gls::StateQueryUtil::verifyStateBoolean(result, gl, m_target, true, m_type);
2704 gl.glDisable(m_target);
2705 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDisable");
2707 gls::StateQueryUtil::verifyStateBoolean(result, gl, m_target, false, m_type);
2709 result.setTestContextResult(m_testCtx);
2713 class PositiveIntegerCase : public TestCase
2716 PositiveIntegerCase (Context& context,
2718 const char* description,
2720 gls::StateQueryUtil::QueryType type);
2722 IterateResult iterate (void);
2724 const gls::StateQueryUtil::QueryType m_type;
2725 const glw::GLenum m_target;
2728 PositiveIntegerCase::PositiveIntegerCase (Context& context,
2730 const char* description,
2732 gls::StateQueryUtil::QueryType type)
2733 : TestCase (context, name, description)
2739 PositiveIntegerCase::IterateResult PositiveIntegerCase::iterate (void)
2741 TCU_CHECK_AND_THROW(NotSupportedError, isKHRDebugSupported(m_context), "GL_KHR_debug is not supported");
2743 glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
2744 tcu::ResultCollector result (m_testCtx.getLog(), " // ERROR: ");
2746 gl.enableLogging(true);
2747 gls::StateQueryUtil::verifyStateIntegerMin(result, gl, m_target, 0, m_type);
2749 result.setTestContextResult(m_testCtx);
2753 class GroupStackDepthQueryCase : public TestCase
2756 GroupStackDepthQueryCase (Context& context,
2758 const char* description,
2759 gls::StateQueryUtil::QueryType type);
2761 IterateResult iterate (void);
2763 const gls::StateQueryUtil::QueryType m_type;
2766 GroupStackDepthQueryCase::GroupStackDepthQueryCase (Context& context,
2768 const char* description,
2769 gls::StateQueryUtil::QueryType type)
2770 : TestCase (context, name, description)
2775 GroupStackDepthQueryCase::IterateResult GroupStackDepthQueryCase::iterate (void)
2777 TCU_CHECK_AND_THROW(NotSupportedError, isKHRDebugSupported(m_context), "GL_KHR_debug is not supported");
2779 glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
2780 tcu::ResultCollector result (m_testCtx.getLog(), " // ERROR: ");
2782 gl.enableLogging(true);
2785 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
2787 gls::StateQueryUtil::verifyStateInteger(result, gl, GL_DEBUG_GROUP_STACK_DEPTH, 1, m_type);
2791 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Scoped", "Scoped");
2793 gl.glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 1, -1, "Application group 1");
2794 gls::StateQueryUtil::verifyStateInteger(result, gl, GL_DEBUG_GROUP_STACK_DEPTH, 2, m_type);
2795 gl.glPopDebugGroup();
2798 result.setTestContextResult(m_testCtx);
2802 extern "C" void GLW_APIENTRY dummyCallback(GLenum, GLenum, GLuint, GLenum, GLsizei, const char*, void*)
2807 class DebugCallbackFunctionCase : public TestCase
2810 DebugCallbackFunctionCase (Context& context, const char* name, const char* description);
2811 IterateResult iterate (void);
2814 DebugCallbackFunctionCase::DebugCallbackFunctionCase (Context& context, const char* name, const char* description)
2815 : TestCase (context, name, description)
2819 DebugCallbackFunctionCase::IterateResult DebugCallbackFunctionCase::iterate (void)
2821 using namespace gls::StateQueryUtil;
2822 TCU_CHECK_AND_THROW(NotSupportedError, isKHRDebugSupported(m_context), "GL_KHR_debug is not supported");
2824 glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
2825 tcu::ResultCollector result (m_testCtx.getLog(), " // ERROR: ");
2827 gl.enableLogging(true);
2830 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
2832 verifyStatePointer(result, gl, GL_DEBUG_CALLBACK_FUNCTION, 0, QUERY_POINTER);
2836 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Set", "Set");
2838 gl.glDebugMessageCallback(dummyCallback, DE_NULL);
2839 verifyStatePointer(result, gl, GL_DEBUG_CALLBACK_FUNCTION, (const void*)dummyCallback, QUERY_POINTER);
2842 result.setTestContextResult(m_testCtx);
2846 class DebugCallbackUserParamCase : public TestCase
2849 DebugCallbackUserParamCase (Context& context, const char* name, const char* description);
2850 IterateResult iterate (void);
2853 DebugCallbackUserParamCase::DebugCallbackUserParamCase (Context& context, const char* name, const char* description)
2854 : TestCase (context, name, description)
2858 DebugCallbackUserParamCase::IterateResult DebugCallbackUserParamCase::iterate (void)
2860 using namespace gls::StateQueryUtil;
2862 TCU_CHECK_AND_THROW(NotSupportedError, isKHRDebugSupported(m_context), "GL_KHR_debug is not supported");
2864 glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
2865 tcu::ResultCollector result (m_testCtx.getLog(), " // ERROR: ");
2867 gl.enableLogging(true);
2870 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
2872 verifyStatePointer(result, gl, GL_DEBUG_CALLBACK_USER_PARAM, 0, QUERY_POINTER);
2876 const tcu::ScopedLogSection section (m_testCtx.getLog(), "Set", "Set");
2877 const void* param = (void*)(int*)0x123;
2879 gl.glDebugMessageCallback(dummyCallback, param);
2880 verifyStatePointer(result, gl, GL_DEBUG_CALLBACK_USER_PARAM, param, QUERY_POINTER);
2883 result.setTestContextResult(m_testCtx);
2889 DebugTests::DebugTests (Context& context)
2890 : TestCaseGroup(context, "debug", "Debug tests")
2896 CASETYPE_CALLBACK = 0,
2903 tcu::TestNode* createCase (CaseType type, Context& ctx, const char* name, const char* desc, TestFunctionWrapper function)
2907 case CASETYPE_CALLBACK: return new CallbackErrorCase(ctx, name, desc, function);
2908 case CASETYPE_LOG: return new LogErrorCase(ctx, name, desc, function);
2909 case CASETYPE_GETERROR: return new GetErrorCase(ctx, name, desc, function);
2912 DE_FATAL("Invalid type");
2918 tcu::TestCaseGroup* createChildCases (CaseType type, Context& ctx, const char* name, const char* desc, const vector<FunctionContainer>& funcs)
2920 tcu::TestCaseGroup* host = new tcu::TestCaseGroup(ctx.getTestContext(), name, desc);
2922 for (size_t ndx = 0; ndx < funcs.size(); ndx++)
2923 host->addChild(createCase(type, ctx, funcs[ndx].name, funcs[ndx].desc, funcs[ndx].function));
2928 vector<FunctionContainer> wrapCoreFunctions (const vector<NegativeTestShared::FunctionContainer>& fns)
2930 vector<FunctionContainer> retVal;
2932 retVal.resize(fns.size());
2933 for (int ndx = 0; ndx < (int)fns.size(); ++ndx)
2935 retVal[ndx].function = TestFunctionWrapper(fns[ndx].function);
2936 retVal[ndx].name = fns[ndx].name;
2937 retVal[ndx].desc = fns[ndx].desc;
2943 void DebugTests::init (void)
2945 const vector<FunctionContainer> bufferFuncs = wrapCoreFunctions(NegativeTestShared::getNegativeBufferApiTestFunctions());
2946 const vector<FunctionContainer> textureFuncs = wrapCoreFunctions(NegativeTestShared::getNegativeTextureApiTestFunctions());
2947 const vector<FunctionContainer> shaderFuncs = wrapCoreFunctions(NegativeTestShared::getNegativeShaderApiTestFunctions());
2948 const vector<FunctionContainer> fragmentFuncs = wrapCoreFunctions(NegativeTestShared::getNegativeFragmentApiTestFunctions());
2949 const vector<FunctionContainer> vaFuncs = wrapCoreFunctions(NegativeTestShared::getNegativeVertexArrayApiTestFunctions());
2950 const vector<FunctionContainer> stateFuncs = wrapCoreFunctions(NegativeTestShared::getNegativeStateApiTestFunctions());
2951 const vector<FunctionContainer> tessellationFuncs = wrapCoreFunctions(NegativeTestShared::getNegativeTessellationTestFunctions());
2952 const vector<FunctionContainer> atomicCounterFuncs = wrapCoreFunctions(NegativeTestShared::getNegativeAtomicCounterTestFunctions());
2953 const vector<FunctionContainer> imageLoadFuncs = wrapCoreFunctions(NegativeTestShared::getNegativeShaderImageLoadTestFunctions());
2954 const vector<FunctionContainer> imageStoreFuncs = wrapCoreFunctions(NegativeTestShared::getNegativeShaderImageStoreTestFunctions());
2955 const vector<FunctionContainer> imageAtomicFuncs = wrapCoreFunctions(NegativeTestShared::getNegativeShaderImageAtomicTestFunctions());
2956 const vector<FunctionContainer> imageAtomicExchangeFuncs = wrapCoreFunctions(NegativeTestShared::getNegativeShaderImageAtomicExchangeTestFunctions());
2957 const vector<FunctionContainer> shaderFunctionFuncs = wrapCoreFunctions(NegativeTestShared::getNegativeShaderFunctionTestFunctions());
2958 const vector<FunctionContainer> shaderDirectiveFuncs = wrapCoreFunctions(NegativeTestShared::getNegativeShaderDirectiveTestFunctions());
2959 const vector<FunctionContainer> ssboBlockFuncs = wrapCoreFunctions(NegativeTestShared::getNegativeSSBOBlockTestFunctions());
2960 const vector<FunctionContainer> preciseFuncs = wrapCoreFunctions(NegativeTestShared::getNegativePreciseTestFunctions());
2961 const vector<FunctionContainer> advancedBlendFuncs = wrapCoreFunctions(NegativeTestShared::getNegativeAdvancedBlendEquationTestFunctions());
2962 const vector<FunctionContainer> shaderStorageFuncs = wrapCoreFunctions(NegativeTestShared::getNegativeShaderStorageTestFunctions());
2963 const vector<FunctionContainer> externalFuncs = getUserMessageFuncs();
2966 using namespace gls::StateQueryUtil;
2968 tcu::TestCaseGroup* const queries = new tcu::TestCaseGroup(m_testCtx, "state_query", "State query");
2973 const char* targetName;
2978 { "max_debug_message_length", "MAX_DEBUG_MESSAGE_LENGTH", GL_MAX_DEBUG_MESSAGE_LENGTH, 1 },
2979 { "max_debug_logged_messages", "MAX_DEBUG_LOGGED_MESSAGES", GL_MAX_DEBUG_LOGGED_MESSAGES, 1 },
2980 { "max_debug_group_stack_depth", "MAX_DEBUG_GROUP_STACK_DEPTH", GL_MAX_DEBUG_GROUP_STACK_DEPTH, 64 },
2981 { "max_label_length", "MAX_LABEL_LENGTH", GL_MAX_LABEL_LENGTH, 256 },
2986 #define FOR_ALL_TYPES(X) \
2990 const char* const postfix = "_getboolean"; \
2991 const QueryType queryType = QUERY_BOOLEAN; \
2995 const char* const postfix = "_getinteger"; \
2996 const QueryType queryType = QUERY_INTEGER; \
3000 const char* const postfix = "_getinteger64"; \
3001 const QueryType queryType = QUERY_INTEGER64; \
3005 const char* const postfix = "_getfloat"; \
3006 const QueryType queryType = QUERY_FLOAT; \
3010 while (deGetFalse())
3011 #define FOR_ALL_ENABLE_TYPES(X) \
3015 const char* const postfix = "_isenabled"; \
3016 const QueryType queryType = QUERY_ISENABLED; \
3021 while (deGetFalse())
3023 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(limits); ++ndx)
3025 FOR_ALL_TYPES(queries->addChild(new LimitQueryCase(m_context,
3026 (std::string(limits[ndx].name) + postfix).c_str(),
3027 (std::string("Test ") + limits[ndx].targetName).c_str(),
3028 limits[ndx].target, limits[ndx].limit, queryType)));
3031 FOR_ALL_ENABLE_TYPES(queries->addChild(new IsEnabledCase (m_context, (std::string("debug_output") + postfix).c_str(), "Test DEBUG_OUTPUT", GL_DEBUG_OUTPUT, IsEnabledCase::INITIAL_CTX_IS_DEBUG, queryType)));
3032 FOR_ALL_ENABLE_TYPES(queries->addChild(new IsEnabledCase (m_context, (std::string("debug_output_synchronous") + postfix).c_str(), "Test DEBUG_OUTPUT_SYNCHRONOUS", GL_DEBUG_OUTPUT_SYNCHRONOUS, IsEnabledCase::INITIAL_FALSE, queryType)));
3034 FOR_ALL_TYPES(queries->addChild(new PositiveIntegerCase (m_context, (std::string("debug_logged_messages") + postfix).c_str(), "Test DEBUG_LOGGED_MESSAGES", GL_DEBUG_LOGGED_MESSAGES, queryType)));
3035 FOR_ALL_TYPES(queries->addChild(new PositiveIntegerCase (m_context, (std::string("debug_next_logged_message_length") + postfix).c_str(), "Test DEBUG_NEXT_LOGGED_MESSAGE_LENGTH", GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH, queryType)));
3036 FOR_ALL_TYPES(queries->addChild(new GroupStackDepthQueryCase(m_context, (std::string("debug_group_stack_depth") + postfix).c_str(), "Test DEBUG_GROUP_STACK_DEPTH", queryType)));
3038 queries->addChild(new DebugCallbackFunctionCase (m_context, "debug_callback_function_getpointer", "Test DEBUG_CALLBACK_FUNCTION"));
3039 queries->addChild(new DebugCallbackUserParamCase(m_context, "debug_callback_user_param_getpointer", "Test DEBUG_CALLBACK_USER_PARAM"));
3041 #undef FOR_ALL_TYPES
3042 #undef FOR_ALL_ENABLE_TYPES
3046 tcu::TestCaseGroup* const negative = new tcu::TestCaseGroup(m_testCtx, "negative_coverage", "API error coverage with various reporting methods");
3050 tcu::TestCaseGroup* const host = new tcu::TestCaseGroup(m_testCtx, "callbacks", "Reporting of standard API errors via callback");
3052 negative->addChild(host);
3053 host->addChild(createChildCases(CASETYPE_CALLBACK, m_context, "buffer", "Negative Buffer API Cases", bufferFuncs));
3054 host->addChild(createChildCases(CASETYPE_CALLBACK, m_context, "texture", "Negative Texture API Cases", textureFuncs));
3055 host->addChild(createChildCases(CASETYPE_CALLBACK, m_context, "shader", "Negative Shader API Cases", shaderFuncs));
3056 host->addChild(createChildCases(CASETYPE_CALLBACK, m_context, "fragment", "Negative Fragment API Cases", fragmentFuncs));
3057 host->addChild(createChildCases(CASETYPE_CALLBACK, m_context, "vertex_array", "Negative Vertex Array API Cases", vaFuncs));
3058 host->addChild(createChildCases(CASETYPE_CALLBACK, m_context, "state", "Negative GL State API Cases", stateFuncs));
3059 host->addChild(createChildCases(CASETYPE_CALLBACK, m_context, "atomic_counter", "Negative Atomic Counter API Cases", atomicCounterFuncs));
3060 host->addChild(createChildCases(CASETYPE_CALLBACK, m_context, "shader_image_load", "Negative Shader Image Load API Cases", imageLoadFuncs));
3061 host->addChild(createChildCases(CASETYPE_CALLBACK, m_context, "shader_image_store", "Negative Shader Image Store API Cases", imageStoreFuncs));
3062 host->addChild(createChildCases(CASETYPE_CALLBACK, m_context, "shader_image_atomic", "Negative Shader Image Atomic API Cases", imageAtomicFuncs));
3063 host->addChild(createChildCases(CASETYPE_CALLBACK, m_context, "shader_image_exchange", "Negative Shader Image Atomic Exchange API Cases", imageAtomicExchangeFuncs));
3064 host->addChild(createChildCases(CASETYPE_CALLBACK, m_context, "shader_function", "Negative Shader Function Cases", shaderFunctionFuncs));
3065 host->addChild(createChildCases(CASETYPE_CALLBACK, m_context, "shader_directive", "Negative Shader Directive Cases", shaderDirectiveFuncs));
3066 host->addChild(createChildCases(CASETYPE_CALLBACK, m_context, "ssbo_block", "Negative SSBO Block Cases", ssboBlockFuncs));
3067 host->addChild(createChildCases(CASETYPE_CALLBACK, m_context, "precise", "Negative Precise Cases", preciseFuncs));
3068 host->addChild(createChildCases(CASETYPE_CALLBACK, m_context, "advanced_blend", "Negative Advanced Blend Equation Cases", advancedBlendFuncs));
3069 host->addChild(createChildCases(CASETYPE_CALLBACK, m_context, "shader_storage", "Negative Shader Storage Cases", shaderStorageFuncs));
3070 host->addChild(createChildCases(CASETYPE_CALLBACK, m_context, "tessellation", "Negative Tessellation Cases", tessellationFuncs));
3074 tcu::TestCaseGroup* const host = new tcu::TestCaseGroup(m_testCtx, "log", "Reporting of standard API errors via log");
3076 negative->addChild(host);
3078 host->addChild(createChildCases(CASETYPE_LOG, m_context, "buffer", "Negative Buffer API Cases", bufferFuncs));
3079 host->addChild(createChildCases(CASETYPE_LOG, m_context, "texture", "Negative Texture API Cases", textureFuncs));
3080 host->addChild(createChildCases(CASETYPE_LOG, m_context, "shader", "Negative Shader API Cases", shaderFuncs));
3081 host->addChild(createChildCases(CASETYPE_LOG, m_context, "fragment", "Negative Fragment API Cases", fragmentFuncs));
3082 host->addChild(createChildCases(CASETYPE_LOG, m_context, "vertex_array", "Negative Vertex Array API Cases", vaFuncs));
3083 host->addChild(createChildCases(CASETYPE_LOG, m_context, "state", "Negative GL State API Cases", stateFuncs));
3084 host->addChild(createChildCases(CASETYPE_LOG, m_context, "atomic_counter", "Negative Atomic Counter API Cases", atomicCounterFuncs));
3085 host->addChild(createChildCases(CASETYPE_LOG, m_context, "shader_image_load", "Negative Shader Image Load API Cases", imageLoadFuncs));
3086 host->addChild(createChildCases(CASETYPE_LOG, m_context, "shader_image_store", "Negative Shader Image Store API Cases", imageStoreFuncs));
3087 host->addChild(createChildCases(CASETYPE_LOG, m_context, "shader_image_atomic", "Negative Shader Image Atomic API Cases", imageAtomicFuncs));
3088 host->addChild(createChildCases(CASETYPE_LOG, m_context, "shader_image_exchange", "Negative Shader Image Atomic Exchange API Cases", imageAtomicExchangeFuncs));
3089 host->addChild(createChildCases(CASETYPE_LOG, m_context, "shader_function", "Negative Shader Function Cases", shaderFunctionFuncs));
3090 host->addChild(createChildCases(CASETYPE_LOG, m_context, "shader_directive", "Negative Shader Directive Cases", shaderDirectiveFuncs));
3091 host->addChild(createChildCases(CASETYPE_LOG, m_context, "ssbo_block", "Negative SSBO Block Cases", ssboBlockFuncs));
3092 host->addChild(createChildCases(CASETYPE_LOG, m_context, "precise", "Negative Precise Cases", preciseFuncs));
3093 host->addChild(createChildCases(CASETYPE_LOG, m_context, "advanced_blend", "Negative Advanced Blend Equation Cases", advancedBlendFuncs));
3094 host->addChild(createChildCases(CASETYPE_LOG, m_context, "shader_storage", "Negative Shader Storage Cases", shaderStorageFuncs));
3095 host->addChild(createChildCases(CASETYPE_LOG, m_context, "tessellation", "Negative Tessellation Cases", tessellationFuncs));
3099 tcu::TestCaseGroup* const host = new tcu::TestCaseGroup(m_testCtx, "get_error", "Reporting of standard API errors via glGetError");
3101 negative->addChild(host);
3103 host->addChild(createChildCases(CASETYPE_GETERROR, m_context, "buffer", "Negative Buffer API Cases", bufferFuncs));
3104 host->addChild(createChildCases(CASETYPE_GETERROR, m_context, "texture", "Negative Texture API Cases", textureFuncs));
3105 host->addChild(createChildCases(CASETYPE_GETERROR, m_context, "shader", "Negative Shader API Cases", shaderFuncs));
3106 host->addChild(createChildCases(CASETYPE_GETERROR, m_context, "fragment", "Negative Fragment API Cases", fragmentFuncs));
3107 host->addChild(createChildCases(CASETYPE_GETERROR, m_context, "vertex_array", "Negative Vertex Array API Cases", vaFuncs));
3108 host->addChild(createChildCases(CASETYPE_GETERROR, m_context, "state", "Negative GL State API Cases", stateFuncs));
3109 host->addChild(createChildCases(CASETYPE_GETERROR, m_context, "atomic_counter", "Negative Atomic Counter API Cases", atomicCounterFuncs));
3110 host->addChild(createChildCases(CASETYPE_GETERROR, m_context, "shader_image_load", "Negative Shader Image Load API Cases", imageLoadFuncs));
3111 host->addChild(createChildCases(CASETYPE_GETERROR, m_context, "shader_image_store", "Negative Shader Image Store API Cases", imageStoreFuncs));
3112 host->addChild(createChildCases(CASETYPE_GETERROR, m_context, "shader_image_atomic", "Negative Shader Image Atomic API Cases", imageAtomicFuncs));
3113 host->addChild(createChildCases(CASETYPE_GETERROR, m_context, "shader_image_exchange", "Negative Shader Image Atomic Exchange API Cases", imageAtomicExchangeFuncs));
3114 host->addChild(createChildCases(CASETYPE_GETERROR, m_context, "shader_function", "Negative Shader Function Cases", shaderFunctionFuncs));
3115 host->addChild(createChildCases(CASETYPE_GETERROR, m_context, "shader_directive", "Negative Shader Directive Cases", shaderDirectiveFuncs));
3116 host->addChild(createChildCases(CASETYPE_GETERROR, m_context, "ssbo_block", "Negative SSBO Block Cases", ssboBlockFuncs));
3117 host->addChild(createChildCases(CASETYPE_GETERROR, m_context, "precise", "Negative Precise Cases", preciseFuncs));
3118 host->addChild(createChildCases(CASETYPE_GETERROR, m_context, "advanced_blend", "Negative Advanced Blend Equation Cases", advancedBlendFuncs));
3119 host->addChild(createChildCases(CASETYPE_GETERROR, m_context, "shader_storage", "Negative Shader Storage Cases", shaderStorageFuncs));
3120 host->addChild(createChildCases(CASETYPE_GETERROR, m_context, "tessellation", "Negative Tessellation Cases", tessellationFuncs));
3125 tcu::TestCaseGroup* const host = createChildCases(CASETYPE_CALLBACK, m_context, "externally_generated", "Externally Generated Messages", externalFuncs);
3127 host->addChild(new GroupCase(m_context, "push_pop_consistency", "Push/pop message generation with full message output checking"));
3133 vector<FunctionContainer> containers;
3134 vector<TestFunctionWrapper> allFuncs;
3136 de::Random rng (0x53941903 ^ m_context.getTestContext().getCommandLine().getBaseSeed());
3138 containers.insert(containers.end(), bufferFuncs.begin(), bufferFuncs.end());
3139 containers.insert(containers.end(), textureFuncs.begin(), textureFuncs.end());
3140 containers.insert(containers.end(), externalFuncs.begin(), externalFuncs.end());
3142 for (size_t ndx = 0; ndx < containers.size(); ndx++)
3143 allFuncs.push_back(containers[ndx].function);
3145 rng.shuffle(allFuncs.begin(), allFuncs.end());
3148 tcu::TestCaseGroup* const filtering = new tcu::TestCaseGroup(m_testCtx, "error_filters", "Filtering of reported errors");
3149 const int errorFuncsPerCase = 4;
3150 const int maxFilteringCaseCount = 32;
3151 const int caseCount = (int(allFuncs.size()) + errorFuncsPerCase-1) / errorFuncsPerCase;
3153 addChild(filtering);
3155 for (int caseNdx = 0; caseNdx < de::min(caseCount, maxFilteringCaseCount); caseNdx++)
3157 const int start = caseNdx*errorFuncsPerCase;
3158 const int end = de::min((caseNdx+1)*errorFuncsPerCase, int(allFuncs.size()));
3159 const string name = "case_" + de::toString(caseNdx);
3160 vector<TestFunctionWrapper> funcs (allFuncs.begin()+start, allFuncs.begin()+end);
3162 // These produce lots of different message types, thus always include at least one when testing filtering
3163 funcs.insert(funcs.end(), externalFuncs[caseNdx%externalFuncs.size()].function);
3165 filtering->addChild(new FilterCase(m_context, name.c_str(), "DebugMessageControl usage", funcs));
3170 tcu::TestCaseGroup* const groups = new tcu::TestCaseGroup(m_testCtx, "error_groups", "Filtering of reported errors with use of Error Groups");
3171 const int errorFuncsPerCase = 4;
3172 const int maxFilteringCaseCount = 16;
3173 const int caseCount = (int(allFuncs.size()) + errorFuncsPerCase-1) / errorFuncsPerCase;
3177 for (int caseNdx = 0; caseNdx < caseCount && caseNdx < maxFilteringCaseCount; caseNdx++)
3179 const int start = caseNdx*errorFuncsPerCase;
3180 const int end = de::min((caseNdx+1)*errorFuncsPerCase, int(allFuncs.size()));
3181 const string name = ("case_" + de::toString(caseNdx)).c_str();
3182 vector<TestFunctionWrapper> funcs (&allFuncs[0]+start, &allFuncs[0]+end);
3184 // These produce lots of different message types, thus always include at least one when testing filtering
3185 funcs.insert(funcs.end(), externalFuncs[caseNdx%externalFuncs.size()].function);
3187 groups->addChild(new GroupFilterCase(m_context, name.c_str(), "Debug Group usage", funcs));
3192 tcu::TestCaseGroup* const async = new tcu::TestCaseGroup(m_testCtx, "async", "Asynchronous message generation");
3193 const int errorFuncsPerCase = 2;
3194 const int maxAsyncCaseCount = 16;
3195 const int caseCount = (int(allFuncs.size()) + errorFuncsPerCase-1) / errorFuncsPerCase;
3199 for (int caseNdx = 0; caseNdx < caseCount && caseNdx < maxAsyncCaseCount; caseNdx++)
3201 const int start = caseNdx*errorFuncsPerCase;
3202 const int end = de::min((caseNdx+1)*errorFuncsPerCase, int(allFuncs.size()));
3203 const string name = ("case_" + de::toString(caseNdx)).c_str();
3204 vector<TestFunctionWrapper> funcs (&allFuncs[0]+start, &allFuncs[0]+end);
3207 async->addChild(new AsyncCase(m_context, (name+"_callback").c_str(), "Async message generation", funcs, true));
3209 async->addChild(new AsyncCase(m_context, (name+"_log").c_str(), "Async message generation", funcs, false));
3215 tcu::TestCaseGroup* const labels = new tcu::TestCaseGroup(m_testCtx, "object_labels", "Labeling objects");
3224 { GL_BUFFER, "buffer", "Debug label on a buffer object" },
3225 { GL_SHADER, "shader", "Debug label on a shader object" },
3226 { GL_PROGRAM, "program", "Debug label on a program object" },
3227 { GL_QUERY, "query", "Debug label on a query object" },
3228 { GL_PROGRAM_PIPELINE, "program_pipeline", "Debug label on a program pipeline object" },
3229 { GL_TRANSFORM_FEEDBACK, "transform_feedback", "Debug label on a transform feedback object" },
3230 { GL_SAMPLER, "sampler", "Debug label on a sampler object" },
3231 { GL_TEXTURE, "texture", "Debug label on a texture object" },
3232 { GL_RENDERBUFFER, "renderbuffer", "Debug label on a renderbuffer object" },
3233 { GL_FRAMEBUFFER, "framebuffer", "Debug label on a framebuffer object" },
3238 labels->addChild(new InitialLabelCase (m_context, "initial", "Debug label initial value"));
3239 labels->addChild(new ClearLabelCase (m_context, "clearing", "Debug label clearing"));
3240 labels->addChild(new SpecifyWithLengthCase (m_context, "specify_with_length", "Debug label specified with length"));
3241 labels->addChild(new BufferLimitedLabelCase (m_context, "buffer_limited_query", "Debug label query to too short buffer"));
3242 labels->addChild(new LabelMaxSizeCase (m_context, "max_label_length", "Max sized debug label"));
3243 labels->addChild(new LabelLengthCase (m_context, "query_length_only", "Query debug label length"));
3245 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(cases); ndx++)
3246 labels->addChild(new LabelCase(m_context, cases[ndx].name, cases[ndx].desc, cases[ndx].identifier));
3247 labels->addChild(new SyncLabelCase(m_context, "sync", "Debug label on a sync object"));