1e5c31af7Sopenharmony_ci#ifndef _GL4CTEXTUREVIEWTESTS_HPP
2e5c31af7Sopenharmony_ci#define _GL4CTEXTUREVIEWTESTS_HPP
3e5c31af7Sopenharmony_ci/*-------------------------------------------------------------------------
4e5c31af7Sopenharmony_ci * OpenGL Conformance Test Suite
5e5c31af7Sopenharmony_ci * -----------------------------
6e5c31af7Sopenharmony_ci *
7e5c31af7Sopenharmony_ci * Copyright (c) 2014-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 * \file  gl4cTextureViewTests.hpp
28e5c31af7Sopenharmony_ci * \brief Declares test classes for "texture view" functionality.
29e5c31af7Sopenharmony_ci */ /*-------------------------------------------------------------------*/
30e5c31af7Sopenharmony_ci
31e5c31af7Sopenharmony_ci#include "glcTestCase.hpp"
32e5c31af7Sopenharmony_ci#include "glwDefs.hpp"
33e5c31af7Sopenharmony_ci#include "glwEnums.hpp"
34e5c31af7Sopenharmony_ci#include "tcuDefs.hpp"
35e5c31af7Sopenharmony_ci#include "tcuVector.hpp"
36e5c31af7Sopenharmony_ci
37e5c31af7Sopenharmony_cinamespace gl4cts
38e5c31af7Sopenharmony_ci{
39e5c31af7Sopenharmony_cinamespace TextureView
40e5c31af7Sopenharmony_ci{
41e5c31af7Sopenharmony_ci
42e5c31af7Sopenharmony_cienum _format
43e5c31af7Sopenharmony_ci{
44e5c31af7Sopenharmony_ci	FORMAT_FLOAT,
45e5c31af7Sopenharmony_ci	FORMAT_RGBE,
46e5c31af7Sopenharmony_ci	FORMAT_SIGNED_INTEGER,
47e5c31af7Sopenharmony_ci	FORMAT_SNORM,
48e5c31af7Sopenharmony_ci	FORMAT_UNORM,
49e5c31af7Sopenharmony_ci	FORMAT_UNSIGNED_INTEGER,
50e5c31af7Sopenharmony_ci
51e5c31af7Sopenharmony_ci	FORMAT_UNDEFINED
52e5c31af7Sopenharmony_ci};
53e5c31af7Sopenharmony_ci
54e5c31af7Sopenharmony_cienum _sampler_type
55e5c31af7Sopenharmony_ci{
56e5c31af7Sopenharmony_ci	SAMPLER_TYPE_FLOAT,
57e5c31af7Sopenharmony_ci	SAMPLER_TYPE_SIGNED_INTEGER,
58e5c31af7Sopenharmony_ci	SAMPLER_TYPE_UNSIGNED_INTEGER,
59e5c31af7Sopenharmony_ci
60e5c31af7Sopenharmony_ci	SAMPLER_TYPE_UNDEFINED
61e5c31af7Sopenharmony_ci};
62e5c31af7Sopenharmony_ci
63e5c31af7Sopenharmony_cienum _view_class
64e5c31af7Sopenharmony_ci{
65e5c31af7Sopenharmony_ci	VIEW_CLASS_FIRST,
66e5c31af7Sopenharmony_ci
67e5c31af7Sopenharmony_ci	VIEW_CLASS_128_BITS = VIEW_CLASS_FIRST,
68e5c31af7Sopenharmony_ci	VIEW_CLASS_96_BITS,
69e5c31af7Sopenharmony_ci	VIEW_CLASS_64_BITS,
70e5c31af7Sopenharmony_ci	VIEW_CLASS_48_BITS,
71e5c31af7Sopenharmony_ci	VIEW_CLASS_32_BITS,
72e5c31af7Sopenharmony_ci	VIEW_CLASS_24_BITS,
73e5c31af7Sopenharmony_ci	VIEW_CLASS_16_BITS,
74e5c31af7Sopenharmony_ci	VIEW_CLASS_8_BITS,
75e5c31af7Sopenharmony_ci	VIEW_CLASS_RGTC1_RED,
76e5c31af7Sopenharmony_ci	VIEW_CLASS_RGTC2_RG,
77e5c31af7Sopenharmony_ci	VIEW_CLASS_BPTC_UNORM,
78e5c31af7Sopenharmony_ci	VIEW_CLASS_BPTC_FLOAT,
79e5c31af7Sopenharmony_ci
80e5c31af7Sopenharmony_ci	/* Always last */
81e5c31af7Sopenharmony_ci	VIEW_CLASS_COUNT,
82e5c31af7Sopenharmony_ci	VIEW_CLASS_UNDEFINED = VIEW_CLASS_COUNT
83e5c31af7Sopenharmony_ci};
84e5c31af7Sopenharmony_ci
85e5c31af7Sopenharmony_ci} // namespace TextureView
86e5c31af7Sopenharmony_ci
87e5c31af7Sopenharmony_ci/** Helper class that implements various methods used across all Texture View tests. */
88e5c31af7Sopenharmony_ciclass TextureViewUtilities
89e5c31af7Sopenharmony_ci{
90e5c31af7Sopenharmony_cipublic:
91e5c31af7Sopenharmony_ci	/* Public type definitions */
92e5c31af7Sopenharmony_ci	typedef glw::GLenum _original_texture_internalformat;
93e5c31af7Sopenharmony_ci	typedef glw::GLenum _original_texture_target;
94e5c31af7Sopenharmony_ci	typedef glw::GLenum _view_texture_internalformat;
95e5c31af7Sopenharmony_ci	typedef glw::GLenum _view_texture_target;
96e5c31af7Sopenharmony_ci	typedef std::pair<_original_texture_internalformat, _view_texture_internalformat> _internalformat_pair;
97e5c31af7Sopenharmony_ci	typedef std::vector<glw::GLenum>		 _internalformats;
98e5c31af7Sopenharmony_ci	typedef _internalformats::const_iterator _internalformats_const_iterator;
99e5c31af7Sopenharmony_ci	typedef _internalformats::iterator		 _internalformats_iterator;
100e5c31af7Sopenharmony_ci	typedef std::pair<_original_texture_target, _view_texture_target> _texture_target_pair;
101e5c31af7Sopenharmony_ci	typedef std::vector<_internalformat_pair>				   _compatible_internalformat_pairs;
102e5c31af7Sopenharmony_ci	typedef _compatible_internalformat_pairs::const_iterator   _compatible_internalformat_pairs_const_iterator;
103e5c31af7Sopenharmony_ci	typedef std::vector<_texture_target_pair>				   _compatible_texture_target_pairs;
104e5c31af7Sopenharmony_ci	typedef _compatible_texture_target_pairs::const_iterator   _compatible_texture_target_pairs_const_iterator;
105e5c31af7Sopenharmony_ci	typedef std::vector<_internalformat_pair>				   _incompatible_internalformat_pairs;
106e5c31af7Sopenharmony_ci	typedef _incompatible_internalformat_pairs::const_iterator _incompatible_internalformat_pairs_const_iterator;
107e5c31af7Sopenharmony_ci	typedef _incompatible_internalformat_pairs::iterator	   _incompatible_internalformat_pairs_iterator;
108e5c31af7Sopenharmony_ci	typedef std::vector<_texture_target_pair>				   _incompatible_texture_target_pairs;
109e5c31af7Sopenharmony_ci	typedef _incompatible_texture_target_pairs::const_iterator _incompatible_texture_target_pairs_const_iterator;
110e5c31af7Sopenharmony_ci	typedef _incompatible_texture_target_pairs::iterator	   _incompatible_texture_target_pairs_iterator;
111e5c31af7Sopenharmony_ci
112e5c31af7Sopenharmony_ci	/* Public methods */
113e5c31af7Sopenharmony_ci
114e5c31af7Sopenharmony_ci	static unsigned int getAmountOfComponentsForInternalformat(const glw::GLenum internalformat);
115e5c31af7Sopenharmony_ci
116e5c31af7Sopenharmony_ci	static unsigned int getBlockSizeForCompressedInternalformat(const glw::GLenum internalformat);
117e5c31af7Sopenharmony_ci
118e5c31af7Sopenharmony_ci	static void getComponentSizeForInternalformat(const glw::GLenum internalformat, unsigned int* out_rgba_size);
119e5c31af7Sopenharmony_ci
120e5c31af7Sopenharmony_ci	static void getComponentSizeForType(const glw::GLenum type, unsigned int* out_rgba_size);
121e5c31af7Sopenharmony_ci
122e5c31af7Sopenharmony_ci	static const char* getErrorCodeString(const glw::GLint error_code);
123e5c31af7Sopenharmony_ci
124e5c31af7Sopenharmony_ci	static TextureView::_format getFormatOfInternalformat(const glw::GLenum internalformat);
125e5c31af7Sopenharmony_ci
126e5c31af7Sopenharmony_ci	static glw::GLenum getGLFormatOfInternalformat(const glw::GLenum internalformat);
127e5c31af7Sopenharmony_ci
128e5c31af7Sopenharmony_ci	static const char* getGLSLDataTypeForSamplerType(const TextureView::_sampler_type sampler_type,
129e5c31af7Sopenharmony_ci													 const unsigned int				  n_components);
130e5c31af7Sopenharmony_ci
131e5c31af7Sopenharmony_ci	static const char* getGLSLTypeForSamplerType(const TextureView::_sampler_type sampler_type);
132e5c31af7Sopenharmony_ci
133e5c31af7Sopenharmony_ci	static _incompatible_internalformat_pairs getIllegalTextureAndViewInternalformatCombinations();
134e5c31af7Sopenharmony_ci
135e5c31af7Sopenharmony_ci	static _incompatible_texture_target_pairs getIllegalTextureAndViewTargetCombinations();
136e5c31af7Sopenharmony_ci
137e5c31af7Sopenharmony_ci	static _internalformats getInternalformatsFromViewClass(TextureView::_view_class view_class);
138e5c31af7Sopenharmony_ci
139e5c31af7Sopenharmony_ci	static const char* getInternalformatString(const glw::GLenum internalformat);
140e5c31af7Sopenharmony_ci
141e5c31af7Sopenharmony_ci	static _compatible_internalformat_pairs getLegalTextureAndViewInternalformatCombinations();
142e5c31af7Sopenharmony_ci
143e5c31af7Sopenharmony_ci	static _compatible_texture_target_pairs getLegalTextureAndViewTargetCombinations();
144e5c31af7Sopenharmony_ci
145e5c31af7Sopenharmony_ci	static void getMajorMinorVersionFromContextVersion(const glu::ContextType& context_type,
146e5c31af7Sopenharmony_ci													   glw::GLint* out_major_version, glw::GLint* out_minor_version);
147e5c31af7Sopenharmony_ci
148e5c31af7Sopenharmony_ci	static TextureView::_sampler_type getSamplerTypeForInternalformat(const glw::GLenum internalformat);
149e5c31af7Sopenharmony_ci
150e5c31af7Sopenharmony_ci	static unsigned int getTextureDataSize(const glw::GLenum internalformat, const glw::GLenum type,
151e5c31af7Sopenharmony_ci										   const unsigned int width, const unsigned int height);
152e5c31af7Sopenharmony_ci
153e5c31af7Sopenharmony_ci	static const char* getTextureTargetString(const glw::GLenum texture_target);
154e5c31af7Sopenharmony_ci
155e5c31af7Sopenharmony_ci	static glw::GLenum getTypeCompatibleWithInternalformat(const glw::GLenum internalformat);
156e5c31af7Sopenharmony_ci
157e5c31af7Sopenharmony_ci	static TextureView::_view_class getViewClassForInternalformat(const glw::GLenum internalformat);
158e5c31af7Sopenharmony_ci
159e5c31af7Sopenharmony_ci	static void initTextureStorage(const glw::Functions& gl, bool init_mutable_to, glw::GLenum texture_target,
160e5c31af7Sopenharmony_ci								   glw::GLint texture_depth, glw::GLint texture_height, glw::GLint texture_width,
161e5c31af7Sopenharmony_ci								   glw::GLenum texture_internalformat, glw::GLenum texture_format,
162e5c31af7Sopenharmony_ci								   glw::GLenum texture_type, unsigned int n_levels_needed,
163e5c31af7Sopenharmony_ci								   unsigned int n_cubemaps_needed, glw::GLint bo_id);
164e5c31af7Sopenharmony_ci
165e5c31af7Sopenharmony_ci	static bool isInternalformatCompatibleForTextureView(glw::GLenum original_internalformat,
166e5c31af7Sopenharmony_ci														 glw::GLenum view_internalformat);
167e5c31af7Sopenharmony_ci
168e5c31af7Sopenharmony_ci	static bool isInternalformatCompressed(const glw::GLenum internalformat);
169e5c31af7Sopenharmony_ci
170e5c31af7Sopenharmony_ci	static bool isInternalformatSRGB(const glw::GLenum internalformat);
171e5c31af7Sopenharmony_ci
172e5c31af7Sopenharmony_ci	static bool isInternalformatSupported(glw::GLenum internalformat, const glw::GLint major_version,
173e5c31af7Sopenharmony_ci										  const glw::GLint minor_version);
174e5c31af7Sopenharmony_ci
175e5c31af7Sopenharmony_ci	static bool isLegalTextureTargetForTextureView(glw::GLenum original_texture_target,
176e5c31af7Sopenharmony_ci												   glw::GLenum view_texture_target);
177e5c31af7Sopenharmony_ci};
178e5c31af7Sopenharmony_ci
179e5c31af7Sopenharmony_ci/**
180e5c31af7Sopenharmony_ci *   1. Make sure glGetTexParameterfv() and glGetTexParameteriv() report
181e5c31af7Sopenharmony_ci *      correct values for the following texture view-specific
182e5c31af7Sopenharmony_ci *      properties:
183e5c31af7Sopenharmony_ci *
184e5c31af7Sopenharmony_ci *      * GL_TEXTURE_IMMUTABLE_LEVELS; (in texture view-specific context
185e5c31af7Sopenharmony_ci *                                      only)
186e5c31af7Sopenharmony_ci *      * GL_TEXTURE_VIEW_MIN_LAYER;
187e5c31af7Sopenharmony_ci *      * GL_TEXTURE_VIEW_MIN_LEVEL;
188e5c31af7Sopenharmony_ci *      * GL_TEXTURE_VIEW_NUM_LAYERS;
189e5c31af7Sopenharmony_ci *      * GL_TEXTURE_VIEW_NUM_LEVELS;
190e5c31af7Sopenharmony_ci *
191e5c31af7Sopenharmony_ci *      These properties should be set to 0 (or GL_FALSE) by default.
192e5c31af7Sopenharmony_ci *      For textures created with glTexStorage() and glTextureView()
193e5c31af7Sopenharmony_ci *      functions, language from bullet (11) of GL_ARB_texture_view
194e5c31af7Sopenharmony_ci *      extension specification applies, as well as "Texture Views"
195e5c31af7Sopenharmony_ci *      section 8.18 of OpenGL 4.3 Core Profile specification.
196e5c31af7Sopenharmony_ci *
197e5c31af7Sopenharmony_ci *      The conformance test should check values of the aforementioned
198e5c31af7Sopenharmony_ci *      properties for the following objects:
199e5c31af7Sopenharmony_ci *
200e5c31af7Sopenharmony_ci *      1) mutable texture objects generated with glTexImage*D() calls,
201e5c31af7Sopenharmony_ci *         then bound to all supported texture targets (as described
202e5c31af7Sopenharmony_ci *         under (*) ).
203e5c31af7Sopenharmony_ci *      2) immutable texture objects generated with glTexStorage*D() calls
204e5c31af7Sopenharmony_ci *         for all supported texture targets (as described under (*) ).
205e5c31af7Sopenharmony_ci *      3) texture views using all texture targets (as described under
206e5c31af7Sopenharmony_ci *         (*) ) compatible with parent texture object's texture target.
207e5c31af7Sopenharmony_ci *         All texture targets should be considered for the parent object.
208e5c31af7Sopenharmony_ci *      4) texture views created on top of texture views described in 3).
209e5c31af7Sopenharmony_ci *
210e5c31af7Sopenharmony_ci *      For texture view cases, the test should verify that:
211e5c31af7Sopenharmony_ci *
212e5c31af7Sopenharmony_ci *      1) GL_TEXTURE_VIEW_NUM_LAYERS and GL_TEXTURE_VIEW_NUM_LEVELS are
213e5c31af7Sopenharmony_ci *         clamped as specified for cases where <numlayers> or <numlevels>
214e5c31af7Sopenharmony_ci *         arguments used for glTextureView() calls exceed beyond the
215e5c31af7Sopenharmony_ci *         original texture.
216e5c31af7Sopenharmony_ci *      2) GL_TEXTURE_VIEW_MIN_LEVEL is set to <minlevel> + value of
217e5c31af7Sopenharmony_ci *         GL_TEXTURE_VIEW_MIN_LEVEL from the original texture.
218e5c31af7Sopenharmony_ci *      3) GL_TEXTURE_VIEW_MIN_LAYER is set to <minlayer> + value of
219e5c31af7Sopenharmony_ci *         GL_TEXTURE_VIEW_MIN_LAYER from the original texture.
220e5c31af7Sopenharmony_ci *      4) GL_TEXTURE_VIEW_NUM_LEVELS is set to the lesser of <numlevels>
221e5c31af7Sopenharmony_ci *         and the value of original texture's GL_TEXTURE_VIEW_NUM_LEVELS
222e5c31af7Sopenharmony_ci *         minus <minlevels>.
223e5c31af7Sopenharmony_ci *      5) GL_TEXTURE_VIEW_NUM_LAYERS is set to the lesser of <numlayers>
224e5c31af7Sopenharmony_ci *         and the value of original texture's GL_TEXTURE_VIEW_NUM_LAYERS
225e5c31af7Sopenharmony_ci *         minus <minlayer>.
226e5c31af7Sopenharmony_ci *
227e5c31af7Sopenharmony_ci *      A single configuration of a texture object and a texture view
228e5c31af7Sopenharmony_ci *      for each valid texture target should be considered for the
229e5c31af7Sopenharmony_ci *      purpose of the test.
230e5c31af7Sopenharmony_ci *
231e5c31af7Sopenharmony_ci *      (*) Texture targets to use:
232e5c31af7Sopenharmony_ci *
233e5c31af7Sopenharmony_ci *      * GL_TEXTURE_1D;
234e5c31af7Sopenharmony_ci *      * GL_TEXTURE_1D_ARRAY;
235e5c31af7Sopenharmony_ci *      * GL_TEXTURE_2D;
236e5c31af7Sopenharmony_ci *      * GL_TEXTURE_2D_ARRAY;
237e5c31af7Sopenharmony_ci *      * GL_TEXTURE_2D_MULTISAMPLE;
238e5c31af7Sopenharmony_ci *      * GL_TEXTURE_2D_MULTISAMPLE_ARRAY;
239e5c31af7Sopenharmony_ci *      * GL_TEXTURE_3D;
240e5c31af7Sopenharmony_ci *      * GL_TEXTURE_CUBE_MAP;
241e5c31af7Sopenharmony_ci *      * GL_TEXTURE_CUBE_MAP_ARRAY;
242e5c31af7Sopenharmony_ci *      * GL_TEXTURE_RECTANGLE;
243e5c31af7Sopenharmony_ci **/
244e5c31af7Sopenharmony_ciclass TextureViewTestGetTexParameter : public deqp::TestCase
245e5c31af7Sopenharmony_ci{
246e5c31af7Sopenharmony_cipublic:
247e5c31af7Sopenharmony_ci	/* Public methods */
248e5c31af7Sopenharmony_ci	TextureViewTestGetTexParameter(deqp::Context& context);
249e5c31af7Sopenharmony_ci
250e5c31af7Sopenharmony_ci	virtual ~TextureViewTestGetTexParameter()
251e5c31af7Sopenharmony_ci	{
252e5c31af7Sopenharmony_ci	}
253e5c31af7Sopenharmony_ci
254e5c31af7Sopenharmony_ci	virtual void						 deinit();
255e5c31af7Sopenharmony_ci	virtual tcu::TestNode::IterateResult iterate();
256e5c31af7Sopenharmony_ci
257e5c31af7Sopenharmony_ciprivate:
258e5c31af7Sopenharmony_ci	/* Private type definitions */
259e5c31af7Sopenharmony_ci	enum _test_texture_type
260e5c31af7Sopenharmony_ci	{
261e5c31af7Sopenharmony_ci		TEST_TEXTURE_TYPE_NO_STORAGE_ALLOCATED,
262e5c31af7Sopenharmony_ci		TEST_TEXTURE_TYPE_IMMUTABLE_TEXTURE_OBJECT,
263e5c31af7Sopenharmony_ci		TEST_TEXTURE_TYPE_MUTABLE_TEXTURE_OBJECT,
264e5c31af7Sopenharmony_ci		TEST_TEXTURE_TYPE_TEXTURE_VIEW_CREATED_FROM_IMMUTABLE_TEXTURE_OBJECT,
265e5c31af7Sopenharmony_ci		TEST_TEXTURE_TYPE_TEXTURE_VIEW_CREATED_FROM_TEXTURE_VIEW,
266e5c31af7Sopenharmony_ci
267e5c31af7Sopenharmony_ci		/* Always last */
268e5c31af7Sopenharmony_ci		TEST_TEXTURE_TYPE_UNDEFINED
269e5c31af7Sopenharmony_ci	};
270e5c31af7Sopenharmony_ci
271e5c31af7Sopenharmony_ci	struct _test_run
272e5c31af7Sopenharmony_ci	{
273e5c31af7Sopenharmony_ci		glw::GLint expected_n_immutable_levels;
274e5c31af7Sopenharmony_ci		glw::GLint expected_n_min_layer;
275e5c31af7Sopenharmony_ci		glw::GLint expected_n_min_level;
276e5c31af7Sopenharmony_ci		glw::GLint expected_n_num_layers;
277e5c31af7Sopenharmony_ci		glw::GLint expected_n_num_levels;
278e5c31af7Sopenharmony_ci
279e5c31af7Sopenharmony_ci		glw::GLuint parent_texture_object_id;
280e5c31af7Sopenharmony_ci		glw::GLuint texture_view_object_created_from_immutable_to_id;
281e5c31af7Sopenharmony_ci		glw::GLuint texture_view_object_created_from_view_to_id;
282e5c31af7Sopenharmony_ci
283e5c31af7Sopenharmony_ci		glw::GLenum		   texture_target;
284e5c31af7Sopenharmony_ci		_test_texture_type texture_type;
285e5c31af7Sopenharmony_ci
286e5c31af7Sopenharmony_ci		/* Constructor */
287e5c31af7Sopenharmony_ci		_test_run()
288e5c31af7Sopenharmony_ci		{
289e5c31af7Sopenharmony_ci			expected_n_immutable_levels = 0;
290e5c31af7Sopenharmony_ci			expected_n_min_layer		= 0;
291e5c31af7Sopenharmony_ci			expected_n_min_level		= 0;
292e5c31af7Sopenharmony_ci			expected_n_num_layers		= 0;
293e5c31af7Sopenharmony_ci			expected_n_num_levels		= 0;
294e5c31af7Sopenharmony_ci
295e5c31af7Sopenharmony_ci			parent_texture_object_id						 = 0;
296e5c31af7Sopenharmony_ci			texture_view_object_created_from_immutable_to_id = 0;
297e5c31af7Sopenharmony_ci			texture_view_object_created_from_view_to_id		 = 0;
298e5c31af7Sopenharmony_ci
299e5c31af7Sopenharmony_ci			texture_target = GL_NONE;
300e5c31af7Sopenharmony_ci			texture_type   = TEST_TEXTURE_TYPE_UNDEFINED;
301e5c31af7Sopenharmony_ci		}
302e5c31af7Sopenharmony_ci	};
303e5c31af7Sopenharmony_ci
304e5c31af7Sopenharmony_ci	typedef std::vector<_test_run>	 _test_runs;
305e5c31af7Sopenharmony_ci	typedef _test_runs::const_iterator _test_runs_const_iterator;
306e5c31af7Sopenharmony_ci	typedef _test_runs::iterator	   _test_runs_iterator;
307e5c31af7Sopenharmony_ci
308e5c31af7Sopenharmony_ci	/* Private methods */
309e5c31af7Sopenharmony_ci	void initTestRuns();
310e5c31af7Sopenharmony_ci
311e5c31af7Sopenharmony_ci	/* Private fields */
312e5c31af7Sopenharmony_ci	_test_runs m_test_runs;
313e5c31af7Sopenharmony_ci};
314e5c31af7Sopenharmony_ci
315e5c31af7Sopenharmony_ci/** Verify glTextureView() generates errors as described in the
316e5c31af7Sopenharmony_ci *  specification:
317e5c31af7Sopenharmony_ci *
318e5c31af7Sopenharmony_ci *  a) GL_INVALID_VALUE should be generated if <texture> is 0.
319e5c31af7Sopenharmony_ci *  b) GL_INVALID_OPERATION should be generated if <texture> is not
320e5c31af7Sopenharmony_ci *     a valid name returned by glGenTextures().
321e5c31af7Sopenharmony_ci *  c) GL_INVALID_OPERATION should be generated if <texture> has
322e5c31af7Sopenharmony_ci *     already been bound and given a target.
323e5c31af7Sopenharmony_ci *  d) GL_INVALID_VALUE should be generated if <origtexture> is not
324e5c31af7Sopenharmony_ci *     the name of a texture object.
325e5c31af7Sopenharmony_ci *  e) GL_INVALID_OPERATION error should be generated if <origtexture>
326e5c31af7Sopenharmony_ci *     is a mutable texture object.
327e5c31af7Sopenharmony_ci *  f) GL_INVALID_OPERATION error should be generated whenever the
328e5c31af7Sopenharmony_ci *     application tries to generate a texture view for a target
329e5c31af7Sopenharmony_ci *     that is incompatible with original texture's target. (as per
330e5c31af7Sopenharmony_ci *     table 8.20 from OpenGL 4.4 specification)
331e5c31af7Sopenharmony_ci *
332e5c31af7Sopenharmony_ci *    NOTE: All invalid original+view texture target combinations
333e5c31af7Sopenharmony_ci *          should be checked.
334e5c31af7Sopenharmony_ci *
335e5c31af7Sopenharmony_ci *  g) GL_INVALID_OPERATION error should be generated whenever the
336e5c31af7Sopenharmony_ci *     application tries to create a texture view, internal format
337e5c31af7Sopenharmony_ci *     of which can be found in table 8.21 of OpenGL 4.4
338e5c31af7Sopenharmony_ci *     specification, and the texture view's internal format is
339e5c31af7Sopenharmony_ci *     incompatible with parent object's internal format. Both
340e5c31af7Sopenharmony_ci *     textures and views should be used as parent objects for the
341e5c31af7Sopenharmony_ci *     purpose of the test.
342e5c31af7Sopenharmony_ci *
343e5c31af7Sopenharmony_ci *     NOTE: All invalid texture view internal formats should be
344e5c31af7Sopenharmony_ci *           checked for all applicable original object's internal
345e5c31af7Sopenharmony_ci *           formats.
346e5c31af7Sopenharmony_ci *
347e5c31af7Sopenharmony_ci *  h) GL_INVALID_OPERATION error should be generated whenever the
348e5c31af7Sopenharmony_ci *     application tries to create a texture view using an internal
349e5c31af7Sopenharmony_ci *     format that does not match the original texture's, and the
350e5c31af7Sopenharmony_ci *     original texture's internalformat cannot be found in table
351e5c31af7Sopenharmony_ci *     8.21 of OpenGL 4.4 specification.
352e5c31af7Sopenharmony_ci *
353e5c31af7Sopenharmony_ci *     NOTE: All required base, sized and compressed texture internal
354e5c31af7Sopenharmony_ci *           formats (as described in section 8.5.1 and table 8.14
355e5c31af7Sopenharmony_ci *           of OpenGL 4.4 specification) that cannot be found in
356e5c31af7Sopenharmony_ci *           table 8.21 should be considered for the purpose of this
357e5c31af7Sopenharmony_ci *           test.
358e5c31af7Sopenharmony_ci *
359e5c31af7Sopenharmony_ci *  i) GL_INVALID_VALUE error should be generated if <minlevel> is
360e5c31af7Sopenharmony_ci *     larger than the greatest level of <origtexture>.
361e5c31af7Sopenharmony_ci *  j) GL_INVALID_VALUE error should be generated if <minlayer> is
362e5c31af7Sopenharmony_ci *     larger than the greatest layer of <origtexture>.
363e5c31af7Sopenharmony_ci *  k) GL_INVALID_VALUE error should be generated if <target> is
364e5c31af7Sopenharmony_ci *     GL_TEXTURE_CUBE_MAP and <numlayers> is not 6.
365e5c31af7Sopenharmony_ci *  l) GL_INVALID_VALUE error should be generated if <target> is
366e5c31af7Sopenharmony_ci *     GL_TEXTURE_CUBE_MAP_ARRAY and <numlayers> is not a multiple
367e5c31af7Sopenharmony_ci *     of 6.
368e5c31af7Sopenharmony_ci *  m) GL_INVALID_VALUE error should be generated if <target> is
369e5c31af7Sopenharmony_ci *     GL_TEXTURE_1D and <numlayers> is not 1;
370e5c31af7Sopenharmony_ci *  n) GL_INVALID_VALUE error should be generated if <target> is
371e5c31af7Sopenharmony_ci *     GL_TEXTURE_2D and <numlayers> is not 1;
372e5c31af7Sopenharmony_ci *  o) GL_INVALID_VALUE error should be generated if <target> is
373e5c31af7Sopenharmony_ci *     GL_TEXTURE_3D and <numlayers> is not 1;
374e5c31af7Sopenharmony_ci *  p) GL_INVALID_VALUE error should be generated if <target> is
375e5c31af7Sopenharmony_ci *     GL_TEXTURE_RECTANGLE and <numlayers> is not 1;
376e5c31af7Sopenharmony_ci *  q) GL_INVALID_VALUE error should be generated if <target> is
377e5c31af7Sopenharmony_ci *     GL_TEXTURE_2D_MULTISAMPLE and <numlayers> is not 1;
378e5c31af7Sopenharmony_ci *  r) GL_INVALID_OPERATION error should be generated if <target> is
379e5c31af7Sopenharmony_ci *     GL_TEXTURE_CUBE_MAP and original texture's width does not
380e5c31af7Sopenharmony_ci *     match original texture's height for all levels.
381e5c31af7Sopenharmony_ci *  s) GL_INVALID_OPERATION error should be generated if <target> is
382e5c31af7Sopenharmony_ci *     GL_TEXTURE_CUBE_MAP_ARRAY and original texture's width does
383e5c31af7Sopenharmony_ci *     not match original texture's height for all levels.
384e5c31af7Sopenharmony_ci *
385e5c31af7Sopenharmony_ci *  NOTE: GL_INVALID_OPERATION error should also be generated for cases
386e5c31af7Sopenharmony_ci *        when any of the original texture's dimension is larger
387e5c31af7Sopenharmony_ci *        than the maximum supported corresponding dimension of the
388e5c31af7Sopenharmony_ci *        new target, but that condition can be very tricky to test
389e5c31af7Sopenharmony_ci *        in a portable manner. Hence, the conformance test will
390e5c31af7Sopenharmony_ci *        not verify if the error is generated as specified.
391e5c31af7Sopenharmony_ci *
392e5c31af7Sopenharmony_ci **/
393e5c31af7Sopenharmony_ciclass TextureViewTestErrors : public deqp::TestCase
394e5c31af7Sopenharmony_ci{
395e5c31af7Sopenharmony_cipublic:
396e5c31af7Sopenharmony_ci	/* Public methods */
397e5c31af7Sopenharmony_ci	TextureViewTestErrors(deqp::Context& context);
398e5c31af7Sopenharmony_ci
399e5c31af7Sopenharmony_ci	virtual ~TextureViewTestErrors()
400e5c31af7Sopenharmony_ci	{
401e5c31af7Sopenharmony_ci	}
402e5c31af7Sopenharmony_ci
403e5c31af7Sopenharmony_ci	virtual void deinit();
404e5c31af7Sopenharmony_ci
405e5c31af7Sopenharmony_ci	virtual tcu::TestNode::IterateResult iterate();
406e5c31af7Sopenharmony_ci
407e5c31af7Sopenharmony_ciprivate:
408e5c31af7Sopenharmony_ci	/* Private fields */
409e5c31af7Sopenharmony_ci	glw::GLuint m_bo_id;
410e5c31af7Sopenharmony_ci	glw::GLuint m_reference_immutable_to_1d_id;
411e5c31af7Sopenharmony_ci	glw::GLuint m_reference_immutable_to_2d_id;
412e5c31af7Sopenharmony_ci	glw::GLuint m_reference_immutable_to_2d_array_id;
413e5c31af7Sopenharmony_ci	glw::GLuint m_reference_immutable_to_2d_array_32_by_33_id;
414e5c31af7Sopenharmony_ci	glw::GLuint m_reference_immutable_to_2d_multisample_id;
415e5c31af7Sopenharmony_ci	glw::GLuint m_reference_immutable_to_3d_id;
416e5c31af7Sopenharmony_ci	glw::GLuint m_reference_immutable_to_cube_map_id;
417e5c31af7Sopenharmony_ci	glw::GLuint m_reference_immutable_to_cube_map_array_id;
418e5c31af7Sopenharmony_ci	glw::GLuint m_reference_immutable_to_rectangle_id;
419e5c31af7Sopenharmony_ci	glw::GLuint m_reference_mutable_to_2d_id;
420e5c31af7Sopenharmony_ci	glw::GLuint m_test_modified_to_id_1;
421e5c31af7Sopenharmony_ci	glw::GLuint m_test_modified_to_id_2;
422e5c31af7Sopenharmony_ci	glw::GLuint m_test_modified_to_id_3;
423e5c31af7Sopenharmony_ci	glw::GLuint m_view_bound_to_id;
424e5c31af7Sopenharmony_ci	glw::GLuint m_view_never_bound_to_id;
425e5c31af7Sopenharmony_ci};
426e5c31af7Sopenharmony_ci
427e5c31af7Sopenharmony_ci/** Verify that sampling data from texture views, that use internal
428e5c31af7Sopenharmony_ci *  format which is compatible with the original texture's internal
429e5c31af7Sopenharmony_ci *  format, works correctly.
430e5c31af7Sopenharmony_ci *
431e5c31af7Sopenharmony_ci *  For simplicity, both the parent object and its corresponding
432e5c31af7Sopenharmony_ci *  view should use the same GL_RGBA8 internal format. Both texture
433e5c31af7Sopenharmony_ci *  and view should be used as parent objects for the purpose of
434e5c31af7Sopenharmony_ci *  the test.
435e5c31af7Sopenharmony_ci *
436e5c31af7Sopenharmony_ci *  The test should iterate over all texture targets enlisted in
437e5c31af7Sopenharmony_ci *  table 8.20 from OpenGL 4.4 specification, excluding GL_TEXTURE_BUFFER.
438e5c31af7Sopenharmony_ci *  For each such texture target, an immutable texture object that
439e5c31af7Sopenharmony_ci *  will be used as original object should be created. The object
440e5c31af7Sopenharmony_ci *  should be defined as follows:
441e5c31af7Sopenharmony_ci *
442e5c31af7Sopenharmony_ci *  a) For 1D texture targets, width of 4 should be used.
443e5c31af7Sopenharmony_ci *  b) For 2D texture targets, width and height of 4 should be used.
444e5c31af7Sopenharmony_ci *  c) For 3D texture targets, depth, width and height of 4 should
445e5c31af7Sopenharmony_ci *     be used;
446e5c31af7Sopenharmony_ci *  d) Cube-map texture objects should use a 4x4 face size;
447e5c31af7Sopenharmony_ci *  e) Arrayed 1D/2D/cube-map texture objects should have a depth
448e5c31af7Sopenharmony_ci *     of 4.
449e5c31af7Sopenharmony_ci *  f) Each slice/face/layer-face mip-map should be filled with
450e5c31af7Sopenharmony_ci *     a static color. If original texture is multi-sampled, subsequent
451e5c31af7Sopenharmony_ci *     samples should be assigned a different color. Exact R/G/B/A
452e5c31af7Sopenharmony_ci *     intensities are arbitrary but they must be unique across all
453e5c31af7Sopenharmony_ci *     mip-maps and samples considered for a particular iteration.
454e5c31af7Sopenharmony_ci *     Mip-maps should *not* be generated - instead, it is expected
455e5c31af7Sopenharmony_ci *     the test will fill them manually with content using API (for
456e5c31af7Sopenharmony_ci *     non-multisampled cases), or by means of a simple FS+VS
457e5c31af7Sopenharmony_ci *     program (for multisampled render targets).
458e5c31af7Sopenharmony_ci *
459e5c31af7Sopenharmony_ci *  For each such original texture object, texture views should be
460e5c31af7Sopenharmony_ci *  created for all compatible texture targets. These views should
461e5c31af7Sopenharmony_ci *  be configured as below:
462e5c31af7Sopenharmony_ci *
463e5c31af7Sopenharmony_ci *  * minlayer:  1 (for arrayed/cube-map/cube-map arrayed views),
464e5c31af7Sopenharmony_ci *               0 otherwise;
465e5c31af7Sopenharmony_ci *  * numlayers: 12 (for cube-map arrayed views),
466e5c31af7Sopenharmony_ci *               6 (for cube-map views)
467e5c31af7Sopenharmony_ci *               2 (for arrayed views),
468e5c31af7Sopenharmony_ci *               1 otherwise;
469e5c31af7Sopenharmony_ci *
470e5c31af7Sopenharmony_ci *  * minlevel:  1;
471e5c31af7Sopenharmony_ci *  * numlevels: 2;
472e5c31af7Sopenharmony_ci *
473e5c31af7Sopenharmony_ci *  For testing purposes, the test should use the following rendering
474e5c31af7Sopenharmony_ci *  stages (forming a program object):
475e5c31af7Sopenharmony_ci *
476e5c31af7Sopenharmony_ci *  - Vertex shader;
477e5c31af7Sopenharmony_ci *  - Tessellation control;
478e5c31af7Sopenharmony_ci *  - Tessellation evaluation;
479e5c31af7Sopenharmony_ci *  - Geometry shader;         (should output a triangle strip forming
480e5c31af7Sopenharmony_ci *                              a full-screen quad);
481e5c31af7Sopenharmony_ci *  - Fragment shader;
482e5c31af7Sopenharmony_ci *
483e5c31af7Sopenharmony_ci *  In each stage (excluding fragment shader), as many samples as
484e5c31af7Sopenharmony_ci *  available (for multisample views) OR a single texel should be
485e5c31af7Sopenharmony_ci *  sampled at central (0.5, 0.5, ...) location using textureLod().
486e5c31af7Sopenharmony_ci *  The data should then be compared with reference values and the
487e5c31af7Sopenharmony_ci *  validation result should be passed to next stage using
488e5c31af7Sopenharmony_ci *  an output variable. Subsequent stages should pass validation results
489e5c31af7Sopenharmony_ci *  from all previous stages to following stages until geometry shader
490e5c31af7Sopenharmony_ci *  stage is reached. The information should be captured by the test
491e5c31af7Sopenharmony_ci *  using XFB and verified.
492e5c31af7Sopenharmony_ci *  Fragment shader should output a green colour, if the sampling
493e5c31af7Sopenharmony_ci *  operation returned a valid set of colors for (U, V) location,
494e5c31af7Sopenharmony_ci *  corresponding to rasterized fragment location, red otherwise.
495e5c31af7Sopenharmony_ci *
496e5c31af7Sopenharmony_ci *  The test passes if the sampling operation worked correctly in
497e5c31af7Sopenharmony_ci *  all stages for all texture's internal format+view's internal
498e5c31af7Sopenharmony_ci *  format combinations.
499e5c31af7Sopenharmony_ci *
500e5c31af7Sopenharmony_ci **/
501e5c31af7Sopenharmony_ciclass TextureViewTestViewSampling : public deqp::TestCase
502e5c31af7Sopenharmony_ci{
503e5c31af7Sopenharmony_cipublic:
504e5c31af7Sopenharmony_ci	/* Public methods */
505e5c31af7Sopenharmony_ci	TextureViewTestViewSampling(deqp::Context& context);
506e5c31af7Sopenharmony_ci
507e5c31af7Sopenharmony_ci	virtual tcu::TestNode::IterateResult iterate();
508e5c31af7Sopenharmony_ci
509e5c31af7Sopenharmony_ciprotected:
510e5c31af7Sopenharmony_ci	/* Protected methods */
511e5c31af7Sopenharmony_ci	virtual void deinit();
512e5c31af7Sopenharmony_ci
513e5c31af7Sopenharmony_ciprivate:
514e5c31af7Sopenharmony_ci	/* Private type declarations */
515e5c31af7Sopenharmony_ci	struct _reference_color_storage
516e5c31af7Sopenharmony_ci	{
517e5c31af7Sopenharmony_ci		tcu::Vec4* data;
518e5c31af7Sopenharmony_ci
519e5c31af7Sopenharmony_ci		unsigned int n_faces;
520e5c31af7Sopenharmony_ci		unsigned int n_layers;
521e5c31af7Sopenharmony_ci		unsigned int n_mipmaps;
522e5c31af7Sopenharmony_ci		unsigned int n_samples;
523e5c31af7Sopenharmony_ci
524e5c31af7Sopenharmony_ci		/** Constructor.
525e5c31af7Sopenharmony_ci		 *
526e5c31af7Sopenharmony_ci		 *  @param in_n_faces   Amount of faces to initialize the storage for.
527e5c31af7Sopenharmony_ci		 *                      Must not be 0.
528e5c31af7Sopenharmony_ci		 *  @param in_n_layers  Amount of layers to initialize the storage for.
529e5c31af7Sopenharmony_ci		 *                      Must not be 0.
530e5c31af7Sopenharmony_ci		 *  @param in_n_mipmaps Amount of mip-maps to initialize the storage for.
531e5c31af7Sopenharmony_ci		 *                      Must not be 0.
532e5c31af7Sopenharmony_ci		 *  @param in_n_samples Amount of samples to initialize the storage for.
533e5c31af7Sopenharmony_ci		 *                      Must not be 0.
534e5c31af7Sopenharmony_ci		 **/
535e5c31af7Sopenharmony_ci		explicit _reference_color_storage(const unsigned int in_n_faces, const unsigned int in_n_layers,
536e5c31af7Sopenharmony_ci										  const unsigned int in_n_mipmaps, const unsigned int in_n_samples)
537e5c31af7Sopenharmony_ci		{
538e5c31af7Sopenharmony_ci			DE_ASSERT(in_n_faces != 0);
539e5c31af7Sopenharmony_ci			DE_ASSERT(in_n_layers != 0);
540e5c31af7Sopenharmony_ci			DE_ASSERT(in_n_mipmaps != 0);
541e5c31af7Sopenharmony_ci			DE_ASSERT(in_n_samples != 0);
542e5c31af7Sopenharmony_ci
543e5c31af7Sopenharmony_ci			n_faces   = in_n_faces;
544e5c31af7Sopenharmony_ci			n_layers  = in_n_layers;
545e5c31af7Sopenharmony_ci			n_mipmaps = in_n_mipmaps;
546e5c31af7Sopenharmony_ci			n_samples = in_n_samples;
547e5c31af7Sopenharmony_ci
548e5c31af7Sopenharmony_ci			data = new tcu::Vec4[in_n_faces * in_n_layers * in_n_mipmaps * in_n_samples];
549e5c31af7Sopenharmony_ci		}
550e5c31af7Sopenharmony_ci
551e5c31af7Sopenharmony_ci		/** Destructor */
552e5c31af7Sopenharmony_ci		~_reference_color_storage()
553e5c31af7Sopenharmony_ci		{
554e5c31af7Sopenharmony_ci			if (data != DE_NULL)
555e5c31af7Sopenharmony_ci			{
556e5c31af7Sopenharmony_ci				delete[] data;
557e5c31af7Sopenharmony_ci
558e5c31af7Sopenharmony_ci				data = DE_NULL;
559e5c31af7Sopenharmony_ci			}
560e5c31af7Sopenharmony_ci		}
561e5c31af7Sopenharmony_ci	};
562e5c31af7Sopenharmony_ci
563e5c31af7Sopenharmony_ci	/* Private methods */
564e5c31af7Sopenharmony_ci	void deinitIterationSpecificProgramAndShaderObjects();
565e5c31af7Sopenharmony_ci	void deinitPerSampleFillerProgramAndShaderObjects();
566e5c31af7Sopenharmony_ci	void deinitTextureObjects();
567e5c31af7Sopenharmony_ci	bool executeTest();
568e5c31af7Sopenharmony_ci	void initIterationSpecificProgramObject();
569e5c31af7Sopenharmony_ci	void initParentTextureContents();
570e5c31af7Sopenharmony_ci	void initPerSampleFillerProgramObject();
571e5c31af7Sopenharmony_ci	void initTest();
572e5c31af7Sopenharmony_ci
573e5c31af7Sopenharmony_ci	void initTextureObject(bool is_view_texture, glw::GLenum texture_target, glw::GLenum view_texture_target);
574e5c31af7Sopenharmony_ci
575e5c31af7Sopenharmony_ci	tcu::Vec4 getRandomReferenceColor();
576e5c31af7Sopenharmony_ci
577e5c31af7Sopenharmony_ci	tcu::Vec4 getReferenceColor(unsigned int n_layer, unsigned int n_face, unsigned int n_mipmap,
578e5c31af7Sopenharmony_ci								unsigned int n_sample);
579e5c31af7Sopenharmony_ci
580e5c31af7Sopenharmony_ci	glw::GLint getMaxConformantSampleCount(glw::GLenum target, glw::GLenum internalFormat);
581e5c31af7Sopenharmony_ci
582e5c31af7Sopenharmony_ci	void resetReferenceColorStorage(unsigned int n_layers, unsigned int n_faces, unsigned int n_mipmaps,
583e5c31af7Sopenharmony_ci									unsigned int n_samples);
584e5c31af7Sopenharmony_ci
585e5c31af7Sopenharmony_ci	void setReferenceColor(unsigned int n_layer, unsigned int n_face, unsigned int n_mipmap, unsigned int n_sample,
586e5c31af7Sopenharmony_ci						   tcu::Vec4 color);
587e5c31af7Sopenharmony_ci
588e5c31af7Sopenharmony_ci	/* Private variables */
589e5c31af7Sopenharmony_ci	glw::GLuint m_bo_id;
590e5c31af7Sopenharmony_ci	glw::GLuint m_fs_id;
591e5c31af7Sopenharmony_ci	glw::GLuint m_gs_id;
592e5c31af7Sopenharmony_ci	glw::GLuint m_po_id;
593e5c31af7Sopenharmony_ci	glw::GLint  m_po_lod_location;
594e5c31af7Sopenharmony_ci	glw::GLint  m_po_n_face_location;
595e5c31af7Sopenharmony_ci	glw::GLint  m_po_reference_colors_location;
596e5c31af7Sopenharmony_ci	glw::GLint  m_po_texture_location;
597e5c31af7Sopenharmony_ci	glw::GLint  m_po_z_float_location;
598e5c31af7Sopenharmony_ci	glw::GLint  m_po_z_int_location;
599e5c31af7Sopenharmony_ci	glw::GLuint m_tc_id;
600e5c31af7Sopenharmony_ci	glw::GLuint m_te_id;
601e5c31af7Sopenharmony_ci	glw::GLuint m_vs_id;
602e5c31af7Sopenharmony_ci
603e5c31af7Sopenharmony_ci	glw::GLuint m_per_sample_filler_fs_id;
604e5c31af7Sopenharmony_ci	glw::GLuint m_per_sample_filler_gs_id;
605e5c31af7Sopenharmony_ci	glw::GLuint m_per_sample_filler_po_id;
606e5c31af7Sopenharmony_ci	glw::GLint  m_per_sample_filler_po_layer_id_location;
607e5c31af7Sopenharmony_ci	glw::GLint  m_per_sample_filler_po_reference_colors_location;
608e5c31af7Sopenharmony_ci	glw::GLuint m_per_sample_filler_vs_id;
609e5c31af7Sopenharmony_ci
610e5c31af7Sopenharmony_ci	glw::GLuint m_result_to_id;
611e5c31af7Sopenharmony_ci	glw::GLuint m_to_id;
612e5c31af7Sopenharmony_ci	glw::GLuint m_view_to_id;
613e5c31af7Sopenharmony_ci
614e5c31af7Sopenharmony_ci	glw::GLuint m_fbo_id;
615e5c31af7Sopenharmony_ci	glw::GLuint m_vao_id;
616e5c31af7Sopenharmony_ci
617e5c31af7Sopenharmony_ci	glw::GLint m_max_color_texture_samples_gl_value;
618e5c31af7Sopenharmony_ci
619e5c31af7Sopenharmony_ci	glw::GLuint m_iteration_parent_texture_depth;
620e5c31af7Sopenharmony_ci	glw::GLuint m_iteration_parent_texture_height;
621e5c31af7Sopenharmony_ci	glw::GLuint m_iteration_parent_texture_n_levels;
622e5c31af7Sopenharmony_ci	glw::GLuint m_iteration_parent_texture_n_samples;
623e5c31af7Sopenharmony_ci	glw::GLenum m_iteration_parent_texture_target;
624e5c31af7Sopenharmony_ci	glw::GLuint m_iteration_parent_texture_width;
625e5c31af7Sopenharmony_ci	glw::GLuint m_iteration_view_texture_minlayer;
626e5c31af7Sopenharmony_ci	glw::GLuint m_iteration_view_texture_numlayers;
627e5c31af7Sopenharmony_ci	glw::GLuint m_iteration_view_texture_minlevel;
628e5c31af7Sopenharmony_ci	glw::GLuint m_iteration_view_texture_numlevels;
629e5c31af7Sopenharmony_ci	glw::GLenum m_iteration_view_texture_target;
630e5c31af7Sopenharmony_ci
631e5c31af7Sopenharmony_ci	const glw::GLuint m_reference_texture_depth;
632e5c31af7Sopenharmony_ci	const glw::GLuint m_reference_texture_height;
633e5c31af7Sopenharmony_ci	const glw::GLuint m_reference_texture_n_mipmaps;
634e5c31af7Sopenharmony_ci	const glw::GLuint m_reference_texture_width;
635e5c31af7Sopenharmony_ci
636e5c31af7Sopenharmony_ci	_reference_color_storage* m_reference_color_storage;
637e5c31af7Sopenharmony_ci	unsigned char*			  m_result_data;
638e5c31af7Sopenharmony_ci};
639e5c31af7Sopenharmony_ci
640e5c31af7Sopenharmony_ci/** Verify view class functionality.
641e5c31af7Sopenharmony_ci *
642e5c31af7Sopenharmony_ci *  Consider all view classes presented in table 8.20 of OpenGL 4.4
643e5c31af7Sopenharmony_ci *  Specification. For each view class, consider all internal format
644e5c31af7Sopenharmony_ci *  combinations for the purpose of the test.
645e5c31af7Sopenharmony_ci *
646e5c31af7Sopenharmony_ci *  For each internal format, a texture object of specified internal
647e5c31af7Sopenharmony_ci *  format and of 2x2 base mip-map resolution should be used.
648e5c31af7Sopenharmony_ci *
649e5c31af7Sopenharmony_ci *  For each internal format, a program object consisting of a vertex
650e5c31af7Sopenharmony_ci *  shader stage should be used. The shader should sample all 4 texels
651e5c31af7Sopenharmony_ci *  of the view and store retrieved data in output variables.
652e5c31af7Sopenharmony_ci *  These values should then be XFBed to the test.
653e5c31af7Sopenharmony_ci *
654e5c31af7Sopenharmony_ci *  The test passes if all retrieved values for all pairs considered
655e5c31af7Sopenharmony_ci *  are found to be valid.
656e5c31af7Sopenharmony_ci *
657e5c31af7Sopenharmony_ci **/
658e5c31af7Sopenharmony_ciclass TextureViewTestViewClasses : public deqp::TestCase
659e5c31af7Sopenharmony_ci{
660e5c31af7Sopenharmony_cipublic:
661e5c31af7Sopenharmony_ci	/* Public methods */
662e5c31af7Sopenharmony_ci	TextureViewTestViewClasses(deqp::Context& context);
663e5c31af7Sopenharmony_ci
664e5c31af7Sopenharmony_ci	virtual tcu::TestNode::IterateResult iterate();
665e5c31af7Sopenharmony_ci
666e5c31af7Sopenharmony_ciprotected:
667e5c31af7Sopenharmony_ci	/* Protected methods */
668e5c31af7Sopenharmony_ci	virtual void deinit();
669e5c31af7Sopenharmony_ci
670e5c31af7Sopenharmony_ciprivate:
671e5c31af7Sopenharmony_ci	/* Private methods */
672e5c31af7Sopenharmony_ci	void getComponentDataForByteAlignedInternalformat(const unsigned char* data, const unsigned int n_components,
673e5c31af7Sopenharmony_ci													  const unsigned int*		 component_sizes,
674e5c31af7Sopenharmony_ci													  const TextureView::_format format, void* result);
675e5c31af7Sopenharmony_ci
676e5c31af7Sopenharmony_ci	void initBufferObject(glw::GLenum texture_internalformat, glw::GLenum view_internalformat);
677e5c31af7Sopenharmony_ci
678e5c31af7Sopenharmony_ci	void initProgramObject(glw::GLenum texture_internalformat, glw::GLenum view_internalformat);
679e5c31af7Sopenharmony_ci
680e5c31af7Sopenharmony_ci	void initTest();
681e5c31af7Sopenharmony_ci
682e5c31af7Sopenharmony_ci	void initTextureObject(bool should_init_parent_texture, glw::GLenum texture_internalformat,
683e5c31af7Sopenharmony_ci						   glw::GLenum view_internalformat);
684e5c31af7Sopenharmony_ci
685e5c31af7Sopenharmony_ci	void verifyResultData(glw::GLenum texture_internalformat, glw::GLenum view_internalformat,
686e5c31af7Sopenharmony_ci						  const unsigned char* texture_data_ptr, const unsigned char* view_data_ptr);
687e5c31af7Sopenharmony_ci
688e5c31af7Sopenharmony_ci	/* Private fields */
689e5c31af7Sopenharmony_ci	glw::GLuint m_bo_id;
690e5c31af7Sopenharmony_ci	glw::GLuint m_po_id;
691e5c31af7Sopenharmony_ci	glw::GLuint m_to_id;
692e5c31af7Sopenharmony_ci	glw::GLuint m_to_temp_id;
693e5c31af7Sopenharmony_ci	glw::GLuint m_vao_id;
694e5c31af7Sopenharmony_ci	glw::GLuint m_view_to_id;
695e5c31af7Sopenharmony_ci	glw::GLuint m_vs_id;
696e5c31af7Sopenharmony_ci
697e5c31af7Sopenharmony_ci	unsigned char* m_decompressed_mipmap_data;
698e5c31af7Sopenharmony_ci	unsigned char* m_mipmap_data;
699e5c31af7Sopenharmony_ci
700e5c31af7Sopenharmony_ci	unsigned int	   m_bo_size;
701e5c31af7Sopenharmony_ci	bool			   m_has_test_failed;
702e5c31af7Sopenharmony_ci	const unsigned int m_texture_height;
703e5c31af7Sopenharmony_ci	const glw::GLenum  m_texture_unit_for_parent_texture;
704e5c31af7Sopenharmony_ci	const glw::GLenum  m_texture_unit_for_view_texture;
705e5c31af7Sopenharmony_ci	const unsigned int m_texture_width;
706e5c31af7Sopenharmony_ci	unsigned int	   m_view_data_offset;
707e5c31af7Sopenharmony_ci};
708e5c31af7Sopenharmony_ci
709e5c31af7Sopenharmony_ci/**
710e5c31af7Sopenharmony_ci *  Verify view/parent texture coherency.
711e5c31af7Sopenharmony_ci *
712e5c31af7Sopenharmony_ci *  Consider an original 2D texture of 64x64 base mip-map resolution,
713e5c31af7Sopenharmony_ci *  using GL_RGBA8 internal format, filled with horizontal linear
714e5c31af7Sopenharmony_ci *  gradient from (0.0, 0.1, 1.0, 1.0) to (1.0, 0.9, 0.0, 0.0).
715e5c31af7Sopenharmony_ci *  All subsequent mip-maps are to be generated by glGenerateMipmap().
716e5c31af7Sopenharmony_ci *
717e5c31af7Sopenharmony_ci *  A 2D texture view should be generated from this texture, using
718e5c31af7Sopenharmony_ci *  mipmaps from levels 1 to 2 (inclusive).
719e5c31af7Sopenharmony_ci *
720e5c31af7Sopenharmony_ci *  The test should verify the following scenarios are handled
721e5c31af7Sopenharmony_ci *  correctly by GL implementation:
722e5c31af7Sopenharmony_ci *
723e5c31af7Sopenharmony_ci *  1) glTexSubImage2D() should be used on the view to replace portion
724e5c31af7Sopenharmony_ci *     of the gradient with a static color. A vertex shader should
725e5c31af7Sopenharmony_ci *     then be used to sample the parent texture at central
726e5c31af7Sopenharmony_ci *     location of that sub-region and verify it has been replaced
727e5c31af7Sopenharmony_ci *     with the static color. Result of the comparison (true/false)
728e5c31af7Sopenharmony_ci *     should be XFBed and verified by the test; *No* memory barrier
729e5c31af7Sopenharmony_ci *     is to be used between the first two steps.
730e5c31af7Sopenharmony_ci *  2) The view should be updated as in step 1), with glTexSubImage2D()
731e5c31af7Sopenharmony_ci *     being replaced with glBlitFramebuffer(). A texture filled
732e5c31af7Sopenharmony_ci *     with a static color should be used as a source for the blitting
733e5c31af7Sopenharmony_ci *     operation.
734e5c31af7Sopenharmony_ci *  3) A program object should be used to fill the view with
735e5c31af7Sopenharmony_ci *     reversed (1.0, 0.9, 0.0, 0.0)->(0.0, 0.1, 1.0, 1.0) gradient.
736e5c31af7Sopenharmony_ci *     Contents of the parent texture should then be validated with
737e5c31af7Sopenharmony_ci *     another program object and the result should be verified by
738e5c31af7Sopenharmony_ci *     XFBing the comparison outcome, similar to what has been
739e5c31af7Sopenharmony_ci *     described for step 1). Again, *no* memory barrier is to be
740e5c31af7Sopenharmony_ci *     used in-between.
741e5c31af7Sopenharmony_ci *  4) The view should be bound to an image unit. The contents of
742e5c31af7Sopenharmony_ci *     that view should then be completely replaced with the reversed
743e5c31af7Sopenharmony_ci *     gradient by doing a sufficient amount of writes, assuming each vertex
744e5c31af7Sopenharmony_ci *     shader invocation performs a single store operation in an
745e5c31af7Sopenharmony_ci *     unique location. A GL_TEXTURE_FETCH_BARRIER_BIT memory
746e5c31af7Sopenharmony_ci *     barrier should be issued. The contents of the parent texture
747e5c31af7Sopenharmony_ci *     should then be verified, as described in step 1) and 3).
748e5c31af7Sopenharmony_ci *  5) The view should be updated as in step 4). However, this time
749e5c31af7Sopenharmony_ci *     a GL_TEXTURE_UPDATE_BARRIER_BIT memory barrier should be issued.
750e5c31af7Sopenharmony_ci *     The contents of the parent texture should then be read with
751e5c31af7Sopenharmony_ci *     a glGetTexImage() call and verified by the test.
752e5c31af7Sopenharmony_ci *
753e5c31af7Sopenharmony_ci *     (NOTE: cases 4) and 5) should only be executed on implementations
754e5c31af7Sopenharmony_ci *            reporting GL_ARB_shader_image_load_store extension
755e5c31af7Sopenharmony_ci *            support, owing to lack of glMemoryBarrier() support
756e5c31af7Sopenharmony_ci *            in OpenGL 4.0)
757e5c31af7Sopenharmony_ci *
758e5c31af7Sopenharmony_ci *  6), 7), 8), 9) Execute tests 1), 2), 3), 4), 5), replacing "texture
759e5c31af7Sopenharmony_ci *                 views" with "parent textures" and "parent textures"
760e5c31af7Sopenharmony_ci *                 with "texture views".
761e5c31af7Sopenharmony_ci */
762e5c31af7Sopenharmony_ciclass TextureViewTestCoherency : public deqp::TestCase
763e5c31af7Sopenharmony_ci{
764e5c31af7Sopenharmony_cipublic:
765e5c31af7Sopenharmony_ci	/* Public methods */
766e5c31af7Sopenharmony_ci	TextureViewTestCoherency(deqp::Context& context);
767e5c31af7Sopenharmony_ci
768e5c31af7Sopenharmony_ci	virtual void						 deinit();
769e5c31af7Sopenharmony_ci	virtual tcu::TestNode::IterateResult iterate();
770e5c31af7Sopenharmony_ci
771e5c31af7Sopenharmony_ciprivate:
772e5c31af7Sopenharmony_ci	/* Private type definitions */
773e5c31af7Sopenharmony_ci	enum _barrier_type
774e5c31af7Sopenharmony_ci	{
775e5c31af7Sopenharmony_ci		BARRIER_TYPE_NONE,
776e5c31af7Sopenharmony_ci		BARRIER_TYPE_TEXTURE_FETCH_BARRIER_BIT,
777e5c31af7Sopenharmony_ci		BARRIER_TYPE_TEXTURE_UPDATE_BUFFER_BIT
778e5c31af7Sopenharmony_ci	};
779e5c31af7Sopenharmony_ci
780e5c31af7Sopenharmony_ci	enum _texture_type
781e5c31af7Sopenharmony_ci	{
782e5c31af7Sopenharmony_ci		TEXTURE_TYPE_PARENT_TEXTURE,
783e5c31af7Sopenharmony_ci		TEXTURE_TYPE_TEXTURE_VIEW,
784e5c31af7Sopenharmony_ci		TEXTURE_TYPE_IMAGE
785e5c31af7Sopenharmony_ci	};
786e5c31af7Sopenharmony_ci
787e5c31af7Sopenharmony_ci	enum _verification_mean
788e5c31af7Sopenharmony_ci	{
789e5c31af7Sopenharmony_ci		VERIFICATION_MEAN_PROGRAM,
790e5c31af7Sopenharmony_ci		VERIFICATION_MEAN_GLGETTEXIMAGE
791e5c31af7Sopenharmony_ci	};
792e5c31af7Sopenharmony_ci
793e5c31af7Sopenharmony_ci	/* Private methods */
794e5c31af7Sopenharmony_ci	void checkAPICallCoherency(_texture_type texture_type, bool should_use_glTexSubImage2D);
795e5c31af7Sopenharmony_ci
796e5c31af7Sopenharmony_ci	void checkProgramWriteCoherency(_texture_type texture_type, bool should_use_images, _barrier_type barrier_type,
797e5c31af7Sopenharmony_ci									_verification_mean verification_mean);
798e5c31af7Sopenharmony_ci
799e5c31af7Sopenharmony_ci	unsigned char* getHorizontalGradientData() const;
800e5c31af7Sopenharmony_ci
801e5c31af7Sopenharmony_ci	void getReadPropertiesForTextureType(_texture_type texture_type, glw::GLuint* out_to_id,
802e5c31af7Sopenharmony_ci										 unsigned int* out_read_lod) const;
803e5c31af7Sopenharmony_ci
804e5c31af7Sopenharmony_ci	unsigned char* getStaticColorTextureData(unsigned int width, unsigned int height) const;
805e5c31af7Sopenharmony_ci
806e5c31af7Sopenharmony_ci	void getWritePropertiesForTextureType(_texture_type texture_type, glw::GLuint* out_to_id, unsigned int* out_width,
807e5c31af7Sopenharmony_ci										  unsigned int* out_height) const;
808e5c31af7Sopenharmony_ci
809e5c31af7Sopenharmony_ci	void initBufferObjects();
810e5c31af7Sopenharmony_ci	void initFBO();
811e5c31af7Sopenharmony_ci	void initPrograms();
812e5c31af7Sopenharmony_ci	void initTextureContents();
813e5c31af7Sopenharmony_ci	void initTextures();
814e5c31af7Sopenharmony_ci	void initVAO();
815e5c31af7Sopenharmony_ci
816e5c31af7Sopenharmony_ci	/* Private fields */
817e5c31af7Sopenharmony_ci	bool		m_are_images_supported;
818e5c31af7Sopenharmony_ci	glw::GLuint m_bo_id;
819e5c31af7Sopenharmony_ci	glw::GLuint m_draw_fbo_id;
820e5c31af7Sopenharmony_ci	glw::GLuint m_gradient_verification_po_id;
821e5c31af7Sopenharmony_ci	glw::GLint  m_gradient_verification_po_sample_exact_uv_location;
822e5c31af7Sopenharmony_ci	glw::GLint  m_gradient_verification_po_lod_location;
823e5c31af7Sopenharmony_ci	glw::GLint  m_gradient_verification_po_texture_location;
824e5c31af7Sopenharmony_ci	glw::GLuint m_gradient_verification_vs_id;
825e5c31af7Sopenharmony_ci	glw::GLint  m_gradient_image_write_image_size_location;
826e5c31af7Sopenharmony_ci	glw::GLuint m_gradient_image_write_po_id;
827e5c31af7Sopenharmony_ci	glw::GLuint m_gradient_image_write_vs_id;
828e5c31af7Sopenharmony_ci	glw::GLuint m_gradient_write_po_id;
829e5c31af7Sopenharmony_ci	glw::GLuint m_gradient_write_fs_id;
830e5c31af7Sopenharmony_ci	glw::GLuint m_gradient_write_vs_id;
831e5c31af7Sopenharmony_ci	glw::GLuint m_read_fbo_id;
832e5c31af7Sopenharmony_ci	glw::GLuint m_static_to_id;
833e5c31af7Sopenharmony_ci	glw::GLuint m_to_id;
834e5c31af7Sopenharmony_ci	glw::GLuint m_vao_id;
835e5c31af7Sopenharmony_ci	glw::GLuint m_view_to_id;
836e5c31af7Sopenharmony_ci	glw::GLint  m_verification_po_expected_color_location;
837e5c31af7Sopenharmony_ci	glw::GLint  m_verification_po_lod_location;
838e5c31af7Sopenharmony_ci	glw::GLuint m_verification_po_id;
839e5c31af7Sopenharmony_ci	glw::GLuint m_verification_vs_id;
840e5c31af7Sopenharmony_ci
841e5c31af7Sopenharmony_ci	unsigned char m_static_color_byte[4 /* rgba */];
842e5c31af7Sopenharmony_ci	float		  m_static_color_float[4 /* rgba */];
843e5c31af7Sopenharmony_ci
844e5c31af7Sopenharmony_ci	const unsigned int m_static_texture_height;
845e5c31af7Sopenharmony_ci	const unsigned int m_static_texture_width;
846e5c31af7Sopenharmony_ci	const unsigned int m_texture_height;
847e5c31af7Sopenharmony_ci	const unsigned int m_texture_n_components;
848e5c31af7Sopenharmony_ci	const unsigned int m_texture_n_levels;
849e5c31af7Sopenharmony_ci	const unsigned int m_texture_width;
850e5c31af7Sopenharmony_ci};
851e5c31af7Sopenharmony_ci
852e5c31af7Sopenharmony_ci/** Verify GL_TEXTURE_BASE_LEVEL and GL_TEXTURE_MAX_LEVEL are
853e5c31af7Sopenharmony_ci *  interpreted relative to the view, not to the original data
854e5c31af7Sopenharmony_ci *  store.
855e5c31af7Sopenharmony_ci *
856e5c31af7Sopenharmony_ci *  Consider original 2D texture of 64x64 base mip-map resolution,
857e5c31af7Sopenharmony_ci *  using GL_RGBA8 internal format, filled with:
858e5c31af7Sopenharmony_ci *
859e5c31af7Sopenharmony_ci *  * horizontal linear gradient from (0.0, 0.1, 0,2, 0.3) to
860e5c31af7Sopenharmony_ci *    (1.0, 0.9, 0.8, 0.7) at level 0;
861e5c31af7Sopenharmony_ci *  * horizontal linear gradient from (0.1, 0.2, 0.3, 0.4) to
862e5c31af7Sopenharmony_ci *    (0.9, 0.8, 0.7, 0.6) at level 1;
863e5c31af7Sopenharmony_ci *  * horizontal linear gradient from (0.2, 0.3, 0.4, 0.5) to
864e5c31af7Sopenharmony_ci *    (0.8, 0.7, 0.6, 0.5) at level 2;
865e5c31af7Sopenharmony_ci *  * ..and so on.
866e5c31af7Sopenharmony_ci *
867e5c31af7Sopenharmony_ci *  GL_TEXTURE_BASE_LEVEL of the texture should be set at 2,
868e5c31af7Sopenharmony_ci *  GL_TEXTURE_MAX_LEVEL of the texture should be set at 4.
869e5c31af7Sopenharmony_ci *
870e5c31af7Sopenharmony_ci *  A 2D texture view should be generated from this texture, using
871e5c31af7Sopenharmony_ci *  mipmaps from 0 to 5 (inclusive).
872e5c31af7Sopenharmony_ci *
873e5c31af7Sopenharmony_ci *  GL_TEXTURE_BASE_LEVEL of the view should be set at 1,
874e5c31af7Sopenharmony_ci *  GL_TEXTURE_MAX_LEVEL of the view should be set at 2.
875e5c31af7Sopenharmony_ci *
876e5c31af7Sopenharmony_ci *  The test should perform the following:
877e5c31af7Sopenharmony_ci *
878e5c31af7Sopenharmony_ci *  1) First, a FS+VS program should be executed twice. The vertex
879e5c31af7Sopenharmony_ci *     shader should output 4 vertices forming a triangle-strip, forming
880e5c31af7Sopenharmony_ci *     a quad spanning from (-1, -1, 0, 1) to (1, 1, 0, 1). Each
881e5c31af7Sopenharmony_ci *     vertex should be assigned a corresponding UV location.
882e5c31af7Sopenharmony_ci *     The fragment shader should sample input texture view with
883e5c31af7Sopenharmony_ci *     textureLod() at fragment-specific UV using LOD 0 in the
884e5c31af7Sopenharmony_ci *     first run, and LOD 1 in the second run.
885e5c31af7Sopenharmony_ci *     The sampled vec4 should be written into a draw buffer, to which
886e5c31af7Sopenharmony_ci *     a texture has been attached of exactly the same resolution
887e5c31af7Sopenharmony_ci *     and internal format as the input texture view's mip-map being
888e5c31af7Sopenharmony_ci *     processed at the time of invocation.
889e5c31af7Sopenharmony_ci *
890e5c31af7Sopenharmony_ci *     This pass should provide us with LOD 0 and LOD 1 texture data,
891e5c31af7Sopenharmony_ci *     as configured with GL_TEXTURE_BASE_LEVEL and
892e5c31af7Sopenharmony_ci *     GL_TEXTURE_MAX_LEVEL view parameters.
893e5c31af7Sopenharmony_ci *
894e5c31af7Sopenharmony_ci *  2) Having executed the aforementioned program, the test should
895e5c31af7Sopenharmony_ci *     download the textures that step 1 has rendered to using
896e5c31af7Sopenharmony_ci *     glGetTexImage() and verify correct mipmaps have been sampled
897e5c31af7Sopenharmony_ci *     by textureLod().
898e5c31af7Sopenharmony_ci *
899e5c31af7Sopenharmony_ci *  Test passes if the retrieved texture data is valid.
900e5c31af7Sopenharmony_ci **/
901e5c31af7Sopenharmony_ciclass TextureViewTestBaseAndMaxLevels : public deqp::TestCase
902e5c31af7Sopenharmony_ci{
903e5c31af7Sopenharmony_cipublic:
904e5c31af7Sopenharmony_ci	/* Public methods */
905e5c31af7Sopenharmony_ci	TextureViewTestBaseAndMaxLevels(deqp::Context& context);
906e5c31af7Sopenharmony_ci
907e5c31af7Sopenharmony_ci	virtual void						 deinit();
908e5c31af7Sopenharmony_ci	virtual tcu::TestNode::IterateResult iterate();
909e5c31af7Sopenharmony_ci
910e5c31af7Sopenharmony_ciprivate:
911e5c31af7Sopenharmony_ci	/* Private methods */
912e5c31af7Sopenharmony_ci	void initProgram();
913e5c31af7Sopenharmony_ci	void initTest();
914e5c31af7Sopenharmony_ci	void initTextures();
915e5c31af7Sopenharmony_ci
916e5c31af7Sopenharmony_ci	/* Private fields */
917e5c31af7Sopenharmony_ci	const unsigned int m_texture_height;
918e5c31af7Sopenharmony_ci	const unsigned int m_texture_n_components;
919e5c31af7Sopenharmony_ci	const unsigned int m_texture_n_levels;
920e5c31af7Sopenharmony_ci	const unsigned int m_texture_width;
921e5c31af7Sopenharmony_ci	const unsigned int m_view_height;
922e5c31af7Sopenharmony_ci	const unsigned int m_view_width;
923e5c31af7Sopenharmony_ci
924e5c31af7Sopenharmony_ci	unsigned char* m_layer_data_lod0;
925e5c31af7Sopenharmony_ci	unsigned char* m_layer_data_lod1;
926e5c31af7Sopenharmony_ci
927e5c31af7Sopenharmony_ci	glw::GLuint m_fbo_id;
928e5c31af7Sopenharmony_ci	glw::GLuint m_fs_id;
929e5c31af7Sopenharmony_ci	glw::GLuint m_po_id;
930e5c31af7Sopenharmony_ci	glw::GLint  m_po_lod_index_uniform_location;
931e5c31af7Sopenharmony_ci	glw::GLint  m_po_to_sampler_uniform_location;
932e5c31af7Sopenharmony_ci	glw::GLuint m_result_to_id;
933e5c31af7Sopenharmony_ci	glw::GLuint m_to_id;
934e5c31af7Sopenharmony_ci	glw::GLuint m_vao_id;
935e5c31af7Sopenharmony_ci	glw::GLuint m_view_to_id;
936e5c31af7Sopenharmony_ci	glw::GLuint m_vs_id;
937e5c31af7Sopenharmony_ci};
938e5c31af7Sopenharmony_ci
939e5c31af7Sopenharmony_ci/** Verify texture view reference counting is implemented correctly.
940e5c31af7Sopenharmony_ci *
941e5c31af7Sopenharmony_ci *  Parent texture object A should be an immutable 2D texture of
942e5c31af7Sopenharmony_ci *  64x64 resolution and of GL_RGBA8 internalformat. Each mip-map
943e5c31af7Sopenharmony_ci *  should be filled with a different static color.
944e5c31af7Sopenharmony_ci *
945e5c31af7Sopenharmony_ci *  View B should be created from texture A, and view C should be
946e5c31af7Sopenharmony_ci *  instantiated from view B. The views should use the same texture
947e5c31af7Sopenharmony_ci *  target and internalformat as texture A. <minlayer> and <minlevel>
948e5c31af7Sopenharmony_ci *  values of 0 should be used for view generation. All available
949e5c31af7Sopenharmony_ci *  texture layers and levels should be used for the views.
950e5c31af7Sopenharmony_ci *
951e5c31af7Sopenharmony_ci *  The test should:
952e5c31af7Sopenharmony_ci *
953e5c31af7Sopenharmony_ci *  a) Sample the texture and both views, make sure correct data can
954e5c31af7Sopenharmony_ci *     be sampled in VS stage;
955e5c31af7Sopenharmony_ci *  b) Delete texture A;
956e5c31af7Sopenharmony_ci *  c) Sample both views, make sure correct data can be sampled in
957e5c31af7Sopenharmony_ci *     VS stage;
958e5c31af7Sopenharmony_ci *  d) Delete view B;
959e5c31af7Sopenharmony_ci *  e) Sample view C, make sure correct data can be sampled in VS
960e5c31af7Sopenharmony_ci *     stage;
961e5c31af7Sopenharmony_ci *
962e5c31af7Sopenharmony_ci *  A program object consisting only of vertex shader should be used
963e5c31af7Sopenharmony_ci *  by the test. The shader should sample all mip-maps of the bound
964e5c31af7Sopenharmony_ci *  texture at (0.5, 0.5) and compare the retrieved texels against
965e5c31af7Sopenharmony_ci *  reference values. Comparison outcome should be XFBed back to
966e5c31af7Sopenharmony_ci *  the test implementation.
967e5c31af7Sopenharmony_ci *
968e5c31af7Sopenharmony_ci *  Test passes if the sampling operation is reported to work
969e5c31af7Sopenharmony_ci *  correctly for all steps.
970e5c31af7Sopenharmony_ci *
971e5c31af7Sopenharmony_ci **/
972e5c31af7Sopenharmony_ciclass TextureViewTestReferenceCounting : public deqp::TestCase
973e5c31af7Sopenharmony_ci{
974e5c31af7Sopenharmony_cipublic:
975e5c31af7Sopenharmony_ci	/* Public methods */
976e5c31af7Sopenharmony_ci	TextureViewTestReferenceCounting(deqp::Context& context);
977e5c31af7Sopenharmony_ci
978e5c31af7Sopenharmony_ci	virtual void						 deinit();
979e5c31af7Sopenharmony_ci	virtual tcu::TestNode::IterateResult iterate();
980e5c31af7Sopenharmony_ci
981e5c31af7Sopenharmony_ciprivate:
982e5c31af7Sopenharmony_ci	/* Private type definitions */
983e5c31af7Sopenharmony_ci	struct _norm_vec4
984e5c31af7Sopenharmony_ci	{
985e5c31af7Sopenharmony_ci		unsigned char rgba[4];
986e5c31af7Sopenharmony_ci
987e5c31af7Sopenharmony_ci		/* Constructor
988e5c31af7Sopenharmony_ci		 *
989e5c31af7Sopenharmony_ci		 * @param r Red value to store for the component
990e5c31af7Sopenharmony_ci		 * @param g Green value to store for the component
991e5c31af7Sopenharmony_ci		 * @param b Blue value to store for the component
992e5c31af7Sopenharmony_ci		 * @param a Alpha value to store for the component.
993e5c31af7Sopenharmony_ci		 */
994e5c31af7Sopenharmony_ci		explicit _norm_vec4(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
995e5c31af7Sopenharmony_ci		{
996e5c31af7Sopenharmony_ci			rgba[0] = r;
997e5c31af7Sopenharmony_ci			rgba[1] = g;
998e5c31af7Sopenharmony_ci			rgba[2] = b;
999e5c31af7Sopenharmony_ci			rgba[3] = a;
1000e5c31af7Sopenharmony_ci		}
1001e5c31af7Sopenharmony_ci	};
1002e5c31af7Sopenharmony_ci
1003e5c31af7Sopenharmony_ci	/* Private methods */
1004e5c31af7Sopenharmony_ci	void initProgram();
1005e5c31af7Sopenharmony_ci	void initTest();
1006e5c31af7Sopenharmony_ci	void initTextures();
1007e5c31af7Sopenharmony_ci	void initXFB();
1008e5c31af7Sopenharmony_ci
1009e5c31af7Sopenharmony_ci	/* Private variables */
1010e5c31af7Sopenharmony_ci	glw::GLuint m_bo_id;
1011e5c31af7Sopenharmony_ci	glw::GLuint m_parent_to_id;
1012e5c31af7Sopenharmony_ci	glw::GLuint m_po_id;
1013e5c31af7Sopenharmony_ci	glw::GLint  m_po_expected_texel_uniform_location;
1014e5c31af7Sopenharmony_ci	glw::GLint  m_po_lod_uniform_location;
1015e5c31af7Sopenharmony_ci	glw::GLuint m_vao_id;
1016e5c31af7Sopenharmony_ci	glw::GLuint m_view_to_id;
1017e5c31af7Sopenharmony_ci	glw::GLuint m_view_view_to_id;
1018e5c31af7Sopenharmony_ci	glw::GLuint m_vs_id;
1019e5c31af7Sopenharmony_ci
1020e5c31af7Sopenharmony_ci	const glw::GLuint m_texture_height;
1021e5c31af7Sopenharmony_ci	const glw::GLuint m_texture_n_levels;
1022e5c31af7Sopenharmony_ci	const glw::GLuint m_texture_width;
1023e5c31af7Sopenharmony_ci
1024e5c31af7Sopenharmony_ci	std::vector<_norm_vec4> m_mipmap_colors;
1025e5c31af7Sopenharmony_ci};
1026e5c31af7Sopenharmony_ci
1027e5c31af7Sopenharmony_ci/** Group class for texture view conformance tests */
1028e5c31af7Sopenharmony_ciclass TextureViewTests : public deqp::TestCaseGroup
1029e5c31af7Sopenharmony_ci{
1030e5c31af7Sopenharmony_cipublic:
1031e5c31af7Sopenharmony_ci	/* Public methods */
1032e5c31af7Sopenharmony_ci	TextureViewTests(deqp::Context& context);
1033e5c31af7Sopenharmony_ci	virtual ~TextureViewTests()
1034e5c31af7Sopenharmony_ci	{
1035e5c31af7Sopenharmony_ci	}
1036e5c31af7Sopenharmony_ci
1037e5c31af7Sopenharmony_ci	virtual void init(void);
1038e5c31af7Sopenharmony_ci
1039e5c31af7Sopenharmony_ciprivate:
1040e5c31af7Sopenharmony_ci	/* Private methods */
1041e5c31af7Sopenharmony_ci	TextureViewTests(const TextureViewTests&);
1042e5c31af7Sopenharmony_ci	TextureViewTests& operator=(const TextureViewTests&);
1043e5c31af7Sopenharmony_ci};
1044e5c31af7Sopenharmony_ci
1045e5c31af7Sopenharmony_ci} /* gl4cts namespace */
1046e5c31af7Sopenharmony_ci
1047e5c31af7Sopenharmony_ci#endif // _GL4CTEXTUREVIEWTESTS_HPP
1048