• 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  esextcTextureBorderClampParameterBorderColorError.Cpp
26  * \brief Texture Border Clamp Border Color Error (Test 1)
27  */ /*-------------------------------------------------------------------*/
28 
29 #include "esextcTextureBorderClampParameterBorderColorError.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 
37 namespace glcts
38 {
39 
40 /* Texture unit number */
41 const glw::GLuint TextureBorderClampParameterBorderColorErrorTest::m_texture_unit = 0;
42 
43 /** Constructor
44  *
45  *  @param context       Test context
46  *  @param name          Test case's name
47  *  @param description   Test case's description
48  **/
TextureBorderClampParameterBorderColorErrorTest(Context & context,const ExtParameters & extParams,const char * name,const char * description)49 TextureBorderClampParameterBorderColorErrorTest::TextureBorderClampParameterBorderColorErrorTest(
50 	Context& context, const ExtParameters& extParams, const char* name, const char* description)
51 	: TextureBorderClampBase(context, extParams, name, description), m_sampler_id(0), m_test_passed(true)
52 {
53 	/* Left blank on purpose */
54 }
55 
56 /** Deinitializes GLES objects created during the test.
57  *
58  */
deinit(void)59 void TextureBorderClampParameterBorderColorErrorTest::deinit(void)
60 {
61 	/* Retrieve ES entry-points */
62 	const glw::Functions& gl = m_context.getRenderContext().getFunctions();
63 
64 	/* Release sampler object */
65 	gl.bindSampler(m_texture_unit, 0);
66 
67 	if (0 != m_sampler_id)
68 	{
69 		gl.deleteSamplers(1, &m_sampler_id);
70 
71 		m_sampler_id = 0;
72 	}
73 
74 	/* Deinitializes base class */
75 	TextureBorderClampBase::deinit();
76 }
77 
78 /** Initializes GLES objects used during the test.
79  *
80  */
initTest(void)81 void TextureBorderClampParameterBorderColorErrorTest::initTest(void)
82 {
83 	if (!m_is_texture_border_clamp_supported)
84 	{
85 		throw tcu::NotSupportedError(TEXTURE_BORDER_CLAMP_NOT_SUPPORTED, "", __FILE__, __LINE__);
86 	}
87 
88 	/* Initialize base class implementation */
89 	TextureBorderClampBase::initTest();
90 
91 	const glw::Functions& gl = m_context.getRenderContext().getFunctions();
92 
93 	/* Generate a sampler object */
94 	gl.genSamplers(1, &m_sampler_id);
95 	GLU_EXPECT_NO_ERROR(gl.getError(), "Error generating a sampler object");
96 
97 	/* Bind a sampler object to the texture unit we will use for the test*/
98 	gl.bindSampler(m_texture_unit, m_sampler_id);
99 	GLU_EXPECT_NO_ERROR(gl.getError(), "Error binding a sampler object to texture unit");
100 }
101 
102 /** Executes the test.
103  *
104  *  Sets the test result to QP_TEST_RESULT_FAIL if the test failed, QP_TEST_RESULT_PASS otherwise.
105  *
106  *  Note the function throws exception should an error occur!
107  *
108  *  @return STOP if the test has finished, CONTINUE to indicate iterate should be called once again.
109  **/
iterate(void)110 tcu::TestNode::IterateResult TextureBorderClampParameterBorderColorErrorTest::iterate(void)
111 {
112 	/* Initialize all ES objects necessary to run the test */
113 	initTest();
114 
115 	for (unsigned int i = 0; i < m_texture_target_list.size(); ++i)
116 	{
117 		/* Check if function glTexParameterf works properly for all the texture targets supported
118 		 * in ES3.1.
119 		 */
120 		VerifyGLTexParameterf(m_texture_target_list[i], GL_TEXTURE_BASE_LEVEL, 0.0f, /* param */
121 							  GL_NO_ERROR /* expected_error */);
122 
123 		/* Make sure that the functions report GL_INVALID_ENUM if
124 		 * any of them attempts to modify GL_TEXTURE_BORDER_COLOR_EXT
125 		 * parameter.
126 		 */
127 		VerifyGLTexParameterf(m_texture_target_list[i], m_glExtTokens.TEXTURE_BORDER_COLOR, 0.0f, /* param */
128 							  GL_INVALID_ENUM /* expected_error */);
129 
130 		/* Check that glTexParameteri() accepts all ES3.1 texture targets */
131 		VerifyGLTexParameteri(m_texture_target_list[i], GL_TEXTURE_BASE_LEVEL, 0, /* param */
132 							  GL_NO_ERROR /* expected_error */);
133 
134 		/* Check that glTexParameteri() reports GL_INVALID_ENUM if used for
135 		 * GL_TEXTURE_BORDER_COLOR_EXT pname */
136 		VerifyGLTexParameteri(m_texture_target_list[i], m_glExtTokens.TEXTURE_BORDER_COLOR, 0, /* param */
137 							  GL_INVALID_ENUM /* expected_error */);
138 	}
139 
140 	/* Check that glSamplerParameter{f,i} functions correctly handle
141 	 * GL_TEXTURE_MIN_FILTER pname.
142 	 **/
143 	VerifyGLSamplerParameterf(GL_TEXTURE_MIN_FILTER, GL_NEAREST, /* param */
144 							  GL_NO_ERROR /* expected_error */);
145 
146 	VerifyGLSamplerParameteri(GL_TEXTURE_MIN_FILTER, GL_NEAREST, /* param */
147 							  GL_NO_ERROR /* expected_error */);
148 
149 	/* Make sure that glSamplerParameter*() functions report GL_INVALID_ENUM
150 	 * if called with GL_TEXTURE_BORDER_COLOR_EXT pname
151 	 */
152 	VerifyGLSamplerParameterf(m_glExtTokens.TEXTURE_BORDER_COLOR, 0.0f, /* param */
153 							  GL_INVALID_ENUM /* expected_error */);
154 
155 	VerifyGLSamplerParameteri(m_glExtTokens.TEXTURE_BORDER_COLOR, 0, /* param */
156 							  GL_INVALID_ENUM /* expected_error */);
157 
158 	if (m_test_passed)
159 	{
160 		m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
161 	}
162 	else
163 	{
164 		m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
165 	}
166 
167 	return STOP;
168 }
169 
170 /** Check if calling glTexParameterf() with user-provided set of arguments causes
171  *  a specified GL error.
172  *
173  *  Should the error codes differ, m_test_passed will be set to false.
174  *
175  * @param target         texture target to use for the call;
176  * @param pname          property name to use for the call;
177  * @param param          property value to use for the call;
178  * @param expected_error expected error code.
179  */
VerifyGLTexParameterf(glw::GLenum target,glw::GLenum pname,glw::GLfloat param,glw::GLenum expected_error)180 void TextureBorderClampParameterBorderColorErrorTest::VerifyGLTexParameterf(glw::GLenum target, glw::GLenum pname,
181 																			glw::GLfloat param,
182 																			glw::GLenum  expected_error)
183 {
184 	glw::GLenum			  error_code = GL_NO_ERROR;
185 	const glw::Functions& gl		 = m_context.getRenderContext().getFunctions();
186 
187 	gl.texParameterf(target, pname, param);
188 
189 	error_code = gl.getError();
190 	if (expected_error != error_code)
191 	{
192 		m_test_passed = false;
193 		m_testCtx.getLog() << tcu::TestLog::Message << "glTexParameterf() failed:["
194 						   << "target:" << getTexTargetString(target) << ", pname:" << getPNameString(pname)
195 						   << "] reported error code:[" << glu::getErrorStr(error_code) << "] expected error code:["
196 						   << glu::getErrorStr(expected_error) << "]\n"
197 						   << tcu::TestLog::EndMessage;
198 	}
199 }
200 
201 /** Check if calling glTexParameteri() with user-provided set of arguments causes
202  *  a specified GL error.
203  *
204  *  Should the error codes differ, m_test_passed will be set to false.
205  *
206  * @param target         texture target to use for the call;
207  * @param pname          property name to use for the call;
208  * @param param          property value to use for the call;
209  * @param expected_error expected error code.
210  */
VerifyGLTexParameteri(glw::GLenum target,glw::GLenum pname,glw::GLint param,glw::GLenum expected_error)211 void TextureBorderClampParameterBorderColorErrorTest::VerifyGLTexParameteri(glw::GLenum target, glw::GLenum pname,
212 																			glw::GLint  param,
213 																			glw::GLenum expected_error)
214 {
215 	glw::GLenum			  error_code = GL_NO_ERROR;
216 	const glw::Functions& gl		 = m_context.getRenderContext().getFunctions();
217 
218 	gl.texParameteri(target, pname, param);
219 
220 	error_code = gl.getError();
221 	if (expected_error != error_code)
222 	{
223 		m_test_passed = false;
224 
225 		m_testCtx.getLog() << tcu::TestLog::Message << "glTexParameteri() failed:["
226 						   << "target:" << getTexTargetString(target) << ", pname:" << getPNameString(pname)
227 						   << "] reported error code:[" << glu::getErrorStr(error_code) << "] expected error code:["
228 						   << glu::getErrorStr(expected_error) << "]\n"
229 						   << tcu::TestLog::EndMessage;
230 	}
231 }
232 
233 /** Check if calling glSamplerParameterf() with user-provided set of arguments causes
234  *  a specified GL error.
235  *
236  *  Should the error codes differ, m_test_passed will be set to false.
237  *
238  * @param pname          property name to use for the call;
239  * @param param          property value to use for the call;
240  * @param expected_error expected error code.
241  */
VerifyGLSamplerParameterf(glw::GLenum pname,glw::GLfloat param,glw::GLenum expected_error)242 void TextureBorderClampParameterBorderColorErrorTest::VerifyGLSamplerParameterf(glw::GLenum pname, glw::GLfloat param,
243 																				glw::GLenum expected_error)
244 {
245 	glw::GLenum			  error_code = GL_NO_ERROR;
246 	const glw::Functions& gl		 = m_context.getRenderContext().getFunctions();
247 
248 	gl.samplerParameterf(m_sampler_id, pname, param);
249 
250 	error_code = gl.getError();
251 	if (expected_error != error_code)
252 	{
253 		m_test_passed = false;
254 
255 		m_testCtx.getLog() << tcu::TestLog::Message << "glSamplerParameterf() failed:["
256 						   << ", pname:" << getPNameString(pname) << "] reported error code:["
257 						   << glu::getErrorStr(error_code) << "] expected error code:["
258 						   << glu::getErrorStr(expected_error) << "]\n"
259 						   << tcu::TestLog::EndMessage;
260 	}
261 }
262 
263 /** Check if calling glSamplerParameteri() with user-provided set of arguments causes
264  *  a specified GL error.
265  *
266  *  Should the error codes differ, m_test_passed will be set to false.
267  *
268  * @param pname          property name to use for the call;
269  * @param param          property value to use for the call;
270  * @param expected_error expected error code.
271  */
VerifyGLSamplerParameteri(glw::GLenum pname,glw::GLint param,glw::GLenum expected_error)272 void TextureBorderClampParameterBorderColorErrorTest::VerifyGLSamplerParameteri(glw::GLenum pname, glw::GLint param,
273 																				glw::GLenum expected_error)
274 {
275 	glw::GLenum			  error_code = GL_NO_ERROR;
276 	const glw::Functions& gl		 = m_context.getRenderContext().getFunctions();
277 
278 	gl.samplerParameteri(m_sampler_id, pname, param);
279 
280 	error_code = gl.getError();
281 	if (expected_error != error_code)
282 	{
283 		m_test_passed = false;
284 
285 		m_testCtx.getLog() << tcu::TestLog::Message << "glSamplerParameteri() failed:["
286 						   << ", pname:" << getPNameString(pname) << "] reported error code:["
287 						   << glu::getErrorStr(error_code) << "] expected error code:["
288 						   << glu::getErrorStr(expected_error) << "]\n"
289 						   << tcu::TestLog::EndMessage;
290 	}
291 }
292 
293 } // namespace glcts
294