• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-------------------------------------------------------------------------
2  * OpenGL Conformance Test Suite
3  * -----------------------------
4  *
5  * Copyright (c) 2017 The Khronos Group Inc.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */ /*!
20  * \file
21  * \brief
22  */ /*-------------------------------------------------------------------*/
23 
24 /**
25  */ /*!
26  * \file  glcNoErrorTests.cpp
27  * \brief Conformance tests for the GL_KHR_no_error functionality.
28  */ /*--------------------------------------------------------------------*/
29 
30 #include "glcNoErrorTests.hpp"
31 #include "gluContextInfo.hpp"
32 #include "gluDefs.hpp"
33 #include "glwEnums.hpp"
34 #include "glwFunctions.hpp"
35 #include "tcuCommandLine.hpp"
36 #include "tcuTestLog.hpp"
37 
38 using namespace glu;
39 
40 namespace glcts
41 {
42 
43 /** Constructor.
44 	 *
45 	 *  @param context     Rendering context
46 	 *  @param name        Test name
47 	 *  @param description Test description
48 	 *  @param apiType     API version
49 	 */
NoErrorContextTest(tcu::TestContext & testCtx,glu::ApiType apiType)50 NoErrorContextTest::NoErrorContextTest(tcu::TestContext& testCtx, glu::ApiType apiType)
51 	: tcu::TestCase(testCtx, "create_context", "Test verifies if it is possible to create context with "
52 											   "CONTEXT_FLAG_NO_ERROR_BIT_KHR flag set in CONTEXT_FLAGS")
53 	, m_ApiType(apiType)
54 {
55 	/* Left blank intentionally */
56 }
57 
58 /** Tears down any GL objects set up to run the test. */
deinit(void)59 void NoErrorContextTest::deinit(void)
60 {
61 }
62 
63 /** Stub init method */
init(void)64 void NoErrorContextTest::init(void)
65 {
66 }
67 
68 /** Veriffy if no error context can be successfully created.
69 	 * @return True when no error context was successfully created.
70 	 */
verifyNoErrorContext(void)71 bool NoErrorContextTest::verifyNoErrorContext(void)
72 {
73 	RenderConfig renderCfg(glu::ContextType(m_ApiType, glu::CONTEXT_NO_ERROR));
74 
75 	const tcu::CommandLine& commandLine = m_testCtx.getCommandLine();
76 	glu::parseRenderConfig(&renderCfg, commandLine);
77 
78 	if (commandLine.getSurfaceType() != tcu::SURFACETYPE_WINDOW)
79 		throw tcu::NotSupportedError("Test not supported in non-windowed context");
80 
81 	RenderContext* noErrorContext = createRenderContext(m_testCtx.getPlatform(), commandLine, renderCfg);
82 	bool		   contextCreated = (noErrorContext != NULL);
83 	delete noErrorContext;
84 
85 	return contextCreated;
86 }
87 
88 /** Executes test iteration.
89 	 *
90 	 *  @return Returns STOP when test has finished executing, CONTINUE if more iterations are needed.
91 	 */
iterate(void)92 tcu::TestNode::IterateResult NoErrorContextTest::iterate(void)
93 {
94 	{
95 		glu::ContextType contextType(m_ApiType);
96 		deqp::Context	context(m_testCtx, contextType);
97 
98 		bool noErrorExtensionExists = glu::contextSupports(contextType, glu::ApiType::core(4, 6));
99 		noErrorExtensionExists |= context.getContextInfo().isExtensionSupported("GL_KHR_no_error");
100 
101 		if (!noErrorExtensionExists)
102 		{
103 			m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "GL_KHR_no_error extension not supported");
104 			return STOP;
105 		}
106 	} // at this point intermediate context used to query the GL_KHR_no_error extension should be destroyed
107 
108 	if (verifyNoErrorContext())
109 	{
110 		m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
111 		return STOP;
112 	}
113 
114 	m_testCtx.getLog() << tcu::TestLog::Message << "Failed to create No Error context" << tcu::TestLog::EndMessage;
115 	m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
116 	return STOP;
117 }
118 
119 /** Constructor.
120 	 *
121 	 *  @param context Rendering context.
122 	 */
NoErrorTests(tcu::TestContext & testCtx,glu::ApiType apiType)123 NoErrorTests::NoErrorTests(tcu::TestContext& testCtx, glu::ApiType apiType)
124 	: tcu::TestCaseGroup(testCtx, "no_error", "Verify conformance of GL_KHR_no_error implementation")
125 	, m_ApiType(apiType)
126 {
127 }
128 
129 /** Initializes the test group contents. */
init(void)130 void NoErrorTests::init(void)
131 {
132 	addChild(new NoErrorContextTest(m_testCtx, m_ApiType));
133 }
134 } /* glcts namespace */
135