• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _ESEXTCTESSELLATIONSHADERVERTEXORDERING_HPP
2 #define _ESEXTCTESSELLATIONSHADERVERTEXORDERING_HPP
3 /*-------------------------------------------------------------------------
4  * OpenGL Conformance Test Suite
5  * -----------------------------
6  *
7  * Copyright (c) 2014-2016 The Khronos Group Inc.
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  */ /*!
22  * \file
23  * \brief
24  */ /*-------------------------------------------------------------------*/
25 
26 #include "../esextcTestCaseBase.hpp"
27 #include "esextcTessellationShaderUtils.hpp"
28 #include "gluShaderUtil.hpp"
29 #include "tcuDefs.hpp"
30 
31 namespace glcts
32 {
33 
34 /** Implementation of Test Case 26
35  *
36  *  Make sure that vertex ordering mode defined in a tessellation evaluation
37  *  shader affects geometry generated by tessellation primitive generator and
38  *  works as per extension specification (to the limit enforced by implementation-
39  *  -dependent behaviour).
40  *  Cover 'triangles' and 'quads' tessellation primitive generator modes.
41  *  Make sure that points are unaffected by the vertex ordering mode.
42  *  Make sure that by default counter-clockwise ordering is used.
43  *  Note: This is based on 3.6.1 from ES spec 3.0.2 (p.102)
44  *
45  *  Technical details:
46  *
47  *  0. Consider the following set: {-1 (where valid), 1, MAX_TESS_GEN_LEVEL_EXT / 2,
48  *     MAX_TESS_GEN_LEVEL_EXT}. All combinations of values from this set
49  *     in regard to relevant inner/outer tessellation levels for all
50  *     primitive generator modes should be checked by this test.
51  *
52  *  1. For cases where clock-wise ordering is expected, make sure that:
53  *
54  *     1/2 * sum(i=0..n-1)(x_i*y_(i@1) - x_(i@1)*y_i) < 0
55  *
56  *     where: n is number of vertices making up a single primitive,
57  *            @ is an operator defined as x@y=(x+y)%n;
58  *
59  *     For cases where counterclock-wise ordering is expected, the value
60  *     should be positive.
61  *
62  **/
63 class TessellationShaderVertexOrdering : public TestCaseBase
64 {
65 public:
66 	/* Public methods */
67 	TessellationShaderVertexOrdering(Context& context, const ExtParameters& extParams);
68 
~TessellationShaderVertexOrdering(void)69 	virtual ~TessellationShaderVertexOrdering(void)
70 	{
71 	}
72 
73 	virtual void		  deinit(void);
74 	void				  initTest(void);
75 	virtual IterateResult iterate(void);
76 
77 private:
78 	/* Private type definitions */
79 	typedef struct _test_iteration
80 	{
81 		char*								 data;
82 		float								 inner_tess_levels[2];
83 		bool								 is_point_mode_enabled;
84 		unsigned int						 n_vertices;
85 		float								 outer_tess_levels[4];
86 		_tessellation_primitive_mode		 primitive_mode;
87 		_tessellation_shader_vertex_ordering vertex_ordering;
88 
_test_iterationglcts::TessellationShaderVertexOrdering::_test_iteration89 		_test_iteration()
90 		{
91 			memset(inner_tess_levels, 0, sizeof(inner_tess_levels));
92 			memset(outer_tess_levels, 0, sizeof(outer_tess_levels));
93 
94 			data					= DE_NULL;
95 			is_point_mode_enabled	= false;
96 			n_vertices				= 0;
97 			primitive_mode			= TESSELLATION_SHADER_PRIMITIVE_MODE_UNKNOWN;
98 			vertex_ordering			= TESSELLATION_SHADER_VERTEX_ORDERING_UNKNOWN;
99 		}
100 	} _test_iteration;
101 
102 	typedef std::vector<_test_iteration>	 _test_iterations;
103 	typedef _test_iterations::const_iterator _test_iterations_const_iterator;
104 
105 	/* Private methods */
106 	void deinitTestIteration(_test_iteration& test_iteration);
107 
108 	_test_iteration initTestIteration(const float* inner_tess_levels, const float* outer_tess_levels,
109 									  _tessellation_primitive_mode		   primitive_mode,
110 									  _tessellation_shader_vertex_ordering vertex_ordering, bool is_point_mode_enabled,
111 									  TessellationShaderUtils* utils);
112 
113 	void verifyVertexOrderingCorrectness(const _test_iteration& test_iteration);
114 
115 	void verifyVertexOrderingDoesNotChangeGeneratedPoints(const _test_iteration& test_iteration_a,
116 														  const _test_iteration& test_iteration_b);
117 
118 	/* Private variables */
119 	glw::GLuint m_bo_id;
120 	glw::GLuint m_fs_id;
121 	glw::GLuint m_tc_id;
122 	glw::GLuint m_vs_id;
123 	glw::GLuint m_vao_id;
124 
125 	_test_iterations		 m_tests;
126 	_test_iterations		 m_tests_points;
127 	TessellationShaderUtils* m_utils;
128 };
129 
130 } // namespace glcts
131 
132 #endif // _ESEXTCTESSELLATIONSHADERVERTEXORDERING_HPP
133