• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _ESEXTCGEOMETRYSHADERADJACENCYTESTS_HPP
2 #define _ESEXTCGEOMETRYSHADERADJACENCYTESTS_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 "esextcGeometryShaderAdjacency.hpp"
28 
29 namespace glcts
30 {
31 /** Test configuration of "Group 2" from CTS_EXT_geometry_shader. Description follows
32  *
33  * 1. Make sure that draw calls properly accept and pass the "lines with
34  *    adjacency" data to a geometry shader. The geometry shader should then
35  *    forward adjacent line segments into one transform feedback buffer object
36  *    and actual line segments into another one.
37  *
38  *    Category: API;
39  *              Functional Test
40  *
41  *    Create a program object and a fragment, geometry and vertex shader
42  *    objects, as well as a buffer object and a transform feedback object.
43  *
44  *    The vertex shader object can be boilerplate.
45  *
46  *    The geometry shader should define:
47  *
48  *    * output vec4 variable called out_adjacent_geometry;
49  *    * output vec4 variable called out_geometry;
50  *
51  *    It should take lines_adjacency data and emit two adjacent line segments
52  *    to out_adjacent_geometry variable and one "actual" line segment to
53  *    out_geometry. Since there will be two adjacent segments and only one
54  *    "actual" line segment, the missing line segment should use (0, 0, 0, 0)
55  *    coordinates for its start/end points.
56  *
57  *    The fragment shader object can have a boilerplate implementation.
58  *
59  *    Compile the shaders, attach them to the program object, link the program
60  *    object.
61  *
62  *    Generate and bind a vertex array object.
63  *
64  *    Initialize a buffer object (A) to have enough space to hold information
65  *    for 3 coordinates * 4  vertex locations * 2 (output primitive
66  *    type-specific data topology). The data should describe 4 lines (including
67  *    adjacency data) that - as a whole - make a rectangle from (-1, -1, 0) to
68  *    (1, 1, 0). The buffer data should then be bound to an attribute, whose
69  *    index corresponds to location of the input in variable. Enable the vertex
70  *    attribute array for this index.
71  *
72  *    Initialize a buffer object (B) to have enough space to hold result
73  *    adjacent data information.
74  *
75  *    Initialize a buffer object (C) to have enough space to hold result
76  *    geometry information.
77  *
78  *    Configure transform feedback so that it captures aforementioned data
79  *    written by geometry shader and stores:
80  *
81  *    * values stored into out_adjacency_geometry in buffer object B;
82  *    * values stored into out_geometry in buffer object C;
83  *
84  *    Use separate transform feedback mode. Enable transform feedback. Enable
85  *    rasterizer discard mode.
86  *
87  *    Finally, issue a draw call in GL_LINES_ADJACENCY_EXT mode for 8 points.
88  *
89  *    Map the buffer objects to client space. The test is assumed to have
90  *    passed if the mapped buffer objects contain correct data.
91  *
92  *    NOTE: This test should verify both arrayed and indexed draw calls work
93  *    correctly.
94  *
95  *
96  * 2. Make sure that draw calls properly accept and pass the "lines with
97  *    adjacency" data to a vertex shader without the adjacency information,
98  *    assuming there is no geometry shader defined for the pipeline.
99  *
100  *    Category: API;
101  *              Functional Test.
102  *
103  *    Create a program object and a fragment and vertex shader object, as well
104  *    as a buffer object and a transform feedback object.
105  *
106  *    The fragment shader object can have a boilerplate implementation.
107  *
108  *    The vertex shader object should define a single input vec3 variable
109  *    called in_vertex and a single output vec3 variable called out_vertex. It
110  *    should write data from in_vertex in an unchanged form to out_vertex.
111  *
112  *    Compile the shaders, attach them to the program object, link the program
113  *    object.
114  *
115  *    Bind the vertex array object.
116  *
117  *    Initialize a buffer object to have enough space to hold information about
118  *    3-component floating point-based 32 vertices. The data should represent 4
119  *    lines (including adjacency data) that - as a whole - make a rectangle
120  *    from (-1, -1, 0) to (1, 1, 0). The buffer data should then be bound to an
121  *    attribute, whose index corresponds to location of the input in variable.
122  *    Enable the vertex attribute array for this index..
123  *
124  *    Initialize another buffer object to have enough space to hold information
125  *    about at most 32 vertices, each consisting of 3 floating-point components.
126  *    Configure transform feed-back so that it captures data written by vertex
127  *    shader output variable to this buffer object. Enable transform feedback.
128  *    Enable rasterizer discard mode.
129  *
130  *    Finally, issue a draw call in GL_LINES_ADJACENCY_EXT mode for 8 points.
131  *
132  *    Map the buffer object to client space. The test is assumed to have passed
133  *    if the result data corresponds to locations of 8 vertices making up the
134  *    rectangle *without* the adjacency data.
135  *
136  *
137  * 3. Make sure that draw calls properly accept and pass the "line strips with
138  *    adjacency" data to a geometry shader, if there is one included in the
139  *    pipeline.
140  *
141  *    Category: API;
142  *              Functional Test.
143  *
144  *    Modify test case 2.1 accordingly to work on "line strips with adjacency"
145  *    data instead of "lines with adjacency" data.
146  *
147  *
148  * 4. Make sure that draw calls properly accept and pass the "line strips with
149  *    adjacency" data to a vertex shader without the adjacency information,
150  *    assuming there is no geometry shader defined for the pipeline.
151  *
152  *    Category: API;
153  *              Functional Test.
154  *
155  *    Modify test case 2.2 accordingly to work on "line strips with adjacency"
156  *    data instead of "lines with adjacency" data.
157  *
158  *
159  * 5. Make sure that draw calls properly accept and pass the "triangles with
160  *    adjacency" data to a geometry shader, if there is one included in the
161  *    pipeline.
162  *
163  *    Category: API;
164  *              Functional Test.
165  *
166  *    Modify test case 2.1 accordingly to work on "triangles with adjacency"
167  *    data instead of "lines with adjacency" data.
168  *
169  *
170  * 6. Make sure that draw calls properly accept and pass the "triangles with
171  *    adjacency" data to a vertex shader without the adjacency information,
172  *    assuming there is no geometry shader defined for the pipeline.
173  *
174  *    Category: API;
175  *              Functional Test.
176  *
177  *    Modify test case 2.2 accordingly to work on "triangles with adjacency"
178  *    data instead of "lines with adjacency" data
179  *
180  *
181  * 7. Make sure that draw calls properly accept and pass the "triangle strips
182  *    with adjacency" data to a geometry shader, if there is one included in
183  *    the pipeline.
184  *
185  *    Category: API;
186  *              Functional Test.
187  *
188  *    Modify test case 2.1 accordingly to work on "triangle strips with
189  *    adjacency" data instead of "lines with adjacency" data.
190  *
191  *
192  * 8. Make sure that draw calls properly accept and pass the "triangle strips
193  *    with adjacency" data to a vertex shader without the adjacency information,
194  *    assuming there is no geometry shader defined for the pipeline.
195  *
196  *    Category: API;
197  *              Functional Test.
198  *
199  *    Modify test case 2.2 accordingly to work on "triangle strips with
200  *    adjacency" data instead of "lines with adjacency" data.
201  *
202  **/
203 class GeometryShaderAdjacencyTests : public glcts::TestCaseGroupBase
204 {
205 public:
206 	/* Public methods */
207 	GeometryShaderAdjacencyTests(glcts::Context& context, const ExtParameters& extParams, const char* name,
208 								 const char* description);
209 
~GeometryShaderAdjacencyTests()210 	virtual ~GeometryShaderAdjacencyTests()
211 	{
212 	}
213 
214 	virtual void init(void);
215 	virtual void deinit(void);
216 
217 private:
218 	/* Private methods */
219 	void configureTestDataLines(AdjacencyTestData& test_data, bool withGS = false, bool indiced = false);
220 	void configureTestDataLineStrip(AdjacencyTestData& test_data, bool withGS = false, bool indiced = false);
221 	void configureTestDataTriangles(AdjacencyTestData& test_data, bool withGS = false, bool indiced = false);
222 	void configureTestDataTriangleStrip(AdjacencyTestData& test_data, bool withGS = false, bool indiced = false);
223 
224 	void createGrid(AdjacencyTestData& test_data);
225 	void createGridLineSegments(AdjacencyTestData& test_data);
226 	void createGridLineStrip(AdjacencyTestData& test_data);
227 	void createGridTriangles(AdjacencyTestData& test_data);
228 	void createGridTriangleStrip(AdjacencyTestData& test_data);
229 
230 	void setLinePointsNonindiced(AdjacencyTestData& test_data);
231 	void setLinePointsindiced(AdjacencyTestData& test_data);
232 	void setLineStripPointsNonindiced(AdjacencyTestData& test_data);
233 	void setLineStripPointsIndiced(AdjacencyTestData& test_data);
234 	void setTrianglePointsNonindiced(AdjacencyTestData& test_data);
235 	void setTrianglePointsIndiced(AdjacencyTestData& test_data);
236 	void setTriangleStripPointsIndiced(AdjacencyTestData& test_data);
237 	void setTriangleStripPointsNonindiced(AdjacencyTestData& test_data);
238 
239 	/* Private constants */
240 	const unsigned int m_grid_granulity;
241 	const unsigned int m_n_components_input;
242 	const unsigned int m_n_components_output;
243 	const unsigned int m_n_line_segments;
244 	const unsigned int m_n_vertices_per_triangle;
245 
246 	/* Private variables */
247 	std::vector<AdjacencyTestData*> m_tests_data;
248 };
249 
250 } // namespace glcts
251 
252 #endif // _ESEXTCGEOMETRYSHADERADJACENCYTESTS_HPP
253