• 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  esextcTextureBorderClampSamplerParameterIWithWrongPname.hpp
26  * \brief Verifies glGetSamplerParameterI*() and glSamplerParameterI*()
27  *        entry-points generate GL_INVALID_ENUM error if invalid pnames
28  *        are used. (Test 5)
29  */ /*-------------------------------------------------------------------*/
30 
31 #include "esextcTextureBorderClampSamplerParameterIWithWrongPname.hpp"
32 #include "esextcTextureBorderClampBase.hpp"
33 #include "gluContextInfo.hpp"
34 #include "gluDefs.hpp"
35 #include "gluStrUtil.hpp"
36 #include "glwEnums.hpp"
37 #include "glwFunctions.hpp"
38 #include "tcuTestLog.hpp"
39 
40 namespace glcts
41 {
42 
43 /* Static constants */
44 const glw::GLuint TextureBorderClampSamplerParameterIWithWrongPnameTest::m_buffer_size		  = 32;
45 const glw::GLuint TextureBorderClampSamplerParameterIWithWrongPnameTest::m_texture_unit_index = 0;
46 
47 /** Constructor
48  *
49  *  @param context     Test context
50  *  @param name        Test case's name
51  *  @param description Test case's description
52  **/
TextureBorderClampSamplerParameterIWithWrongPnameTest(Context & context,const ExtParameters & extParams,const char * name,const char * description)53 TextureBorderClampSamplerParameterIWithWrongPnameTest::TextureBorderClampSamplerParameterIWithWrongPnameTest(
54 	Context& context, const ExtParameters& extParams, const char* name, const char* description)
55 	: TextureBorderClampBase(context, extParams, name, description), m_sampler_id(0), m_test_passed(true)
56 {
57 	/* No implementation needed */
58 }
59 
60 /** Deinitializes GLES objects created during the test.
61  *
62  */
deinit(void)63 void TextureBorderClampSamplerParameterIWithWrongPnameTest::deinit(void)
64 {
65 	/* Retrieve ES entry-points */
66 	const glw::Functions& gl = m_context.getRenderContext().getFunctions();
67 
68 	/* Bind the default sampler object */
69 	gl.bindSampler(m_texture_unit_index, 0);
70 
71 	/* Delete a sampler object, if one was created during test execution */
72 	if (0 != m_sampler_id)
73 	{
74 		gl.deleteSamplers(1, &m_sampler_id);
75 
76 		m_sampler_id = 0;
77 	}
78 
79 	/* Deinitialize base class instance */
80 	TestCaseBase::deinit();
81 }
82 
83 /** Initializes GLES objects used during the test.
84  *
85  */
initTest(void)86 void TextureBorderClampSamplerParameterIWithWrongPnameTest::initTest(void)
87 {
88 	/* Check if EXT_texture_border_clamp is supported */
89 	if (!m_is_texture_border_clamp_supported)
90 	{
91 		throw tcu::NotSupportedError(TEXTURE_BORDER_CLAMP_NOT_SUPPORTED, "", __FILE__, __LINE__);
92 	}
93 
94 	/* Retrieve ES entry-points */
95 	const glw::Functions& gl = m_context.getRenderContext().getFunctions();
96 
97 	/* Generate a sampler object */
98 	gl.genSamplers(1, &m_sampler_id);
99 	GLU_EXPECT_NO_ERROR(gl.getError(), "Error generating sampler object");
100 
101 	/* Bind the sampler object to a texture unit */
102 	gl.bindSampler(m_texture_unit_index, m_sampler_id);
103 	GLU_EXPECT_NO_ERROR(gl.getError(), "Error binding sampler object");
104 
105 	/* Store all enums that should generate GL_INVALID_ENUM error when used
106 	 * as parameter names for glGetSamplerParameterI*() and glSamplerParameterI*()
107 	 * calls.
108 	 */
109 	m_pnames_list.push_back(GL_TEXTURE_BASE_LEVEL);
110 	m_pnames_list.push_back(GL_TEXTURE_IMMUTABLE_FORMAT);
111 	m_pnames_list.push_back(GL_TEXTURE_MAX_LEVEL);
112 	m_pnames_list.push_back(GL_TEXTURE_SWIZZLE_R);
113 	m_pnames_list.push_back(GL_TEXTURE_SWIZZLE_G);
114 	m_pnames_list.push_back(GL_TEXTURE_SWIZZLE_B);
115 	m_pnames_list.push_back(GL_TEXTURE_SWIZZLE_A);
116 }
117 
118 /** Executes the test.
119  *
120  *  Sets the test result to QP_TEST_RESULT_FAIL if the test failed, QP_TEST_RESULT_PASS otherwise.
121  *
122  *  Note the function throws exception should an error occur!
123  *
124  *  @return STOP if the test has finished, CONTINUE to indicate iterate should be called once again.
125  **/
iterate(void)126 tcu::TestNode::IterateResult TextureBorderClampSamplerParameterIWithWrongPnameTest::iterate(void)
127 {
128 	initTest();
129 
130 	for (glw::GLuint i = 0; i < m_pnames_list.size(); ++i)
131 	{
132 		/* Check glGetSamplerParameterIivEXT() */
133 		VerifyGLGetSamplerParameterIiv(m_sampler_id, m_pnames_list[i], GL_INVALID_ENUM);
134 
135 		/* Check glGetSamplerParameterIuivEXT() */
136 		VerifyGLGetSamplerParameterIuiv(m_sampler_id, m_pnames_list[i], GL_INVALID_ENUM);
137 
138 		/* Check glSamplerParameterIivEXT() */
139 		VerifyGLSamplerParameterIiv(m_sampler_id, m_pnames_list[i], GL_INVALID_ENUM);
140 
141 		/* Check glSamplerParameterIuivEXT() */
142 		VerifyGLSamplerParameterIuiv(m_sampler_id, m_pnames_list[i], GL_INVALID_ENUM);
143 	} /* for (all pnames) */
144 
145 	if (m_test_passed)
146 	{
147 		m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
148 	}
149 	else
150 	{
151 		m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
152 	}
153 
154 	return STOP;
155 }
156 
157 /**
158  * Checks if glGetSamplerParameterIivEXT() reports an user-specified GL error, if
159  * called with specific arguments.
160  *
161  * Should the check fail, the function will set m_test_passed to false.
162  *
163  * @param sampler_id     id of sampler object to use for the call;
164  * @param pname          pname to use for the call;
165  * @param expected_error expected GL error code.
166  */
VerifyGLGetSamplerParameterIiv(glw::GLuint sampler_id,glw::GLenum pname,glw::GLenum expected_error)167 void TextureBorderClampSamplerParameterIWithWrongPnameTest::VerifyGLGetSamplerParameterIiv(glw::GLuint sampler_id,
168 																						   glw::GLenum pname,
169 																						   glw::GLenum expected_error)
170 {
171 	glw::GLenum				error_code = GL_NO_ERROR;
172 	const glw::Functions&   gl		   = m_context.getRenderContext().getFunctions();
173 	std::vector<glw::GLint> params(m_buffer_size);
174 
175 	gl.getSamplerParameterIiv(sampler_id, pname, &params[0]);
176 
177 	error_code = gl.getError();
178 	if (expected_error != error_code)
179 	{
180 		m_test_passed = false;
181 
182 		m_testCtx.getLog() << tcu::TestLog::Message << "glGetSamplerParameterIivEXT() failed:["
183 						   << "sampler id:" << sampler_id << ", pname:" << getPNameString(pname)
184 						   << "] reported error code:[" << glu::getErrorStr(error_code) << "] expected error code:["
185 						   << glu::getErrorStr(expected_error) << "]\n"
186 						   << tcu::TestLog::EndMessage;
187 	}
188 }
189 
190 /**
191  * Checks if glGetSamplerParameterIuivEXT() reports an user-specified GL error, if
192  * called with specific arguments.
193  *
194  * Should the check fail, the function will set m_test_passed to false.
195  *
196  * @param sampler_id     id of sampler object to use for the call;
197  * @param pname          pname to use for the call;
198  * @param expected_error expected GL error code.
199  */
VerifyGLGetSamplerParameterIuiv(glw::GLuint sampler_id,glw::GLenum pname,glw::GLenum expected_error)200 void TextureBorderClampSamplerParameterIWithWrongPnameTest::VerifyGLGetSamplerParameterIuiv(glw::GLuint sampler_id,
201 																							glw::GLenum pname,
202 																							glw::GLenum expected_error)
203 {
204 	glw::GLenum				 error_code = GL_NO_ERROR;
205 	const glw::Functions&	gl			= m_context.getRenderContext().getFunctions();
206 	std::vector<glw::GLuint> params(m_buffer_size);
207 
208 	gl.getSamplerParameterIuiv(sampler_id, pname, &params[0]);
209 
210 	error_code = gl.getError();
211 	if (expected_error != error_code)
212 	{
213 		m_test_passed = false;
214 
215 		m_testCtx.getLog() << tcu::TestLog::Message << "glGetSamplerParameterIuivEXT() failed:["
216 						   << "sampler id:" << sampler_id << ", pname:" << getPNameString(pname)
217 						   << "] reported error code:[" << glu::getErrorStr(error_code) << "] expected error code:["
218 						   << glu::getErrorStr(expected_error) << "]\n"
219 						   << tcu::TestLog::EndMessage;
220 	}
221 }
222 
223 /**
224  * Checks if glSamplerParameterIivEXT() reports an user-specified GL error, if
225  * called with specific arguments.
226  *
227  * Should the check fail, the function will set m_test_passed to false.
228  *
229  * @param sampler_id     id of sampler object to use for the call;
230  * @param pname          pname argument value to use for the call;
231  * @param expected_error expected GL error code.
232  */
VerifyGLSamplerParameterIiv(glw::GLuint sampler_id,glw::GLenum pname,glw::GLenum expected_error)233 void TextureBorderClampSamplerParameterIWithWrongPnameTest::VerifyGLSamplerParameterIiv(glw::GLuint sampler_id,
234 																						glw::GLenum pname,
235 																						glw::GLenum expected_error)
236 {
237 	glw::GLenum				error_code = GL_NO_ERROR;
238 	const glw::Functions&   gl		   = m_context.getRenderContext().getFunctions();
239 	std::vector<glw::GLint> params(m_buffer_size);
240 
241 	gl.samplerParameterIiv(sampler_id, pname, &params[0]);
242 
243 	error_code = gl.getError();
244 	if (expected_error != error_code)
245 	{
246 		m_test_passed = false;
247 
248 		m_testCtx.getLog() << tcu::TestLog::Message << "glSamplerParameterIivEXT() failed:["
249 						   << "sampler id:" << sampler_id << ", pname:" << getPNameString(pname)
250 						   << "] reported error code:[" << glu::getErrorStr(error_code) << "] expected error code:["
251 						   << glu::getErrorStr(expected_error) << "]\n"
252 						   << tcu::TestLog::EndMessage;
253 	}
254 }
255 
256 /**
257  * Checks if glSamplerParameterIuivEXT() reports an user-specified GL error, if
258  * called with specific arguments.
259  *
260  * Should the check fail, the function will set m_test_passed to false.
261  *
262  * @param sampler_id     id of sampler object to use for the call;
263  * @param pname          pname argument value to use for the call;
264  * @param expected_error expected GL error code.
265  **/
VerifyGLSamplerParameterIuiv(glw::GLuint sampler_id,glw::GLenum pname,glw::GLenum expected_error)266 void TextureBorderClampSamplerParameterIWithWrongPnameTest::VerifyGLSamplerParameterIuiv(glw::GLuint sampler_id,
267 																						 glw::GLenum pname,
268 																						 glw::GLenum expected_error)
269 {
270 	glw::GLenum				 error_code = GL_NO_ERROR;
271 	const glw::Functions&	gl			= m_context.getRenderContext().getFunctions();
272 	std::vector<glw::GLuint> params(m_buffer_size);
273 
274 	gl.samplerParameterIuiv(sampler_id, pname, &params[0]);
275 
276 	error_code = gl.getError();
277 	if (expected_error != error_code)
278 	{
279 		m_test_passed = false;
280 
281 		m_testCtx.getLog() << tcu::TestLog::Message << "glSamplerParameterIuivEXT() failed:["
282 						   << "sampler id:" << sampler_id << ", pname:" << getPNameString(pname)
283 						   << "] reported error code:[" << glu::getErrorStr(error_code) << "] expected error code:["
284 						   << glu::getErrorStr(expected_error) << "]\n"
285 						   << tcu::TestLog::EndMessage;
286 	}
287 }
288 
289 } // namespace glcts
290