Home | History | Annotate | Download | only in gl
      1 /*-------------------------------------------------------------------------
      2  * OpenGL Conformance Test Suite
      3  * -----------------------------
      4  *
      5  * Copyright (c) 2015-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  gl4cGetTextureSubImageTests.cpp
     27  * \brief Get Texture Sub Image Tests Suite Implementation
     28  */ /*-------------------------------------------------------------------*/
     29 
     30 /* Includes. */
     31 #include "gl4cGetTextureSubImageTests.hpp"
     32 #include "gluContextInfo.hpp"
     33 #include "gluDefs.hpp"
     34 #include "gluRenderContext.hpp"
     35 #include "gluStrUtil.hpp"
     36 #include "tcuTestLog.hpp"
     37 #include <cstdlib>
     38 
     39 /* Implementation */
     40 
     41 /**************************************************************************************************
     42  * Tests Group Implementation                                                                     *
     43  **************************************************************************************************/
     44 
     45 gl4cts::GetTextureSubImage::Tests::Tests(deqp::Context& context)
     46 	: TestCaseGroup(context, "get_texture_sub_image", "Get Texture Sub Image Tests Suite")
     47 {
     48 	addChild(new GetTextureSubImage::Errors(m_context));
     49 	addChild(new GetTextureSubImage::Functional(m_context));
     50 }
     51 
     52 gl4cts::GetTextureSubImage::Tests::~Tests(void)
     53 {
     54 }
     55 
     56 void gl4cts::GetTextureSubImage::Tests::init(void)
     57 {
     58 }
     59 
     60 /**************************************************************************************************
     61  * Errors Tests Implementation                                                                    *
     62  **************************************************************************************************/
     63 
     64 /** Constructor of API Errors tests.
     65  *
     66  *  @return [in] context    OpenGL context in which test shall run.
     67  */
     68 gl4cts::GetTextureSubImage::Errors::Errors(deqp::Context& context)
     69 	: deqp::TestCase(context, "errors_test", "Get Texture SubImage Errors Test")
     70 	, m_context(context)
     71 	, m_texture_1D(0)
     72 	, m_texture_1D_array(0)
     73 	, m_texture_2D(0)
     74 	, m_texture_rectangle(0)
     75 	, m_texture_2D_compressed(0)
     76 	, m_texture_2D_multisampled(0)
     77 	, m_destination_buffer(DE_NULL)
     78 	, m_gl_GetTextureSubImage(DE_NULL)
     79 	, m_gl_GetCompressedTextureSubImage(DE_NULL)
     80 {
     81 }
     82 
     83 /** Destructor of API Errors tests.
     84  */
     85 gl4cts::GetTextureSubImage::Errors::~Errors(void)
     86 {
     87 }
     88 
     89 /** This function iterate over API Errors tests.
     90  */
     91 tcu::TestNode::IterateResult gl4cts::GetTextureSubImage::Errors::iterate(void)
     92 {
     93 	bool is_ok		= true;
     94 	bool test_error = false;
     95 
     96 	bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
     97 	bool is_arb_get_texture_sub_image = m_context.getContextInfo().isExtensionSupported("GL_ARB_get_texture_sub_image");
     98 
     99 	try
    100 	{
    101 		if (is_at_least_gl_45 || is_arb_get_texture_sub_image)
    102 		{
    103 			/* Prepare texture objects */
    104 			prepare();
    105 
    106 			/* Do tests. */
    107 			is_ok &= testExistingTextureObjectError();
    108 
    109 			is_ok &= testBufferOrMultisampledTargetError();
    110 
    111 			is_ok &= testNegativeOffsetError();
    112 
    113 			is_ok &= testBoundsError();
    114 
    115 			is_ok &= testOneDimmensionalTextureErrors();
    116 
    117 			is_ok &= testTwoDimmensionalTextureErrors();
    118 
    119 			is_ok &= testBufferSizeError();
    120 		}
    121 	}
    122 	catch (...)
    123 	{
    124 		is_ok	  = false;
    125 		test_error = true;
    126 	}
    127 
    128 	/* Clean up */
    129 	clean();
    130 
    131 	/* Result's setup. */
    132 	if (is_ok)
    133 	{
    134 		m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
    135 	}
    136 	else
    137 	{
    138 		if (test_error)
    139 		{
    140 			m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
    141 		}
    142 		else
    143 		{
    144 			m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
    145 		}
    146 	}
    147 
    148 	return STOP;
    149 }
    150 
    151 /** Preparation of source textures and destination buffer.
    152  */
    153 void gl4cts::GetTextureSubImage::Errors::prepare()
    154 {
    155 	/* OpenGL functions access point. */
    156 	const glw::Functions& gl = m_context.getRenderContext().getFunctions();
    157 
    158 	/* If already initialized throw exception. */
    159 	if (m_texture_1D || m_texture_1D_array || m_texture_2D || m_texture_rectangle || m_texture_2D_compressed ||
    160 		m_texture_2D_multisampled)
    161 	{
    162 		throw 0;
    163 	}
    164 
    165 	/* Generate texture ids. */
    166 	gl.genTextures(1, &m_texture_1D);
    167 	gl.genTextures(1, &m_texture_1D_array);
    168 	gl.genTextures(1, &m_texture_2D);
    169 	gl.genTextures(1, &m_texture_rectangle);
    170 	gl.genTextures(1, &m_texture_2D_compressed);
    171 	gl.genTextures(1, &m_texture_2D_multisampled);
    172 
    173 	GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures call failed.");
    174 
    175 	/* If one is not initialized throw exception. */
    176 	if (!(m_texture_1D && m_texture_1D_array && m_texture_2D))
    177 	{
    178 		throw 0;
    179 	}
    180 
    181 	/* Upload texture data. */
    182 	gl.bindTexture(GL_TEXTURE_1D, m_texture_1D);
    183 	GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture call failed.");
    184 
    185 	gl.texImage1D(GL_TEXTURE_1D, 0, GL_RGBA8, s_texture_data_width, 0, GL_RGBA, GL_UNSIGNED_BYTE, s_texture_data);
    186 	GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D call failed.");
    187 
    188 	gl.bindTexture(GL_TEXTURE_1D_ARRAY, m_texture_1D_array);
    189 	GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture call failed.");
    190 
    191 	gl.texImage2D(GL_TEXTURE_1D_ARRAY, 0, GL_RGBA8, s_texture_data_width, s_texture_data_height, 0, GL_RGBA,
    192 				  GL_UNSIGNED_BYTE, s_texture_data);
    193 	GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D call failed.");
    194 
    195 	gl.bindTexture(GL_TEXTURE_2D, m_texture_2D);
    196 	GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture call failed.");
    197 
    198 	gl.texImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, s_texture_data_width, s_texture_data_height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
    199 				  s_texture_data);
    200 	GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D call failed.");
    201 
    202 	gl.bindTexture(GL_TEXTURE_RECTANGLE, m_texture_rectangle);
    203 	GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture call failed.");
    204 
    205 	gl.texImage2D(GL_TEXTURE_RECTANGLE, 0, GL_RGBA8, s_texture_data_width, s_texture_data_height, 0, GL_RGBA,
    206 				  GL_UNSIGNED_BYTE, s_texture_data);
    207 	GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D call failed.");
    208 
    209 	/* Upload compressed texture data. */
    210 	gl.bindTexture(GL_TEXTURE_2D, m_texture_2D_compressed);
    211 	GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture call failed.");
    212 
    213 	gl.compressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB8_ETC2, s_texture_data_compressed_width,
    214 							s_texture_data_compressed_height, 0, s_texture_data_compressed_size,
    215 							s_texture_data_compressed);
    216 	GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D call failed.");
    217 
    218 	/* Prepare multisampled texture storage. */
    219 	gl.bindTexture(GL_TEXTURE_2D_MULTISAMPLE, m_texture_2D_multisampled);
    220 	GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture call failed.");
    221 
    222 	gl.texImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 1, GL_R8, s_texture_data_width, s_texture_data_height, GL_TRUE);
    223 	GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D call failed.");
    224 
    225 	/* Prepare function pointers. */
    226 	m_gl_GetTextureSubImage =
    227 		(PFNGLGETTEXTURESUBIMAGEPROC)m_context.getRenderContext().getProcAddress("glGetTextureSubImage");
    228 	m_gl_GetCompressedTextureSubImage =
    229 		(PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC)m_context.getRenderContext().getProcAddress(
    230 			"glGetCompressedTextureSubImage");
    231 
    232 	if ((DE_NULL == m_gl_GetTextureSubImage) || (DE_NULL == m_gl_GetCompressedTextureSubImage))
    233 	{
    234 		throw 0;
    235 	}
    236 
    237 	/* Allocate destination buffer. */
    238 	m_destination_buffer = (glw::GLubyte*)malloc(s_destination_buffer_size);
    239 
    240 	if (DE_NULL == m_destination_buffer)
    241 	{
    242 		throw 0;
    243 	}
    244 }
    245 
    246 /** The function checks that GL_INVALID_OPERATION error is generated by GetTextureSubImage if
    247  *  texture is not the name of an existing texture object. It also checks that
    248  *  GL_INVALID_OPERATION error is generated by GetCompressedTextureSubImage if texture is not
    249  *  the name of an existing texture object. For reference see the OpenGL 4.5 Core Specification
    250  *  chapter 8.11.4.
    251  *
    252  *  @return True if proper error values are generated, false otherwise.
    253  */
    254 bool gl4cts::GetTextureSubImage::Errors::testExistingTextureObjectError()
    255 {
    256 	/* OpenGL functions access point. */
    257 	const glw::Functions& gl = m_context.getRenderContext().getFunctions();
    258 
    259 	/* Prepare invalid texture name. */
    260 	glw::GLuint invalid_texture = m_texture_2D_multisampled;
    261 
    262 	while (gl.isTexture(++invalid_texture))
    263 		;
    264 
    265 	m_gl_GetTextureSubImage(invalid_texture, 0, 0, 0, 0, s_texture_data_width, s_texture_data_height, 1, GL_RGBA,
    266 							GL_UNSIGNED_BYTE, s_destination_buffer_size, m_destination_buffer);
    267 
    268 	glw::GLint error_value	 = gl.getError();
    269 	glw::GLint is_proper_error = (GL_INVALID_OPERATION == error_value);
    270 
    271 	if (!is_proper_error)
    272 	{
    273 		m_testCtx.getLog() << tcu::TestLog::Message << "GL_INVALID_OPERATION error is expected to be generated by "
    274 													   "glGetTextureSubImage if texture is not the name of an existing "
    275 													   "texture object (OpenGL 4.5 Core Specification chapter 8.11.4)."
    276 						   << " However, the error value " << glu::getErrorName(error_value) << " was generated."
    277 						   << tcu::TestLog::EndMessage;
    278 	}
    279 
    280 	m_gl_GetCompressedTextureSubImage(invalid_texture, 0, 0, 0, 0, s_texture_data_compressed_width,
    281 									  s_texture_data_compressed_height, 1, s_destination_buffer_size,
    282 									  m_destination_buffer);
    283 
    284 	error_value = gl.getError();
    285 
    286 	glw::GLint is_proper_error_compressed = (GL_INVALID_OPERATION == error_value);
    287 
    288 	if (!is_proper_error_compressed)
    289 	{
    290 		m_testCtx.getLog() << tcu::TestLog::Message
    291 						   << "GL_INVALID_OPERATION error is expected to be generated by glGetCompressedTextureSubImage "
    292 							  "if texture is not the name of an existing texture object (OpenGL 4.5 Core Specification "
    293 							  "chapter 8.11.4)."
    294 						   << " However, the error value " << glu::getErrorName(error_value) << " was generated."
    295 						   << tcu::TestLog::EndMessage;
    296 	}
    297 
    298 	if (is_proper_error && is_proper_error_compressed)
    299 	{
    300 		return true;
    301 	}
    302 
    303 	return false;
    304 }
    305 
    306 /** The function checks that GL_INVALID_OPERATION error is generated if texture is the
    307  *  name of a buffer or multisample texture. For reference see OpenGL 4.5 Core Specification
    308  *  chapter 8.11.4.
    309  *
    310  *  @return True if proper error values are generated, false otherwise.
    311  */
    312 bool gl4cts::GetTextureSubImage::Errors::testBufferOrMultisampledTargetError()
    313 {
    314 	/* OpenGL functions access point. */
    315 	const glw::Functions& gl = m_context.getRenderContext().getFunctions();
    316 
    317 	/* Test. */
    318 	m_gl_GetTextureSubImage(m_texture_2D_multisampled, 0, 0, 0, 0, s_texture_data_width, s_texture_data_height, 1,
    319 							GL_RGBA, GL_UNSIGNED_BYTE, s_destination_buffer_size, m_destination_buffer);
    320 
    321 	glw::GLint error_value	 = gl.getError();
    322 	glw::GLint is_proper_error = (GL_INVALID_OPERATION == error_value);
    323 
    324 	if (!is_proper_error)
    325 	{
    326 		m_testCtx.getLog() << tcu::TestLog::Message << "GL_INVALID_OPERATION error is expected to be generated by "
    327 													   "glGetTextureSubImage if texture is the name of multisample "
    328 													   "texture (OpenGL 4.5 Core Specification chapter 8.11.4)."
    329 						   << " However, the error value " << glu::getErrorName(error_value) << " was generated."
    330 						   << tcu::TestLog::EndMessage;
    331 	}
    332 
    333 	if (is_proper_error)
    334 	{
    335 		return true;
    336 	}
    337 
    338 	return false;
    339 }
    340 
    341 /** The functions checks that GL_INVALID_VALUE is generated if xoffset, yoffset or
    342  *  zoffset are negative. For reference see OpenGL 4.5 Core Specification
    343  *  chapter 8.11.4.
    344  *
    345  *  @return True if proper error values are generated, false otherwise.
    346  */
    347 bool gl4cts::GetTextureSubImage::Errors::testNegativeOffsetError()
    348 {
    349 	/* OpenGL functions access point. */
    350 	const glw::Functions& gl = m_context.getRenderContext().getFunctions();
    351 
    352 	/* Test. */
    353 	m_gl_GetTextureSubImage(m_texture_2D, 0, -1, 0, 0, s_texture_data_width, s_texture_data_height, 1, GL_RGBA,
    354 							GL_UNSIGNED_BYTE, s_destination_buffer_size, m_destination_buffer);
    355 
    356 	glw::GLint error_value	 = gl.getError();
    357 	glw::GLint is_proper_error = (GL_INVALID_VALUE == error_value);
    358 
    359 	if (!is_proper_error)
    360 	{
    361 		m_testCtx.getLog() << tcu::TestLog::Message
    362 						   << "GL_INVALID_VALUE error is expected to be generated by glGetTextureSubImage if xoffset, "
    363 							  "yoffset or zoffset are negative (OpenGL 4.5 Core Specification chapter 8.11.4)."
    364 						   << " However, the error value " << glu::getErrorName(error_value) << " was generated."
    365 						   << tcu::TestLog::EndMessage;
    366 	}
    367 
    368 	m_gl_GetCompressedTextureSubImage(m_texture_2D_compressed, 0, -1, 0, 0, s_texture_data_compressed_width,
    369 									  s_texture_data_compressed_height, 1, s_destination_buffer_size,
    370 									  m_destination_buffer);
    371 
    372 	error_value = gl.getError();
    373 
    374 	glw::GLint is_proper_error_compressed = (GL_INVALID_VALUE == error_value);
    375 
    376 	if (!is_proper_error_compressed)
    377 	{
    378 		m_testCtx.getLog() << tcu::TestLog::Message
    379 						   << "GL_INVALID_VALUE error is expected to be generated by glGetCompressedTextureSubImage if "
    380 							  "xoffset, yoffset or zoffset are negative (OpenGL 4.5 Core Specification chapter 8.11.4)."
    381 						   << " However, the error value " << glu::getErrorName(error_value) << " was generated."
    382 						   << tcu::TestLog::EndMessage;
    383 	}
    384 
    385 	if (is_proper_error && is_proper_error_compressed)
    386 	{
    387 		return true;
    388 	}
    389 
    390 	return false;
    391 }
    392 
    393 /** The functions checks that GL_INVALID_VALUE is generated if xoffset + width is
    394  *  greater than the texture's width, yoffset + height is greater than
    395  *  the texture's height, or zoffset + depth is greater than the
    396  *  texture's depth. For reference see OpenGL 4.5 Core Specification
    397  *  chapter 8.11.4.
    398  *
    399  *  @return True if proper error values are generated, false otherwise.
    400  */
    401 bool gl4cts::GetTextureSubImage::Errors::testBoundsError()
    402 {
    403 	/* OpenGL functions access point. */
    404 	const glw::Functions& gl = m_context.getRenderContext().getFunctions();
    405 
    406 	/* Uncompresse texture test. */
    407 	m_gl_GetTextureSubImage(m_texture_2D, 0, s_texture_data_width, s_texture_data_height, 0, s_texture_data_width * 2,
    408 							s_texture_data_height * 2, 1, GL_RGBA, GL_UNSIGNED_BYTE, s_destination_buffer_size,
    409 							m_destination_buffer);
    410 
    411 	glw::GLint error_value	 = gl.getError();
    412 	glw::GLint is_proper_error = (GL_INVALID_VALUE == error_value);
    413 
    414 	if (!is_proper_error)
    415 	{
    416 		m_testCtx.getLog()
    417 			<< tcu::TestLog::Message
    418 			<< "GL_INVALID_VALUE error is expected to be generated by glGetTextureSubImage if xoffset + width is"
    419 			   " greater than the texture's width, yoffset + height is greater than"
    420 			   " the texture's height, or zoffset + depth is greater than the"
    421 			   " texture's depth. (OpenGL 4.5 Core Specification chapter 8.11.4)."
    422 			   " However, the error value "
    423 			<< glu::getErrorName(error_value) << " was generated." << tcu::TestLog::EndMessage;
    424 	}
    425 
    426 	/* Compresse texture test. */
    427 	m_gl_GetCompressedTextureSubImage(m_texture_2D_compressed, 0, s_texture_data_compressed_width,
    428 									  s_texture_data_compressed_height, 0, s_texture_data_compressed_width * 2,
    429 									  s_texture_data_compressed_height * 2, 1, s_destination_buffer_size,
    430 									  m_destination_buffer);
    431 
    432 	error_value = gl.getError();
    433 
    434 	glw::GLint is_proper_error_compressed = (GL_INVALID_VALUE == error_value);
    435 
    436 	if (!is_proper_error_compressed)
    437 	{
    438 		m_testCtx.getLog() << tcu::TestLog::Message
    439 						   << "GL_INVALID_VALUE error is expected to be generated by glGetCompressedTextureSubImage if "
    440 							  "xoffset + width is"
    441 							  " greater than the texture's width, yoffset + height is greater than"
    442 							  " the texture's height, or zoffset + depth is greater than the"
    443 							  " texture's depth. (OpenGL 4.5 Core Specification chapter 8.11.4)."
    444 							  " However, the error value "
    445 						   << glu::getErrorName(error_value) << " was generated." << tcu::TestLog::EndMessage;
    446 	}
    447 
    448 	if (is_proper_error && is_proper_error_compressed)
    449 	{
    450 		return true;
    451 	}
    452 
    453 	return false;
    454 }
    455 
    456 /** The functions checks that GL_INVALID_VALUE error is generated if the effective
    457  *  target is GL_TEXTURE_1D and either yoffset is not zero, or height
    458  *  is not one. For reference see OpenGL 4.5 Core Specification
    459  *  chapter 8.11.4.
    460  *
    461  *  @return True if proper error values are generated, false otherwise.
    462  */
    463 bool gl4cts::GetTextureSubImage::Errors::testOneDimmensionalTextureErrors()
    464 {
    465 	/* OpenGL functions access point. */
    466 	const glw::Functions& gl = m_context.getRenderContext().getFunctions();
    467 
    468 	/* Test. */
    469 	m_gl_GetTextureSubImage(m_texture_1D, 0, 0, 1, 0, s_texture_data_width, 2, 1, GL_RGBA, GL_UNSIGNED_BYTE,
    470 							s_destination_buffer_size, m_destination_buffer);
    471 
    472 	glw::GLint error_value	 = gl.getError();
    473 	glw::GLint is_proper_error = (GL_INVALID_VALUE == error_value);
    474 
    475 	if (!is_proper_error)
    476 	{
    477 		m_testCtx.getLog()
    478 			<< tcu::TestLog::Message
    479 			<< "GL_INVALID_VALUE error is expected to be generated by glGetTextureSubImage if the effective"
    480 			   " target is GL_TEXTURE_1D and either yoffset is not zero, or height"
    481 			   " is not one (OpenGL 4.5 Core Specification chapter 8.11.4)."
    482 			   " However, the error value "
    483 			<< glu::getErrorName(error_value) << " was generated." << tcu::TestLog::EndMessage;
    484 	}
    485 
    486 	if (is_proper_error)
    487 	{
    488 		return true;
    489 	}
    490 
    491 	return false;
    492 }
    493 
    494 /** The functions checks that GL_INVALID_VALUE error is generated if the effective
    495  *  target is GL_TEXTURE_1D, GL_TEXTURE_1D_ARRAY, GL_TEXTURE_2D or
    496  *  GL_TEXTURE_RECTANGLE and either zoffset is not zero, or depth
    497  *  is not one. For reference see OpenGL 4.5 Core Specification
    498  *  chapter 8.11.4.
    499  *
    500  *  @return True if proper error values are generated, false otherwise.
    501  */
    502 bool gl4cts::GetTextureSubImage::Errors::testTwoDimmensionalTextureErrors()
    503 {
    504 	/* OpenGL functions access point. */
    505 	const glw::Functions& gl = m_context.getRenderContext().getFunctions();
    506 
    507 	/* Test. */
    508 	static const struct
    509 	{
    510 		glw::GLuint		   id;
    511 		const glw::GLchar* target_name;
    512 	} test_textures[] = { { m_texture_1D, "GL_TEXTURE_1D" },
    513 						  { m_texture_1D_array, "GL_TEXTURE_1D_ARRAY" },
    514 						  { m_texture_2D, "GL_TEXTURE_2D" } };
    515 
    516 	static const glw::GLuint test_textures_size = sizeof(test_textures) / sizeof(test_textures[0]);
    517 
    518 	glw::GLint is_error = true;
    519 
    520 	for (glw::GLuint i = 0; i < test_textures_size; ++i)
    521 	{
    522 		m_gl_GetTextureSubImage(test_textures[i].id, 0, 0, 0, 1, s_texture_data_width,
    523 								(test_textures[i].id == GL_TEXTURE_1D) ? 1 : s_texture_data_height, 2, GL_RGBA,
    524 								GL_UNSIGNED_BYTE, s_destination_buffer_size, m_destination_buffer);
    525 
    526 		glw::GLint error_value	 = gl.getError();
    527 		glw::GLint is_proper_error = (GL_INVALID_VALUE == error_value);
    528 
    529 		if (!is_proper_error)
    530 		{
    531 			is_error = false;
    532 
    533 			m_testCtx.getLog()
    534 				<< tcu::TestLog::Message
    535 				<< "GL_INVALID_VALUE error is expected to be generated by glGetTextureSubImage if the effective"
    536 				   " target is "
    537 				<< test_textures[i].target_name << " and either zoffset is not zero, or depth"
    538 												   " is not one. (OpenGL 4.5 Core Specification chapter 8.11.4)."
    539 												   " However, the error value "
    540 				<< glu::getErrorName(error_value) << " was generated." << tcu::TestLog::EndMessage;
    541 		}
    542 	}
    543 
    544 	/* Test (compressed textures). */
    545 	static const struct
    546 	{
    547 		glw::GLuint		   id;
    548 		const glw::GLchar* target_name;
    549 	} test_compressed_textures[] = { { m_texture_2D_compressed, "GL_TEXTURE_2D" } };
    550 
    551 	static const glw::GLuint test_compressed_textures_size =
    552 		sizeof(test_compressed_textures) / sizeof(test_compressed_textures[0]);
    553 
    554 	for (glw::GLuint i = 0; i < test_compressed_textures_size; ++i)
    555 	{
    556 		m_gl_GetCompressedTextureSubImage(test_compressed_textures[i].id, 0, 0, 0, 1, s_texture_data_compressed_width,
    557 										  s_texture_data_compressed_height, 2, s_destination_buffer_size,
    558 										  m_destination_buffer);
    559 
    560 		glw::GLint error_value = gl.getError();
    561 
    562 		glw::GLint is_proper_error_compressed = (GL_INVALID_VALUE == error_value);
    563 
    564 		if (!is_proper_error_compressed)
    565 		{
    566 			is_error = false;
    567 
    568 			m_testCtx.getLog() << tcu::TestLog::Message << "GL_INVALID_VALUE error is expected to be generated by "
    569 														   "glGetCompressedTextureSubImage if the effective"
    570 														   " target is "
    571 							   << test_compressed_textures[i].target_name
    572 							   << " and either zoffset is not zero, or depth"
    573 								  " is not one. (OpenGL 4.5 Core Specification chapter 8.11.4)."
    574 								  " However, the error value "
    575 							   << glu::getErrorName(error_value) << " was generated." << tcu::TestLog::EndMessage;
    576 		}
    577 	}
    578 
    579 	if (is_error)
    580 	{
    581 		return true;
    582 	}
    583 
    584 	return false;
    585 }
    586 
    587 /** The functions checks that GL_INVALID_OPERATION error is generated if the buffer
    588  *  size required to store the requested data is greater than bufSize.
    589  *  For reference see OpenGL 4.5 Core Specification chapter 8.11.4.
    590  *
    591  *  @return True if proper error values are generated, false otherwise.
    592  */
    593 bool gl4cts::GetTextureSubImage::Errors::testBufferSizeError()
    594 {
    595 	/* OpenGL functions access point. */
    596 	const glw::Functions& gl = m_context.getRenderContext().getFunctions();
    597 
    598 	/* Test for uncompressed texture. */
    599 	m_gl_GetTextureSubImage(m_texture_2D, 0, 0, 0, 0, s_texture_data_width, s_texture_data_height, 1, GL_RGBA,
    600 							GL_UNSIGNED_BYTE, 1, m_destination_buffer);
    601 
    602 	glw::GLint error_value	 = gl.getError();
    603 	glw::GLint is_proper_error = (GL_INVALID_OPERATION == error_value);
    604 
    605 	if (!is_proper_error)
    606 	{
    607 		m_testCtx.getLog()
    608 			<< tcu::TestLog::Message
    609 			<< "GL_INVALID_OPERATION error is expected to be generated by glGetTextureSubImage if the buffer"
    610 			   " size required to store the requested data is greater than bufSize. (OpenGL 4.5 Core Specification "
    611 			   "chapter 8.11.4)."
    612 			   " However, the error value "
    613 			<< glu::getErrorName(error_value) << " was generated." << tcu::TestLog::EndMessage;
    614 	}
    615 
    616 	/* Test for compressed texture. */
    617 	m_gl_GetCompressedTextureSubImage(m_texture_2D_compressed, 0, 0, 0, 0, s_texture_data_compressed_width,
    618 									  s_texture_data_compressed_height, 1, 1, m_destination_buffer);
    619 
    620 	error_value = gl.getError();
    621 
    622 	glw::GLint is_proper_error_compressed = (GL_INVALID_OPERATION == error_value);
    623 
    624 	if (!is_proper_error_compressed)
    625 	{
    626 		m_testCtx.getLog()
    627 			<< tcu::TestLog::Message
    628 			<< "GL_INVALID_OPERATION error is expected to be generated by glGetCompressedTextureSubImage if the buffer"
    629 			   " size required to store the requested data is greater than bufSize. (OpenGL 4.5 Core Specification "
    630 			   "chapter 8.11.4)."
    631 			   " However, the error value "
    632 			<< glu::getErrorName(error_value) << " was generated." << tcu::TestLog::EndMessage;
    633 	}
    634 
    635 	/* Return results. */
    636 	if (is_proper_error && is_proper_error_compressed)
    637 	{
    638 		return true;
    639 	}
    640 
    641 	return false;
    642 }
    643 
    644 void gl4cts::GetTextureSubImage::Errors::clean()
    645 {
    646 	/* OpenGL functions access point. */
    647 	const glw::Functions& gl = m_context.getRenderContext().getFunctions();
    648 
    649 	/*Textures cleanup. */
    650 	if (m_texture_1D)
    651 	{
    652 		gl.deleteTextures(1, &m_texture_1D);
    653 		m_texture_1D = 0;
    654 	}
    655 
    656 	if (m_texture_1D_array)
    657 	{
    658 		gl.deleteTextures(1, &m_texture_1D_array);
    659 		m_texture_1D_array = 0;
    660 	}
    661 
    662 	if (m_texture_2D)
    663 	{
    664 		gl.deleteTextures(1, &m_texture_2D);
    665 		m_texture_2D = 0;
    666 	}
    667 	if (m_texture_rectangle)
    668 	{
    669 		gl.deleteTextures(1, &m_texture_rectangle);
    670 		m_texture_rectangle = 0;
    671 	}
    672 
    673 	if (m_texture_2D_compressed)
    674 	{
    675 		gl.deleteTextures(1, &m_texture_2D_compressed);
    676 		m_texture_2D_compressed = 0;
    677 	}
    678 
    679 	if (m_texture_2D_multisampled)
    680 	{
    681 		gl.deleteTextures(1, &m_texture_2D_multisampled);
    682 		m_texture_2D_multisampled = 0;
    683 	}
    684 
    685 	/* CPU buffers */
    686 	if (m_destination_buffer)
    687 	{
    688 		free(m_destination_buffer);
    689 		m_destination_buffer = DE_NULL;
    690 	}
    691 }
    692 
    693 /* Uncompressed source texture 2x2 pixels */
    694 
    695 const glw::GLubyte gl4cts::GetTextureSubImage::Errors::s_texture_data[] = {
    696 	0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
    697 }; //<! uncompressed texture
    698 
    699 const glw::GLuint gl4cts::GetTextureSubImage::Errors::s_texture_data_size =
    700 	sizeof(s_texture_data); //<! uncompressed texture size
    701 
    702 const glw::GLuint gl4cts::GetTextureSubImage::Errors::s_texture_data_width = 2; //<! uncompressed texture width
    703 
    704 const glw::GLuint gl4cts::GetTextureSubImage::Errors::s_texture_data_height = 2; //<! uncompressed texture height
    705 
    706 /* ETC2 compressed texture (4x4 pixels === 1 block) */
    707 
    708 const glw::GLubyte gl4cts::GetTextureSubImage::Errors::s_texture_data_compressed[] = {
    709 	0x15, 0x90, 0x33, 0x6f, 0xaf, 0xcc, 0x16, 0x98
    710 }; //<! ETC2 compressed texture
    711 
    712 const glw::GLuint gl4cts::GetTextureSubImage::Errors::s_texture_data_compressed_size =
    713 	sizeof(s_texture_data_compressed); //<! ETC2 compressed texture size
    714 
    715 const glw::GLuint gl4cts::GetTextureSubImage::Errors::s_texture_data_compressed_width =
    716 	4; //<! ETC2 compressed texture width
    717 
    718 const glw::GLuint gl4cts::GetTextureSubImage::Errors::s_texture_data_compressed_height =
    719 	4; //<! ETC2 compressed texture height
    720 
    721 const glw::GLuint gl4cts::GetTextureSubImage::Errors::s_destination_buffer_size =
    722 	(s_texture_data_size > s_texture_data_compressed_size) ?
    723 		s_texture_data_size :
    724 		s_texture_data_compressed_size; //<! size of the destination buffer (for fetched data)
    725 
    726 /*****************************************************************************************************
    727  * Functional Test Implementation                                                                    *
    728  *****************************************************************************************************/
    729 
    730 /** Constructor of the functional test.
    731  *
    732  *  @param [in] context     OpenGL context in which test shall run.
    733  */
    734 gl4cts::GetTextureSubImage::Functional::Functional(deqp::Context& context)
    735 	: deqp::TestCase(context, "functional_test", "Get Texture SubImage Functional Test")
    736 	, m_context(context)
    737 	, m_texture(0)
    738 {
    739 }
    740 
    741 /** Destructor of the functional test.
    742  */
    743 gl4cts::GetTextureSubImage::Functional::~Functional(void)
    744 {
    745 }
    746 
    747 /** Iterate over functional test cases.
    748  */
    749 tcu::TestNode::IterateResult gl4cts::GetTextureSubImage::Functional::iterate(void)
    750 {
    751 	bool is_ok		= true;
    752 	bool test_error = false;
    753 
    754 	bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
    755 	bool is_arb_get_texture_sub_image = m_context.getContextInfo().isExtensionSupported("GL_ARB_get_texture_sub_image");
    756 
    757 	/* Bind function pointers. */
    758 	m_gl_GetCompressedTextureSubImage =
    759 		(PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC)m_context.getRenderContext().getProcAddress(
    760 			"glGetCompressedTextureSubImage");
    761 	m_gl_GetTextureSubImage =
    762 		(PFNGLGETTEXTURESUBIMAGEPROC)m_context.getRenderContext().getProcAddress("glGetTextureSubImage");
    763 
    764 	try
    765 	{
    766 		/* Report error when function pointers are not available. */
    767 		if ((DE_NULL == m_gl_GetCompressedTextureSubImage) || (DE_NULL == m_gl_GetTextureSubImage))
    768 		{
    769 			m_testCtx.getLog()
    770 				<< tcu::TestLog::Message
    771 				<< "Cannot obtain glGetCompressedTextureSubImage or glGetTextureSubImage function pointer."
    772 				<< tcu::TestLog::EndMessage;
    773 			throw 0;
    774 		}
    775 
    776 		/* Run tests. */
    777 		if (is_at_least_gl_45 || is_arb_get_texture_sub_image)
    778 		{
    779 			/* Tested targets. */
    780 			glw::GLenum targets[] = { GL_TEXTURE_1D,		GL_TEXTURE_1D_ARRAY, GL_TEXTURE_2D,
    781 									  GL_TEXTURE_RECTANGLE, GL_TEXTURE_CUBE_MAP, GL_TEXTURE_CUBE_MAP_ARRAY,
    782 									  GL_TEXTURE_2D_ARRAY,  GL_TEXTURE_3D };
    783 
    784 			glw::GLuint targets_count = sizeof(targets) / sizeof(targets[0]);
    785 
    786 			for (glw::GLuint i = 0; i < targets_count; ++i)
    787 			{
    788 				prepare(targets[i], false);
    789 
    790 				is_ok &= check(targets[i], false);
    791 
    792 				clean();
    793 			}
    794 
    795 			/* Compressed textures tested targets. */
    796 			glw::GLenum compressed_targets[] = { GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP, GL_TEXTURE_CUBE_MAP_ARRAY,
    797 												 GL_TEXTURE_2D_ARRAY };
    798 
    799 			glw::GLuint compressed_targets_count = sizeof(compressed_targets) / sizeof(compressed_targets[0]);
    800 
    801 			for (glw::GLuint i = 0; i < compressed_targets_count; ++i)
    802 			{
    803 				prepare(compressed_targets[i], true);
    804 
    805 				is_ok &= check(compressed_targets[i], true);
    806 
    807 				clean();
    808 			}
    809 		}
    810 	}
    811 	catch (...)
    812 	{
    813 		m_testCtx.getLog() << tcu::TestLog::Message << "Test error has occured." << tcu::TestLog::EndMessage;
    814 
    815 		is_ok	  = false;
    816 		test_error = true;
    817 
    818 		clean();
    819 	}
    820 
    821 	/* Result's setup. */
    822 	if (is_ok)
    823 	{
    824 		m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
    825 	}
    826 	else
    827 	{
    828 		if (test_error)
    829 		{
    830 			m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
    831 		}
    832 		else
    833 		{
    834 			m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
    835 		}
    836 	}
    837 
    838 	return STOP;
    839 }
    840 
    841 /** Prepare source texture for the test.
    842  *
    843  *  @param [in] target          Target of the texture to be prepared.
    844  *  @param [in] is_compressed   Flag indicating that texture shall be compressed (true) or uncompressed (false).
    845  */
    846 void gl4cts::GetTextureSubImage::Functional::prepare(glw::GLenum target, bool is_compressed)
    847 {
    848 	/* OpenGL functions access point. */
    849 	const glw::Functions& gl = m_context.getRenderContext().getFunctions();
    850 
    851 	/* Generate and bind texture. */
    852 	gl.genTextures(1, &m_texture);
    853 	GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures call failed.");
    854 
    855 	gl.bindTexture(target, m_texture);
    856 	GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture call failed.");
    857 
    858 	/* Upload data to the texture. */
    859 	if (is_compressed)
    860 	{
    861 		/* Upload compressed texture. */
    862 		switch (target)
    863 		{
    864 		case GL_TEXTURE_2D:
    865 			gl.compressedTexImage2D(target, 0, GL_COMPRESSED_RGBA_BPTC_UNORM, s_texture_data_width, s_texture_data_height, 0,
    866 									s_texture_data_compressed_size / s_texture_data_depth, s_texture_data_compressed);
    867 			GLU_EXPECT_NO_ERROR(gl.getError(), "glCompressedTexImage2D call failed.");
    868 			break;
    869 		case GL_TEXTURE_CUBE_MAP:
    870 			gl.compressedTexImage2D(
    871 				GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA_BPTC_UNORM, s_texture_data_width, s_texture_data_height,
    872 				0, s_texture_data_compressed_size / s_texture_data_depth,
    873 				&s_texture_data_compressed[0 * s_texture_data_compressed_size / s_texture_data_depth]);
    874 			gl.compressedTexImage2D(
    875 				GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA_BPTC_UNORM, s_texture_data_width, s_texture_data_height,
    876 				0, s_texture_data_compressed_size / s_texture_data_depth,
    877 				&s_texture_data_compressed[1 * s_texture_data_compressed_size / s_texture_data_depth]);
    878 			gl.compressedTexImage2D(
    879 				GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA_BPTC_UNORM, s_texture_data_width, s_texture_data_height,
    880 				0, s_texture_data_compressed_size / s_texture_data_depth,
    881 				&s_texture_data_compressed[2 * s_texture_data_compressed_size / s_texture_data_depth]);
    882 			gl.compressedTexImage2D(
    883 				GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA_BPTC_UNORM, s_texture_data_width, s_texture_data_height,
    884 				0, s_texture_data_compressed_size / s_texture_data_depth,
    885 				&s_texture_data_compressed[3 * s_texture_data_compressed_size / s_texture_data_depth]);
    886 			gl.compressedTexImage2D(
    887 				GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA_BPTC_UNORM, s_texture_data_width, s_texture_data_height,
    888 				0, s_texture_data_compressed_size / s_texture_data_depth,
    889 				&s_texture_data_compressed[4 * s_texture_data_compressed_size / s_texture_data_depth]);
    890 			gl.compressedTexImage2D(
    891 				GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA_BPTC_UNORM, s_texture_data_width, s_texture_data_height,
    892 				0, s_texture_data_compressed_size / s_texture_data_depth,
    893 				&s_texture_data_compressed[5 * s_texture_data_compressed_size / s_texture_data_depth]);
    894 			GLU_EXPECT_NO_ERROR(gl.getError(), "glCompressedTexImage2D call failed.");
    895 			break;
    896 		case GL_TEXTURE_CUBE_MAP_ARRAY:
    897 			gl.compressedTexImage3D(target, 0, GL_COMPRESSED_RGBA_BPTC_UNORM, s_texture_data_width, s_texture_data_height, 6,
    898 									0, s_texture_data_compressed_size / s_texture_data_depth * 6,
    899 									s_texture_data_compressed);
    900 			GLU_EXPECT_NO_ERROR(gl.getError(), "glCompressedTexImage3D call failed.");
    901 			break;
    902 		case GL_TEXTURE_2D_ARRAY:
    903 			gl.compressedTexImage3D(target, 0, GL_COMPRESSED_RGBA_BPTC_UNORM, s_texture_data_width, s_texture_data_height,
    904 									s_texture_data_depth, 0, s_texture_data_compressed_size, s_texture_data_compressed);
    905 			GLU_EXPECT_NO_ERROR(gl.getError(), "glCompressedTexImage3D call failed.");
    906 			break;
    907 		default:
    908 			throw 0;
    909 		};
    910 	}
    911 	else
    912 	{
    913 		/* Upload uncompressed texture. */
    914 		switch (target)
    915 		{
    916 		case GL_TEXTURE_1D:
    917 			gl.texImage1D(target, 0, GL_RGBA8, s_texture_data_width, 0, GL_RGBA, GL_UNSIGNED_BYTE, s_texture_data);
    918 			GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D call failed.");
    919 			break;
    920 		case GL_TEXTURE_1D_ARRAY:
    921 		case GL_TEXTURE_2D:
    922 		case GL_TEXTURE_RECTANGLE:
    923 			gl.texImage2D(target, 0, GL_RGBA8, s_texture_data_width, s_texture_data_height, 0, GL_RGBA,
    924 						  GL_UNSIGNED_BYTE, s_texture_data);
    925 			GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D call failed.");
    926 			break;
    927 		case GL_TEXTURE_CUBE_MAP:
    928 			gl.texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA8, s_texture_data_width, s_texture_data_height, 0,
    929 						  GL_RGBA, GL_UNSIGNED_BYTE,
    930 						  &s_texture_data[0 * s_texture_data_width * s_texture_data_height * 4 /* RGBA */]);
    931 			gl.texImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGBA8, s_texture_data_width, s_texture_data_height, 0,
    932 						  GL_RGBA, GL_UNSIGNED_BYTE,
    933 						  &s_texture_data[1 * s_texture_data_width * s_texture_data_height * 4 /* RGBA */]);
    934 			gl.texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGBA8, s_texture_data_width, s_texture_data_height, 0,
    935 						  GL_RGBA, GL_UNSIGNED_BYTE,
    936 						  &s_texture_data[2 * s_texture_data_width * s_texture_data_height * 4 /* RGBA */]);
    937 			gl.texImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA8, s_texture_data_width, s_texture_data_height, 0,
    938 						  GL_RGBA, GL_UNSIGNED_BYTE,
    939 						  &s_texture_data[3 * s_texture_data_width * s_texture_data_height * 4 /* RGBA */]);
    940 			gl.texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGBA8, s_texture_data_width, s_texture_data_height, 0,
    941 						  GL_RGBA, GL_UNSIGNED_BYTE,
    942 						  &s_texture_data[4 * s_texture_data_width * s_texture_data_height * 4 /* RGBA */]);
    943 			gl.texImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA8, s_texture_data_width, s_texture_data_height, 0,
    944 						  GL_RGBA, GL_UNSIGNED_BYTE,
    945 						  &s_texture_data[5 * s_texture_data_width * s_texture_data_height * 4 /* RGBA */]);
    946 			GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D call failed.");
    947 			break;
    948 		case GL_TEXTURE_CUBE_MAP_ARRAY:
    949 			gl.texImage3D(target, 0, GL_RGBA8, s_texture_data_width, s_texture_data_height, 6, 0, GL_RGBA,
    950 						  GL_UNSIGNED_BYTE, s_texture_data);
    951 			GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage3D call failed.");
    952 			break;
    953 		case GL_TEXTURE_2D_ARRAY:
    954 		case GL_TEXTURE_3D:
    955 			gl.texImage3D(target, 0, GL_RGBA8, s_texture_data_width, s_texture_data_height, s_texture_data_depth, 0,
    956 						  GL_RGBA, GL_UNSIGNED_BYTE, s_texture_data);
    957 			GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage3D call failed.");
    958 			break;
    959 		default:
    960 			throw 0;
    961 		};
    962 	}
    963 }
    964 
    965 /** Test that Get(Compressed)TextureSubImage resturns expected texture data.
    966  *
    967  *  @param [in] target          Target of the texture to be prepared.
    968  *  @param [in] is_compressed   Flag indicating that texture shall be compressed (true) or uncompressed (false).
    969  *
    970  *  @return True if test succeeded, false otherwise.
    971  */
    972 bool gl4cts::GetTextureSubImage::Functional::check(glw::GLenum target, bool is_compressed)
    973 {
    974 	/* OpenGL functions access point. */
    975 	const glw::Functions& gl = m_context.getRenderContext().getFunctions();
    976 
    977 	/* Arguments setup (depends on dimmension) */
    978 	glw::GLint x_offset = s_texture_data_width / 2 /* half */;
    979 	glw::GLint width	= s_texture_data_width / 2 /* half */;
    980 
    981 	glw::GLint y_offset = 0;
    982 	glw::GLint height   = 1;
    983 
    984 	glw::GLint z_offset = 0;
    985 	glw::GLint depth	= 1;
    986 
    987 	/* For 2 and 3 -dimensional textures setup y-direction. */
    988 	if (GL_TEXTURE_1D != target)
    989 	{
    990 		y_offset = s_texture_data_height / 2 /* half */;
    991 		height   = s_texture_data_height / 2 /* half */;
    992 	}
    993 
    994 	/* For 3-dimensional textures setup z-direction. */
    995 	if ((GL_TEXTURE_3D == target) || (GL_TEXTURE_2D_ARRAY == target))
    996 	{
    997 		z_offset = s_texture_data_depth / 2 /* half */;
    998 		depth	= s_texture_data_depth / 2 /* half */;
    999 	}
   1000 
   1001 	/* For cube-map texture stup 6-cube faces. */
   1002 	if ((GL_TEXTURE_CUBE_MAP == target) || (GL_TEXTURE_CUBE_MAP_ARRAY == target))
   1003 	{
   1004 		z_offset = 3; /* half of cube map */
   1005 		depth	= 3; /* half of cube map */
   1006 	}
   1007 
   1008 	/* Setup number of components. */
   1009 	glw::GLint number_of_components = 0;
   1010 
   1011 	if (is_compressed)
   1012 	{
   1013 		number_of_components = 16; /* 128 bit block of 4x4 compressed pixels. */
   1014 	}
   1015 	else
   1016 	{
   1017 		number_of_components = 4; /* RGBA components. */
   1018 	}
   1019 
   1020 	/* Setup size. */
   1021 	glw::GLsizei size = 0;
   1022 
   1023 	/* Iterate over pixels. */
   1024 	glw::GLint x_block = 1;
   1025 	glw::GLint y_block = 1;
   1026 
   1027 	if (is_compressed)
   1028 	{
   1029 		/* Iterate over 4x4 compressed pixel block. */
   1030 		x_block = 4;
   1031 		y_block = 4;
   1032 
   1033 		size = static_cast<glw::GLsizei>((width / x_block) * (height / y_block) * depth * number_of_components *
   1034 										 sizeof(glw::GLubyte));
   1035 	}
   1036 	else
   1037 	{
   1038 		size = static_cast<glw::GLsizei>(width * height * depth * number_of_components * sizeof(glw::GLubyte));
   1039 	}
   1040 
   1041 	/* Storage for fetched texturte. */
   1042 	glw::GLubyte* texture_data = new glw::GLubyte[size];
   1043 
   1044 	if (DE_NULL == texture_data)
   1045 	{
   1046 		throw 0;
   1047 	}
   1048 
   1049 	/* Fetching texture. */
   1050 	if (is_compressed)
   1051 	{
   1052 		m_gl_GetCompressedTextureSubImage(m_texture, 0, x_offset, y_offset, z_offset, width, height, depth, size,
   1053 										  texture_data);
   1054 	}
   1055 	else
   1056 	{
   1057 		m_gl_GetTextureSubImage(m_texture, 0, x_offset, y_offset, z_offset, width, height, depth, GL_RGBA,
   1058 								GL_UNSIGNED_BYTE, size, texture_data);
   1059 	}
   1060 
   1061 	/* Comprae fetched texture with reference. */
   1062 	glw::GLint error = gl.getError();
   1063 
   1064 	bool is_ok = true;
   1065 
   1066 	if (GL_NO_ERROR == error)
   1067 	{
   1068 		for (glw::GLint k = 0; k < depth; ++k)
   1069 		{
   1070 			for (glw::GLint j = 0; j < height / y_block; ++j)
   1071 			{
   1072 				for (glw::GLint i = 0; i < width / x_block; ++i)
   1073 				{
   1074 					for (glw::GLint c = 0; c < number_of_components; ++c) /* RGBA components iterating */
   1075 					{
   1076 						glw::GLuint reference_data_position =
   1077 							(i + (x_offset / x_block)) * number_of_components +
   1078 							(j + (y_offset / y_block)) * s_texture_data_width / x_block * number_of_components +
   1079 							(k + z_offset) * s_texture_data_width / x_block * s_texture_data_height / y_block *
   1080 								number_of_components +
   1081 							c;
   1082 
   1083 						glw::GLuint tested_data_position =
   1084 							i * number_of_components + j * width / x_block * number_of_components +
   1085 							k * width / x_block * height / y_block * number_of_components + c;
   1086 
   1087 						glw::GLubyte reference_value = (is_compressed) ?
   1088 														   s_texture_data_compressed[reference_data_position] :
   1089 														   s_texture_data[reference_data_position];
   1090 						glw::GLubyte tested_value = texture_data[tested_data_position];
   1091 
   1092 						if (reference_value != tested_value)
   1093 						{
   1094 							is_ok = false;
   1095 							break;
   1096 						}
   1097 					}
   1098 				}
   1099 			}
   1100 		}
   1101 	}
   1102 	else
   1103 	{
   1104 		/* GL error. */
   1105 		delete[] texture_data;
   1106 		throw 0;
   1107 	}
   1108 
   1109 	/* Cleanup. */
   1110 	delete[] texture_data;
   1111 
   1112 	/* Error reporting. */
   1113 	if (!is_ok)
   1114 	{
   1115 		m_testCtx.getLog() << tcu::TestLog::Message << "Functional test of "
   1116 						   << ((is_compressed) ? "glGetCompressedTextureSubImage " : "glGetTextureSubImage ")
   1117 						   << "function has failed with target " << glu::getTextureTargetStr(target) << "."
   1118 						   << tcu::TestLog::EndMessage;
   1119 	}
   1120 
   1121 	/* Return result. */
   1122 	return is_ok;
   1123 }
   1124 
   1125 /** Clean texture. */
   1126 void gl4cts::GetTextureSubImage::Functional::clean()
   1127 {
   1128 	/* OpenGL functions access point. */
   1129 	const glw::Functions& gl = m_context.getRenderContext().getFunctions();
   1130 
   1131 	if (m_texture)
   1132 	{
   1133 		gl.deleteTextures(1, &m_texture);
   1134 
   1135 		m_texture = 0;
   1136 	}
   1137 }
   1138 
   1139 /** RGBA 8x8x8 pixels in size source texture for testing GetTextureSubImage. */
   1140 const glw::GLubyte gl4cts::GetTextureSubImage::Functional::s_texture_data[] = {
   1141 	0,   0,   0,   0,  0,   0,   32,  1,  0,   0,   64,  2,  0,   0,   96,  3,
   1142 	0,   0,   128, 4,  0,   0,   160, 5,  0,   0,   192, 6,  0,   0,   224, 7,
   1143 
   1144 	0,   32,  0,   1,  0,   32,  32,  2,  0,   32,  64,  3,  0,   32,  96,  4,
   1145 	0,   32,  128, 5,  0,   32,  160, 6,  0,   32,  192, 7,  0,   32,  224, 8,
   1146 
   1147 	0,   64,  0,   2,  0,   64,  32,  3,  0,   64,  64,  4,  0,   64,  96,  5,
   1148 	0,   64,  128, 6,  0,   64,  160, 7,  0,   64,  192, 8,  0,   64,  224, 9,
   1149 
   1150 	0,   96,  0,   3,  0,   96,  32,  4,  0,   96,  64,  5,  0,   96,  96,  6,
   1151 	0,   96,  128, 7,  0,   96,  160, 8,  0,   96,  192, 9,  0,   96,  224, 10,
   1152 
   1153 	0,   128, 0,   4,  0,   128, 32,  5,  0,   128, 64,  6,  0,   128, 96,  7,
   1154 	0,   128, 128, 8,  0,   128, 160, 9,  0,   128, 192, 10, 0,   128, 224, 11,
   1155 
   1156 	0,   160, 0,   5,  0,   160, 32,  6,  0,   160, 64,  7,  0,   160, 96,  8,
   1157 	0,   160, 128, 9,  0,   160, 160, 10, 0,   160, 192, 11, 0,   160, 224, 12,
   1158 
   1159 	0,   192, 0,   6,  0,   192, 32,  7,  0,   192, 64,  8,  0,   192, 96,  9,
   1160 	0,   192, 128, 10, 0,   192, 160, 11, 0,   192, 192, 12, 0,   192, 224, 13,
   1161 
   1162 	0,   224, 0,   7,  0,   224, 32,  8,  0,   224, 64,  9,  0,   224, 96,  10,
   1163 	0,   224, 128, 11, 0,   224, 160, 12, 0,   224, 192, 13, 0,   224, 224, 14,
   1164 
   1165 	32,  0,   0,   1,  32,  0,   32,  2,  32,  0,   64,  3,  32,  0,   96,  4,
   1166 	32,  0,   128, 5,  32,  0,   160, 6,  32,  0,   192, 7,  32,  0,   224, 8,
   1167 
   1168 	32,  32,  0,   2,  32,  32,  32,  3,  32,  32,  64,  4,  32,  32,  96,  5,
   1169 	32,  32,  128, 6,  32,  32,  160, 7,  32,  32,  192, 8,  32,  32,  224, 9,
   1170 
   1171 	32,  64,  0,   3,  32,  64,  32,  4,  32,  64,  64,  5,  32,  64,  96,  6,
   1172 	32,  64,  128, 7,  32,  64,  160, 8,  32,  64,  192, 9,  32,  64,  224, 10,
   1173 
   1174 	32,  96,  0,   4,  32,  96,  32,  5,  32,  96,  64,  6,  32,  96,  96,  7,
   1175 	32,  96,  128, 8,  32,  96,  160, 9,  32,  96,  192, 10, 32,  96,  224, 11,
   1176 
   1177 	32,  128, 0,   5,  32,  128, 32,  6,  32,  128, 64,  7,  32,  128, 96,  8,
   1178 	32,  128, 128, 9,  32,  128, 160, 10, 32,  128, 192, 11, 32,  128, 224, 12,
   1179 
   1180 	32,  160, 0,   6,  32,  160, 32,  7,  32,  160, 64,  8,  32,  160, 96,  9,
   1181 	32,  160, 128, 10, 32,  160, 160, 11, 32,  160, 192, 12, 32,  160, 224, 13,
   1182 
   1183 	32,  192, 0,   7,  32,  192, 32,  8,  32,  192, 64,  9,  32,  192, 96,  10,
   1184 	32,  192, 128, 11, 32,  192, 160, 12, 32,  192, 192, 13, 32,  192, 224, 14,
   1185 
   1186 	32,  224, 0,   8,  32,  224, 32,  9,  32,  224, 64,  10, 32,  224, 96,  11,
   1187 	32,  224, 128, 12, 32,  224, 160, 13, 32,  224, 192, 14, 32,  224, 224, 15,
   1188 
   1189 	64,  0,   0,   2,  64,  0,   32,  3,  64,  0,   64,  4,  64,  0,   96,  5,
   1190 	64,  0,   128, 6,  64,  0,   160, 7,  64,  0,   192, 8,  64,  0,   224, 9,
   1191 
   1192 	64,  32,  0,   3,  64,  32,  32,  4,  64,  32,  64,  5,  64,  32,  96,  6,
   1193 	64,  32,  128, 7,  64,  32,  160, 8,  64,  32,  192, 9,  64,  32,  224, 10,
   1194 
   1195 	64,  64,  0,   4,  64,  64,  32,  5,  64,  64,  64,  6,  64,  64,  96,  7,
   1196 	64,  64,  128, 8,  64,  64,  160, 9,  64,  64,  192, 10, 64,  64,  224, 11,
   1197 
   1198 	64,  96,  0,   5,  64,  96,  32,  6,  64,  96,  64,  7,  64,  96,  96,  8,
   1199 	64,  96,  128, 9,  64,  96,  160, 10, 64,  96,  192, 11, 64,  96,  224, 12,
   1200 
   1201 	64,  128, 0,   6,  64,  128, 32,  7,  64,  128, 64,  8,  64,  128, 96,  9,
   1202 	64,  128, 128, 10, 64,  128, 160, 11, 64,  128, 192, 12, 64,  128, 224, 13,
   1203 
   1204 	64,  160, 0,   7,  64,  160, 32,  8,  64,  160, 64,  9,  64,  160, 96,  10,
   1205 	64,  160, 128, 11, 64,  160, 160, 12, 64,  160, 192, 13, 64,  160, 224, 14,
   1206 
   1207 	64,  192, 0,   8,  64,  192, 32,  9,  64,  192, 64,  10, 64,  192, 96,  11,
   1208 	64,  192, 128, 12, 64,  192, 160, 13, 64,  192, 192, 14, 64,  192, 224, 15,
   1209 
   1210 	64,  224, 0,   9,  64,  224, 32,  10, 64,  224, 64,  11, 64,  224, 96,  12,
   1211 	64,  224, 128, 13, 64,  224, 160, 14, 64,  224, 192, 15, 64,  224, 224, 16,
   1212 
   1213 	96,  0,   0,   3,  96,  0,   32,  4,  96,  0,   64,  5,  96,  0,   96,  6,
   1214 	96,  0,   128, 7,  96,  0,   160, 8,  96,  0,   192, 9,  96,  0,   224, 10,
   1215 
   1216 	96,  32,  0,   4,  96,  32,  32,  5,  96,  32,  64,  6,  96,  32,  96,  7,
   1217 	96,  32,  128, 8,  96,  32,  160, 9,  96,  32,  192, 10, 96,  32,  224, 11,
   1218 
   1219 	96,  64,  0,   5,  96,  64,  32,  6,  96,  64,  64,  7,  96,  64,  96,  8,
   1220 	96,  64,  128, 9,  96,  64,  160, 10, 96,  64,  192, 11, 96,  64,  224, 12,
   1221 
   1222 	96,  96,  0,   6,  96,  96,  32,  7,  96,  96,  64,  8,  96,  96,  96,  9,
   1223 	96,  96,  128, 10, 96,  96,  160, 11, 96,  96,  192, 12, 96,  96,  224, 13,
   1224 
   1225 	96,  128, 0,   7,  96,  128, 32,  8,  96,  128, 64,  9,  96,  128, 96,  10,
   1226 	96,  128, 128, 11, 96,  128, 160, 12, 96,  128, 192, 13, 96,  128, 224, 14,
   1227 
   1228 	96,  160, 0,   8,  96,  160, 32,  9,  96,  160, 64,  10, 96,  160, 96,  11,
   1229 	96,  160, 128, 12, 96,  160, 160, 13, 96,  160, 192, 14, 96,  160, 224, 15,
   1230 
   1231 	96,  192, 0,   9,  96,  192, 32,  10, 96,  192, 64,  11, 96,  192, 96,  12,
   1232 	96,  192, 128, 13, 96,  192, 160, 14, 96,  192, 192, 15, 96,  192, 224, 16,
   1233 
   1234 	96,  224, 0,   10, 96,  224, 32,  11, 96,  224, 64,  12, 96,  224, 96,  13,
   1235 	96,  224, 128, 14, 96,  224, 160, 15, 96,  224, 192, 16, 96,  224, 224, 17,
   1236 
   1237 	128, 0,   0,   4,  128, 0,   32,  5,  128, 0,   64,  6,  128, 0,   96,  7,
   1238 	128, 0,   128, 8,  128, 0,   160, 9,  128, 0,   192, 10, 128, 0,   224, 11,
   1239 
   1240 	128, 32,  0,   5,  128, 32,  32,  6,  128, 32,  64,  7,  128, 32,  96,  8,
   1241 	128, 32,  128, 9,  128, 32,  160, 10, 128, 32,  192, 11, 128, 32,  224, 12,
   1242 
   1243 	128, 64,  0,   6,  128, 64,  32,  7,  128, 64,  64,  8,  128, 64,  96,  9,
   1244 	128, 64,  128, 10, 128, 64,  160, 11, 128, 64,  192, 12, 128, 64,  224, 13,
   1245 
   1246 	128, 96,  0,   7,  128, 96,  32,  8,  128, 96,  64,  9,  128, 96,  96,  10,
   1247 	128, 96,  128, 11, 128, 96,  160, 12, 128, 96,  192, 13, 128, 96,  224, 14,
   1248 
   1249 	128, 128, 0,   8,  128, 128, 32,  9,  128, 128, 64,  10, 128, 128, 96,  11,
   1250 	128, 128, 128, 12, 128, 128, 160, 13, 128, 128, 192, 14, 128, 128, 224, 15,
   1251 
   1252 	128, 160, 0,   9,  128, 160, 32,  10, 128, 160, 64,  11, 128, 160, 96,  12,
   1253 	128, 160, 128, 13, 128, 160, 160, 14, 128, 160, 192, 15, 128, 160, 224, 16,
   1254 
   1255 	128, 192, 0,   10, 128, 192, 32,  11, 128, 192, 64,  12, 128, 192, 96,  13,
   1256 	128, 192, 128, 14, 128, 192, 160, 15, 128, 192, 192, 16, 128, 192, 224, 17,
   1257 
   1258 	128, 224, 0,   11, 128, 224, 32,  12, 128, 224, 64,  13, 128, 224, 96,  14,
   1259 	128, 224, 128, 15, 128, 224, 160, 16, 128, 224, 192, 17, 128, 224, 224, 18,
   1260 
   1261 	160, 0,   0,   5,  160, 0,   32,  6,  160, 0,   64,  7,  160, 0,   96,  8,
   1262 	160, 0,   128, 9,  160, 0,   160, 10, 160, 0,   192, 11, 160, 0,   224, 12,
   1263 
   1264 	160, 32,  0,   6,  160, 32,  32,  7,  160, 32,  64,  8,  160, 32,  96,  9,
   1265 	160, 32,  128, 10, 160, 32,  160, 11, 160, 32,  192, 12, 160, 32,  224, 13,
   1266 
   1267 	160, 64,  0,   7,  160, 64,  32,  8,  160, 64,  64,  9,  160, 64,  96,  10,
   1268 	160, 64,  128, 11, 160, 64,  160, 12, 160, 64,  192, 13, 160, 64,  224, 14,
   1269 
   1270 	160, 96,  0,   8,  160, 96,  32,  9,  160, 96,  64,  10, 160, 96,  96,  11,
   1271 	160, 96,  128, 12, 160, 96,  160, 13, 160, 96,  192, 14, 160, 96,  224, 15,
   1272 
   1273 	160, 128, 0,   9,  160, 128, 32,  10, 160, 128, 64,  11, 160, 128, 96,  12,
   1274 	160, 128, 128, 13, 160, 128, 160, 14, 160, 128, 192, 15, 160, 128, 224, 16,
   1275 
   1276 	160, 160, 0,   10, 160, 160, 32,  11, 160, 160, 64,  12, 160, 160, 96,  13,
   1277 	160, 160, 128, 14, 160, 160, 160, 15, 160, 160, 192, 16, 160, 160, 224, 17,
   1278 
   1279 	160, 192, 0,   11, 160, 192, 32,  12, 160, 192, 64,  13, 160, 192, 96,  14,
   1280 	160, 192, 128, 15, 160, 192, 160, 16, 160, 192, 192, 17, 160, 192, 224, 18,
   1281 
   1282 	160, 224, 0,   12, 160, 224, 32,  13, 160, 224, 64,  14, 160, 224, 96,  15,
   1283 	160, 224, 128, 16, 160, 224, 160, 17, 160, 224, 192, 18, 160, 224, 224, 19,
   1284 
   1285 	192, 0,   0,   6,  192, 0,   32,  7,  192, 0,   64,  8,  192, 0,   96,  9,
   1286 	192, 0,   128, 10, 192, 0,   160, 11, 192, 0,   192, 12, 192, 0,   224, 13,
   1287 
   1288 	192, 32,  0,   7,  192, 32,  32,  8,  192, 32,  64,  9,  192, 32,  96,  10,
   1289 	192, 32,  128, 11, 192, 32,  160, 12, 192, 32,  192, 13, 192, 32,  224, 14,
   1290 
   1291 	192, 64,  0,   8,  192, 64,  32,  9,  192, 64,  64,  10, 192, 64,  96,  11,
   1292 	192, 64,  128, 12, 192, 64,  160, 13, 192, 64,  192, 14, 192, 64,  224, 15,
   1293 
   1294 	192, 96,  0,   9,  192, 96,  32,  10, 192, 96,  64,  11, 192, 96,  96,  12,
   1295 	192, 96,  128, 13, 192, 96,  160, 14, 192, 96,  192, 15, 192, 96,  224, 16,
   1296 
   1297 	192, 128, 0,   10, 192, 128, 32,  11, 192, 128, 64,  12, 192, 128, 96,  13,
   1298 	192, 128, 128, 14, 192, 128, 160, 15, 192, 128, 192, 16, 192, 128, 224, 17,
   1299 
   1300 	192, 160, 0,   11, 192, 160, 32,  12, 192, 160, 64,  13, 192, 160, 96,  14,
   1301 	192, 160, 128, 15, 192, 160, 160, 16, 192, 160, 192, 17, 192, 160, 224, 18,
   1302 
   1303 	192, 192, 0,   12, 192, 192, 32,  13, 192, 192, 64,  14, 192, 192, 96,  15,
   1304 	192, 192, 128, 16, 192, 192, 160, 17, 192, 192, 192, 18, 192, 192, 224, 19,
   1305 
   1306 	192, 224, 0,   13, 192, 224, 32,  14, 192, 224, 64,  15, 192, 224, 96,  16,
   1307 	192, 224, 128, 17, 192, 224, 160, 18, 192, 224, 192, 19, 192, 224, 224, 20,
   1308 
   1309 	224, 0,   0,   7,  224, 0,   32,  8,  224, 0,   64,  9,  224, 0,   96,  10,
   1310 	224, 0,   128, 11, 224, 0,   160, 12, 224, 0,   192, 13, 224, 0,   224, 14,
   1311 
   1312 	224, 32,  0,   8,  224, 32,  32,  9,  224, 32,  64,  10, 224, 32,  96,  11,
   1313 	224, 32,  128, 12, 224, 32,  160, 13, 224, 32,  192, 14, 224, 32,  224, 15,
   1314 
   1315 	224, 64,  0,   9,  224, 64,  32,  10, 224, 64,  64,  11, 224, 64,  96,  12,
   1316 	224, 64,  128, 13, 224, 64,  160, 14, 224, 64,  192, 15, 224, 64,  224, 16,
   1317 
   1318 	224, 96,  0,   10, 224, 96,  32,  11, 224, 96,  64,  12, 224, 96,  96,  13,
   1319 	224, 96,  128, 14, 224, 96,  160, 15, 224, 96,  192, 16, 224, 96,  224, 17,
   1320 
   1321 	224, 128, 0,   11, 224, 128, 32,  12, 224, 128, 64,  13, 224, 128, 96,  14,
   1322 	224, 128, 128, 15, 224, 128, 160, 16, 224, 128, 192, 17, 224, 128, 224, 18,
   1323 
   1324 	224, 160, 0,   12, 224, 160, 32,  13, 224, 160, 64,  14, 224, 160, 96,  15,
   1325 	224, 160, 128, 16, 224, 160, 160, 17, 224, 160, 192, 18, 224, 160, 224, 19,
   1326 
   1327 	224, 192, 0,   13, 224, 192, 32,  14, 224, 192, 64,  15, 224, 192, 96,  16,
   1328 	224, 192, 128, 17, 224, 192, 160, 18, 224, 192, 192, 19, 224, 192, 224, 20,
   1329 
   1330 	224, 224, 0,   14, 224, 224, 32,  15, 224, 224, 64,  16, 224, 224, 96,  17,
   1331 	224, 224, 128, 18, 224, 224, 160, 19, 224, 224, 192, 20, 224, 224, 224, 21
   1332 };
   1333 
   1334 const glw::GLsizei gl4cts::GetTextureSubImage::Functional::s_texture_data_size =
   1335 	sizeof(s_texture_data); //!< Size of the uncompressed texture.
   1336 
   1337 const glw::GLsizei gl4cts::GetTextureSubImage::Functional::s_texture_data_width =
   1338 	8; //!< Width  of compressed and uncompressed textures.
   1339 const glw::GLsizei gl4cts::GetTextureSubImage::Functional::s_texture_data_height =
   1340 	8; //!< Height of compressed and uncompressed textures.
   1341 const glw::GLsizei gl4cts::GetTextureSubImage::Functional::s_texture_data_depth =
   1342 	8; //!< Depth  of compressed and uncompressed textures.
   1343 
   1344 /** ETC2 8x8x8(layers) pixels in size source texture for testing GetCompressedTextureSubImage. */
   1345 const glw::GLubyte gl4cts::GetTextureSubImage::Functional::s_texture_data_compressed[] = {
   1346 	/* Layer 0 */
   1347 	0x80, 0x80, 0x4, 0x2, 0x1, 0x0, 0x10, 0x0, 0x80, 0x81, 0x4, 0x2, 0x1, 0xf8, 0x10, 0x20,
   1348 	0x81, 0x80, 0x4, 0x2, 0x81,	0x0, 0x1f, 0xc0, 0x81, 0x81, 0x4, 0x2, 0x81, 0xf8, 0x1f, 0xe0,
   1349 	0x80, 0x80, 0x5, 0x2, 0x1, 0x0, 0x10, 0x0, 0x80, 0x81, 0x5, 0x2, 0x1, 0xf8, 0x10, 0x20,
   1350 	0x81, 0x80, 0x5, 0x2, 0x81,	0x0, 0x1f, 0xc0, 0x81, 0x81, 0x5, 0x2, 0x81, 0xf8, 0x1f, 0xe0,
   1351 
   1352 	/* Layer 1 */
   1353 	0x90, 0x80, 0x4, 0x12, 0x1, 0x1, 0x10, 0x0, 0x90, 0x81, 0x4, 0x12, 0x1, 0xf9, 0x10, 0x20,
   1354 	0x91, 0x80, 0x4, 0x12, 0x81, 0x1, 0x1f, 0xc0, 0x91, 0x81, 0x4, 0x12, 0x81, 0xf9, 0x1f, 0xe0,
   1355 	0x90, 0x80, 0x5, 0x12, 0x1, 0x1, 0x10, 0x0, 0x90, 0x81, 0x5, 0x12, 0x1, 0xf9, 0x10, 0x20,
   1356 	0x91, 0x80, 0x5, 0x12, 0x81, 0x1, 0x1f, 0xc0, 0x91, 0x81, 0x5, 0x12, 0x81, 0xf9, 0x1f, 0xe0,
   1357 
   1358 	/* Layer 2 */
   1359 	0xa0, 0x80, 0x4, 0x22, 0x1, 0x2, 0x10, 0x0, 0xa0, 0x81, 0x4, 0x22, 0x1, 0xfa, 0x10, 0x20,
   1360 	0xa1, 0x80, 0x4, 0x22, 0x81, 0x2, 0x1f, 0xc0, 0xa1, 0x81, 0x4, 0x22, 0x81, 0xfa, 0x1f, 0xe0,
   1361 	0xa0, 0x80, 0x5, 0x22, 0x1, 0x2, 0x10, 0x0, 0xa0, 0x81, 0x5, 0x22, 0x1, 0xfa, 0x10, 0x20,
   1362 	0xa1, 0x80, 0x5, 0x22, 0x81, 0x2, 0x1f, 0xc0, 0xa1, 0x81, 0x5, 0x22, 0x81, 0xfa, 0x1f, 0xe0,
   1363 
   1364 	/* Layer 3 */
   1365 	0xb0, 0x80, 0x4, 0x32, 0x1, 0x3, 0x10, 0x0, 0xb0, 0x81, 0x4, 0x32, 0x1, 0xfb, 0x10, 0x20,
   1366 	0xb1, 0x80, 0x4, 0x32, 0x81, 0x3, 0x1f, 0xc0, 0xb1, 0x81, 0x4, 0x32, 0x81, 0xfb, 0x1f, 0xe0,
   1367 	0xb0, 0x80, 0x5, 0x32, 0x1, 0x3, 0x10, 0x0, 0xb0, 0x81, 0x5, 0x32, 0x1, 0xfb, 0x10, 0x20,
   1368 	0xb1, 0x80, 0x5, 0x32, 0x81, 0x3, 0x1f, 0xc0, 0xb1, 0x81, 0x5, 0x32, 0x81, 0xfb, 0x1f, 0xe0,
   1369 
   1370 	/* Layer 4 */
   1371 	0x40, 0x80, 0x4, 0x42, 0x1, 0x4, 0x10, 0x0, 0x40, 0x81, 0x4, 0x42, 0x1, 0xfc, 0x10, 0x20,
   1372 	0x41, 0x80, 0x4, 0x42, 0x81, 0x4, 0x1f, 0xc0, 0x41, 0x81, 0x4, 0x42, 0x81, 0xfc, 0x1f, 0xe0,
   1373 	0x40, 0x80, 0x5, 0x42, 0x1, 0x4, 0x10, 0x0, 0x40, 0x81, 0x5, 0x42, 0x1, 0xfc, 0x10, 0x20,
   1374 	0x41, 0x80, 0x5, 0x42, 0x81, 0x4, 0x1f, 0xc0, 0x41, 0x81, 0x5, 0x42, 0x81, 0xfc, 0x1f, 0xe0,
   1375 
   1376 	/* Layer 5 */
   1377 	0x50, 0x80, 0x4, 0x52, 0x1, 0x5, 0x10, 0x0, 0x50, 0x81, 0x4, 0x52, 0x1, 0xfd, 0x10, 0x20,
   1378 	0x51, 0x80, 0x4, 0x52, 0x81, 0x5, 0x1f, 0xc0, 0x51, 0x81, 0x4, 0x52, 0x81, 0xfd, 0x1f, 0xe0,
   1379 	0x50, 0x80, 0x5, 0x52, 0x1, 0x5, 0x10, 0x0, 0x50, 0x81, 0x5, 0x52, 0x1, 0xfd, 0x10, 0x20,
   1380 	0x51, 0x80, 0x5, 0x52, 0x81, 0x5, 0x1f, 0xc0, 0x51, 0x81, 0x5, 0x52, 0x81, 0xfd, 0x1f, 0xe0,
   1381 
   1382 	/* Layer 6 */
   1383 	0x5e, 0x80, 0x4, 0x5f, 0x1, 0x5, 0xf0, 0x0, 0x5e, 0x81, 0x4, 0x5f, 0x1, 0xfd, 0xf0, 0x20,
   1384 	0x5f, 0x80, 0x4, 0x5f, 0x81, 0x5, 0xff, 0xc0, 0x5f, 0x81, 0x4, 0x5f, 0x81, 0xfd, 0xff, 0xe0,
   1385 	0x5e, 0x80, 0x5, 0x5f, 0x1, 0x5, 0xf0, 0x0, 0x5e, 0x81, 0x5, 0x5f, 0x1, 0xfd, 0xf0, 0x20,
   1386 	0x5f, 0x80, 0x5, 0x5f, 0x81, 0x5, 0xff, 0xc0, 0x5f, 0x81, 0x5, 0x5f, 0x81, 0xfd, 0xff, 0xe0,
   1387 
   1388 	/* Layer 7 */
   1389 	0x6e, 0x80, 0x4, 0x6f, 0x1, 0x6, 0xf0, 0x0, 0x6e, 0x81, 0x4, 0x6f, 0x1, 0xfe, 0xf0, 0x20,
   1390 	0x6f, 0x80, 0x4, 0x6f, 0x81, 0x6, 0xff, 0xc0, 0x6f, 0x81, 0x4, 0x6f, 0x81, 0xfe, 0xff, 0xe0,
   1391 	0x6e, 0x80, 0x5, 0x6f, 0x1, 0x6, 0xf0, 0x0, 0x6e, 0x81, 0x5, 0x6f, 0x1, 0xfe, 0xf0, 0x20,
   1392 	0x6f, 0x80, 0x5, 0x6f, 0x81, 0x6, 0xff, 0xc0, 0x6f, 0x81, 0x5, 0x6f, 0x81, 0xfe, 0xff, 0xe0
   1393 };
   1394 
   1395 const glw::GLsizei gl4cts::GetTextureSubImage::Functional::s_texture_data_compressed_size =
   1396 	sizeof(s_texture_data_compressed); //!< Size of compressed texture.
   1397