es31cTextureStorageMultisampleGetTexLevelParameterifvTests.cpp revision 84322c9402f810da3cd80b52e9f9ef72150a9004
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 */ /*! 26 * \file es31cTextureStorageMultisampleGetTexLevelParameterifvTests.cpp 27 * \brief Verifies glGetTexLevelParameter(if)v() entry points work correctly. 28 * (ES3.1 only) 29 */ /*-------------------------------------------------------------------*/ 30 31#include "es31cTextureStorageMultisampleGetTexLevelParameterifvTests.hpp" 32#include "gluContextInfo.hpp" 33#include "gluDefs.hpp" 34#include "glwEnums.hpp" 35#include "glwFunctions.hpp" 36#include "tcuRenderTarget.hpp" 37#include "tcuTestLog.hpp" 38 39#include <algorithm> 40#include <map> 41#include <string> 42#include <vector> 43 44namespace glcts 45{ 46/** Constructor. 47 * 48 * @param context CTS context handle. 49 **/ 50MultisampleTextureGetTexLevelParametervFunctionalTest::MultisampleTextureGetTexLevelParametervFunctionalTest( 51 Context& context) 52 : TestCase(context, "functional_test", "Verifies glGetTexLevelParameter{if}v() entry-points " 53 "work correctly for all ES3.1 texture targets.") 54 , gl_oes_texture_storage_multisample_2d_array_supported(GL_FALSE) 55 , to_2d(0) 56 , to_2d_array(0) 57 , to_2d_multisample(0) 58 , to_2d_multisample_array(0) 59 , to_3d(0) 60 , to_cubemap(0) 61{ 62 /* Left blank on purpose */ 63} 64 65/** Deinitializes GL ES objects used by the test */ 66void MultisampleTextureGetTexLevelParametervFunctionalTest::deinit() 67{ 68 const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 69 70 if (to_2d != 0) 71 { 72 gl.deleteTextures(1, &to_2d); 73 74 to_2d = 0; 75 } 76 77 if (to_2d_array != 0) 78 { 79 gl.deleteTextures(1, &to_2d_array); 80 81 to_2d_array = 0; 82 } 83 84 if (to_2d_multisample != 0) 85 { 86 gl.deleteTextures(1, &to_2d_multisample); 87 88 to_2d_multisample = 0; 89 } 90 91 if (to_2d_multisample_array != 0) 92 { 93 gl.deleteTextures(1, &to_2d_multisample_array); 94 95 to_2d_multisample_array = 0; 96 } 97 98 if (to_3d != 0) 99 { 100 gl.deleteTextures(1, &to_3d); 101 102 to_3d = 0; 103 } 104 105 if (to_cubemap != 0) 106 { 107 gl.deleteTextures(1, &to_cubemap); 108 109 to_cubemap = 0; 110 } 111 112 /* Call base class' deinit() */ 113 TestCase::deinit(); 114} 115 116/** Executes test iteration. 117 * 118 * @return Returns STOP when test has finished executing. 119 */ 120tcu::TestNode::IterateResult MultisampleTextureGetTexLevelParametervFunctionalTest::iterate() 121{ 122 gl_oes_texture_storage_multisample_2d_array_supported = 123 m_context.getContextInfo().isExtensionSupported("GL_OES_texture_storage_multisample_2d_array"); 124 125 const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 126 127 /* Retrieve maximum number of sample supported by the implementation for GL_RGB565 internalformat 128 * used for GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES texture target. 129 */ 130 glw::GLint max_rgb565_internalformat_samples = 0; 131 132 if (gl_oes_texture_storage_multisample_2d_array_supported) 133 { 134 gl.getInternalformativ(GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES, GL_RGB565, GL_SAMPLES, 1, 135 &max_rgb565_internalformat_samples); 136 GLU_EXPECT_NO_ERROR(gl.getError(), 137 "Could not retrieve maximum supported amount of samples for RGB565 internalformat"); 138 } 139 140 /* Set up texture property descriptors. We'll use these later to set up texture objects 141 * in an automated manner. 142 */ 143 _texture_properties texture_2d_array_properties; 144 _texture_properties texture_2d_multisample_array_properties; 145 _texture_properties texture_2d_multisample_properties; 146 _texture_properties texture_2d_properties; 147 _texture_properties texture_3d_properties; 148 _texture_properties texture_cm_face_properties; 149 150 _texture_properties* texture_descriptors_with_extension[] = { &texture_2d_array_properties, 151 &texture_2d_multisample_array_properties, 152 &texture_2d_multisample_properties, 153 &texture_2d_properties, 154 &texture_3d_properties, 155 &texture_cm_face_properties }; 156 157 _texture_properties* texture_descriptors_without_extension[] = { &texture_2d_array_properties, 158 &texture_2d_multisample_properties, 159 &texture_2d_properties, &texture_3d_properties, 160 &texture_cm_face_properties }; 161 162 unsigned int n_texture_descriptors = 0; 163 _texture_properties** texture_descriptors = NULL; 164 165 if (gl_oes_texture_storage_multisample_2d_array_supported) 166 { 167 n_texture_descriptors = 168 sizeof(texture_descriptors_with_extension) / sizeof(texture_descriptors_with_extension[0]); 169 texture_descriptors = texture_descriptors_with_extension; 170 } 171 else 172 { 173 n_texture_descriptors = 174 sizeof(texture_descriptors_without_extension) / sizeof(texture_descriptors_without_extension[0]); 175 texture_descriptors = texture_descriptors_without_extension; 176 } 177 178 /* GL_TEXTURE_2D */ 179 texture_2d_properties.format = GL_DEPTH_STENCIL; 180 texture_2d_properties.height = 16; 181 texture_2d_properties.internalformat = GL_DEPTH24_STENCIL8; 182 texture_2d_properties.is_2d_texture = true; 183 texture_2d_properties.target = GL_TEXTURE_2D; 184 texture_2d_properties.to_id_ptr = &to_2d; 185 texture_2d_properties.type = GL_UNSIGNED_INT_24_8; 186 texture_2d_properties.width = 16; 187 188 texture_2d_properties.expected_compressed = GL_FALSE; 189 texture_2d_properties.expected_texture_alpha_size = 0; 190 texture_2d_properties.expected_texture_alpha_types.push_back(GL_NONE); 191 texture_2d_properties.expected_texture_blue_size = 0; 192 texture_2d_properties.expected_texture_blue_types.push_back(GL_NONE); 193 texture_2d_properties.expected_texture_depth = 1; 194 texture_2d_properties.expected_texture_depth_size = 24; 195 /* Return value is implementation-dependent. For current input values GL_UNSIGNED_INT and GL_UNSIGNED_NORMALIZED are valid */ 196 texture_2d_properties.expected_texture_depth_types.push_back(GL_UNSIGNED_INT); 197 texture_2d_properties.expected_texture_depth_types.push_back(GL_UNSIGNED_NORMALIZED); 198 texture_2d_properties.expected_texture_fixed_sample_locations = GL_TRUE; 199 texture_2d_properties.expected_texture_green_size = 0; 200 texture_2d_properties.expected_texture_green_types.push_back(GL_NONE); 201 texture_2d_properties.expected_texture_height = 16; 202 texture_2d_properties.expected_texture_internal_format = GL_DEPTH24_STENCIL8; 203 texture_2d_properties.expected_texture_red_size = 0; 204 texture_2d_properties.expected_texture_red_types.push_back(GL_NONE); 205 texture_2d_properties.expected_texture_samples = 0; 206 texture_2d_properties.expected_texture_shared_size = 0; 207 texture_2d_properties.expected_texture_stencil_size = 8; 208 texture_2d_properties.expected_texture_width = 16; 209 210 /* GL_TEXTURE_2D_ARRAY */ 211 texture_2d_array_properties.depth = 32; 212 texture_2d_array_properties.format = GL_RGBA; 213 texture_2d_array_properties.height = 32; 214 texture_2d_array_properties.internalformat = GL_RGBA8; 215 texture_2d_array_properties.is_2d_texture = false; 216 texture_2d_array_properties.target = GL_TEXTURE_2D_ARRAY; 217 texture_2d_array_properties.to_id_ptr = &to_2d_array; 218 texture_2d_array_properties.type = GL_UNSIGNED_BYTE; 219 texture_2d_array_properties.width = 32; 220 221 texture_2d_array_properties.expected_compressed = GL_FALSE; 222 texture_2d_array_properties.expected_texture_alpha_size = 8; 223 /* Return value is implementation-dependent. For current input values GL_UNSIGNED_INT and GL_UNSIGNED_NORMALIZED are valid */ 224 texture_2d_array_properties.expected_texture_alpha_types.push_back(GL_UNSIGNED_NORMALIZED); 225 texture_2d_array_properties.expected_texture_alpha_types.push_back(GL_UNSIGNED_INT); 226 texture_2d_array_properties.expected_texture_blue_size = 8; 227 /* Return value is implementation-dependent. For current input values GL_UNSIGNED_INT and GL_UNSIGNED_NORMALIZED are valid */ 228 texture_2d_array_properties.expected_texture_blue_types.push_back(GL_UNSIGNED_NORMALIZED); 229 texture_2d_array_properties.expected_texture_blue_types.push_back(GL_UNSIGNED_INT); 230 texture_2d_array_properties.expected_texture_depth = 32; 231 texture_2d_array_properties.expected_texture_depth_size = 0; 232 texture_2d_array_properties.expected_texture_depth_types.push_back(GL_NONE); 233 texture_2d_array_properties.expected_texture_fixed_sample_locations = GL_TRUE; 234 texture_2d_array_properties.expected_texture_green_size = 8; 235 /* Return value is implementation-dependent. For current input values GL_UNSIGNED_INT and GL_UNSIGNED_NORMALIZED are valid */ 236 texture_2d_array_properties.expected_texture_green_types.push_back(GL_UNSIGNED_NORMALIZED); 237 texture_2d_array_properties.expected_texture_green_types.push_back(GL_UNSIGNED_INT); 238 texture_2d_array_properties.expected_texture_height = 32; 239 texture_2d_array_properties.expected_texture_internal_format = GL_RGBA8; 240 texture_2d_array_properties.expected_texture_red_size = 8; 241 /* Return value is implementation-dependent. For current input values GL_UNSIGNED_INT and GL_UNSIGNED_NORMALIZED are valid */ 242 texture_2d_array_properties.expected_texture_red_types.push_back(GL_UNSIGNED_NORMALIZED); 243 texture_2d_array_properties.expected_texture_red_types.push_back(GL_UNSIGNED_INT); 244 texture_2d_array_properties.expected_texture_samples = 0; 245 texture_2d_array_properties.expected_texture_shared_size = 0; 246 texture_2d_array_properties.expected_texture_stencil_size = 0; 247 texture_2d_array_properties.expected_texture_width = 32; 248 249 /* GL_TEXTURE_2D_MULTISAMPLE */ 250 texture_2d_multisample_properties.fixedsamplelocations = GL_FALSE; 251 texture_2d_multisample_properties.format = GL_RGBA_INTEGER; 252 texture_2d_multisample_properties.height = 8; 253 texture_2d_multisample_properties.internalformat = GL_RGBA8UI; 254 texture_2d_multisample_properties.is_2d_texture = true; 255 texture_2d_multisample_properties.is_multisample_texture = true; 256 texture_2d_multisample_properties.samples = 1; 257 texture_2d_multisample_properties.target = GL_TEXTURE_2D_MULTISAMPLE; 258 texture_2d_multisample_properties.to_id_ptr = &to_2d_multisample; 259 texture_2d_multisample_properties.type = GL_UNSIGNED_INT; 260 texture_2d_multisample_properties.width = 8; 261 262 texture_2d_multisample_properties.expected_compressed = GL_FALSE; 263 texture_2d_multisample_properties.expected_texture_alpha_size = 8; 264 /* Return value is implementation-dependent. For current input values GL_UNSIGNED_INT and GL_UNSIGNED_NORMALIZED are valid */ 265 texture_2d_multisample_properties.expected_texture_alpha_types.push_back(GL_UNSIGNED_INT); 266 texture_2d_multisample_properties.expected_texture_alpha_types.push_back(GL_UNSIGNED_NORMALIZED); 267 texture_2d_multisample_properties.expected_texture_blue_size = 8; 268 /* Return value is implementation-dependent. For current input values GL_UNSIGNED_INT and GL_UNSIGNED_NORMALIZED are valid */ 269 texture_2d_multisample_properties.expected_texture_blue_types.push_back(GL_UNSIGNED_INT); 270 texture_2d_multisample_properties.expected_texture_blue_types.push_back(GL_UNSIGNED_NORMALIZED); 271 texture_2d_multisample_properties.expected_texture_depth = 1; 272 texture_2d_multisample_properties.expected_texture_depth_size = 0; 273 texture_2d_multisample_properties.expected_texture_depth_types.push_back(GL_NONE); 274 texture_2d_multisample_properties.expected_texture_fixed_sample_locations = GL_FALSE; 275 texture_2d_multisample_properties.expected_texture_green_size = 8; 276 /* Return value is implementation-dependent. For current input values GL_UNSIGNED_INT and GL_UNSIGNED_NORMALIZED are valid */ 277 texture_2d_multisample_properties.expected_texture_green_types.push_back(GL_UNSIGNED_INT); 278 texture_2d_multisample_properties.expected_texture_green_types.push_back(GL_UNSIGNED_NORMALIZED); 279 texture_2d_multisample_properties.expected_texture_height = 8; 280 texture_2d_multisample_properties.expected_texture_internal_format = GL_RGBA8UI; 281 texture_2d_multisample_properties.expected_texture_red_size = 8; 282 /* Return value is implementation-dependent. For current input values GL_UNSIGNED_INT and GL_UNSIGNED_NORMALIZED are valid */ 283 texture_2d_multisample_properties.expected_texture_red_types.push_back(GL_UNSIGNED_INT); 284 texture_2d_multisample_properties.expected_texture_red_types.push_back(GL_UNSIGNED_NORMALIZED); 285 texture_2d_multisample_properties.expected_texture_samples = 1; 286 texture_2d_multisample_properties.expected_texture_shared_size = 0; 287 texture_2d_multisample_properties.expected_texture_stencil_size = 0; 288 texture_2d_multisample_properties.expected_texture_width = 8; 289 290 /* GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES */ 291 texture_2d_multisample_array_properties.depth = 4; /* note: test spec missed this bit */ 292 texture_2d_multisample_array_properties.fixedsamplelocations = GL_TRUE; 293 texture_2d_multisample_array_properties.format = GL_RGB; 294 texture_2d_multisample_array_properties.height = 4; 295 texture_2d_multisample_array_properties.internalformat = GL_RGB565; 296 texture_2d_multisample_array_properties.is_2d_texture = false; 297 texture_2d_multisample_array_properties.is_multisample_texture = true; 298 texture_2d_multisample_array_properties.samples = max_rgb565_internalformat_samples; 299 texture_2d_multisample_array_properties.target = GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES; 300 texture_2d_multisample_array_properties.to_id_ptr = &to_2d_multisample_array; 301 texture_2d_multisample_array_properties.type = GL_UNSIGNED_BYTE; 302 texture_2d_multisample_array_properties.width = 4; 303 304 texture_2d_multisample_array_properties.expected_compressed = GL_FALSE; 305 texture_2d_multisample_array_properties.expected_texture_alpha_size = 0; 306 texture_2d_multisample_array_properties.expected_texture_alpha_types.push_back(GL_NONE); 307 texture_2d_multisample_array_properties.expected_texture_blue_size = 5; 308 /* Return value is implementation-dependent. For current input values GL_UNSIGNED_INT and GL_UNSIGNED_NORMALIZED are valid */ 309 texture_2d_multisample_array_properties.expected_texture_blue_types.push_back(GL_UNSIGNED_NORMALIZED); 310 texture_2d_multisample_array_properties.expected_texture_blue_types.push_back(GL_UNSIGNED_INT); 311 texture_2d_multisample_array_properties.expected_texture_depth = 4; 312 texture_2d_multisample_array_properties.expected_texture_depth_size = 0; 313 texture_2d_multisample_array_properties.expected_texture_depth_types.push_back(GL_NONE); 314 texture_2d_multisample_array_properties.expected_texture_fixed_sample_locations = GL_TRUE; 315 texture_2d_multisample_array_properties.expected_texture_green_size = 6; 316 /* Return value is implementation-dependent. For current input values GL_UNSIGNED_INT and GL_UNSIGNED_NORMALIZED are valid */ 317 texture_2d_multisample_array_properties.expected_texture_green_types.push_back(GL_UNSIGNED_NORMALIZED); 318 texture_2d_multisample_array_properties.expected_texture_green_types.push_back(GL_UNSIGNED_INT); 319 texture_2d_multisample_array_properties.expected_texture_height = 4; 320 texture_2d_multisample_array_properties.expected_texture_internal_format = GL_RGB565; 321 texture_2d_multisample_array_properties.expected_texture_red_size = 5; 322 /* Return value is implementation-dependent. For current input values GL_UNSIGNED_INT and GL_UNSIGNED_NORMALIZED are valid */ 323 texture_2d_multisample_array_properties.expected_texture_red_types.push_back(GL_UNSIGNED_NORMALIZED); 324 texture_2d_multisample_array_properties.expected_texture_red_types.push_back(GL_UNSIGNED_INT); 325 texture_2d_multisample_array_properties.expected_texture_samples = max_rgb565_internalformat_samples; 326 texture_2d_multisample_array_properties.expected_texture_shared_size = 0; 327 texture_2d_multisample_array_properties.expected_texture_stencil_size = 0; 328 texture_2d_multisample_array_properties.expected_texture_width = 4; 329 330 /* GL_TEXTURE_3D */ 331 texture_3d_properties.depth = 2; 332 texture_3d_properties.format = GL_RGB; 333 texture_3d_properties.height = 2; 334 texture_3d_properties.internalformat = GL_RGB9_E5; 335 texture_3d_properties.is_2d_texture = false; 336 texture_3d_properties.target = GL_TEXTURE_3D; 337 texture_3d_properties.to_id_ptr = &to_3d; 338 texture_3d_properties.type = GL_FLOAT; 339 texture_3d_properties.width = 2; 340 341 texture_3d_properties.expected_compressed = GL_FALSE; 342 texture_3d_properties.expected_texture_alpha_size = 0; 343 texture_3d_properties.expected_texture_alpha_types.push_back(GL_NONE); 344 texture_3d_properties.expected_texture_blue_size = 9; 345 texture_3d_properties.expected_texture_blue_types.push_back(GL_FLOAT); 346 texture_3d_properties.expected_texture_depth = 2; 347 texture_3d_properties.expected_texture_depth_size = 0; 348 texture_3d_properties.expected_texture_depth_types.push_back(GL_NONE); 349 texture_3d_properties.expected_texture_fixed_sample_locations = GL_TRUE; 350 texture_3d_properties.expected_texture_green_size = 9; 351 texture_3d_properties.expected_texture_green_types.push_back(GL_FLOAT); 352 texture_3d_properties.expected_texture_height = 2; 353 texture_3d_properties.expected_texture_internal_format = GL_RGB9_E5; 354 texture_3d_properties.expected_texture_red_size = 9; 355 texture_3d_properties.expected_texture_red_types.push_back(GL_FLOAT); 356 texture_3d_properties.expected_texture_samples = 0; 357 texture_3d_properties.expected_texture_shared_size = 5; 358 texture_3d_properties.expected_texture_stencil_size = 0; 359 texture_3d_properties.expected_texture_width = 2; 360 361 /* GL_TEXTURE_CUBE_MAP_* */ 362 texture_cm_face_properties.format = GL_RGB_INTEGER; 363 texture_cm_face_properties.height = 1; 364 texture_cm_face_properties.internalformat = GL_RGB16I; 365 texture_cm_face_properties.is_cm_texture = true; 366 texture_cm_face_properties.target = GL_TEXTURE_CUBE_MAP; 367 texture_cm_face_properties.to_id_ptr = &to_cubemap; 368 texture_cm_face_properties.type = GL_SHORT; 369 texture_cm_face_properties.width = 1; 370 371 texture_cm_face_properties.expected_compressed = GL_FALSE; 372 texture_cm_face_properties.expected_texture_alpha_size = 0; 373 texture_cm_face_properties.expected_texture_alpha_types.push_back(GL_NONE); 374 texture_cm_face_properties.expected_texture_blue_size = 16; 375 texture_cm_face_properties.expected_texture_blue_types.push_back(GL_INT); 376 texture_cm_face_properties.expected_texture_depth = 1; 377 texture_cm_face_properties.expected_texture_depth_size = 0; 378 texture_cm_face_properties.expected_texture_depth_types.push_back(GL_NONE); 379 texture_cm_face_properties.expected_texture_fixed_sample_locations = GL_TRUE; 380 texture_cm_face_properties.expected_texture_green_size = 16; 381 texture_cm_face_properties.expected_texture_green_types.push_back(GL_INT); 382 texture_cm_face_properties.expected_texture_height = 1; 383 texture_cm_face_properties.expected_texture_internal_format = GL_RGB16I; 384 texture_cm_face_properties.expected_texture_red_size = 16; 385 texture_cm_face_properties.expected_texture_red_types.push_back(GL_INT); 386 texture_cm_face_properties.expected_texture_samples = 0; 387 texture_cm_face_properties.expected_texture_shared_size = 0; 388 texture_cm_face_properties.expected_texture_stencil_size = 0; 389 texture_cm_face_properties.expected_texture_width = 1; 390 391 /* The test needs to be run in two iterations: 392 * 393 * a) In first run, we need to test immutable textures; 394 * b) In second one, mutable textures should be used. 395 */ 396 for (unsigned int n_iteration = 0; n_iteration < 2 /* immutable/mutable textures */; ++n_iteration) 397 { 398 bool is_immutable_run = (n_iteration == 0); 399 400 /* Generate texture object IDs */ 401 gl.genTextures(1, &to_2d); 402 gl.genTextures(1, &to_2d_array); 403 gl.genTextures(1, &to_2d_multisample); 404 gl.genTextures(1, &to_2d_multisample_array); 405 gl.genTextures(1, &to_3d); 406 gl.genTextures(1, &to_cubemap); 407 408 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTexture() call(s) failed."); 409 410 /* Configure texture storage for each target. */ 411 for (unsigned int n_descriptor = 0; n_descriptor < n_texture_descriptors; ++n_descriptor) 412 { 413 const _texture_properties* texture_ptr = texture_descriptors[n_descriptor]; 414 415 /* Multisample texture targets are not supported by glTexImage*D() API in ES3.1. 416 * Skip two iterations so that we follow the requirement. 417 */ 418 if (!is_immutable_run && (texture_ptr->target == GL_TEXTURE_2D_MULTISAMPLE || 419 texture_ptr->target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES)) 420 { 421 continue; 422 } 423 424 /* Bind the ID to processed texture target */ 425 gl.bindTexture(texture_ptr->target, *texture_ptr->to_id_ptr); 426 427 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture() call failed"); 428 429 /* Set up texture storage */ 430 if (is_immutable_run) 431 { 432 if (texture_ptr->is_2d_texture) 433 { 434 if (texture_ptr->is_multisample_texture) 435 { 436 gl.texStorage2DMultisample(texture_ptr->target, texture_ptr->samples, 437 texture_ptr->internalformat, texture_ptr->width, texture_ptr->height, 438 texture_ptr->fixedsamplelocations); 439 440 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage2DMultisample() call failed"); 441 } 442 else 443 { 444 gl.texStorage2D(texture_ptr->target, 1, /* levels */ 445 texture_ptr->internalformat, texture_ptr->width, texture_ptr->height); 446 447 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage2D() call failed"); 448 } 449 } 450 else if (texture_ptr->is_cm_texture) 451 { 452 gl.texStorage2D(GL_TEXTURE_CUBE_MAP, 1, /* levels */ 453 texture_ptr->internalformat, texture_ptr->width, texture_ptr->height); 454 455 GLU_EXPECT_NO_ERROR(gl.getError(), 456 "glTexStorage2D() call failed for GL_TEXTURE_CUBE_MAP texture target"); 457 } 458 else 459 { 460 if (texture_ptr->target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES) 461 { 462 if (gl_oes_texture_storage_multisample_2d_array_supported) 463 { 464 gl.texStorage3DMultisample(texture_ptr->target, texture_ptr->samples, 465 texture_ptr->internalformat, texture_ptr->width, 466 texture_ptr->height, texture_ptr->depth, 467 texture_ptr->fixedsamplelocations); 468 469 GLU_EXPECT_NO_ERROR(gl.getError(), "gltexStorage3DMultisample() call failed"); 470 } 471 else 472 { 473 TCU_FAIL("Invalid texture target is being used."); 474 } 475 } 476 else 477 { 478 /* Must be a single-sampled 2D array or 3D texture */ 479 gl.texStorage3D(texture_ptr->target, 1, /* levels */ 480 texture_ptr->internalformat, texture_ptr->width, texture_ptr->height, 481 texture_ptr->depth); 482 483 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage3D() call failed"); 484 } 485 } 486 } /* if (!is_immutable_run) */ 487 else 488 { 489 /* Mutable run */ 490 if (texture_ptr->is_2d_texture) 491 { 492 gl.texImage2D(texture_ptr->target, 0, /* level */ 493 texture_ptr->internalformat, texture_ptr->width, texture_ptr->height, 0, /* border */ 494 texture_ptr->format, texture_ptr->type, NULL); /* pixels */ 495 496 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D() call failed"); 497 } 498 else if (texture_ptr->is_cm_texture) 499 { 500 const glw::GLenum cm_texture_targets[] = { 501 GL_TEXTURE_CUBE_MAP_NEGATIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 502 GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 503 }; 504 const unsigned int n_cm_texture_targets = 505 sizeof(cm_texture_targets) / sizeof(cm_texture_targets[0]); 506 507 for (unsigned int n_cm_texture_target = 0; n_cm_texture_target < n_cm_texture_targets; 508 ++n_cm_texture_target) 509 { 510 glw::GLenum texture_target = cm_texture_targets[n_cm_texture_target]; 511 512 gl.texImage2D(texture_target, 0, /* level */ 513 texture_ptr->internalformat, texture_ptr->width, texture_ptr->height, 514 0, /* border */ 515 texture_ptr->format, texture_ptr->type, NULL); /* pixels */ 516 517 GLU_EXPECT_NO_ERROR(gl.getError(), 518 "glTexImage2D() call failed for a cube-map face texture target"); 519 } /* for (all cube-map texture targets) */ 520 } 521 else 522 { 523 /* Must be a 2D array texture or 3D texture */ 524 gl.texImage3D(texture_ptr->target, 0, /* level */ 525 texture_ptr->internalformat, texture_ptr->width, texture_ptr->height, 526 texture_ptr->depth, 0, /* border */ 527 texture_ptr->format, texture_ptr->type, NULL); /* pixels */ 528 529 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage3D() call failed"); 530 } 531 } 532 } /* for (all texture descriptors) */ 533 534 /* Check if correct values are reported for all texture properties described in 535 * the spec. 536 */ 537 typedef std::map<glw::GLenum, const _texture_properties*> target_to_texture_properties_map; 538 typedef target_to_texture_properties_map::const_iterator target_to_texture_properties_map_const_iterator; 539 540 const glw::GLenum pnames[] = { GL_TEXTURE_RED_TYPE, 541 GL_TEXTURE_GREEN_TYPE, 542 GL_TEXTURE_BLUE_TYPE, 543 GL_TEXTURE_ALPHA_TYPE, 544 GL_TEXTURE_DEPTH_TYPE, 545 GL_TEXTURE_RED_SIZE, 546 GL_TEXTURE_GREEN_SIZE, 547 GL_TEXTURE_BLUE_SIZE, 548 GL_TEXTURE_ALPHA_SIZE, 549 GL_TEXTURE_DEPTH_SIZE, 550 GL_TEXTURE_STENCIL_SIZE, 551 GL_TEXTURE_SHARED_SIZE, 552 GL_TEXTURE_COMPRESSED, 553 GL_TEXTURE_INTERNAL_FORMAT, 554 GL_TEXTURE_WIDTH, 555 GL_TEXTURE_HEIGHT, 556 GL_TEXTURE_DEPTH, 557 GL_TEXTURE_SAMPLES, 558 GL_TEXTURE_FIXED_SAMPLE_LOCATIONS }; 559 const unsigned int n_pnames = sizeof(pnames) / sizeof(pnames[0]); 560 target_to_texture_properties_map targets; 561 562 targets[GL_TEXTURE_2D] = &texture_2d_properties; 563 targets[GL_TEXTURE_2D_ARRAY] = &texture_2d_array_properties; 564 targets[GL_TEXTURE_2D_MULTISAMPLE] = &texture_2d_multisample_properties; 565 targets[GL_TEXTURE_3D] = &texture_3d_properties; 566 targets[GL_TEXTURE_CUBE_MAP_NEGATIVE_X] = &texture_cm_face_properties; 567 targets[GL_TEXTURE_CUBE_MAP_NEGATIVE_Y] = &texture_cm_face_properties; 568 targets[GL_TEXTURE_CUBE_MAP_NEGATIVE_Z] = &texture_cm_face_properties; 569 targets[GL_TEXTURE_CUBE_MAP_POSITIVE_X] = &texture_cm_face_properties; 570 targets[GL_TEXTURE_CUBE_MAP_POSITIVE_Y] = &texture_cm_face_properties; 571 targets[GL_TEXTURE_CUBE_MAP_POSITIVE_Z] = &texture_cm_face_properties; 572 573 if (gl_oes_texture_storage_multisample_2d_array_supported) 574 { 575 targets[GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES] = &texture_2d_multisample_array_properties; 576 } 577 578 for (target_to_texture_properties_map_const_iterator target_iterator = targets.begin(); 579 target_iterator != targets.end(); target_iterator++) 580 { 581 glw::GLenum target = target_iterator->first; 582 const _texture_properties* texture_ptr = target_iterator->second; 583 584 /* Multisample texture targets are not supported by glTexImage*D() API in ES3.1. 585 * Skip two iterations so that we follow the requirement. 586 */ 587 if (m_context.getRenderContext().getType().getAPI() == glu::ApiType::es(3, 1) && !is_immutable_run && 588 (texture_ptr->target == GL_TEXTURE_2D_MULTISAMPLE || 589 texture_ptr->target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES)) 590 { 591 continue; 592 } 593 594 for (unsigned int n_pname = 0; n_pname < n_pnames; ++n_pname) 595 { 596 glw::GLenum pname = pnames[n_pname]; 597 598 /* Run the check in two stages: 599 * 600 * a) Use glGetTexLevelParameteriv() in first run; 601 * b) Use glGetTexLevelParameterfv() in the other run; 602 */ 603 for (unsigned int n_stage = 0; n_stage < 2 /* stages */; ++n_stage) 604 { 605 glw::GLfloat float_value = 0.0f; 606 glw::GLint int_value = 0; 607 608 /* Check if the retrieved value is correct */ 609 glw::GLenum expected_error_code = GL_NO_ERROR; 610 std::vector<glw::GLint> expected_int_values; 611 612 switch (pname) 613 { 614 case GL_TEXTURE_RED_TYPE: 615 { 616 /* Return value is implementation-dependent and not enforced by spec. 617 * For this pname, more that one value could be valid. */ 618 expected_int_values = texture_ptr->expected_texture_red_types; 619 620 break; 621 } 622 623 case GL_TEXTURE_GREEN_TYPE: 624 { 625 /* Return value is implementation-dependent and not enforced by spec. 626 * For this pname, more that one value could be valid. */ 627 expected_int_values = texture_ptr->expected_texture_green_types; 628 629 break; 630 } 631 632 case GL_TEXTURE_BLUE_TYPE: 633 { 634 /* Return value is implementation-dependent and not enforced by spec. 635 * For this pname, more that one value could be valid. */ 636 expected_int_values = texture_ptr->expected_texture_blue_types; 637 638 break; 639 } 640 641 case GL_TEXTURE_ALPHA_TYPE: 642 { 643 /* Return value is implementation-dependent and not enforced by spec. 644 * For this pname, more that one value could be valid. */ 645 expected_int_values = texture_ptr->expected_texture_alpha_types; 646 647 break; 648 } 649 650 case GL_TEXTURE_DEPTH_TYPE: 651 { 652 /* Return value is implementation-dependent and not enforced by spec. 653 * For this pname, more that one value could be valid. */ 654 expected_int_values = texture_ptr->expected_texture_depth_types; 655 656 break; 657 } 658 659 case GL_TEXTURE_RED_SIZE: 660 { 661 /* Return value is implementation-dependent and not enforced by spec, 662 * but it can't be less that expected_int_value */ 663 expected_int_values.push_back(texture_ptr->expected_texture_red_size); 664 665 break; 666 } 667 668 case GL_TEXTURE_GREEN_SIZE: 669 { 670 /* Return value is implementation-dependent and not enforced by spec, 671 * but it can't be less that expected_int_value */ 672 expected_int_values.push_back(texture_ptr->expected_texture_green_size); 673 674 break; 675 } 676 677 case GL_TEXTURE_BLUE_SIZE: 678 { 679 /* Return value is implementation-dependent and not enforced by spec, 680 * but it can't be less that expected_int_value */ 681 expected_int_values.push_back(texture_ptr->expected_texture_blue_size); 682 683 break; 684 } 685 686 case GL_TEXTURE_ALPHA_SIZE: 687 { 688 /* Return value is implementation-dependent and not enforced by spec, 689 * but it can't be less that expected_int_value */ 690 expected_int_values.push_back(texture_ptr->expected_texture_alpha_size); 691 692 break; 693 } 694 695 case GL_TEXTURE_DEPTH_SIZE: 696 { 697 /* Return value is implementation-dependent and not enforced by spec, 698 * but it can't be less that expected_int_value */ 699 expected_int_values.push_back(texture_ptr->expected_texture_depth_size); 700 701 break; 702 } 703 704 case GL_TEXTURE_STENCIL_SIZE: 705 { 706 /* Return value is implementation-dependent and not enforced by spec, 707 * but it can't be less that expected_int_value */ 708 expected_int_values.push_back(texture_ptr->expected_texture_stencil_size); 709 710 break; 711 } 712 713 case GL_TEXTURE_SHARED_SIZE: 714 { 715 /* Return value is implementation-dependent and not enforced by spec, 716 * but it can't be less that expected_int_value */ 717 expected_int_values.push_back(texture_ptr->expected_texture_shared_size); 718 719 break; 720 } 721 722 case GL_TEXTURE_COMPRESSED: 723 { 724 expected_int_values.push_back(texture_ptr->expected_compressed); 725 726 break; 727 } 728 729 case GL_TEXTURE_INTERNAL_FORMAT: 730 { 731 expected_int_values.push_back(texture_ptr->expected_texture_internal_format); 732 733 break; 734 } 735 736 case GL_TEXTURE_WIDTH: 737 { 738 expected_int_values.push_back(texture_ptr->expected_texture_width); 739 740 break; 741 } 742 743 case GL_TEXTURE_HEIGHT: 744 { 745 expected_int_values.push_back(texture_ptr->expected_texture_height); 746 747 break; 748 } 749 750 case GL_TEXTURE_DEPTH: 751 { 752 expected_int_values.push_back(texture_ptr->expected_texture_depth); 753 754 break; 755 } 756 757 case GL_TEXTURE_SAMPLES: 758 { 759 expected_int_values.push_back(texture_ptr->expected_texture_samples); 760 761 break; 762 } 763 764 case GL_TEXTURE_FIXED_SAMPLE_LOCATIONS: 765 { 766 expected_int_values.push_back(texture_ptr->expected_texture_fixed_sample_locations); 767 768 break; 769 } 770 771 default: 772 { 773 m_testCtx.getLog() << tcu::TestLog::Message << "Unrecognized pname [" << pname << "]" 774 << tcu::TestLog::EndMessage; 775 776 TCU_FAIL("Unrecognized pname"); 777 } 778 } /* switch (pname) */ 779 780 /* Do the actual call. If we're expecting an error, make sure it was generated. 781 * Otherwise, confirm no error was generated by the call */ 782 glw::GLenum error_code = GL_NO_ERROR; 783 784 if (n_stage == 0) 785 { 786 /* call glGetTexLevelParameteriv() */ 787 gl.getTexLevelParameteriv(target, 0 /* level */, pname, &int_value); 788 789 error_code = gl.getError(); 790 if (error_code != expected_error_code) 791 { 792 m_testCtx.getLog() << tcu::TestLog::Message << "glGetTexLevelParameteriv() for pname [" 793 << pname << "]" 794 << " and target [" << target << "]" 795 << " generated an invalid error code [" << error_code << "]" 796 << tcu::TestLog::EndMessage; 797 798 TCU_FAIL("Error calling glGetTexLevelParameteriv()"); 799 } /* if (error_code != GL_NO_ERROR) */ 800 } /* if (n_stage == 0) */ 801 else 802 { 803 /* call glGetTexLevelParameterfv() */ 804 gl.getTexLevelParameterfv(target, 0 /* level */, pname, &float_value); 805 806 error_code = gl.getError(); 807 if (error_code != expected_error_code) 808 { 809 m_testCtx.getLog() << tcu::TestLog::Message << "glGetTexLevelParameteriv() for pname [" 810 << pname << "]" 811 << " and target [" << target << "]" 812 << " generated an invalid error code [" << error_code << "]" 813 << tcu::TestLog::EndMessage; 814 815 TCU_FAIL("Error calling glGetTexLevelParameterfv()"); 816 } /* if (error_code != GL_NO_ERROR) */ 817 818 /* Cast the result to an integer - this is fine since none of the properties we are 819 * querying is FP. 820 **/ 821 DE_ASSERT(float_value == (float)(int)float_value); 822 int_value = (int)float_value; 823 } 824 825 /* Check the result value only if no error was expected */ 826 if (expected_error_code == GL_NO_ERROR) 827 { 828 switch (pname) 829 { 830 case GL_TEXTURE_RED_SIZE: 831 case GL_TEXTURE_GREEN_SIZE: 832 case GL_TEXTURE_BLUE_SIZE: 833 case GL_TEXTURE_ALPHA_SIZE: 834 case GL_TEXTURE_DEPTH_SIZE: 835 case GL_TEXTURE_STENCIL_SIZE: 836 case GL_TEXTURE_SHARED_SIZE: 837 case GL_TEXTURE_SAMPLES: 838 { 839 /* For some pnames with size, value range is valid. 840 * For example for GL_RGB16I and GL_TEXTURE_RED_SIZE implementation may return 16 or 32, 841 * which will still comply with the spec. 842 * In such case we check if returned value is no less than 16. 843 */ 844 if (expected_int_values.at(0) > int_value) 845 { 846 m_testCtx.getLog() << tcu::TestLog::Message << "Too small value reported for pname [" 847 << pname << "]" 848 << " and target [" << target << "]" 849 << " expected not less than:[" << expected_int_values.at(0) << "]" 850 << " retrieved:[" << int_value << "]" << tcu::TestLog::EndMessage; 851 852 TCU_FAIL("Invalid value reported."); 853 } 854 break; 855 } 856 857 case GL_TEXTURE_COMPRESSED: 858 case GL_TEXTURE_INTERNAL_FORMAT: 859 case GL_TEXTURE_WIDTH: 860 case GL_TEXTURE_HEIGHT: 861 case GL_TEXTURE_DEPTH: 862 case GL_TEXTURE_FIXED_SAMPLE_LOCATIONS: 863 { 864 if (expected_int_values.at(0) != int_value) 865 { 866 m_testCtx.getLog() << tcu::TestLog::Message << "Invalid value reported for pname [" 867 << pname << "]" 868 << " and target [" << target << "]" 869 << " expected:[" << expected_int_values.at(0) << "]" 870 << " retrieved:[" << int_value << "]" << tcu::TestLog::EndMessage; 871 872 TCU_FAIL("Invalid value reported."); 873 } 874 break; 875 } 876 877 case GL_TEXTURE_RED_TYPE: 878 case GL_TEXTURE_GREEN_TYPE: 879 case GL_TEXTURE_BLUE_TYPE: 880 case GL_TEXTURE_ALPHA_TYPE: 881 case GL_TEXTURE_DEPTH_TYPE: 882 { 883 /* For some pnames with types, more than one value could be valid. 884 * For example for GL_DEPTH24_STENCIL8 and GL_DEPTH_TYPE query, the returned value is implementation 885 * dependent, some implementations return GL_UNSIGNED_NORMALIZED, other may return GL_UNSIGNED_INT 886 * depending on hardware specific representation of depth. 887 */ 888 889 std::vector<glw::GLint>::iterator expected_value_it = 890 find(expected_int_values.begin(), expected_int_values.end(), int_value); 891 892 if (expected_value_it == expected_int_values.end()) 893 { 894 std::ostringstream expected_values_string_stream; 895 896 for (std::vector<glw::GLint>::iterator it = expected_int_values.begin(); 897 it != expected_int_values.end(); ++it) 898 { 899 if (it != expected_int_values.begin()) 900 { 901 expected_values_string_stream << ", "; 902 } 903 904 expected_values_string_stream << *it; 905 } 906 907 m_testCtx.getLog() << tcu::TestLog::Message << "Invalid value reported for pname [" 908 << pname << "]" 909 << " and target [" << target << "]" 910 << " expected:[" << expected_values_string_stream.str() << "]" 911 << " retrieved:[" << int_value << "]" << tcu::TestLog::EndMessage; 912 913 TCU_FAIL("Invalid value reported."); 914 } 915 break; 916 } 917 918 default: 919 { 920 m_testCtx.getLog() << tcu::TestLog::Message << "Unrecognized pname [" << pname << "]" 921 << tcu::TestLog::EndMessage; 922 923 TCU_FAIL("Unrecognized pname"); 924 } /* default: */ 925 } /* switch (pname) */ 926 } /* if (expected_error_code == GL_NO_ERROR) */ 927 } /* for (all stages) */ 928 } /* for (all properties) */ 929 } /* for (all texture targets) */ 930 931 /* Iteration finished - clean up. */ 932 for (unsigned int n_descriptor = 0; n_descriptor < n_texture_descriptors; ++n_descriptor) 933 { 934 const _texture_properties* texture_ptr = texture_descriptors[n_descriptor]; 935 936 /* Release the texture object */ 937 gl.bindTexture(texture_ptr->target, 0); 938 gl.deleteTextures(1, texture_ptr->to_id_ptr); 939 940 GLU_EXPECT_NO_ERROR(gl.getError(), "glDeleteTextures() call failed"); 941 942 /* Assign a new object to the ID */ 943 gl.genTextures(1, texture_ptr->to_id_ptr); 944 945 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures() call failed"); 946 } /* for (all texture descriptors) */ 947 } /* for (immutable & mutable textures) */ 948 949 /* All done */ 950 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); 951 952 return STOP; 953} 954 955/** Constructor. 956 * 957 * @param context CTS context handle. 958 **/ 959MultisampleTextureGetTexLevelParametervWorksForMaximumLodTest:: 960 MultisampleTextureGetTexLevelParametervWorksForMaximumLodTest(Context& context) 961 : TestCase(context, "functional_max_lod_test", "Verifies glGetTexLevelParameter{if}v() entry-points work " 962 "correctly when info about maximum LOD is requested.") 963 , gl_oes_texture_storage_multisample_2d_array_supported(GL_FALSE) 964 , to_id(0) 965{ 966 /* Left blank on purpose */ 967} 968 969/** Deinitializes GL ES objects used by the test */ 970void MultisampleTextureGetTexLevelParametervWorksForMaximumLodTest::deinit() 971{ 972 const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 973 974 if (to_id != 0) 975 { 976 gl.deleteTextures(1, &to_id); 977 978 to_id = 0; 979 } 980 981 /* Call base class' deinit() */ 982 TestCase::deinit(); 983} 984 985/** Executes test iteration. 986 * 987 * @return Returns STOP when test has finished executing. 988 */ 989tcu::TestNode::IterateResult MultisampleTextureGetTexLevelParametervWorksForMaximumLodTest::iterate() 990{ 991 gl_oes_texture_storage_multisample_2d_array_supported = 992 m_context.getContextInfo().isExtensionSupported("GL_OES_texture_storage_multisample_2d_array"); 993 994 const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 995 int number_of_iterations = 0; 996 997 /* Generate a texture object and bind id to a 2D multisample texture target */ 998 gl.genTextures(1, &to_id); 999 gl.bindTexture(GL_TEXTURE_2D_MULTISAMPLE, to_id); 1000 1001 GLU_EXPECT_NO_ERROR(gl.getError(), "Could not create a texture object"); 1002 1003 if (gl_oes_texture_storage_multisample_2d_array_supported) 1004 { 1005 /* Run in two iterations: 1006 * 1007 * a) Texture storage initialized with glTexStorage2DMultisample(); 1008 * b) Texture storage initialized with gltexStorage3DMultisample(). 1009 */ 1010 number_of_iterations = 2; 1011 } 1012 else 1013 { 1014 /* Run in one iteration: 1015 * 1016 * a) Texture storage initialized with glTexStorage2DMultisample(); 1017 */ 1018 number_of_iterations = 1; 1019 } 1020 1021 /* Run in two iterations: 1022 * 1023 * a) Texture storage initialized with glTexStorage2DMultisample(); 1024 * b) Texture storage initialized with gltexStorage3DMultisample(). 1025 */ 1026 for (int n_iteration = 0; n_iteration < number_of_iterations; ++n_iteration) 1027 { 1028 bool is_2d_multisample_iteration = (n_iteration == 0); 1029 const int max_lod = 1030 0; /* For multisample textures only lod=0 is valid, queries for lod > 0 will always return GL_NONE, as those lods are not defined for such texture */ 1031 glw::GLenum texture_target = 1032 (n_iteration == 0) ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES; 1033 1034 /* Set up texture storage */ 1035 if (is_2d_multisample_iteration) 1036 { 1037 gl.texStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 1, /* samples */ 1038 GL_RGBA8, 16, /* width */ 1039 16, /* height */ 1040 GL_FALSE); /* fixedsamplelocations */ 1041 1042 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage2DMultisample() call failed"); 1043 } /* if (is_2d_multisample_iteration) */ 1044 else 1045 { 1046 gl.texStorage3DMultisample(GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES, 1, /* samples */ 1047 GL_RGBA8, 16, /* width */ 1048 16, /* height */ 1049 16, /* depth */ 1050 GL_FALSE); /* fixedsamplelocations */ 1051 1052 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage2DMultisample() call failed"); 1053 } 1054 1055 /* Check all glGetTexLevelParameter*() entry-points */ 1056 for (int n_api_call = 0; n_api_call < 2 /* iv(), fv() */; ++n_api_call) 1057 { 1058 float float_value = 0; 1059 glw::GLint red_size = 0; 1060 glw::GLint red_type = 0; 1061 glw::GLint texture_internal_format = GL_NONE; 1062 glw::GLint texture_samples = 0; 1063 1064 switch (n_api_call) 1065 { 1066 case 0: 1067 { 1068 gl.getTexLevelParameteriv(texture_target, max_lod, GL_TEXTURE_RED_TYPE, &red_type); 1069 gl.getTexLevelParameteriv(texture_target, max_lod, GL_TEXTURE_RED_SIZE, &red_size); 1070 gl.getTexLevelParameteriv(texture_target, max_lod, GL_TEXTURE_INTERNAL_FORMAT, 1071 &texture_internal_format); 1072 gl.getTexLevelParameteriv(texture_target, max_lod, GL_TEXTURE_SAMPLES, &texture_samples); 1073 1074 GLU_EXPECT_NO_ERROR(gl.getError(), "At least one glGetTexLevelParameteriv() call failed."); 1075 1076 break; 1077 } 1078 1079 case 1: 1080 { 1081 gl.getTexLevelParameterfv(texture_target, max_lod, GL_TEXTURE_RED_TYPE, &float_value); 1082 red_type = (glw::GLint)float_value; 1083 1084 gl.getTexLevelParameterfv(texture_target, max_lod, GL_TEXTURE_RED_SIZE, &float_value); 1085 red_size = (glw::GLint)float_value; 1086 1087 gl.getTexLevelParameterfv(texture_target, max_lod, GL_TEXTURE_INTERNAL_FORMAT, &float_value); 1088 texture_internal_format = (glw::GLint)float_value; 1089 1090 gl.getTexLevelParameterfv(texture_target, max_lod, GL_TEXTURE_SAMPLES, &float_value); 1091 texture_samples = (glw::GLint)float_value; 1092 1093 GLU_EXPECT_NO_ERROR(gl.getError(), "At least one glGetTexLevelParameterfv() call failed."); 1094 1095 break; 1096 } 1097 1098 default: 1099 TCU_FAIL("Unrecognized API call index"); 1100 } 1101 1102 /* Make sure the retrieved values are valid 1103 * 1104 * NOTE: The original test case did not make much sense in this regard. */ 1105 if (red_type != GL_UNSIGNED_NORMALIZED) 1106 { 1107 m_testCtx.getLog() << tcu::TestLog::Message 1108 << "Invalid value returned for a GL_TEXTURE_RED_TYPE query: " 1109 << "expected:GL_UNSIGNED_NORMALIZED, retrieved:" << red_type 1110 << tcu::TestLog::EndMessage; 1111 1112 TCU_FAIL("Invalid value returned for a GL_TEXTURE_RED_TYPE query"); 1113 } 1114 1115 if (red_size != 8) 1116 { 1117 m_testCtx.getLog() << tcu::TestLog::Message 1118 << "Invalid value returned for a GL_TEXTURE_RED_SIZE query: " 1119 << "expected:8, retrieved:" << red_size << tcu::TestLog::EndMessage; 1120 1121 TCU_FAIL("Invalid value returned for a GL_TEXTURE_RED_SIZE query"); 1122 } 1123 1124 if (texture_internal_format != GL_RGBA8) 1125 { 1126 m_testCtx.getLog() << tcu::TestLog::Message 1127 << "Invalid value returned for a GL_TEXTURE_INTERNAL_FORMAT query: " 1128 << "expected:GL_RGBA8, retrieved:" << texture_internal_format 1129 << tcu::TestLog::EndMessage; 1130 1131 TCU_FAIL("Invalid value returned for a GL_TEXTURE_INTERNAL_FORMAT query"); 1132 } 1133 1134 /* Implementation is allowed to return more samples than requested */ 1135 if (texture_samples < 1) 1136 { 1137 m_testCtx.getLog() << tcu::TestLog::Message << "Invalid value returned for a GL_TEXTURE_SAMPLES query: " 1138 << "expected:1, retrieved:" << texture_samples << tcu::TestLog::EndMessage; 1139 1140 TCU_FAIL("Invalid value returned for a GL_TEXTURE_SAMPLES query"); 1141 } 1142 } /* for (both API call types) */ 1143 1144 /* Re-create the texture object and bind it to 2D multisample array texture target */ 1145 gl.deleteTextures(1, &to_id); 1146 to_id = 0; 1147 1148 /* Prepare for the next iteration (if needed). */ 1149 if (n_iteration == 0 && number_of_iterations == 2) 1150 { 1151 gl.genTextures(1, &to_id); 1152 gl.bindTexture(GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES, to_id); 1153 } 1154 1155 GLU_EXPECT_NO_ERROR(gl.getError(), "Could not re-create the texture object."); 1156 } /* for (all iterations) */ 1157 1158 /* All done */ 1159 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); 1160 1161 return STOP; 1162} 1163 1164/** Constructor. 1165 * 1166 * @param context CTS context handle. 1167 **/ 1168MultisampleTextureGetTexLevelParametervInvalidTextureTargetRejectedTest:: 1169 MultisampleTextureGetTexLevelParametervInvalidTextureTargetRejectedTest(Context& context) 1170 : TestCase(context, "invalid_texture_target_rejected", "Verifies glGetTexLevelParameter{if}v() rejects invalid " 1171 "texture target by generating GL_INVALID_ENUM error.") 1172 , float_data(0.0f) 1173 , int_data(0) 1174{ 1175 /* Left blank on purpose */ 1176} 1177 1178/** Deinitializes ES objects created during test execution */ 1179void MultisampleTextureGetTexLevelParametervInvalidTextureTargetRejectedTest::deinit() 1180{ 1181 /* Call base class' deinit() */ 1182 TestCase::deinit(); 1183} 1184 1185/** Executes test iteration. 1186 * 1187 * @return Returns STOP when test has finished executing. 1188 */ 1189tcu::TestNode::IterateResult MultisampleTextureGetTexLevelParametervInvalidTextureTargetRejectedTest::iterate() 1190{ 1191 const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 1192 1193 /* Call glGetTexLevelParameteriv() with invalid texture target. */ 1194 gl.getTexLevelParameteriv(GL_TEXTURE_WIDTH /* invalid value */, 0, /* level */ 1195 GL_TEXTURE_RED_TYPE, &int_data); 1196 1197 /* Expect GL_INVALID_ENUM error code. */ 1198 TCU_CHECK_MSG(gl.getError() == GL_INVALID_ENUM, 1199 "glGetTexLevelParameteriv() did not generate GL_INVALID_ENUM error."); 1200 1201 /* Call glGetTexLevelParameterfv() with invalid texture target. */ 1202 gl.getTexLevelParameterfv(GL_TEXTURE_WIDTH /* invalid value */, 0, /* level */ 1203 GL_TEXTURE_RED_TYPE, &float_data); 1204 1205 /* Expect GL_INVALID_ENUM error code. */ 1206 TCU_CHECK_MSG(gl.getError() == GL_INVALID_ENUM, 1207 "glGetTexLevelParameterfv() did not generate GL_INVALID_ENUM error."); 1208 1209 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); 1210 1211 return STOP; 1212} 1213 1214/** Constructor. 1215 * 1216 * @param context CTS context handle. 1217 **/ 1218MultisampleTextureGetTexLevelParametervInvalidValueArgumentRejectedTest:: 1219 MultisampleTextureGetTexLevelParametervInvalidValueArgumentRejectedTest(Context& context) 1220 : TestCase(context, "invalid_value_argument_rejected", "Verifies glGetTexLevelParameter{if}v() rejects invalid " 1221 "value argument by generating GL_INVALID_VALUE error.") 1222 , float_data(0.0f) 1223 , int_data(0) 1224{ 1225 /* Left blank on purpose */ 1226} 1227 1228/** Deinitializes ES objects created during test execution */ 1229void MultisampleTextureGetTexLevelParametervInvalidValueArgumentRejectedTest::deinit() 1230{ 1231 /* Call base class' deinit() */ 1232 TestCase::deinit(); 1233} 1234 1235/** Executes test iteration. 1236 * 1237 * @return Returns STOP when test has finished executing. 1238 */ 1239tcu::TestNode::IterateResult MultisampleTextureGetTexLevelParametervInvalidValueArgumentRejectedTest::iterate() 1240{ 1241 const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 1242 1243 /* Call glGetTexLevelParameteriv() with invalid value argument. */ 1244 gl.getTexLevelParameteriv(GL_TEXTURE_2D, 0, /* level */ 1245 GL_SIGNED_NORMALIZED /* invalid value */, &int_data); 1246 1247 /* From spec: 1248 * An INVALID_ENUM error is generated if pname is not one of the symbolic values in tables 6.12. 1249 */ 1250 1251 /* Expect INVALID_ENUM error code. */ 1252 glw::GLenum error_code = gl.getError(); 1253 1254 TCU_CHECK_MSG(error_code == GL_INVALID_ENUM, "glGetTexLevelParameteriv() did not generate GL_INVALID_ENUM error."); 1255 1256 /* Call glGetTexLevelParameterfv() with invalid value argument. */ 1257 gl.getTexLevelParameterfv(GL_TEXTURE_2D, 0, /* level */ 1258 GL_SIGNED_NORMALIZED /* invalid value */, &float_data); 1259 1260 /* Expect INVALID_ENUM error code. */ 1261 error_code = gl.getError(); 1262 1263 TCU_CHECK_MSG(error_code == GL_INVALID_ENUM, "glGetTexLevelParameterfv() did not generate GL_INVALID_ENUM error."); 1264 1265 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); 1266 1267 return STOP; 1268} 1269 1270/** Constructor. 1271 * 1272 * @param context CTS context handle. 1273 **/ 1274MultisampleTextureGetTexLevelParametervNegativeLodIsRejectedTest:: 1275 MultisampleTextureGetTexLevelParametervNegativeLodIsRejectedTest(Context& context) 1276 : TestCase(context, "negative_lod_is_rejected_test", "Verifies glGetTexLevelParameter{if}v() rejects negative " 1277 "<lod> by generating GL_INVALID_VALUE error.") 1278 , float_data(0.0f) 1279 , int_data(0) 1280 , to_id(0) 1281{ 1282 /* Left blank on purpose */ 1283} 1284 1285/** Deinitializes ES objects created during test execution */ 1286void MultisampleTextureGetTexLevelParametervNegativeLodIsRejectedTest::deinit() 1287{ 1288 const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 1289 1290 /* Bind default texture object to GL_TEXTURE_2D_MULTISAMPLE texture target. */ 1291 gl.bindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0); 1292 1293 /* Delete texture object. */ 1294 gl.deleteTextures(1, &to_id); 1295 1296 to_id = 0; 1297 1298 /* Check if no error was generated. */ 1299 GLU_EXPECT_NO_ERROR(gl.getError(), "Texture object deletion failed."); 1300 1301 /* Call base class' deinit() */ 1302 TestCase::deinit(); 1303} 1304 1305/** Initializes ES objects created during test execution */ 1306void MultisampleTextureGetTexLevelParametervNegativeLodIsRejectedTest::initInternals() 1307{ 1308 const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 1309 1310 /* Generate texture object id. */ 1311 gl.genTextures(1, &to_id); 1312 1313 /* Bind generated texture object ID to GL_TEXTURE_2D_MULTISAMPLE texture target. */ 1314 gl.bindTexture(GL_TEXTURE_2D_MULTISAMPLE, to_id); 1315 1316 /* Check if no error was generated. */ 1317 GLU_EXPECT_NO_ERROR(gl.getError(), "Texture object initialization failed."); 1318} 1319 1320/** Executes test iteration. 1321 * 1322 * @return Returns STOP when test has finished executing. 1323 */ 1324tcu::TestNode::IterateResult MultisampleTextureGetTexLevelParametervNegativeLodIsRejectedTest::iterate() 1325{ 1326 const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 1327 1328 initInternals(); 1329 1330 /* Set up texture storage. */ 1331 gl.texStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 1, /* samples */ 1332 GL_RGBA8, 16, /* width */ 1333 16, /* height */ 1334 GL_FALSE); 1335 1336 /* Check if no error was generated. */ 1337 GLU_EXPECT_NO_ERROR(gl.getError(), "Texture object initialization failed."); 1338 1339 /* Call glGetTexLevelParameteriv() with negative lod. */ 1340 gl.getTexLevelParameteriv(GL_TEXTURE_2D_MULTISAMPLE, -1 /* negative lod */, GL_TEXTURE_RED_TYPE, &int_data); 1341 1342 /* Expect GL_INVALID_VALUE error code. */ 1343 TCU_CHECK_MSG(gl.getError() == GL_INVALID_VALUE, 1344 "glGetTexLevelParameteriv() did not generate GL_INVALID_VALUE error."); 1345 1346 /* Call glGetTexLevelParameterfv() with negative lod. */ 1347 gl.getTexLevelParameterfv(GL_TEXTURE_2D_MULTISAMPLE, -1 /* negative lod */, GL_TEXTURE_RED_TYPE, &float_data); 1348 1349 /* Expect GL_INVALID_VALUE error code. */ 1350 TCU_CHECK_MSG(gl.getError() == GL_INVALID_VALUE, 1351 "glGetTexLevelParameterfv() did not generate GL_INVALID_VALUE error."); 1352 1353 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); 1354 1355 return STOP; 1356} 1357} /* glcts namespace */ 1358