1 #ifndef _ESEXTCTESSELLATIONSHADERPOINTS_HPP
2 #define _ESEXTCTESSELLATIONSHADERPOINTS_HPP
3 /*-------------------------------------------------------------------------
4  * OpenGL Conformance Test Suite
5  * -----------------------------
6  *
7  * Copyright (c) 2014-2016 The Khronos Group Inc.
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  */ /*!
22  * \file
23  * \brief
24  */ /*-------------------------------------------------------------------*/
25 
26 #include "../esextcTestCaseBase.hpp"
27 #include "esextcTessellationShaderUtils.hpp"
28 #include "gluShaderUtil.hpp"
29 #include "tcuDefs.hpp"
30 
31 namespace glcts
32 {
33 
34 /** A DEQP CTS test group that collects all tests that verify triangle
35  *  tessellation.
36  */
37 class TessellationShaderPointsTests : public glcts::TestCaseGroupBase
38 {
39 public:
40     /* Public methods */
41     TessellationShaderPointsTests(glcts::Context &context, const ExtParameters &extParams);
~TessellationShaderPointsTests(void)42     virtual ~TessellationShaderPointsTests(void)
43     {
44     }
45 
46     virtual void init(void);
47 
48 private:
49     /* Private methods */
50     TessellationShaderPointsTests(const TessellationShaderPointsTests &other);
51     TessellationShaderPointsTests &operator=(const TessellationShaderPointsTests &other);
52 };
53 
54 /** Implementation of Test Case 39
55  *
56  *  Assuming the implementation reports maximum point size to be at least 2,
57  *  make sure that points are rendered with size as defined by:
58  *
59  *  * geometry shader (if present); (*)
60  *  * tessellation evaluation shader (if GL_EXT_tessellation_shader and
61  *    GL_EXT_tessellation_shader_point_size extensions are supported and no
62  *    geometry shader is active); (**)
63  *
64  *  Technical details.
65  *
66  *  0. The test should draw points in a few pre-defined locations (screen corners,
67  *     center of the draw buffer).
68  *  1a. For case (*), vertex shader should set point size to 0.01, TE should
69  *      set point size to 0.1 and GE should set point size to 2 for each
70  *      vertex processed.
71  *  1b. For case (**), TE should set the point size to 2 and VE should set it
72  *      to 0.1.
73  *  2.  The test passes if centers of the rendered points have correct values.
74  *
75  **/
76 class TessellationShaderPointsgl_PointSize : public TestCaseBase
77 {
78 public:
79     /* Public methods */
80     TessellationShaderPointsgl_PointSize(Context &context, const ExtParameters &extParams);
81 
~TessellationShaderPointsgl_PointSize(void)82     virtual ~TessellationShaderPointsgl_PointSize(void)
83     {
84     }
85 
86     virtual void deinit();
87     void initTest(void);
88     virtual IterateResult iterate(void);
89 
90 private:
91     /* Private type definitions */
92     typedef struct _test_descriptor
93     {
94         const char *fs_body;
95         const char *gs_body;
96         const char *tes_body;
97         const char *tcs_body;
98         const char *vs_body;
99 
100         glw::GLint fs_id;
101         glw::GLint gs_id;
102         glw::GLint tes_id;
103         glw::GLint tcs_id;
104         glw::GLint vs_id;
105 
106         glw::GLint draw_call_count;
107         glw::GLint po_id;
108 
_test_descriptorglcts::TessellationShaderPointsgl_PointSize::_test_descriptor109         _test_descriptor()
110         {
111             fs_body  = NULL;
112             gs_body  = NULL;
113             tes_body = NULL;
114             tcs_body = NULL;
115             vs_body  = NULL;
116 
117             fs_id  = 0;
118             gs_id  = 0;
119             tes_id = 0;
120             tcs_id = 0;
121             vs_id  = 0;
122 
123             draw_call_count = 0;
124             po_id           = 0;
125         }
126     } _test_descriptor;
127 
128     typedef std::vector<_test_descriptor> _tests;
129     typedef _tests::iterator _tests_iterator;
130 
131     /* Private methods */
132 
133     /* Private variables */
134     _tests m_tests;
135 
136     glw::GLuint m_fbo_id;
137     glw::GLuint m_to_id;
138     glw::GLuint m_vao_id;
139 
140     static const unsigned int m_rt_height;
141     static const unsigned int m_rt_width;
142 };
143 
144 /** Implementation of Test Case 27
145  *
146  *  Make sure that point mode enabled in a tessellation evaluation shader
147  *  affects geometry generated by tessellation primitive generator. Iterate
148  *  over all vertex spacing modes.
149  *  Cover all three tessellation primitive generator modes (triangles, quads,
150  *  isolines).
151  *
152  *  Technical details:
153  *
154  *  0. Consider the following set: {-1 (where valid), 1, MAX_TESS_GEN_LEVEL_EXT / 2,
155  *     MAX_TESS_GEN_LEVEL_EXT}. All combinations of values from this set
156  *     in regard to relevant inner/outer tessellation levels for all
157  *     primitive generator modes should be checked by this test.
158  *
159  *  1. TE should capture output points. Captured vertices should not
160  *     duplicate and their amount should be exactly as defined in the spec
161  *     for the (inner tessellation level, outer tessellation level, output
162  *     geometry) combination considered.
163  *
164  *  This test implementation skips configurations meeting all of the following
165  *  properties:
166  *
167  *  - primitive mode:      QUADS or TRIANGLES
168  *  - vertex spacing mode: FRACTIONAL ODD
169  *  - inner tess level[0]: <= 1
170  *  - inner tess level[1]: <= 1
171  *
172  *  These configurations are affected by a nuance described in greater
173  *  detail in Khronos Bugzilla#11979, which this test cannot handle.
174  *
175  **/
176 class TessellationShaderPointsVerification : public TestCaseBase
177 {
178 public:
179     /* Public methods */
180     TessellationShaderPointsVerification(Context &context, const ExtParameters &extParams);
181 
~TessellationShaderPointsVerification(void)182     virtual ~TessellationShaderPointsVerification(void)
183     {
184     }
185 
186     virtual void deinit(void);
187     void initTest(void);
188     virtual IterateResult iterate(void);
189 
190 private:
191     /* Private declarations */
192     typedef struct _run
193     {
194         float inner[2];
195         float outer[4];
196         _tessellation_primitive_mode primitive_mode;
197         _tessellation_shader_vertex_spacing vertex_spacing;
198 
_runglcts::TessellationShaderPointsVerification::_run199         _run()
200         {
201             memset(inner, 0, sizeof(inner));
202             memset(outer, 0, sizeof(outer));
203 
204             primitive_mode = TESSELLATION_SHADER_PRIMITIVE_MODE_UNKNOWN;
205             vertex_spacing = TESSELLATION_SHADER_VERTEX_SPACING_UNKNOWN;
206         }
207     } _run;
208 
209     /* Private methods */
210     void verifyCorrectAmountOfDuplicateVertices(const _run &run, const void *run_data, unsigned int run_n_vertices);
211 
212     void verifyCorrectAmountOfVertices(const _run &run, const void *run_data, unsigned int run_n_vertices);
213 
214     /* Private variables */
215     std::vector<_run> m_runs;
216     TessellationShaderUtils *m_utils;
217     glw::GLuint m_vao_id;
218 };
219 
220 } // namespace glcts
221 
222 #endif // _ESEXTCTESSELLATIONSHADERPOINTS_HPP
223