• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _ESEXTCTESSELLATIONSHADERISOLINES_HPP
2 #define _ESEXTCTESSELLATIONSHADERISOLINES_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 #include <map>
31 #include <vector>
32 
33 namespace glcts
34 {
35 /** Implementation of Test Case 34
36  *
37  *  Consider isoline tessellation.
38  *  Make sure that the number of isolines generated is derived from the first
39  *  outer tessellation level;
40  *  Make sure that the number of segments in each isoline is derived
41  *  from the second outer tessellation level.
42  *  Make sure that both inner tessellation levels and the third and the fourth
43  *  outer tessellation levels do not affect the tessellation process.
44  *  Make sure that 'equal_spacing' vertex spacing mode is always used for
45  *  vertical subdivision of the input quad.
46  *  Make sure no line is drawn between (0, 1) and (1, 1) in (u, v) domain.
47  *
48  *  0. Consider the following set: {-1, 1, MAX_TESS_GEN_LEVEL_EXT / 2,
49  *     MAX_TESS_GEN_LEVEL_EXT}. All combinations of values from this set
50  *     in regard to the first two outer tessellation levels for isolines
51  *     generator mode should be checked by this test.
52  *  1. For each combination and case described in the test summary, output
53  *     vertices processed by TE should be XFBed and verified by the test
54  *     implementation.
55  *  2. For the case where we verify that inner tessellation level and
56  *     the 3rd and the 4th outer tessellation levels are ignored,
57  *     the test should work along the lines of test case 28.
58  *
59  **/
60 class TessellationShadersIsolines : public TestCaseBase
61 {
62 public:
63 	/* Public methods */
64 	TessellationShadersIsolines(Context& context, const ExtParameters& extParams);
65 
~TessellationShadersIsolines(void)66 	virtual ~TessellationShadersIsolines(void)
67 	{
68 	}
69 
70 	virtual void		  deinit(void);
71 	virtual IterateResult iterate(void);
72 
73 private:
74 	/* Forward declarations */
75 	struct _test_descriptor;
76 
77 	/* Private type definitions */
78 	/** Stores:
79 	 *
80 	 *  a) properties used to generate tessellated coordinates.
81 	 *  b) pointer to owning test descriptor
82 	 *  c) captured tessellated coordinates.
83 	 **/
84 	typedef struct _test_result
85 	{
86 		unsigned int			n_isolines;
87 		unsigned int			n_vertices;
88 		const _test_descriptor* parent;
89 		std::vector<float>		rendered_data;
90 
91 		int irrelevant_tess_level;
92 		int outer1_tess_level;
93 		int outer2_tess_level;
94 
_test_resultglcts::TessellationShadersIsolines::_test_result95 		_test_result()
96 		{
97 			n_isolines = 0;
98 			n_vertices = 0;
99 			parent	 = DE_NULL;
100 			rendered_data.clear();
101 
102 			irrelevant_tess_level = 0;
103 			outer1_tess_level	 = 0;
104 			outer2_tess_level	 = 0;
105 		}
106 	} _test_result;
107 
108 	/** Encapsulates:
109 	 *
110 	 *  a) Tessellation properties corresponding to what is set
111 	 *     in TC and TE stages, when the particular program object
112 	 *     is used for draw calls.
113 	 *  b) Pointer to test instance.
114 	 **/
115 	typedef struct _test_descriptor
116 	{
117 		TessellationShadersIsolines* parent;
118 
119 		float								inner_tess_levels[2];
120 		float								irrelevant_tess_level;
121 		float								outer_tess_levels[4];
122 		_tessellation_shader_vertex_spacing vertex_spacing_mode;
123 
_test_descriptorglcts::TessellationShadersIsolines::_test_descriptor124 		_test_descriptor() : irrelevant_tess_level(0)
125 		{
126 			parent = DE_NULL;
127 
128 			memset(inner_tess_levels, 0, sizeof(inner_tess_levels));
129 			memset(outer_tess_levels, 0, sizeof(outer_tess_levels));
130 
131 			vertex_spacing_mode = TESSELLATION_SHADER_VERTEX_SPACING_UNKNOWN;
132 		}
133 	} _test_descriptor;
134 
135 	/** Function pointer used to refer to verification functions that operate on
136 	 *  a single test result descriptor.
137 	 **/
138 	typedef void (*PFNTESTRESULTPROCESSORPROC)(_test_result& test_result, glw::GLenum glToken);
139 
140 	typedef std::vector<_test_descriptor> _tests;
141 	typedef _tests::const_iterator		  _tests_const_iterator;
142 	typedef _tests::iterator			  _tests_iterator;
143 	typedef std::map<_tessellation_shader_vertex_spacing, _tests> _tests_per_vertex_spacing_map;
144 	typedef _tests_per_vertex_spacing_map::const_iterator _tests_per_vertex_spacing_map_const_iterator;
145 	typedef _tests_per_vertex_spacing_map::iterator		  _tests_per_vertex_spacing_map_iterator;
146 	typedef std::vector<_test_result>					  _test_results;
147 	typedef _test_results::iterator						  _test_results_iterator;
148 	typedef std::map<_tessellation_shader_vertex_spacing, _test_results> _test_results_per_vertex_spacing_map;
149 	typedef _test_results_per_vertex_spacing_map::const_iterator _test_results_per_vertex_spacing_map_const_iterator;
150 	typedef _test_results_per_vertex_spacing_map::iterator		 _test_results_per_vertex_spacing_map_iterator;
151 
152 	typedef int _irrelevant_tess_level;
153 	typedef int _outer1_tess_level;
154 	typedef int _outer2_tess_level;
155 
156 	/* Private methods */
157 	void countIsolines(_test_result& test_result);
158 
159 	_test_result findTestResult(_irrelevant_tess_level irrelevant_tess_level, _outer1_tess_level outer1_tess_level,
160 								_outer2_tess_level					outer2_tess_level,
161 								_tessellation_shader_vertex_spacing vertex_spacing_mode);
162 
163 	Context& getContext();
164 	void	 initTest(void);
165 
166 	void initTestDescriptor(_tessellation_shader_vertex_spacing vertex_spacing_mode, const float* inner_tess_levels,
167 							const float* outer_tess_levels, float irrelevant_tess_level, _test_descriptor& test);
168 
169 	void runForAllTestResults(PFNTESTRESULTPROCESSORPROC pProcessTestResult);
170 
171 	static void checkFirstOuterTessellationLevelEffect(_test_result&	 test_result,
172 													   const glw::GLenum glMaxTessGenLevelToken);
173 
174 	void checkIrrelevantTessellationLevelsHaveNoEffect();
175 
176 	static void checkNoLineSegmentIsDefinedAtHeightOne(_test_result& test_result, const glw::GLenum unused);
177 
178 	static void checkSecondOuterTessellationLevelEffect(_test_result&	 test_result,
179 														const glw::GLenum glMaxTessGenLevelToken);
180 
181 	void checkVertexSpacingDoesNotAffectAmountOfGeneratedIsolines();
182 
183 	/* Private variables */
184 	float m_irrelevant_tess_value_1;
185 	float m_irrelevant_tess_value_2;
186 
187 	_test_results_per_vertex_spacing_map m_test_results;
188 	_tests_per_vertex_spacing_map		 m_tests;
189 	TessellationShaderUtils*			 m_utils_ptr;
190 	glw::GLuint							 m_vao_id;
191 };
192 
193 } // namespace glcts
194 
195 #endif // _ESEXTCTESSELLATIONSHADERISOLINES_HPP
196