1#ifndef _ESEXTCGEOMETRYSHADERLAYEREDFRAMEBUFFER_HPP
2#define _ESEXTCGEOMETRYSHADERLAYEREDFRAMEBUFFER_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
28namespace glcts
29{
30/** Implementation of Tests 11.3 from CTS_EXT_geometry_shader. Description follows:
31 *
32 *  3. Make sure blending and color writes work correctly for layered rendering.
33 *
34 *  Category: API;
35 *            Functional Test.
36 *
37 *  Consider a layered framebuffer object A:
38 *
39 *  - 3D texture object A of resolution 4x4x4, internalformat GL_RGBA8, is
40 *    bound to color attachment 0.
41 *
42 *  For texture object A, each slice should be filled with texels of value
43 *  (0, slice_index / 4, slice_index / 8, slice_index / 12), where
44 *  slice_index corresponds to slice index considered.
45 *
46 *  Depth and stencil tests should be disabled.
47 *
48 *  Blending should be enabled. Source blend function should be set to
49 *  GL_ONE_MINUS_SRC_COLOR, destination blend function should be set to
50 *  GL_DST_COLOR.
51 *
52 *  A vertex shader for the test can be boilerplate.
53 *
54 *  Geometry shader should take points on input and output a maximum of
55 *  4 (layers) * (4 (sets of) * 4 (coordinates) ) vertices forming a triangle
56 *  strip (as in test case 7.1). The shader should emit 4 "full-screen quads"
57 *  for layers 0, 1, 2 and 3.
58 *
59 *  A fragment shader for the test should set the only output vec4 variable
60 *  to (0.2, 0.2, 0.2, 0.2).
61 *
62 *  Using a program object built of these three shaders *and* with the
63 *  framebuffer object A bound to both targets *and* with stencil test
64 *  stage configured as discussed, the test should draw a single point.
65 *
66 *  Test passes if result texel data is valid for all slices, given active
67 *  blending equation and function configuration.
68 *
69 **/
70class GeometryShaderLayeredFramebufferBlending : public TestCaseBase
71{
72public:
73	/* Public methods */
74	GeometryShaderLayeredFramebufferBlending(Context& context, const ExtParameters& extParams, const char* name,
75											 const char* description);
76
77	virtual ~GeometryShaderLayeredFramebufferBlending()
78	{
79	}
80
81	void		  deinit(void);
82	IterateResult iterate(void);
83
84private:
85	/* Private functions */
86
87	/* Private variables */
88	glw::GLuint m_fbo_id;
89	glw::GLuint m_fs_id;
90	glw::GLuint m_gs_id;
91	glw::GLuint m_po_id;
92	glw::GLuint m_read_fbo_id;
93	glw::GLuint m_to_id;
94	glw::GLuint m_vao_id;
95	glw::GLuint m_vs_id;
96};
97
98/** Implementation of Tests 11.4 and 11.5 from CTS_EXT_geometry_shader. Description follows:
99 *
100 * 4. Make sure glClear*() commands clear all layers of a layered attachment.
101 *
102 *  Category: API;
103 *            Functional Test.
104 *
105 *  Consider a layered framebuffer object A with the following configuration:
106 *
107 *  - 3D texture of resolution 4x4x4 and of internal format GL_RGBA8, bound
108 *  to color attachment 0. The texture contents should be as follows:
109 *
110 *  1) Texels of the first slice should be set to  (255, 0,   0,   0).
111 *  2) Texels of the second slice should be set to (0,   255, 0,   0).
112 *  3) Texels of the third slice should be set to  (0,   0,   255, 0).
113 *  4) Texels of the fourth slice should be set to (255, 255, 0,   0).
114 *
115 *  FBO A should be bound to GL_FRAMEBUFFER target. Clear color should be set
116 *  to (64, 128, 255, 32).
117 *
118 *  For each glClear*() command, reset all slices of the texture object with
119 *  values as above, and clear color attachment 0. The test should then
120 *  verify that each slice was set to (64, 128, 255, 32).
121 *
122 * 5. glReadPixels() calls done for a layered attachment should always work on
123 *    layer zero.
124 *
125 *    Category: API;
126 *              Functional Test.
127 *
128 *    Consider a 3D texture object A, configured exactly like in test case 11.4.
129 *
130 *    Consider a layered framebuffer object B. Texture object A's first layer
131 *    should be attached to color attachment 0.
132 *
133 *    The test should do a glReadPixels() call with GL_RGBA format and
134 *    GL_UNSIGNED_BYTE type. The data read should be equal to (255, 0, 0, 0)
135 *    for all texels.
136 *
137 **/
138class GeometryShaderLayeredFramebufferClear : public TestCaseBase
139{
140public:
141	/* Public methods */
142	GeometryShaderLayeredFramebufferClear(Context& context, const ExtParameters& extParams, const char* name,
143										  const char* description);
144
145	void		  deinit(void);
146	IterateResult iterate(void);
147
148private:
149	/* Private functions */
150
151	/* Private variables */
152	glw::GLuint m_fbo_char_id;
153	glw::GLuint m_fbo_int_id;
154	glw::GLuint m_fbo_uint_id;
155	glw::GLuint m_read_fbo_id;
156	glw::GLuint m_to_rgba32i_id;
157	glw::GLuint m_to_rgba32ui_id;
158	glw::GLuint m_to_rgba8_id;
159};
160
161/** Implementation of Tests 11.2 from CTS_EXT_geometry_shader. Description follows:
162 *
163 *  2. Make sure depth test stage works correctly for layered rendering.
164 *
165 *     Category: API;
166 *               Functional Test.
167 *
168 *     Consider a layered framebuffer object A:
169 *
170 *     - 2D array texture object A of resolution 4x4x4, internalformat GL_RGBA8, all
171 *       slices set to (0, 0, 0, 0) is bound to color attachment 0.
172 *     - 2D array texture object B of resolution 4x4x4, internalformat
173 *       GL_DEPTH_COMPONENT32F is bound to depth attachment.
174 *
175 *     For texture object B, all slices should be filled with depth value 0.5.
176 *
177 *     Stencil test should be disabled.
178 *
179 *     A vertex shader for the test can be boilerplate.
180 *
181 *     Geometry shader should take points on input and output a maximum of
182 *     4 (layers) * (4 (sets of) * 4 (coordinates) ) vertices forming a triangle
183 *     strip (as in test case 7.1). The shader should emit 4 "full-screen quads"
184 *     for layers 0, 1, 2 and 3, with an exception that the depth of each of
185 *     these quads should be equal to -1 + (quad index) / 2. For instance:
186 *     first layer's quad would be placed at depth -1.0, second layer's quad
187 *     would be placed at depth -0.5, and so on.
188 *
189 *     A fragment shader for the test should set the only output vec4 variable
190 *     to (1, 1, 1, 1).
191 *
192 *     Using a program object built of these three shaders *and* with the
193 *     framebuffer object A bound to both targets *and* with stencil test stage
194 *     configured as discussed, the test should draw a single point.
195 *
196 *     Test passes if the following conditions are met at this point:
197 *
198 *     * All texels of slice 0 of the texture object A are set to
199 *       (255, 255, 255, 255).
200 *     * All texels of slice 1 of the texture object A are set to
201 *       (255, 255, 255, 255).
202 *     * All texels of slice 2 of the texture object A are set to
203 *       (0, 0, 0, 0);
204 *     * All texels of slice 3 of the texture object A are set to
205 *       (0, 0, 0, 0);
206 **/
207class GeometryShaderLayeredFramebufferDepth : public TestCaseBase
208{
209public:
210	/* Public methods */
211	GeometryShaderLayeredFramebufferDepth(Context& context, const ExtParameters& extParams, const char* name,
212										  const char* description);
213
214	void		  deinit(void);
215	IterateResult iterate(void);
216
217private:
218	/* Private functions */
219
220	/* Private variables */
221	glw::GLuint m_fbo_id;
222	glw::GLuint m_fs_id;
223	glw::GLuint m_gs_id;
224	glw::GLuint m_po_id;
225	glw::GLuint m_read_fbo_id;
226	glw::GLuint m_to_a_id;
227	glw::GLuint m_to_b_id;
228	glw::GLuint m_vao_id;
229	glw::GLuint m_vs_id;
230};
231
232/** Implementation of Tests 11.1 from CTS_EXT_geometry_shader. Description follows:
233 *
234 * Make sure stencil test stage works correctly for layered rendering.
235 *
236 * Category: API;
237 *           Functional Test.
238 *
239 * Consider a layered framebuffer object A:
240 *
241 * - 2D array texture object A of resolution 4x4x4, internalformat GL_RGBA8, all
242 *   slices set to (0, 0, 0, 0) is bound to color attachment 0.
243 * - 2D array texture object B of resolution 4x4x4, internalformat
244 *   GL_DEPTH32F_STENCIL8 is bound to depth+stencil attachments.
245 *
246 * For texture object B, first slice (of index 0) should be filled with
247 * stencil value 2, second slice should be filled with stencil value 1,
248 * third and fourth slices should be filled with stencil value 0.
249 *
250 * Stencil function should be set to GL_LESS, reference value should
251 * be set at 0.
252 *
253 * Depth tests should be disabled.
254 *
255 * A vertex shader for the test can be boilerplate.
256 *
257 * Geometry shader should take points on input and output a maximum of
258 * 4 (layers) * (4 (sets of) *4 (coordinates) ) vertices forming a triangle
259 * strip (as in test case 7.1). The shader should emit 4 "full-screen quads"
260 * for layers 0, 1, 2 and 3.
261 *
262 * A fragment shader for the test should set the only output vec4 variable
263 * to (1, 1, 1, 1).
264 *
265 * Using a program object built of these three shaders *and* with the
266 * framebuffer object A bound to both targets *and* with stencil test stage
267 * configured as discussed, the test should draw a single point.
268 *
269 * Test passes if the following conditions are met at this point:
270 *
271 * * All texels of slice 0 of the texture object A are set to
272 *   (255, 255, 255, 255).
273 * * All texels of slice 1 of the texture object A are set to
274 *   (255, 255, 255, 255).
275 * * All texels of slice 2 of the texture object A are set to
276 *   (0, 0, 0, 0);
277 * * All texels of slice 3 of the texture object A are set to
278 *   (0, 0, 0, 0);
279 *
280 **/
281class GeometryShaderLayeredFramebufferStencil : public TestCaseBase
282{
283public:
284	/* Public methods */
285	GeometryShaderLayeredFramebufferStencil(Context& context, const ExtParameters& extParams, const char* name,
286											const char* description);
287
288	void		  deinit(void);
289	IterateResult iterate(void);
290
291private:
292	/* Private functions */
293
294	/* Private variables */
295	glw::GLuint m_fbo_id;
296	glw::GLuint m_fs_id;
297	glw::GLuint m_gs_id;
298	glw::GLuint m_po_id;
299	glw::GLuint m_to_a_id;
300	glw::GLuint m_to_b_id;
301	glw::GLuint m_vao_id;
302	glw::GLuint m_vs_id;
303};
304
305} // namespace glcts
306
307#endif // _ESEXTCGEOMETRYSHADERLAYEREDFRAMEBUFFER_HPP
308