1#ifndef _ESEXTCGEOMETRYSHADERAPI_HPP
2#define _ESEXTCGEOMETRYSHADERAPI_HPP
3/*-------------------------------------------------------------------------
4 * OpenGL Conformance Test Suite
5 * -----------------------------
6 *
7 * Copyright (c) 2015-2016 The Khronos Group Inc.
8 *
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 *      http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 *
21 */ /*!
22 * \file
23 * \brief
24 */ /*-------------------------------------------------------------------*/
25
26#include "../esextcTestCaseBase.hpp"
27
28namespace glcts
29{
30/** Implementation of "Group 18", test 1 from CTS_EXT_geometry_shader. Description follows:
31 *
32 *  1. Make sure glCreateShaderProgramv() works correctly with geometry
33 *     shaders.
34 *
35 *     Category: API;
36 *
37 *     Consider two geometry shader implementations (consisting of at least
38 *     2 body parts): a compilable (A) and a non-compilable one (B). For (A),
39 *     vertex and fragment shader stage implementations as in test case 8.1
40 *     should be considered.
41 *
42 *     Call glCreateShaderProgramv() for both codebases:
43 *
44 *     - In both cases, a new program object should be created;
45 *     - For (A), GL_LINK_STATUS for the program object should be reported
46 *       as GL_TRUE; Using a pipeline object to which all three separable
47 *       program objects have been attached for each corresponding stage, the
48 *       test should draw a single point and check the results (as described in
49 *       test case 8.1)
50 *     - For (B), GL_LINK_STATUS for the program object should be reported as
51 *       GL_FALSE.
52 *     - No error should be reported.
53 *
54 **/
55class GeometryShaderCreateShaderProgramvTest : public TestCaseBase
56{
57public:
58	/* Public methods */
59	GeometryShaderCreateShaderProgramvTest(Context& context, const ExtParameters& extParams, const char* name,
60										   const char* description);
61
62	virtual ~GeometryShaderCreateShaderProgramvTest()
63	{
64	}
65
66	virtual void		  deinit();
67	virtual IterateResult iterate();
68
69private:
70	/* Private type definition */
71
72	/* Private methods */
73	void initFBO();
74	void initPipelineObject();
75
76	/* Private variables */
77	static const char* fs_code;
78	static const char* gs_code;
79	static const char* vs_code;
80
81	glw::GLuint m_fbo_id;
82	glw::GLuint m_fs_po_id;
83	glw::GLuint m_gs_po_id;
84	glw::GLuint m_pipeline_object_id;
85	glw::GLuint m_to_id;
86	glw::GLuint m_vao_id;
87	glw::GLuint m_vs_po_id;
88
89	static const unsigned int m_to_height;
90	static const unsigned int m_to_width;
91};
92
93/* Implementation of "Group 18", test 2 from CTS_EXT_geometry_shader. Description follows:
94 *
95 *  2. GL_GEOMETRY_SHADER_EXT is reported by glGetShaderiv() for geometry shaders.
96 *
97 *     Category: API.
98 *
99 *     Create a geometry shader object. Make sure glGetShaderiv() reports
100 *     GL_GEOMETRY_SHADER_EXT when passed GL_SHADER_TYPE pname and the shader's
101 *     id.
102 *
103 */
104class GeometryShaderGetShaderivTest : public TestCaseBase
105{
106public:
107	/* Public methods */
108	GeometryShaderGetShaderivTest(Context& context, const ExtParameters& extParams, const char* name,
109								  const char* description);
110
111	virtual ~GeometryShaderGetShaderivTest()
112	{
113	}
114
115	virtual void		  deinit();
116	virtual IterateResult iterate();
117
118private:
119	/* Private type definition */
120
121	/* Private methods */
122
123	/* Private variables */
124	glw::GLuint m_gs_id;
125};
126
127/* Implementation of "Group 18", test 3 from CTS_EXT_geometry_shader. Description follows:
128 *
129 *  3. GL_INVALID_OPERATION error is generated if geometry stage-specific
130 *     queries such as:
131 *
132 *     * GL_GEOMETRY_LINKED_VERTICES_OUT_EXT;
133 *     * GL_GEOMETRY_LINKED_INPUT_TYPE_EXT;
134 *     * GL_GEOMETRY_LINKED_OUTPUT_TYPE_EXT;
135 *     * GL_GEOMETRY_SHADER_INVOCATIONS_EXT;
136 *
137 *     are passed to glGetProgramiv() for a program object that was not linked
138 *     successfully.
139 *
140 *     Category: API;
141 *               Negative Test.
142 *
143 *     Create a program object.
144 *
145 *     Issue all of the above queries on the program object. The test fails if
146 *     any of these queries does not result in a GL_INVALID_OPERATION error.
147 *
148 */
149class GeometryShaderGetProgramivTest : public TestCaseBase
150{
151public:
152	/* Public methods */
153	GeometryShaderGetProgramivTest(Context& context, const ExtParameters& extParams, const char* name,
154								   const char* description);
155
156	virtual ~GeometryShaderGetProgramivTest()
157	{
158	}
159
160	virtual void		  deinit();
161	virtual IterateResult iterate();
162
163private:
164	/* Private type definition */
165
166	/* Private methods */
167
168	/* Private variables */
169	glw::GLuint m_po_id;
170};
171
172/* Implementation of "Group 18", test 4 from CTS_EXT_geometry_shader. Description follows:
173 *
174 *  4. GL_INVALID_OPERATION error is generated if geometry stage-specific
175 *     queries such as:
176 *
177 *     * GL_GEOMETRY_LINKED_VERTICES_OUT_EXT;
178 *     * GL_GEOMETRY_LINKED_INPUT_TYPE_EXT;
179 *     * GL_GEOMETRY_LINKED_OUTPUT_TYPE_EXT;
180 *     * GL_GEOMETRY_SHADER_INVOCATIONS_EXT;
181 *
182 *     are passed to glGetProgramiv() for a linked program object that does not
183 *     have a geometry shader attached.
184 *
185 *     Category: API;
186 *               Negative Test.
187 *
188 *     Create a program object and attach boilerplate fragment and vertex
189 *     shaders to it. The program object should link successfully.
190 *
191 *     Issue all of the above queries on the program object. The test fails if
192 *     any of these queries does not result in a GL_INVALID_OPERATION error.
193 *
194 */
195class GeometryShaderGetProgramiv2Test : public TestCaseBase
196{
197public:
198	/* Public methods */
199	GeometryShaderGetProgramiv2Test(Context& context, const ExtParameters& extParams, const char* name,
200									const char* description);
201
202	virtual ~GeometryShaderGetProgramiv2Test()
203	{
204	}
205
206	virtual void		  deinit();
207	virtual IterateResult iterate();
208
209private:
210	/* Private type definition */
211
212	/* Private methods */
213
214	/* Private variables */
215	glw::GLuint m_fs_id;
216	glw::GLuint m_po_id;
217	glw::GLuint m_vs_id;
218};
219
220/* Implementation of "Group 19", test 1 from CTS_EXT_geometry_shader. Description follows:
221 *
222 *  1. Program objects that either have been attached compilable fragment &
223 *     geometry & vertex shader objects attached and link successfully OR which
224 *     have been assigned successfully linked separate fragment & geometry &
225 *     shader object programs can be queried for geometry stage properties
226 *
227 *     Category: API;
228 *
229 *     The test should iterate through 3 different fragment + geometry + vertex
230 *     shader object configurations.
231 *     It should query the following geometry shader states and verify the
232 *     reported values:
233 *
234 *     1) GL_GEOMETRY_LINKED_VERTICES_OUT_EXT,
235 *     2) GL_GEOMETRY_LINKED_INPUT_TYPE_EXT,
236 *     3) GL_GEOMETRY_LINKED_OUTPUT_TYPE_EXT,
237 *     4) GL_GEOMETRY_SHADER_INVOCATIONS_EXT
238 *
239 *     For pipeline objects, an additional case should be checked: using
240 *     a separable program object with fragment & vertex shader stages defined
241 *     as a source for geometry shader stage should succeed but reported
242 *     geometry shader program object id (retrieved by calling
243 *     glGetProgramPipelineiv() with GL_GEOMETRY_SHADER_EXT pname) should return 0.
244 *
245 */
246class GeometryShaderGetProgramiv3Test : public TestCaseBase
247{
248public:
249	/* Public methods */
250	GeometryShaderGetProgramiv3Test(Context& context, const ExtParameters& extParams, const char* name,
251									const char* description);
252
253	virtual ~GeometryShaderGetProgramiv3Test()
254	{
255	}
256
257	virtual void		  deinit();
258	virtual IterateResult iterate();
259
260private:
261	/* Private type definition */
262	typedef struct _run
263	{
264		glw::GLenum input_primitive_type;
265		int			invocations;
266		int			max_vertices;
267		glw::GLenum output_primitive_type;
268
269		explicit _run(glw::GLenum in_input_primitive_type, int in_invocations, int in_max_vertices,
270					  glw::GLenum in_output_primitive_type)
271		{
272			input_primitive_type  = in_input_primitive_type;
273			invocations			  = in_invocations;
274			max_vertices		  = in_max_vertices;
275			output_primitive_type = in_output_primitive_type;
276		}
277	} _run;
278
279	/* Private methods */
280	bool buildShader(glw::GLuint so_id, const char* so_body);
281
282	bool buildShaderProgram(glw::GLuint* out_spo_id, glw::GLenum spo_bits, const char* spo_body);
283
284	void deinitPO();
285
286	void deinitSOs(bool release_all_SOs);
287
288	void deinitSPOs(bool release_all_SPOs);
289
290	std::string getLayoutQualifierForPrimitiveType(glw::GLenum primitive_type);
291
292	std::string getGSCode(const _run& run);
293
294	void initTestRuns();
295
296	/* Private variables */
297	glw::GLuint m_fs_id;
298	glw::GLuint m_fs_po_id;
299	glw::GLuint m_gs_id;
300	glw::GLuint m_gs_po_id;
301	glw::GLuint m_pipeline_object_id;
302	glw::GLuint m_po_id;
303	glw::GLuint m_vs_id;
304	glw::GLuint m_vs_po_id;
305
306	std::vector<_run> _runs;
307};
308
309/* Implementation of "Group 19", test 2 from CTS_EXT_geometry_shader. Description follows:
310 *
311 *  1. For an active pipeline object consisting of a geometry shader stage but
312 *     lacking a vertex shader stage, GL_INVALID_OPERATION error should be
313 *     generated if an application attempts to perform a draw call.
314 *
315 *     Category: API;
316 *               Negative Test;
317 *
318 *     Create a pipeline object.
319 *
320 *     Create boilerplate separate fragment and geometry shader program objects.
321 *     Configure the pipeline object to use them correspondingly for fragment
322 *     and geometry stages.
323 *
324 *     Generate and bind a vertex array object.
325 *
326 *     The test should now bind the pipeline object and do a glDrawArrays()
327 *     call.
328 *
329 *     Test succeeds if GL_INVALID_OPERATION error was generated.
330 *
331 */
332class GeometryShaderDrawCallWithFSAndGS : public TestCaseBase
333{
334public:
335	/* Public methods */
336	GeometryShaderDrawCallWithFSAndGS(Context& context, const ExtParameters& extParams, const char* name,
337									  const char* description);
338
339	virtual ~GeometryShaderDrawCallWithFSAndGS()
340	{
341	}
342
343	virtual void		  deinit();
344	virtual IterateResult iterate();
345
346private:
347	/* Private type definition */
348
349	/* Private methods */
350
351	/* Private variables */
352	glw::GLuint m_fs_po_id;
353	glw::GLuint m_gs_po_id;
354	glw::GLuint m_pipeline_object_id;
355	glw::GLuint m_vao_id;
356};
357
358/* Implementation of "Group 23", test 1 from CTS_EXT_geometry_shader. Description follows:
359 *
360 *  1. It should be possible to use as many image uniforms in a geometry shader
361 *     as reported for GL_MAX_GEOMETRY_IMAGE_UNIFORMS_EXT property.
362 *
363 *     Category: API;
364 *               Functional Test.
365 *
366 *     1.  Create a program object consisting of a fragment, geometry and vertex
367 *         shader:
368 *     1a. The shaders can have boilerplate implementation but should be
369 *         compatible with each other.
370 *     1b. Geometry shader should take points on input and output a maximum of
371 *         1 point.
372 *     1c. Geometry shader should define exactly as many image uniforms as
373 *         reported for the property.
374 *     1d. Geometry shader should load values from all bound images, sum them up,
375 *         and store the result in X component of output vertex.
376 *     2.  Configure transform feedback to capture gl_Position output from the
377 *         program.
378 *     3.  All shaders should compile successfully and the program object should
379 *         link without problems.
380 *     4.  Bind integer 2D texture objects of resolution 1x1 to all image units.
381 *         First texture used should use a value of 1, second texture should use
382 *         a value of 2, and so on.
383 *     5.  Generate, bind a vertex array object, do a single point draw call. The
384 *         test succeeds if the first component in the vector retrieved is equal
385 *         to sum(i=1..n)(i) = n(n+1)/2 where n =
386 *         GL_MAX_GEOMETRY_IMAGE_UNIFORMS_EXT property value.
387 *
388 */
389class GeometryShaderMaxImageUniformsTest : public TestCaseBase
390{
391public:
392	/* Public methods */
393	GeometryShaderMaxImageUniformsTest(Context& context, const ExtParameters& extParams, const char* name,
394									   const char* description);
395
396	virtual ~GeometryShaderMaxImageUniformsTest()
397	{
398	}
399
400	virtual void		  deinit();
401	virtual IterateResult iterate();
402
403private:
404	/* Private type definition */
405
406	/* Private methods */
407	std::string getGSCode();
408
409	/* Private variables */
410	glw::GLuint  m_fs_id;
411	glw::GLint   m_gl_max_geometry_image_uniforms_ext_value;
412	glw::GLuint  m_gs_id;
413	glw::GLuint  m_po_id;
414	glw::GLuint* m_texture_ids;
415	glw::GLuint  m_tfbo_id;
416	glw::GLuint  m_vao_id;
417	glw::GLuint  m_vs_id;
418};
419
420/* Implementation of "Group 23", test 2 from CTS_EXT_geometry_shader. Description follows:
421 *
422 *  2. It should be possible to use as many shader storage blocks in a geometry
423 *     shader as reported for GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT property.
424 *
425 *     Category: API;
426 *             Functional Test.0
427 *
428 *     1. Create a program object consisting of a fragment, geometry and vertex
429 *        shader:
430 *     1a. The shaders can have boilerplate implementation but should be
431 *         compatible with each other.
432 *     1b. Geometry shader should take points on input and output a maximum of
433 *         1 point.
434 *     1c. Geometry shader should define exactly as many shader storage blocks
435 *         as reported for the property, each using subsequent shader storage
436 *         buffer binding points. Each storage block should take a single int
437 *         value.
438 *     1d. Geometry shader should read values from all bound SSBOs, write
439 *         *incremented* values. It should also store a summed-up result (along
440 *         the lines of test case 23.1) calculated from values *prior* to
441 *         incrementation in X component of output vertex.
442 *     2. Configure transform feedback to capture gl_Position output from the
443 *        program.
444 *     3. All shaders should compile successfully and the program object should
445 *        link without problems.
446 *     4. Initialize a buffer object filled with subsequent int values (starting
447 *        from 1). Bind corresponding ranges (of size sizeof(int) ) to subsequent
448 *        SSBO binding points.
449 *     5. Generate, bind a vertex array object, do a single point draw call. The
450 *        test succeeds if the value retrieved is equal to
451 *        sum(i=1..n)(i) = n(n+1)/2 where n =
452 *        GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT property value AND if the
453 *        buffer object storing input data is now filled with increasing values,
454 *        assuming a delta of 1 and a start value of 2.
455 *
456 */
457class GeometryShaderMaxShaderStorageBlocksTest : public TestCaseBase
458{
459public:
460	/* Public methods */
461	GeometryShaderMaxShaderStorageBlocksTest(Context& context, const ExtParameters& extParams, const char* name,
462											 const char* description);
463
464	virtual ~GeometryShaderMaxShaderStorageBlocksTest()
465	{
466	}
467
468	virtual void		  deinit();
469	virtual IterateResult iterate();
470
471private:
472	/* Private type definition */
473
474	/* Private methods */
475	std::string getGSCode();
476
477	/* Private variables */
478	glw::GLuint m_fs_id;
479	glw::GLint  m_gl_max_geometry_shader_storage_blocks_ext_value;
480	glw::GLuint m_gs_id;
481	glw::GLuint m_po_id;
482	glw::GLuint m_ssbo_id;
483	glw::GLuint m_tfbo_id;
484	glw::GLuint m_vao_id;
485	glw::GLuint m_vs_id;
486};
487
488/* Implementation of "Group 23", test 3 from CTS_EXT_geometry_shader. Description follows:
489 *
490 *  3. Make sure writing up to GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT atomic
491 *     counters from within a geometry shader works correctly.
492 *
493 *     Category: API.
494 *
495 *     Create a program object. Define a boilerplate fragment shader object,
496 *     a vertex and a geometry shader.
497 *
498 *     The vertex shader should:
499 *
500 *     - pass gl_VertexID information to the geometry shader using an output
501 *       int variable called vertex_id.
502 *
503 *     The geometry shader should:
504 *
505 *     - define exactly GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT atomic counters.
506 *     - take points on input and output a maximum of 1 point;
507 *     - use only one invocation.
508 *     - the shader should increment all atomic counters, for which
509 *       (vertex_id % counter_id) == 0, where counter_id stands for "id" of
510 *       a shader atomic counter, assuming first shader atomic counter has an
511 *       "id" of 1.
512 *
513 *     A single buffer object should be used to back up the storage. It should
514 *     be filled with zeros on start-up.
515 *
516 *     The test should draw 128*GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT points. It then
517 *     should read the buffer object's contents and make sure the values read
518 *     are valid.
519 *
520 */
521class GeometryShaderMaxAtomicCountersTest : public TestCaseBase
522{
523public:
524	/* Public methods */
525	GeometryShaderMaxAtomicCountersTest(Context& context, const ExtParameters& extParams, const char* name,
526										const char* description);
527
528	virtual ~GeometryShaderMaxAtomicCountersTest()
529	{
530	}
531
532	virtual void		  deinit();
533	virtual IterateResult iterate();
534
535private:
536	/* Private type definition */
537
538	/* Private methods */
539	std::string getGSCode();
540
541	/* Private variables */
542	glw::GLuint m_acbo_id;
543	glw::GLuint m_fs_id;
544	glw::GLint  m_gl_max_geometry_atomic_counters_ext_value;
545	glw::GLuint m_gs_id;
546	glw::GLuint m_po_id;
547	glw::GLuint m_vao_id;
548	glw::GLuint m_vs_id;
549};
550
551/* Implementation of "Group 23", test 5 from CTS_EXT_geometry_shader. Description follows:
552 *
553 *  5. Make sure writing up to GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT atomic
554 *     counter buffers from within a geometry shader works correctly.
555 *
556 *     Category: API.
557 *
558 *     Create a program object. Define a boilerplate fragment shader object,
559 *     a vertex and a geometry shader.
560 *
561 *     The vertex shader should:
562 *
563 *     - pass gl_VertexID information to the geometry shader using an output
564 *     int variable called vertex_id.
565 *
566 *     The geometry shader should:
567 *
568 *     - define exactly GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT atomic
569 *       counters.
570 *     - take points on input and output a maximum of 1 point;
571 *     - use only one invocation.
572 *     - the shader should increment all atomic counter if
573 *       (vertex_id % counter_id) == 0, where counter_id stands for "id" of
574 *       a shader atomic counter, assuming first shader atomic counter has an
575 *       "id" of 1.
576 *
577 *     Each atomic counter should use a separate buffer object binding to back
578 *     up the storage. They should be filled with zeros on start-up.
579 *
580 *     The test should draw 128*GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT
581 *     points. It then should read the buffer objects' contents and make sure
582 *     the values read are valid.
583 *
584 */
585class GeometryShaderMaxAtomicCounterBuffersTest : public TestCaseBase
586{
587public:
588	/* Public methods */
589	GeometryShaderMaxAtomicCounterBuffersTest(Context& context, const ExtParameters& extParams, const char* name,
590											  const char* description);
591
592	virtual ~GeometryShaderMaxAtomicCounterBuffersTest()
593	{
594	}
595
596	virtual void		  deinit();
597	virtual IterateResult iterate();
598
599private:
600	/* Private type definition */
601
602	/* Private methods */
603	std::string getGSCode();
604
605	/* Private variables */
606	glw::GLuint* m_acbo_ids;
607	glw::GLuint  m_fs_id;
608	glw::GLint   m_gl_max_atomic_counter_buffer_bindings_value;
609	glw::GLint   m_gl_max_geometry_atomic_counter_buffers_ext_value;
610	glw::GLuint  m_gs_id;
611	glw::GLuint  m_po_id;
612	glw::GLuint  m_vao_id;
613	glw::GLuint  m_vs_id;
614};
615
616/* Implementation of "Group 24", test 2 from CTS_EXT_geometry_shader. Description follows:
617 *
618 *  2. Make sure that draw calls results in an error if the bound pipeline
619 *     program object has a configured geometry stage but has no active program
620 *     with an executable vertex shader.
621 *
622 *     Category: API;
623 *
624 *     Generate a pipeline object.
625 *
626 *     Create stand-alone fragment and geometry programs. Both of the programs
627 *     should be provided valid but boilerplate implementation. Use these
628 *     programs to define fragment and geometry stages for the pipeline object.
629 *
630 *     Generate and bind a vertex array object. Bind the pipeline object and
631 *     try to draw a single point. Test succeeds if GL_INVALID_OPERATION error
632 *     was generated.
633 *
634 */
635class GeometryShaderPiplineProgramObjectWithoutActiveVSProgramTest : public TestCaseBase
636{
637public:
638	/* Public methods */
639	GeometryShaderPiplineProgramObjectWithoutActiveVSProgramTest(Context& context, const ExtParameters& extParams,
640																 const char* name, const char* description);
641
642	virtual ~GeometryShaderPiplineProgramObjectWithoutActiveVSProgramTest()
643	{
644	}
645
646	virtual void		  deinit();
647	virtual IterateResult iterate();
648
649private:
650	/* Private type definition */
651
652	/* Private methods */
653
654	/* Private variables */
655	glw::GLuint m_fs_id;
656	glw::GLuint m_fs_po_id;
657	glw::GLuint m_gs_id;
658	glw::GLuint m_gs_po_id;
659	glw::GLuint m_ppo_id;
660	glw::GLuint m_vao_id;
661};
662
663/* Implementation of "Group 24", test 3 from CTS_EXT_geometry_shader. Description follows:
664 *
665 *  3. Verify that doing a draw call using a mode that is incompatible with
666 *     input type of geometry shader active in current pipeline results in
667 *     GL_INVALID_OPERATION error.
668 *
669 *     Category: API;
670 *               Negative Test.
671 *
672 *     Create 5 program objects and a fragment & vertex shader objects. These
673 *     shaders are free to use boilerplate code. Create 5 geometry shaders, each
674 *     using a different input primitive type allowed for geometry shaders.
675 *     Each program object should be assigned a set of fragment, geometry and
676 *     vertex shaders, assuming each program is set a different geometry shader.
677 *     Compile all shaders and link the program objects.
678 *
679 *     Generate a vertex array object and bind it.
680 *
681 *     For each valid draw call mode, iterate through all program objects. For
682 *     program objects that accept an input primitive geometry type deemed
683 *     incompatible for the draw call mode considered, try executing the draw
684 *     call. Test fails if any of these draw calls does not result in
685 *     a GL_INVALID_OPERATION.
686 *
687 *     Invalid primitive types for all available draw call modes:
688 *
689 *     * GL_LINE_LOOP draw call mode:
690 *     1) lines_adjacency;
691 *     2) points;
692 *     3) triangles;
693 *     4) triangles with adjacency;
694 *
695 *     * GL_LINE_STRIP draw call mode:
696 *     1) lines with adjacency;
697 *     2) points;
698 *     3) triangles;
699 *     4) triangles with adajcency;
700 *
701 *     * GL_LINE_STRIP_ADJACENCY_EXT draw call mode:
702 *     1) lines;
703 *     2) points;
704 *     3) triangles;
705 *     4) triangles with adjacency;
706 *
707 *     * GL_LINES draw call mode:
708 *     1) lines with adjacency;
709 *     2) points;
710 *     3) triangles;
711 *     4) triangles with adjacency;
712 *
713 *     * GL_LINES_ADJACENCY_EXT draw call mode:
714 *     1) lines;
715 *     2) points;
716 *     3) triangles;
717 *     4) triangles with adjacency;
718 *
719 *     * GL_POINTS draw call mode:
720 *     1) lines;
721 *     2) lines with adjacency;
722 *     3) triangles;
723 *     4) triangles with adjacency;
724 *
725 *     * GL_TRIANGLE_FAN draw call mode:
726 *     1) lines;
727 *     2) lines with adjacency;
728 *     3) points;
729 *     4) triangles with adjacency;
730 *
731 *     * GL_TRIANGLE_STRIP draw call mode:
732 *     1) lines;
733 *     2) lines with adjacency;
734 *     3) points;
735 *     4) triangles with adjacency;
736 *
737 *     * GL_TRIANGLES draw call mode:
738 *     1) lines;
739 *     2) lines with adjacency;
740 *     3) points;
741 *     4) triangles with adjacency;
742 *
743 *     * GL_TRIANGLES_ADJACENCY_EXT draw call mode:
744 *     1) lines;
745 *     2) lines with adjacency;
746 *     3) points;
747 *     4) triangles;
748 *
749 *     * GL_TRIANGLE_STRIP_ADJACENCY_EXT draw call mdoe:
750 *     1) lines;
751 *     2) lines with adjacency;
752 *     3) points;
753 *     4) triangles;
754 *
755 */
756class GeometryShaderIncompatibleDrawCallModeTest : public TestCaseBase
757{
758public:
759	/* Public methods */
760	GeometryShaderIncompatibleDrawCallModeTest(Context& context, const ExtParameters& extParams, const char* name,
761											   const char* description);
762
763	virtual ~GeometryShaderIncompatibleDrawCallModeTest()
764	{
765	}
766
767	virtual void		  deinit();
768	virtual IterateResult iterate();
769
770private:
771	/* Private type definition */
772
773	/* Private methods */
774
775	/* Private variables */
776	glw::GLuint		  m_fs_id;
777	glw::GLuint*	  m_gs_ids;
778	const glw::GLuint m_number_of_gs;
779	glw::GLuint*	  m_po_ids;
780	glw::GLuint		  m_vs_id;
781	glw::GLuint		  m_vao_id;
782};
783
784/* Implementation of "Group 24", test 5 from CTS_EXT_geometry_shader. Description follows:
785 *
786 *  5. Make sure that nothing is drawn if the number of vertices emitted by
787 *     a geometry shader is insufficient to produce a single primitive.
788 *
789 *     Category: API;
790 *               Functional/Negative Test.
791 *
792 *     For each output primitive type from the following list:
793 *
794 *     - Line strip;
795 *     - Triangle strip;
796 *
797 *     Create a geometry shader that accepts a single point and emits exactly
798 *     (N-1) vertices, coordinates of which are located within <-1,1>x<-1,1>
799 *     region, Z set to 0 and W to 1, where N corresponds to exact amount of
800 *     vertices needed to output a single primitive for output primitive type
801 *     considered.
802 *
803 *     Create a vertex shader object with boilerplate but valid implementation.
804 *     Create a fragment shader object setting the only output variable to
805 *     (1, 0, 0, 0).
806 *
807 *     Create 2 program objects, compile all the shaders. For each program
808 *     object, attach vertex and fragment shader objects discussed, as well as
809 *     one of the geometry shaders discussed. All program objects together
810 *     should use all geometry shaders discussed in the second paragraph.
811 *     Link all program objects.
812 *
813 *     Create a FBO and a texture object using a GL_RGBA8 internalformat and
814 *     of 16x16 resolution. Attach the texture object to color attachment 0 of
815 *     the FBO, bind the FBO to both framebuffer targets.
816 *
817 *     Create a vertex array object and bind it.
818 *
819 *     Set clear color to (0, 1, 0, 0).
820 *
821 *     Iterate through all program objects. For each iteration:
822 *     - Before doing actual draw call, clear the color buffer.;
823 *     - Activate program object specific for current iteration;
824 *     - Draw a single point.
825 *     - Read rendered contents (glReadPixels() call with GL_RGBA format and
826 *     GL_UNSIGNED_BYTE type) and make sure all pixels are set to (0, 255, 0, 0).
827 *
828 */
829class GeometryShaderInsufficientEmittedVerticesTest : public TestCaseBase
830{
831public:
832	/* Public methods */
833	GeometryShaderInsufficientEmittedVerticesTest(Context& context, const ExtParameters& extParams, const char* name,
834												  const char* description);
835
836	virtual ~GeometryShaderInsufficientEmittedVerticesTest()
837	{
838	}
839
840	virtual void		  deinit();
841	virtual IterateResult iterate();
842
843private:
844	/* Private type definition */
845
846	/* Private methods */
847
848	/* Private variables */
849	glw::GLubyte* m_pixels;
850
851	glw::GLuint		  m_fbo_id;
852	glw::GLuint		  m_fs_id;
853	glw::GLuint*	  m_gs_ids;
854	const glw::GLuint m_number_of_color_components;
855	const glw::GLuint m_number_of_gs;
856	glw::GLuint*	  m_po_ids;
857	const glw::GLuint m_texture_height;
858	glw::GLuint		  m_texture_id;
859	const glw::GLuint m_texture_width;
860	glw::GLuint		  m_vs_id;
861	glw::GLuint		  m_vao_id;
862};
863
864/* Implementation of "Group 25", test 2 from CTS_EXT_geometry_shader. Description follows:
865 *
866 *  2. Transform feedback which captures data from two variables where,
867 *     configured separately for two separable program objects where:
868 *
869 *     - the first one defines vertex shader stage (as in test case 25.1); is set
870 *       by a program activated for vertex shader stage;
871 *     - the second one defines geometry shader stage (as in test case 25.1);
872 *       should correctly capture output variables from either geometry shader
873 *       stage (if both stages are active) or vertex shader stage (if geometry
874 *       shader stage is inactive) in a result buffer object.
875 *
876 *     Category: API;
877 *               Functional Test.
878 *
879 *     Modify test case 25.1 to use pipeline objects.
880 *
881 *     First, a pipeline object consisting of both stages, should be used for
882 *     the test. Next, the geometry shader stage should be detached from the
883 *     geometry shader.
884 *     Transform feedback should be paused before the pipeline object's geometry
885 *     shader stage is deactivated.
886 *
887 *     Test succeeds if:
888 *
889 *     - out_gs_1 variable values are correctly captured if both shader stages
890 *       are being used for the pipeline object;
891 *     - out_vs_1 variable values are correctly captured if only vertex shader
892 *       stage is being used for the pipeline object;
893 *
894 */
895class GeometryShaderPipelineObjectTransformFeedbackVertexAndGeometryShaderCaptureTest : public TestCaseBase
896{
897public:
898	/* Public methods */
899	GeometryShaderPipelineObjectTransformFeedbackVertexAndGeometryShaderCaptureTest(Context&			 context,
900																					const ExtParameters& extParams,
901																					const char*			 name,
902																					const char*			 description);
903
904	virtual ~GeometryShaderPipelineObjectTransformFeedbackVertexAndGeometryShaderCaptureTest()
905	{
906	}
907
908	virtual void		  deinit();
909	virtual IterateResult iterate();
910
911private:
912	/* Private type definition */
913
914	/* Private methods */
915
916	/* Private variables */
917	glw::GLuint m_gs_id;
918	glw::GLuint m_gs_po_id;
919	glw::GLuint m_ppo_id;
920	glw::GLuint m_tfbo_id;
921	glw::GLuint m_vao_id;
922	glw::GLuint m_vs_id;
923	glw::GLuint m_vs_po_id;
924};
925
926/* Implementation of "Group 25", test 3 from CTS_EXT_geometry_shader. Description follows:
927 *
928 *  3. Make sure that, while transform feedback is active, attempts to draw
929 *     primitives that do not match output primitive type of the geometry shader
930 *     are rejected with GL_INVALID_OPERATION error.
931 *
932 *     Category: API;
933 *               Negative Test.
934 *
935 *     Consider a program object, for which fragment, geometry and vertex
936 *     shaders have been defined and attached. The geometry shader meets the
937 *     following requirements:
938 *
939 *     - accepts lines input;
940 *     - outputs triangles (a maximum of 3 vertices);
941 *     - defines and assigns a value to an output variable that can be used for
942 *       transform feedback process.
943 *
944 *     Fragment & vertex shader stages are boilerplate. Program object should
945 *     capture data stored in the geometry shader's output variable described.
946 *
947 *     Using the program object and GL_LINES transform feedback primitive mode,
948 *     doing a draw call in GL_TRIANGLES mode should result in
949 *     GL_INVALID_OPERATION error.
950 *
951 */
952class GeometryShaderDrawPrimitivesDoNotMatchOutputPrimitives : public TestCaseBase
953{
954public:
955	/* Public methods */
956	GeometryShaderDrawPrimitivesDoNotMatchOutputPrimitives(Context& context, const ExtParameters& extParams,
957														   const char* name, const char* description);
958
959	virtual ~GeometryShaderDrawPrimitivesDoNotMatchOutputPrimitives()
960	{
961	}
962
963	virtual void		  deinit();
964	virtual IterateResult iterate();
965
966private:
967	/* Private type definition */
968
969	/* Private methods */
970
971	/* Private variables */
972	glw::GLuint m_fs_id;
973	glw::GLuint m_gs_id;
974	glw::GLuint m_po_id;
975	glw::GLuint m_tfbo_id;
976	glw::GLuint m_vs_id;
977	glw::GLuint m_vao_id;
978};
979
980/* Implementation of "Group 25", test 4 from CTS_EXT_geometry_shader. Description follows:
981 *
982 *  4. Make sure that, while transform feedback is paused, all draw calls
983 *     executed with an active program object, which includes a geometry shader,
984 *     are valid. All input primitive type+output primitive type configurations
985 *     should be considered.
986 *
987 *     Category: API.
988 *
989 *     The test should run through all three transform feedback primitive modes,
990 *     but should pause transform feedback before doing a check draw call. All
991 *     permutations of valid input and output primitive types should be
992 *     considered, actual implementation can be boilerplate.
993 *
994 *     Note: in order to keep the execution times and implementation complexity
995 *           level in control, this test is not focused on verifying visual
996 *           outcome of the draw calls. Its aim is to only verify that the
997 *           driver correctly handles use cases where the transform feedback is
998 *           paused and draw calls are issued, meaning no error is reported.
999 *
1000 */
1001class GeometryShaderDrawCallsWhileTFPaused : public TestCaseBase
1002{
1003public:
1004	/* Public methods */
1005	GeometryShaderDrawCallsWhileTFPaused(Context& context, const ExtParameters& extParams, const char* name,
1006										 const char* description);
1007
1008	virtual ~GeometryShaderDrawCallsWhileTFPaused()
1009	{
1010	}
1011
1012	virtual void		  deinit();
1013	virtual IterateResult iterate();
1014
1015private:
1016	/* Private type definition */
1017
1018	/* Private methods */
1019
1020	/* Private variables */
1021	glw::GLuint m_fs_id;
1022	glw::GLuint m_gs_id;
1023	glw::GLuint m_po_ids[15] /* All combinations of possible inputs and outputs in GS */;
1024	glw::GLuint m_tfbo_id;
1025	glw::GLuint m_vs_id;
1026	glw::GLuint m_vao_id;
1027};
1028
1029} // namespace glcts
1030
1031#endif // _ESEXTCGEOMETRYSHADERAPI_HPP
1032