1e5c31af7Sopenharmony_ci#ifndef _ESEXTCTESSELLATIONSHADERVERTEXORDERING_HPP
2e5c31af7Sopenharmony_ci#define _ESEXTCTESSELLATIONSHADERVERTEXORDERING_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
31e5c31af7Sopenharmony_cinamespace glcts
32e5c31af7Sopenharmony_ci{
33e5c31af7Sopenharmony_ci
34e5c31af7Sopenharmony_ci/** Implementation of Test Case 26
35e5c31af7Sopenharmony_ci *
36e5c31af7Sopenharmony_ci *  Make sure that vertex ordering mode defined in a tessellation evaluation
37e5c31af7Sopenharmony_ci *  shader affects geometry generated by tessellation primitive generator and
38e5c31af7Sopenharmony_ci *  works as per extension specification (to the limit enforced by implementation-
39e5c31af7Sopenharmony_ci *  -dependent behaviour).
40e5c31af7Sopenharmony_ci *  Cover 'triangles' and 'quads' tessellation primitive generator modes.
41e5c31af7Sopenharmony_ci *  Make sure that points are unaffected by the vertex ordering mode.
42e5c31af7Sopenharmony_ci *  Make sure that by default counter-clockwise ordering is used.
43e5c31af7Sopenharmony_ci *  Note: This is based on 3.6.1 from ES spec 3.0.2 (p.102)
44e5c31af7Sopenharmony_ci *
45e5c31af7Sopenharmony_ci *  Technical details:
46e5c31af7Sopenharmony_ci *
47e5c31af7Sopenharmony_ci *  0. Consider the following set: {-1 (where valid), 1, MAX_TESS_GEN_LEVEL_EXT / 2,
48e5c31af7Sopenharmony_ci *     MAX_TESS_GEN_LEVEL_EXT}. All combinations of values from this set
49e5c31af7Sopenharmony_ci *     in regard to relevant inner/outer tessellation levels for all
50e5c31af7Sopenharmony_ci *     primitive generator modes should be checked by this test.
51e5c31af7Sopenharmony_ci *
52e5c31af7Sopenharmony_ci *  1. For cases where clock-wise ordering is expected, make sure that:
53e5c31af7Sopenharmony_ci *
54e5c31af7Sopenharmony_ci *     1/2 * sum(i=0..n-1)(x_i*y_(i@1) - x_(i@1)*y_i) < 0
55e5c31af7Sopenharmony_ci *
56e5c31af7Sopenharmony_ci *     where: n is number of vertices making up a single primitive,
57e5c31af7Sopenharmony_ci *            @ is an operator defined as x@y=(x+y)%n;
58e5c31af7Sopenharmony_ci *
59e5c31af7Sopenharmony_ci *     For cases where counterclock-wise ordering is expected, the value
60e5c31af7Sopenharmony_ci *     should be positive.
61e5c31af7Sopenharmony_ci *
62e5c31af7Sopenharmony_ci **/
63e5c31af7Sopenharmony_ciclass TessellationShaderVertexOrdering : public TestCaseBase
64e5c31af7Sopenharmony_ci{
65e5c31af7Sopenharmony_cipublic:
66e5c31af7Sopenharmony_ci	/* Public methods */
67e5c31af7Sopenharmony_ci	TessellationShaderVertexOrdering(Context& context, const ExtParameters& extParams);
68e5c31af7Sopenharmony_ci
69e5c31af7Sopenharmony_ci	virtual ~TessellationShaderVertexOrdering(void)
70e5c31af7Sopenharmony_ci	{
71e5c31af7Sopenharmony_ci	}
72e5c31af7Sopenharmony_ci
73e5c31af7Sopenharmony_ci	virtual void		  deinit(void);
74e5c31af7Sopenharmony_ci	void				  initTest(void);
75e5c31af7Sopenharmony_ci	virtual IterateResult iterate(void);
76e5c31af7Sopenharmony_ci
77e5c31af7Sopenharmony_ciprivate:
78e5c31af7Sopenharmony_ci	/* Private type definitions */
79e5c31af7Sopenharmony_ci	typedef struct _test_iteration
80e5c31af7Sopenharmony_ci	{
81e5c31af7Sopenharmony_ci		char*								 data;
82e5c31af7Sopenharmony_ci		float								 inner_tess_levels[2];
83e5c31af7Sopenharmony_ci		bool								 is_point_mode_enabled;
84e5c31af7Sopenharmony_ci		unsigned int						 n_vertices;
85e5c31af7Sopenharmony_ci		float								 outer_tess_levels[4];
86e5c31af7Sopenharmony_ci		_tessellation_primitive_mode		 primitive_mode;
87e5c31af7Sopenharmony_ci		_tessellation_shader_vertex_ordering vertex_ordering;
88e5c31af7Sopenharmony_ci
89e5c31af7Sopenharmony_ci		_test_iteration()
90e5c31af7Sopenharmony_ci		{
91e5c31af7Sopenharmony_ci			memset(inner_tess_levels, 0, sizeof(inner_tess_levels));
92e5c31af7Sopenharmony_ci			memset(outer_tess_levels, 0, sizeof(outer_tess_levels));
93e5c31af7Sopenharmony_ci
94e5c31af7Sopenharmony_ci			data					= DE_NULL;
95e5c31af7Sopenharmony_ci			is_point_mode_enabled	= false;
96e5c31af7Sopenharmony_ci			n_vertices				= 0;
97e5c31af7Sopenharmony_ci			primitive_mode			= TESSELLATION_SHADER_PRIMITIVE_MODE_UNKNOWN;
98e5c31af7Sopenharmony_ci			vertex_ordering			= TESSELLATION_SHADER_VERTEX_ORDERING_UNKNOWN;
99e5c31af7Sopenharmony_ci		}
100e5c31af7Sopenharmony_ci	} _test_iteration;
101e5c31af7Sopenharmony_ci
102e5c31af7Sopenharmony_ci	typedef std::vector<_test_iteration>	 _test_iterations;
103e5c31af7Sopenharmony_ci	typedef _test_iterations::const_iterator _test_iterations_const_iterator;
104e5c31af7Sopenharmony_ci
105e5c31af7Sopenharmony_ci	/* Private methods */
106e5c31af7Sopenharmony_ci	void deinitTestIteration(_test_iteration& test_iteration);
107e5c31af7Sopenharmony_ci
108e5c31af7Sopenharmony_ci	_test_iteration initTestIteration(const float* inner_tess_levels, const float* outer_tess_levels,
109e5c31af7Sopenharmony_ci									  _tessellation_primitive_mode		   primitive_mode,
110e5c31af7Sopenharmony_ci									  _tessellation_shader_vertex_ordering vertex_ordering, bool is_point_mode_enabled,
111e5c31af7Sopenharmony_ci									  TessellationShaderUtils* utils);
112e5c31af7Sopenharmony_ci
113e5c31af7Sopenharmony_ci	void verifyVertexOrderingCorrectness(const _test_iteration& test_iteration);
114e5c31af7Sopenharmony_ci
115e5c31af7Sopenharmony_ci	void verifyVertexOrderingDoesNotChangeGeneratedPoints(const _test_iteration& test_iteration_a,
116e5c31af7Sopenharmony_ci														  const _test_iteration& test_iteration_b);
117e5c31af7Sopenharmony_ci
118e5c31af7Sopenharmony_ci	/* Private variables */
119e5c31af7Sopenharmony_ci	glw::GLuint m_bo_id;
120e5c31af7Sopenharmony_ci	glw::GLuint m_fs_id;
121e5c31af7Sopenharmony_ci	glw::GLuint m_tc_id;
122e5c31af7Sopenharmony_ci	glw::GLuint m_vs_id;
123e5c31af7Sopenharmony_ci	glw::GLuint m_vao_id;
124e5c31af7Sopenharmony_ci
125e5c31af7Sopenharmony_ci	_test_iterations		 m_tests;
126e5c31af7Sopenharmony_ci	_test_iterations		 m_tests_points;
127e5c31af7Sopenharmony_ci	TessellationShaderUtils* m_utils;
128e5c31af7Sopenharmony_ci};
129e5c31af7Sopenharmony_ci
130e5c31af7Sopenharmony_ci} // namespace glcts
131e5c31af7Sopenharmony_ci
132e5c31af7Sopenharmony_ci#endif // _ESEXTCTESSELLATIONSHADERVERTEXORDERING_HPP
133