1e5c31af7Sopenharmony_ci/*-------------------------------------------------------------------------
2e5c31af7Sopenharmony_ci * OpenGL Conformance Test Suite
3e5c31af7Sopenharmony_ci * -----------------------------
4e5c31af7Sopenharmony_ci *
5e5c31af7Sopenharmony_ci * Copyright (c) 2014-2016 The Khronos Group Inc.
6e5c31af7Sopenharmony_ci *
7e5c31af7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
8e5c31af7Sopenharmony_ci * you may not use this file except in compliance with the License.
9e5c31af7Sopenharmony_ci * You may obtain a copy of the License at
10e5c31af7Sopenharmony_ci *
11e5c31af7Sopenharmony_ci *      http://www.apache.org/licenses/LICENSE-2.0
12e5c31af7Sopenharmony_ci *
13e5c31af7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
14e5c31af7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
15e5c31af7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16e5c31af7Sopenharmony_ci * See the License for the specific language governing permissions and
17e5c31af7Sopenharmony_ci * limitations under the License.
18e5c31af7Sopenharmony_ci *
19e5c31af7Sopenharmony_ci */ /*!
20e5c31af7Sopenharmony_ci * \file
21e5c31af7Sopenharmony_ci * \brief
22e5c31af7Sopenharmony_ci */ /*-------------------------------------------------------------------*/
23e5c31af7Sopenharmony_ci
24e5c31af7Sopenharmony_ci#include "glwEnums.inl"
25e5c31af7Sopenharmony_ci
26e5c31af7Sopenharmony_ci#include "deMath.h"
27e5c31af7Sopenharmony_ci#include "esextcGeometryShaderAdjacencyTests.hpp"
28e5c31af7Sopenharmony_ci#include <cstring>
29e5c31af7Sopenharmony_ci
30e5c31af7Sopenharmony_cinamespace glcts
31e5c31af7Sopenharmony_ci{
32e5c31af7Sopenharmony_ci
33e5c31af7Sopenharmony_ci/** Constructor
34e5c31af7Sopenharmony_ci *
35e5c31af7Sopenharmony_ci * @param context       Test context
36e5c31af7Sopenharmony_ci * @param name          Test case's name
37e5c31af7Sopenharmony_ci * @param description   Test case's description
38e5c31af7Sopenharmony_ci **/
39e5c31af7Sopenharmony_ciGeometryShaderAdjacencyTests::GeometryShaderAdjacencyTests(Context& context, const ExtParameters& extParams,
40e5c31af7Sopenharmony_ci														   const char* name, const char* description)
41e5c31af7Sopenharmony_ci	: TestCaseGroupBase(context, extParams, name, description)
42e5c31af7Sopenharmony_ci	, m_grid_granulity(1)
43e5c31af7Sopenharmony_ci	, m_n_components_input(2)
44e5c31af7Sopenharmony_ci	, m_n_components_output(4)
45e5c31af7Sopenharmony_ci	, m_n_line_segments(4)
46e5c31af7Sopenharmony_ci	, m_n_vertices_per_triangle(3)
47e5c31af7Sopenharmony_ci{
48e5c31af7Sopenharmony_ci	/* Nothing to be done here */
49e5c31af7Sopenharmony_ci}
50e5c31af7Sopenharmony_ci
51e5c31af7Sopenharmony_ci/** Deinitializes tests data
52e5c31af7Sopenharmony_ci *
53e5c31af7Sopenharmony_ci **/
54e5c31af7Sopenharmony_civoid GeometryShaderAdjacencyTests::deinit(void)
55e5c31af7Sopenharmony_ci{
56e5c31af7Sopenharmony_ci	for (std::vector<AdjacencyTestData*>::iterator it = m_tests_data.begin(); it != m_tests_data.end(); ++it)
57e5c31af7Sopenharmony_ci	{
58e5c31af7Sopenharmony_ci		delete *it;
59e5c31af7Sopenharmony_ci		*it = NULL;
60e5c31af7Sopenharmony_ci	}
61e5c31af7Sopenharmony_ci
62e5c31af7Sopenharmony_ci	m_tests_data.clear();
63e5c31af7Sopenharmony_ci
64e5c31af7Sopenharmony_ci	/* Call base class' deinit() function. */
65e5c31af7Sopenharmony_ci	glcts::TestCaseGroupBase::deinit();
66e5c31af7Sopenharmony_ci}
67e5c31af7Sopenharmony_ci
68e5c31af7Sopenharmony_ci/** Initializes tests data
69e5c31af7Sopenharmony_ci *
70e5c31af7Sopenharmony_ci **/
71e5c31af7Sopenharmony_civoid GeometryShaderAdjacencyTests::init(void)
72e5c31af7Sopenharmony_ci{
73e5c31af7Sopenharmony_ci	/* Tests for GL_LINES_ADJACENCY_EXT */
74e5c31af7Sopenharmony_ci
75e5c31af7Sopenharmony_ci	/* Test 2.1 Non indiced Data */
76e5c31af7Sopenharmony_ci	m_tests_data.push_back(new AdjacencyTestData());
77e5c31af7Sopenharmony_ci	configureTestDataLines(*m_tests_data.back(), true, false);
78e5c31af7Sopenharmony_ci	addChild(new GeometryShaderAdjacency(getContext(), m_extParams, "adjacency_non_indiced_lines",
79e5c31af7Sopenharmony_ci										 "Test 2.1 non indiced", *m_tests_data.back()));
80e5c31af7Sopenharmony_ci	/* Test 2.1 indiced Data */
81e5c31af7Sopenharmony_ci	m_tests_data.push_back(new AdjacencyTestData());
82e5c31af7Sopenharmony_ci	configureTestDataLines(*m_tests_data.back(), true, true);
83e5c31af7Sopenharmony_ci	addChild(new GeometryShaderAdjacency(getContext(), m_extParams, "adjacency_indiced_lines", "Test 2.1 indiced",
84e5c31af7Sopenharmony_ci										 *m_tests_data.back()));
85e5c31af7Sopenharmony_ci
86e5c31af7Sopenharmony_ci	/* Tests for GL_LINE_STRIP_ADJACENCY_EXT */
87e5c31af7Sopenharmony_ci
88e5c31af7Sopenharmony_ci	/* Test 2.3 Non indiced Data */
89e5c31af7Sopenharmony_ci	m_tests_data.push_back(new AdjacencyTestData());
90e5c31af7Sopenharmony_ci	configureTestDataLineStrip(*m_tests_data.back(), true, false);
91e5c31af7Sopenharmony_ci	addChild(new GeometryShaderAdjacency(getContext(), m_extParams, "adjacency_non_indiced_line_strip",
92e5c31af7Sopenharmony_ci										 "Test 2.3 non indiced", *m_tests_data.back()));
93e5c31af7Sopenharmony_ci	/* Test 2.3 indiced Data */
94e5c31af7Sopenharmony_ci	m_tests_data.push_back(new AdjacencyTestData());
95e5c31af7Sopenharmony_ci	configureTestDataLineStrip(*m_tests_data.back(), true, true);
96e5c31af7Sopenharmony_ci	addChild(new GeometryShaderAdjacency(getContext(), m_extParams, "adjacency_indiced_line_strip", "Test 2.3 indiced",
97e5c31af7Sopenharmony_ci										 *m_tests_data.back()));
98e5c31af7Sopenharmony_ci
99e5c31af7Sopenharmony_ci	/* Tests for GL_TRIANGLES_ADJACENCY_EXT */
100e5c31af7Sopenharmony_ci
101e5c31af7Sopenharmony_ci	/* Test 2.5 Non indiced Data */
102e5c31af7Sopenharmony_ci	m_tests_data.push_back(new AdjacencyTestData());
103e5c31af7Sopenharmony_ci	configureTestDataTriangles(*m_tests_data.back(), true, false);
104e5c31af7Sopenharmony_ci	addChild(new GeometryShaderAdjacency(getContext(), m_extParams, "adjacency_non_indiced_triangles",
105e5c31af7Sopenharmony_ci										 "Test 2.5 non indiced", *m_tests_data.back()));
106e5c31af7Sopenharmony_ci	/* Test 2.5 indiced Data */
107e5c31af7Sopenharmony_ci	m_tests_data.push_back(new AdjacencyTestData());
108e5c31af7Sopenharmony_ci	configureTestDataTriangles(*m_tests_data.back(), true, true);
109e5c31af7Sopenharmony_ci	addChild(new GeometryShaderAdjacency(getContext(), m_extParams, "adjacency_indiced_triangles", "Test 2.5 indiced",
110e5c31af7Sopenharmony_ci										 *m_tests_data.back()));
111e5c31af7Sopenharmony_ci
112e5c31af7Sopenharmony_ci	/* Tests for GL_TRIANGLE_STRIP_ADJACENCY_EXT */
113e5c31af7Sopenharmony_ci
114e5c31af7Sopenharmony_ci	/* Test 2.7 Non indiced Data */
115e5c31af7Sopenharmony_ci	m_tests_data.push_back(new AdjacencyTestData());
116e5c31af7Sopenharmony_ci	configureTestDataTriangleStrip(*m_tests_data.back(), true, false);
117e5c31af7Sopenharmony_ci	addChild(new GeometryShaderAdjacency(getContext(), m_extParams, "adjacency_non_indiced_triangle_strip",
118e5c31af7Sopenharmony_ci										 "Test 2.7 non indiced", *m_tests_data.back()));
119e5c31af7Sopenharmony_ci	/* Test 2.7 indiced Data */
120e5c31af7Sopenharmony_ci	m_tests_data.push_back(new AdjacencyTestData());
121e5c31af7Sopenharmony_ci	configureTestDataTriangleStrip(*m_tests_data.back(), true, true);
122e5c31af7Sopenharmony_ci	addChild(new GeometryShaderAdjacency(getContext(), m_extParams, "adjacency_indiced_triangle_strip",
123e5c31af7Sopenharmony_ci										 "Test 2.7 indiced", *m_tests_data.back()));
124e5c31af7Sopenharmony_ci}
125e5c31af7Sopenharmony_ci
126e5c31af7Sopenharmony_ci/** Configure Test Data for GL_LINES_ADJACENCY_EXT drawing mode
127e5c31af7Sopenharmony_ci *
128e5c31af7Sopenharmony_ci *  @param testData reference to AdjacencyTestData instance to be configured
129e5c31af7Sopenharmony_ci *                  accordingly;
130e5c31af7Sopenharmony_ci *  @param withGS   if true, geometry shader code will be attached to test data;
131e5c31af7Sopenharmony_ci *  @param indiced  if true, indices will be stored in testData.
132e5c31af7Sopenharmony_ci **/
133e5c31af7Sopenharmony_civoid GeometryShaderAdjacencyTests::configureTestDataLines(AdjacencyTestData& test_data, bool withGS, bool indiced)
134e5c31af7Sopenharmony_ci{
135e5c31af7Sopenharmony_ci	static const char* gsCode = "${VERSION}\n"
136e5c31af7Sopenharmony_ci								"\n"
137e5c31af7Sopenharmony_ci								"${GEOMETRY_SHADER_REQUIRE}\n"
138e5c31af7Sopenharmony_ci								"\n"
139e5c31af7Sopenharmony_ci								"precision highp float;\n"
140e5c31af7Sopenharmony_ci								"\n"
141e5c31af7Sopenharmony_ci								"layout(lines_adjacency)            in;\n"
142e5c31af7Sopenharmony_ci								"layout(line_strip, max_vertices=2) out;\n"
143e5c31af7Sopenharmony_ci								"\n"
144e5c31af7Sopenharmony_ci								"layout(location = 0) out vec4 out_adjacent_geometry;\n"
145e5c31af7Sopenharmony_ci								"layout(location = 1) out vec4 out_geometry;\n"
146e5c31af7Sopenharmony_ci								"\n"
147e5c31af7Sopenharmony_ci								"void main()\n"
148e5c31af7Sopenharmony_ci								"{\n"
149e5c31af7Sopenharmony_ci								"    out_adjacent_geometry = gl_in[0].gl_Position;\n"
150e5c31af7Sopenharmony_ci								"    out_geometry          = gl_in[1].gl_Position;\n"
151e5c31af7Sopenharmony_ci								"    EmitVertex();\n"
152e5c31af7Sopenharmony_ci								"    out_adjacent_geometry = gl_in[3].gl_Position;\n"
153e5c31af7Sopenharmony_ci								"    out_geometry          = gl_in[2].gl_Position;\n"
154e5c31af7Sopenharmony_ci								"    EmitVertex();\n"
155e5c31af7Sopenharmony_ci								"    EndPrimitive();\n"
156e5c31af7Sopenharmony_ci								"}\n";
157e5c31af7Sopenharmony_ci
158e5c31af7Sopenharmony_ci	test_data.m_gs_code = (withGS) ? gsCode : 0;
159e5c31af7Sopenharmony_ci	test_data.m_mode	= GL_LINES_ADJACENCY_EXT;
160e5c31af7Sopenharmony_ci	test_data.m_tf_mode = GL_LINES;
161e5c31af7Sopenharmony_ci
162e5c31af7Sopenharmony_ci	createGrid(test_data);
163e5c31af7Sopenharmony_ci
164e5c31af7Sopenharmony_ci	if (indiced)
165e5c31af7Sopenharmony_ci	{
166e5c31af7Sopenharmony_ci		setLinePointsindiced(test_data);
167e5c31af7Sopenharmony_ci	}
168e5c31af7Sopenharmony_ci	else
169e5c31af7Sopenharmony_ci	{
170e5c31af7Sopenharmony_ci		setLinePointsNonindiced(test_data);
171e5c31af7Sopenharmony_ci	}
172e5c31af7Sopenharmony_ci}
173e5c31af7Sopenharmony_ci
174e5c31af7Sopenharmony_ci/** Configure Test Data for GL_LINE_STRIP_ADJACENCY_EXT drawing mode
175e5c31af7Sopenharmony_ci *
176e5c31af7Sopenharmony_ci * @param testData reference to AdjacencyTestData instance to be configured
177e5c31af7Sopenharmony_ci *                  accordingly;
178e5c31af7Sopenharmony_ci * @param withGS   if true geometry shader code will be attached to test data;
179e5c31af7Sopenharmony_ci * @param indiced  if true indices will be stored in testData.
180e5c31af7Sopenharmony_ci **/
181e5c31af7Sopenharmony_civoid GeometryShaderAdjacencyTests::configureTestDataLineStrip(AdjacencyTestData& test_data, bool withGS, bool indiced)
182e5c31af7Sopenharmony_ci{
183e5c31af7Sopenharmony_ci	static const char* gsCode = "${VERSION}\n"
184e5c31af7Sopenharmony_ci								"\n"
185e5c31af7Sopenharmony_ci								"${GEOMETRY_SHADER_REQUIRE}\n"
186e5c31af7Sopenharmony_ci								"\n"
187e5c31af7Sopenharmony_ci								"precision highp float;\n"
188e5c31af7Sopenharmony_ci								"\n"
189e5c31af7Sopenharmony_ci								"layout(lines_adjacency)            in;\n"
190e5c31af7Sopenharmony_ci								"layout(line_strip, max_vertices=2) out;\n"
191e5c31af7Sopenharmony_ci								"\n"
192e5c31af7Sopenharmony_ci								"out vec4 out_adjacent_geometry;\n"
193e5c31af7Sopenharmony_ci								"out vec4 out_geometry;\n"
194e5c31af7Sopenharmony_ci								"\n"
195e5c31af7Sopenharmony_ci								"void main()\n"
196e5c31af7Sopenharmony_ci								"{\n"
197e5c31af7Sopenharmony_ci								"    out_adjacent_geometry = gl_in[0].gl_Position;\n"
198e5c31af7Sopenharmony_ci								"    out_geometry          = gl_in[1].gl_Position;\n"
199e5c31af7Sopenharmony_ci								"    EmitVertex();\n"
200e5c31af7Sopenharmony_ci								"    out_adjacent_geometry = gl_in[3].gl_Position;\n"
201e5c31af7Sopenharmony_ci								"    out_geometry          = gl_in[2].gl_Position;\n"
202e5c31af7Sopenharmony_ci								"    EmitVertex();\n"
203e5c31af7Sopenharmony_ci								"    EndPrimitive();\n"
204e5c31af7Sopenharmony_ci								"}\n";
205e5c31af7Sopenharmony_ci
206e5c31af7Sopenharmony_ci	test_data.m_gs_code = (withGS) ? gsCode : 0;
207e5c31af7Sopenharmony_ci	test_data.m_mode	= GL_LINE_STRIP_ADJACENCY_EXT;
208e5c31af7Sopenharmony_ci	test_data.m_tf_mode = GL_LINES;
209e5c31af7Sopenharmony_ci
210e5c31af7Sopenharmony_ci	createGrid(test_data);
211e5c31af7Sopenharmony_ci
212e5c31af7Sopenharmony_ci	if (indiced)
213e5c31af7Sopenharmony_ci	{
214e5c31af7Sopenharmony_ci		setLineStripPointsIndiced(test_data);
215e5c31af7Sopenharmony_ci	}
216e5c31af7Sopenharmony_ci	else
217e5c31af7Sopenharmony_ci	{
218e5c31af7Sopenharmony_ci		setLineStripPointsNonindiced(test_data);
219e5c31af7Sopenharmony_ci	}
220e5c31af7Sopenharmony_ci}
221e5c31af7Sopenharmony_ci
222e5c31af7Sopenharmony_ci/** Configure Test Data for GL_TRIANGLES_ADJACENCY_EXT drawing mode
223e5c31af7Sopenharmony_ci *
224e5c31af7Sopenharmony_ci * @param testData reference to AdjacencyTestData instance to be configured
225e5c31af7Sopenharmony_ci *                  accordingly;
226e5c31af7Sopenharmony_ci * @param withGS   if true geometry shader code will be attached to test data;
227e5c31af7Sopenharmony_ci * @param indiced  if true indices will be stored in testData.
228e5c31af7Sopenharmony_ci **/
229e5c31af7Sopenharmony_civoid GeometryShaderAdjacencyTests::configureTestDataTriangles(AdjacencyTestData& test_data, bool withGS, bool indiced)
230e5c31af7Sopenharmony_ci{
231e5c31af7Sopenharmony_ci	static const char* gsCode = "${VERSION}\n"
232e5c31af7Sopenharmony_ci								"\n"
233e5c31af7Sopenharmony_ci								"${GEOMETRY_SHADER_REQUIRE}\n"
234e5c31af7Sopenharmony_ci								"\n"
235e5c31af7Sopenharmony_ci								"precision highp float;\n"
236e5c31af7Sopenharmony_ci								"\n"
237e5c31af7Sopenharmony_ci								"layout(triangles_adjacency)            in;\n"
238e5c31af7Sopenharmony_ci								"layout(triangle_strip, max_vertices=3) out;\n"
239e5c31af7Sopenharmony_ci								"\n"
240e5c31af7Sopenharmony_ci								"out vec4 out_adjacent_geometry;\n"
241e5c31af7Sopenharmony_ci								"out vec4 out_geometry;\n"
242e5c31af7Sopenharmony_ci								"\n"
243e5c31af7Sopenharmony_ci								"void main()\n"
244e5c31af7Sopenharmony_ci								"{\n"
245e5c31af7Sopenharmony_ci								"    out_adjacent_geometry = gl_in[1].gl_Position;\n"
246e5c31af7Sopenharmony_ci								"    out_geometry          = gl_in[0].gl_Position;\n"
247e5c31af7Sopenharmony_ci								"    EmitVertex();\n"
248e5c31af7Sopenharmony_ci								"    out_adjacent_geometry = gl_in[3].gl_Position;\n"
249e5c31af7Sopenharmony_ci								"    out_geometry          = gl_in[2].gl_Position;\n"
250e5c31af7Sopenharmony_ci								"    EmitVertex();\n"
251e5c31af7Sopenharmony_ci								"    out_adjacent_geometry = gl_in[5].gl_Position;\n"
252e5c31af7Sopenharmony_ci								"    out_geometry          = gl_in[4].gl_Position;\n"
253e5c31af7Sopenharmony_ci								"    EmitVertex();\n"
254e5c31af7Sopenharmony_ci								"    EndPrimitive();\n"
255e5c31af7Sopenharmony_ci								"}\n";
256e5c31af7Sopenharmony_ci
257e5c31af7Sopenharmony_ci	test_data.m_gs_code = (withGS) ? gsCode : 0;
258e5c31af7Sopenharmony_ci	test_data.m_mode	= GL_TRIANGLES_ADJACENCY_EXT;
259e5c31af7Sopenharmony_ci	test_data.m_tf_mode = GL_TRIANGLES;
260e5c31af7Sopenharmony_ci
261e5c31af7Sopenharmony_ci	createGrid(test_data);
262e5c31af7Sopenharmony_ci
263e5c31af7Sopenharmony_ci	if (indiced)
264e5c31af7Sopenharmony_ci	{
265e5c31af7Sopenharmony_ci		setTrianglePointsIndiced(test_data);
266e5c31af7Sopenharmony_ci	}
267e5c31af7Sopenharmony_ci	else
268e5c31af7Sopenharmony_ci	{
269e5c31af7Sopenharmony_ci		setTrianglePointsNonindiced(test_data);
270e5c31af7Sopenharmony_ci	}
271e5c31af7Sopenharmony_ci}
272e5c31af7Sopenharmony_ci
273e5c31af7Sopenharmony_ci/** Configure Test Data for GL_TRIANGLE_STRIP_ADJACENCY_EXT drawing mode
274e5c31af7Sopenharmony_ci *
275e5c31af7Sopenharmony_ci * @param testData reference to AdjacencyTestData instance to be configured
276e5c31af7Sopenharmony_ci *                  accordingly;
277e5c31af7Sopenharmony_ci * @param withGS   if true geometry shader code will be attached to test data;
278e5c31af7Sopenharmony_ci * @param indiced  if true indices will be stored in test_data.
279e5c31af7Sopenharmony_ci **/
280e5c31af7Sopenharmony_civoid GeometryShaderAdjacencyTests::configureTestDataTriangleStrip(AdjacencyTestData& test_data, bool withGS,
281e5c31af7Sopenharmony_ci																  bool indiced)
282e5c31af7Sopenharmony_ci{
283e5c31af7Sopenharmony_ci	static const char* gsCode = "${VERSION}\n"
284e5c31af7Sopenharmony_ci								"\n"
285e5c31af7Sopenharmony_ci								"${GEOMETRY_SHADER_REQUIRE}\n"
286e5c31af7Sopenharmony_ci								"\n"
287e5c31af7Sopenharmony_ci								"precision highp float;\n"
288e5c31af7Sopenharmony_ci								"\n"
289e5c31af7Sopenharmony_ci								"layout(triangles_adjacency)            in;\n"
290e5c31af7Sopenharmony_ci								"layout(triangle_strip, max_vertices=3) out;\n"
291e5c31af7Sopenharmony_ci								"\n"
292e5c31af7Sopenharmony_ci								"out vec4 out_adjacent_geometry;\n"
293e5c31af7Sopenharmony_ci								"out vec4 out_geometry;\n"
294e5c31af7Sopenharmony_ci								"\n"
295e5c31af7Sopenharmony_ci								"void main()\n"
296e5c31af7Sopenharmony_ci								"{\n"
297e5c31af7Sopenharmony_ci								"    out_adjacent_geometry = gl_in[1].gl_Position;\n"
298e5c31af7Sopenharmony_ci								"    out_geometry          = gl_in[0].gl_Position;\n"
299e5c31af7Sopenharmony_ci								"    EmitVertex();\n"
300e5c31af7Sopenharmony_ci								"    out_adjacent_geometry = gl_in[3].gl_Position;\n"
301e5c31af7Sopenharmony_ci								"    out_geometry          = gl_in[2].gl_Position;\n"
302e5c31af7Sopenharmony_ci								"    EmitVertex();\n"
303e5c31af7Sopenharmony_ci								"    out_adjacent_geometry = gl_in[5].gl_Position;\n"
304e5c31af7Sopenharmony_ci								"    out_geometry          = gl_in[4].gl_Position;\n"
305e5c31af7Sopenharmony_ci								"    EmitVertex();\n"
306e5c31af7Sopenharmony_ci								"    EndPrimitive();\n"
307e5c31af7Sopenharmony_ci								"}\n";
308e5c31af7Sopenharmony_ci
309e5c31af7Sopenharmony_ci	test_data.m_gs_code = (withGS) ? gsCode : 0;
310e5c31af7Sopenharmony_ci	test_data.m_mode	= GL_TRIANGLE_STRIP_ADJACENCY_EXT;
311e5c31af7Sopenharmony_ci	test_data.m_tf_mode = GL_TRIANGLES;
312e5c31af7Sopenharmony_ci
313e5c31af7Sopenharmony_ci	createGrid(test_data);
314e5c31af7Sopenharmony_ci
315e5c31af7Sopenharmony_ci	if (indiced)
316e5c31af7Sopenharmony_ci	{
317e5c31af7Sopenharmony_ci		setTriangleStripPointsIndiced(test_data);
318e5c31af7Sopenharmony_ci	}
319e5c31af7Sopenharmony_ci	else
320e5c31af7Sopenharmony_ci	{
321e5c31af7Sopenharmony_ci		setTriangleStripPointsNonindiced(test_data);
322e5c31af7Sopenharmony_ci	}
323e5c31af7Sopenharmony_ci}
324e5c31af7Sopenharmony_ci
325e5c31af7Sopenharmony_ci/** Create vertex grid for the test instance.
326e5c31af7Sopenharmony_ci *
327e5c31af7Sopenharmony_ci * @param test_data AdjacencyTestData instance to be filled with grid data.
328e5c31af7Sopenharmony_ci */
329e5c31af7Sopenharmony_civoid GeometryShaderAdjacencyTests::createGrid(AdjacencyTestData& test_data)
330e5c31af7Sopenharmony_ci{
331e5c31af7Sopenharmony_ci	/* Create a grid object */
332e5c31af7Sopenharmony_ci	test_data.m_grid = new AdjacencyGrid;
333e5c31af7Sopenharmony_ci
334e5c31af7Sopenharmony_ci	/* Allocate space for grid elements */
335e5c31af7Sopenharmony_ci	test_data.m_grid->m_n_points = (m_grid_granulity + 1) * (m_grid_granulity + 1);
336e5c31af7Sopenharmony_ci	test_data.m_grid->m_line_segments =
337e5c31af7Sopenharmony_ci		new AdjacencyGridLineSegment[m_n_line_segments * m_grid_granulity * m_grid_granulity];
338e5c31af7Sopenharmony_ci	test_data.m_grid->m_points = new AdjacencyGridPoint[test_data.m_grid->m_n_points];
339e5c31af7Sopenharmony_ci
340e5c31af7Sopenharmony_ci	/* Generate points */
341e5c31af7Sopenharmony_ci	float		 dx		= 1.0f / static_cast<float>(m_grid_granulity);
342e5c31af7Sopenharmony_ci	float		 dy		= 1.0f / static_cast<float>(m_grid_granulity);
343e5c31af7Sopenharmony_ci	unsigned int nPoint = 0;
344e5c31af7Sopenharmony_ci
345e5c31af7Sopenharmony_ci	for (unsigned int y = 0; y < m_grid_granulity + 1; ++y)
346e5c31af7Sopenharmony_ci	{
347e5c31af7Sopenharmony_ci		for (unsigned int x = 0; x < m_grid_granulity + 1; ++x, ++nPoint)
348e5c31af7Sopenharmony_ci		{
349e5c31af7Sopenharmony_ci			test_data.m_grid->m_points[nPoint].index = nPoint;
350e5c31af7Sopenharmony_ci			test_data.m_grid->m_points[nPoint].x	 = dx * static_cast<float>(x);
351e5c31af7Sopenharmony_ci			test_data.m_grid->m_points[nPoint].y	 = dy * static_cast<float>(y);
352e5c31af7Sopenharmony_ci		}
353e5c31af7Sopenharmony_ci	}
354e5c31af7Sopenharmony_ci
355e5c31af7Sopenharmony_ci	switch (test_data.m_mode)
356e5c31af7Sopenharmony_ci	{
357e5c31af7Sopenharmony_ci	case GL_LINES_ADJACENCY_EXT:
358e5c31af7Sopenharmony_ci	{
359e5c31af7Sopenharmony_ci		/* Generate line segment data*/
360e5c31af7Sopenharmony_ci		createGridLineSegments(test_data);
361e5c31af7Sopenharmony_ci
362e5c31af7Sopenharmony_ci		break;
363e5c31af7Sopenharmony_ci	}
364e5c31af7Sopenharmony_ci
365e5c31af7Sopenharmony_ci	case GL_LINE_STRIP_ADJACENCY_EXT:
366e5c31af7Sopenharmony_ci	{
367e5c31af7Sopenharmony_ci		/* Line strip data generation requires line segment data to be present */
368e5c31af7Sopenharmony_ci		createGridLineSegments(test_data);
369e5c31af7Sopenharmony_ci
370e5c31af7Sopenharmony_ci		/* Generate line strip data */
371e5c31af7Sopenharmony_ci		createGridLineStrip(test_data);
372e5c31af7Sopenharmony_ci
373e5c31af7Sopenharmony_ci		break;
374e5c31af7Sopenharmony_ci	}
375e5c31af7Sopenharmony_ci
376e5c31af7Sopenharmony_ci	case GL_TRIANGLES_ADJACENCY_EXT:
377e5c31af7Sopenharmony_ci	{
378e5c31af7Sopenharmony_ci		/* Generate triangles data */
379e5c31af7Sopenharmony_ci		createGridTriangles(test_data);
380e5c31af7Sopenharmony_ci
381e5c31af7Sopenharmony_ci		break;
382e5c31af7Sopenharmony_ci	}
383e5c31af7Sopenharmony_ci
384e5c31af7Sopenharmony_ci	case GL_TRIANGLE_STRIP_ADJACENCY_EXT:
385e5c31af7Sopenharmony_ci	{
386e5c31af7Sopenharmony_ci		/* Triangle strip data generation requires triangle data to be present */
387e5c31af7Sopenharmony_ci		createGridTriangles(test_data);
388e5c31af7Sopenharmony_ci
389e5c31af7Sopenharmony_ci		/* Generate triangle strip data */
390e5c31af7Sopenharmony_ci		createGridTriangleStrip(test_data);
391e5c31af7Sopenharmony_ci
392e5c31af7Sopenharmony_ci		break;
393e5c31af7Sopenharmony_ci	}
394e5c31af7Sopenharmony_ci
395e5c31af7Sopenharmony_ci	default:
396e5c31af7Sopenharmony_ci	{
397e5c31af7Sopenharmony_ci		TCU_FAIL("Unrecognized test mode");
398e5c31af7Sopenharmony_ci	}
399e5c31af7Sopenharmony_ci	}
400e5c31af7Sopenharmony_ci}
401e5c31af7Sopenharmony_ci
402e5c31af7Sopenharmony_ci/** Generate Line segment data.
403e5c31af7Sopenharmony_ci *
404e5c31af7Sopenharmony_ci * @param test_data AdjacencyTestData instance to be filled with line segment data.
405e5c31af7Sopenharmony_ci **/
406e5c31af7Sopenharmony_civoid GeometryShaderAdjacencyTests::createGridLineSegments(AdjacencyTestData& test_data)
407e5c31af7Sopenharmony_ci{
408e5c31af7Sopenharmony_ci	/* Generate line segments.
409e5c31af7Sopenharmony_ci	 *
410e5c31af7Sopenharmony_ci	 * For simplicity, we consider all possible line segments for the grid. If a given line segment
411e5c31af7Sopenharmony_ci	 * is already stored, it is discarded.
412e5c31af7Sopenharmony_ci	 */
413e5c31af7Sopenharmony_ci	unsigned int nAddedSegments = 0;
414e5c31af7Sopenharmony_ci
415e5c31af7Sopenharmony_ci	for (unsigned int nPoint = 0; nPoint < m_grid_granulity * m_grid_granulity; ++nPoint)
416e5c31af7Sopenharmony_ci	{
417e5c31af7Sopenharmony_ci		AdjacencyGridPoint* pointTL = test_data.m_grid->m_points + nPoint;
418e5c31af7Sopenharmony_ci		AdjacencyGridPoint* pointTR = 0;
419e5c31af7Sopenharmony_ci		AdjacencyGridPoint* pointBL = 0;
420e5c31af7Sopenharmony_ci		AdjacencyGridPoint* pointBR = 0;
421e5c31af7Sopenharmony_ci
422e5c31af7Sopenharmony_ci		/* Retrieve neighbor point instances */
423e5c31af7Sopenharmony_ci		pointTR = test_data.m_grid->m_points + nPoint + 1;
424e5c31af7Sopenharmony_ci		pointBL = test_data.m_grid->m_points + m_grid_granulity + 1;
425e5c31af7Sopenharmony_ci		pointBR = test_data.m_grid->m_points + m_grid_granulity + 2;
426e5c31af7Sopenharmony_ci
427e5c31af7Sopenharmony_ci		/* For each quad, we need to to add at most 4 line segments.
428e5c31af7Sopenharmony_ci		 *
429e5c31af7Sopenharmony_ci		 * NOTE: Adjacent points are determined in later stage.
430e5c31af7Sopenharmony_ci		 **/
431e5c31af7Sopenharmony_ci		AdjacencyGridLineSegment* candidateSegments = new AdjacencyGridLineSegment[m_n_line_segments];
432e5c31af7Sopenharmony_ci
433e5c31af7Sopenharmony_ci		candidateSegments[0].m_point_start = pointTL;
434e5c31af7Sopenharmony_ci		candidateSegments[0].m_point_end   = pointTR;
435e5c31af7Sopenharmony_ci		candidateSegments[1].m_point_start = pointTR;
436e5c31af7Sopenharmony_ci		candidateSegments[1].m_point_end   = pointBR;
437e5c31af7Sopenharmony_ci		candidateSegments[2].m_point_start = pointBR;
438e5c31af7Sopenharmony_ci		candidateSegments[2].m_point_end   = pointBL;
439e5c31af7Sopenharmony_ci		candidateSegments[3].m_point_start = pointBL;
440e5c31af7Sopenharmony_ci		candidateSegments[3].m_point_end   = pointTL;
441e5c31af7Sopenharmony_ci
442e5c31af7Sopenharmony_ci		for (unsigned int nSegment = 0; nSegment < m_n_line_segments; ++nSegment)
443e5c31af7Sopenharmony_ci		{
444e5c31af7Sopenharmony_ci			bool					  alreadyAdded		  = false;
445e5c31af7Sopenharmony_ci			AdjacencyGridLineSegment* candidateSegmentPtr = candidateSegments + nSegment;
446e5c31af7Sopenharmony_ci
447e5c31af7Sopenharmony_ci			for (unsigned int n = 0; n < nAddedSegments; ++n)
448e5c31af7Sopenharmony_ci			{
449e5c31af7Sopenharmony_ci				AdjacencyGridLineSegment* segmentPtr = test_data.m_grid->m_line_segments + n;
450e5c31af7Sopenharmony_ci
451e5c31af7Sopenharmony_ci				/* Do not pay attention to direction of the line segment */
452e5c31af7Sopenharmony_ci				if ((segmentPtr->m_point_end == candidateSegmentPtr->m_point_end ||
453e5c31af7Sopenharmony_ci					 segmentPtr->m_point_end == candidateSegmentPtr->m_point_start) &&
454e5c31af7Sopenharmony_ci					(segmentPtr->m_point_start == candidateSegmentPtr->m_point_end ||
455e5c31af7Sopenharmony_ci					 segmentPtr->m_point_start == candidateSegmentPtr->m_point_start))
456e5c31af7Sopenharmony_ci				{
457e5c31af7Sopenharmony_ci					alreadyAdded = true;
458e5c31af7Sopenharmony_ci
459e5c31af7Sopenharmony_ci					break;
460e5c31af7Sopenharmony_ci				}
461e5c31af7Sopenharmony_ci			}
462e5c31af7Sopenharmony_ci
463e5c31af7Sopenharmony_ci			/* If not already added, store in the array */
464e5c31af7Sopenharmony_ci			if (!alreadyAdded)
465e5c31af7Sopenharmony_ci			{
466e5c31af7Sopenharmony_ci				test_data.m_grid->m_line_segments[nAddedSegments].m_point_end   = candidateSegmentPtr->m_point_end;
467e5c31af7Sopenharmony_ci				test_data.m_grid->m_line_segments[nAddedSegments].m_point_start = candidateSegmentPtr->m_point_start;
468e5c31af7Sopenharmony_ci
469e5c31af7Sopenharmony_ci				++nAddedSegments;
470e5c31af7Sopenharmony_ci			}
471e5c31af7Sopenharmony_ci		} /* for (all line segments) */
472e5c31af7Sopenharmony_ci
473e5c31af7Sopenharmony_ci		delete[] candidateSegments;
474e5c31af7Sopenharmony_ci		candidateSegments = DE_NULL;
475e5c31af7Sopenharmony_ci	} /* for (all grid points) */
476e5c31af7Sopenharmony_ci
477e5c31af7Sopenharmony_ci	test_data.m_grid->m_n_segments = nAddedSegments;
478e5c31af7Sopenharmony_ci
479e5c31af7Sopenharmony_ci	/* Determine adjacent points for line segments */
480e5c31af7Sopenharmony_ci	for (unsigned int nSegment = 0; nSegment < nAddedSegments; ++nSegment)
481e5c31af7Sopenharmony_ci	{
482e5c31af7Sopenharmony_ci		float					  endToAdjacentPointDelta   = 2.0f * static_cast<float>(m_grid_granulity);
483e5c31af7Sopenharmony_ci		AdjacencyGridLineSegment* segmentPtr				= test_data.m_grid->m_line_segments + nSegment;
484e5c31af7Sopenharmony_ci		float					  startToAdjacentPointDelta = 2.0f * static_cast<float>(m_grid_granulity);
485e5c31af7Sopenharmony_ci
486e5c31af7Sopenharmony_ci		/* For start and end points, find an adjacent vertex that is not a part of the considered line segment */
487e5c31af7Sopenharmony_ci		for (unsigned int nPoint = 0; nPoint < test_data.m_grid->m_n_points; ++nPoint)
488e5c31af7Sopenharmony_ci		{
489e5c31af7Sopenharmony_ci			AdjacencyGridPoint* pointPtr = test_data.m_grid->m_points + nPoint;
490e5c31af7Sopenharmony_ci
491e5c31af7Sopenharmony_ci			if (pointPtr != segmentPtr->m_point_end && pointPtr != segmentPtr->m_point_start)
492e5c31af7Sopenharmony_ci			{
493e5c31af7Sopenharmony_ci				float deltaStart = deFloatSqrt(
494e5c31af7Sopenharmony_ci					(segmentPtr->m_point_start->x - pointPtr->x) * (segmentPtr->m_point_start->x - pointPtr->x) +
495e5c31af7Sopenharmony_ci					(segmentPtr->m_point_start->y - pointPtr->y) * (segmentPtr->m_point_start->y - pointPtr->y));
496e5c31af7Sopenharmony_ci				float deltaEnd = deFloatSqrt(
497e5c31af7Sopenharmony_ci					(segmentPtr->m_point_end->x - pointPtr->x) * (segmentPtr->m_point_end->x - pointPtr->x) +
498e5c31af7Sopenharmony_ci					(segmentPtr->m_point_end->y - pointPtr->y) * (segmentPtr->m_point_end->y - pointPtr->y));
499e5c31af7Sopenharmony_ci
500e5c31af7Sopenharmony_ci				if (deltaStart < startToAdjacentPointDelta)
501e5c31af7Sopenharmony_ci				{
502e5c31af7Sopenharmony_ci					/* New adjacent point found for start point */
503e5c31af7Sopenharmony_ci					segmentPtr->m_point_start_adjacent = pointPtr;
504e5c31af7Sopenharmony_ci					startToAdjacentPointDelta		   = deltaStart;
505e5c31af7Sopenharmony_ci				}
506e5c31af7Sopenharmony_ci
507e5c31af7Sopenharmony_ci				if (deltaEnd < endToAdjacentPointDelta)
508e5c31af7Sopenharmony_ci				{
509e5c31af7Sopenharmony_ci					/* New adjacent point found for end point */
510e5c31af7Sopenharmony_ci					segmentPtr->m_point_end_adjacent = pointPtr;
511e5c31af7Sopenharmony_ci					endToAdjacentPointDelta			 = deltaEnd;
512e5c31af7Sopenharmony_ci				}
513e5c31af7Sopenharmony_ci			} /* if (point found) */
514e5c31af7Sopenharmony_ci		}	 /* for (all points) */
515e5c31af7Sopenharmony_ci	}		  /* for (all line segments) */
516e5c31af7Sopenharmony_ci}
517e5c31af7Sopenharmony_ci
518e5c31af7Sopenharmony_ci/** Generate Line Strip data
519e5c31af7Sopenharmony_ci *
520e5c31af7Sopenharmony_ci * @param test_data AdjacencyTestData instance ot be filled with line strip data.
521e5c31af7Sopenharmony_ci **/
522e5c31af7Sopenharmony_civoid GeometryShaderAdjacencyTests::createGridLineStrip(AdjacencyTestData& test_data)
523e5c31af7Sopenharmony_ci{
524e5c31af7Sopenharmony_ci	/* Add 2 extra point for adjacency start+end points */
525e5c31af7Sopenharmony_ci	test_data.m_grid->m_line_strip.m_n_points = test_data.m_grid->m_n_points + 2;
526e5c31af7Sopenharmony_ci	test_data.m_grid->m_line_strip.m_points   = new AdjacencyGridPoint[test_data.m_grid->m_line_strip.m_n_points];
527e5c31af7Sopenharmony_ci
528e5c31af7Sopenharmony_ci	memset(test_data.m_grid->m_line_strip.m_points, 0,
529e5c31af7Sopenharmony_ci		   sizeof(AdjacencyGridPoint) * test_data.m_grid->m_line_strip.m_n_points);
530e5c31af7Sopenharmony_ci
531e5c31af7Sopenharmony_ci	for (unsigned int n = 0; n < test_data.m_grid->m_line_strip.m_n_points; ++n)
532e5c31af7Sopenharmony_ci	{
533e5c31af7Sopenharmony_ci		AdjacencyGridPoint* pointPtr = test_data.m_grid->m_line_strip.m_points + n;
534e5c31af7Sopenharmony_ci
535e5c31af7Sopenharmony_ci		pointPtr->index = n;
536e5c31af7Sopenharmony_ci
537e5c31af7Sopenharmony_ci		/* If this is a start point, use any of the adjacent points */
538e5c31af7Sopenharmony_ci		if (n == 0)
539e5c31af7Sopenharmony_ci		{
540e5c31af7Sopenharmony_ci			pointPtr->x = test_data.m_grid->m_line_segments[0].m_point_start_adjacent->x;
541e5c31af7Sopenharmony_ci			pointPtr->y = test_data.m_grid->m_line_segments[0].m_point_start_adjacent->y;
542e5c31af7Sopenharmony_ci		}
543e5c31af7Sopenharmony_ci		else
544e5c31af7Sopenharmony_ci			/* Last point should be handled analogously */
545e5c31af7Sopenharmony_ci			if (n == (test_data.m_grid->m_line_strip.m_n_points - 1))
546e5c31af7Sopenharmony_ci		{
547e5c31af7Sopenharmony_ci			pointPtr->x = test_data.m_grid->m_line_segments[test_data.m_grid->m_n_segments - 1].m_point_end_adjacent->x;
548e5c31af7Sopenharmony_ci			pointPtr->y = test_data.m_grid->m_line_segments[test_data.m_grid->m_n_segments - 1].m_point_end_adjacent->y;
549e5c31af7Sopenharmony_ci		}
550e5c31af7Sopenharmony_ci		else
551e5c31af7Sopenharmony_ci		/* Intermediate points */
552e5c31af7Sopenharmony_ci		{
553e5c31af7Sopenharmony_ci			pointPtr->x = test_data.m_grid->m_line_segments[n - 1].m_point_start->x;
554e5c31af7Sopenharmony_ci			pointPtr->y = test_data.m_grid->m_line_segments[n - 1].m_point_start->y;
555e5c31af7Sopenharmony_ci		}
556e5c31af7Sopenharmony_ci	} /* for (all points) */
557e5c31af7Sopenharmony_ci}
558e5c31af7Sopenharmony_ci
559e5c31af7Sopenharmony_ci/** Generate Triangles data.
560e5c31af7Sopenharmony_ci *
561e5c31af7Sopenharmony_ci * @param test_data AdjacencyTestData instance to be filled with triangles data.
562e5c31af7Sopenharmony_ci **/
563e5c31af7Sopenharmony_civoid GeometryShaderAdjacencyTests::createGridTriangles(AdjacencyTestData& test_data)
564e5c31af7Sopenharmony_ci{
565e5c31af7Sopenharmony_ci	const int	nTrianglesPerQuad = 2;
566e5c31af7Sopenharmony_ci	unsigned int nTriangles		   = m_grid_granulity * m_grid_granulity * nTrianglesPerQuad;
567e5c31af7Sopenharmony_ci
568e5c31af7Sopenharmony_ci	test_data.m_grid->m_triangles   = new AdjacencyGridTriangle[nTriangles];
569e5c31af7Sopenharmony_ci	test_data.m_grid->m_n_triangles = nTriangles;
570e5c31af7Sopenharmony_ci
571e5c31af7Sopenharmony_ci	for (unsigned int nQuad = 0; nQuad < (nTriangles / nTrianglesPerQuad); ++nQuad)
572e5c31af7Sopenharmony_ci	{
573e5c31af7Sopenharmony_ci		unsigned int quadTLX = (nQuad) % m_grid_granulity;
574e5c31af7Sopenharmony_ci		unsigned int quadTLY = (nQuad) / m_grid_granulity;
575e5c31af7Sopenharmony_ci
576e5c31af7Sopenharmony_ci		/* Grid is built off points row-by-row. */
577e5c31af7Sopenharmony_ci		AdjacencyGridPoint* pointTL = test_data.m_grid->m_points + (quadTLY * (m_grid_granulity + 1) + quadTLX);
578e5c31af7Sopenharmony_ci		AdjacencyGridPoint* pointTR = test_data.m_grid->m_points + (quadTLY * (m_grid_granulity + 1) + quadTLX + 1);
579e5c31af7Sopenharmony_ci		AdjacencyGridPoint* pointBL = test_data.m_grid->m_points + ((quadTLY + 1) * (m_grid_granulity + 1) + quadTLX);
580e5c31af7Sopenharmony_ci		AdjacencyGridPoint* pointBR =
581e5c31af7Sopenharmony_ci			test_data.m_grid->m_points + ((quadTLY + 1) * (m_grid_granulity + 1) + quadTLX + 1);
582e5c31af7Sopenharmony_ci
583e5c31af7Sopenharmony_ci		/* Note: In many cases, the adjacency data used below is not correct topologically-wise.
584e5c31af7Sopenharmony_ci		 *       However, since we're not doing any rendering, we're safe as long as unique data
585e5c31af7Sopenharmony_ci		 *       is used.
586e5c31af7Sopenharmony_ci		 */
587e5c31af7Sopenharmony_ci		test_data.m_grid->m_triangles[nQuad * nTrianglesPerQuad + 0].m_vertex_x			 = pointTL;
588e5c31af7Sopenharmony_ci		test_data.m_grid->m_triangles[nQuad * nTrianglesPerQuad + 0].m_vertex_x_adjacent = pointTR;
589e5c31af7Sopenharmony_ci		test_data.m_grid->m_triangles[nQuad * nTrianglesPerQuad + 0].m_vertex_y			 = pointBR;
590e5c31af7Sopenharmony_ci		test_data.m_grid->m_triangles[nQuad * nTrianglesPerQuad + 0].m_vertex_y_adjacent = pointBL;
591e5c31af7Sopenharmony_ci		test_data.m_grid->m_triangles[nQuad * nTrianglesPerQuad + 0].m_vertex_z			 = pointBL;
592e5c31af7Sopenharmony_ci		test_data.m_grid->m_triangles[nQuad * nTrianglesPerQuad + 0].m_vertex_z_adjacent = pointBR;
593e5c31af7Sopenharmony_ci
594e5c31af7Sopenharmony_ci		test_data.m_grid->m_triangles[nQuad * nTrianglesPerQuad + 1].m_vertex_x			 = pointTL;
595e5c31af7Sopenharmony_ci		test_data.m_grid->m_triangles[nQuad * nTrianglesPerQuad + 1].m_vertex_x_adjacent = pointTR;
596e5c31af7Sopenharmony_ci		test_data.m_grid->m_triangles[nQuad * nTrianglesPerQuad + 1].m_vertex_y			 = pointTR;
597e5c31af7Sopenharmony_ci		test_data.m_grid->m_triangles[nQuad * nTrianglesPerQuad + 1].m_vertex_y_adjacent = pointTL;
598e5c31af7Sopenharmony_ci		test_data.m_grid->m_triangles[nQuad * nTrianglesPerQuad + 1].m_vertex_z			 = pointBR;
599e5c31af7Sopenharmony_ci		test_data.m_grid->m_triangles[nQuad * nTrianglesPerQuad + 1].m_vertex_z_adjacent = pointBL;
600e5c31af7Sopenharmony_ci	}
601e5c31af7Sopenharmony_ci}
602e5c31af7Sopenharmony_ci
603e5c31af7Sopenharmony_ci/** Generate Triangle Strip data.
604e5c31af7Sopenharmony_ci *
605e5c31af7Sopenharmony_ci * @param test_data AdjacencyTestData instance to be filled with relevant data.
606e5c31af7Sopenharmony_ci **/
607e5c31af7Sopenharmony_civoid GeometryShaderAdjacencyTests::createGridTriangleStrip(AdjacencyTestData& test_data)
608e5c31af7Sopenharmony_ci{
609e5c31af7Sopenharmony_ci	/* For simplicity, reuse adjacency data we have already defined for single triangles.
610e5c31af7Sopenharmony_ci	 * This does not make a correct topology, but our point is to verify that shaders
611e5c31af7Sopenharmony_ci	 * are fed valid values (as per spec), not to confirm rendering works correctly.
612e5c31af7Sopenharmony_ci	 */
613e5c31af7Sopenharmony_ci	const int nVerticesPerTriangleStripPrimitive = 6;
614e5c31af7Sopenharmony_ci
615e5c31af7Sopenharmony_ci	test_data.m_grid->m_triangle_strip.m_n_points =
616e5c31af7Sopenharmony_ci		test_data.m_grid->m_n_triangles * nVerticesPerTriangleStripPrimitive;
617e5c31af7Sopenharmony_ci	test_data.m_grid->m_triangle_strip.m_points = new AdjacencyGridPoint[test_data.m_grid->m_triangle_strip.m_n_points];
618e5c31af7Sopenharmony_ci
619e5c31af7Sopenharmony_ci	memset(test_data.m_grid->m_triangle_strip.m_points, 0,
620e5c31af7Sopenharmony_ci		   sizeof(AdjacencyGridPoint) * test_data.m_grid->m_triangle_strip.m_n_points);
621e5c31af7Sopenharmony_ci
622e5c31af7Sopenharmony_ci	for (unsigned int n = 0; n < test_data.m_grid->m_triangle_strip.m_n_points; ++n)
623e5c31af7Sopenharmony_ci	{
624e5c31af7Sopenharmony_ci		AdjacencyGridPoint*	pointPtr		 = test_data.m_grid->m_triangle_strip.m_points + n;
625e5c31af7Sopenharmony_ci		unsigned int		   triangleIndex = n / nVerticesPerTriangleStripPrimitive;
626e5c31af7Sopenharmony_ci		AdjacencyGridTriangle* trianglePtr   = test_data.m_grid->m_triangles + triangleIndex;
627e5c31af7Sopenharmony_ci
628e5c31af7Sopenharmony_ci		pointPtr->index = n;
629e5c31af7Sopenharmony_ci
630e5c31af7Sopenharmony_ci		switch (n % nVerticesPerTriangleStripPrimitive)
631e5c31af7Sopenharmony_ci		{
632e5c31af7Sopenharmony_ci		case 0:
633e5c31af7Sopenharmony_ci			pointPtr->x = trianglePtr->m_vertex_x->x;
634e5c31af7Sopenharmony_ci			pointPtr->y = trianglePtr->m_vertex_x->y;
635e5c31af7Sopenharmony_ci			break;
636e5c31af7Sopenharmony_ci		case 1:
637e5c31af7Sopenharmony_ci			pointPtr->x = trianglePtr->m_vertex_x_adjacent->x;
638e5c31af7Sopenharmony_ci			pointPtr->y = trianglePtr->m_vertex_x_adjacent->y;
639e5c31af7Sopenharmony_ci			break;
640e5c31af7Sopenharmony_ci		case 2:
641e5c31af7Sopenharmony_ci			pointPtr->x = trianglePtr->m_vertex_y->x;
642e5c31af7Sopenharmony_ci			pointPtr->y = trianglePtr->m_vertex_y->y;
643e5c31af7Sopenharmony_ci			break;
644e5c31af7Sopenharmony_ci		case 3:
645e5c31af7Sopenharmony_ci			pointPtr->x = trianglePtr->m_vertex_y_adjacent->x;
646e5c31af7Sopenharmony_ci			pointPtr->y = trianglePtr->m_vertex_y_adjacent->y;
647e5c31af7Sopenharmony_ci			break;
648e5c31af7Sopenharmony_ci		case 4:
649e5c31af7Sopenharmony_ci			pointPtr->x = trianglePtr->m_vertex_z->x;
650e5c31af7Sopenharmony_ci			pointPtr->y = trianglePtr->m_vertex_z->y;
651e5c31af7Sopenharmony_ci			break;
652e5c31af7Sopenharmony_ci		case 5:
653e5c31af7Sopenharmony_ci			pointPtr->x = trianglePtr->m_vertex_z_adjacent->x;
654e5c31af7Sopenharmony_ci			pointPtr->y = trianglePtr->m_vertex_z_adjacent->y;
655e5c31af7Sopenharmony_ci			break;
656e5c31af7Sopenharmony_ci		}
657e5c31af7Sopenharmony_ci	} /* for (all points) */
658e5c31af7Sopenharmony_ci}
659e5c31af7Sopenharmony_ci
660e5c31af7Sopenharmony_ci/** Set line vertex data used to be used by non-indiced draw calls.
661e5c31af7Sopenharmony_ci *
662e5c31af7Sopenharmony_ci * @param test_data AdjacencyTestData instance to be filled with relevant data.
663e5c31af7Sopenharmony_ci **/
664e5c31af7Sopenharmony_civoid GeometryShaderAdjacencyTests::setLinePointsNonindiced(AdjacencyTestData& test_data)
665e5c31af7Sopenharmony_ci{
666e5c31af7Sopenharmony_ci	float* travellerExpectedAdjacencyGeometryPtr = 0;
667e5c31af7Sopenharmony_ci	float* travellerExpectedGeometryPtr			 = 0;
668e5c31af7Sopenharmony_ci	float* travellerPtr							 = 0;
669e5c31af7Sopenharmony_ci
670e5c31af7Sopenharmony_ci	/* Set buffer sizes */
671e5c31af7Sopenharmony_ci	test_data.m_n_vertices = test_data.m_grid->m_n_segments * 2 /* start + end points form a segment */;
672e5c31af7Sopenharmony_ci	test_data.m_geometry_bo_size =
673e5c31af7Sopenharmony_ci		static_cast<glw::GLuint>(test_data.m_n_vertices * m_n_components_output * sizeof(float));
674e5c31af7Sopenharmony_ci	test_data.m_vertex_data_bo_size = static_cast<glw::GLuint>(test_data.m_n_vertices * m_n_components_input *
675e5c31af7Sopenharmony_ci															   2 /* include adjacency info */ * sizeof(float));
676e5c31af7Sopenharmony_ci
677e5c31af7Sopenharmony_ci	/* Allocate memory for input and expected data */
678e5c31af7Sopenharmony_ci	test_data.m_expected_adjacency_geometry = new float[test_data.m_geometry_bo_size / sizeof(float)];
679e5c31af7Sopenharmony_ci	test_data.m_expected_geometry			= new float[test_data.m_geometry_bo_size / sizeof(float)];
680e5c31af7Sopenharmony_ci	test_data.m_vertex_data					= new float[test_data.m_vertex_data_bo_size / sizeof(float)];
681e5c31af7Sopenharmony_ci
682e5c31af7Sopenharmony_ci	travellerExpectedAdjacencyGeometryPtr = test_data.m_expected_adjacency_geometry;
683e5c31af7Sopenharmony_ci	travellerExpectedGeometryPtr		  = test_data.m_expected_geometry;
684e5c31af7Sopenharmony_ci	travellerPtr						  = test_data.m_vertex_data;
685e5c31af7Sopenharmony_ci
686e5c31af7Sopenharmony_ci	/* Set input and expected values */
687e5c31af7Sopenharmony_ci	for (unsigned int n = 0; n < test_data.m_grid->m_n_segments; ++n)
688e5c31af7Sopenharmony_ci	{
689e5c31af7Sopenharmony_ci		AdjacencyGridLineSegment* segmentPtr = test_data.m_grid->m_line_segments + n;
690e5c31af7Sopenharmony_ci
691e5c31af7Sopenharmony_ci		*travellerPtr = segmentPtr->m_point_start_adjacent->x;
692e5c31af7Sopenharmony_ci		++travellerPtr;
693e5c31af7Sopenharmony_ci		*travellerPtr = segmentPtr->m_point_start_adjacent->y;
694e5c31af7Sopenharmony_ci		++travellerPtr;
695e5c31af7Sopenharmony_ci		*travellerPtr = segmentPtr->m_point_start->x;
696e5c31af7Sopenharmony_ci		++travellerPtr;
697e5c31af7Sopenharmony_ci		*travellerPtr = segmentPtr->m_point_start->y;
698e5c31af7Sopenharmony_ci		++travellerPtr;
699e5c31af7Sopenharmony_ci		*travellerPtr = segmentPtr->m_point_end->x;
700e5c31af7Sopenharmony_ci		++travellerPtr;
701e5c31af7Sopenharmony_ci		*travellerPtr = segmentPtr->m_point_end->y;
702e5c31af7Sopenharmony_ci		++travellerPtr;
703e5c31af7Sopenharmony_ci		*travellerPtr = segmentPtr->m_point_end_adjacent->x;
704e5c31af7Sopenharmony_ci		++travellerPtr;
705e5c31af7Sopenharmony_ci		*travellerPtr = segmentPtr->m_point_end_adjacent->y;
706e5c31af7Sopenharmony_ci		++travellerPtr;
707e5c31af7Sopenharmony_ci
708e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = segmentPtr->m_point_start_adjacent->x;
709e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
710e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = segmentPtr->m_point_start_adjacent->y;
711e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
712e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = 0;
713e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
714e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = 1;
715e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
716e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = segmentPtr->m_point_end_adjacent->x;
717e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
718e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = segmentPtr->m_point_end_adjacent->y;
719e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
720e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = 0;
721e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
722e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = 1;
723e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
724e5c31af7Sopenharmony_ci
725e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = segmentPtr->m_point_start->x;
726e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
727e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = segmentPtr->m_point_start->y;
728e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
729e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = 0;
730e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
731e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = 1;
732e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
733e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = segmentPtr->m_point_end->x;
734e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
735e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = segmentPtr->m_point_end->y;
736e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
737e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = 0;
738e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
739e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = 1;
740e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
741e5c31af7Sopenharmony_ci	} /* for (all line segments) */
742e5c31af7Sopenharmony_ci}
743e5c31af7Sopenharmony_ci
744e5c31af7Sopenharmony_ci/** Set line vertex data used to be used by indiced draw calls.
745e5c31af7Sopenharmony_ci *
746e5c31af7Sopenharmony_ci * @param test_data AdjacencyTestData instance to be filled with relevant data.
747e5c31af7Sopenharmony_ci **/
748e5c31af7Sopenharmony_civoid GeometryShaderAdjacencyTests::setLinePointsindiced(AdjacencyTestData& test_data)
749e5c31af7Sopenharmony_ci{
750e5c31af7Sopenharmony_ci	float*		  travellerExpectedAdjacencyGeometryPtr = 0;
751e5c31af7Sopenharmony_ci	float*		  travellerExpectedGeometryPtr			= 0;
752e5c31af7Sopenharmony_ci	unsigned int* travellerIndicesPtr					= 0;
753e5c31af7Sopenharmony_ci	float*		  travellerPtr							= 0;
754e5c31af7Sopenharmony_ci
755e5c31af7Sopenharmony_ci	/* Set buffer sizes */
756e5c31af7Sopenharmony_ci	test_data.m_n_vertices = test_data.m_grid->m_n_segments * 2 /* start + end points form a segment */;
757e5c31af7Sopenharmony_ci	test_data.m_geometry_bo_size =
758e5c31af7Sopenharmony_ci		static_cast<glw::GLuint>(test_data.m_n_vertices * m_n_components_output * sizeof(float));
759e5c31af7Sopenharmony_ci	test_data.m_vertex_data_bo_size =
760e5c31af7Sopenharmony_ci		static_cast<glw::GLuint>(test_data.m_grid->m_n_points * m_n_components_input * sizeof(float));
761e5c31af7Sopenharmony_ci	test_data.m_index_data_bo_size =
762e5c31af7Sopenharmony_ci		static_cast<glw::GLuint>(test_data.m_n_vertices * 2 /* include adjacency info */ * sizeof(unsigned int));
763e5c31af7Sopenharmony_ci
764e5c31af7Sopenharmony_ci	/* Allocate memory for input and expected data */
765e5c31af7Sopenharmony_ci	test_data.m_expected_adjacency_geometry = new float[test_data.m_geometry_bo_size / sizeof(float)];
766e5c31af7Sopenharmony_ci	test_data.m_expected_geometry			= new float[test_data.m_geometry_bo_size / sizeof(float)];
767e5c31af7Sopenharmony_ci	test_data.m_index_data					= new unsigned int[test_data.m_index_data_bo_size / sizeof(unsigned int)];
768e5c31af7Sopenharmony_ci	test_data.m_vertex_data					= new float[test_data.m_vertex_data_bo_size / sizeof(float)];
769e5c31af7Sopenharmony_ci
770e5c31af7Sopenharmony_ci	travellerExpectedAdjacencyGeometryPtr = test_data.m_expected_adjacency_geometry;
771e5c31af7Sopenharmony_ci	travellerExpectedGeometryPtr		  = test_data.m_expected_geometry;
772e5c31af7Sopenharmony_ci	travellerIndicesPtr					  = test_data.m_index_data;
773e5c31af7Sopenharmony_ci	travellerPtr						  = test_data.m_vertex_data;
774e5c31af7Sopenharmony_ci
775e5c31af7Sopenharmony_ci	/* Set input and expected values */
776e5c31af7Sopenharmony_ci	for (unsigned int n = 0; n < test_data.m_grid->m_n_points; ++n)
777e5c31af7Sopenharmony_ci	{
778e5c31af7Sopenharmony_ci		*travellerPtr = test_data.m_grid->m_points[n].x;
779e5c31af7Sopenharmony_ci		++travellerPtr;
780e5c31af7Sopenharmony_ci		*travellerPtr = test_data.m_grid->m_points[n].y;
781e5c31af7Sopenharmony_ci		++travellerPtr;
782e5c31af7Sopenharmony_ci	}
783e5c31af7Sopenharmony_ci
784e5c31af7Sopenharmony_ci	for (unsigned int n = 0; n < test_data.m_grid->m_n_segments; ++n)
785e5c31af7Sopenharmony_ci	{
786e5c31af7Sopenharmony_ci		AdjacencyGridLineSegment* segmentPtr = test_data.m_grid->m_line_segments + n;
787e5c31af7Sopenharmony_ci
788e5c31af7Sopenharmony_ci		*travellerIndicesPtr = segmentPtr->m_point_end_adjacent->index;
789e5c31af7Sopenharmony_ci		++travellerIndicesPtr;
790e5c31af7Sopenharmony_ci		*travellerIndicesPtr = segmentPtr->m_point_end->index;
791e5c31af7Sopenharmony_ci		++travellerIndicesPtr;
792e5c31af7Sopenharmony_ci		*travellerIndicesPtr = segmentPtr->m_point_start->index;
793e5c31af7Sopenharmony_ci		++travellerIndicesPtr;
794e5c31af7Sopenharmony_ci		*travellerIndicesPtr = segmentPtr->m_point_start_adjacent->index;
795e5c31af7Sopenharmony_ci		++travellerIndicesPtr;
796e5c31af7Sopenharmony_ci
797e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = segmentPtr->m_point_end_adjacent->x;
798e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
799e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = segmentPtr->m_point_end_adjacent->y;
800e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
801e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = 0;
802e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
803e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = 1;
804e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
805e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = segmentPtr->m_point_start_adjacent->x;
806e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
807e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = segmentPtr->m_point_start_adjacent->y;
808e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
809e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = 0;
810e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
811e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = 1;
812e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
813e5c31af7Sopenharmony_ci
814e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = segmentPtr->m_point_end->x;
815e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
816e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = segmentPtr->m_point_end->y;
817e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
818e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = 0;
819e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
820e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = 1;
821e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
822e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = segmentPtr->m_point_start->x;
823e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
824e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = segmentPtr->m_point_start->y;
825e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
826e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = 0;
827e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
828e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = 1;
829e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
830e5c31af7Sopenharmony_ci	} /* for (all line segments) */
831e5c31af7Sopenharmony_ci}
832e5c31af7Sopenharmony_ci
833e5c31af7Sopenharmony_ci/** Set line strip vertex data used to be used by non-indiced draw calls.
834e5c31af7Sopenharmony_ci *
835e5c31af7Sopenharmony_ci * @param test_data AdjacencyTestData instance to be filled with relevant data.
836e5c31af7Sopenharmony_ci **/
837e5c31af7Sopenharmony_civoid GeometryShaderAdjacencyTests::setLineStripPointsNonindiced(AdjacencyTestData& test_data)
838e5c31af7Sopenharmony_ci{
839e5c31af7Sopenharmony_ci	float* travellerExpectedAdjacencyGeometryPtr = 0;
840e5c31af7Sopenharmony_ci	float* travellerExpectedGeometryPtr			 = 0;
841e5c31af7Sopenharmony_ci	float* travellerPtr							 = 0;
842e5c31af7Sopenharmony_ci
843e5c31af7Sopenharmony_ci	/* Set buffer sizes */
844e5c31af7Sopenharmony_ci	test_data.m_n_vertices		 = test_data.m_grid->m_line_strip.m_n_points;
845e5c31af7Sopenharmony_ci	test_data.m_geometry_bo_size = static_cast<glw::GLuint>((test_data.m_n_vertices - 3) * m_n_components_output *
846e5c31af7Sopenharmony_ci															2 /* start/end */ * sizeof(float));
847e5c31af7Sopenharmony_ci	test_data.m_vertex_data_bo_size =
848e5c31af7Sopenharmony_ci		static_cast<glw::GLuint>(test_data.m_n_vertices * m_n_components_input * sizeof(float));
849e5c31af7Sopenharmony_ci
850e5c31af7Sopenharmony_ci	/* Allocate memory for input and expected data */
851e5c31af7Sopenharmony_ci	test_data.m_expected_adjacency_geometry = new float[test_data.m_geometry_bo_size / sizeof(float)];
852e5c31af7Sopenharmony_ci	test_data.m_expected_geometry			= new float[test_data.m_geometry_bo_size / sizeof(float)];
853e5c31af7Sopenharmony_ci	test_data.m_vertex_data					= new float[test_data.m_vertex_data_bo_size / sizeof(float)];
854e5c31af7Sopenharmony_ci
855e5c31af7Sopenharmony_ci	travellerExpectedAdjacencyGeometryPtr = test_data.m_expected_adjacency_geometry;
856e5c31af7Sopenharmony_ci	travellerExpectedGeometryPtr		  = test_data.m_expected_geometry;
857e5c31af7Sopenharmony_ci	travellerPtr						  = test_data.m_vertex_data;
858e5c31af7Sopenharmony_ci
859e5c31af7Sopenharmony_ci	/* Set input and expected values */
860e5c31af7Sopenharmony_ci	for (unsigned int n = 0; n < test_data.m_n_vertices; ++n)
861e5c31af7Sopenharmony_ci	{
862e5c31af7Sopenharmony_ci		*travellerPtr = test_data.m_grid->m_line_strip.m_points[n].x;
863e5c31af7Sopenharmony_ci		++travellerPtr;
864e5c31af7Sopenharmony_ci		*travellerPtr = test_data.m_grid->m_line_strip.m_points[n].y;
865e5c31af7Sopenharmony_ci		++travellerPtr;
866e5c31af7Sopenharmony_ci	}
867e5c31af7Sopenharmony_ci
868e5c31af7Sopenharmony_ci	for (unsigned int n = 0; n < test_data.m_n_vertices - 3; ++n)
869e5c31af7Sopenharmony_ci	{
870e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = test_data.m_grid->m_line_strip.m_points[n].x;
871e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
872e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = test_data.m_grid->m_line_strip.m_points[n].y;
873e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
874e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = 0;
875e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
876e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = 1;
877e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
878e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = test_data.m_grid->m_line_strip.m_points[n + 3].x;
879e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
880e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = test_data.m_grid->m_line_strip.m_points[n + 3].y;
881e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
882e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = 0;
883e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
884e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = 1;
885e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
886e5c31af7Sopenharmony_ci
887e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = test_data.m_grid->m_line_strip.m_points[n + 1].x;
888e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
889e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = test_data.m_grid->m_line_strip.m_points[n + 1].y;
890e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
891e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = 0;
892e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
893e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = 1;
894e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
895e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = test_data.m_grid->m_line_strip.m_points[n + 2].x;
896e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
897e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = test_data.m_grid->m_line_strip.m_points[n + 2].y;
898e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
899e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = 0;
900e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
901e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = 1;
902e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
903e5c31af7Sopenharmony_ci	} /* for (all vertices (apart from the three last ones) ) */
904e5c31af7Sopenharmony_ci}
905e5c31af7Sopenharmony_ci
906e5c31af7Sopenharmony_ci/** Set line strip vertex data used to be used by indiced draw calls.
907e5c31af7Sopenharmony_ci *
908e5c31af7Sopenharmony_ci * @param test_data AdjacencyTestData instance to be filled with relevant data.
909e5c31af7Sopenharmony_ci **/
910e5c31af7Sopenharmony_civoid GeometryShaderAdjacencyTests::setLineStripPointsIndiced(AdjacencyTestData& test_data)
911e5c31af7Sopenharmony_ci{
912e5c31af7Sopenharmony_ci
913e5c31af7Sopenharmony_ci	float*		  travellerExpectedAdjacencyGeometryPtr = 0;
914e5c31af7Sopenharmony_ci	float*		  travellerExpectedGeometryPtr			= 0;
915e5c31af7Sopenharmony_ci	unsigned int* travellerIndicesPtr					= 0;
916e5c31af7Sopenharmony_ci	float*		  travellerPtr							= 0;
917e5c31af7Sopenharmony_ci
918e5c31af7Sopenharmony_ci	/* Set buffer sizes */
919e5c31af7Sopenharmony_ci	test_data.m_n_vertices		 = test_data.m_grid->m_line_strip.m_n_points;
920e5c31af7Sopenharmony_ci	test_data.m_geometry_bo_size = static_cast<glw::GLuint>((test_data.m_n_vertices - 3) * m_n_components_output *
921e5c31af7Sopenharmony_ci															2 /* start/end */ * sizeof(float));
922e5c31af7Sopenharmony_ci	test_data.m_vertex_data_bo_size =
923e5c31af7Sopenharmony_ci		static_cast<glw::GLuint>(test_data.m_n_vertices * m_n_components_input * sizeof(float));
924e5c31af7Sopenharmony_ci	test_data.m_index_data_bo_size = static_cast<glw::GLuint>(test_data.m_n_vertices * sizeof(unsigned int));
925e5c31af7Sopenharmony_ci
926e5c31af7Sopenharmony_ci	/* Allocate memory for input and expected data */
927e5c31af7Sopenharmony_ci	test_data.m_expected_adjacency_geometry = new float[test_data.m_geometry_bo_size / sizeof(float)];
928e5c31af7Sopenharmony_ci	test_data.m_expected_geometry			= new float[test_data.m_geometry_bo_size / sizeof(float)];
929e5c31af7Sopenharmony_ci	test_data.m_index_data					= new unsigned int[test_data.m_index_data_bo_size / sizeof(unsigned int)];
930e5c31af7Sopenharmony_ci	test_data.m_vertex_data					= new float[test_data.m_vertex_data_bo_size / sizeof(float)];
931e5c31af7Sopenharmony_ci
932e5c31af7Sopenharmony_ci	travellerExpectedAdjacencyGeometryPtr = test_data.m_expected_adjacency_geometry;
933e5c31af7Sopenharmony_ci	travellerExpectedGeometryPtr		  = test_data.m_expected_geometry;
934e5c31af7Sopenharmony_ci	travellerIndicesPtr					  = test_data.m_index_data;
935e5c31af7Sopenharmony_ci	travellerPtr						  = test_data.m_vertex_data;
936e5c31af7Sopenharmony_ci
937e5c31af7Sopenharmony_ci	/* Set input and expected value s*/
938e5c31af7Sopenharmony_ci	for (unsigned int n = 0; n < test_data.m_n_vertices; ++n)
939e5c31af7Sopenharmony_ci	{
940e5c31af7Sopenharmony_ci		*travellerPtr = test_data.m_grid->m_line_strip.m_points[n].x;
941e5c31af7Sopenharmony_ci		++travellerPtr;
942e5c31af7Sopenharmony_ci		*travellerPtr = test_data.m_grid->m_line_strip.m_points[n].y;
943e5c31af7Sopenharmony_ci		++travellerPtr;
944e5c31af7Sopenharmony_ci	}
945e5c31af7Sopenharmony_ci
946e5c31af7Sopenharmony_ci	for (unsigned int n = 0; n < test_data.m_n_vertices; ++n)
947e5c31af7Sopenharmony_ci	{
948e5c31af7Sopenharmony_ci		*travellerIndicesPtr = (test_data.m_n_vertices - n - 1);
949e5c31af7Sopenharmony_ci		++travellerIndicesPtr;
950e5c31af7Sopenharmony_ci	}
951e5c31af7Sopenharmony_ci
952e5c31af7Sopenharmony_ci	for (unsigned int n = 0; n < test_data.m_n_vertices - 3; ++n)
953e5c31af7Sopenharmony_ci	{
954e5c31af7Sopenharmony_ci		AdjacencyGridPoint* pointN0 = test_data.m_grid->m_line_strip.m_points + test_data.m_index_data[n];
955e5c31af7Sopenharmony_ci		AdjacencyGridPoint* pointN1 = test_data.m_grid->m_line_strip.m_points + test_data.m_index_data[n + 1];
956e5c31af7Sopenharmony_ci		AdjacencyGridPoint* pointN2 = test_data.m_grid->m_line_strip.m_points + test_data.m_index_data[n + 2];
957e5c31af7Sopenharmony_ci		AdjacencyGridPoint* pointN3 = test_data.m_grid->m_line_strip.m_points + test_data.m_index_data[n + 3];
958e5c31af7Sopenharmony_ci
959e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = pointN0->x;
960e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
961e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = pointN0->y;
962e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
963e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = 0;
964e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
965e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = 1;
966e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
967e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = pointN3->x;
968e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
969e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = pointN3->y;
970e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
971e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = 0;
972e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
973e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = 1;
974e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
975e5c31af7Sopenharmony_ci
976e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = pointN1->x;
977e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
978e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = pointN1->y;
979e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
980e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = 0;
981e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
982e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = 1;
983e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
984e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = pointN2->x;
985e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
986e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = pointN2->y;
987e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
988e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = 0;
989e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
990e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = 1;
991e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
992e5c31af7Sopenharmony_ci	} /* for (all vertices apart from the three last ones) */
993e5c31af7Sopenharmony_ci}
994e5c31af7Sopenharmony_ci
995e5c31af7Sopenharmony_ci/** Set triangle vertex data used to be used by non-indiced draw calls.
996e5c31af7Sopenharmony_ci *
997e5c31af7Sopenharmony_ci * @param test_data AdjacencyTestData instance to be filled with relevant data.
998e5c31af7Sopenharmony_ci **/
999e5c31af7Sopenharmony_civoid GeometryShaderAdjacencyTests::setTrianglePointsNonindiced(AdjacencyTestData& test_data)
1000e5c31af7Sopenharmony_ci{
1001e5c31af7Sopenharmony_ci	float* travellerExpectedAdjacencyGeometryPtr = NULL;
1002e5c31af7Sopenharmony_ci	float* travellerExpectedGeometryPtr			 = NULL;
1003e5c31af7Sopenharmony_ci	float* travellerPtr							 = NULL;
1004e5c31af7Sopenharmony_ci
1005e5c31af7Sopenharmony_ci	/* Set buffer sizes */
1006e5c31af7Sopenharmony_ci	test_data.m_n_vertices		 = test_data.m_grid->m_n_triangles * m_n_vertices_per_triangle;
1007e5c31af7Sopenharmony_ci	test_data.m_geometry_bo_size = static_cast<glw::GLuint>(
1008e5c31af7Sopenharmony_ci		test_data.m_grid->m_n_triangles * m_n_vertices_per_triangle * m_n_components_output * sizeof(float));
1009e5c31af7Sopenharmony_ci	test_data.m_vertex_data_bo_size = static_cast<glw::GLuint>(test_data.m_n_vertices * m_n_components_input *
1010e5c31af7Sopenharmony_ci															   sizeof(float) * 2); /* include adjacency info */
1011e5c31af7Sopenharmony_ci
1012e5c31af7Sopenharmony_ci	/* Allocate memory for input and expected data */
1013e5c31af7Sopenharmony_ci	test_data.m_expected_adjacency_geometry = new float[test_data.m_geometry_bo_size / sizeof(float)];
1014e5c31af7Sopenharmony_ci	test_data.m_expected_geometry			= new float[test_data.m_geometry_bo_size / sizeof(float)];
1015e5c31af7Sopenharmony_ci	test_data.m_vertex_data					= new float[test_data.m_vertex_data_bo_size / sizeof(float)];
1016e5c31af7Sopenharmony_ci
1017e5c31af7Sopenharmony_ci	travellerExpectedAdjacencyGeometryPtr = test_data.m_expected_adjacency_geometry;
1018e5c31af7Sopenharmony_ci	travellerExpectedGeometryPtr		  = test_data.m_expected_geometry;
1019e5c31af7Sopenharmony_ci	travellerPtr						  = test_data.m_vertex_data;
1020e5c31af7Sopenharmony_ci
1021e5c31af7Sopenharmony_ci	/* Set input and expected values */
1022e5c31af7Sopenharmony_ci	for (unsigned int n = 0; n < test_data.m_grid->m_n_triangles; ++n)
1023e5c31af7Sopenharmony_ci	{
1024e5c31af7Sopenharmony_ci		AdjacencyGridTriangle* trianglePtr = test_data.m_grid->m_triangles + n;
1025e5c31af7Sopenharmony_ci
1026e5c31af7Sopenharmony_ci		*travellerPtr = trianglePtr->m_vertex_x->x;
1027e5c31af7Sopenharmony_ci		++travellerPtr;
1028e5c31af7Sopenharmony_ci		*travellerPtr = trianglePtr->m_vertex_x->y;
1029e5c31af7Sopenharmony_ci		++travellerPtr;
1030e5c31af7Sopenharmony_ci		*travellerPtr = trianglePtr->m_vertex_x_adjacent->x;
1031e5c31af7Sopenharmony_ci		++travellerPtr;
1032e5c31af7Sopenharmony_ci		*travellerPtr = trianglePtr->m_vertex_x_adjacent->y;
1033e5c31af7Sopenharmony_ci		++travellerPtr;
1034e5c31af7Sopenharmony_ci		*travellerPtr = trianglePtr->m_vertex_y->x;
1035e5c31af7Sopenharmony_ci		++travellerPtr;
1036e5c31af7Sopenharmony_ci		*travellerPtr = trianglePtr->m_vertex_y->y;
1037e5c31af7Sopenharmony_ci		++travellerPtr;
1038e5c31af7Sopenharmony_ci		*travellerPtr = trianglePtr->m_vertex_y_adjacent->x;
1039e5c31af7Sopenharmony_ci		++travellerPtr;
1040e5c31af7Sopenharmony_ci		*travellerPtr = trianglePtr->m_vertex_y_adjacent->y;
1041e5c31af7Sopenharmony_ci		++travellerPtr;
1042e5c31af7Sopenharmony_ci		*travellerPtr = trianglePtr->m_vertex_z->x;
1043e5c31af7Sopenharmony_ci		++travellerPtr;
1044e5c31af7Sopenharmony_ci		*travellerPtr = trianglePtr->m_vertex_z->y;
1045e5c31af7Sopenharmony_ci		++travellerPtr;
1046e5c31af7Sopenharmony_ci		*travellerPtr = trianglePtr->m_vertex_z_adjacent->x;
1047e5c31af7Sopenharmony_ci		++travellerPtr;
1048e5c31af7Sopenharmony_ci		*travellerPtr = trianglePtr->m_vertex_z_adjacent->y;
1049e5c31af7Sopenharmony_ci		++travellerPtr;
1050e5c31af7Sopenharmony_ci
1051e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = trianglePtr->m_vertex_x_adjacent->x;
1052e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
1053e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = trianglePtr->m_vertex_x_adjacent->y;
1054e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
1055e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = 0;
1056e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
1057e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = 1;
1058e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
1059e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = trianglePtr->m_vertex_y_adjacent->x;
1060e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
1061e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = trianglePtr->m_vertex_y_adjacent->y;
1062e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
1063e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = 0;
1064e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
1065e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = 1;
1066e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
1067e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = trianglePtr->m_vertex_z_adjacent->x;
1068e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
1069e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = trianglePtr->m_vertex_z_adjacent->y;
1070e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
1071e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = 0;
1072e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
1073e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = 1;
1074e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
1075e5c31af7Sopenharmony_ci
1076e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = trianglePtr->m_vertex_x->x;
1077e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
1078e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = trianglePtr->m_vertex_x->y;
1079e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
1080e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = 0;
1081e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
1082e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = 1;
1083e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
1084e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = trianglePtr->m_vertex_y->x;
1085e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
1086e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = trianglePtr->m_vertex_y->y;
1087e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
1088e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = 0;
1089e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
1090e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = 1;
1091e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
1092e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = trianglePtr->m_vertex_z->x;
1093e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
1094e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = trianglePtr->m_vertex_z->y;
1095e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
1096e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = 0;
1097e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
1098e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = 1;
1099e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
1100e5c31af7Sopenharmony_ci	} /* for (all triangles) */
1101e5c31af7Sopenharmony_ci}
1102e5c31af7Sopenharmony_ci
1103e5c31af7Sopenharmony_ci/** Set triangle vertex data used to be used by indiced draw calls.
1104e5c31af7Sopenharmony_ci *
1105e5c31af7Sopenharmony_ci * @param test_data AdjacencyTestDatainstance to be filled with relevant data.
1106e5c31af7Sopenharmony_ci **/
1107e5c31af7Sopenharmony_civoid GeometryShaderAdjacencyTests::setTrianglePointsIndiced(AdjacencyTestData& test_data)
1108e5c31af7Sopenharmony_ci{
1109e5c31af7Sopenharmony_ci	float*		  travellerExpectedAdjacencyGeometryPtr = 0;
1110e5c31af7Sopenharmony_ci	float*		  travellerExpectedGeometryPtr			= 0;
1111e5c31af7Sopenharmony_ci	unsigned int* travellerIndicesPtr					= 0;
1112e5c31af7Sopenharmony_ci	float*		  travellerPtr							= 0;
1113e5c31af7Sopenharmony_ci
1114e5c31af7Sopenharmony_ci	/* Set buffer sizes */
1115e5c31af7Sopenharmony_ci	test_data.m_n_vertices		 = test_data.m_grid->m_n_triangles * m_n_vertices_per_triangle;
1116e5c31af7Sopenharmony_ci	test_data.m_geometry_bo_size = static_cast<glw::GLuint>(
1117e5c31af7Sopenharmony_ci		test_data.m_grid->m_n_triangles * m_n_vertices_per_triangle * m_n_components_output * sizeof(float));
1118e5c31af7Sopenharmony_ci	test_data.m_vertex_data_bo_size =
1119e5c31af7Sopenharmony_ci		static_cast<glw::GLuint>(test_data.m_grid->m_n_points * m_n_components_input * sizeof(float));
1120e5c31af7Sopenharmony_ci	test_data.m_index_data_bo_size =
1121e5c31af7Sopenharmony_ci		static_cast<glw::GLuint>(test_data.m_n_vertices * sizeof(unsigned int) * 2); /* include adjacency info */
1122e5c31af7Sopenharmony_ci
1123e5c31af7Sopenharmony_ci	/* Allocate memory for input and expected data */
1124e5c31af7Sopenharmony_ci	test_data.m_expected_adjacency_geometry = new float[test_data.m_geometry_bo_size / sizeof(float)];
1125e5c31af7Sopenharmony_ci	test_data.m_expected_geometry			= new float[test_data.m_geometry_bo_size / sizeof(float)];
1126e5c31af7Sopenharmony_ci	test_data.m_index_data					= new unsigned int[test_data.m_index_data_bo_size / sizeof(unsigned int)];
1127e5c31af7Sopenharmony_ci	test_data.m_vertex_data					= new float[test_data.m_vertex_data_bo_size / sizeof(float)];
1128e5c31af7Sopenharmony_ci
1129e5c31af7Sopenharmony_ci	travellerExpectedAdjacencyGeometryPtr = test_data.m_expected_adjacency_geometry;
1130e5c31af7Sopenharmony_ci	travellerExpectedGeometryPtr		  = test_data.m_expected_geometry;
1131e5c31af7Sopenharmony_ci	travellerPtr						  = test_data.m_vertex_data;
1132e5c31af7Sopenharmony_ci	travellerIndicesPtr					  = test_data.m_index_data;
1133e5c31af7Sopenharmony_ci
1134e5c31af7Sopenharmony_ci	/* Set input and expected values */
1135e5c31af7Sopenharmony_ci	for (unsigned int n = 0; n < test_data.m_grid->m_n_points; ++n)
1136e5c31af7Sopenharmony_ci	{
1137e5c31af7Sopenharmony_ci		*travellerPtr = test_data.m_grid->m_points[n].x;
1138e5c31af7Sopenharmony_ci		++travellerPtr;
1139e5c31af7Sopenharmony_ci		*travellerPtr = test_data.m_grid->m_points[n].y;
1140e5c31af7Sopenharmony_ci		++travellerPtr;
1141e5c31af7Sopenharmony_ci	}
1142e5c31af7Sopenharmony_ci
1143e5c31af7Sopenharmony_ci	for (unsigned int n = 0; n < test_data.m_grid->m_n_triangles; ++n)
1144e5c31af7Sopenharmony_ci	{
1145e5c31af7Sopenharmony_ci		AdjacencyGridTriangle* trianglePtr = test_data.m_grid->m_triangles + (n + 1) % 2;
1146e5c31af7Sopenharmony_ci
1147e5c31af7Sopenharmony_ci		*travellerIndicesPtr = trianglePtr->m_vertex_x->index;
1148e5c31af7Sopenharmony_ci		++travellerIndicesPtr;
1149e5c31af7Sopenharmony_ci		*travellerIndicesPtr = trianglePtr->m_vertex_x_adjacent->index;
1150e5c31af7Sopenharmony_ci		++travellerIndicesPtr;
1151e5c31af7Sopenharmony_ci		*travellerIndicesPtr = trianglePtr->m_vertex_y->index;
1152e5c31af7Sopenharmony_ci		++travellerIndicesPtr;
1153e5c31af7Sopenharmony_ci		*travellerIndicesPtr = trianglePtr->m_vertex_y_adjacent->index;
1154e5c31af7Sopenharmony_ci		++travellerIndicesPtr;
1155e5c31af7Sopenharmony_ci		*travellerIndicesPtr = trianglePtr->m_vertex_z->index;
1156e5c31af7Sopenharmony_ci		++travellerIndicesPtr;
1157e5c31af7Sopenharmony_ci		*travellerIndicesPtr = trianglePtr->m_vertex_z_adjacent->index;
1158e5c31af7Sopenharmony_ci		++travellerIndicesPtr;
1159e5c31af7Sopenharmony_ci
1160e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = trianglePtr->m_vertex_x_adjacent->x;
1161e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
1162e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = trianglePtr->m_vertex_x_adjacent->y;
1163e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
1164e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = 0;
1165e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
1166e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = 1;
1167e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
1168e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = trianglePtr->m_vertex_y_adjacent->x;
1169e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
1170e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = trianglePtr->m_vertex_y_adjacent->y;
1171e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
1172e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = 0;
1173e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
1174e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = 1;
1175e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
1176e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = trianglePtr->m_vertex_z_adjacent->x;
1177e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
1178e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = trianglePtr->m_vertex_z_adjacent->y;
1179e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
1180e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = 0;
1181e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
1182e5c31af7Sopenharmony_ci		*travellerExpectedAdjacencyGeometryPtr = 1;
1183e5c31af7Sopenharmony_ci		++travellerExpectedAdjacencyGeometryPtr;
1184e5c31af7Sopenharmony_ci
1185e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = trianglePtr->m_vertex_x->x;
1186e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
1187e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = trianglePtr->m_vertex_x->y;
1188e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
1189e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = 0;
1190e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
1191e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = 1;
1192e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
1193e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = trianglePtr->m_vertex_y->x;
1194e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
1195e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = trianglePtr->m_vertex_y->y;
1196e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
1197e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = 0;
1198e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
1199e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = 1;
1200e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
1201e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = trianglePtr->m_vertex_z->x;
1202e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
1203e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = trianglePtr->m_vertex_z->y;
1204e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
1205e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = 0;
1206e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
1207e5c31af7Sopenharmony_ci		*travellerExpectedGeometryPtr = 1;
1208e5c31af7Sopenharmony_ci		++travellerExpectedGeometryPtr;
1209e5c31af7Sopenharmony_ci	} /* For (all triangles) */
1210e5c31af7Sopenharmony_ci}
1211e5c31af7Sopenharmony_ci
1212e5c31af7Sopenharmony_ci/** Set triangle strip vertex data used to be used by non-indiced draw calls.
1213e5c31af7Sopenharmony_ci *
1214e5c31af7Sopenharmony_ci * @param test_data AdjacencyTestData instance to be filled with relevant data.
1215e5c31af7Sopenharmony_ci **/
1216e5c31af7Sopenharmony_civoid GeometryShaderAdjacencyTests::setTriangleStripPointsNonindiced(AdjacencyTestData& test_data)
1217e5c31af7Sopenharmony_ci{
1218e5c31af7Sopenharmony_ci	/* Generate ordered vertex GL_TRIANGLE_STRIP_ADJACENCY_EXT data for actual test.
1219e5c31af7Sopenharmony_ci	 *
1220e5c31af7Sopenharmony_ci	 * "In triangle strips with adjacency, n triangles are drawn where there are
1221e5c31af7Sopenharmony_ci	 *  2 * (n+2) + k vertices passed. k is either 0 or 1; if k is 1, the final
1222e5c31af7Sopenharmony_ci	 *  vertex is ignored. "
1223e5c31af7Sopenharmony_ci	 *
1224e5c31af7Sopenharmony_ci	 * implies: for k input vertices, floor((n - 4) / 2) triangles will be drawn.
1225e5c31af7Sopenharmony_ci	 */
1226e5c31af7Sopenharmony_ci	unsigned int nTriangles = (test_data.m_grid->m_triangle_strip.m_n_points - 4) / 2;
1227e5c31af7Sopenharmony_ci
1228e5c31af7Sopenharmony_ci	float* travellerExpectedAdjacencyGeometryPtr = 0;
1229e5c31af7Sopenharmony_ci	float* travellerExpectedGeometryPtr			 = 0;
1230e5c31af7Sopenharmony_ci	float* travellerPtr							 = 0;
1231e5c31af7Sopenharmony_ci
1232e5c31af7Sopenharmony_ci	/* Set buffer sizes */
1233e5c31af7Sopenharmony_ci	test_data.m_n_vertices = test_data.m_grid->m_triangle_strip.m_n_points;
1234e5c31af7Sopenharmony_ci	test_data.m_geometry_bo_size =
1235e5c31af7Sopenharmony_ci		static_cast<glw::GLuint>(nTriangles * m_n_components_output * 3 /* adjacent vertices */ * sizeof(float));
1236e5c31af7Sopenharmony_ci	test_data.m_vertex_data_bo_size =
1237e5c31af7Sopenharmony_ci		static_cast<glw::GLuint>(test_data.m_n_vertices * m_n_components_input * sizeof(float));
1238e5c31af7Sopenharmony_ci
1239e5c31af7Sopenharmony_ci	/* Allocate memory for input and expected data */
1240e5c31af7Sopenharmony_ci	test_data.m_expected_adjacency_geometry           = new float[test_data.m_geometry_bo_size / sizeof(float)];
1241e5c31af7Sopenharmony_ci	test_data.m_expected_geometry			          = new float[test_data.m_geometry_bo_size / sizeof(float)];
1242e5c31af7Sopenharmony_ci	test_data.m_alternate_expected_adjacency_geometry = new float[test_data.m_geometry_bo_size / sizeof(float)];
1243e5c31af7Sopenharmony_ci	test_data.m_alternate_expected_geometry			  = new float[test_data.m_geometry_bo_size / sizeof(float)];
1244e5c31af7Sopenharmony_ci	test_data.m_vertex_data					          = new float[test_data.m_vertex_data_bo_size / sizeof(float)];
1245e5c31af7Sopenharmony_ci
1246e5c31af7Sopenharmony_ci	travellerPtr						  = test_data.m_vertex_data;
1247e5c31af7Sopenharmony_ci
1248e5c31af7Sopenharmony_ci	/* Set input and expected values */
1249e5c31af7Sopenharmony_ci	for (unsigned int n = 0; n < test_data.m_n_vertices; ++n)
1250e5c31af7Sopenharmony_ci	{
1251e5c31af7Sopenharmony_ci		*travellerPtr = test_data.m_grid->m_triangle_strip.m_points[n].x;
1252e5c31af7Sopenharmony_ci		++travellerPtr;
1253e5c31af7Sopenharmony_ci		*travellerPtr = test_data.m_grid->m_triangle_strip.m_points[n].y;
1254e5c31af7Sopenharmony_ci		++travellerPtr;
1255e5c31af7Sopenharmony_ci	}
1256e5c31af7Sopenharmony_ci
1257e5c31af7Sopenharmony_ci	for (unsigned int j = 0; j < 2; ++j)
1258e5c31af7Sopenharmony_ci	{
1259e5c31af7Sopenharmony_ci		if (j == 0)
1260e5c31af7Sopenharmony_ci		{
1261e5c31af7Sopenharmony_ci			travellerExpectedAdjacencyGeometryPtr = test_data.m_expected_adjacency_geometry;
1262e5c31af7Sopenharmony_ci			travellerExpectedGeometryPtr		  = test_data.m_expected_geometry;
1263e5c31af7Sopenharmony_ci		}
1264e5c31af7Sopenharmony_ci		else
1265e5c31af7Sopenharmony_ci		{
1266e5c31af7Sopenharmony_ci			travellerExpectedAdjacencyGeometryPtr = test_data.m_alternate_expected_adjacency_geometry;
1267e5c31af7Sopenharmony_ci			travellerExpectedGeometryPtr		  = test_data.m_alternate_expected_geometry;
1268e5c31af7Sopenharmony_ci		}
1269e5c31af7Sopenharmony_ci		for (unsigned int n = 0; n < nTriangles; ++n)
1270e5c31af7Sopenharmony_ci		{
1271e5c31af7Sopenharmony_ci			/* Derived from per table 2.X1 from the spec */
1272e5c31af7Sopenharmony_ci			int vertexIndex[3]				= { -1, -1, -1 };
1273e5c31af7Sopenharmony_ci			int adjVertexIndex[3]			= { -1, -1, -1 };
1274e5c31af7Sopenharmony_ci
1275e5c31af7Sopenharmony_ci			if (n == 0)
1276e5c31af7Sopenharmony_ci			{
1277e5c31af7Sopenharmony_ci				/* first (i==0) */
1278e5c31af7Sopenharmony_ci				adjVertexIndex[0] = 2;
1279e5c31af7Sopenharmony_ci				adjVertexIndex[1] = 7;
1280e5c31af7Sopenharmony_ci				adjVertexIndex[2] = 4;
1281e5c31af7Sopenharmony_ci				vertexIndex[0]	= 1;
1282e5c31af7Sopenharmony_ci				vertexIndex[1]	= 3;
1283e5c31af7Sopenharmony_ci				vertexIndex[2]	= 5;
1284e5c31af7Sopenharmony_ci			}
1285e5c31af7Sopenharmony_ci			else if (n == nTriangles - 1)
1286e5c31af7Sopenharmony_ci			{
1287e5c31af7Sopenharmony_ci				if (n % 2 == 0)
1288e5c31af7Sopenharmony_ci				{
1289e5c31af7Sopenharmony_ci					/* last (i==n-1, i even) */
1290e5c31af7Sopenharmony_ci					adjVertexIndex[0] = 2 * n - 1;
1291e5c31af7Sopenharmony_ci					adjVertexIndex[1] = 2 * n + 6;
1292e5c31af7Sopenharmony_ci					adjVertexIndex[2] = 2 * n + 4;
1293e5c31af7Sopenharmony_ci					vertexIndex[0]	= 2 * n + 1;
1294e5c31af7Sopenharmony_ci					vertexIndex[1]	= 2 * n + 3;
1295e5c31af7Sopenharmony_ci					vertexIndex[2]	= 2 * n + 5;
1296e5c31af7Sopenharmony_ci				}
1297e5c31af7Sopenharmony_ci				else
1298e5c31af7Sopenharmony_ci				{
1299e5c31af7Sopenharmony_ci					/* last (i==n-1, i odd) */
1300e5c31af7Sopenharmony_ci					if (j == 0)
1301e5c31af7Sopenharmony_ci					{
1302e5c31af7Sopenharmony_ci						adjVertexIndex[0] = 2 * n - 1;
1303e5c31af7Sopenharmony_ci						adjVertexIndex[1] = 2 * n + 4;
1304e5c31af7Sopenharmony_ci						adjVertexIndex[2] = 2 * n + 6;
1305e5c31af7Sopenharmony_ci						vertexIndex[0]	  = 2 * n + 3;
1306e5c31af7Sopenharmony_ci						vertexIndex[1]	  = 2 * n + 1;
1307e5c31af7Sopenharmony_ci						vertexIndex[2]	  = 2 * n + 5;
1308e5c31af7Sopenharmony_ci					}
1309e5c31af7Sopenharmony_ci					else
1310e5c31af7Sopenharmony_ci					{
1311e5c31af7Sopenharmony_ci						adjVertexIndex[0] = 2 * n + 4;
1312e5c31af7Sopenharmony_ci						adjVertexIndex[1] = 2 * n + 6;
1313e5c31af7Sopenharmony_ci						adjVertexIndex[2] = 2 * n - 1;
1314e5c31af7Sopenharmony_ci						vertexIndex[0]	  = 2 * n + 1;
1315e5c31af7Sopenharmony_ci						vertexIndex[1]	  = 2 * n + 5;
1316e5c31af7Sopenharmony_ci						vertexIndex[2]	  = 2 * n + 3;
1317e5c31af7Sopenharmony_ci					}
1318e5c31af7Sopenharmony_ci				}
1319e5c31af7Sopenharmony_ci			}
1320e5c31af7Sopenharmony_ci			else
1321e5c31af7Sopenharmony_ci			{
1322e5c31af7Sopenharmony_ci				if (n % 2 == 0)
1323e5c31af7Sopenharmony_ci				{
1324e5c31af7Sopenharmony_ci					/* middle (i even) */
1325e5c31af7Sopenharmony_ci					adjVertexIndex[0] = 2 * n - 1;
1326e5c31af7Sopenharmony_ci					adjVertexIndex[1] = 2 * n + 7;
1327e5c31af7Sopenharmony_ci					adjVertexIndex[2] = 2 * n + 4;
1328e5c31af7Sopenharmony_ci					vertexIndex[0]	= 2 * n + 1;
1329e5c31af7Sopenharmony_ci					vertexIndex[1]	= 2 * n + 3;
1330e5c31af7Sopenharmony_ci					vertexIndex[2]	= 2 * n + 5;
1331e5c31af7Sopenharmony_ci				}
1332e5c31af7Sopenharmony_ci				else
1333e5c31af7Sopenharmony_ci				{
1334e5c31af7Sopenharmony_ci					/* middle (i odd) */
1335e5c31af7Sopenharmony_ci					if (j == 0)
1336e5c31af7Sopenharmony_ci					{
1337e5c31af7Sopenharmony_ci
1338e5c31af7Sopenharmony_ci						adjVertexIndex[0] = 2 * n - 1;
1339e5c31af7Sopenharmony_ci						adjVertexIndex[1] = 2 * n + 4;
1340e5c31af7Sopenharmony_ci						adjVertexIndex[2] = 2 * n + 7;
1341e5c31af7Sopenharmony_ci						vertexIndex[0]	  = 2 * n + 3;
1342e5c31af7Sopenharmony_ci						vertexIndex[1]	  = 2 * n + 1;
1343e5c31af7Sopenharmony_ci						vertexIndex[2]	  = 2 * n + 5;
1344e5c31af7Sopenharmony_ci					}
1345e5c31af7Sopenharmony_ci					else
1346e5c31af7Sopenharmony_ci					{
1347e5c31af7Sopenharmony_ci						adjVertexIndex[0] = 2 * n + 4;
1348e5c31af7Sopenharmony_ci						adjVertexIndex[1] = 2 * n + 7;
1349e5c31af7Sopenharmony_ci						adjVertexIndex[2] = 2 * n - 1;
1350e5c31af7Sopenharmony_ci						vertexIndex[0]    = 2 * n + 1;
1351e5c31af7Sopenharmony_ci						vertexIndex[1]    = 2 * n + 5;
1352e5c31af7Sopenharmony_ci						vertexIndex[2]    = 2 * n + 3;
1353e5c31af7Sopenharmony_ci					}
1354e5c31af7Sopenharmony_ci				}
1355e5c31af7Sopenharmony_ci			}
1356e5c31af7Sopenharmony_ci
1357e5c31af7Sopenharmony_ci			/* Spec assumes vertices are indexed from 1 */
1358e5c31af7Sopenharmony_ci			vertexIndex[0]--;
1359e5c31af7Sopenharmony_ci			vertexIndex[1]--;
1360e5c31af7Sopenharmony_ci			vertexIndex[2]--;
1361e5c31af7Sopenharmony_ci			adjVertexIndex[0]--;
1362e5c31af7Sopenharmony_ci			adjVertexIndex[1]--;
1363e5c31af7Sopenharmony_ci			adjVertexIndex[2]--;
1364e5c31af7Sopenharmony_ci
1365e5c31af7Sopenharmony_ci			*travellerExpectedAdjacencyGeometryPtr = test_data.m_grid->m_triangle_strip.m_points[adjVertexIndex[0]].x;
1366e5c31af7Sopenharmony_ci			++travellerExpectedAdjacencyGeometryPtr;
1367e5c31af7Sopenharmony_ci			*travellerExpectedAdjacencyGeometryPtr = test_data.m_grid->m_triangle_strip.m_points[adjVertexIndex[0]].y;
1368e5c31af7Sopenharmony_ci			++travellerExpectedAdjacencyGeometryPtr;
1369e5c31af7Sopenharmony_ci			*travellerExpectedAdjacencyGeometryPtr = 0;
1370e5c31af7Sopenharmony_ci			++travellerExpectedAdjacencyGeometryPtr;
1371e5c31af7Sopenharmony_ci			*travellerExpectedAdjacencyGeometryPtr = 1;
1372e5c31af7Sopenharmony_ci			++travellerExpectedAdjacencyGeometryPtr;
1373e5c31af7Sopenharmony_ci			*travellerExpectedAdjacencyGeometryPtr = test_data.m_grid->m_triangle_strip.m_points[adjVertexIndex[1]].x;
1374e5c31af7Sopenharmony_ci			++travellerExpectedAdjacencyGeometryPtr;
1375e5c31af7Sopenharmony_ci			*travellerExpectedAdjacencyGeometryPtr = test_data.m_grid->m_triangle_strip.m_points[adjVertexIndex[1]].y;
1376e5c31af7Sopenharmony_ci			++travellerExpectedAdjacencyGeometryPtr;
1377e5c31af7Sopenharmony_ci			*travellerExpectedAdjacencyGeometryPtr = 0;
1378e5c31af7Sopenharmony_ci			++travellerExpectedAdjacencyGeometryPtr;
1379e5c31af7Sopenharmony_ci			*travellerExpectedAdjacencyGeometryPtr = 1;
1380e5c31af7Sopenharmony_ci			++travellerExpectedAdjacencyGeometryPtr;
1381e5c31af7Sopenharmony_ci			*travellerExpectedAdjacencyGeometryPtr = test_data.m_grid->m_triangle_strip.m_points[adjVertexIndex[2]].x;
1382e5c31af7Sopenharmony_ci			++travellerExpectedAdjacencyGeometryPtr;
1383e5c31af7Sopenharmony_ci			*travellerExpectedAdjacencyGeometryPtr = test_data.m_grid->m_triangle_strip.m_points[adjVertexIndex[2]].y;
1384e5c31af7Sopenharmony_ci			++travellerExpectedAdjacencyGeometryPtr;
1385e5c31af7Sopenharmony_ci			*travellerExpectedAdjacencyGeometryPtr = 0;
1386e5c31af7Sopenharmony_ci			++travellerExpectedAdjacencyGeometryPtr;
1387e5c31af7Sopenharmony_ci			*travellerExpectedAdjacencyGeometryPtr = 1;
1388e5c31af7Sopenharmony_ci			++travellerExpectedAdjacencyGeometryPtr;
1389e5c31af7Sopenharmony_ci
1390e5c31af7Sopenharmony_ci			*travellerExpectedGeometryPtr = test_data.m_grid->m_triangle_strip.m_points[vertexIndex[0]].x;
1391e5c31af7Sopenharmony_ci			++travellerExpectedGeometryPtr;
1392e5c31af7Sopenharmony_ci			*travellerExpectedGeometryPtr = test_data.m_grid->m_triangle_strip.m_points[vertexIndex[0]].y;
1393e5c31af7Sopenharmony_ci			++travellerExpectedGeometryPtr;
1394e5c31af7Sopenharmony_ci			*travellerExpectedGeometryPtr = 0;
1395e5c31af7Sopenharmony_ci			++travellerExpectedGeometryPtr;
1396e5c31af7Sopenharmony_ci			*travellerExpectedGeometryPtr = 1;
1397e5c31af7Sopenharmony_ci			++travellerExpectedGeometryPtr;
1398e5c31af7Sopenharmony_ci			*travellerExpectedGeometryPtr = test_data.m_grid->m_triangle_strip.m_points[vertexIndex[1]].x;
1399e5c31af7Sopenharmony_ci			++travellerExpectedGeometryPtr;
1400e5c31af7Sopenharmony_ci			*travellerExpectedGeometryPtr = test_data.m_grid->m_triangle_strip.m_points[vertexIndex[1]].y;
1401e5c31af7Sopenharmony_ci			++travellerExpectedGeometryPtr;
1402e5c31af7Sopenharmony_ci			*travellerExpectedGeometryPtr = 0;
1403e5c31af7Sopenharmony_ci			++travellerExpectedGeometryPtr;
1404e5c31af7Sopenharmony_ci			*travellerExpectedGeometryPtr = 1;
1405e5c31af7Sopenharmony_ci			++travellerExpectedGeometryPtr;
1406e5c31af7Sopenharmony_ci			*travellerExpectedGeometryPtr = test_data.m_grid->m_triangle_strip.m_points[vertexIndex[2]].x;
1407e5c31af7Sopenharmony_ci			++travellerExpectedGeometryPtr;
1408e5c31af7Sopenharmony_ci			*travellerExpectedGeometryPtr = test_data.m_grid->m_triangle_strip.m_points[vertexIndex[2]].y;
1409e5c31af7Sopenharmony_ci			++travellerExpectedGeometryPtr;
1410e5c31af7Sopenharmony_ci			*travellerExpectedGeometryPtr = 0;
1411e5c31af7Sopenharmony_ci			++travellerExpectedGeometryPtr;
1412e5c31af7Sopenharmony_ci			*travellerExpectedGeometryPtr = 1;
1413e5c31af7Sopenharmony_ci			++travellerExpectedGeometryPtr;
1414e5c31af7Sopenharmony_ci		} /* for (all triangles) */
1415e5c31af7Sopenharmony_ci	}
1416e5c31af7Sopenharmony_ci}
1417e5c31af7Sopenharmony_ci
1418e5c31af7Sopenharmony_ci/** Set triangle strip vertex data used to be used by indiced draw calls.
1419e5c31af7Sopenharmony_ci *
1420e5c31af7Sopenharmony_ci * @param test_data AdjacencyTestData instance to be filled with relevant data.
1421e5c31af7Sopenharmony_ci **/
1422e5c31af7Sopenharmony_civoid GeometryShaderAdjacencyTests::setTriangleStripPointsIndiced(AdjacencyTestData& test_data)
1423e5c31af7Sopenharmony_ci{
1424e5c31af7Sopenharmony_ci	unsigned int nTriangles = (test_data.m_grid->m_triangle_strip.m_n_points - 4) / 2;
1425e5c31af7Sopenharmony_ci
1426e5c31af7Sopenharmony_ci	float*		  travellerExpectedAdjacencyGeometryPtr = 0;
1427e5c31af7Sopenharmony_ci	float*		  travellerExpectedGeometryPtr			= 0;
1428e5c31af7Sopenharmony_ci	unsigned int* travellerIndicesPtr					= 0;
1429e5c31af7Sopenharmony_ci	float*		  travellerPtr							= 0;
1430e5c31af7Sopenharmony_ci
1431e5c31af7Sopenharmony_ci	/* Set buffer sizes */
1432e5c31af7Sopenharmony_ci	test_data.m_n_vertices = test_data.m_grid->m_triangle_strip.m_n_points;
1433e5c31af7Sopenharmony_ci	test_data.m_geometry_bo_size =
1434e5c31af7Sopenharmony_ci		static_cast<glw::GLuint>(nTriangles * m_n_components_output * 3 /* adjacent vertices */ * sizeof(float));
1435e5c31af7Sopenharmony_ci	test_data.m_vertex_data_bo_size =
1436e5c31af7Sopenharmony_ci		static_cast<glw::GLuint>(test_data.m_n_vertices * m_n_components_input * sizeof(float));
1437e5c31af7Sopenharmony_ci	test_data.m_index_data_bo_size = static_cast<glw::GLuint>(test_data.m_n_vertices * sizeof(unsigned int));
1438e5c31af7Sopenharmony_ci
1439e5c31af7Sopenharmony_ci	/* Allocate memory for input and expected data */
1440e5c31af7Sopenharmony_ci	test_data.m_expected_adjacency_geometry           = new float[test_data.m_geometry_bo_size / sizeof(float)];
1441e5c31af7Sopenharmony_ci	test_data.m_expected_geometry			          = new float[test_data.m_geometry_bo_size / sizeof(float)];
1442e5c31af7Sopenharmony_ci	test_data.m_alternate_expected_adjacency_geometry = new float[test_data.m_geometry_bo_size / sizeof(float)];
1443e5c31af7Sopenharmony_ci	test_data.m_alternate_expected_geometry			  = new float[test_data.m_geometry_bo_size / sizeof(float)];
1444e5c31af7Sopenharmony_ci	test_data.m_index_data					          = new unsigned int[test_data.m_index_data_bo_size / sizeof(unsigned int)];
1445e5c31af7Sopenharmony_ci	test_data.m_vertex_data					          = new float[test_data.m_vertex_data_bo_size / sizeof(float)];
1446e5c31af7Sopenharmony_ci
1447e5c31af7Sopenharmony_ci	travellerIndicesPtr					  = test_data.m_index_data;
1448e5c31af7Sopenharmony_ci	travellerPtr						  = test_data.m_vertex_data;
1449e5c31af7Sopenharmony_ci
1450e5c31af7Sopenharmony_ci	/* Set input and expected values */
1451e5c31af7Sopenharmony_ci	for (unsigned int n = 0; n < test_data.m_n_vertices; ++n)
1452e5c31af7Sopenharmony_ci	{
1453e5c31af7Sopenharmony_ci		*travellerIndicesPtr = (test_data.m_n_vertices - 1) - n;
1454e5c31af7Sopenharmony_ci		++travellerIndicesPtr;
1455e5c31af7Sopenharmony_ci	}
1456e5c31af7Sopenharmony_ci
1457e5c31af7Sopenharmony_ci	for (unsigned int n = 0; n < test_data.m_n_vertices; ++n)
1458e5c31af7Sopenharmony_ci	{
1459e5c31af7Sopenharmony_ci		*travellerPtr = test_data.m_grid->m_triangle_strip.m_points[n].x;
1460e5c31af7Sopenharmony_ci		++travellerPtr;
1461e5c31af7Sopenharmony_ci		*travellerPtr = test_data.m_grid->m_triangle_strip.m_points[n].y;
1462e5c31af7Sopenharmony_ci		++travellerPtr;
1463e5c31af7Sopenharmony_ci	}
1464e5c31af7Sopenharmony_ci
1465e5c31af7Sopenharmony_ci	for (unsigned int j = 0; j < 2; ++j)
1466e5c31af7Sopenharmony_ci	{
1467e5c31af7Sopenharmony_ci		if (j == 0)
1468e5c31af7Sopenharmony_ci		{
1469e5c31af7Sopenharmony_ci			travellerExpectedAdjacencyGeometryPtr = test_data.m_expected_adjacency_geometry;
1470e5c31af7Sopenharmony_ci			travellerExpectedGeometryPtr		  = test_data.m_expected_geometry;
1471e5c31af7Sopenharmony_ci		}
1472e5c31af7Sopenharmony_ci		else
1473e5c31af7Sopenharmony_ci		{
1474e5c31af7Sopenharmony_ci			travellerExpectedAdjacencyGeometryPtr = test_data.m_alternate_expected_adjacency_geometry;
1475e5c31af7Sopenharmony_ci			travellerExpectedGeometryPtr		  = test_data.m_alternate_expected_geometry;
1476e5c31af7Sopenharmony_ci		}
1477e5c31af7Sopenharmony_ci
1478e5c31af7Sopenharmony_ci		for (unsigned int n = 0; n < nTriangles; ++n)
1479e5c31af7Sopenharmony_ci		{
1480e5c31af7Sopenharmony_ci			/* Derived from per table 2.X1 from the spec */
1481e5c31af7Sopenharmony_ci			int vertexIndex[3]	= { -1, -1, -1 };
1482e5c31af7Sopenharmony_ci			int adjVertexIndex[3] = { -1, -1, -1 };
1483e5c31af7Sopenharmony_ci
1484e5c31af7Sopenharmony_ci			if (n == 0)
1485e5c31af7Sopenharmony_ci			{
1486e5c31af7Sopenharmony_ci				/* first (i==0) */
1487e5c31af7Sopenharmony_ci				adjVertexIndex[0] = 2;
1488e5c31af7Sopenharmony_ci				adjVertexIndex[1] = 7;
1489e5c31af7Sopenharmony_ci				adjVertexIndex[2] = 4;
1490e5c31af7Sopenharmony_ci				vertexIndex[0]	= 1;
1491e5c31af7Sopenharmony_ci				vertexIndex[1]	= 3;
1492e5c31af7Sopenharmony_ci				vertexIndex[2]	= 5;
1493e5c31af7Sopenharmony_ci			}
1494e5c31af7Sopenharmony_ci			else if (n == nTriangles - 1)
1495e5c31af7Sopenharmony_ci			{
1496e5c31af7Sopenharmony_ci				if (n % 2 == 0)
1497e5c31af7Sopenharmony_ci				{
1498e5c31af7Sopenharmony_ci					/* last (i==n-1, i even) */
1499e5c31af7Sopenharmony_ci					adjVertexIndex[0] = 2 * n - 1;
1500e5c31af7Sopenharmony_ci					adjVertexIndex[1] = 2 * n + 6;
1501e5c31af7Sopenharmony_ci					adjVertexIndex[2] = 2 * n + 4;
1502e5c31af7Sopenharmony_ci					vertexIndex[0]	= 2 * n + 1;
1503e5c31af7Sopenharmony_ci					vertexIndex[1]	= 2 * n + 3;
1504e5c31af7Sopenharmony_ci					vertexIndex[2]	= 2 * n + 5;
1505e5c31af7Sopenharmony_ci				}
1506e5c31af7Sopenharmony_ci				else
1507e5c31af7Sopenharmony_ci				{
1508e5c31af7Sopenharmony_ci					/* last (i==n-1, i odd) */
1509e5c31af7Sopenharmony_ci					if (j == 0)
1510e5c31af7Sopenharmony_ci					{
1511e5c31af7Sopenharmony_ci						adjVertexIndex[0] = 2 * n - 1;
1512e5c31af7Sopenharmony_ci						adjVertexIndex[1] = 2 * n + 4;
1513e5c31af7Sopenharmony_ci						adjVertexIndex[2] = 2 * n + 6;
1514e5c31af7Sopenharmony_ci						vertexIndex[0]	  = 2 * n + 3;
1515e5c31af7Sopenharmony_ci						vertexIndex[1]	  = 2 * n + 1;
1516e5c31af7Sopenharmony_ci						vertexIndex[2]	  = 2 * n + 5;
1517e5c31af7Sopenharmony_ci					}
1518e5c31af7Sopenharmony_ci					else
1519e5c31af7Sopenharmony_ci					{
1520e5c31af7Sopenharmony_ci						adjVertexIndex[0] = 2 * n + 4;
1521e5c31af7Sopenharmony_ci						adjVertexIndex[1] = 2 * n + 6;
1522e5c31af7Sopenharmony_ci						adjVertexIndex[2] = 2 * n - 1;
1523e5c31af7Sopenharmony_ci						vertexIndex[0]	  = 2 * n + 1;
1524e5c31af7Sopenharmony_ci						vertexIndex[1]	  = 2 * n + 5;
1525e5c31af7Sopenharmony_ci						vertexIndex[2]	  = 2 * n + 3;
1526e5c31af7Sopenharmony_ci					}
1527e5c31af7Sopenharmony_ci				}
1528e5c31af7Sopenharmony_ci			}
1529e5c31af7Sopenharmony_ci			else
1530e5c31af7Sopenharmony_ci			{
1531e5c31af7Sopenharmony_ci				if (n % 2 == 0)
1532e5c31af7Sopenharmony_ci				{
1533e5c31af7Sopenharmony_ci					/* middle (i even) */
1534e5c31af7Sopenharmony_ci					adjVertexIndex[0] = 2 * n - 1;
1535e5c31af7Sopenharmony_ci					adjVertexIndex[1] = 2 * n + 7;
1536e5c31af7Sopenharmony_ci					adjVertexIndex[2] = 2 * n + 4;
1537e5c31af7Sopenharmony_ci					vertexIndex[0]	= 2 * n + 1;
1538e5c31af7Sopenharmony_ci					vertexIndex[1]	= 2 * n + 3;
1539e5c31af7Sopenharmony_ci					vertexIndex[2]	= 2 * n + 5;
1540e5c31af7Sopenharmony_ci				}
1541e5c31af7Sopenharmony_ci				else
1542e5c31af7Sopenharmony_ci				{
1543e5c31af7Sopenharmony_ci					/* middle (i odd) */
1544e5c31af7Sopenharmony_ci					if (j == 0)
1545e5c31af7Sopenharmony_ci					{
1546e5c31af7Sopenharmony_ci						adjVertexIndex[0] = 2 * n - 1;
1547e5c31af7Sopenharmony_ci						adjVertexIndex[1] = 2 * n + 4;
1548e5c31af7Sopenharmony_ci						adjVertexIndex[2] = 2 * n + 7;
1549e5c31af7Sopenharmony_ci						vertexIndex[0]	  = 2 * n + 3;
1550e5c31af7Sopenharmony_ci						vertexIndex[1]	  = 2 * n + 1;
1551e5c31af7Sopenharmony_ci						vertexIndex[2]	  = 2 * n + 5;
1552e5c31af7Sopenharmony_ci					}
1553e5c31af7Sopenharmony_ci					else
1554e5c31af7Sopenharmony_ci					{
1555e5c31af7Sopenharmony_ci						adjVertexIndex[0] = 2 * n + 4;
1556e5c31af7Sopenharmony_ci						adjVertexIndex[1] = 2 * n + 7;
1557e5c31af7Sopenharmony_ci						adjVertexIndex[2] = 2 * n - 1;
1558e5c31af7Sopenharmony_ci						vertexIndex[0]	  = 2 * n + 1;
1559e5c31af7Sopenharmony_ci						vertexIndex[1]	  = 2 * n + 5;
1560e5c31af7Sopenharmony_ci						vertexIndex[2]	  = 2 * n + 3;
1561e5c31af7Sopenharmony_ci					}
1562e5c31af7Sopenharmony_ci				}
1563e5c31af7Sopenharmony_ci			}
1564e5c31af7Sopenharmony_ci
1565e5c31af7Sopenharmony_ci			/* Spec assumes vertices are indexed from 1 */
1566e5c31af7Sopenharmony_ci			vertexIndex[0]--;
1567e5c31af7Sopenharmony_ci			vertexIndex[1]--;
1568e5c31af7Sopenharmony_ci			vertexIndex[2]--;
1569e5c31af7Sopenharmony_ci			adjVertexIndex[0]--;
1570e5c31af7Sopenharmony_ci			adjVertexIndex[1]--;
1571e5c31af7Sopenharmony_ci			adjVertexIndex[2]--;
1572e5c31af7Sopenharmony_ci
1573e5c31af7Sopenharmony_ci			*travellerExpectedAdjacencyGeometryPtr =
1574e5c31af7Sopenharmony_ci				test_data.m_grid->m_triangle_strip.m_points[test_data.m_index_data[adjVertexIndex[0]]].x;
1575e5c31af7Sopenharmony_ci			++travellerExpectedAdjacencyGeometryPtr;
1576e5c31af7Sopenharmony_ci			*travellerExpectedAdjacencyGeometryPtr =
1577e5c31af7Sopenharmony_ci				test_data.m_grid->m_triangle_strip.m_points[test_data.m_index_data[adjVertexIndex[0]]].y;
1578e5c31af7Sopenharmony_ci			++travellerExpectedAdjacencyGeometryPtr;
1579e5c31af7Sopenharmony_ci			*travellerExpectedAdjacencyGeometryPtr = 0;
1580e5c31af7Sopenharmony_ci			++travellerExpectedAdjacencyGeometryPtr;
1581e5c31af7Sopenharmony_ci			*travellerExpectedAdjacencyGeometryPtr = 1;
1582e5c31af7Sopenharmony_ci			++travellerExpectedAdjacencyGeometryPtr;
1583e5c31af7Sopenharmony_ci			*travellerExpectedAdjacencyGeometryPtr =
1584e5c31af7Sopenharmony_ci				test_data.m_grid->m_triangle_strip.m_points[test_data.m_index_data[adjVertexIndex[1]]].x;
1585e5c31af7Sopenharmony_ci			++travellerExpectedAdjacencyGeometryPtr;
1586e5c31af7Sopenharmony_ci			*travellerExpectedAdjacencyGeometryPtr =
1587e5c31af7Sopenharmony_ci				test_data.m_grid->m_triangle_strip.m_points[test_data.m_index_data[adjVertexIndex[1]]].y;
1588e5c31af7Sopenharmony_ci			++travellerExpectedAdjacencyGeometryPtr;
1589e5c31af7Sopenharmony_ci			*travellerExpectedAdjacencyGeometryPtr = 0;
1590e5c31af7Sopenharmony_ci			++travellerExpectedAdjacencyGeometryPtr;
1591e5c31af7Sopenharmony_ci			*travellerExpectedAdjacencyGeometryPtr = 1;
1592e5c31af7Sopenharmony_ci			++travellerExpectedAdjacencyGeometryPtr;
1593e5c31af7Sopenharmony_ci			*travellerExpectedAdjacencyGeometryPtr =
1594e5c31af7Sopenharmony_ci				test_data.m_grid->m_triangle_strip.m_points[test_data.m_index_data[adjVertexIndex[2]]].x;
1595e5c31af7Sopenharmony_ci			++travellerExpectedAdjacencyGeometryPtr;
1596e5c31af7Sopenharmony_ci			*travellerExpectedAdjacencyGeometryPtr =
1597e5c31af7Sopenharmony_ci				test_data.m_grid->m_triangle_strip.m_points[test_data.m_index_data[adjVertexIndex[2]]].y;
1598e5c31af7Sopenharmony_ci			++travellerExpectedAdjacencyGeometryPtr;
1599e5c31af7Sopenharmony_ci			*travellerExpectedAdjacencyGeometryPtr = 0;
1600e5c31af7Sopenharmony_ci			++travellerExpectedAdjacencyGeometryPtr;
1601e5c31af7Sopenharmony_ci			*travellerExpectedAdjacencyGeometryPtr = 1;
1602e5c31af7Sopenharmony_ci			++travellerExpectedAdjacencyGeometryPtr;
1603e5c31af7Sopenharmony_ci
1604e5c31af7Sopenharmony_ci			*travellerExpectedGeometryPtr =
1605e5c31af7Sopenharmony_ci				test_data.m_grid->m_triangle_strip.m_points[test_data.m_index_data[vertexIndex[0]]].x;
1606e5c31af7Sopenharmony_ci			++travellerExpectedGeometryPtr;
1607e5c31af7Sopenharmony_ci			*travellerExpectedGeometryPtr =
1608e5c31af7Sopenharmony_ci				test_data.m_grid->m_triangle_strip.m_points[test_data.m_index_data[vertexIndex[0]]].y;
1609e5c31af7Sopenharmony_ci			++travellerExpectedGeometryPtr;
1610e5c31af7Sopenharmony_ci			*travellerExpectedGeometryPtr = 0;
1611e5c31af7Sopenharmony_ci			++travellerExpectedGeometryPtr;
1612e5c31af7Sopenharmony_ci			*travellerExpectedGeometryPtr = 1;
1613e5c31af7Sopenharmony_ci			++travellerExpectedGeometryPtr;
1614e5c31af7Sopenharmony_ci			*travellerExpectedGeometryPtr =
1615e5c31af7Sopenharmony_ci				test_data.m_grid->m_triangle_strip.m_points[test_data.m_index_data[vertexIndex[1]]].x;
1616e5c31af7Sopenharmony_ci			++travellerExpectedGeometryPtr;
1617e5c31af7Sopenharmony_ci			*travellerExpectedGeometryPtr =
1618e5c31af7Sopenharmony_ci				test_data.m_grid->m_triangle_strip.m_points[test_data.m_index_data[vertexIndex[1]]].y;
1619e5c31af7Sopenharmony_ci			++travellerExpectedGeometryPtr;
1620e5c31af7Sopenharmony_ci			*travellerExpectedGeometryPtr = 0;
1621e5c31af7Sopenharmony_ci			++travellerExpectedGeometryPtr;
1622e5c31af7Sopenharmony_ci			*travellerExpectedGeometryPtr = 1;
1623e5c31af7Sopenharmony_ci			++travellerExpectedGeometryPtr;
1624e5c31af7Sopenharmony_ci			*travellerExpectedGeometryPtr =
1625e5c31af7Sopenharmony_ci				test_data.m_grid->m_triangle_strip.m_points[test_data.m_index_data[vertexIndex[2]]].x;
1626e5c31af7Sopenharmony_ci			++travellerExpectedGeometryPtr;
1627e5c31af7Sopenharmony_ci			*travellerExpectedGeometryPtr =
1628e5c31af7Sopenharmony_ci				test_data.m_grid->m_triangle_strip.m_points[test_data.m_index_data[vertexIndex[2]]].y;
1629e5c31af7Sopenharmony_ci			++travellerExpectedGeometryPtr;
1630e5c31af7Sopenharmony_ci			*travellerExpectedGeometryPtr = 0;
1631e5c31af7Sopenharmony_ci			++travellerExpectedGeometryPtr;
1632e5c31af7Sopenharmony_ci			*travellerExpectedGeometryPtr = 1;
1633e5c31af7Sopenharmony_ci			++travellerExpectedGeometryPtr;
1634e5c31af7Sopenharmony_ci		} /* for (all triangles) */
1635e5c31af7Sopenharmony_ci	}
1636e5c31af7Sopenharmony_ci}
1637e5c31af7Sopenharmony_ci}
1638