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 esextcTextureCubeMapArrayGetterCalls.cpp
26 * \brief Texture Cube Map Array Getter Calls (Test 6)
27 */ /*-------------------------------------------------------------------*/
28
29 #include "esextcTextureCubeMapArrayGetterCalls.hpp"
30 #include "gluContextInfo.hpp"
31 #include "gluDefs.hpp"
32 #include "glwEnums.hpp"
33 #include "glwFunctions.hpp"
34 #include "tcuTestLog.hpp"
35 #include <string.h>
36
37 namespace glcts
38 {
39
40 /* Properties of a cube-map array texture used by the test */
41 const glw::GLuint TextureCubeMapArrayGetterCalls::m_depth = 6;
42 const glw::GLsizei TextureCubeMapArrayGetterCalls::m_height = 64;
43 const glw::GLsizei TextureCubeMapArrayGetterCalls::m_width = 64;
44 const glw::GLuint TextureCubeMapArrayGetterCalls::m_n_components = 4;
45
46 /* Name strings for GetTexParameter*() pnames */
getStringForGetTexParameterPname(glw::GLenum pname)47 const char *TextureCubeMapArrayGetterCalls::getStringForGetTexParameterPname(glw::GLenum pname)
48 {
49 if (pname == GL_TEXTURE_BASE_LEVEL)
50 return "GL_TEXTURE_BASE_LEVEL";
51 if (pname == GL_TEXTURE_MAX_LEVEL)
52 return "GL_TEXTURE_MAX_LEVEL";
53 if (pname == GL_TEXTURE_MIN_FILTER)
54 return "GL_TEXTURE_MIN_FILTER";
55 if (pname == GL_TEXTURE_MAG_FILTER)
56 return "GL_TEXTURE_MAG_FILTER";
57 if (pname == GL_TEXTURE_MIN_LOD)
58 return "GL_TEXTURE_MIN_LOD";
59 if (pname == GL_TEXTURE_MAX_LOD)
60 return "GL_TEXTURE_MAX_LOD";
61 if (pname == GL_TEXTURE_SWIZZLE_R)
62 return "GL_TEXTURE_SWIZZLE_R";
63 if (pname == GL_TEXTURE_SWIZZLE_G)
64 return "GL_TEXTURE_SWIZZLE_G";
65 if (pname == GL_TEXTURE_SWIZZLE_B)
66 return "GL_TEXTURE_SWIZZLE_B";
67 if (pname == GL_TEXTURE_SWIZZLE_A)
68 return "GL_TEXTURE_SWIZZLE_A";
69 if (pname == GL_TEXTURE_WRAP_S)
70 return "GL_TEXTURE_WRAP_S";
71 if (pname == GL_TEXTURE_WRAP_T)
72 return "GL_TEXTURE_WRAP_T";
73 if (pname == GL_TEXTURE_WRAP_R)
74 return "GL_TEXTURE_WRAP_R";
75
76 return "UNKNOWN PARAMETER NAME";
77 }
78
79 /* Name strings for GetTexLevelParameter*() pnames */
getStringForGetTexLevelParameterPname(glw::GLenum pname)80 const char *TextureCubeMapArrayGetterCalls::getStringForGetTexLevelParameterPname(glw::GLenum pname)
81 {
82 if (pname == GL_TEXTURE_COMPRESSED)
83 return "GL_TEXTURE_COMPRESSED";
84 if (pname == GL_TEXTURE_ALPHA_SIZE)
85 return "GL_TEXTURE_ALPHA_SIZE";
86 if (pname == GL_TEXTURE_BLUE_SIZE)
87 return "GL_TEXTURE_BLUE_SIZE";
88 if (pname == GL_TEXTURE_GREEN_SIZE)
89 return "GL_TEXTURE_GREEN_SIZE";
90 if (pname == GL_TEXTURE_RED_SIZE)
91 return "GL_TEXTURE_RED_SIZE";
92 if (pname == GL_TEXTURE_DEPTH_SIZE)
93 return "GL_TEXTURE_DEPTH_SIZE";
94 if (pname == GL_TEXTURE_SHARED_SIZE)
95 return "GL_TEXTURE_SHARED_SIZE";
96 if (pname == GL_TEXTURE_STENCIL_SIZE)
97 return "GL_TEXTURE_STENCIL_SIZE";
98 if (pname == GL_TEXTURE_ALPHA_TYPE)
99 return "GL_TEXTURE_ALPHA_TYPE";
100 if (pname == GL_TEXTURE_BLUE_TYPE)
101 return "GL_TEXTURE_BLUE_TYPE";
102 if (pname == GL_TEXTURE_GREEN_TYPE)
103 return "GL_TEXTURE_GREEN_TYPE";
104 if (pname == GL_TEXTURE_RED_TYPE)
105 return "GL_TEXTURE_RED_TYPE";
106 if (pname == GL_TEXTURE_DEPTH_TYPE)
107 return "GL_TEXTURE_DEPTH_TYPE";
108 if (pname == GL_TEXTURE_INTERNAL_FORMAT)
109 return "GL_TEXTURE_INTERNAL_FORMAT";
110 if (pname == GL_TEXTURE_WIDTH)
111 return "GL_TEXTURE_WIDTH";
112 if (pname == GL_TEXTURE_HEIGHT)
113 return "GL_TEXTURE_HEIGHT";
114 if (pname == GL_TEXTURE_DEPTH)
115 return "GL_TEXTURE_DEPTH";
116
117 return "UNKNOWN PARAMETER NAME";
118 }
119
120 /** Constructor
121 *
122 * @param context Test context
123 * @param name Test case's name
124 * @param description Test case's description
125 **/
TextureCubeMapArrayGetterCalls(Context & context,const ExtParameters & extParams,const char * name,const char * description)126 TextureCubeMapArrayGetterCalls::TextureCubeMapArrayGetterCalls(Context &context, const ExtParameters &extParams,
127 const char *name, const char *description)
128 : TestCaseBase(context, extParams, name, description)
129 , m_to_id(0)
130 , m_test_passed(true)
131 , m_expected_alpha_size(0)
132 , m_expected_alpha_type(0)
133 , m_expected_blue_size(0)
134 , m_expected_blue_type(0)
135 , m_expected_compressed(0)
136 , m_expected_depth_size(0)
137 , m_expected_depth_type(0)
138 , m_expected_green_size(0)
139 , m_expected_green_type(0)
140 , m_expected_red_size(0)
141 , m_expected_red_type(0)
142 , m_expected_shared_size(0)
143 , m_expected_stencil_size(0)
144 , m_expected_texture_internal_format(0)
145 {
146 /* Nothing to be done here */
147 }
148
149 /** Deinitializes GLES objects created during the test.
150 *
151 */
deinit(void)152 void TextureCubeMapArrayGetterCalls::deinit(void)
153 {
154 /* Retrieve ES entry points */
155 const glw::Functions &gl = m_context.getRenderContext().getFunctions();
156
157 /* Reset ES state */
158 gl.bindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, 0);
159
160 /* Release any objects that may have been created during test execution */
161 if (m_to_id != 0)
162 {
163 gl.deleteTextures(1, &m_to_id);
164
165 m_to_id = 0;
166 }
167
168 /* Deinitialize base class */
169 TestCaseBase::deinit();
170 }
171
172 /** Initializes GLES objects used during the test.
173 *
174 */
initTest(void)175 void TextureCubeMapArrayGetterCalls::initTest(void)
176 {
177 /* Only execute if GL_EXT_texture_cube_map_array extension is supported */
178 if (!m_is_texture_cube_map_array_supported)
179 {
180 throw tcu::NotSupportedError(TEXTURE_CUBE_MAP_ARRAY_EXTENSION_NOT_SUPPORTED);
181 }
182
183 pnames_for_gettexparameter_default[GL_TEXTURE_BASE_LEVEL] = 0;
184 pnames_for_gettexparameter_default[GL_TEXTURE_MAX_LEVEL] = 1000;
185 pnames_for_gettexparameter_default[GL_TEXTURE_MIN_FILTER] = GL_NEAREST_MIPMAP_LINEAR;
186 pnames_for_gettexparameter_default[GL_TEXTURE_MAG_FILTER] = GL_LINEAR;
187 pnames_for_gettexparameter_default[GL_TEXTURE_MIN_LOD] = -1000;
188 pnames_for_gettexparameter_default[GL_TEXTURE_MAX_LOD] = 1000;
189 pnames_for_gettexparameter_default[GL_TEXTURE_SWIZZLE_R] = GL_RED;
190 pnames_for_gettexparameter_default[GL_TEXTURE_SWIZZLE_G] = GL_GREEN;
191 pnames_for_gettexparameter_default[GL_TEXTURE_SWIZZLE_B] = GL_BLUE;
192 pnames_for_gettexparameter_default[GL_TEXTURE_SWIZZLE_A] = GL_ALPHA;
193 pnames_for_gettexparameter_default[GL_TEXTURE_WRAP_S] = GL_REPEAT;
194 pnames_for_gettexparameter_default[GL_TEXTURE_WRAP_T] = GL_REPEAT;
195 pnames_for_gettexparameter_default[GL_TEXTURE_WRAP_R] = GL_REPEAT;
196
197 pnames_for_gettexparameter_modified[GL_TEXTURE_BASE_LEVEL] = 1;
198 pnames_for_gettexparameter_modified[GL_TEXTURE_MAX_LEVEL] = 1;
199 pnames_for_gettexparameter_modified[GL_TEXTURE_MIN_FILTER] = GL_NEAREST;
200 pnames_for_gettexparameter_modified[GL_TEXTURE_MAG_FILTER] = GL_NEAREST;
201 pnames_for_gettexparameter_modified[GL_TEXTURE_MIN_LOD] = -10;
202 pnames_for_gettexparameter_modified[GL_TEXTURE_MAX_LOD] = 10;
203 pnames_for_gettexparameter_modified[GL_TEXTURE_SWIZZLE_R] = GL_GREEN;
204 pnames_for_gettexparameter_modified[GL_TEXTURE_SWIZZLE_G] = GL_BLUE;
205 pnames_for_gettexparameter_modified[GL_TEXTURE_SWIZZLE_B] = GL_ALPHA;
206 pnames_for_gettexparameter_modified[GL_TEXTURE_SWIZZLE_A] = GL_RED;
207 pnames_for_gettexparameter_modified[GL_TEXTURE_WRAP_S] = GL_CLAMP_TO_EDGE;
208 pnames_for_gettexparameter_modified[GL_TEXTURE_WRAP_T] = GL_MIRRORED_REPEAT;
209 pnames_for_gettexparameter_modified[GL_TEXTURE_WRAP_R] = GL_CLAMP_TO_EDGE;
210
211 pnames_for_gettexlevelparameter.push_back(GL_TEXTURE_COMPRESSED);
212 pnames_for_gettexlevelparameter.push_back(GL_TEXTURE_ALPHA_SIZE);
213 pnames_for_gettexlevelparameter.push_back(GL_TEXTURE_BLUE_SIZE);
214 pnames_for_gettexlevelparameter.push_back(GL_TEXTURE_GREEN_SIZE);
215 pnames_for_gettexlevelparameter.push_back(GL_TEXTURE_RED_SIZE);
216 pnames_for_gettexlevelparameter.push_back(GL_TEXTURE_DEPTH_SIZE);
217 pnames_for_gettexlevelparameter.push_back(GL_TEXTURE_SHARED_SIZE);
218 pnames_for_gettexlevelparameter.push_back(GL_TEXTURE_STENCIL_SIZE);
219 pnames_for_gettexlevelparameter.push_back(GL_TEXTURE_ALPHA_TYPE);
220 pnames_for_gettexlevelparameter.push_back(GL_TEXTURE_BLUE_TYPE);
221 pnames_for_gettexlevelparameter.push_back(GL_TEXTURE_GREEN_TYPE);
222 pnames_for_gettexlevelparameter.push_back(GL_TEXTURE_RED_TYPE);
223 pnames_for_gettexlevelparameter.push_back(GL_TEXTURE_DEPTH_TYPE);
224 pnames_for_gettexlevelparameter.push_back(GL_TEXTURE_INTERNAL_FORMAT);
225 pnames_for_gettexlevelparameter.push_back(GL_TEXTURE_WIDTH);
226 pnames_for_gettexlevelparameter.push_back(GL_TEXTURE_HEIGHT);
227 pnames_for_gettexlevelparameter.push_back(GL_TEXTURE_DEPTH);
228 }
229
230 /** Executes the test.
231 *
232 * Sets the test result to QP_TEST_RESULT_FAIL if the test failed, QP_TEST_RESULT_PASS otherwise.
233 *
234 * Note the function throws exception should an error occur!
235 *
236 * @return STOP if the test has finished, CONTINUE to indicate iterate should be called once again.
237 **/
iterate(void)238 tcu::TestNode::IterateResult TextureCubeMapArrayGetterCalls::iterate(void)
239 {
240 initTest();
241
242 /* Retrieve ES entry points */
243 const glw::Functions &gl = m_context.getRenderContext().getFunctions();
244
245 /* Generate a texture object */
246 gl.genTextures(1, &m_to_id);
247 GLU_EXPECT_NO_ERROR(gl.getError(), "Could not generate a texture object!");
248
249 /* Bind the texture object to GL_TEXTURE_CUBE_MAP_ARRAY_EXT texture target */
250 gl.bindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, m_to_id);
251 GLU_EXPECT_NO_ERROR(gl.getError(), "Could not bind a texture object!");
252
253 glw::GLubyte texture_data_ubyte[m_width * m_height * m_depth * m_n_components];
254 memset(texture_data_ubyte, 0, m_width * m_height * m_depth * m_n_components * sizeof(glw::GLubyte));
255
256 /* Set up mutable texture storage */
257 gl.texImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, /* target */
258 0, /* level */
259 GL_RGBA8, /* internal format */
260 m_width, /* width */
261 m_height, /* height */
262 m_depth, /* depth */
263 0, /* border */
264 GL_RGBA, /* format */
265 GL_UNSIGNED_BYTE, /* type */
266 texture_data_ubyte); /* texel data */
267 GLU_EXPECT_NO_ERROR(gl.getError(), "Could not create mutable texture storage!");
268
269 gl.texImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, /* target */
270 1, /* level */
271 GL_RGBA8, /* internal format */
272 m_width, /* width */
273 m_height, /* height */
274 m_depth, /* depth */
275 0, /* border */
276 GL_RGBA, /* format */
277 GL_UNSIGNED_BYTE, /* type */
278 texture_data_ubyte); /* texel data */
279 GLU_EXPECT_NO_ERROR(gl.getError(), "Could not create mutable texture storage!");
280
281 /* Configure expected values for all properties we will be checking */
282 m_expected_compressed = GL_FALSE;
283 m_expected_alpha_size = 8;
284 m_expected_alpha_type = GL_UNSIGNED_NORMALIZED;
285 m_expected_blue_size = 8;
286 m_expected_blue_type = GL_UNSIGNED_NORMALIZED;
287 m_expected_green_size = 8;
288 m_expected_green_type = GL_UNSIGNED_NORMALIZED;
289 m_expected_red_size = 8;
290 m_expected_red_type = GL_UNSIGNED_NORMALIZED;
291 m_expected_depth_size = 0;
292 m_expected_depth_type = GL_NONE;
293 m_expected_shared_size = 0;
294 m_expected_stencil_size = 0;
295 m_expected_texture_internal_format = GL_RGBA8;
296
297 /* Verify the texture bindings have been updated */
298 verifyTextureBindings();
299
300 /* Verify texture parameter values reported by glGetTexParameter*() functions are valid. */
301 PNamesMap::iterator pnames_iter = pnames_for_gettexparameter_default.begin();
302 PNamesMap::iterator pnames_end = pnames_for_gettexparameter_default.end();
303 for (; pnames_iter != pnames_end; ++pnames_iter)
304 {
305 verifyGetTexParameter(pnames_iter->first, pnames_iter->second);
306 }
307
308 pnames_iter = pnames_for_gettexparameter_modified.begin();
309 pnames_end = pnames_for_gettexparameter_modified.end();
310 for (; pnames_iter != pnames_end; ++pnames_iter)
311 {
312 /* Set property value(s) using glGetTexParameteriv() */
313 gl.texParameteriv(GL_TEXTURE_CUBE_MAP_ARRAY, pnames_iter->first, &pnames_iter->second);
314
315 if (gl.getError() != GL_NO_ERROR)
316 {
317 m_testCtx.getLog() << tcu::TestLog::Message << "glTexParameteriv() call failed for pname: "
318 << getStringForGetTexParameterPname(pnames_iter->first)
319 << " and value: " << pnames_iter->second << tcu::TestLog::EndMessage;
320
321 TCU_FAIL("glTexParameteriv() call failed");
322 }
323
324 verifyGetTexParameter(pnames_iter->first, pnames_iter->second);
325 }
326
327 /* Verify texture level parameter values reported by glGetTexLevelParameter*()
328 * functions are valid. */
329 verifyGetTexLevelParameters();
330
331 /* Delete a texture object */
332 gl.deleteTextures(1, &m_to_id);
333 m_to_id = 0;
334
335 /* Generate a texture object */
336 gl.genTextures(1, &m_to_id);
337 GLU_EXPECT_NO_ERROR(gl.getError(), "Could not generate a texture object!");
338
339 /* Bind the texture object to GL_TEXTURE_CUBE_MAP_ARRAY_EXT texture target */
340 gl.bindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, m_to_id);
341 GLU_EXPECT_NO_ERROR(gl.getError(), "Could not bind a texture object!");
342
343 /* Set up immutable texture storage */
344 gl.texStorage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 2, /* levels */
345 GL_RGBA32F, /* internal format */
346 m_width, /* width */
347 m_height, /* height */
348 m_depth); /* depth */
349 GLU_EXPECT_NO_ERROR(gl.getError(), "Could not create an immutable texture storage!");
350
351 /* Update expected values for all the properties we will be checking */
352 m_expected_compressed = GL_FALSE;
353 m_expected_alpha_size = 32;
354 m_expected_alpha_type = GL_FLOAT;
355 m_expected_blue_size = 32;
356 m_expected_blue_type = GL_FLOAT;
357 m_expected_green_size = 32;
358 m_expected_green_type = GL_FLOAT;
359 m_expected_red_size = 32;
360 m_expected_red_type = GL_FLOAT;
361 m_expected_depth_size = 0;
362 m_expected_depth_type = GL_NONE;
363 m_expected_shared_size = 0;
364 m_expected_stencil_size = 0;
365 m_expected_texture_internal_format = GL_RGBA32F;
366
367 /* Verify that texture bindings have been updated */
368 verifyTextureBindings();
369
370 /* Verify texture parameter values reported by glGetTexParameter*() functions are valid. */
371 pnames_iter = pnames_for_gettexparameter_default.begin();
372 pnames_end = pnames_for_gettexparameter_default.end();
373 for (; pnames_iter != pnames_end; ++pnames_iter)
374 {
375 verifyGetTexParameter(pnames_iter->first, pnames_iter->second);
376 }
377
378 pnames_iter = pnames_for_gettexparameter_modified.begin();
379 pnames_end = pnames_for_gettexparameter_modified.end();
380 for (; pnames_iter != pnames_end; ++pnames_iter)
381 {
382 /* Set property value(s) using glGetTexParameteriv() */
383 gl.texParameteriv(GL_TEXTURE_CUBE_MAP_ARRAY, pnames_iter->first, &pnames_iter->second);
384
385 if (gl.getError() != GL_NO_ERROR)
386 {
387 m_testCtx.getLog() << tcu::TestLog::Message << "glTexParameteriv() call failed for pname: "
388 << getStringForGetTexParameterPname(pnames_iter->first)
389 << " and value: " << pnames_iter->second << tcu::TestLog::EndMessage;
390
391 TCU_FAIL("glTexParameteriv() call failed");
392 }
393
394 verifyGetTexParameter(pnames_iter->first, pnames_iter->second);
395 }
396
397 /* Verify texture level parameter values reported by glGetTexLevelParameter*()
398 * functions are valid. */
399 verifyGetTexLevelParameters();
400
401 if (m_test_passed)
402 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
403 else
404 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
405
406 return STOP;
407 }
408
409 /** Verifies GL_TEXTURE_CUBE_MAP_ARRAY_EXT texture binding is reported
410 * correctly by glGetBooleanv(), glGetFloatv() and glGetIntegerv().
411 *
412 * It is assumed that texture object of id m_to_id is bound to
413 * GL_TEXTURE_CUBE_MAP_ARRAY_EXT texture binding point at the time
414 * of the call.
415 *
416 **/
verifyTextureBindings(void)417 void TextureCubeMapArrayGetterCalls::verifyTextureBindings(void)
418 {
419 const glw::Functions &gl = m_context.getRenderContext().getFunctions();
420 glw::GLboolean bool_value = GL_FALSE;
421 const float epsilon = 1e-5f;
422 glw::GLfloat float_value = 0.0f;
423 glw::GLint int_value = 0;
424
425 /* Check glGetBooleanv() reports a correct value */
426 gl.getBooleanv(GL_TEXTURE_BINDING_CUBE_MAP_ARRAY, &bool_value);
427 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetBooleanv() failed for GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_EXT pname");
428
429 if ((m_to_id == 0 && bool_value != GL_FALSE) || (m_to_id != 0 && bool_value != GL_TRUE))
430 {
431 m_testCtx.getLog()
432 << tcu::TestLog::Message
433 << "glGetBooleanv() reported an invalid value for GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_EXT pname"
434 << tcu::TestLog::EndMessage;
435 m_test_passed = false;
436 }
437
438 /* Check glGetFloatv() reports a correct value */
439 gl.getFloatv(GL_TEXTURE_BINDING_CUBE_MAP_ARRAY, &float_value);
440 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetFloatv() failed for GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_EXT pname");
441
442 if (de::abs(float_value - static_cast<float>(m_to_id)) > epsilon)
443 {
444 m_testCtx.getLog() << tcu::TestLog::Message
445 << "glGetFloatv() reported an invalid value for GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_EXT pname"
446 << tcu::TestLog::EndMessage;
447 m_test_passed = false;
448 }
449
450 /* Check glGetIntegerv() reports a correct value */
451 gl.getIntegerv(GL_TEXTURE_BINDING_CUBE_MAP_ARRAY, &int_value);
452 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv() failed for GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_EXT pname");
453
454 if (de::abs(float_value - static_cast<float>(m_to_id)) > epsilon)
455 {
456 m_testCtx.getLog()
457 << tcu::TestLog::Message
458 << "glGetIntegerv() reported an invalid value for GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_EXT pname"
459 << tcu::TestLog::EndMessage;
460 m_test_passed = false;
461 }
462 }
463
464 /** Verifies that all texture parameter values reported by corresponding
465 * getter functions are as defined for a texture object currently bound to
466 * GL_TEXTURE_CUBE_MAP_ARRAY_EXT binding point
467 **/
verifyGetTexParameter(glw::GLenum pname,glw::GLint expected_value)468 void TextureCubeMapArrayGetterCalls::verifyGetTexParameter(glw::GLenum pname, glw::GLint expected_value)
469 {
470 /* Retrieve ES function pointers */
471 const glw::Functions &gl = m_context.getRenderContext().getFunctions();
472
473 glw::GLint int_value = 0;
474
475 /* Retrieve property value(s) using glGetTexParameteriv() */
476 gl.getTexParameteriv(GL_TEXTURE_CUBE_MAP_ARRAY, pname, &int_value);
477
478 if (gl.getError() != GL_NO_ERROR)
479 {
480 m_testCtx.getLog() << tcu::TestLog::Message
481 << "glGetTexParameteriv() call failed for pname: " << getStringForGetTexParameterPname(pname)
482 << tcu::TestLog::EndMessage;
483
484 TCU_FAIL("glGetTexLevelParameteriv() call failed");
485 }
486
487 if (int_value != expected_value)
488 {
489 m_testCtx.getLog() << tcu::TestLog::Message
490 << "glGetTexParameteriv() called for pname: "
491 "["
492 << getStringForGetTexParameterPname(pname)
493 << "]"
494 " returned an invalid value of:"
495 "["
496 << int_value
497 << "]"
498 ", expected:"
499 "["
500 << expected_value << "]" << tcu::TestLog::EndMessage;
501
502 m_test_passed = false;
503 }
504 }
505
506 /** Verifies that all texture level parameter values reported by corresponding
507 * getter functions are as defined for a texture object currently bound to
508 * GL_TEXTURE_CUBE_MAP_ARRAY_EXT binding point
509 **/
verifyGetTexLevelParameters(void)510 void TextureCubeMapArrayGetterCalls::verifyGetTexLevelParameters(void)
511 {
512 /* Retrieve ES function pointers */
513 const glw::Functions &gl = m_context.getRenderContext().getFunctions();
514
515 glw::GLfloat float_value = 0.0f;
516 glw::GLint int_value = 0;
517 const glw::GLfloat epsilon = 1e-5f;
518
519 PNamesVec::iterator pnames_end = pnames_for_gettexlevelparameter.end();
520 for (PNamesVec::iterator pnames_iter = pnames_for_gettexlevelparameter.begin(); pnames_iter != pnames_end;
521 ++pnames_iter)
522 {
523 glw::GLenum pname = *pnames_iter;
524
525 /* Retrieve property value(s) using glGetTexLevelParameteriv() */
526 gl.getTexLevelParameteriv(GL_TEXTURE_CUBE_MAP_ARRAY, 0, /* level */
527 pname, &int_value);
528
529 if (gl.getError() != GL_NO_ERROR)
530 {
531 m_testCtx.getLog() << tcu::TestLog::Message << "glGetTexLevelParameteriv() call failed for pname: "
532 << getStringForGetTexLevelParameterPname(pname) << tcu::TestLog::EndMessage;
533
534 TCU_FAIL("glGetTexLevelParameteriv() call failed");
535 }
536
537 /* Retrieve property value(s) using glGetTexLevelParameterfv() */
538 gl.getTexLevelParameterfv(GL_TEXTURE_CUBE_MAP_ARRAY, 0, /* level */
539 pname, &float_value);
540
541 if (gl.getError() != GL_NO_ERROR)
542 {
543 m_testCtx.getLog() << tcu::TestLog::Message << "glGetTexLevelParameterfv() call failed for pname: "
544 << getStringForGetTexLevelParameterPname(pname) << tcu::TestLog::EndMessage;
545
546 TCU_FAIL("glGetTexLevelParameterfv() call failed");
547 }
548
549 /* Make sure the property values are valid */
550 glw::GLboolean should_use_equal_comparison = true;
551 glw::GLint expected_property_int_value = 0;
552
553 switch (pname)
554 {
555 case GL_TEXTURE_ALPHA_SIZE:
556 {
557 expected_property_int_value = m_expected_alpha_size;
558 should_use_equal_comparison = false;
559 break;
560 }
561
562 case GL_TEXTURE_ALPHA_TYPE:
563 {
564 expected_property_int_value = m_expected_alpha_type;
565 break;
566 }
567
568 case GL_TEXTURE_BLUE_SIZE:
569 {
570 expected_property_int_value = m_expected_blue_size;
571 should_use_equal_comparison = false;
572 break;
573 }
574
575 case GL_TEXTURE_BLUE_TYPE:
576 {
577 expected_property_int_value = m_expected_blue_type;
578 break;
579 }
580
581 case GL_TEXTURE_COMPRESSED:
582 {
583 expected_property_int_value = m_expected_compressed;
584 break;
585 }
586
587 case GL_TEXTURE_DEPTH:
588 {
589 expected_property_int_value = m_depth;
590 break;
591 }
592
593 case GL_TEXTURE_DEPTH_SIZE:
594 {
595 expected_property_int_value = m_expected_depth_size;
596 break;
597 }
598
599 case GL_TEXTURE_DEPTH_TYPE:
600 {
601 expected_property_int_value = m_expected_depth_type;
602 break;
603 }
604
605 case GL_TEXTURE_GREEN_SIZE:
606 {
607 expected_property_int_value = m_expected_green_size;
608 should_use_equal_comparison = false;
609 break;
610 }
611
612 case GL_TEXTURE_GREEN_TYPE:
613 {
614 expected_property_int_value = m_expected_green_type;
615 break;
616 }
617
618 case GL_TEXTURE_HEIGHT:
619 {
620 expected_property_int_value = m_height;
621 break;
622 }
623
624 case GL_TEXTURE_INTERNAL_FORMAT:
625 {
626 expected_property_int_value = m_expected_texture_internal_format;
627 break;
628 }
629
630 case GL_TEXTURE_RED_SIZE:
631 {
632 expected_property_int_value = m_expected_red_size;
633 should_use_equal_comparison = false;
634 break;
635 }
636
637 case GL_TEXTURE_RED_TYPE:
638 {
639 expected_property_int_value = m_expected_red_type;
640
641 break;
642 }
643
644 case GL_TEXTURE_SHARED_SIZE:
645 {
646 expected_property_int_value = m_expected_shared_size;
647 should_use_equal_comparison = false;
648 break;
649 }
650
651 case GL_TEXTURE_STENCIL_SIZE:
652 {
653 expected_property_int_value = m_expected_stencil_size;
654 break;
655 }
656
657 case GL_TEXTURE_WIDTH:
658 {
659 expected_property_int_value = m_width;
660 break;
661 }
662
663 default:
664 {
665 TCU_FAIL("Unrecognized pname");
666 }
667 } /* switch(pname) */
668
669 if ((should_use_equal_comparison && (expected_property_int_value != int_value)) ||
670 (!should_use_equal_comparison && (expected_property_int_value < int_value)))
671 {
672 m_testCtx.getLog() << tcu::TestLog::Message
673 << "glGetTexLevelParameteriv() called for pname: "
674 "["
675 << getStringForGetTexLevelParameterPname(pname)
676 << "]"
677 " returned an invalid value of:"
678 "["
679 << int_value
680 << "]"
681 ", expected:"
682 "["
683 << expected_property_int_value << "]" << tcu::TestLog::EndMessage;
684
685 m_test_passed = false;
686 }
687
688 glw::GLfloat expected_property_float_value = static_cast<glw::GLfloat>(expected_property_int_value);
689 if ((should_use_equal_comparison && (de::abs(float_value - (expected_property_float_value)) > epsilon)) ||
690 (!should_use_equal_comparison && (expected_property_float_value < float_value)))
691 {
692 m_testCtx.getLog() << tcu::TestLog::Message
693 << "glGetTexLevelParameterfv() called for pname: "
694 "["
695 << getStringForGetTexLevelParameterPname(pname)
696 << "]"
697 " returned an invalid value of:"
698 "["
699 << float_value
700 << "]"
701 ", expected:"
702 "["
703 << expected_property_float_value << "]" << tcu::TestLog::EndMessage;
704
705 m_test_passed = false;
706 }
707 } /* for (all property names) */
708 }
709
710 } // namespace glcts
711