1 /*-------------------------------------------------------------------------
2 * OpenGL Conformance Test Suite
3 * -----------------------------
5 * Copyright (c) 2017 The Khronos Group Inc.
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.
22 */ /*-------------------------------------------------------------------*/
26 * \file glcNoErrorTests.cpp
27 * \brief Conformance tests for the GL_KHR_no_error functionality.
28 */ /*--------------------------------------------------------------------*/
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"
45 * @param context Rendering context
46 * @param name Test name
47 * @param description Test description
48 * @param apiType API version
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")
55 /* Left blank intentionally */
58 /** Tears down any GL objects set up to run the test. */
59 void NoErrorContextTest::deinit(void)
63 /** Stub init method */
64 void NoErrorContextTest::init(void)
68 /** Veriffy if no error context can be successfully created.
69 * @return True when no error context was successfully created.
71 bool NoErrorContextTest::verifyNoErrorContext(void)
73 RenderConfig renderCfg(glu::ContextType(m_ApiType, glu::CONTEXT_NO_ERROR));
75 const tcu::CommandLine& commandLine = m_testCtx.getCommandLine();
76 glu::parseRenderConfig(&renderCfg, commandLine);
78 if (commandLine.getSurfaceType() != tcu::SURFACETYPE_WINDOW)
79 throw tcu::NotSupportedError("Test not supported in non-windowed context");
81 RenderContext* noErrorContext = createRenderContext(m_testCtx.getPlatform(), commandLine, renderCfg);
82 bool contextCreated = (noErrorContext != NULL);
83 delete noErrorContext;
85 return contextCreated;
88 /** Executes test iteration.
90 * @return Returns STOP when test has finished executing, CONTINUE if more iterations are needed.
92 tcu::TestNode::IterateResult NoErrorContextTest::iterate(void)
95 glu::ContextType contextType(m_ApiType);
96 deqp::Context context(m_testCtx, contextType);
98 bool noErrorExtensionExists = glu::contextSupports(contextType, glu::ApiType::core(4, 6));
99 noErrorExtensionExists |= context.getContextInfo().isExtensionSupported("GL_KHR_no_error");
101 if (!noErrorExtensionExists)
103 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "GL_KHR_no_error extension not supported");
106 } // at this point intermediate context used to query the GL_KHR_no_error extension should be destroyed
108 if (verifyNoErrorContext())
110 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
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");
121 * @param context Rendering context.
123 NoErrorTests::NoErrorTests(tcu::TestContext& testCtx, glu::ApiType apiType)
124 : tcu::TestCaseGroup(testCtx, "no_error", "Verify conformance of GL_KHR_no_error implementation")
129 /** Initializes the test group contents. */
130 void NoErrorTests::init(void)
132 addChild(new NoErrorContextTest(m_testCtx, m_ApiType));
134 } /* glcts namespace */