• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-------------------------------------------------------------------------
2  * OpenGL Conformance Test Suite
3  * -----------------------------
4  *
5  * Copyright (c) 2014-2016 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  * \file esextcTextureBorderClampGetTexParameterIErrors.cpp
26  * \brief Texture Border Clamp glGetTexParameterIivEXT(), glGetTexParameterIuivEXT() Errors (Test 3)
27  */ /*-------------------------------------------------------------------*/
28 
29 #include "esextcTextureBorderClampGetTexParameterIErrors.hpp"
30 #include "gluContextInfo.hpp"
31 #include "gluDefs.hpp"
32 #include "gluStrUtil.hpp"
33 #include "glwEnums.hpp"
34 #include "glwFunctions.hpp"
35 #include "tcuTestLog.hpp"
36 #include <vector>
37 
38 namespace glcts
39 {
40 
41 /* Amount of entries to pre-allocate for vectors which will be used by
42  * glGetTexParameterIivEXT() and glGetTexParameterIuivEXT() functions.
43  */
44 const glw::GLuint TextureBorderClampGetTexParameterIErrorsTest::m_buffer_size = 32;
45 
46 /** Constructor
47  *
48  *  @param context     Test context
49  *  @param name        Test case's name
50  *  @param description Test case's description
51  **/
TextureBorderClampGetTexParameterIErrorsTest(Context & context,const ExtParameters & extParams,const char * name,const char * description)52 TextureBorderClampGetTexParameterIErrorsTest::TextureBorderClampGetTexParameterIErrorsTest(
53 	Context& context, const ExtParameters& extParams, const char* name, const char* description)
54 	: TextureBorderClampBase(context, extParams, name, description), m_test_passed(true)
55 {
56 	/* Left blank on purpose */
57 }
58 
59 /** Initializes GLES objects used during the test.  */
initTest(void)60 void TextureBorderClampGetTexParameterIErrorsTest::initTest(void)
61 {
62 	if (!m_is_texture_border_clamp_supported)
63 	{
64 		throw tcu::NotSupportedError(TEXTURE_BORDER_CLAMP_NOT_SUPPORTED, "", __FILE__, __LINE__);
65 	}
66 
67 	/* Initialize base class */
68 	TextureBorderClampBase::initTest();
69 
70 	m_pname_list.push_back(GL_DEPTH_STENCIL_TEXTURE_MODE);
71 	m_pname_list.push_back(GL_TEXTURE_BASE_LEVEL);
72 	m_pname_list.push_back(m_glExtTokens.TEXTURE_BORDER_COLOR);
73 	m_pname_list.push_back(GL_TEXTURE_COMPARE_FUNC);
74 	m_pname_list.push_back(GL_TEXTURE_IMMUTABLE_FORMAT);
75 	m_pname_list.push_back(GL_TEXTURE_IMMUTABLE_LEVELS);
76 	m_pname_list.push_back(GL_TEXTURE_MAG_FILTER);
77 	m_pname_list.push_back(GL_TEXTURE_MAX_LEVEL);
78 	m_pname_list.push_back(GL_TEXTURE_MAX_LOD);
79 	m_pname_list.push_back(GL_TEXTURE_MIN_FILTER);
80 	m_pname_list.push_back(GL_TEXTURE_MIN_LOD);
81 	m_pname_list.push_back(GL_TEXTURE_SWIZZLE_R);
82 	m_pname_list.push_back(GL_TEXTURE_SWIZZLE_G);
83 	m_pname_list.push_back(GL_TEXTURE_SWIZZLE_B);
84 	m_pname_list.push_back(GL_TEXTURE_SWIZZLE_A);
85 	m_pname_list.push_back(GL_TEXTURE_WRAP_S);
86 	m_pname_list.push_back(GL_TEXTURE_WRAP_T);
87 	m_pname_list.push_back(GL_TEXTURE_WRAP_R);
88 }
89 
90 /** Executes the test.
91  *
92  *  Sets the test result to QP_TEST_RESULT_FAIL if the test failed, QP_TEST_RESULT_PASS otherwise.
93  *
94  *  Note the function throws exception should an error occur!
95  *
96  *  @return STOP if the test has finished, CONTINUE to indicate iterate should be called once again.
97  **/
iterate(void)98 tcu::TestNode::IterateResult TextureBorderClampGetTexParameterIErrorsTest::iterate(void)
99 {
100 	initTest();
101 
102 	/* Make sure the tested functions report GL_NO_ERROR if used with
103 	 * cube map texture target. */
104 	CheckAllNames(GL_TEXTURE_CUBE_MAP, GL_NO_ERROR);
105 
106 	/* Make sure the tested functions report GL_INVALID_ENUM error
107 	 * if used for cube-map face texture targets. */
108 	CheckAllNames(GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_INVALID_ENUM);
109 
110 	if (m_is_texture_buffer_supported)
111 	{
112 		/* Make sure the tested functions report GL_INVALID_ENUM error
113 		 * if used for GL_TEXTURE_BUFFER_EXT texture target. */
114 		CheckAllNames(GL_TEXTURE_BUFFER_EXT, GL_INVALID_ENUM);
115 	}
116 
117 	if (m_test_passed)
118 	{
119 		m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
120 	}
121 	else
122 	{
123 		m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
124 	}
125 
126 	return STOP;
127 }
128 
129 /**
130  * Verifies that all pnames are correctly handled by glGetTexParameterIivEXT() and
131  * glGetTexParameterIuivEXT() functions for a particular texture target.
132  *
133  * @param target          texture target to be used for the calls;
134  * @param expected_error  GL error code to expect;
135  */
CheckAllNames(glw::GLenum target,glw::GLenum expected_error)136 void TextureBorderClampGetTexParameterIErrorsTest::CheckAllNames(glw::GLenum target, glw::GLenum expected_error)
137 {
138 	for (glw::GLuint i = 0; i < m_pname_list.size(); ++i)
139 	{
140 		/* Check glGetTexParameterIivEXT() */
141 		VerifyGLGetTexParameterIiv(target, m_pname_list[i] /* pname*/, expected_error);
142 		/* Check glGetTexParameterIuivEXT() */
143 		VerifyGLGetTexParameterIuiv(target, m_pname_list[i] /* pname*/, expected_error);
144 	}
145 }
146 
147 /** Verifies that calling glGetTexParameterIivEXT() with user-specified arguments
148  *  generates user-defined error code.
149  *
150  * @param target         texture target to be used for the call;
151  * @param pname          pname to be used for the call;
152  * @param expected_error anticipated GL error code;
153  */
VerifyGLGetTexParameterIiv(glw::GLenum target,glw::GLenum pname,glw::GLenum expected_error)154 void TextureBorderClampGetTexParameterIErrorsTest::VerifyGLGetTexParameterIiv(glw::GLenum target, glw::GLenum pname,
155 																			  glw::GLenum expected_error)
156 {
157 	glw::GLenum				error_code = GL_NO_ERROR;
158 	const glw::Functions&   gl		   = m_context.getRenderContext().getFunctions();
159 	std::vector<glw::GLint> params(m_buffer_size);
160 
161 	gl.getTexParameterIiv(target, pname, &params[0]);
162 
163 	error_code = gl.getError();
164 	if (expected_error != error_code)
165 	{
166 		m_test_passed = false;
167 
168 		m_testCtx.getLog() << tcu::TestLog::Message << "glGetTexParameterIivEXT() failed:["
169 						   << "target:" << getTexTargetString(target) << ", pname:" << getPNameString(pname)
170 						   << "] reported error code:[" << glu::getErrorStr(error_code) << "] expected error code:["
171 						   << glu::getErrorStr(expected_error) << "]\n"
172 						   << tcu::TestLog::EndMessage;
173 	}
174 }
175 
176 /** Verifies that calling glGetTexParameterIuivEXT() with user-specified arguments
177  *  generates user-defined error code.
178  *
179  * @param target         texture target to be used for the call;
180  * @param pname          pname to be used for the call;
181  * @param expected_error anticipated GL error code;
182  */
VerifyGLGetTexParameterIuiv(glw::GLenum target,glw::GLenum pname,glw::GLenum expected_error)183 void TextureBorderClampGetTexParameterIErrorsTest::VerifyGLGetTexParameterIuiv(glw::GLenum target, glw::GLenum pname,
184 																			   glw::GLenum expected_error)
185 {
186 	glw::GLenum				 error_code = GL_NO_ERROR;
187 	const glw::Functions&	gl			= m_context.getRenderContext().getFunctions();
188 	std::vector<glw::GLuint> params(m_buffer_size);
189 
190 	gl.getTexParameterIuiv(target, pname, &params[0]);
191 
192 	error_code = gl.getError();
193 	if (expected_error != error_code)
194 	{
195 		m_test_passed = false;
196 
197 		m_testCtx.getLog() << tcu::TestLog::Message << "glGetTexParameterIuivEXT() failed:["
198 						   << "target:" << getTexTargetString(target) << ", pname:" << getPNameString(pname)
199 						   << "] reported error code:[" << glu::getErrorStr(error_code) << "] expected error code:["
200 						   << glu::getErrorStr(expected_error) << "]\n"
201 						   << tcu::TestLog::EndMessage;
202 	}
203 }
204 
205 } // namespace glcts
206