1e5c31af7Sopenharmony_ci#ifndef _ESEXTCTESSELLATIONSHADERQUADS_HPP
2e5c31af7Sopenharmony_ci#define _ESEXTCTESSELLATIONSHADERQUADS_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#include "../esextcTestCaseBase.hpp"
27e5c31af7Sopenharmony_ci#include "esextcTessellationShaderUtils.hpp"
28e5c31af7Sopenharmony_ci#include "gluShaderUtil.hpp"
29e5c31af7Sopenharmony_ci#include "tcuDefs.hpp"
30e5c31af7Sopenharmony_ci#include <vector>
31e5c31af7Sopenharmony_ci
32e5c31af7Sopenharmony_cinamespace glcts
33e5c31af7Sopenharmony_ci{
34e5c31af7Sopenharmony_ci/** A DEQP CTS test group that collects all tests that verify quad
35e5c31af7Sopenharmony_ci *  tessellation.
36e5c31af7Sopenharmony_ci */
37e5c31af7Sopenharmony_ciclass TessellationShaderQuadsTests : public glcts::TestCaseGroupBase
38e5c31af7Sopenharmony_ci{
39e5c31af7Sopenharmony_cipublic:
40e5c31af7Sopenharmony_ci	/* Public methods */
41e5c31af7Sopenharmony_ci	TessellationShaderQuadsTests(glcts::Context& context, const ExtParameters& extParams);
42e5c31af7Sopenharmony_ci	virtual ~TessellationShaderQuadsTests(void)
43e5c31af7Sopenharmony_ci	{
44e5c31af7Sopenharmony_ci	}
45e5c31af7Sopenharmony_ci
46e5c31af7Sopenharmony_ci	void init(void);
47e5c31af7Sopenharmony_ci
48e5c31af7Sopenharmony_ciprivate:
49e5c31af7Sopenharmony_ci	/* Private methods */
50e5c31af7Sopenharmony_ci	TessellationShaderQuadsTests(const TessellationShaderQuadsTests& other);
51e5c31af7Sopenharmony_ci	TessellationShaderQuadsTests& operator=(const TessellationShaderQuadsTests& other);
52e5c31af7Sopenharmony_ci};
53e5c31af7Sopenharmony_ci
54e5c31af7Sopenharmony_ci/** Implementation of Test Case 32
55e5c31af7Sopenharmony_ci *
56e5c31af7Sopenharmony_ci *  Consider quad tessellation.
57e5c31af7Sopenharmony_ci *  Make sure that only a single triangle pair covering the outer rectangle
58e5c31af7Sopenharmony_ci *  is generated, if both clamped inner tessellation levels and all four
59e5c31af7Sopenharmony_ci *  clamped outer tessellation levels are exactly one.
60e5c31af7Sopenharmony_ci *
61e5c31af7Sopenharmony_ci *  Consider a few different inner and outer tessellation level pairs
62e5c31af7Sopenharmony_ci *  combined with vertex spacing modes that clamp/round to the values as
63e5c31af7Sopenharmony_ci *  per test summary.
64e5c31af7Sopenharmony_ci *
65e5c31af7Sopenharmony_ci *  The test should capture vertices output in TE stage, given the
66e5c31af7Sopenharmony_ci *  pre-conditions described in the test summary, and then verify vertex
67e5c31af7Sopenharmony_ci *  locations. Assume epsilon 1e-5. A single triangle should be drawn.
68e5c31af7Sopenharmony_ci *
69e5c31af7Sopenharmony_ci **/
70e5c31af7Sopenharmony_ciclass TessellationShaderQuadsDegenerateCase : public TestCaseBase
71e5c31af7Sopenharmony_ci{
72e5c31af7Sopenharmony_cipublic:
73e5c31af7Sopenharmony_ci	/* Public methods */
74e5c31af7Sopenharmony_ci	TessellationShaderQuadsDegenerateCase(Context& context, const ExtParameters& extParams);
75e5c31af7Sopenharmony_ci
76e5c31af7Sopenharmony_ci	virtual ~TessellationShaderQuadsDegenerateCase(void)
77e5c31af7Sopenharmony_ci	{
78e5c31af7Sopenharmony_ci	}
79e5c31af7Sopenharmony_ci
80e5c31af7Sopenharmony_ci	virtual void		  deinit(void);
81e5c31af7Sopenharmony_ci	void				  initTest(void);
82e5c31af7Sopenharmony_ci	virtual IterateResult iterate(void);
83e5c31af7Sopenharmony_ci
84e5c31af7Sopenharmony_ciprivate:
85e5c31af7Sopenharmony_ci	/* Private type definitions */
86e5c31af7Sopenharmony_ci	typedef struct _run
87e5c31af7Sopenharmony_ci	{
88e5c31af7Sopenharmony_ci		float								inner[2];
89e5c31af7Sopenharmony_ci		float								outer[4];
90e5c31af7Sopenharmony_ci		_tessellation_shader_vertex_spacing vertex_spacing;
91e5c31af7Sopenharmony_ci
92e5c31af7Sopenharmony_ci		std::vector<char> data;
93e5c31af7Sopenharmony_ci		unsigned int	  n_vertices;
94e5c31af7Sopenharmony_ci
95e5c31af7Sopenharmony_ci		_run()
96e5c31af7Sopenharmony_ci		{
97e5c31af7Sopenharmony_ci			memset(inner, 0, sizeof(inner));
98e5c31af7Sopenharmony_ci			memset(outer, 0, sizeof(outer));
99e5c31af7Sopenharmony_ci
100e5c31af7Sopenharmony_ci			n_vertices	 = 0;
101e5c31af7Sopenharmony_ci			vertex_spacing = TESSELLATION_SHADER_VERTEX_SPACING_UNKNOWN;
102e5c31af7Sopenharmony_ci		}
103e5c31af7Sopenharmony_ci	} _run;
104e5c31af7Sopenharmony_ci
105e5c31af7Sopenharmony_ci	typedef std::vector<_run>	 _runs;
106e5c31af7Sopenharmony_ci	typedef _runs::const_iterator _runs_const_iterator;
107e5c31af7Sopenharmony_ci
108e5c31af7Sopenharmony_ci	/* Private variables */
109e5c31af7Sopenharmony_ci	glw::GLuint				 m_vao_id;
110e5c31af7Sopenharmony_ci	_runs					 m_runs;
111e5c31af7Sopenharmony_ci	TessellationShaderUtils* m_utils;
112e5c31af7Sopenharmony_ci};
113e5c31af7Sopenharmony_ci
114e5c31af7Sopenharmony_ci/** Implementation of Test Case 33
115e5c31af7Sopenharmony_ci *
116e5c31af7Sopenharmony_ci *  Consider quad tessellation.
117e5c31af7Sopenharmony_ci *  Make sure that if either clamped inner tessellation level is set to one, that
118e5c31af7Sopenharmony_ci *  tessellation level is treated as though it were originally specified as
119e5c31af7Sopenharmony_ci *  2, which would rounded up to result in a two- or three-segment subdivision
120e5c31af7Sopenharmony_ci *  according to the tessellation spacing.
121e5c31af7Sopenharmony_ci *
122e5c31af7Sopenharmony_ci *  Technical details:
123e5c31af7Sopenharmony_ci *
124e5c31af7Sopenharmony_ci *  1. Consider all vertex spacing modes. For each vertex spacing mode, take
125e5c31af7Sopenharmony_ci *     a level value that, given the mode active, would clamp to one. In first
126e5c31af7Sopenharmony_ci *     iteration use that value for the first inner tessellation level
127e5c31af7Sopenharmony_ci *     (setting the other inner tessellation level to any valid value), then
128e5c31af7Sopenharmony_ci *     in the other iteration swap the second inner tessellation level with
129e5c31af7Sopenharmony_ci *     the first inner tessellation level.
130e5c31af7Sopenharmony_ci *     For equal and fractional even vertex spacing modes used for every
131e5c31af7Sopenharmony_ci *     inner tessellation configuration, do:
132e5c31af7Sopenharmony_ci *  1a. Using any valid outer tessellation configuration, "draw" four patches.
133e5c31af7Sopenharmony_ci *      Capture output vertices from TE stage.
134e5c31af7Sopenharmony_ci *  1b. Using the same outer tessellation configuration, but replacing the
135e5c31af7Sopenharmony_ci *      rounding value to the value we actually expect it to round to for the
136e5c31af7Sopenharmony_ci *      given iteration, again capture output vertices from TE stage.
137e5c31af7Sopenharmony_ci *  1c. Iteration passes if primitives captured are identical in both cases.
138e5c31af7Sopenharmony_ci *      Assume epsilon 1e-5.
139e5c31af7Sopenharmony_ci *
140e5c31af7Sopenharmony_ci *     In case of fractional odd vertex spacing, verify that two marker
141e5c31af7Sopenharmony_ci *     triangles capping the opposite ends of the inner quad tessellation
142e5c31af7Sopenharmony_ci *     region exist. More information about the technique (and the rationale)
143e5c31af7Sopenharmony_ci *     can be found in
144e5c31af7Sopenharmony_ci *     TessellationShaderQuadsInnerTessellationLevelRounding::iterate().
145e5c31af7Sopenharmony_ci *
146e5c31af7Sopenharmony_ci *  2. Test passes if all iterations passed successfully.
147e5c31af7Sopenharmony_ci *
148e5c31af7Sopenharmony_ci **/
149e5c31af7Sopenharmony_ciclass TessellationShaderQuadsInnerTessellationLevelRounding : public TestCaseBase
150e5c31af7Sopenharmony_ci{
151e5c31af7Sopenharmony_cipublic:
152e5c31af7Sopenharmony_ci	/* Public methods */
153e5c31af7Sopenharmony_ci	TessellationShaderQuadsInnerTessellationLevelRounding(Context& context, const ExtParameters& extParams);
154e5c31af7Sopenharmony_ci
155e5c31af7Sopenharmony_ci	virtual ~TessellationShaderQuadsInnerTessellationLevelRounding(void)
156e5c31af7Sopenharmony_ci	{
157e5c31af7Sopenharmony_ci	}
158e5c31af7Sopenharmony_ci
159e5c31af7Sopenharmony_ci	virtual void		  deinit(void);
160e5c31af7Sopenharmony_ci	void				  initTest(void);
161e5c31af7Sopenharmony_ci	virtual IterateResult iterate(void);
162e5c31af7Sopenharmony_ci
163e5c31af7Sopenharmony_ciprivate:
164e5c31af7Sopenharmony_ci	/* Private type definitions */
165e5c31af7Sopenharmony_ci	typedef struct _run
166e5c31af7Sopenharmony_ci	{
167e5c31af7Sopenharmony_ci		float								set1_inner[2];
168e5c31af7Sopenharmony_ci		float								set1_outer[4];
169e5c31af7Sopenharmony_ci		float								set2_inner[2];
170e5c31af7Sopenharmony_ci		float								set2_outer[4];
171e5c31af7Sopenharmony_ci		_tessellation_shader_vertex_spacing vertex_spacing;
172e5c31af7Sopenharmony_ci
173e5c31af7Sopenharmony_ci		std::vector<char> set1_data;
174e5c31af7Sopenharmony_ci		std::vector<char> set2_data;
175e5c31af7Sopenharmony_ci		unsigned int	  n_vertices;
176e5c31af7Sopenharmony_ci
177e5c31af7Sopenharmony_ci		_run()
178e5c31af7Sopenharmony_ci		{
179e5c31af7Sopenharmony_ci			memset(set1_inner, 0, sizeof(set1_inner));
180e5c31af7Sopenharmony_ci			memset(set1_outer, 0, sizeof(set1_outer));
181e5c31af7Sopenharmony_ci			memset(set2_inner, 0, sizeof(set2_inner));
182e5c31af7Sopenharmony_ci			memset(set2_outer, 0, sizeof(set2_outer));
183e5c31af7Sopenharmony_ci
184e5c31af7Sopenharmony_ci			n_vertices	 = 0;
185e5c31af7Sopenharmony_ci			vertex_spacing = TESSELLATION_SHADER_VERTEX_SPACING_UNKNOWN;
186e5c31af7Sopenharmony_ci		}
187e5c31af7Sopenharmony_ci	} _run;
188e5c31af7Sopenharmony_ci
189e5c31af7Sopenharmony_ci	typedef std::vector<_run>	 _runs;
190e5c31af7Sopenharmony_ci	typedef _runs::const_iterator _runs_const_iterator;
191e5c31af7Sopenharmony_ci
192e5c31af7Sopenharmony_ci	/* Private methods */
193e5c31af7Sopenharmony_ci	std::vector<_vec2> getUniqueTessCoordinatesFromVertexDataSet(const float*		raw_data,
194e5c31af7Sopenharmony_ci																 const unsigned int n_raw_data_vertices);
195e5c31af7Sopenharmony_ci
196e5c31af7Sopenharmony_ci	/* Private variables */
197e5c31af7Sopenharmony_ci	glw::GLuint				 m_vao_id;
198e5c31af7Sopenharmony_ci	_runs					 m_runs;
199e5c31af7Sopenharmony_ci	TessellationShaderUtils* m_utils;
200e5c31af7Sopenharmony_ci};
201e5c31af7Sopenharmony_ci
202e5c31af7Sopenharmony_ci} // namespace glcts
203e5c31af7Sopenharmony_ci
204e5c31af7Sopenharmony_ci#endif // _ESEXTCTESSELLATIONSHADERQUADS_HPP
205