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 esextcTextureBorderClampSamplerParameterIError.cpp
26 * \brief Verifies glGetSamplerParameterI*() and glSamplerParameterI*()
27 * entry-points generate errors for non-generated sampler objects
28 * as per extension specification. (Test 4)
29 */ /*-------------------------------------------------------------------*/
30
31 #include "esextcTextureBorderClampSamplerParameterIError.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 /* Static constants */
43 const glw::GLuint TextureBorderClampSamplerParameterIErrorTest::m_buffer_size = 32;
44 const glw::GLuint TextureBorderClampSamplerParameterIErrorTest::m_texture_unit_index = 0;
45
46 /** Constructor
47 *
48 * @param context Test context
49 * @param name Test case's name
50 * @param description Test case's description
51 **/
TextureBorderClampSamplerParameterIErrorTest(Context & context,const ExtParameters & extParams,const char * name,const char * description)52 TextureBorderClampSamplerParameterIErrorTest::TextureBorderClampSamplerParameterIErrorTest(
53 Context& context, const ExtParameters& extParams, const char* name, const char* description)
54 : TextureBorderClampBase(context, extParams, name, description), m_sampler_id(0), m_test_passed(true)
55 {
56 /* No implementation needed */
57 }
58
59 /** Deinitializes GLES objects created during the test.
60 *
61 */
deinit(void)62 void TextureBorderClampSamplerParameterIErrorTest::deinit(void)
63 {
64 /* Retrieve ES entry-points */
65 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
66
67 /* Bind the default sampler object */
68 gl.bindSampler(m_texture_unit_index, 0);
69
70 /* Delete a sampler object, if one was created during test execution */
71 if (0 != m_sampler_id)
72 {
73 gl.deleteSamplers(1, &m_sampler_id);
74
75 m_sampler_id = 0;
76 }
77
78 /* Deinitialize base class instance */
79 TestCaseBase::deinit();
80 }
81
82 /** Initializes GLES objects used during the test. */
initTest(void)83 void TextureBorderClampSamplerParameterIErrorTest::initTest(void)
84 {
85 if (!m_is_texture_border_clamp_supported)
86 {
87 throw tcu::NotSupportedError(TEXTURE_BORDER_CLAMP_NOT_SUPPORTED, "", __FILE__, __LINE__);
88 }
89
90 /* Retrieve ES entry-points */
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 sampler object");
96
97 /* Bind the sampler object to a texture unit */
98 gl.bindSampler(m_texture_unit_index, m_sampler_id);
99 GLU_EXPECT_NO_ERROR(gl.getError(), "Error binding sampler object");
100
101 /* Fill list with property name + property value pairs that should
102 * be used to verify that glGetSamplerParameterI*() and glSamplerParameterI*()
103 * entry-points generate errors for non-generated sampler objects
104 * as per extension specification.
105 */
106 m_pnames_list.push_back(PnameParams(GL_TEXTURE_MAG_FILTER, GL_LINEAR));
107 m_pnames_list.push_back(PnameParams(GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR));
108 m_pnames_list.push_back(PnameParams(GL_TEXTURE_MIN_LOD, 1));
109 m_pnames_list.push_back(PnameParams(GL_TEXTURE_MAX_LOD, 1));
110 m_pnames_list.push_back(PnameParams(GL_TEXTURE_WRAP_S, GL_REPEAT));
111 m_pnames_list.push_back(PnameParams(GL_TEXTURE_WRAP_T, GL_REPEAT));
112 m_pnames_list.push_back(PnameParams(GL_TEXTURE_WRAP_R, GL_REPEAT));
113 m_pnames_list.push_back(PnameParams(m_glExtTokens.TEXTURE_BORDER_COLOR, 0, 0, 0, 0));
114 m_pnames_list.push_back(PnameParams(GL_TEXTURE_COMPARE_MODE, GL_NONE));
115 m_pnames_list.push_back(PnameParams(GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL));
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 TextureBorderClampSamplerParameterIErrorTest::iterate(void)
127 {
128 initTest();
129
130 /* Verify glGetSamplerParameterIivEXT() and glGetSamplerParameterIuivEXT(),
131 * report GL_NO_ERROR if called for a generated sampler object*/
132 VerifyGLGetCallsForAllPNames(m_sampler_id, GL_NO_ERROR);
133
134 /* Verify glGetSamplerParameterIivEXT() and glGetSamplerParameterIuivEXT(),
135 * report GL_INVALID_OPERATION if called for a non-existent sampler object*/
136 VerifyGLGetCallsForAllPNames(m_sampler_id + 1, GL_INVALID_OPERATION);
137
138 /* Verify glSamplerParameterIivEXT() and glSamplerParameterIuivEXT(),
139 * report GL_NO_ERROR if called for a generated sampler object*/
140 VerifyGLSamplerCallsForAllPNames(m_sampler_id, GL_NO_ERROR);
141
142 /* Verify glSamplerParameterIivEXT() and glSamplerParameterIuivEXT(),
143 * report GL_INVALID_OPERATION if called for a non-existent sampler object*/
144 VerifyGLSamplerCallsForAllPNames(m_sampler_id + 2, GL_INVALID_OPERATION);
145
146 if (m_test_passed)
147 {
148 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
149 }
150 else
151 {
152 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
153 }
154
155 return STOP;
156 }
157
158 /**
159 * Checks if glGetSamplerParameterIivEXT() reports an user-specified GL error, if
160 * called with specific arguments.
161 *
162 * Should the check fail, the function will set m_test_passed to false.
163 *
164 * @param sampler_id id of sampler object to use for the call;
165 * @param pname pname to use for the call;
166 * @param expected_error expected GL error code.
167 */
VerifyGLGetSamplerParameterIiv(glw::GLuint sampler_id,glw::GLenum pname,glw::GLenum expected_error)168 void TextureBorderClampSamplerParameterIErrorTest::VerifyGLGetSamplerParameterIiv(glw::GLuint sampler_id,
169 glw::GLenum pname,
170 glw::GLenum expected_error)
171 {
172 glw::GLenum error_code = GL_NO_ERROR;
173 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
174 std::vector<glw::GLint> params(m_buffer_size);
175
176 gl.getSamplerParameterIiv(sampler_id, pname, ¶ms[0]);
177
178 error_code = gl.getError();
179 if (expected_error != error_code)
180 {
181 m_test_passed = false;
182
183 m_testCtx.getLog() << tcu::TestLog::Message << "glGetSamplerParameterIivEXT() failed:["
184 << "sampler id:" << sampler_id << ", pname:" << getPNameString(pname)
185 << "] reported error code:[" << glu::getErrorStr(error_code) << "] expected error code:["
186 << glu::getErrorStr(expected_error) << "]\n"
187 << tcu::TestLog::EndMessage;
188 }
189 }
190
191 /**
192 * Checks if glGetSamplerParameterIuivEXT() reports an user-specified GL error, if
193 * called with specific arguments.
194 *
195 * Should the check fail, the function will set m_test_passed to false.
196 *
197 * @param sampler_id id of sampler object to use for the call;
198 * @param pname pname to use for the call;
199 * @param expected_error expected GL error code.
200 */
VerifyGLGetSamplerParameterIuiv(glw::GLuint sampler_id,glw::GLenum pname,glw::GLenum expected_error)201 void TextureBorderClampSamplerParameterIErrorTest::VerifyGLGetSamplerParameterIuiv(glw::GLuint sampler_id,
202 glw::GLenum pname,
203 glw::GLenum expected_error)
204 {
205 glw::GLenum error_code = GL_NO_ERROR;
206 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
207 std::vector<glw::GLuint> params(m_buffer_size);
208
209 gl.getSamplerParameterIuiv(sampler_id, pname, ¶ms[0]);
210
211 error_code = gl.getError();
212 if (expected_error != error_code)
213 {
214 m_test_passed = false;
215
216 m_testCtx.getLog() << tcu::TestLog::Message << "glGetSamplerParameterIuivEXT() failed:["
217 << "sampler id:" << sampler_id << ", pname:" << getPNameString(pname)
218 << "] reported error code:[" << glu::getErrorStr(error_code) << "] expected error code:["
219 << glu::getErrorStr(expected_error) << "]\n"
220 << tcu::TestLog::EndMessage;
221 }
222 }
223
224 /** Verifies all pnames stored in m_pnames_list generate an user-specified error when used with
225 * paired value for glGetSamplerParameterIivEXT() and glGetSamplerParameterIuivEXT() functions.
226 *
227 * @param sampler_id id of a sampler object to use for the calls;
228 * @param expected_error expected GL error code.
229 */
VerifyGLGetCallsForAllPNames(glw::GLuint sampler_id,glw::GLenum expected_error)230 void TextureBorderClampSamplerParameterIErrorTest::VerifyGLGetCallsForAllPNames(glw::GLuint sampler_id,
231 glw::GLenum expected_error)
232 {
233 for (glw::GLuint i = 0; i < m_pnames_list.size(); ++i)
234 {
235 /* Check glGetSamplerParameterIivEXT() */
236 VerifyGLGetSamplerParameterIiv(sampler_id, m_pnames_list[i].pname, expected_error);
237
238 /* Check glGetSamplerParameterIuivEXT() */
239 VerifyGLGetSamplerParameterIuiv(sampler_id, m_pnames_list[i].pname, expected_error);
240 } /* for (all pname+value pairs) */
241 }
242
243 /**
244 * Checks if glSamplerParameterIivEXT() reports an user-specified GL error, if
245 * called with specific arguments.
246 *
247 * Should the check fail, the function will set m_test_passed to false.
248 *
249 * @param sampler_id id of sampler object to use for the call;
250 * @param pname pname argument value to use for the call;
251 * @param params params argument value to use for the call;
252 * @param expected_error expected GL error code.
253 */
VerifyGLSamplerParameterIiv(glw::GLuint sampler_id,glw::GLenum pname,glw::GLint * params,glw::GLenum expected_error)254 void TextureBorderClampSamplerParameterIErrorTest::VerifyGLSamplerParameterIiv(glw::GLuint sampler_id,
255 glw::GLenum pname, glw::GLint* params,
256 glw::GLenum expected_error)
257 {
258 glw::GLenum error_code = GL_NO_ERROR;
259 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
260
261 gl.samplerParameterIiv(sampler_id, pname, params);
262
263 error_code = gl.getError();
264 if (expected_error != error_code)
265 {
266 m_test_passed = false;
267
268 m_testCtx.getLog() << tcu::TestLog::Message << "glSamplerParameterIivEXT() failed:["
269 << "sampler id:" << sampler_id << ", pname:" << getPNameString(pname)
270 << "] reported error code:[" << glu::getErrorStr(error_code) << "] expected error code:["
271 << glu::getErrorStr(expected_error) << "]\n"
272 << tcu::TestLog::EndMessage;
273 }
274 }
275
276 /**
277 * Checks if glSamplerParameterIuivEXT() reports an user-specified GL error, if
278 * called with specific arguments.
279 *
280 * Should the check fail, the function will set m_test_passed to false.
281 *
282 * @param sampler_id id of sampler object to use for the call;
283 * @param pname pname argument value to use for the call;
284 * @param params params argument value to use for the call;
285 * @param expected_error expected GL error code.
286 **/
VerifyGLSamplerParameterIuiv(glw::GLuint sampler_id,glw::GLenum pname,glw::GLuint * params,glw::GLenum expected_error)287 void TextureBorderClampSamplerParameterIErrorTest::VerifyGLSamplerParameterIuiv(glw::GLuint sampler_id,
288 glw::GLenum pname, glw::GLuint* params,
289 glw::GLenum expected_error)
290 {
291 glw::GLenum error_code = GL_NO_ERROR;
292 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
293
294 gl.samplerParameterIuiv(sampler_id, pname, params);
295
296 error_code = gl.getError();
297 if (expected_error != error_code)
298 {
299 m_test_passed = false;
300
301 m_testCtx.getLog() << tcu::TestLog::Message << "glSamplerParameterIuivEXT() failed:["
302 << "sampler id:" << sampler_id << ", pname:" << getPNameString(pname)
303 << "] reported error code:[" << glu::getErrorStr(error_code) << "] expected error code:["
304 << glu::getErrorStr(expected_error) << "]\n"
305 << tcu::TestLog::EndMessage;
306 }
307 }
308
309 /** Verifies all pnames stored in m_pnames_list generate an user-specified error when used with
310 * paired value for glSamplerParameterIivEXT() and glSamplerParameterIuivEXT() functions.
311 *
312 * @param sampler_id id of a sampler object to use for the calls;
313 * @param expected_error expected GL error code.
314 */
VerifyGLSamplerCallsForAllPNames(glw::GLuint sampler_id,glw::GLenum expected_error)315 void TextureBorderClampSamplerParameterIErrorTest::VerifyGLSamplerCallsForAllPNames(glw::GLuint sampler_id,
316 glw::GLenum expected_error)
317 {
318 for (glw::GLuint i = 0; i < m_pnames_list.size(); ++i)
319 {
320 /* Check glSamplerParameterIivEXT() */
321 VerifyGLSamplerParameterIiv(sampler_id, m_pnames_list[i].pname, (glw::GLint*)m_pnames_list[i].params,
322 expected_error);
323 /* Check glSamplerParameterIuivEXT() */
324 VerifyGLSamplerParameterIuiv(sampler_id, m_pnames_list[i].pname, (glw::GLuint*)m_pnames_list[i].params,
325 expected_error);
326 } /* for (all pname+value pairs) */
327 }
328
329 } // namespace glcts
330