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