Home | History | Annotate | Download | only in gl
      1 #ifndef _GL4CGETTEXTURESUBIMAGETESTS_HPP
      2 #define _GL4CGETTEXTURESUBIMAGETESTS_HPP
      3 /*-------------------------------------------------------------------------
      4  * OpenGL Conformance Test Suite
      5  * -----------------------------
      6  *
      7  * Copyright (c) 2015-2016 The Khronos Group Inc.
      8  *
      9  * Licensed under the Apache License, Version 2.0 (the "License");
     10  * you may not use this file except in compliance with the License.
     11  * You may obtain a copy of the License at
     12  *
     13  *      http://www.apache.org/licenses/LICENSE-2.0
     14  *
     15  * Unless required by applicable law or agreed to in writing, software
     16  * distributed under the License is distributed on an "AS IS" BASIS,
     17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     18  * See the License for the specific language governing permissions and
     19  * limitations under the License.
     20  *
     21  */ /*!
     22  * \file
     23  * \brief
     24  */ /*-------------------------------------------------------------------*/
     25 
     26 /**
     27  */ /*!
     28  * \file  gl4cGetTextureSubImageTests.hpp
     29  * \brief Get Texture Sub Image Tests Suite Interface
     30  */ /*-------------------------------------------------------------------*/
     31 
     32 /* Includes. */
     33 
     34 #include "glcTestCase.hpp"
     35 #include "glwDefs.hpp"
     36 #include "tcuDefs.hpp"
     37 
     38 #include "glwEnums.hpp"
     39 #include "glwFunctions.hpp"
     40 
     41 /* Interface. */
     42 
     43 namespace gl4cts
     44 {
     45 namespace GetTextureSubImage
     46 {
     47 /** Tests group for GetTextureSubImage tests.
     48  *
     49  *  Following tests will be run:
     50  *  -   Errors Test
     51  *  -   Functional Test
     52  */
     53 class Tests : public deqp::TestCaseGroup
     54 {
     55 public:
     56 	Tests(deqp::Context& context);
     57 	~Tests(void);
     58 	virtual void init(void);
     59 
     60 private:
     61 	/* Private member functions. */
     62 	Tests(const Tests& other);
     63 	Tests& operator=(const Tests& other);
     64 };
     65 /* Tests class. */
     66 
     67 /** Error Generation Tests
     68  *
     69  *  The Errors test verifies that functions glGetTextureSubImage and
     70  *  glGetCompressedTextureSubImage generate proper error values if used
     71  *  improperly. For reference see OpenGL 4.5 Core Specification chapter
     72  *  8.11.4.
     73 
     74  *  *   Check that GL_INVALID_VALUE error is generated by
     75  *      glGetTextureSubImage if texture is not the name of an existing
     76  *      texture object.
     77  *
     78  *  *   Check that GL_INVALID_VALUE error is generated by
     79  *      glGetCompressedTextureSubImage if texture is not the name
     80  *      of an existingtexture object.
     81  *
     82  *  *   Check that GL_INVALID_OPERATION error is generated if texture is the
     83  *      name of a buffer or multisample texture.
     84  *
     85  *  *   Check that GL_INVALID_VALUE is generated if xoffset, yoffset or
     86  *      zoffset are negative.
     87  *
     88  *  *   Check that GL_INVALID_VALUE is generated if xoffset + width is
     89  *      greater than the texture's width, yoffset + height is greater than
     90  *      the texture's height, or zoffset + depth is greater than the
     91  *      texture's depth.
     92  *
     93  *  *   Check that GL_INVALID_VALUE error is generated if the effective
     94  *      target is GL_TEXTURE_1D and either yoffset is not zero, or height
     95  *      is not one.
     96  *
     97  *  *   Check that GL_INVALID_VALUE error is generated if the effective
     98  *      target is GL_TEXTURE_1D, GL_TEXTURE_1D_ARRAY, GL_TEXTURE_2D or
     99  *      GL_TEXTURE_RECTANGLE and either zoffset is not zero, or depth
    100  *      is not one.
    101  *
    102  *  *   Check that GL_INVALID_OPERATION error is generated if the buffer
    103  *      size required to store the requested data is greater than bufSize.
    104  */
    105 class Errors : public deqp::TestCase
    106 {
    107 public:
    108 	Errors(deqp::Context& context);
    109 	~Errors(void);
    110 	IterateResult iterate(void);
    111 
    112 private:
    113 	/* Private member variables. */
    114 	deqp::Context& m_context;
    115 	glw::GLuint	m_texture_1D;
    116 	glw::GLuint	m_texture_1D_array;
    117 	glw::GLuint	m_texture_2D;
    118 	glw::GLuint	m_texture_rectangle;
    119 	glw::GLuint	m_texture_2D_compressed;
    120 	glw::GLuint	m_texture_2D_multisampled;
    121 	glw::GLubyte*  m_destination_buffer;
    122 
    123 	/* Get(Compressed)TextureSubImage function pointer and type declarations. */
    124 	typedef void(GLW_APIENTRY* PFNGLGETTEXTURESUBIMAGEPROC)(glw::GLuint texture, glw::GLint level, glw::GLint xoffset,
    125 															glw::GLint yoffset, glw::GLint zoffset, glw::GLsizei width,
    126 															glw::GLsizei height, glw::GLsizei depth, glw::GLenum format,
    127 															glw::GLenum type, glw::GLsizei bufSize, void* pixels);
    128 
    129 	typedef void(GLW_APIENTRY* PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC)(glw::GLuint texture, glw::GLint level,
    130 																	  glw::GLint xoffset, glw::GLint yoffset,
    131 																	  glw::GLint zoffset, glw::GLsizei width,
    132 																	  glw::GLsizei height, glw::GLsizei depth,
    133 																	  glw::GLsizei bufSize, void* pixels);
    134 
    135 	PFNGLGETTEXTURESUBIMAGEPROC			  m_gl_GetTextureSubImage;
    136 	PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC m_gl_GetCompressedTextureSubImage;
    137 
    138 	/* Private member functions. */
    139 	void prepare();
    140 
    141 	bool testExistingTextureObjectError();
    142 
    143 	bool testBufferOrMultisampledTargetError();
    144 
    145 	bool testNegativeOffsetError();
    146 
    147 	bool testBoundsError();
    148 
    149 	bool testOneDimmensionalTextureErrors();
    150 
    151 	bool testTwoDimmensionalTextureErrors();
    152 
    153 	bool testBufferSizeError();
    154 
    155 	void clean();
    156 
    157 	/* Private static constants. */
    158 	static const glw::GLubyte s_texture_data[];
    159 	static const glw::GLuint  s_texture_data_size;
    160 	static const glw::GLuint  s_texture_data_width;
    161 	static const glw::GLuint  s_texture_data_height;
    162 
    163 	static const glw::GLubyte s_texture_data_compressed[];
    164 	static const glw::GLuint  s_texture_data_compressed_size;
    165 	static const glw::GLuint  s_texture_data_compressed_width;
    166 	static const glw::GLuint  s_texture_data_compressed_height;
    167 
    168 	static const glw::GLuint s_destination_buffer_size;
    169 };
    170 /* Errors class. */
    171 
    172 /** Functional
    173  *
    174  *  The Functional test verifies that functions glGetTextureSubImage and
    175  *  glGetCompressedTextureSubImage works properly. The whole test shall be
    176  *  constructed as follows:
    177  *
    178  *      for each tested function
    179  *          for each supported texture target
    180  *              prepare and upload texture
    181  *              download texture using the function
    182  *              compare uploaded texture with downloaded texture
    183  *              clean up
    184  *
    185  *  where:
    186  *  *   tested functions are:
    187  *      - GetTextureSubImage,
    188  *      - GetCompressedTextureSubImage;
    189  *  *   supported uncompressed texture targets are:
    190  *      - GL_TEXTURE_1D,
    191  *      - GL_TEXTURE_1D_ARRAY,
    192  *      - GL_TEXTURE_2D,
    193  *      - GL_TEXTURE_2D_ARRAY,
    194  *      - GL_TEXTURE_3D,
    195  *      - GL_TEXTURE_CUBE_MAP,
    196  *      - GL_TEXTURE_CUBE_MAP_ARRAY,
    197  *      - GL_TEXTURE_RECTANGLE;
    198  *  *   supported compressed texture targets are:
    199  *      - GL_TEXTURE_2D,
    200  *      - GL_TEXTURE_2D_ARRAY,
    201  *      - GL_TEXTURE_CUBE_MAP,
    202  *      - GL_TEXTURE_CUBE_MAP_ARRAY;
    203  *  *   texture internal format shall be GL_RGBA8 and
    204  *      GL_COMPRESSED_RGB8_ETC2;
    205  *  *   use linear dimmension of texture equal to 8;
    206  *  *   use offset of 4 (if dimmension is available);
    207  *  *   use width/height/depth of 4 (if dimmension is available).
    208  */
    209 class Functional : public deqp::TestCase
    210 {
    211 public:
    212 	Functional(deqp::Context& context);
    213 	~Functional(void);
    214 	IterateResult iterate(void);
    215 
    216 private:
    217 	/* Private member variables. */
    218 	deqp::Context& m_context;
    219 	glw::GLuint	m_texture;
    220 
    221 	/* Private member functions. */
    222 	void prepare(glw::GLenum target, bool is_compressed);
    223 	bool check(glw::GLenum target, bool is_compressed);
    224 	void clean();
    225 
    226 	/* Get(Compressed)TextureSubImage function pointer and type declarations. */
    227 	typedef void(GLW_APIENTRY* PFNGLGETTEXTURESUBIMAGEPROC)(glw::GLuint texture, glw::GLint level, glw::GLint xoffset,
    228 															glw::GLint yoffset, glw::GLint zoffset, glw::GLsizei width,
    229 															glw::GLsizei height, glw::GLsizei depth, glw::GLenum format,
    230 															glw::GLenum type, glw::GLsizei bufSize, void* pixels);
    231 
    232 	typedef void(GLW_APIENTRY* PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC)(glw::GLuint texture, glw::GLint level,
    233 																	  glw::GLint xoffset, glw::GLint yoffset,
    234 																	  glw::GLint zoffset, glw::GLsizei width,
    235 																	  glw::GLsizei height, glw::GLsizei depth,
    236 																	  glw::GLsizei bufSize, void* pixels);
    237 
    238 	PFNGLGETTEXTURESUBIMAGEPROC			  m_gl_GetTextureSubImage;
    239 	PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC m_gl_GetCompressedTextureSubImage;
    240 
    241 	/* Static constants. */
    242 	static const glw::GLubyte s_texture_data[];
    243 	static const glw::GLsizei s_texture_data_size;
    244 	static const glw::GLsizei s_texture_data_width;
    245 	static const glw::GLsizei s_texture_data_height;
    246 	static const glw::GLsizei s_texture_data_depth;
    247 
    248 	static const glw::GLubyte s_texture_data_compressed[];
    249 	static const glw::GLsizei s_texture_data_compressed_size;
    250 };
    251 
    252 /* Functional class */
    253 } /* namespace GetTextureSubImage */
    254 } /* namespace gl4cts */
    255 
    256 #endif // _GL4CGETTEXTURESUBIMAGETESTS_HPP
    257