1 /*-------------------------------------------------------------------------
2 * OpenGL Conformance Test Suite
3 * -----------------------------
5 * Copyright (c) 2014-2016 The Khronos Group Inc.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 */ /*-------------------------------------------------------------------*/
24 #include "es31cArrayOfArraysTests.hpp"
25 #include "gluContextInfo.hpp"
26 #include "gluDefs.hpp"
27 #include "gluRenderContext.hpp"
28 #include "glwFunctions.hpp"
29 #include "tcuTestLog.hpp"
37 /* Selects if debug output is enabled */
39 #define IS_DEBUG_DUMP_ALL_SHADERS 0
41 /* Selects if workaround in ExpressionsInvalid2 test is enabled */
42 #define WRKARD_EXPRESSIONSINVALID2 0
45 #include "tcuTestLog.hpp"
50 namespace ArraysOfArrays
54 /* Sets limits on number of dimensions. Value 8 comes from ogirinal "ES" implementation.
55 * Explanation was as follows:
57 * "The current specifations allow up to 8 array dimensions."
59 const size_t ES::MAX_ARRAY_DIMENSIONS = 8;
60 const size_t GL::MAX_ARRAY_DIMENSIONS = 8;
62 /* API specific shader parts */
63 const char* ES::shader_version_gpu5 =
64 "#version 310 es\n#extension GL_EXT_gpu_shader5 : require\nprecision mediump float;\n\n";
65 const char* ES::shader_version = "#version 310 es\nprecision mediump float;\n\n";
67 const char* GL::shader_version_gpu5 = "#version 430 core\n\n";
68 const char* GL::shader_version = "#version 430 core\n\n";
69 } /* namespace Interface */
71 /* Dummy fragment shader source code.
72 * Used when testing the vertex shader. */
73 const std::string default_fragment_shader_source = "//default fragment shader\n"
77 " color = vec4(1.0);\n"
80 /* Dummy vertex shader source code.
81 * Used when testing the fragment shader. */
82 const std::string default_vertex_shader_source = "//default vertex shader\n"
86 " gl_Position = vec4(0.0,0.0,0.0,1.0);\n"
89 /* Dummy geometry shader source code.
90 * Used when testing the other shaders. */
91 const std::string default_geometry_shader_source = "//default geometry\n"
95 " gl_Position = vec4(-1, -1, 0, 1);\n"
97 " gl_Position = vec4(-1, 1, 0, 1);\n"
99 " gl_Position = vec4(1, -1, 0, 1);\n"
101 " gl_Position = vec4(1, 1, 0, 1);\n"
105 /* Dummy tesselation control shader source code.
106 * Used when testing the other shaders. */
107 const std::string default_tc_shader_source = "//default tcs\n"
111 " gl_TessLevelOuter[0] = 1.0;\n"
112 " gl_TessLevelOuter[1] = 1.0;\n"
113 " gl_TessLevelOuter[2] = 1.0;\n"
114 " gl_TessLevelOuter[3] = 1.0;\n"
115 " gl_TessLevelInner[0] = 1.0;\n"
116 " gl_TessLevelInner[1] = 1.0;\n"
119 /* Dummy tesselation evaluation shader source code.
120 * Used when testing the other shaders. */
121 const std::string default_te_shader_source = "//default tes\n"
127 /* Pass-through shaders source code. Used when testing other stage. */
128 const std::string pass_fragment_shader_source = "//pass fragment shader\n"
129 "in float fs_result;\n"
134 " color = vec4(fs_result);\n"
137 const std::string pass_geometry_shader_source = "//pass geometry\n"
138 "in float gs_result[];\n"
139 "out float fs_result;\n"
143 " gl_Position = vec4(-1, -1, 0, 1);\n"
144 " fs_result = gs_result[0];\n"
146 " gl_Position = vec4(-1, 1, 0, 1);\n"
147 " fs_result = gs_result[0];\n"
149 " gl_Position = vec4(1, -1, 0, 1);\n"
150 " fs_result = gs_result[0];\n"
152 " gl_Position = vec4(1, 1, 0, 1);\n"
153 " fs_result = gs_result[0];\n"
157 const std::string pass_te_shader_source = "//pass tes\n"
158 "in float tcs_result[];\n"
159 "out float fs_result;\n"
163 " fs_result = tcs_result[0];\n"
167 static const std::string empty_string = "";
169 /* Beginning of a shader source code. */
170 const std::string shader_start = "void main()\n"
173 /* End of a shader source code. */
174 const std::string shader_end = "}\n";
176 /* Emit full screen quad from GS */
177 const std::string emit_quad = " gl_Position = vec4(-1, -1, 0, 1);\n"
179 " gl_Position = vec4(-1, 1, 0, 1);\n"
181 " gl_Position = vec4(1, -1, 0, 1);\n"
183 " gl_Position = vec4(1, 1, 0, 1);\n"
186 /* Set tesselation levels */
187 const std::string set_tesseation = " gl_TessLevelOuter[0] = 1.0;\n"
188 " gl_TessLevelOuter[1] = 1.0;\n"
189 " gl_TessLevelOuter[2] = 1.0;\n"
190 " gl_TessLevelOuter[3] = 1.0;\n"
191 " gl_TessLevelInner[0] = 1.0;\n"
192 " gl_TessLevelInner[1] = 1.0;\n";
194 /* Input and output data type modifiers. */
195 const std::string in_out_type_modifiers[] = { "in", "out", "uniform" };
197 /* Types and appropriate initialisers, used throughout these tests */
198 const var_descriptor var_descriptors[] = {
199 { "bool", "", "true", "false", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A" },
200 { "int", "", "1", "0", "0", "int", "", "iterator", "1", "N/A", "N/A" },
201 { "uint", "", "1u", "0u", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A" },
202 { "float", "", "1.0", "0.0", "0.0", "float", "", "iterator", "1.0", "N/A", "N/A" },
203 { "vec2", "", "vec2(1.0)", "vec2(0.0)", "0.0", "float", "[0]", "vec2(iterator)", "vec2(1.0)", "N/A", "N/A" },
204 { "vec3", "", "vec3(1.0)", "vec3(0.0)", "0.0", "float", "[0]", "vec3(iterator)", "vec3(1.0)", "N/A", "N/A" },
205 { "vec4", "", "vec4(1.0)", "vec4(0.0)", "0.0", "float", "[0]", "vec4(iterator)", "vec4(1.0)", "N/A", "N/A" },
206 { "bvec2", "", "bvec2(1)", "bvec2(0)", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A" },
207 { "bvec3", "", "bvec3(1)", "bvec3(0)", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A" },
208 { "bvec4", "", "bvec4(1)", "bvec4(0)", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A" },
209 { "ivec2", "", "ivec2(1)", "ivec2(0)", "0", "int", "[0]", "ivec2(iterator)", "ivec2(1)", "N/A", "N/A" },
210 { "ivec3", "", "ivec3(1)", "ivec3(0)", "0", "int", "[0]", "ivec3(iterator)", "ivec3(1)", "N/A", "N/A" },
211 { "ivec4", "", "ivec4(1)", "ivec4(0)", "0", "int", "[0]", "ivec4(iterator)", "ivec4(1)", "N/A", "N/A" },
212 { "uvec2", "", "uvec2(1u)", "uvec2(0u)", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A" },
213 { "uvec3", "", "uvec3(1u)", "uvec3(0u)", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A" },
214 { "uvec4", "", "uvec4(1u)", "uvec4(0u)", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A" },
215 { "mat2", "", "mat2(1.0)", "mat2(0.0)", "0.0", "float", "[0][0]", "mat2(iterator)", "mat2(1.0)", "N/A", "N/A" },
216 { "mat3", "", "mat3(1.0)", "mat3(0.0)", "0.0", "float", "[0][0]", "mat3(iterator)", "mat3(1.0)", "N/A", "N/A" },
217 { "mat4", "", "mat4(1.0)", "mat4(0.0)", "0.0", "float", "[0][0]", "mat4(iterator)", "mat4(1.0)", "N/A", "N/A" },
218 { "mat2x2", "", "mat2x2(1.0)", "mat2x2(0.0)", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A" },
219 { "mat2x3", "", "mat2x3(1.0)", "mat2x3(0.0)", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A" },
220 { "mat2x4", "", "mat2x4(1.0)", "mat2x4(0.0)", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A" },
221 { "mat3x2", "", "mat3x2(1.0)", "mat3x2(0.0)", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A" },
222 { "mat3x3", "", "mat3x3(1.0)", "mat3x3(0.0)", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A" },
223 { "mat3x4", "", "mat3x4(1.0)", "mat3x4(0.0)", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A" },
224 { "mat4x2", "", "mat4x2(1.0)", "mat4x2(0.0)", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A" },
225 { "mat4x3", "", "mat4x3(1.0)", "mat4x3(0.0)", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A" },
226 { "mat4x4", "", "mat4x4(1.0)", "mat4x4(0.0)", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A" },
227 { "imageBuffer", "", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A" },
228 { "iimageBuffer", "", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A" },
229 { "uimageBuffer", "", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A" },
230 { "samplerBuffer", "lowp", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A" },
231 { "isamplerBuffer", "lowp", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A" },
232 { "usamplerBuffer", "lowp", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A" },
233 { "sampler2D", "", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "vec2(0.0)", "vec4" },
234 { "sampler3D", "lowp", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "vec3(0.0)", "vec4" },
235 { "samplerCube", "", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "vec3(0.0)", "vec4" },
237 "samplerCubeShadow", "lowp", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "vec4(0.0)", "float",
239 { "sampler2DShadow", "lowp", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "vec3(0.0)", "float" },
240 { "sampler2DArray", "lowp", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "vec3(0.0)", "vec4" },
241 { "sampler2DArrayShadow", "lowp", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "vec4(0.0)", "float" },
242 { "isampler2D", "lowp", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "vec2(0.0)", "ivec4" },
243 { "isampler3D", "lowp", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "vec3(0.0)", "ivec4" },
244 { "isamplerCube", "lowp", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "vec3(0.0)", "ivec4" },
245 { "isampler2DArray", "lowp", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "vec3(0.0)", "ivec4" },
246 { "usampler2D", "lowp", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "vec2(0.0)", "uvec4" },
247 { "usampler3D", "lowp", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "vec3(0.0)", "uvec4" },
248 { "usamplerCube", "lowp", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "vec3(0.0)", "uvec4" },
249 { "usampler2DArray", "lowp", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "vec3(0.0)", "uvec4" },
252 const var_descriptor var_double_descriptors[] = {
253 { "double", "", "1.0", "0.0", "0.0", "double", "", "iterator", "1.0", "N/A", "N/A" },
254 { "dmat2", "", "dmat2(1.0)", "dmat2(0.0)", "0.0", "double", "[0][0]", "dmat2(iterator)", "dmat2(1.0)", "N/A",
256 { "dmat3", "", "dmat3(1.0)", "dmat3(0.0)", "0.0", "double", "[0][0]", "dmat3(iterator)", "dmat3(1.0)", "N/A",
258 { "dmat4", "", "dmat4(1.0)", "dmat4(0.0)", "0.0", "double", "[0][0]", "dmat4(iterator)", "dmat4(1.0)", "N/A",
260 { "dmat2x2", "", "dmat2x2(1.0)", "dmat2x2(0.0)", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A" },
261 { "dmat2x3", "", "dmat2x3(1.0)", "dmat2x3(0.0)", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A" },
262 { "dmat2x4", "", "dmat2x4(1.0)", "dmat2x4(0.0)", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A" },
263 { "dmat3x2", "", "dmat3x2(1.0)", "dmat3x2(0.0)", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A" },
264 { "dmat3x3", "", "dmat3x3(1.0)", "dmat3x3(0.0)", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A" },
265 { "dmat3x4", "", "dmat3x4(1.0)", "dmat3x4(0.0)", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A" },
266 { "dmat4x2", "", "dmat4x2(1.0)", "dmat4x2(0.0)", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A" },
267 { "dmat4x3", "", "dmat4x3(1.0)", "dmat4x3(0.0)", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A" },
268 { "dmat4x4", "", "dmat4x4(1.0)", "dmat4x4(0.0)", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A" },
271 _supported_variable_types_map supported_variable_types_map;
273 /** List of all supported variable types for es. */
274 const test_var_type var_types_es[] = {
275 VAR_TYPE_BOOL, VAR_TYPE_INT, VAR_TYPE_UINT, VAR_TYPE_FLOAT, VAR_TYPE_VEC2, VAR_TYPE_VEC3,
276 VAR_TYPE_VEC4, VAR_TYPE_BVEC2, VAR_TYPE_BVEC3, VAR_TYPE_BVEC4, VAR_TYPE_IVEC2, VAR_TYPE_IVEC3,
277 VAR_TYPE_IVEC4, VAR_TYPE_UVEC2, VAR_TYPE_UVEC3, VAR_TYPE_UVEC4, VAR_TYPE_MAT2, VAR_TYPE_MAT3,
278 VAR_TYPE_MAT4, VAR_TYPE_MAT2X2, VAR_TYPE_MAT2X3, VAR_TYPE_MAT2X4, VAR_TYPE_MAT3X2, VAR_TYPE_MAT3X3,
279 VAR_TYPE_MAT3X4, VAR_TYPE_MAT4X2, VAR_TYPE_MAT4X3, VAR_TYPE_MAT4X4,
282 const test_var_type* Interface::ES::var_types = var_types_es;
283 const size_t Interface::ES::n_var_types = sizeof(var_types_es) / sizeof(var_types_es[0]);
285 /** List of all supported variable types for gl. */
286 static const glcts::test_var_type var_types_gl[] = {
287 VAR_TYPE_BOOL, VAR_TYPE_INT, VAR_TYPE_UINT, VAR_TYPE_FLOAT, VAR_TYPE_VEC2, VAR_TYPE_VEC3,
288 VAR_TYPE_VEC4, VAR_TYPE_BVEC2, VAR_TYPE_BVEC3, VAR_TYPE_BVEC4, VAR_TYPE_IVEC2, VAR_TYPE_IVEC3,
289 VAR_TYPE_IVEC4, VAR_TYPE_UVEC2, VAR_TYPE_UVEC3, VAR_TYPE_UVEC4, VAR_TYPE_MAT2, VAR_TYPE_MAT3,
290 VAR_TYPE_MAT4, VAR_TYPE_MAT2X2, VAR_TYPE_MAT2X3, VAR_TYPE_MAT2X4, VAR_TYPE_MAT3X2, VAR_TYPE_MAT3X3,
291 VAR_TYPE_MAT3X4, VAR_TYPE_MAT4X2, VAR_TYPE_MAT4X3, VAR_TYPE_MAT4X4, VAR_TYPE_DOUBLE, VAR_TYPE_DMAT2,
292 VAR_TYPE_DMAT3, VAR_TYPE_DMAT4, VAR_TYPE_DMAT2X2, VAR_TYPE_DMAT2X3, VAR_TYPE_DMAT2X4, VAR_TYPE_DMAT3X2,
293 VAR_TYPE_DMAT3X3, VAR_TYPE_DMAT3X4, VAR_TYPE_DMAT4X2, VAR_TYPE_DMAT4X3, VAR_TYPE_DMAT4X4,
296 const test_var_type* Interface::GL::var_types = var_types_gl;
297 const size_t Interface::GL::n_var_types = sizeof(var_types_gl) / sizeof(var_types_gl[0]);
299 /** List of all supported opaque types. */
300 const glcts::test_var_type opaque_var_types[] = {
301 //Floating Point Sampler Types (opaque)
302 VAR_TYPE_SAMPLER2D, VAR_TYPE_SAMPLER3D, VAR_TYPE_SAMPLERCUBE, VAR_TYPE_SAMPLERCUBESHADOW, VAR_TYPE_SAMPLER2DSHADOW,
303 VAR_TYPE_SAMPLER2DARRAY, VAR_TYPE_SAMPLER2DARRAYSHADOW,
304 //Signed Integer Sampler Types (opaque)
305 VAR_TYPE_ISAMPLER2D, VAR_TYPE_ISAMPLER3D, VAR_TYPE_ISAMPLERCUBE, VAR_TYPE_ISAMPLER2DARRAY,
306 //Unsigned Integer Sampler Types (opaque)
307 VAR_TYPE_USAMPLER2D, VAR_TYPE_USAMPLER3D, VAR_TYPE_USAMPLERCUBE, VAR_TYPE_USAMPLER2DARRAY,
310 /** Sets up the type map that will be used to look up the type names, initialisation
311 * values, etc., associated with each of the types used within the array tests
320 supported_variable_types_map[VAR_TYPE_BOOL] = var_descriptors[temp_index++];
321 supported_variable_types_map[VAR_TYPE_INT] = var_descriptors[temp_index++];
322 supported_variable_types_map[VAR_TYPE_UINT] = var_descriptors[temp_index++];
323 supported_variable_types_map[VAR_TYPE_FLOAT] = var_descriptors[temp_index++];
324 supported_variable_types_map[VAR_TYPE_VEC2] = var_descriptors[temp_index++];
325 supported_variable_types_map[VAR_TYPE_VEC3] = var_descriptors[temp_index++];
326 supported_variable_types_map[VAR_TYPE_VEC4] = var_descriptors[temp_index++];
327 supported_variable_types_map[VAR_TYPE_BVEC2] = var_descriptors[temp_index++];
328 supported_variable_types_map[VAR_TYPE_BVEC3] = var_descriptors[temp_index++];
329 supported_variable_types_map[VAR_TYPE_BVEC4] = var_descriptors[temp_index++];
330 supported_variable_types_map[VAR_TYPE_IVEC2] = var_descriptors[temp_index++];
331 supported_variable_types_map[VAR_TYPE_IVEC3] = var_descriptors[temp_index++];
332 supported_variable_types_map[VAR_TYPE_IVEC4] = var_descriptors[temp_index++];
333 supported_variable_types_map[VAR_TYPE_UVEC2] = var_descriptors[temp_index++];
334 supported_variable_types_map[VAR_TYPE_UVEC3] = var_descriptors[temp_index++];
335 supported_variable_types_map[VAR_TYPE_UVEC4] = var_descriptors[temp_index++];
336 supported_variable_types_map[VAR_TYPE_MAT2] = var_descriptors[temp_index++];
337 supported_variable_types_map[VAR_TYPE_MAT3] = var_descriptors[temp_index++];
338 supported_variable_types_map[VAR_TYPE_MAT4] = var_descriptors[temp_index++];
339 supported_variable_types_map[VAR_TYPE_MAT2X2] = var_descriptors[temp_index++];
340 supported_variable_types_map[VAR_TYPE_MAT2X3] = var_descriptors[temp_index++];
341 supported_variable_types_map[VAR_TYPE_MAT2X4] = var_descriptors[temp_index++];
342 supported_variable_types_map[VAR_TYPE_MAT3X2] = var_descriptors[temp_index++];
343 supported_variable_types_map[VAR_TYPE_MAT3X3] = var_descriptors[temp_index++];
344 supported_variable_types_map[VAR_TYPE_MAT3X4] = var_descriptors[temp_index++];
345 supported_variable_types_map[VAR_TYPE_MAT4X2] = var_descriptors[temp_index++];
346 supported_variable_types_map[VAR_TYPE_MAT4X3] = var_descriptors[temp_index++];
347 supported_variable_types_map[VAR_TYPE_MAT4X4] = var_descriptors[temp_index++];
348 supported_variable_types_map[VAR_TYPE_IMAGEBUFFER] = var_descriptors[temp_index++];
349 supported_variable_types_map[VAR_TYPE_IIMAGEBUFFER] = var_descriptors[temp_index++];
350 supported_variable_types_map[VAR_TYPE_UIMAGEBUFFER] = var_descriptors[temp_index++];
351 supported_variable_types_map[VAR_TYPE_SAMPLERBUFFER] = var_descriptors[temp_index++];
352 supported_variable_types_map[VAR_TYPE_ISAMPLERBUFFER] = var_descriptors[temp_index++];
353 supported_variable_types_map[VAR_TYPE_USAMPLERBUFFER] = var_descriptors[temp_index++];
354 supported_variable_types_map[VAR_TYPE_SAMPLER2D] = var_descriptors[temp_index++];
355 supported_variable_types_map[VAR_TYPE_SAMPLER3D] = var_descriptors[temp_index++];
356 supported_variable_types_map[VAR_TYPE_SAMPLERCUBE] = var_descriptors[temp_index++];
357 supported_variable_types_map[VAR_TYPE_SAMPLERCUBESHADOW] = var_descriptors[temp_index++];
358 supported_variable_types_map[VAR_TYPE_SAMPLER2DSHADOW] = var_descriptors[temp_index++];
359 supported_variable_types_map[VAR_TYPE_SAMPLER2DARRAY] = var_descriptors[temp_index++];
360 supported_variable_types_map[VAR_TYPE_SAMPLER2DARRAYSHADOW] = var_descriptors[temp_index++];
361 supported_variable_types_map[VAR_TYPE_ISAMPLER2D] = var_descriptors[temp_index++];
362 supported_variable_types_map[VAR_TYPE_ISAMPLER3D] = var_descriptors[temp_index++];
363 supported_variable_types_map[VAR_TYPE_ISAMPLERCUBE] = var_descriptors[temp_index++];
364 supported_variable_types_map[VAR_TYPE_ISAMPLER2DARRAY] = var_descriptors[temp_index++];
365 supported_variable_types_map[VAR_TYPE_USAMPLER2D] = var_descriptors[temp_index++];
366 supported_variable_types_map[VAR_TYPE_USAMPLER3D] = var_descriptors[temp_index++];
367 supported_variable_types_map[VAR_TYPE_USAMPLERCUBE] = var_descriptors[temp_index++];
368 supported_variable_types_map[VAR_TYPE_USAMPLER2DARRAY] = var_descriptors[temp_index++];
374 supported_variable_types_map[VAR_TYPE_DOUBLE] = var_double_descriptors[temp_index++];
375 supported_variable_types_map[VAR_TYPE_DMAT2] = var_double_descriptors[temp_index++];
376 supported_variable_types_map[VAR_TYPE_DMAT3] = var_double_descriptors[temp_index++];
377 supported_variable_types_map[VAR_TYPE_DMAT4] = var_double_descriptors[temp_index++];
378 supported_variable_types_map[VAR_TYPE_DMAT2X2] = var_double_descriptors[temp_index++];
379 supported_variable_types_map[VAR_TYPE_DMAT2X3] = var_double_descriptors[temp_index++];
380 supported_variable_types_map[VAR_TYPE_DMAT2X4] = var_double_descriptors[temp_index++];
381 supported_variable_types_map[VAR_TYPE_DMAT3X2] = var_double_descriptors[temp_index++];
382 supported_variable_types_map[VAR_TYPE_DMAT3X3] = var_double_descriptors[temp_index++];
383 supported_variable_types_map[VAR_TYPE_DMAT3X4] = var_double_descriptors[temp_index++];
384 supported_variable_types_map[VAR_TYPE_DMAT4X2] = var_double_descriptors[temp_index++];
385 supported_variable_types_map[VAR_TYPE_DMAT4X3] = var_double_descriptors[temp_index++];
386 supported_variable_types_map[VAR_TYPE_DMAT4X4] = var_double_descriptors[temp_index++];
390 /** Macro appends default ending of main function to source string
392 * @param SOURCE Tested shader source
394 #define DEFAULT_MAIN_ENDING(TYPE, SOURCE) \
396 /* Apply stage specific stuff */ \
399 case TestCaseBase<API>::VERTEX_SHADER_TYPE: \
400 SOURCE += "\n gl_Position = vec4(0.0);\n"; \
402 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE: \
404 case TestCaseBase<API>::COMPUTE_SHADER_TYPE: \
406 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE: \
407 SOURCE += emit_quad; \
409 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE: \
410 SOURCE += set_tesseation; \
412 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE: \
415 TCU_FAIL("Unrecognized shader type."); \
419 /* End main function */ \
420 SOURCE += shader_end; \
423 /** Macro executes positive test selected on USE_ALL_SHADER_STAGES
425 * @param TYPE Tested shader stage
426 * @param SOURCE Tested shader source
427 * @param DELETE Selects if program should be deleted afterwards
429 #define EXECUTE_POSITIVE_TEST(TYPE, SOURCE, DELETE, GPU5) \
431 const std::string* cs = &empty_string; \
432 const std::string* vs = &default_vertex_shader_source; \
433 const std::string* tcs = &default_tc_shader_source; \
434 const std::string* tes = &default_te_shader_source; \
435 const std::string* gs = &default_geometry_shader_source; \
436 const std::string* fs = &default_fragment_shader_source; \
440 case TestCaseBase<API>::COMPUTE_SHADER_TYPE: \
442 vs = &empty_string; \
443 tcs = &empty_string; \
444 tes = &empty_string; \
445 gs = &empty_string; \
446 fs = &empty_string; \
448 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE: \
451 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE: \
454 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE: \
457 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE: \
460 case TestCaseBase<API>::VERTEX_SHADER_TYPE: \
464 TCU_FAIL("Invalid enum"); \
468 if (API::USE_ALL_SHADER_STAGES) \
470 this->execute_positive_test(*vs, *tcs, *tes, *gs, *fs, *cs, DELETE, GPU5); \
474 this->execute_positive_test(*vs, *fs, DELETE, GPU5); \
478 /** Macro executes either positive or negative test
480 * @param S Selects negative test when 0, positive test otherwise
481 * @param TYPE Tested shader stage
482 * @param SOURCE Tested shader source
484 #define EXECUTE_SHADER_TEST(S, TYPE, SOURCE) \
487 EXECUTE_POSITIVE_TEST(TYPE, SOURCE, true, false); \
491 this->execute_negative_test(TYPE, SOURCE); \
494 /** Test case constructor.
496 * @tparam API Tested API descriptor
498 * @param context EGL context ID.
499 * @param name Name of a test case.
500 * @param description Test case description.
503 TestCaseBase<API>::TestCaseBase(Context& context, const char* name, const char* description)
504 : tcu::TestCase(context.getTestContext(), name, description)
505 , context_id(context)
506 , program_object_id(0)
507 , compute_shader_object_id(0)
508 , fragment_shader_object_id(0)
509 , geometry_shader_object_id(0)
510 , tess_ctrl_shader_object_id(0)
511 , tess_eval_shader_object_id(0)
512 , vertex_shader_object_id(0)
514 /* Left blank on purpose */
517 /** Clears up the shaders and program that were created during the tests
519 * @tparam API Tested API descriptor
522 void TestCaseBase<API>::delete_objects(void)
524 const glw::Functions& gl = context_id.getRenderContext().getFunctions();
526 /* Release all ES objects that may have been created by iterate() */
527 if (program_object_id != 0)
529 gl.deleteProgram(program_object_id);
530 program_object_id = 0;
533 /* Use default program object to be sure the objects were released. */
537 /** Releases all OpenGL ES objects that were created for test case purposes.
539 * @tparam API Tested API descriptor
542 void TestCaseBase<API>::deinit(void)
544 this->delete_objects();
547 /** Runs the actual test for each shader type.
549 * @tparam API Tested API descriptor
551 * @return QP_TEST_RESULT_FAIL - test has failed;
552 * QP_TEST_RESULT_PASS - test has succeeded;
555 tcu::TestNode::IterateResult TestCaseBase<API>::iterate(void)
557 test_shader_compilation(TestCaseBase<API>::VERTEX_SHADER_TYPE);
558 test_shader_compilation(TestCaseBase<API>::FRAGMENT_SHADER_TYPE);
560 if (API::USE_ALL_SHADER_STAGES)
562 test_shader_compilation(TestCaseBase<API>::COMPUTE_SHADER_TYPE);
563 test_shader_compilation(TestCaseBase<API>::GEOMETRY_SHADER_TYPE);
564 test_shader_compilation(TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE);
565 test_shader_compilation(TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE);
571 /** Generates a shader object of the specified type,
572 * attaches the specified shader source,
573 * compiles it, and returns the compilation result.
575 * @tparam API Tested API descriptor
577 * @param shader_source The source for the shader object.
578 * @param tested_shader_type The type of shader being compiled (vertex or fragment).
580 * @return Compilation result (GL_TRUE if the shader compilation succeeded, GL_FALSE otherwise).
583 glw::GLint TestCaseBase<API>::compile_shader_and_get_compilation_result(const std::string& tested_snippet,
584 TestShaderType tested_shader_type,
585 bool require_gpu_shader5)
587 static const char* preamble_cs = "\n"
588 "layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;\n"
591 static const char* preamble_gs = "\n"
592 "layout(points) in;\n"
593 "layout(triangle_strip, max_vertices = 4) out;\n"
596 static const char* preamble_tcs = "\n"
597 "layout(vertices = 1) out;\n"
600 static const char* preamble_tes = "\n"
601 "layout(isolines, point_mode) in;\n"
604 glw::GLint compile_status = GL_TRUE;
605 const glw::Functions& gl = context_id.getRenderContext().getFunctions();
606 glw::GLint shader_object_id = 0;
608 std::string shader_source;
610 if (true == tested_snippet.empty())
612 return compile_status;
615 if (require_gpu_shader5)
617 // Add the version number here, rather than in each individual test
618 shader_source = API::shader_version_gpu5;
622 // Add the version number here, rather than in each individual test
623 shader_source = API::shader_version;
626 /* Apply stage specific stuff */
627 switch (tested_shader_type)
629 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
631 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
633 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
634 shader_source += preamble_cs;
636 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
637 shader_source += preamble_gs;
639 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
640 shader_source += preamble_tcs;
642 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
643 shader_source += preamble_tes;
646 TCU_FAIL("Unrecognized shader type.");
650 shader_source += tested_snippet;
652 /* Prepare shader object */
653 switch (tested_shader_type)
655 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
657 shader_object_id = gl.createShader(GL_VERTEX_SHADER);
658 assert(0 == vertex_shader_object_id);
659 vertex_shader_object_id = shader_object_id;
661 GLU_EXPECT_NO_ERROR(gl.getError(), "Could not create a vertex shader.");
664 } /* case TestCaseBase<API>::VERTEX_SHADER_TYPE: */
665 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
667 shader_object_id = gl.createShader(GL_FRAGMENT_SHADER);
668 assert(0 == fragment_shader_object_id);
669 fragment_shader_object_id = shader_object_id;
671 GLU_EXPECT_NO_ERROR(gl.getError(), "Could not create a fragment shader.");
674 } /* case TestCaseBase<API>::FRAGMENT_SHADER_TYPE: */
675 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
677 shader_object_id = gl.createShader(GL_COMPUTE_SHADER);
678 assert(0 == compute_shader_object_id);
679 compute_shader_object_id = shader_object_id;
681 GLU_EXPECT_NO_ERROR(gl.getError(), "Could not create a compute shader.");
684 } /* case TestCaseBase<API>::COMPUTE_SHADER_TYPE: */
685 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
687 shader_object_id = gl.createShader(GL_GEOMETRY_SHADER);
688 assert(0 == geometry_shader_object_id);
689 geometry_shader_object_id = shader_object_id;
691 GLU_EXPECT_NO_ERROR(gl.getError(), "Could not create a geometry shader.");
694 } /* case TestCaseBase<API>::GEOMETRY_SHADER_TYPE: */
695 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
697 shader_object_id = gl.createShader(GL_TESS_CONTROL_SHADER);
698 assert(0 == tess_ctrl_shader_object_id);
699 tess_ctrl_shader_object_id = shader_object_id;
701 GLU_EXPECT_NO_ERROR(gl.getError(), "Could not create a tesselation control shader.");
704 } /* case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE: */
705 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
707 shader_object_id = gl.createShader(GL_TESS_EVALUATION_SHADER);
708 assert(0 == tess_eval_shader_object_id);
709 tess_eval_shader_object_id = shader_object_id;
711 GLU_EXPECT_NO_ERROR(gl.getError(), "Could not create a tesselation evaluation shader.");
714 } /* case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE: */
717 TCU_FAIL("Unrecognized shader type.");
721 } /* switch (tested_shader_type) */
723 /* Assign source code to the objects */
724 const char* code_ptr = shader_source.c_str();
726 #if IS_DEBUG_DUMP_ALL_SHADERS
727 context_id.getTestContext().getLog() << tcu::TestLog::Message << "Compiling: " << tcu::TestLog::EndMessage;
728 context_id.getTestContext().getLog() << tcu::TestLog::KernelSource(code_ptr);
729 #endif /* IS_DEBUG_DUMP_ALL_SHADERS */
731 gl.shaderSource(shader_object_id, 1 /* count */, &code_ptr, NULL);
732 GLU_EXPECT_NO_ERROR(gl.getError(), "glShaderSource() failed");
734 /* Compile the shader */
735 gl.compileShader(shader_object_id);
736 GLU_EXPECT_NO_ERROR(gl.getError(), "glCompileShader() failed");
738 /* Get the compilation result. */
739 gl.getShaderiv(shader_object_id, GL_COMPILE_STATUS, &compile_status);
740 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv() failed");
743 if (GL_TRUE != compile_status)
745 glw::GLint length = 0;
748 /* Error log length */
749 gl.getShaderiv(shader_object_id, GL_INFO_LOG_LENGTH, &length);
750 GLU_EXPECT_NO_ERROR(gl.getError(), "GetShaderiv");
752 /* Prepare storage */
753 message.resize(length, 0);
756 gl.getShaderInfoLog(shader_object_id, length, 0, &message[0]);
757 GLU_EXPECT_NO_ERROR(gl.getError(), "GetShaderInfoLog");
759 context_id.getTestContext().getLog() << tcu::TestLog::Message << "Error message: " << &message[0]
760 << tcu::TestLog::EndMessage;
762 #if IS_DEBUG_DUMP_ALL_SHADERS
763 #else /* IS_DEBUG_DUMP_ALL_SHADERS */
764 context_id.getTestContext().getLog() << tcu::TestLog::KernelSource(code_ptr);
765 #endif /* IS_DEBUG_DUMP_ALL_SHADERS */
767 #endif /* IS_DEBUG */
769 return compile_status;
772 /** Runs the negative test.
773 * The shader sources are considered as invalid,
774 * and the compilation of a shader object with the specified
775 * shader source is expected to fail.
777 * @tparam API Tested API descriptor
779 * @param tested_shader_type The type of shader object (can be fragment or vertex).
780 * @param shader_source The source for the shader object to be used for this test.
782 * @return QP_TEST_RESULT_FAIL - test has failed;
783 * QP_TEST_RESULT_PASS - test has succeeded;
786 tcu::TestNode::IterateResult TestCaseBase<API>::execute_negative_test(
787 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& shader_source)
789 glw::GLint compile_status = GL_FALSE;
790 const char* error_message = 0;
791 const glw::Functions& gl = context_id.getRenderContext().getFunctions();
792 bool test_result = true;
794 /* Try to generate and compile the shader object. */
795 switch (tested_shader_type)
797 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
799 "The fragment shader was expected to fail to compile, but the compilation process was successful.";
802 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
804 "The vertex shader was expected to fail to compile, but the compilation process was successful.";
808 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
810 "The compute shader was expected to fail to compile, but the compilation process was successful.";
813 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
815 "The geometry shader was expected to fail to compile, but the compilation process was successful.";
818 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
819 error_message = "The tesselation control shader was expected to fail to compile, but the compilation process "
823 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
824 error_message = "The tesselation evaluation shader was expected to fail to compile, but the compilation "
825 "process was successful.";
829 TCU_FAIL("Unrecognized shader type.");
833 } /* switch (shader_type) */
835 compile_status = compile_shader_and_get_compilation_result(shader_source, tested_shader_type);
837 if (compile_status == GL_TRUE)
839 TCU_FAIL(error_message);
844 /* Deallocate any resources used. */
845 this->delete_objects();
846 if (0 != compute_shader_object_id)
848 gl.deleteShader(compute_shader_object_id);
849 compute_shader_object_id = 0;
851 if (0 != fragment_shader_object_id)
853 gl.deleteShader(fragment_shader_object_id);
854 fragment_shader_object_id = 0;
856 if (0 != geometry_shader_object_id)
858 gl.deleteShader(geometry_shader_object_id);
859 geometry_shader_object_id = 0;
861 if (0 != tess_ctrl_shader_object_id)
863 gl.deleteShader(tess_ctrl_shader_object_id);
864 tess_ctrl_shader_object_id = 0;
866 if (0 != tess_eval_shader_object_id)
868 gl.deleteShader(tess_eval_shader_object_id);
869 tess_eval_shader_object_id = 0;
871 if (0 != vertex_shader_object_id)
873 gl.deleteShader(vertex_shader_object_id);
874 vertex_shader_object_id = 0;
877 /* Return test pass if true. */
878 if (true == test_result)
880 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
886 /** Runs the positive test.
887 * The shader sources are considered as valid,
888 * and the compilation and program linking are expected to succeed.
890 * @tparam API Tested API descriptor
892 * @param vertex_shader_source The source for the vertex shader to be used for this test.
893 * @param fragment_shader_source The source for the fragment shader to be used for this test.
894 * @param delete_generated_objects If true, the compiled shader objects will be deleted before returning.
896 * @return QP_TEST_RESULT_FAIL - test has failed;
897 * QP_TEST_RESULT_PASS - test has succeeded;
900 tcu::TestNode::IterateResult TestCaseBase<API>::execute_positive_test(const std::string& vertex_shader_source,
901 const std::string& fragment_shader_source,
902 bool delete_generated_objects,
903 bool require_gpu_shader5)
905 glw::GLint compile_status = GL_TRUE;
906 const glw::Functions& gl = context_id.getRenderContext().getFunctions();
907 glw::GLint link_status = GL_TRUE;
908 bool test_result = true;
910 /* Compile, and check the compilation result for the fragment shader object. */
911 compile_status = compile_shader_and_get_compilation_result(
912 fragment_shader_source, TestCaseBase<API>::FRAGMENT_SHADER_TYPE, require_gpu_shader5);
914 if (compile_status == GL_FALSE)
916 TCU_FAIL("The fragment shader was expected to compile successfully, but failed to compile.");
921 /* Compile, and check the compilation result for the vertex shader object. */
922 compile_status = compile_shader_and_get_compilation_result(
923 vertex_shader_source, TestCaseBase<API>::VERTEX_SHADER_TYPE, require_gpu_shader5);
925 if (compile_status == GL_FALSE)
927 TCU_FAIL("The vertex shader was expected to compile successfully, but failed to compile.");
932 if (true == test_result)
934 /* Create program object. */
935 assert(0 == program_object_id);
936 program_object_id = gl.createProgram();
937 GLU_EXPECT_NO_ERROR(gl.getError(), "Could not create a program object.");
939 /* Configure the program object */
940 gl.attachShader(program_object_id, fragment_shader_object_id);
941 gl.attachShader(program_object_id, vertex_shader_object_id);
942 GLU_EXPECT_NO_ERROR(gl.getError(), "glAttachShader() failed.");
944 gl.deleteShader(fragment_shader_object_id);
945 gl.deleteShader(vertex_shader_object_id);
946 fragment_shader_object_id = 0;
947 vertex_shader_object_id = 0;
949 /* Link the program object */
950 gl.linkProgram(program_object_id);
951 GLU_EXPECT_NO_ERROR(gl.getError(), "glLinkProgram() failed.");
953 /* Make sure the linking operation succeeded. */
954 gl.getProgramiv(program_object_id, GL_LINK_STATUS, &link_status);
955 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramiv() failed.");
957 if (link_status != GL_TRUE)
960 glw::GLint length = 0;
963 /* Get error log length */
964 gl.getProgramiv(program_object_id, GL_INFO_LOG_LENGTH, &length);
965 GLU_EXPECT_NO_ERROR(gl.getError(), "GetProgramiv");
967 message.resize(length, 0);
970 gl.getProgramInfoLog(program_object_id, length, 0, &message[0]);
971 GLU_EXPECT_NO_ERROR(gl.getError(), "GetProgramInfoLog");
973 context_id.getTestContext().getLog() << tcu::TestLog::Message << "Error message: " << &message[0]
974 << tcu::TestLog::EndMessage;
976 #if IS_DEBUG_DUMP_ALL_SHADERS
977 #else /* IS_DEBUG_DUMP_ALL_SHADERS */
978 context_id.getTestContext().getLog() << tcu::TestLog::KernelSource(vertex_shader_source);
979 context_id.getTestContext().getLog() << tcu::TestLog::KernelSource(fragment_shader_source);
980 #endif /* IS_DEBUG_DUMP_ALL_SHADERS */
981 #endif /* IS_DEBUG */
983 TCU_FAIL("Linking was expected to succeed, but the process was unsuccessful.");
989 if (delete_generated_objects)
991 /* Deallocate any resources used. */
992 this->delete_objects();
995 /* Return test pass if true. */
996 if (true == test_result)
998 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1004 /** Runs the positive test.
1005 * The shader sources are considered as valid,
1006 * and the compilation and program linking are expected to succeed.
1008 * @tparam API Tested API descriptor
1010 * @param vertex_shader_source The source for the vertex shader to be used for this test.
1011 * @param tess_ctrl_shader_source The source for the vertex shader to be used for this test.
1012 * @param tess_eval_shader_source The source for the vertex shader to be used for this test.
1013 * @param geometry_shader_source The source for the vertex shader to be used for this test.
1014 * @param fragment_shader_source The source for the vertex shader to be used for this test.
1015 * @param compute_shader_source The source for the fragment shader to be used for this test.
1016 * @param delete_generated_objects If true, the compiled shader objects will be deleted before returning.
1018 * @return QP_TEST_RESULT_FAIL - test has failed;
1019 * QP_TEST_RESULT_PASS - test has succeeded;
1021 template <class API>
1022 tcu::TestNode::IterateResult TestCaseBase<API>::execute_positive_test(
1023 const std::string& vertex_shader_source, const std::string& tess_ctrl_shader_source,
1024 const std::string& tess_eval_shader_source, const std::string& geometry_shader_source,
1025 const std::string& fragment_shader_source, const std::string& compute_shader_source, bool delete_generated_objects,
1026 bool require_gpu_shader5)
1028 glw::GLint compile_status = GL_TRUE;
1029 const glw::Functions& gl = context_id.getRenderContext().getFunctions();
1030 glw::GLint link_status = GL_TRUE;
1031 bool test_compute = !compute_shader_source.empty();
1032 bool test_result = true;
1034 if (false == test_compute)
1036 /* Compile, and check the compilation result for the fragment shader object. */
1037 compile_status = compile_shader_and_get_compilation_result(
1038 fragment_shader_source, TestCaseBase<API>::FRAGMENT_SHADER_TYPE, require_gpu_shader5);
1040 if (compile_status == GL_FALSE)
1042 TCU_FAIL("The fragment shader was expected to compile successfully, but failed to compile.");
1044 test_result = false;
1047 /* Compile, and check the compilation result for the geometry shader object. */
1048 compile_status = compile_shader_and_get_compilation_result(
1049 geometry_shader_source, TestCaseBase<API>::GEOMETRY_SHADER_TYPE, require_gpu_shader5);
1051 if (compile_status == GL_FALSE)
1053 TCU_FAIL("The geometry shader was expected to compile successfully, but failed to compile.");
1055 test_result = false;
1058 /* Compile, and check the compilation result for the te shader object. */
1059 compile_status = compile_shader_and_get_compilation_result(
1060 tess_eval_shader_source, TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE, require_gpu_shader5);
1062 if (compile_status == GL_FALSE)
1064 TCU_FAIL("The tesselation evaluation shader was expected to compile successfully, but failed to compile.");
1066 test_result = false;
1069 /* Compile, and check the compilation result for the tc shader object. */
1070 compile_status = compile_shader_and_get_compilation_result(
1071 tess_ctrl_shader_source, TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE, require_gpu_shader5);
1073 if (compile_status == GL_FALSE)
1075 TCU_FAIL("The tesselation control shader was expected to compile successfully, but failed to compile.");
1077 test_result = false;
1080 /* Compile, and check the compilation result for the vertex shader object. */
1081 compile_status = compile_shader_and_get_compilation_result(
1082 vertex_shader_source, TestCaseBase<API>::VERTEX_SHADER_TYPE, require_gpu_shader5);
1084 if (compile_status == GL_FALSE)
1086 TCU_FAIL("The vertex shader was expected to compile successfully, but failed to compile.");
1088 test_result = false;
1093 /* Compile, and check the compilation result for the compute shader object. */
1094 compile_status = compile_shader_and_get_compilation_result(
1095 compute_shader_source, TestCaseBase<API>::COMPUTE_SHADER_TYPE, require_gpu_shader5);
1097 if (compile_status == GL_FALSE)
1099 TCU_FAIL("The compute shader was expected to compile successfully, but failed to compile.");
1101 test_result = false;
1105 if (true == test_result)
1107 /* Create program object. */
1108 program_object_id = gl.createProgram();
1109 GLU_EXPECT_NO_ERROR(gl.getError(), "Could not create a program object.");
1111 /* Configure the program object */
1112 if (false == test_compute)
1114 gl.attachShader(program_object_id, fragment_shader_object_id);
1116 if (geometry_shader_object_id)
1118 gl.attachShader(program_object_id, geometry_shader_object_id);
1121 if (tess_ctrl_shader_object_id)
1123 gl.attachShader(program_object_id, tess_ctrl_shader_object_id);
1126 if (tess_eval_shader_object_id)
1128 gl.attachShader(program_object_id, tess_eval_shader_object_id);
1131 gl.attachShader(program_object_id, vertex_shader_object_id);
1135 gl.attachShader(program_object_id, compute_shader_object_id);
1137 GLU_EXPECT_NO_ERROR(gl.getError(), "glAttachShader() failed.");
1139 if (false == test_compute)
1141 gl.deleteShader(fragment_shader_object_id);
1143 if (geometry_shader_object_id)
1145 gl.deleteShader(geometry_shader_object_id);
1148 if (tess_ctrl_shader_object_id)
1150 gl.deleteShader(tess_ctrl_shader_object_id);
1153 if (tess_eval_shader_object_id)
1155 gl.deleteShader(tess_eval_shader_object_id);
1158 gl.deleteShader(vertex_shader_object_id);
1162 gl.deleteShader(compute_shader_object_id);
1165 fragment_shader_object_id = 0;
1166 vertex_shader_object_id = 0;
1167 geometry_shader_object_id = 0;
1168 tess_ctrl_shader_object_id = 0;
1169 tess_eval_shader_object_id = 0;
1170 compute_shader_object_id = 0;
1172 /* Link the program object */
1173 gl.linkProgram(program_object_id);
1174 GLU_EXPECT_NO_ERROR(gl.getError(), "glLinkProgram() failed.");
1176 /* Make sure the linking operation succeeded. */
1177 gl.getProgramiv(program_object_id, GL_LINK_STATUS, &link_status);
1178 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramiv() failed.");
1180 if (link_status != GL_TRUE)
1183 glw::GLint length = 0;
1184 std::string message;
1186 /* Get error log length */
1187 gl.getProgramiv(program_object_id, GL_INFO_LOG_LENGTH, &length);
1188 GLU_EXPECT_NO_ERROR(gl.getError(), "GetProgramiv");
1190 message.resize(length, 0);
1193 gl.getProgramInfoLog(program_object_id, length, 0, &message[0]);
1194 GLU_EXPECT_NO_ERROR(gl.getError(), "GetProgramInfoLog");
1196 context_id.getTestContext().getLog() << tcu::TestLog::Message << "Error message: " << &message[0]
1197 << tcu::TestLog::EndMessage;
1199 #if IS_DEBUG_DUMP_ALL_SHADERS
1200 if (false == test_compute)
1202 context_id.getTestContext().getLog() << tcu::TestLog::KernelSource(vertex_shader_source);
1203 context_id.getTestContext().getLog() << tcu::TestLog::KernelSource(tess_ctrl_shader_source);
1204 context_id.getTestContext().getLog() << tcu::TestLog::KernelSource(tess_eval_shader_source);
1205 context_id.getTestContext().getLog() << tcu::TestLog::KernelSource(geometry_shader_source);
1206 context_id.getTestContext().getLog() << tcu::TestLog::KernelSource(fragment_shader_source);
1210 context_id.getTestContext().getLog() << tcu::TestLog::KernelSource(compute_shader_source);
1212 #endif /* IS_DEBUG_DUMP_ALL_SHADERS */
1213 #endif /* IS_DEBUG */
1215 TCU_FAIL("Linking was expected to succeed, but the process was unsuccessful.");
1217 test_result = false;
1221 if (delete_generated_objects)
1223 /* Deallocate any resources used. */
1224 this->delete_objects();
1227 /* Return test pass if true. */
1228 if (true == test_result)
1230 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1236 /** Adds the specified @param sub_script onto the base_string @param number_of_elements times.
1237 * E.g. extend_string("a", [2], 3) would give a[2][2][2].
1239 * @tparam API Tested API descriptor
1241 * @param base_string The base string that is to be added to.
1242 * @param sub_string The string to be repeatedly added
1243 * @param number_of_elements The number of repetitions.
1245 * @return The extended string.
1247 template <class API>
1248 std::string TestCaseBase<API>::extend_string(std::string base_string, std::string sub_string, size_t number_of_elements)
1250 std::string temp_string = base_string;
1252 for (size_t sub_script_index = 0; sub_script_index < number_of_elements; sub_script_index++)
1254 temp_string += sub_string;
1260 /* Generates the shader source code for the SizedDeclarationsPrimitive
1261 * array tests, and attempts to compile each test shader, for both
1262 * vertex and fragment shaders.
1264 * @tparam API Tested API descriptor
1266 * @param tested_shader_type The type of shader that is being tested
1267 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
1270 template <class API>
1271 void SizedDeclarationsPrimitive<API>::test_shader_compilation(
1272 typename TestCaseBase<API>::TestShaderType tested_shader_type)
1274 for (size_t var_type_index = 0; var_type_index < API::n_var_types; var_type_index++)
1276 _supported_variable_types_map_const_iterator var_iterator =
1277 supported_variable_types_map.find(API::var_types[var_type_index]);
1279 if (var_iterator != supported_variable_types_map.end())
1281 /* Loop round for each var_types ("int", "uint", "float", etc.)
1282 * We are testing a[][] to a [][][][][][][][], so start counter at 2. */
1283 for (size_t max_dimension_limit = 2; max_dimension_limit <= API::MAX_ARRAY_DIMENSIONS;
1284 max_dimension_limit++)
1286 // Record the base varTypeModifier + varType
1287 std::string base_var_type = var_iterator->second.type;
1288 std::string base_variable_string = base_var_type;
1290 for (size_t base_sub_script_index = 0; base_sub_script_index <= max_dimension_limit;
1291 base_sub_script_index++)
1293 std::string shader_source = "";
1295 // Add the shader body start, and the base varTypeModifier + varType + variable name.
1296 shader_source += shader_start + " " + base_variable_string + " a";
1298 for (size_t remaining_sub_script_index = base_sub_script_index;
1299 remaining_sub_script_index < max_dimension_limit; remaining_sub_script_index++)
1301 /* Add as many array sub_scripts as we can, up to the current dimension limit. */
1302 shader_source += "[2]";
1306 shader_source += ";\n";
1309 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
1312 EXECUTE_POSITIVE_TEST(tested_shader_type, shader_source, true, false);
1314 /* From now on, we'll have an extra sub_script each time. */
1315 base_variable_string += "[2]";
1316 } /* for (int base_sub_script_index = 0; ...) */
1317 } /* for (int max_dimension_limit = 2; ...) */
1318 } /* if var_type iterator found */
1321 TCU_FAIL("Type not found.");
1323 } /* for (int var_type_index = 0; ...) */
1326 /* Generates the shader source code for the SizedDeclarationsStructTypes1
1327 * array tests, and attempts to compile each test shader, for both
1328 * vertex and fragment shaders.
1330 * @tparam API Tested API descriptor
1332 * @param tested_shader_type The type of shader that is being tested
1333 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
1335 template <class API>
1336 void SizedDeclarationsStructTypes1<API>::test_shader_compilation(
1337 typename TestCaseBase<API>::TestShaderType tested_shader_type)
1339 std::string example_struct("struct light {\n"
1340 " float intensity;\n"
1343 std::string shader_source;
1345 for (size_t max_dimension_index = 1; max_dimension_index < API::MAX_ARRAY_DIMENSIONS; max_dimension_index++)
1347 shader_source = example_struct;
1348 shader_source += shader_start;
1349 shader_source += " light[2]";
1351 for (size_t temp_dimension_index = 0; temp_dimension_index < max_dimension_index; temp_dimension_index++)
1353 shader_source += "[2]";
1356 shader_source += " x;\n";
1359 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
1362 EXECUTE_POSITIVE_TEST(tested_shader_type, shader_source, true, false);
1364 } /* for (int max_dimension_index = 1; ...) */
1367 /* Generates the shader source code for the SizedDeclarationsStructTypes2
1368 * array tests, and attempts to compile each test shader, for both
1369 * vertex and fragment shaders.
1371 * @tparam API Tested API descriptor
1373 * @param tested_shader_type The type of shader that is being tested
1374 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
1376 template <class API>
1377 void SizedDeclarationsStructTypes2<API>::test_shader_compilation(
1378 typename TestCaseBase<API>::TestShaderType tested_shader_type)
1380 std::string structure_declaration = "struct MyStructure {\n"
1385 "e[2][2][2][2][2], "
1386 "f[2][2][2][2][2][2], "
1387 "g[2][2][2][2][2][2][2], "
1388 "h[2][2][2][2][2][2][2][2];\n"
1389 "} myStructureObject;\n\n";
1390 std::string shader_source = structure_declaration;
1392 shader_source += shader_start;
1395 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
1398 EXECUTE_POSITIVE_TEST(tested_shader_type, shader_source, true, false);
1401 /* Generates the shader source code for the SizedDeclarationsStructTypes3
1402 * array tests, and attempts to compile each test shader, for both
1403 * vertex and fragment shaders.
1405 * @tparam API Tested API descriptor
1407 * @param tested_shader_type The type of shader that is being tested
1408 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
1410 template <class API>
1411 void SizedDeclarationsStructTypes3<API>::test_shader_compilation(
1412 typename TestCaseBase<API>::TestShaderType tested_shader_type)
1414 std::string example_struct("struct light {\n"
1415 " float[2] intensity;\n"
1416 " int[2] position;\n"
1418 std::string shader_source;
1420 for (size_t max_dimension_index = 1; max_dimension_index <= API::MAX_ARRAY_DIMENSIONS; max_dimension_index++)
1422 shader_source = example_struct;
1423 shader_source += shader_start;
1424 shader_source += this->extend_string(" light my_light_object", "[2]", max_dimension_index);
1425 shader_source += ";\n";
1428 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
1431 EXECUTE_POSITIVE_TEST(tested_shader_type, shader_source, true, false);
1432 } /* for (int max_dimension_index = 1; ...) */
1435 /* Generates the shader source code for the SizedDeclarationsStructTypes4
1436 * array tests, and attempts to compile each test shader, for both
1437 * vertex and fragment shaders.
1439 * @tparam API Tested API descriptor
1441 * @param tested_shader_type The type of shader that is being tested
1442 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
1444 template <class API>
1445 void SizedDeclarationsStructTypes4<API>::test_shader_compilation(
1446 typename TestCaseBase<API>::TestShaderType tested_shader_type)
1448 std::string example_struct("struct light {\n"
1449 " float[2] intensity;\n"
1450 " int[2] position;\n"
1452 std::string shader_source;
1454 for (size_t max_dimension_index = 1; max_dimension_index < API::MAX_ARRAY_DIMENSIONS; max_dimension_index++)
1456 shader_source = example_struct;
1458 for (size_t temp_dimension_index = 0; temp_dimension_index < max_dimension_index; temp_dimension_index++)
1460 shader_source += "[2]";
1462 shader_source += ";\n\n";
1463 shader_source += shader_start;
1466 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
1469 EXECUTE_POSITIVE_TEST(tested_shader_type, shader_source, true, false);
1470 } /* for (int max_dimension_index = 1; ...) */
1473 /* Generates the shader source code for the SizedDeclarationsTypenameStyle1
1474 * array tests, and attempts to compile each test shader, for both
1475 * vertex and fragment shaders.
1477 * @tparam API Tested API descriptor
1479 * @param tested_shader_type The type of shader that is being tested
1480 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
1482 template <class API>
1483 void SizedDeclarationsTypenameStyle1<API>::test_shader_compilation(
1484 typename TestCaseBase<API>::TestShaderType tested_shader_type)
1486 for (size_t max_dimension_index = 1; max_dimension_index <= API::MAX_ARRAY_DIMENSIONS; max_dimension_index++)
1488 std::string shader_source = shader_start;
1490 shader_source += this->extend_string(" float", "[2]", max_dimension_index);
1491 shader_source += this->extend_string(" x", "[2]", API::MAX_ARRAY_DIMENSIONS - max_dimension_index);
1492 shader_source += ";\n";
1495 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
1498 EXECUTE_POSITIVE_TEST(tested_shader_type, shader_source, true, false);
1499 } /* for (int max_dimension_index = 1; ...) */
1502 /* Generates the shader source code for the SizedDeclarationsTypenameStyle2
1503 * array tests, and attempts to compile each test shader, for both
1504 * vertex and fragment shaders.
1506 * @tparam API Tested API descriptor
1508 * @param tested_shader_type The type of shader that is being tested
1509 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
1511 template <class API>
1512 void SizedDeclarationsTypenameStyle2<API>::test_shader_compilation(
1513 typename TestCaseBase<API>::TestShaderType tested_shader_type)
1515 std::string shader_source = shader_start;
1517 shader_source += this->extend_string(" float", "[2]", 2);
1518 shader_source += this->extend_string(" a", "[2]", 0);
1519 shader_source += ", ";
1520 shader_source += this->extend_string("b", "[2]", 1);
1521 shader_source += ", ";
1522 shader_source += this->extend_string("c", "[2]", 2);
1523 shader_source += ", ";
1524 shader_source += this->extend_string("d", "[2]", 3);
1525 shader_source += ", ";
1526 shader_source += this->extend_string("e", "[2]", 4);
1527 shader_source += ", ";
1528 shader_source += this->extend_string("f", "[2]", 5);
1529 shader_source += ", ";
1530 shader_source += this->extend_string("g", "[2]", 6);
1531 shader_source += ";\n";
1534 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
1537 EXECUTE_POSITIVE_TEST(tested_shader_type, shader_source, true, false);
1540 /* Generates the shader source code for the SizedDeclarationsTypenameStyle3
1541 * array tests, and attempts to compile each test shader, for both
1542 * vertex and fragment shaders.
1544 * @tparam API Tested API descriptor
1546 * @param tested_shader_type The type of shader that is being tested
1547 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
1549 template <class API>
1550 void SizedDeclarationsTypenameStyle3<API>::test_shader_compilation(
1551 typename TestCaseBase<API>::TestShaderType tested_shader_type)
1553 std::string shader_source = "struct{\n" + this->extend_string(" float", "[2]", 2);
1555 shader_source += this->extend_string(" a", "[2]", API::MAX_ARRAY_DIMENSIONS - API::MAX_ARRAY_DIMENSIONS);
1556 shader_source += ",";
1557 shader_source += this->extend_string(" b", "[2]", 1);
1558 shader_source += ",";
1559 shader_source += this->extend_string(" c", "[2]", 2);
1560 shader_source += ",";
1561 shader_source += this->extend_string(" d", "[2]", 3);
1562 shader_source += ",";
1563 shader_source += this->extend_string(" e", "[2]", 4);
1564 shader_source += ",";
1565 shader_source += this->extend_string(" f", "[2]", 5);
1566 shader_source += ",";
1567 shader_source += this->extend_string(" g", "[2]", 6);
1568 shader_source += ";\n} x;\n\n";
1569 shader_source += shader_start;
1572 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
1575 EXECUTE_POSITIVE_TEST(tested_shader_type, shader_source, true, false);
1578 /* Generates the shader source code for the SizedDeclarationsTypenameStyle4
1579 * array tests, and attempts to compile each test shader, for both
1580 * vertex and fragment shaders.
1582 * @tparam API Tested API descriptor
1584 * @param tested_shader_type The type of shader that is being tested
1585 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
1587 template <class API>
1588 void SizedDeclarationsTypenameStyle4<API>::test_shader_compilation(
1589 typename TestCaseBase<API>::TestShaderType tested_shader_type)
1591 std::string example_struct_begin("struct light {\n");
1592 std::string example_struct_end("};\n\n");
1594 for (size_t max_dimension_index = 1; max_dimension_index <= API::MAX_ARRAY_DIMENSIONS; max_dimension_index++)
1596 std::string shader_source = example_struct_begin;
1598 shader_source += this->extend_string(" float", "[2]", max_dimension_index);
1599 shader_source += this->extend_string(" x", "[2]", API::MAX_ARRAY_DIMENSIONS - max_dimension_index);
1600 shader_source += ";\n";
1601 shader_source += example_struct_end;
1602 shader_source += shader_start;
1605 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
1608 EXECUTE_POSITIVE_TEST(tested_shader_type, shader_source, true, false);
1609 } /* for (int max_dimension_index = 1; ...) */
1612 /* Generates the shader source code for the SizedDeclarationsTypenameStyle5
1613 * array tests, and attempts to compile each test shader, for both
1614 * vertex and fragment shaders.
1616 * @tparam API Tested API descriptor
1618 * @param tested_shader_type The type of shader that is being tested
1619 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
1621 template <class API>
1622 void SizedDeclarationsTypenameStyle5<API>::test_shader_compilation(
1623 typename TestCaseBase<API>::TestShaderType tested_shader_type)
1625 std::string example_struct_begin("struct light {\n");
1626 std::string example_struct_end("};\n\n");
1628 std::string shader_source = example_struct_begin;
1630 shader_source += this->extend_string(" float", "[2]", 2);
1631 shader_source += this->extend_string(" a", "[2]", API::MAX_ARRAY_DIMENSIONS - API::MAX_ARRAY_DIMENSIONS);
1632 shader_source += ", ";
1633 shader_source += this->extend_string("b", "[2]", 2);
1634 shader_source += ", ";
1635 shader_source += this->extend_string("c", "[2]", 3);
1636 shader_source += ", ";
1637 shader_source += this->extend_string("d", "[2]", 4);
1638 shader_source += ", ";
1639 shader_source += this->extend_string("e", "[2]", 5);
1640 shader_source += ", ";
1641 shader_source += this->extend_string("f", "[2]", 6);
1642 shader_source += ";\n";
1643 shader_source += example_struct_end;
1644 shader_source += shader_start;
1647 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
1650 EXECUTE_POSITIVE_TEST(tested_shader_type, shader_source, true, false);
1653 /* Generates the shader source code for the SizedDeclarationsFunctionParams
1654 * array tests, and attempts to compile each test shader, for both
1655 * vertex and fragment shaders.
1657 * @tparam API Tested API descriptor
1659 * @param tested_shader_type The type of shader that is being tested
1660 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
1662 template <class API>
1663 void SizedDeclarationsFunctionParams<API>::test_shader_compilation(
1664 typename TestCaseBase<API>::TestShaderType tested_shader_type)
1666 size_t dimension_index = 0;
1667 std::string example_struct1("\nvoid my_function(");
1668 std::string example_struct2(")\n"
1671 std::string base_variable_string;
1672 std::string variable_basenames[API::MAX_ARRAY_DIMENSIONS] = { "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8" };
1673 std::string full_variable_names[API::MAX_ARRAY_DIMENSIONS];
1675 for (size_t max_dimension_index = 0; max_dimension_index < API::MAX_ARRAY_DIMENSIONS; max_dimension_index++)
1677 full_variable_names[max_dimension_index] =
1678 this->extend_string(variable_basenames[max_dimension_index], "[2]", max_dimension_index + 1);
1681 for (size_t max_dimension_index = 0; max_dimension_index < API::MAX_ARRAY_DIMENSIONS; max_dimension_index++)
1683 base_variable_string += "float ";
1684 base_variable_string += full_variable_names[max_dimension_index];
1685 base_variable_string += ";\n";
1688 base_variable_string += example_struct1;
1689 base_variable_string += this->extend_string("float a", "[2]", 1);
1690 base_variable_string += ", ";
1691 base_variable_string += this->extend_string("float b", "[2]", 2);
1692 base_variable_string += ", ";
1693 base_variable_string += this->extend_string("float c", "[2]", 3);
1694 base_variable_string += ", ";
1695 base_variable_string += this->extend_string("float d", "[2]", 4);
1696 base_variable_string += ", ";
1697 base_variable_string += this->extend_string("float e", "[2]", 5);
1698 base_variable_string += ", ";
1699 base_variable_string += this->extend_string("float f", "[2]", 6);
1700 base_variable_string += ", ";
1701 base_variable_string += this->extend_string("float g", "[2]", 7);
1702 base_variable_string += ", ";
1703 base_variable_string += this->extend_string("float h", "[2]", 8);
1704 base_variable_string += example_struct2;
1706 std::string shader_source = base_variable_string;
1708 shader_source += shader_start;
1709 shader_source += " my_function(";
1711 for (dimension_index = 0; dimension_index < API::MAX_ARRAY_DIMENSIONS - 1; dimension_index++)
1713 shader_source += variable_basenames[dimension_index];
1714 shader_source += ", ";
1717 shader_source += variable_basenames[dimension_index];
1718 shader_source += ");\n";
1721 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
1724 EXECUTE_POSITIVE_TEST(tested_shader_type, shader_source, true, false);
1726 /* Only the previous case should succeed, so start from index 1 rather than 0.
1727 * The other cases should fail, so only compile them, rather than trying to also link them.
1728 * We'll swap items 2/3, then 2/4, then 2/5, then 2/6, ...
1729 * Then we'll swap items 3/4, then 3/5, ...
1730 * Repeat, starting for 4/5-8, 5/6-8, 6/7-8...
1731 * Finally, we'll swap items 7/8
1733 for (size_t swap_item = 1; swap_item < API::MAX_ARRAY_DIMENSIONS; swap_item++)
1735 for (size_t max_dimension_index = swap_item + 1; max_dimension_index < API::MAX_ARRAY_DIMENSIONS;
1736 max_dimension_index++)
1738 std::string temp = variable_basenames[swap_item];
1740 shader_source = base_variable_string;
1741 variable_basenames[swap_item] = variable_basenames[max_dimension_index];
1742 variable_basenames[max_dimension_index] = temp;
1744 shader_source += shader_start;
1745 shader_source += " my_function(";
1747 for (dimension_index = 0; dimension_index < API::MAX_ARRAY_DIMENSIONS - 1; dimension_index++)
1749 shader_source += variable_basenames[dimension_index];
1750 shader_source += ", ";
1753 shader_source += variable_basenames[dimension_index];
1754 shader_source += ");\n";
1756 temp = variable_basenames[swap_item];
1757 variable_basenames[swap_item] = variable_basenames[max_dimension_index];
1758 variable_basenames[max_dimension_index] = temp;
1761 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
1764 this->execute_negative_test(tested_shader_type, shader_source);
1765 } /* for (int max_dimension_index = swap_item + 1; ...) */
1766 } /* for (int swap_item = 1; ...) */
1769 /* Generates the shader source code for the sized_declarations_invalid_sizes1
1770 * array tests, and attempts to compile each test shader, for both
1771 * vertex and fragment shaders.
1773 * @tparam API Tested API descriptor
1775 * @param tested_shader_type The type of shader that is being tested
1776 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
1778 template <class API>
1779 void sized_declarations_invalid_sizes1<API>::test_shader_compilation(
1780 typename TestCaseBase<API>::TestShaderType tested_shader_type)
1782 std::string invalid_declarations[] = {
1783 "float x[2][2][2][0];\n", "float x[2][2][0][2];\n", "float x[2][0][2][2];\n", "float x[0][2][2][2];\n",
1784 "float x[2][2][0][0];\n", "float x[2][0][2][0];\n", "float x[0][2][2][0];\n", "float x[2][0][0][2];\n",
1785 "float x[0][2][0][2];\n", "float x[0][0][2][2];\n", "float x[2][0][0][0];\n", "float x[0][2][0][0];\n",
1786 "float x[0][0][2][0];\n", "float x[0][0][0][2];\n", "float x[0][0][0][0];\n"
1789 for (size_t invalid_declarations_index = 0;
1790 invalid_declarations_index < sizeof(invalid_declarations) / sizeof(invalid_declarations);
1791 invalid_declarations_index++)
1793 std::string shader_source;
1795 shader_source = shader_start;
1796 shader_source += invalid_declarations[invalid_declarations_index];
1799 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
1802 this->execute_negative_test(tested_shader_type, shader_source);
1803 } /* for (int invalid_declarations_index = 0; ...) */
1806 /* Generates the shader source code for the sized_declarations_invalid_sizes2
1807 * array tests, and attempts to compile each test shader, for both
1808 * vertex and fragment shaders.
1810 * @tparam API Tested API descriptor
1812 * @param tested_shader_type The type of shader that is being tested
1813 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
1815 template <class API>
1816 void sized_declarations_invalid_sizes2<API>::test_shader_compilation(
1817 typename TestCaseBase<API>::TestShaderType tested_shader_type)
1819 std::string invalid_declarations[] = {
1820 " float x[2][2][2][-1];\n", " float x[2][2][-1][2];\n", " float x[2][-1][2][2];\n",
1821 " float x[-1][2][2][2];\n", " float x[2][2][-1][-1];\n", " float x[2][-1][2][-1];\n",
1822 " float x[-1][2][2][-1];\n", " float x[2][-1][-1][2];\n", " float x[-1][2][-1][2];\n",
1823 " float x[-1][-1][2][2];\n", " float x[2][-1][-1][-1];\n", " float x[-1][2][-1][-1];\n",
1824 " float x[-1][-1][2][-1];\n", " float x[-1][-1][-1][2];\n", " float x[-1][-1][-1][-1];\n"
1827 for (size_t invalid_declarations_index = 0;
1828 invalid_declarations_index < sizeof(invalid_declarations) / sizeof(invalid_declarations);
1829 invalid_declarations_index++)
1831 std::string shader_source;
1833 shader_source = shader_start;
1834 shader_source += invalid_declarations[invalid_declarations_index];
1837 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
1840 this->execute_negative_test(tested_shader_type, shader_source);
1841 } /* for (int invalid_declarations_index = 0; ...) */
1844 /* Generates the shader source code for the sized_declarations_invalid_sizes3
1845 * array tests, and attempts to compile each test shader, for both
1846 * vertex and fragment shaders.
1848 * @tparam API Tested API descriptor
1850 * @param tested_shader_type The type of shader that is being tested
1851 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
1853 template <class API>
1854 void sized_declarations_invalid_sizes3<API>::test_shader_compilation(
1855 typename TestCaseBase<API>::TestShaderType tested_shader_type)
1857 std::string invalid_declarations[] = {
1858 " float x[2][2][2][a];\n", " float x[2][2][a][2];\n", " float x[2][a][2][2];\n",
1859 " float x[a][2][2][2];\n", " float x[2][2][a][a];\n", " float x[2][a][2][a];\n",
1860 " float x[a][2][2][a];\n", " float x[2][a][a][2];\n", " float x[a][2][a][2];\n",
1861 " float x[a][a][2][2];\n", " float x[2][a][a][a];\n", " float x[a][2][a][a];\n",
1862 " float x[a][a][2][a];\n", " float x[a][a][a][2];\n", " float x[a][a][a][a];\n"
1864 std::string non_constant_variable_declaration = " uint a = 2u;\n";
1866 for (size_t invalid_declarations_index = 0;
1867 invalid_declarations_index < sizeof(invalid_declarations) / sizeof(invalid_declarations);
1868 invalid_declarations_index++)
1870 std::string shader_source;
1872 shader_source = shader_start;
1873 shader_source += non_constant_variable_declaration;
1874 shader_source += invalid_declarations[invalid_declarations_index];
1877 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
1880 this->execute_negative_test(tested_shader_type, shader_source);
1881 } /* for (int invalid_declarations_index = 0; ...) */
1884 /* Generates the shader source code for the sized_declarations_invalid_sizes4
1885 * array tests, and attempts to compile each test shader, for both
1886 * vertex and fragment shaders.
1888 * @tparam API Tested API descriptor
1890 * @param tested_shader_type The type of shader that is being tested
1891 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
1893 template <class API>
1894 void sized_declarations_invalid_sizes4<API>::test_shader_compilation(
1895 typename TestCaseBase<API>::TestShaderType tested_shader_type)
1897 std::string input[] = { " float x[2,2][2][2];\n", " float x[2][2,2][2];\n", " float x[2][2][2,2];\n",
1898 " float x[2,2,2][2];\n", " float x[2][2,2,2];\n", " float x[2,2,2,2];\n" };
1900 for (size_t string_index = 0; string_index < sizeof(input) / sizeof(input[0]); string_index++)
1902 std::string shader_source;
1904 shader_source += shader_start;
1905 shader_source += input[string_index];
1908 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
1911 this->execute_negative_test(tested_shader_type, shader_source);
1912 } /* for (int string_index = 0; ...) */
1915 /* Constructs a suitable constructor for the specified number of dimensions.
1917 * @tparam API Tested API descriptor
1919 * @param var_type The type of the variable
1920 * @param dimension_index The current recursion level (counts down)
1921 * @param init_string The initialisation string
1923 template <class API>
1924 std::string ConstructorsAndUnsizedDeclConstructors1<API>::recursively_initialise(std::string var_type,
1925 size_t dimension_index,
1926 std::string init_string)
1928 std::string temp_string;
1930 if (dimension_index == 0)
1932 temp_string = init_string;
1936 std::string prefix = "\n";
1938 for (size_t indent_index = dimension_index; indent_index < (API::MAX_ARRAY_DIMENSIONS + 1); indent_index++)
1943 prefix += this->extend_string(var_type, "[]", dimension_index);
1945 for (int sub_script_index = 0; sub_script_index < 2; sub_script_index++)
1947 temp_string += prefix;
1948 temp_string += recursively_initialise(var_type, dimension_index - 1, init_string);
1950 if (sub_script_index == 1)
1961 /* Generates the shader source code for the ConstructorsAndUnsizedDeclConstructors1
1962 * array tests, and attempts to compile each test shader, for both
1963 * vertex and fragment shaders.
1965 * @tparam API Tested API descriptor
1967 * @param tested_shader_type The type of shader that is being tested
1968 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
1970 template <class API>
1971 void ConstructorsAndUnsizedDeclConstructors1<API>::test_shader_compilation(
1972 typename TestCaseBase<API>::TestShaderType tested_shader_type)
1974 //vec4 color = vec4(0.0, 1.0, 0.0, 1.0);
1975 int num_var_types = API::n_var_types;
1977 for (int var_type_index = 0; var_type_index < num_var_types; var_type_index++)
1979 _supported_variable_types_map_const_iterator var_iterator =
1980 supported_variable_types_map.find(API::var_types[var_type_index]);
1982 if (var_iterator != supported_variable_types_map.end())
1984 for (size_t max_dimension_index = 2; max_dimension_index < API::MAX_ARRAY_DIMENSIONS; max_dimension_index++)
1986 std::string base_variable_string =
1987 this->extend_string(" " + var_iterator->second.type + " a", "[]", max_dimension_index);
1989 base_variable_string += " = ";
1990 base_variable_string += recursively_initialise(var_iterator->second.type, max_dimension_index,
1991 var_iterator->second.initializer_with_ones);
1992 base_variable_string += ";\n\n";
1994 std::string shader_source = shader_start + base_variable_string;
1997 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
2000 EXECUTE_POSITIVE_TEST(tested_shader_type, shader_source, true, false);
2001 } /* for (int max_dimension_index = 1; ...) */
2002 } /* if var_type iterator found */
2005 TCU_FAIL("Type not found.");
2007 } /* for (int var_type_index = 0; ...) */
2009 for (int var_type_index = 0; var_type_index < num_var_types; var_type_index++)
2011 _supported_variable_types_map_const_iterator var_iterator =
2012 supported_variable_types_map.find(API::var_types[var_type_index]);
2014 if (var_iterator != supported_variable_types_map.end())
2016 std::string base_structure = "struct my_structure\n";
2018 base_structure += "{\n";
2019 base_structure += " " + var_iterator->second.type + " b;\n";
2020 base_structure += " " + var_iterator->second.type + " c;\n";
2021 base_structure += "};\n\n";
2023 for (size_t max_dimension_index = 1; max_dimension_index < API::MAX_ARRAY_DIMENSIONS; max_dimension_index++)
2025 std::string outer_separator = "(";
2026 std::string base_variable_string;
2028 base_variable_string +=
2029 this->extend_string(" " + var_iterator->second.type + " a", "[2]", max_dimension_index);
2030 base_variable_string += " = ";
2031 base_variable_string += recursively_initialise(var_iterator->second.type, max_dimension_index,
2032 var_iterator->second.initializer_with_ones);
2033 base_variable_string += ";\n\n";
2035 std::string shader_source = base_structure + shader_start + base_variable_string;
2038 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
2041 EXECUTE_POSITIVE_TEST(tested_shader_type, shader_source, true, false);
2042 } /* for (int max_dimension_index = 1; ...) */
2043 } /* if var_type iterator found */
2046 TCU_FAIL("Type not found.");
2048 } /* for (int var_type_index = 0; ...) */
2051 /* Generates the shader source code for the ConstructorsAndUnsizedDeclConstructors2
2052 * array tests, and attempts to compile each test shader, for both
2053 * vertex and fragment shaders.
2055 * @tparam API Tested API descriptor
2057 * @param tested_shader_type The type of shader that is being tested
2058 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
2060 template <class API>
2061 void ConstructorsAndUnsizedDeclConstructors2<API>::test_shader_compilation(
2062 typename TestCaseBase<API>::TestShaderType tested_shader_type)
2064 std::string base_variable_string = " float[2][2] x = float[2][2](float[4](1.0, 2.0, 3.0, 4.0));\n";
2065 std::string shader_source = shader_start + base_variable_string;
2068 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
2071 this->execute_negative_test(tested_shader_type, shader_source);
2073 base_variable_string = "float[2][2] x = float[2][2](float[1][4](float[4](1.0, 2.0, 3.0, 4.0)));\n\n";
2074 shader_source = base_variable_string + shader_start;
2077 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
2080 this->execute_negative_test(tested_shader_type, shader_source);
2083 /* Generates the shader source code for the ConstructorsAndUnsizedDeclUnsizedConstructors
2084 * array tests, and attempts to compile each test shader, for both
2085 * vertex and fragment shaders.
2087 * @tparam API Tested API descriptor
2089 * @param tested_shader_type The type of shader that is being tested
2090 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
2092 template <class API>
2093 void ConstructorsAndUnsizedDeclUnsizedConstructors<API>::test_shader_compilation(
2094 typename TestCaseBase<API>::TestShaderType tested_shader_type)
2096 std::string shader_variable_declarations = "= float[2][1][2][1](\n"
2097 " float[1][2][1](\n"
2099 " float[1](12.3), float[1](54.2) \n"
2102 " float[1][2][1](\n"
2104 " float[1]( 3.2), float[1]( 7.4) \n"
2109 std::string input[] = { "float a[2][1][2][]", "float a[2][1][][1]", "float a[2][1][][]", "float a[2][][2][1]",
2110 "float a[2][][2][]", "float a[2][][][1]", "float a[2][][][]", "float a[][1][2][1]",
2111 "float a[][1][2][]", "float a[][1][][1]", "float a[][1][][]", "float a[][][2][1]",
2112 "float a[][][2][]", "float a[][][][1]", "float a[][][][]" };
2114 for (size_t string_index = 0; string_index < sizeof(input) / sizeof(input[0]); string_index++)
2116 std::string shader_source = shader_start + " " + input[string_index] + shader_variable_declarations;
2119 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
2122 EXECUTE_POSITIVE_TEST(tested_shader_type, shader_source, true, false);
2123 } /* for (int string_index = 0; ...) */
2126 /* Generates the shader source code for the ConstructorsAndUnsizedDeclConst
2127 * array tests, and attempts to compile each test shader, for both
2128 * vertex and fragment shaders.
2130 * @tparam API Tested API descriptor
2132 * @param tested_shader_type The type of shader that is being tested
2133 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
2135 template <class API>
2136 void ConstructorsAndUnsizedDeclConst<API>::test_shader_compilation(
2137 typename TestCaseBase<API>::TestShaderType tested_shader_type)
2139 std::string shader_source = "const float[2][2] x = float[2][2](float[2](1.0, 2.0), float[2](3.0, 4.0));\n\n";
2140 shader_source += shader_start;
2143 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
2146 EXECUTE_POSITIVE_TEST(tested_shader_type, shader_source, true, false);
2149 /* Generates the shader source code for the ConstructorsAndUnsizedDeclInvalidConstructors1
2150 * array tests, and attempts to compile each test shader, for both
2151 * vertex and fragment shaders.
2153 * @tparam API Tested API descriptor
2155 * @param tested_shader_type The type of shader that is being tested
2156 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
2158 template <class API>
2159 void ConstructorsAndUnsizedDeclInvalidConstructors1<API>::test_shader_compilation(
2160 typename TestCaseBase<API>::TestShaderType tested_shader_type)
2162 int num_var_types = sizeof(opaque_var_types) / sizeof(opaque_var_types[0]);
2164 for (int var_type_index = 0; var_type_index < num_var_types; var_type_index++)
2166 _supported_variable_types_map_const_iterator var_iterator =
2167 supported_variable_types_map.find(opaque_var_types[var_type_index]);
2169 if (var_iterator != supported_variable_types_map.end())
2171 std::string base_variable_string =
2172 "uniform " + var_iterator->second.precision + " " + var_iterator->second.type + " my_sampler1;\n" +
2173 "uniform " + var_iterator->second.precision + " " + var_iterator->second.type + " my_sampler2;\n" +
2174 "uniform " + var_iterator->second.precision + " " + var_iterator->second.type + " my_sampler3;\n" +
2175 "uniform " + var_iterator->second.precision + " " + var_iterator->second.type + " my_sampler4;\n\n";
2177 std::string shader_source = base_variable_string + shader_start;
2178 shader_source += " const " + var_iterator->second.type + "[2][2] x = " + var_iterator->second.type +
2179 "[2][2](" + var_iterator->second.type + "[2](my_sampler1, my_sampler2), " +
2180 var_iterator->second.type + "[2](my_sampler3, my_sampler4));\n\n";
2183 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
2186 this->execute_negative_test(tested_shader_type, shader_source);
2187 } /* if var_type iterator found */
2190 TCU_FAIL("Type not found.");
2192 } /* for (int var_type_index = 0; ...) */
2195 /* Generates the shader source code for the ConstructorsAndUnsizedDeclInvalidConstructors2
2196 * array tests, and attempts to compile each test shader, for both
2197 * vertex and fragment shaders.
2199 * @tparam API Tested API descriptor
2201 * @param tested_shader_type The type of shader that is being tested
2202 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
2204 template <class API>
2205 void ConstructorsAndUnsizedDeclInvalidConstructors2<API>::test_shader_compilation(
2206 typename TestCaseBase<API>::TestShaderType tested_shader_type)
2208 std::string invalid_initializers[] = { " int x[2][2][0]; \n", " int x[2][0][2]; \n", " int x[0][2][2]; \n",
2209 " int x[2][0][0]; \n", " int x[0][2][0]; \n", " int x[0][0][2]; \n",
2210 " int x[0][0][0]; \n" };
2212 for (size_t invalid_initializers_index = 0;
2213 invalid_initializers_index < sizeof(invalid_initializers) / sizeof(invalid_initializers[0]);
2214 invalid_initializers_index++)
2216 std::string shader_source;
2218 shader_source = shader_start;
2219 shader_source += invalid_initializers[invalid_initializers_index];
2222 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
2225 this->execute_negative_test(tested_shader_type, shader_source);
2226 } /* for (int invalid_initializers_index = 0; ...) */
2229 /* Generates the shader source code for the ConstructorsAndUnsizedDeclInvalidConstructors3
2230 * array tests, and attempts to compile each test shader, for both
2231 * vertex and fragment shaders.
2233 * @tparam API Tested API descriptor
2235 * @param tested_shader_type The type of shader that is being tested
2236 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
2238 template <class API>
2239 void ConstructorsAndUnsizedDeclInvalidConstructors3<API>::test_shader_compilation(
2240 typename TestCaseBase<API>::TestShaderType tested_shader_type)
2242 std::string invalid_initializers[] = { " int x[2][2][-1]; \n", " int x[2][-1][2]; \n",
2243 " int x[-1][2][2]; \n", " int x[2][-1][-1]; \n",
2244 " int x[-1][2][-1]; \n", " int x[-1][-1][2]; \n",
2245 " int x[-1][-1][-1]; \n" };
2247 for (size_t invalid_initializers_index = 0;
2248 invalid_initializers_index < sizeof(invalid_initializers) / sizeof(invalid_initializers[0]);
2249 invalid_initializers_index++)
2251 std::string shader_source;
2253 shader_source = shader_start;
2254 shader_source += invalid_initializers[invalid_initializers_index];
2257 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
2260 this->execute_negative_test(tested_shader_type, shader_source);
2261 } /* for (int invalid_initializers_index = 0; ...) */
2264 /* Generates the shader source code for the ConstructorsAndUnsizedDeclInvalidConstructors4
2265 * array tests, and attempts to compile each test shader, for both
2266 * vertex and fragment shaders.
2268 * @tparam API Tested API descriptor
2270 * @param tested_shader_type The type of shader that is being tested
2271 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
2273 template <class API>
2274 void ConstructorsAndUnsizedDeclInvalidConstructors4<API>::test_shader_compilation(
2275 typename TestCaseBase<API>::TestShaderType tested_shader_type)
2277 std::string invalid_initializers[] = { " int x[2][2][a]; \n", " int x[2][a][2]; \n", " int x[a][2][2]; \n",
2278 " int x[2][a][a]; \n", " int x[a][2][a]; \n", " int x[a][a][2]; \n",
2279 " int x[a][a][a]; \n" };
2280 std::string non_constant_variable_init = " uint a = 2u;\n";
2282 for (size_t invalid_initializers_index = 0;
2283 invalid_initializers_index < sizeof(invalid_initializers) / sizeof(invalid_initializers[0]);
2284 invalid_initializers_index++)
2286 std::string shader_source;
2288 shader_source = shader_start;
2289 shader_source += non_constant_variable_init;
2290 shader_source += invalid_initializers[invalid_initializers_index];
2293 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
2296 this->execute_negative_test(tested_shader_type, shader_source);
2297 } /* for (int invalid_initializers_index = 0; ...) */
2300 /* Generates the shader source code for the ConstructorsAndUnsizedDeclConstructorSizing1
2301 * array tests, and attempts to compile each test shader, for both
2302 * vertex and fragment shaders.
2304 * @tparam API Tested API descriptor
2306 * @param tested_shader_type The type of shader that is being tested
2307 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
2309 template <class API>
2310 void ConstructorsAndUnsizedDeclConstructorSizing1<API>::test_shader_compilation(
2311 typename TestCaseBase<API>::TestShaderType tested_shader_type)
2313 std::string valid_size_initializers[] = { "[1][1][1][]", "[1][1][][1]", "[1][][1][1]", "[][1][1][1]", "[1][1][][]",
2314 "[1][][1][]", "[][1][1][]", "[1][][][1]", "[][1][][1]", "[][][1][1]",
2315 "[1][][][]", "[][1][][]", "[][][1][]", "[][][][1]", "[][][][]" };
2317 for (size_t var_type_index = 0; var_type_index < API::n_var_types; var_type_index++)
2319 _supported_variable_types_map_const_iterator var_iterator =
2320 supported_variable_types_map.find(API::var_types[var_type_index]);
2322 if (var_iterator != supported_variable_types_map.end())
2324 for (size_t valid_size_initializers_index = 0;
2325 valid_size_initializers_index < sizeof(valid_size_initializers) / sizeof(valid_size_initializers[0]);
2326 valid_size_initializers_index++)
2328 std::string shader_source;
2329 std::string variable_constructor =
2330 " " + var_iterator->second.type + " x" + valid_size_initializers[valid_size_initializers_index] +
2331 " = " + var_iterator->second.type + "[1][1][1][1](" + var_iterator->second.type + "[1][1][1](" +
2332 var_iterator->second.type + "[1][1](" + var_iterator->second.type + "[1](" +
2333 var_iterator->second.initializer_with_zeroes + "))));\n";
2335 shader_source = shader_start;
2336 shader_source += variable_constructor;
2339 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
2342 EXECUTE_POSITIVE_TEST(tested_shader_type, shader_source, true, false);
2343 } /* for (int valid_size_initializers_index = 0; ...) */
2344 } /* if var_type iterator found */
2347 TCU_FAIL("Type not found.");
2349 } /* for (int var_type_index = 0; ...) */
2352 /* Generates the shader source code for the ConstructorsAndUnsizedDeclConstructorSizing2
2353 * array tests, and attempts to compile each test shader, for both
2354 * vertex and fragment shaders.
2356 * @tparam API Tested API descriptor
2358 * @param tested_shader_type The type of shader that is being tested
2359 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
2361 template <class API>
2362 void ConstructorsAndUnsizedDeclConstructorSizing2<API>::test_shader_compilation(
2363 typename TestCaseBase<API>::TestShaderType tested_shader_type)
2365 std::string shader_source = shader_start;
2367 shader_source += " float[] a ="
2368 " float[](1.0, 2.0),"
2371 " float[](1.0, 2.0),"
2372 " float[](3.0, 4.0)"
2385 " float[](1.0, 2.0),"
2386 " float[](3.0, 4.0),"
2387 " float[](5.0, 6.0)"
2392 " float[](1.0, 2.0),"
2393 " float[](3.0, 4.0),"
2394 " float[](5.0, 6.0)"
2432 " float[][][][][][]("
2444 " float[][][][][][][]("
2445 " float[][][][][][]("
2458 " float[][][][][][][][]("
2459 " float[][][][][][][]("
2460 " float[][][][][][]("
2475 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
2478 EXECUTE_POSITIVE_TEST(tested_shader_type, shader_source, true, false);
2481 /* Constructs a suitable constructor for the specified number of dimensions.
2483 * @tparam API Tested API descriptor
2485 * @param var_type The type of the variable
2486 * @param dimension_index The current recursion level (counts down)
2487 * @param init_string The initialisation string
2489 template <class API>
2490 std::string ConstructorsAndUnsizedDeclStructConstructors<API>::recursively_initialise(std::string var_type,
2491 size_t dimension_index,
2492 std::string init_string)
2494 std::string temp_string;
2496 if (dimension_index == 0)
2498 temp_string = var_type + "(" + init_string + ")";
2502 std::string prefix = "\n";
2504 for (size_t indent_index = dimension_index; indent_index < (API::MAX_ARRAY_DIMENSIONS + 1); indent_index++)
2509 prefix += this->extend_string(var_type, "[]", dimension_index);
2512 for (int sub_script_index = 0; sub_script_index < 2; sub_script_index++)
2514 temp_string += prefix;
2515 temp_string += recursively_initialise(var_type, dimension_index - 1, init_string);
2518 if (dimension_index == 1)
2529 /* Generates the shader source code for the ConstructorsAndUnsizedDeclStructConstructors
2530 * array tests, and attempts to compile each test shader, for both
2531 * vertex and fragment shaders.
2533 * @tparam API Tested API descriptor
2535 * @param tested_shader_type The type of shader that is being tested
2536 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
2538 template <class API>
2539 void ConstructorsAndUnsizedDeclStructConstructors<API>::test_shader_compilation(
2540 typename TestCaseBase<API>::TestShaderType tested_shader_type)
2542 std::string example_structure_definition("struct light {\n"
2543 " float intensity;\n"
2546 std::string example_structure_object(" light my_light_variable");
2548 for (size_t max_dimension_index = 2; max_dimension_index <= API::MAX_ARRAY_DIMENSIONS; max_dimension_index++)
2550 std::string base_variable_string = this->extend_string(example_structure_object, "[]", max_dimension_index);
2551 base_variable_string += " = ";
2552 base_variable_string += recursively_initialise("light", max_dimension_index, "1.0, 2");
2553 base_variable_string += ";\n\n";
2555 std::string shader_source = example_structure_definition + shader_start + base_variable_string;
2558 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
2561 EXECUTE_POSITIVE_TEST(tested_shader_type, shader_source, true, false);
2562 } /* for (int max_dimension_index = 2; ...) */
2565 /* Generates the shader source code for the ConstructorsAndUnsizedDeclUnsizedArrays1
2566 * array tests, and attempts to compile each test shader, for both
2567 * vertex and fragment shaders.
2569 * @tparam API Tested API descriptor
2571 * @param tested_shader_type The type of shader that is being tested
2572 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
2574 template <class API>
2575 void ConstructorsAndUnsizedDeclUnsizedArrays1<API>::test_shader_compilation(
2576 typename TestCaseBase<API>::TestShaderType tested_shader_type)
2578 std::string base_variable_string;
2580 for (size_t max_dimension_index = 2; max_dimension_index <= API::MAX_ARRAY_DIMENSIONS; max_dimension_index++)
2582 base_variable_string = this->extend_string(" int x", "[]", max_dimension_index);
2583 base_variable_string += ";\n\n";
2585 std::string shader_source = shader_start + base_variable_string;
2588 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
2591 this->execute_negative_test(tested_shader_type, shader_source);
2592 } /* for (int max_dimension_index = 2; ...) */
2595 /* Generates the shader source code for the ConstructorsAndUnsizedDeclUnsizedArrays2
2596 * array tests, and attempts to compile each test shader, for both
2597 * vertex and fragment shaders.
2599 * @tparam API Tested API descriptor
2601 * @param tested_shader_type The type of shader that is being tested
2602 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
2604 template <class API>
2605 void ConstructorsAndUnsizedDeclUnsizedArrays2<API>::test_shader_compilation(
2606 typename TestCaseBase<API>::TestShaderType tested_shader_type)
2608 std::string input[] = { " float [] x = float[](1), y;\n\n" };
2610 for (size_t string_index = 0; string_index < sizeof(input) / sizeof(input[0]); string_index++)
2612 std::string shader_source;
2614 shader_source += shader_start;
2615 shader_source += input[string_index];
2618 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
2621 EXECUTE_SHADER_TEST(API::ALLOW_UNSIZED_DECLARATION, tested_shader_type, shader_source);
2622 } /* for (int string_index = 0; ...) */
2625 /* Generates the shader source code for the ConstructorsAndUnsizedDeclUnsizedArrays3
2626 * array tests, and attempts to compile each test shader, for both
2627 * vertex and fragment shaders.
2629 * @tparam API Tested API descriptor
2631 * @param tested_shader_type The type of shader that is being tested
2632 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
2634 template <class API>
2635 void ConstructorsAndUnsizedDeclUnsizedArrays3<API>::test_shader_compilation(
2636 typename TestCaseBase<API>::TestShaderType tested_shader_type)
2638 std::string base_variable_string(" float[][] x = mat4(0);\n\n");
2640 std::string shader_source = shader_start + base_variable_string;
2643 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
2646 this->execute_negative_test(tested_shader_type, shader_source);
2649 /* Generates the shader source code for the ConstructorsAndUnsizedDeclUnsizedArrays4
2650 * array tests, and attempts to compile each test shader, for both
2651 * vertex and fragment shaders.
2653 * @tparam API Tested API descriptor
2655 * @param tested_shader_type The type of shader that is being tested
2656 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
2658 template <class API>
2659 void ConstructorsAndUnsizedDeclUnsizedArrays4<API>::test_shader_compilation(
2660 typename TestCaseBase<API>::TestShaderType tested_shader_type)
2662 std::string example_struct("struct light {\n"
2663 " float[][] intensity;\n"
2667 std::string shader_source = example_struct + shader_start;
2670 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
2673 this->execute_negative_test(tested_shader_type, shader_source);
2676 /* Constructs a suitable constructor for the specified number of dimensions.
2678 * @tparam API Tested API descriptor
2680 * @param dimension_index The current recursion level (counts down)
2681 * @param init_string The initialisation string
2683 template <class API>
2684 std::string ExpressionsAssignment1<API>::recursively_initialise(std::string var_type, size_t dimension_index,
2685 std::string init_string)
2687 std::string temp_string;
2689 if (dimension_index == 0)
2691 temp_string = init_string;
2695 std::string prefix = "\n";
2697 for (size_t indent_index = dimension_index; indent_index < (API::MAX_ARRAY_DIMENSIONS + 1); indent_index++)
2702 prefix += this->extend_string(var_type, "[]", dimension_index);
2704 for (int sub_script_index = 0; sub_script_index < 2; sub_script_index++)
2706 temp_string += prefix;
2707 temp_string += recursively_initialise(var_type, dimension_index - 1, init_string);
2709 if (dimension_index == 1)
2720 /* Generates the shader source code for the ExpressionsAssignment1
2721 * array tests, and attempts to compile each test shader, for both
2722 * vertex and fragment shaders.
2724 * @tparam API Tested API descriptor
2726 * @param tested_shader_type The type of shader that is being tested
2727 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
2729 template <class API>
2730 void ExpressionsAssignment1<API>::test_shader_compilation(typename TestCaseBase<API>::TestShaderType tested_shader_type)
2732 for (size_t max_dimension_index = 2; max_dimension_index <= API::MAX_ARRAY_DIMENSIONS; max_dimension_index++)
2734 std::string prefix = "(";
2735 std::string base_variable_string;
2737 base_variable_string += this->extend_string(" float x", "[2]", max_dimension_index);
2738 base_variable_string += " = ";
2739 base_variable_string += recursively_initialise("float", max_dimension_index, "4.0, 6.0");
2740 base_variable_string += ";\n";
2741 base_variable_string += this->extend_string(" float y", "[2]", max_dimension_index);
2742 base_variable_string += " = ";
2743 base_variable_string += recursively_initialise("float", max_dimension_index, "1.0, 2.0");
2744 base_variable_string += ";\n\n";
2746 std::string shader_source = shader_start + base_variable_string;
2748 shader_source += " x = y;\n";
2751 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
2754 EXECUTE_POSITIVE_TEST(tested_shader_type, shader_source, true, false);
2755 } /* for (int max_dimension_index = 2; ...) */
2758 /* Generates the shader source code for the ExpressionsAssignment2
2759 * array tests, and attempts to compile each test shader, for both
2760 * vertex and fragment shaders.
2762 * @tparam API Tested API descriptor
2764 * @param tested_shader_type The type of shader that is being tested
2765 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
2767 template <class API>
2768 void ExpressionsAssignment2<API>::test_shader_compilation(typename TestCaseBase<API>::TestShaderType tested_shader_type)
2770 std::string shader_body(" float a[2] = float[](1.0, 2.0);\n"
2771 " float b[2][2] = float[][](float[](1.0, 2.0), float[](1.0, 2.0));\n"
2772 " float c[2][2][2] = float[][][]("
2773 "float[][](float[](1.0, 2.0), float[](1.0, 2.0)),"
2774 "float[][](float[](1.0, 2.0), float[](1.0, 2.0)));\n"
2775 " float d[2][2][2][2] = float[][][][]("
2777 "float[][](float[](1.0, 2.0), float[](1.0, 2.0)), "
2778 "float[][](float[](1.0, 2.0), float[](1.0, 2.0))),"
2780 "float[][](float[](1.0, 2.0), float[](1.0, 2.0)), "
2781 "float[][](float[](1.0, 2.0), float[](1.0, 2.0))));\n\n");
2783 std::string variable_basenames[] = { "a", "b", "c", "d" };
2784 int number_of_elements = sizeof(variable_basenames) / sizeof(variable_basenames[0]);
2786 for (int variable_index = 0; variable_index < number_of_elements; variable_index++)
2788 for (int value_index = variable_index; value_index < number_of_elements; value_index++)
2790 std::string shader_source = shader_start + shader_body;
2792 /* Avoid the situation when a variable is assign to itself. */
2793 if (variable_index != value_index)
2795 shader_source += " " + variable_basenames[variable_index] + " = " + variable_basenames[value_index];
2796 shader_source += ";\n";
2799 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
2802 this->execute_negative_test(tested_shader_type, shader_source);
2803 } /* if(variable_index != value_index) */
2804 } /* for (int value_index = variable_index; ...) */
2805 } /* for (int variable_index = 0; ...) */
2808 /* Generates the shader source code for the ExpressionsAssignment3
2809 * array tests, and attempts to compile each test shader, for both
2810 * vertex and fragment shaders.
2812 * @tparam API Tested API descriptor
2814 * @param tested_shader_type The type of shader that is being tested
2815 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
2817 template <class API>
2818 void ExpressionsAssignment3<API>::test_shader_compilation(typename TestCaseBase<API>::TestShaderType tested_shader_type)
2820 std::string prefix, base_variable_string;
2822 const int test_array_dimensions = 4;
2824 prefix = this->extend_string(" float a", "[1]", 4);
2825 prefix += " = float[][][][](\n"
2828 " float[](1.0))));\n";
2830 prefix += " float b";
2832 for (int permutation = 0; permutation < (1 << test_array_dimensions); permutation++)
2834 base_variable_string = prefix;
2836 for (int sub_script_index = test_array_dimensions - 1; sub_script_index >= 0; sub_script_index--)
2838 if (permutation & (1 << sub_script_index))
2840 base_variable_string += "[1]";
2844 base_variable_string += "[2]";
2848 base_variable_string += ";\n\n";
2850 if (permutation != (1 << test_array_dimensions) - 1)
2852 std::string shader_source = shader_start + base_variable_string;
2854 shader_source += " b = a;\n";
2857 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
2860 this->execute_negative_test(tested_shader_type, shader_source);
2861 } /* if (permutation != (1 << test_array_dimensions) - 1) */
2862 } /* for (int permutation = 0; ...) */
2865 /* Generates the shader source code for the ExpressionsTypeRestrictions1
2866 * array tests, and attempts to compile each test shader, for both
2867 * vertex and fragment shaders.
2869 * @tparam API Tested API descriptor
2871 * @param tested_shader_type The type of shader that is being tested
2872 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
2874 template <class API>
2875 void ExpressionsTypeRestrictions1<API>::test_shader_compilation(
2876 typename TestCaseBase<API>::TestShaderType tested_shader_type)
2878 int num_var_types = sizeof(opaque_var_types) / sizeof(opaque_var_types[0]);
2880 for (int var_type_index = 0; var_type_index < num_var_types; var_type_index++)
2882 _supported_variable_types_map_const_iterator var_iterator =
2883 supported_variable_types_map.find(opaque_var_types[var_type_index]);
2885 if (var_iterator != supported_variable_types_map.end())
2887 std::string shader_source =
2888 "uniform " + var_iterator->second.precision + " " + var_iterator->second.type + " var1[2][2];\n"
2890 var_iterator->second.precision + " " + var_iterator->second.type + " var2[2][2];\n\n";
2891 shader_source += shader_start;
2893 shader_source += " var1 = var2;\n";
2896 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
2899 this->execute_negative_test(tested_shader_type, shader_source);
2900 } /* if var_type iterator found */
2903 TCU_FAIL("Type not found.");
2905 } /* for (int var_type_index = 0; ...) */
2908 /* Generates the shader source code for the ExpressionsTypeRestrictions2
2909 * array tests, and attempts to compile each test shader, for both
2910 * vertex and fragment shaders.
2912 * @tparam API Tested API descriptor
2914 * @param tested_shader_type The type of shader that is being tested
2915 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
2917 template <class API>
2918 void ExpressionsTypeRestrictions2<API>::test_shader_compilation(
2919 typename TestCaseBase<API>::TestShaderType tested_shader_type)
2921 int num_var_types = sizeof(opaque_var_types) / sizeof(opaque_var_types[0]);
2923 for (int var_type_index = 0; var_type_index < num_var_types; var_type_index++)
2925 _supported_variable_types_map_const_iterator var_iterator =
2926 supported_variable_types_map.find(opaque_var_types[var_type_index]);
2928 if (var_iterator != supported_variable_types_map.end())
2930 std::string shader_source =
2931 "uniform " + var_iterator->second.precision + " " + var_iterator->second.type + " sampler1;\n"
2933 var_iterator->second.precision + " " + var_iterator->second.type + " sampler2;\n"
2935 var_iterator->second.precision + " " + var_iterator->second.type + " sampler3;\n"
2937 var_iterator->second.precision + " " + var_iterator->second.type + " sampler4;\n"
2940 var_iterator->second.type + " var1[2][2];\n"
2942 shader_source += shader_start;
2945 (" light1 x = light1(" + var_iterator->second.type + "[][](" + var_iterator->second.type +
2946 "[](sampler1, sampler2), " + var_iterator->second.type + "[](sampler3, sampler4)));\n");
2947 shader_source += " light1 y = x;\n\n";
2950 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
2953 this->execute_negative_test(tested_shader_type, shader_source);
2954 } /* if var_type iterator found */
2957 TCU_FAIL("Type not found.");
2959 } /* for (int var_type_index = 0; ...) */
2962 /* Generates the shader source code for the ExpressionsIndexingScalar1
2963 * array tests, and attempts to compile each test shader, for both
2964 * vertex and fragment shaders.
2966 * @tparam API Tested API descriptor
2968 * @param tested_shader_type The type of shader that is being tested
2969 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
2971 template <class API>
2972 void ExpressionsIndexingScalar1<API>::test_shader_compilation(
2973 typename TestCaseBase<API>::TestShaderType tested_shader_type)
2975 for (size_t var_type_index = 0; var_type_index < API::n_var_types; var_type_index++)
2977 _supported_variable_types_map_const_iterator var_iterator =
2978 supported_variable_types_map.find(API::var_types[var_type_index]);
2980 if (var_iterator != supported_variable_types_map.end())
2982 std::string shader_source = shader_start + " " + var_iterator->second.type + " x[1][2][3][4];\n\n";
2984 shader_source += " for (uint i = 0u; i < 2u; i++) {\n";
2985 shader_source += " for (uint j = 0u; j < 3u; j++) {\n";
2986 shader_source += " for (uint k = 0u; k < 4u; k++) {\n";
2987 shader_source += " x[0][i][j][k] = " + var_iterator->second.initializer_with_ones + ";\n";
2988 shader_source += " }\n";
2989 shader_source += " }\n";
2990 shader_source += " }\n";
2993 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
2996 EXECUTE_POSITIVE_TEST(tested_shader_type, shader_source, true, false);
2997 } /* if var_type iterator found */
3000 TCU_FAIL("Type not found.");
3005 /* Generates the shader source code for the ExpressionsIndexingScalar2
3006 * array tests, and attempts to compile each test shader, for both
3007 * vertex and fragment shaders.
3009 * @tparam API Tested API descriptor
3011 * @param tested_shader_type The type of shader that is being tested
3012 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
3014 template <class API>
3015 void ExpressionsIndexingScalar2<API>::test_shader_compilation(
3016 typename TestCaseBase<API>::TestShaderType tested_shader_type)
3018 std::string base_shader_string, shader_source;
3020 // This test tests arrays with 4 dimensions, e.g. x[1][1][1][1]
3021 const int test_array_dimensions = 4;
3023 base_shader_string = "float a[1][2][3][4];\n";
3024 base_shader_string += "float b = 2.0;\n\n";
3025 base_shader_string += shader_start;
3027 // There are 16 permutations, so loop 4x4 times.
3028 for (int permutation = 0; permutation < (1 << test_array_dimensions); permutation++)
3030 shader_source = base_shader_string + " a"; // a var called 'a'
3032 for (int sub_script_index = test_array_dimensions - 1; sub_script_index >= 0; sub_script_index--)
3034 /* If any bit is set for a particular number then add
3035 * a valid array sub_script at that place, otherwise
3036 * add an invalid array sub_script. */
3037 if (permutation & (1 << sub_script_index))
3039 shader_source += "[0]";
3043 shader_source += "[-1]";
3047 shader_source += " = b;\n";
3049 if (permutation != (1 << test_array_dimensions) - 1)
3052 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
3055 this->execute_negative_test(tested_shader_type, shader_source);
3056 } /* if (permutation != (1 << test_array_dimensions) - 1) */
3057 } /* for (int permutation = 0; ...) */
3060 /* Generates the shader source code for the ExpressionsIndexingScalar3
3061 * array tests, and attempts to compile each test shader, for both
3062 * vertex and fragment shaders.
3064 * @tparam API Tested API descriptor
3066 * @param tested_shader_type The type of shader that is being tested
3067 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
3069 template <class API>
3070 void ExpressionsIndexingScalar3<API>::test_shader_compilation(
3071 typename TestCaseBase<API>::TestShaderType tested_shader_type)
3073 std::string base_shader_string;
3074 std::string shader_source;
3075 const int test_array_dimensions = 4;
3077 base_shader_string = "float a[1][2][3][4];\n";
3078 base_shader_string += "float b = 2.0;\n\n";
3079 base_shader_string += shader_start;
3081 for (int permutation = 0; permutation < (1 << test_array_dimensions); permutation++)
3083 shader_source = base_shader_string + " a";
3085 for (int sub_script_index = test_array_dimensions - 1; sub_script_index >= 0; sub_script_index--)
3087 if (permutation & (1 << sub_script_index))
3089 shader_source += "[0]";
3093 shader_source += "[4]";
3097 shader_source += " = b;\n";
3099 if (permutation != (1 << test_array_dimensions) - 1)
3102 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
3105 this->execute_negative_test(tested_shader_type, shader_source);
3106 } /* if (permutation != (1 << test_array_dimensions) - 1) */
3107 } /* for (int permutation = 0; ...) */
3110 /* Generates the shader source code for the ExpressionsIndexingScalar4
3111 * array tests, and attempts to compile each test shader, for both
3112 * vertex and fragment shaders.
3114 * @tparam API Tested API descriptor
3116 * @param tested_shader_type The type of shader that is being tested
3117 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
3119 template <class API>
3120 void ExpressionsIndexingScalar4<API>::test_shader_compilation(
3121 typename TestCaseBase<API>::TestShaderType tested_shader_type)
3123 std::string base_shader_string;
3124 std::string shader_source;
3126 const int test_array_dimensions = 4;
3128 base_shader_string = "float a[1][2][3][4];\n";
3129 base_shader_string += "float b = 2.0;\n\n";
3130 base_shader_string += shader_start;
3132 for (int permutation = 0; permutation < (1 << test_array_dimensions); permutation++)
3134 shader_source = base_shader_string + " a";
3136 for (int sub_script_index = test_array_dimensions - 1; sub_script_index >= 0; sub_script_index--)
3138 if (permutation & (1 << sub_script_index))
3140 shader_source += "[0]";
3144 shader_source += "[]";
3148 shader_source += " = b;\n";
3150 if (permutation != (1 << test_array_dimensions) - 1)
3153 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
3156 this->execute_negative_test(tested_shader_type, shader_source);
3157 } /* if (permutation != (1 << test_array_dimensions) - 1) */
3158 } /* for (int permutation = 0; ...) */
3161 /* Generates the shader source code for the ExpressionsIndexingArray1
3162 * array tests, and attempts to compile each test shader, for both
3163 * vertex and fragment shaders.
3165 * @tparam API Tested API descriptor
3167 * @param tested_shader_type The type of shader that is being tested
3168 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
3170 template <class API>
3171 void ExpressionsIndexingArray1<API>::test_shader_compilation(
3172 typename TestCaseBase<API>::TestShaderType tested_shader_type)
3174 std::string shader_source;
3175 std::string variable_declaration = "float x[1][1][1][1][1][1][1][1];\n\n";
3177 std::string variable_initializations[] = {
3178 "x[0] = float[1][1][1][1][1][1][1]("
3179 "float[1][1][1][1][1][1](float[1][1][1][1][1](float[1][1][1][1](float[1][1][1](float[1][1](float[1](1.0)))))));"
3182 "float[1][1][1][1][1][1](float[1][1][1][1][1](float[1][1][1][1](float[1][1][1](float[1][1](float[1](1.0))))));"
3185 "float[1][1][1][1][1](float[1][1][1][1](float[1][1][1](float[1][1](float[1](1.0)))));\n",
3186 "x[0][0][0][0] = float[1][1][1][1](float[1][1][1](float[1][1](float[1](1.0))));\n",
3187 "x[0][0][0][0][0] = float[1][1][1](float[1][1](float[1](1.0)));\n",
3188 "x[0][0][0][0][0][0] = float[1][1](float[1](1.0));\n", "x[0][0][0][0][0][0][0] = float[1](1.0);\n",
3189 "x[0][0][0][0][0][0][0][0] = 1.0;\n"
3192 for (size_t string_index = 0; string_index < sizeof(variable_initializations) / sizeof(variable_initializations[0]);
3195 shader_source = variable_declaration + shader_start;
3196 shader_source += " " + variable_initializations[string_index];
3199 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
3202 EXECUTE_POSITIVE_TEST(tested_shader_type, shader_source, true, false);
3203 } /* for (int string_index = 0; ...) */
3206 /* Constructs a suitable constructor for the specified number of dimensions.
3208 * @tparam API Tested API descriptor
3210 * @param dimension_index The current recursion level (counts down)
3211 * @param init_string The initialisation string
3213 template <class API>
3214 std::string ExpressionsIndexingArray2<API>::recursively_initialise(std::string var_type, size_t dimension_index,
3215 std::string init_string)
3217 std::string temp_string;
3219 if (dimension_index == 0)
3221 temp_string = init_string;
3225 std::string prefix = "\n";
3227 for (size_t indent_index = dimension_index; indent_index < (API::MAX_ARRAY_DIMENSIONS + 1); indent_index++)
3232 prefix += this->extend_string(var_type, "[]", dimension_index);
3234 for (int sub_script_index = 0; sub_script_index < 2; sub_script_index++)
3236 temp_string += prefix;
3237 temp_string += recursively_initialise(var_type, dimension_index - 1, init_string);
3239 if (dimension_index == 1)
3250 /* Generates the shader source code for the ExpressionsIndexingArray2
3251 * array tests, and attempts to compile each test shader, for both
3252 * vertex and fragment shaders.
3254 * @tparam API Tested API descriptor
3256 * @param tested_shader_type The type of shader that is being tested
3257 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
3259 template <class API>
3260 void ExpressionsIndexingArray2<API>::test_shader_compilation(
3261 typename TestCaseBase<API>::TestShaderType tested_shader_type)
3263 std::string variable_initialiser = " float[](float[](float(float(float(float(float(float(1.0))))))));\n";
3265 std::string x_variable_initializaton =
3266 " float x[2][2][2][2][2][2][2][1] = " + recursively_initialise("float", API::MAX_ARRAY_DIMENSIONS, "1.0") +
3268 std::string y_variable_initializaton =
3269 " float y[2][2][2][2][2][2][2][1] = " + recursively_initialise("float", API::MAX_ARRAY_DIMENSIONS, "1.0") +
3272 std::string shader_code_common_part = shader_start + x_variable_initializaton + y_variable_initializaton;
3274 for (size_t max_dimension_index = 1; max_dimension_index <= API::MAX_ARRAY_DIMENSIONS; max_dimension_index++)
3276 std::string iteration_specific_shader_code_part;
3278 iteration_specific_shader_code_part += this->extend_string(" x", "[0]", max_dimension_index);
3279 iteration_specific_shader_code_part += " = ";
3280 iteration_specific_shader_code_part += this->extend_string("y", "[0]", max_dimension_index);
3281 iteration_specific_shader_code_part += ";\n";
3283 std::string shader_source = shader_code_common_part + iteration_specific_shader_code_part;
3286 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
3289 EXECUTE_POSITIVE_TEST(tested_shader_type, shader_source, true, false);
3293 /* Generates the shader source code for the ExpressionsIndexingArray3
3294 * array tests, and attempts to compile each test shader, for both
3295 * vertex and fragment shaders.
3297 * @tparam API Tested API descriptor
3299 * @param tested_shader_type The type of shader that is being tested
3300 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
3302 template <class API>
3303 void ExpressionsIndexingArray3<API>::test_shader_compilation(
3304 typename TestCaseBase<API>::TestShaderType tested_shader_type)
3306 std::string input[] = { " x[ivec2(0)] = 1.0;\n\n", " x[ivec3(0)] = 1.0;\n\n", " x[ivec4(0)] = 1.0;\n\n" };
3308 for (size_t string_index = 0; string_index < sizeof(input) / sizeof(input[0]); string_index++)
3310 std::string shader_source = shader_start + this->extend_string(" float x", "[2]", (int)string_index + 2) +
3311 ";\n\n" + input[string_index];
3314 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
3317 this->execute_negative_test(tested_shader_type, shader_source);
3318 } /* for (int string_index = 0; ...) */
3321 /* Generates the shader source code for the ExpressionsDynamicIndexing1
3322 * array tests, and attempts to compile each test shader, for both
3323 * vertex and fragment shaders.
3325 * @tparam API Tested API descriptor
3327 * @param tested_shader_type The type of shader that is being tested
3328 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
3330 template <class API>
3331 void ExpressionsDynamicIndexing1<API>::test_shader_compilation(
3332 typename TestCaseBase<API>::TestShaderType tested_shader_type)
3334 std::string expression_type_declarations = "uniform int a;\n"
3335 "const int b = 0;\n"
3339 std::string expressions[] = { "a", "b", "c", "0 + 1" };
3340 std::string shader_source;
3342 for (size_t write_index = 0; write_index < sizeof(expressions) / sizeof(expressions[0]); write_index++)
3344 for (size_t read_index = 0; read_index < sizeof(expressions) / sizeof(expressions[0]); read_index++)
3346 shader_source = expression_type_declarations;
3347 shader_source += shader_start;
3348 shader_source += " x[";
3349 shader_source += expressions[write_index];
3350 shader_source += "][";
3351 shader_source += expressions[read_index];
3352 shader_source += "] = 1.0;\n\n";
3355 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
3358 EXECUTE_POSITIVE_TEST(tested_shader_type, shader_source, true, false);
3359 } /* for (int read_index = 0; ...) */
3360 } /* for (int write_index = 0; ...) */
3363 /* Generates the shader source code for the ExpressionsDynamicIndexing2
3364 * array tests, and attempts to compile each test shader, for both
3365 * vertex and fragment shaders.
3367 * @tparam API Tested API descriptor
3369 * @param tested_shader_type The type of shader that is being tested
3370 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
3372 template <class API>
3373 void ExpressionsDynamicIndexing2<API>::test_shader_compilation(
3374 typename TestCaseBase<API>::TestShaderType tested_shader_type)
3376 int num_var_types = sizeof(opaque_var_types) / sizeof(opaque_var_types[0]);
3377 const std::string invalid_size_declarations[] = { "[0][0][0][y]", "[0][0][y][0]", "[0][y][0][0]", "[y][0][0][0]",
3378 "[0][0][y][y]", "[0][y][0][y]", "[y][0][0][y]", "[0][y][y][0]",
3379 "[y][0][y][0]", "[y][y][0][0]", "[0][y][y][y]", "[y][0][y][y]",
3380 "[y][y][0][y]", "[y][y][y][0]", "[y][y][y][y]" };
3382 bool dynamic_indexing_supported = false;
3383 if (glu::contextSupports(this->context_id.getRenderContext().getType(), glu::ApiType::es(3, 2)) ||
3384 glu::contextSupports(this->context_id.getRenderContext().getType(), glu::ApiType::core(4, 0)) ||
3385 this->context_id.getContextInfo().isExtensionSupported("GL_EXT_gpu_shader5"))
3387 dynamic_indexing_supported = true;
3390 for (int var_type_index = 0; var_type_index < num_var_types; var_type_index++)
3392 _supported_variable_types_map_const_iterator var_iterator =
3393 supported_variable_types_map.find(opaque_var_types[var_type_index]);
3395 if (var_iterator != supported_variable_types_map.end())
3397 int num_invalid_size_declarations =
3398 sizeof(invalid_size_declarations) / sizeof(invalid_size_declarations[0]);
3400 for (int invalid_size_index = 0; invalid_size_index < num_invalid_size_declarations; invalid_size_index++)
3402 std::string shader_source = "int y = 1;\n";
3404 shader_source += "uniform " + var_iterator->second.precision + " " + var_iterator->second.type +
3405 " x[2][2][2][2];\n\n";
3406 shader_source += "void main()\n";
3407 shader_source += "{\n";
3408 shader_source += (" " + var_iterator->second.type_of_result_of_texture_function +
3409 " color = texture(x" + invalid_size_declarations[invalid_size_index] + ", " +
3410 var_iterator->second.coord_param_for_texture_function + ");\n");
3413 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
3415 if (dynamic_indexing_supported)
3417 EXECUTE_POSITIVE_TEST(tested_shader_type, shader_source, true, true);
3421 this->execute_negative_test(tested_shader_type, shader_source);
3423 } /* for (int invalid_size_index = 0; ...) */
3424 } /* if var_type iterator found */
3427 TCU_FAIL("Type not found.");
3429 } /* for (int var_type_index = 0; ...) */
3432 /* Generates the shader source code for the ExpressionsEquality1
3433 * array tests, and attempts to compile each test shader, for both
3434 * vertex and fragment shaders.
3436 * @tparam API Tested API descriptor
3438 * @param tested_shader_type The type of shader that is being tested
3439 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
3441 template <class API>
3442 void ExpressionsEquality1<API>::test_shader_compilation(typename TestCaseBase<API>::TestShaderType tested_shader_type)
3444 int num_var_types = API::n_var_types;
3446 for (int var_type_index = 0; var_type_index < num_var_types; var_type_index++)
3448 _supported_variable_types_map_const_iterator var_iterator =
3449 supported_variable_types_map.find(API::var_types[var_type_index]);
3451 if (var_iterator != supported_variable_types_map.end())
3453 std::string shader_source = shader_start;
3455 shader_source += " ";
3456 shader_source += var_iterator->second.type;
3457 shader_source += "[][] x = ";
3458 shader_source += var_iterator->second.type;
3459 shader_source += "[][](";
3460 shader_source += var_iterator->second.type;
3461 shader_source += "[](";
3462 shader_source += var_iterator->second.initializer_with_zeroes;
3463 shader_source += ",";
3464 shader_source += var_iterator->second.initializer_with_zeroes;
3465 shader_source += "),";
3466 shader_source += var_iterator->second.type;
3467 shader_source += "[](";
3468 shader_source += var_iterator->second.initializer_with_zeroes;
3469 shader_source += ",";
3470 shader_source += var_iterator->second.initializer_with_zeroes;
3471 shader_source += "));\n";
3472 shader_source += " ";
3473 shader_source += var_iterator->second.type;
3474 shader_source += "[][] y = ";
3475 shader_source += var_iterator->second.type;
3476 shader_source += "[][](";
3477 shader_source += var_iterator->second.type;
3478 shader_source += "[](";
3479 shader_source += var_iterator->second.initializer_with_zeroes;
3480 shader_source += ",";
3481 shader_source += var_iterator->second.initializer_with_zeroes;
3482 shader_source += "),";
3483 shader_source += var_iterator->second.type;
3484 shader_source += "[](";
3485 shader_source += var_iterator->second.initializer_with_zeroes;
3486 shader_source += ",";
3487 shader_source += var_iterator->second.initializer_with_zeroes;
3488 shader_source += "));\n\n";
3489 shader_source += " float result = 0.0;\n\n";
3490 shader_source += " if (x == y)\n";
3491 shader_source += " {\n";
3492 shader_source += " result = 1.0;\n";
3493 shader_source += " }\n";
3494 shader_source += " if (y != x)\n";
3495 shader_source += " {\n";
3496 shader_source += " result = 2.0;\n";
3497 shader_source += " }\n";
3500 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
3503 EXECUTE_POSITIVE_TEST(tested_shader_type, shader_source, true, false);
3504 } /* if var_type iterator found */
3507 TCU_FAIL("Type not found.");
3512 /* Generates the shader source code for the ExpressionsEquality2
3513 * array tests, and attempts to compile each test shader, for both
3514 * vertex and fragment shaders.
3516 * @tparam API Tested API descriptor
3518 * @param tested_shader_type The type of shader that is being tested
3519 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
3521 template <class API>
3522 void ExpressionsEquality2<API>::test_shader_compilation(typename TestCaseBase<API>::TestShaderType tested_shader_type)
3524 int num_var_types = API::n_var_types;
3526 for (int var_type_index = 0; var_type_index < num_var_types; var_type_index++)
3528 _supported_variable_types_map_const_iterator var_iterator =
3529 supported_variable_types_map.find(API::var_types[var_type_index]);
3531 if (var_iterator != supported_variable_types_map.end())
3533 std::string shader_source = "struct light {\n float intensity;\n int position;\n};\n\n";
3535 shader_source += shader_start;
3536 shader_source += " light[][] x =";
3537 shader_source += "light";
3538 shader_source += "[][](";
3539 shader_source += "light";
3540 shader_source += "[](light(1.0, 1)),";
3541 shader_source += "light";
3542 shader_source += "[](light(2.0, 2)));\n\n";
3543 shader_source += " light[][] y =";
3544 shader_source += "light";
3545 shader_source += "[][](";
3546 shader_source += "light";
3547 shader_source += "[](light(3.0, 3)),";
3548 shader_source += "light";
3549 shader_source += "[](light(4.0, 4)));\n\n";
3550 shader_source += " float result = 0.0;\n\n";
3551 shader_source += " if (x == y)\n";
3552 shader_source += " {\n";
3553 shader_source += " result = 1.0;\n";
3554 shader_source += " }\n";
3555 shader_source += " if (y != x)\n";
3556 shader_source += " {\n";
3557 shader_source += " result = 2.0;\n";
3558 shader_source += " }\n";
3560 /* Apply stage specific stuff */
3561 switch (tested_shader_type)
3563 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
3564 shader_source += "\n gl_Position = vec4(0.0,0.0,0.0,1.0);\n";
3566 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
3567 shader_source += "\n gl_FragDepth = result;\n";
3569 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
3571 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
3572 shader_source += emit_quad;
3574 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
3575 shader_source += set_tesseation;
3577 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
3580 TCU_FAIL("Unrecognized shader type.");
3584 /* End main function */
3585 shader_source += shader_end;
3588 EXECUTE_POSITIVE_TEST(tested_shader_type, shader_source, true, false);
3589 } /* if var_type iterator found */
3592 TCU_FAIL("Type not found.");
3597 /* Generates the shader source code for the ExpressionsLength1
3598 * array tests, and attempts to compile each test shader, for both
3599 * vertex and fragment shaders.
3601 * @tparam API Tested API descriptor
3603 * @param tested_shader_type The type of shader that is being tested
3604 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
3606 template <class API>
3607 void ExpressionsLength1<API>::test_shader_compilation(typename TestCaseBase<API>::TestShaderType tested_shader_type)
3609 std::string array_declaration = " int x[4][3][2][1];\n\n";
3610 std::string case_specific_string[] = { " if (x.length() != 4) {\n"
3611 " result = 0.0f;\n }\n",
3612 " if (x[0].length() != 3) {\n"
3613 " result = 0.0f;\n }\n",
3614 " if (x[0][0].length() != 2) {\n"
3615 " result = 0.0f;\n }\n",
3616 " if (x[0][0][0].length() != 1) {\n"
3617 " result = 0.0f;\n }\n" };
3618 const bool test_compute = (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type);
3620 for (size_t case_specific_string_index = 0;
3621 case_specific_string_index < sizeof(case_specific_string) / sizeof(case_specific_string[0]);
3622 case_specific_string_index++)
3624 const std::string& test_snippet = case_specific_string[case_specific_string_index];
3626 if (false == test_compute)
3628 execute_draw_test(tested_shader_type, array_declaration, test_snippet);
3632 execute_dispatch_test(tested_shader_type, array_declaration, test_snippet);
3635 /* Deallocate any resources used. */
3636 this->delete_objects();
3637 } /* for (int case_specific_string_index = 0; ...) */
3640 /** Executes test for compute program
3642 * @tparam API Tested API descriptor
3644 * @param tested_shader_type The type of shader that is being tested
3645 * @param tested_declaration Declaration used to prepare shader
3646 * @param tested_snippet Snippet used to prepare shader
3648 template <class API>
3649 void ExpressionsLength1<API>::execute_dispatch_test(typename TestCaseBase<API>::TestShaderType tested_shader_type,
3650 const std::string& tested_declaration,
3651 const std::string& tested_snippet)
3653 const std::string& compute_shader_source =
3654 prepare_compute_shader(tested_shader_type, tested_declaration, tested_snippet);
3655 const glw::Functions& gl = this->context_id.getRenderContext().getFunctions();
3657 this->execute_positive_test(empty_string, empty_string, empty_string, empty_string, empty_string,
3658 compute_shader_source, false, false);
3660 /* We are now ready to verify whether the returned size is correct. */
3661 unsigned char buffer[4] = { 0 };
3662 glw::GLuint framebuffer_object_id = 0;
3663 glw::GLint location = -1;
3664 glw::GLuint texture_object_id = 0;
3665 glw::GLuint vao_id = 0;
3667 gl.useProgram(this->program_object_id);
3668 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram() failed.");
3670 gl.genTextures(1, &texture_object_id);
3671 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures() failed.");
3673 gl.bindTexture(GL_TEXTURE_2D, texture_object_id);
3674 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture() failed.");
3676 gl.texStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 1, 1);
3677 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage2D() failed.");
3679 gl.bindImageTexture(0 /* image unit */, texture_object_id, 0 /* level */, GL_FALSE /* layered */, 0 /* layer */,
3680 GL_WRITE_ONLY, GL_RGBA8);
3681 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindImageTexture() failed.");
3683 location = gl.getUniformLocation(this->program_object_id, "uni_image");
3684 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation() failed.");
3688 TCU_FAIL("Uniform is inactive");
3691 gl.uniform1i(location, 0 /* image unit */);
3692 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i() failed.");
3694 gl.genVertexArrays(1, &vao_id);
3695 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenVertexArrays() failed.");
3697 gl.bindVertexArray(vao_id);
3698 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray() failed.");
3700 gl.dispatchCompute(1, 1, 1);
3701 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
3703 gl.genFramebuffers(1, &framebuffer_object_id);
3704 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers() failed.");
3706 gl.bindFramebuffer(GL_FRAMEBUFFER, framebuffer_object_id);
3707 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer() failed.");
3709 gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_object_id, 0);
3710 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferTexture2D() failed.");
3712 gl.viewport(0, 0, 1, 1);
3713 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport() failed.");
3715 gl.readBuffer(GL_COLOR_ATTACHMENT0);
3716 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadBuffer() failed.");
3718 gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
3719 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels() failed.");
3721 if (buffer[0] != 255)
3723 TCU_FAIL("Invalid array size was returned.");
3726 /* Delete generated objects. */
3727 gl.deleteTextures(1, &texture_object_id);
3728 gl.deleteFramebuffers(1, &framebuffer_object_id);
3729 gl.deleteVertexArrays(1, &vao_id);
3730 GLU_EXPECT_NO_ERROR(gl.getError(), "An error ocurred while deleting generated objects.");
3733 /** Executes test for draw program
3735 * @tparam API Tested API descriptor
3737 * @param tested_shader_type The type of shader that is being tested
3738 * @param tested_declaration Declaration used to prepare shader
3739 * @param tested_snippet Snippet used to prepare shader
3741 template <class API>
3742 void ExpressionsLength1<API>::execute_draw_test(typename TestCaseBase<API>::TestShaderType tested_shader_type,
3743 const std::string& tested_declaration,
3744 const std::string& tested_snippet)
3746 const glw::Functions& gl = this->context_id.getRenderContext().getFunctions();
3748 if (API::USE_ALL_SHADER_STAGES)
3750 const std::string& compute_shader_source = empty_string;
3751 const std::string& fragment_shader_source =
3752 this->prepare_fragment_shader(tested_shader_type, tested_declaration, tested_snippet);
3753 const std::string& geometry_shader_source =
3754 this->prepare_geometry_shader(tested_shader_type, tested_declaration, tested_snippet);
3755 const std::string& tess_ctrl_shader_source =
3756 this->prepare_tess_ctrl_shader(tested_shader_type, tested_declaration, tested_snippet);
3757 const std::string& tess_eval_shader_source =
3758 this->prepare_tess_eval_shader(tested_shader_type, tested_declaration, tested_snippet);
3759 const std::string& vertex_shader_source =
3760 this->prepare_vertex_shader(tested_shader_type, tested_declaration, tested_snippet);
3762 switch (tested_shader_type)
3764 case TestCaseBase<API>::VERTEX_SHADER_TYPE: /* Fall through */
3765 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
3766 this->execute_positive_test(vertex_shader_source, fragment_shader_source, false, false);
3769 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
3770 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
3771 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE: /* Fall through */
3772 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
3773 this->execute_positive_test(vertex_shader_source, tess_ctrl_shader_source, tess_eval_shader_source,
3774 geometry_shader_source, fragment_shader_source, compute_shader_source, false,
3779 TCU_FAIL("Invalid enum");
3785 const std::string& fragment_shader_source =
3786 this->prepare_fragment_shader(tested_shader_type, tested_declaration, tested_snippet);
3787 const std::string& vertex_shader_source =
3788 this->prepare_vertex_shader(tested_shader_type, tested_declaration, tested_snippet);
3790 this->execute_positive_test(vertex_shader_source, fragment_shader_source, false, false);
3793 /* We are now ready to verify whether the returned size is correct. */
3794 unsigned char buffer[4] = { 0 };
3795 glw::GLuint framebuffer_object_id = 0;
3796 glw::GLuint texture_object_id = 0;
3797 glw::GLuint vao_id = 0;
3799 gl.useProgram(this->program_object_id);
3800 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram() failed.");
3802 gl.genTextures(1, &texture_object_id);
3803 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures() failed.");
3805 gl.bindTexture(GL_TEXTURE_2D, texture_object_id);
3806 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture() failed.");
3808 gl.texStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 1, 1);
3809 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage2D() failed.");
3811 gl.genFramebuffers(1, &framebuffer_object_id);
3812 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers() failed.");
3814 gl.bindFramebuffer(GL_FRAMEBUFFER, framebuffer_object_id);
3815 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer() failed.");
3817 gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_object_id, 0);
3818 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferTexture2D() failed.");
3820 gl.viewport(0, 0, 1, 1);
3821 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport() failed.");
3823 gl.genVertexArrays(1, &vao_id);
3824 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenVertexArrays() failed.");
3826 gl.bindVertexArray(vao_id);
3827 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray() failed.");
3829 switch (tested_shader_type)
3831 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE: /* Fall through */
3832 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
3833 gl.drawArrays(GL_TRIANGLE_FAN, 0, 4);
3834 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
3837 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE: /* Fall through */
3838 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
3839 /* Tesselation patch set up */
3840 gl.patchParameteri(GL_PATCH_VERTICES, 1);
3841 GLU_EXPECT_NO_ERROR(gl.getError(), "PatchParameteri");
3843 gl.drawArrays(GL_PATCHES, 0, 1);
3844 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
3847 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
3848 gl.drawArrays(GL_POINTS, 0, 1);
3849 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
3853 TCU_FAIL("Invalid enum");
3857 gl.readBuffer(GL_COLOR_ATTACHMENT0);
3858 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadBuffer() failed.");
3860 gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
3861 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels() failed.");
3863 if (buffer[0] != 255)
3865 TCU_FAIL("Invalid array size was returned.");
3868 /* Delete generated objects. */
3869 gl.deleteTextures(1, &texture_object_id);
3870 gl.deleteFramebuffers(1, &framebuffer_object_id);
3871 gl.deleteVertexArrays(1, &vao_id);
3872 GLU_EXPECT_NO_ERROR(gl.getError(), "An error ocurred while deleting generated objects.");
3877 * @tparam API Tested API descriptor
3879 * @param tested_shader_type The type of shader that is being tested
3880 * @param tested_declaration Declaration used to prepare shader
3881 * @param tested_snippet Snippet used to prepare shader
3883 template <class API>
3884 std::string ExpressionsLength1<API>::prepare_compute_shader(
3885 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& tested_declaration,
3886 const std::string& tested_snippet)
3888 std::string compute_shader_source;
3890 if (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type)
3892 compute_shader_source = "writeonly uniform image2D uni_image;\n"
3896 " float result = 1u;\n"
3898 compute_shader_source += tested_declaration;
3899 compute_shader_source += tested_snippet;
3900 compute_shader_source += "\n"
3901 " imageStore(uni_image, ivec2(gl_GlobalInvocationID.xy), vec4(result, 0, 0, 0));\n"
3906 return compute_shader_source;
3911 * @tparam API Tested API descriptor
3913 * @param tested_shader_type The type of shader that is being tested
3914 * @param tested_declaration Declaration used to prepare shader
3915 * @param tested_snippet Snippet used to prepare shader
3917 template <class API>
3918 std::string ExpressionsLength1<API>::prepare_fragment_shader(
3919 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& tested_declaration,
3920 const std::string& tested_snippet)
3922 std::string fragment_shader_source;
3924 switch (tested_shader_type)
3926 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
3929 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
3930 fragment_shader_source = "out vec4 colour;\n"
3934 fragment_shader_source += tested_declaration;
3935 fragment_shader_source += " float result = 1.0f;\n";
3936 fragment_shader_source += tested_snippet;
3937 fragment_shader_source += " colour = vec4(result);\n"
3941 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
3942 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
3943 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
3944 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
3945 fragment_shader_source = "in float fs_result;\n\n"
3946 "out vec4 colour;\n\n"
3949 " colour = vec4(fs_result);\n"
3955 TCU_FAIL("Unrecognized shader object type.");
3959 return fragment_shader_source;
3964 * @tparam API Tested API descriptor
3966 * @param tested_shader_type The type of shader that is being tested
3967 * @param tested_declaration Declaration used to prepare shader
3968 * @param tested_snippet Snippet used to prepare shader
3970 template <class API>
3971 std::string ExpressionsLength1<API>::prepare_geometry_shader(
3972 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& tested_declaration,
3973 const std::string& tested_snippet)
3975 std::string geometry_shader_source;
3977 switch (tested_shader_type)
3979 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
3980 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
3981 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
3984 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
3985 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
3986 geometry_shader_source = "layout(points) in;\n"
3987 "layout(triangle_strip, max_vertices = 4) out;\n"
3989 "in float tes_result[];\n"
3990 "out float fs_result;\n"
3994 " gl_Position = vec4(-1, -1, 0, 1);\n"
3995 " fs_result = tes_result[0];\n"
3997 " gl_Position = vec4(-1, 1, 0, 1);\n"
3998 " fs_result = tes_result[0];\n"
4000 " gl_Position = vec4(1, -1, 0, 1);\n"
4001 " fs_result = tes_result[0];\n"
4003 " gl_Position = vec4(1, 1, 0, 1);\n"
4004 " fs_result = tes_result[0];\n"
4009 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
4010 geometry_shader_source = "layout(points) in;\n"
4011 "layout(triangle_strip, max_vertices = 4) out;\n"
4013 "out float fs_result;\n"
4017 geometry_shader_source += tested_declaration;
4018 geometry_shader_source += " float result = 1.0;\n\n";
4019 geometry_shader_source += tested_snippet;
4020 geometry_shader_source += "\n gl_Position = vec4(-1, -1, 0, 1);\n"
4021 " fs_result = result;\n"
4023 " gl_Position = vec4(-1, 1, 0, 1);\n"
4024 " fs_result = result;\n"
4026 " gl_Position = vec4(1, -1, 0, 1);\n"
4027 " fs_result = result;\n"
4029 " gl_Position = vec4(1, 1, 0, 1);\n"
4030 " fs_result = result;\n"
4036 TCU_FAIL("Unrecognized shader object type.");
4040 return geometry_shader_source;
4045 * @tparam API Tested API descriptor
4047 * @param tested_shader_type The type of shader that is being tested
4048 * @param tested_declaration Declaration used to prepare shader
4049 * @param tested_snippet Snippet used to prepare shader
4051 template <class API>
4052 std::string ExpressionsLength1<API>::prepare_tess_ctrl_shader(
4053 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& tested_declaration,
4054 const std::string& tested_snippet)
4056 std::string tess_ctrl_shader_source;
4058 switch (tested_shader_type)
4060 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
4061 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
4062 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
4063 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
4066 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
4067 tess_ctrl_shader_source = "layout(vertices = 1) out;\n"
4069 "out float tcs_result[];\n"
4073 tess_ctrl_shader_source += tested_declaration;
4074 tess_ctrl_shader_source += " float result = 1.0;\n\n";
4075 tess_ctrl_shader_source += tested_snippet;
4076 tess_ctrl_shader_source += " tcs_result[gl_InvocationID] = result;\n"
4078 " gl_TessLevelOuter[0] = 1.0;\n"
4079 " gl_TessLevelOuter[1] = 1.0;\n"
4080 " gl_TessLevelOuter[2] = 1.0;\n"
4081 " gl_TessLevelOuter[3] = 1.0;\n"
4082 " gl_TessLevelInner[0] = 1.0;\n"
4083 " gl_TessLevelInner[1] = 1.0;\n"
4087 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
4088 tess_ctrl_shader_source = default_tc_shader_source;
4092 TCU_FAIL("Unrecognized shader object type.");
4096 return tess_ctrl_shader_source;
4101 * @tparam API Tested API descriptor
4103 * @param tested_shader_type The type of shader that is being tested
4104 * @param tested_declaration Declaration used to prepare shader
4105 * @param tested_snippet Snippet used to prepare shader
4107 template <class API>
4108 std::string ExpressionsLength1<API>::prepare_tess_eval_shader(
4109 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& tested_declaration,
4110 const std::string& tested_snippet)
4112 std::string tess_eval_shader_source;
4114 switch (tested_shader_type)
4116 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
4117 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
4118 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
4119 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
4122 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
4123 tess_eval_shader_source = "layout(isolines, point_mode) in;\n"
4125 "in float tcs_result[];\n"
4126 "out float tes_result;\n"
4130 " tes_result = tcs_result[0];\n"
4134 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
4135 tess_eval_shader_source = "layout(isolines, point_mode) in;\n"
4137 "out float tes_result;\n"
4141 tess_eval_shader_source += tested_declaration;
4142 tess_eval_shader_source += " float result = 1.0;\n\n";
4143 tess_eval_shader_source += tested_snippet;
4144 tess_eval_shader_source += " tes_result = result;\n"
4149 TCU_FAIL("Unrecognized shader object type.");
4153 return tess_eval_shader_source;
4158 * @tparam API Tested API descriptor
4160 * @param tested_shader_type The type of shader that is being tested
4161 * @param tested_declaration Declaration used to prepare shader
4162 * @param tested_snippet Snippet used to prepare shader
4164 template <class API>
4165 std::string ExpressionsLength1<API>::prepare_vertex_shader(
4166 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& tested_declaration,
4167 const std::string& tested_snippet)
4169 std::string vertex_shader_source;
4171 switch (tested_shader_type)
4173 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
4176 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
4177 vertex_shader_source = "/** GL_TRIANGLE_FAN-type quad vertex data. */\n"
4178 "const vec4 vertex_positions[4] = vec4[4](vec4( 1.0, -1.0, 0.0, 1.0),\n"
4179 " vec4(-1.0, -1.0, 0.0, 1.0),\n"
4180 " vec4(-1.0, 1.0, 0.0, 1.0),\n"
4181 " vec4( 1.0, 1.0, 0.0, 1.0) );\n"
4185 " gl_Position = vertex_positions[gl_VertexID];"
4189 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
4190 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
4191 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
4192 vertex_shader_source = default_vertex_shader_source;
4195 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
4196 vertex_shader_source = "out float fs_result;\n"
4198 "/** GL_TRIANGLE_FAN-type quad vertex data. */\n"
4199 "const vec4 vertex_positions[4] = vec4[4](vec4( 1.0, -1.0, 0.0, 1.0),\n"
4200 " vec4(-1.0, -1.0, 0.0, 1.0),\n"
4201 " vec4(-1.0, 1.0, 0.0, 1.0),\n"
4202 " vec4( 1.0, 1.0, 0.0, 1.0) );\n"
4206 vertex_shader_source += tested_declaration;
4207 vertex_shader_source += " float result = 1.0;\n\n";
4208 vertex_shader_source += tested_snippet;
4209 vertex_shader_source += " gl_Position = vertex_positions[gl_VertexID];\n"
4210 " fs_result = result;\n";
4211 vertex_shader_source += shader_end;
4215 TCU_FAIL("Unrecognized shader object type.");
4219 return vertex_shader_source;
4222 /* Generates the shader source code for the ExpressionsLength2
4223 * array tests, and attempts to compile each test shader, for both
4224 * vertex and fragment shaders.
4226 * @tparam API Tested API descriptor
4228 * @param tested_shader_type The type of shader that is being tested
4229 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
4231 template <class API>
4232 void ExpressionsLength2<API>::test_shader_compilation(typename TestCaseBase<API>::TestShaderType tested_shader_type)
4234 std::string array_declaration = " int x[1][2][3][4];\n\n";
4235 std::string case_specific_string[] = { " if (x.length() != 1) {\n"
4236 " result = 0.0f;\n }\n",
4237 " if (x[0].length() != 2) {\n"
4238 " result = 0.0f;\n }\n",
4239 " if (x[0][0].length() != 3) {\n"
4240 " result = 0.0f;\n }\n",
4241 " if (x[0][0][0].length() != 4) {\n"
4242 " result = 0.0f;\n }\n" };
4243 const bool test_compute = (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type);
4245 for (size_t case_specific_string_index = 0;
4246 case_specific_string_index < sizeof(case_specific_string) / sizeof(case_specific_string[0]);
4247 case_specific_string_index++)
4249 const std::string& test_snippet = case_specific_string[case_specific_string_index];
4251 if (false == test_compute)
4253 this->execute_draw_test(tested_shader_type, array_declaration, test_snippet);
4257 this->execute_dispatch_test(tested_shader_type, array_declaration, test_snippet);
4260 /* Deallocate any resources used. */
4261 this->delete_objects();
4262 } /* for (int case_specific_string_index = 0; ...) */
4265 /* Generates the shader source code for the ExpressionsLength3
4266 * array tests, and attempts to compile each test shader, for both
4267 * vertex and fragment shaders.
4269 * @tparam API Tested API descriptor
4271 * @param tested_shader_type The type of shader that is being tested
4272 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
4274 template <class API>
4275 void ExpressionsLength3<API>::test_shader_compilation(typename TestCaseBase<API>::TestShaderType tested_shader_type)
4277 std::string array_declaration = " int x[1][1][1][1];\n\n";
4278 std::string input[] = { " if (x[].length() != 2) {\n"
4279 " result = 0.0f;\n }\n",
4280 " if (x[][].length() != 2) {\n"
4281 " result = 0.0f;\n }\n",
4282 " if (x[][][].length() != 2) {\n"
4283 " result = 0.0f;\n }\n" };
4285 for (size_t string_index = 0; string_index < sizeof(input) / sizeof(input[0]); string_index++)
4287 std::string shader_source;
4288 const std::string& test_snippet = input[string_index];
4290 switch (tested_shader_type)
4292 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
4293 shader_source = this->prepare_vertex_shader(tested_shader_type, array_declaration, test_snippet);
4296 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
4297 shader_source = this->prepare_fragment_shader(tested_shader_type, array_declaration, test_snippet);
4300 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
4301 shader_source = this->prepare_compute_shader(tested_shader_type, array_declaration, test_snippet);
4304 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
4305 shader_source = this->prepare_geometry_shader(tested_shader_type, array_declaration, test_snippet);
4308 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
4309 shader_source = this->prepare_tess_ctrl_shader(tested_shader_type, array_declaration, test_snippet);
4312 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
4313 shader_source = this->prepare_tess_eval_shader(tested_shader_type, array_declaration, test_snippet);
4317 TCU_FAIL("Unrecognized shader type.");
4319 } /* switch (tested_shader_type) */
4321 this->execute_negative_test(tested_shader_type, shader_source);
4322 } /* for (int string_index = 0; ...) */
4325 /* Generates the shader source code for the ExpressionsInvalid1
4326 * array tests, and attempts to compile each test shader, for both
4327 * vertex and fragment shaders.
4329 * @tparam API Tested API descriptor
4331 * @param tested_shader_type The type of shader that is being tested
4332 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
4334 template <class API>
4335 void ExpressionsInvalid1<API>::test_shader_compilation(typename TestCaseBase<API>::TestShaderType tested_shader_type)
4337 std::string shader_variable_declarations =
4338 " mat2 y = mat2(0.0);\n"
4339 " float x[2][2] = float[2][2](float[2](4.0, 5.0), float[2](6.0, 7.0));\n\n";
4341 std::string shader_source = shader_start + shader_variable_declarations;
4343 shader_source += " y = x;\n";
4345 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
4347 this->execute_negative_test(tested_shader_type, shader_source);
4350 /* Generates the shader source code for the ExpressionsInvalid2
4351 * array tests, and attempts to compile each test shader, for both
4352 * vertex and fragment shaders.
4354 * @tparam API Tested API descriptor
4356 * @param tested_shader_type The type of shader that is being tested
4357 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
4359 template <class API>
4360 void ExpressionsInvalid2<API>::test_shader_compilation(typename TestCaseBase<API>::TestShaderType tested_shader_type)
4363 std::string shader_variable_declarations[] = { " x", " y" };
4364 std::string variable_relation_opeartors[] = {
4365 " float result = 0.0;\n\n if(x < y)\n {\n result = 1.0;\n }\n\n\n",
4366 " float result = 0.0;\n\n if(x <= y)\n {\n result = 1.0;\n }\n\n\n",
4367 " float result = 0.0;\n\n if(x > y)\n {\n result = 1.0;\n }\n\n\n",
4368 " float result = 0.0;\n\n if(x >= y)\n {\n result = 1.0;\n }\n\n\n"
4370 std::string valid_relation_opeartors =
4371 " float result = 0.0;\n\n if(x == y)\n {\n result = 1.0;\n }\n\n\n";
4373 for (size_t var_type_index = 0; var_type_index < API::n_var_types; var_type_index++)
4375 _supported_variable_types_map_const_iterator var_iterator =
4376 supported_variable_types_map.find(API::var_types[var_type_index]);
4378 if (var_iterator != supported_variable_types_map.end())
4380 std::string base_variable_string;
4382 for (size_t variable_declaration_index = 0;
4383 variable_declaration_index <
4384 sizeof(shader_variable_declarations) / sizeof(shader_variable_declarations[0]);
4385 variable_declaration_index++)
4387 base_variable_string += var_iterator->second.type;
4388 base_variable_string += shader_variable_declarations[variable_declaration_index];
4390 base_variable_string += "[1][1][1][1][1][1][1][1] = ";
4392 for (size_t sub_script_index = 0; sub_script_index < API::MAX_ARRAY_DIMENSIONS; sub_script_index++)
4394 base_variable_string += this->extend_string(var_iterator->second.type, "[1]",
4395 API::MAX_ARRAY_DIMENSIONS - sub_script_index);
4396 base_variable_string += "(";
4399 base_variable_string += var_iterator->second.initializer_with_ones;
4401 for (size_t sub_script_index = 0; sub_script_index < API::MAX_ARRAY_DIMENSIONS; sub_script_index++)
4403 base_variable_string += ")";
4406 base_variable_string += ";\n";
4407 } /* for (int variable_declaration_index = 0; ...) */
4409 /* Run positive case */
4411 std::string shader_source;
4413 shader_source = base_variable_string + "\n";
4414 shader_source += shader_start + valid_relation_opeartors;
4416 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
4418 EXECUTE_POSITIVE_TEST(tested_shader_type, shader_source, true, false);
4421 /* Run negative cases */
4422 for (size_t string_index = 0;
4423 string_index < sizeof(variable_relation_opeartors) / sizeof(variable_relation_opeartors[0]);
4426 std::string shader_source;
4428 shader_source = base_variable_string + "\n";
4429 shader_source += shader_start + variable_relation_opeartors[string_index];
4431 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
4433 this->execute_negative_test(tested_shader_type, shader_source);
4434 } /* for (int string_index = 0; ...) */
4435 } /* if var_type iterator found */
4438 TCU_FAIL("Type not found.");
4440 } /* for (int var_type_index = 0; ...) */
4443 /* Generates the shader source code for the InteractionFunctionCalls1
4444 * array tests, and attempts to compile each test shader, for both
4445 * vertex and fragment shaders.
4447 * @tparam API Tested API descriptor
4449 * @param tested_shader_type The type of shader that is being tested
4450 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
4452 template <class API>
4453 void InteractionFunctionCalls1<API>::test_shader_compilation(
4454 typename TestCaseBase<API>::TestShaderType tested_shader_type)
4456 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_IVEC2,
4457 VAR_TYPE_IVEC3, VAR_TYPE_IVEC4, VAR_TYPE_VEC2,
4458 VAR_TYPE_VEC3, VAR_TYPE_VEC4, VAR_TYPE_MAT2,
4459 VAR_TYPE_MAT3, VAR_TYPE_MAT4 };
4460 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
4462 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_IVEC2,
4463 VAR_TYPE_IVEC3, VAR_TYPE_IVEC4, VAR_TYPE_VEC2,
4464 VAR_TYPE_VEC3, VAR_TYPE_VEC4, VAR_TYPE_MAT2,
4465 VAR_TYPE_MAT3, VAR_TYPE_MAT4, VAR_TYPE_DOUBLE,
4466 VAR_TYPE_DMAT2, VAR_TYPE_DMAT3, VAR_TYPE_DMAT4 };
4467 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
4469 const std::string iteration_loop_end = " }\n"
4477 const std::string iteration_loop_start = " for (uint a = 0u; a < 2u; a++)\n"
4479 " for (uint b = 0u; b < 2u; b++)\n"
4481 " for (uint c = 0u; c < 2u; c++)\n"
4483 " for (uint d = 0u; d < 2u; d++)\n"
4485 " for (uint e = 0u; e < 2u; e++)\n"
4487 " for (uint f = 0u; f < 2u; f++)\n"
4489 " for (uint g = 0u; g < 2u; g++)\n"
4491 " for (uint h = 0u; h < 2u; h++)\n"
4493 const glcts::test_var_type* var_types_set = var_types_set_es;
4494 size_t num_var_types = num_var_types_es;
4495 const bool test_compute = (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type);
4497 if (API::USE_DOUBLE)
4499 var_types_set = var_types_set_gl;
4500 num_var_types = num_var_types_gl;
4503 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
4505 _supported_variable_types_map_const_iterator var_iterator =
4506 supported_variable_types_map.find(var_types_set[var_type_index]);
4508 if (var_iterator != supported_variable_types_map.end())
4510 std::string iterator_declaration = " " + var_iterator->second.iterator_type +
4511 " iterator = " + var_iterator->second.iterator_initialization + ";\n";
4513 std::string function_definition;
4514 std::string function_use;
4515 std::string verification;
4517 function_definition = "void my_function(out ";
4518 function_definition += var_iterator->second.type;
4519 function_definition += " output_array[2][2][2][2][2][2][2][2]) {\n";
4520 function_definition += iterator_declaration;
4521 function_definition += iteration_loop_start;
4522 function_definition += " output_array[a][b][c][d][e][f][g][h] = " +
4523 var_iterator->second.variable_type_initializer1 + ";\n";
4524 function_definition +=
4525 " iterator += " + var_iterator->second.iterator_type + "(1);\n";
4526 function_definition += iteration_loop_end;
4527 function_definition += "}";
4529 function_use = " " + var_iterator->second.type + " my_array[2][2][2][2][2][2][2][2];\n";
4530 function_use += " my_function(my_array);";
4532 verification = iterator_declaration;
4533 verification += " float result = 1.0;\n";
4534 verification += iteration_loop_start;
4535 verification += " if (my_array[a][b][c][d][e][f][g][h] " +
4536 var_iterator->second.specific_element +
4542 var_iterator->second.iterator_type + "(1);\n";
4543 verification += iteration_loop_end;
4545 if (false == test_compute)
4547 execute_draw_test(tested_shader_type, function_definition, function_use, verification);
4551 execute_dispatch_test(tested_shader_type, function_definition, function_use, verification);
4554 /* Deallocate any resources used. */
4555 this->delete_objects();
4556 } /* if var_type iterator found */
4559 TCU_FAIL("Type not found.");
4561 } /* for (int var_type_index = 0; ...) */
4564 /** Executes test for compute program
4566 * @tparam API Tested API descriptor
4568 * @param tested_shader_type The type of shader that is being tested
4569 * @param function_definition Definition used to prepare shader
4570 * @param function_use Snippet that makes use of defined function
4571 * @param verification Snippet that verifies results
4573 template <class API>
4574 void InteractionFunctionCalls1<API>::execute_dispatch_test(
4575 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& function_definition,
4576 const std::string& function_use, const std::string& verification)
4578 const std::string& compute_shader_source =
4579 prepare_compute_shader(tested_shader_type, function_definition, function_use, verification);
4580 const glw::Functions& gl = this->context_id.getRenderContext().getFunctions();
4582 this->execute_positive_test(empty_string, empty_string, empty_string, empty_string, empty_string,
4583 compute_shader_source, false, false);
4585 /* We are now ready to verify whether the returned size is correct. */
4586 unsigned char buffer[4] = { 0 };
4587 glw::GLuint framebuffer_object_id = 0;
4588 glw::GLint location = -1;
4589 glw::GLuint texture_object_id = 0;
4590 glw::GLuint vao_id = 0;
4592 gl.useProgram(this->program_object_id);
4593 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram() failed.");
4595 gl.genTextures(1, &texture_object_id);
4596 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures() failed.");
4598 gl.bindTexture(GL_TEXTURE_2D, texture_object_id);
4599 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture() failed.");
4601 gl.texStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 1, 1);
4602 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage2D() failed.");
4604 gl.bindImageTexture(0 /* image unit */, texture_object_id, 0 /* level */, GL_FALSE /* layered */, 0 /* layer */,
4605 GL_WRITE_ONLY, GL_RGBA8);
4606 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindImageTexture() failed.");
4608 location = gl.getUniformLocation(this->program_object_id, "uni_image");
4609 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation() failed.");
4613 TCU_FAIL("Uniform is inactive");
4616 gl.uniform1i(location, 0 /* image unit */);
4617 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i() failed.");
4619 gl.genVertexArrays(1, &vao_id);
4620 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenVertexArrays() failed.");
4622 gl.bindVertexArray(vao_id);
4623 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray() failed.");
4625 gl.dispatchCompute(1, 1, 1);
4626 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
4628 gl.genFramebuffers(1, &framebuffer_object_id);
4629 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers() failed.");
4631 gl.bindFramebuffer(GL_FRAMEBUFFER, framebuffer_object_id);
4632 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer() failed.");
4634 gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_object_id, 0);
4635 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferTexture2D() failed.");
4637 gl.viewport(0, 0, 1, 1);
4638 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport() failed.");
4640 gl.readBuffer(GL_COLOR_ATTACHMENT0);
4641 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadBuffer() failed.");
4643 gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
4644 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels() failed.");
4646 if (buffer[0] != 255)
4648 TCU_FAIL("Invalid array size was returned.");
4651 /* Delete generated objects. */
4652 gl.deleteTextures(1, &texture_object_id);
4653 gl.deleteFramebuffers(1, &framebuffer_object_id);
4654 gl.deleteVertexArrays(1, &vao_id);
4655 GLU_EXPECT_NO_ERROR(gl.getError(), "An error ocurred while deleting generated objects.");
4658 /** Executes test for draw program
4660 * @tparam API Tested API descriptor
4662 * @param tested_shader_type The type of shader that is being tested
4663 * @param function_definition Definition used to prepare shader
4664 * @param function_use Snippet that makes use of defined function
4665 * @param verification Snippet that verifies results
4667 template <class API>
4668 void InteractionFunctionCalls1<API>::execute_draw_test(typename TestCaseBase<API>::TestShaderType tested_shader_type,
4669 const std::string& function_definition,
4670 const std::string& function_use, const std::string& verification)
4672 const glw::Functions& gl = this->context_id.getRenderContext().getFunctions();
4674 if (API::USE_ALL_SHADER_STAGES)
4676 const std::string& compute_shader_source = empty_string;
4677 const std::string& fragment_shader_source =
4678 this->prepare_fragment_shader(tested_shader_type, function_definition, function_use, verification);
4679 const std::string& geometry_shader_source =
4680 this->prepare_geometry_shader(tested_shader_type, function_definition, function_use, verification);
4681 const std::string& tess_ctrl_shader_source =
4682 this->prepare_tess_ctrl_shader(tested_shader_type, function_definition, function_use, verification);
4683 const std::string& tess_eval_shader_source =
4684 this->prepare_tess_eval_shader(tested_shader_type, function_definition, function_use, verification);
4685 const std::string& vertex_shader_source =
4686 this->prepare_vertex_shader(tested_shader_type, function_definition, function_use, verification);
4688 switch (tested_shader_type)
4690 case TestCaseBase<API>::VERTEX_SHADER_TYPE: /* Fall through */
4691 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
4692 this->execute_positive_test(vertex_shader_source, fragment_shader_source, false, false);
4695 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
4696 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
4697 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE: /* Fall through */
4698 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
4699 this->execute_positive_test(vertex_shader_source, tess_ctrl_shader_source, tess_eval_shader_source,
4700 geometry_shader_source, fragment_shader_source, compute_shader_source, false,
4705 TCU_FAIL("Invalid enum");
4711 const std::string& fragment_shader_source =
4712 this->prepare_fragment_shader(tested_shader_type, function_definition, function_use, verification);
4713 const std::string& vertex_shader_source =
4714 this->prepare_vertex_shader(tested_shader_type, function_definition, function_use, verification);
4716 this->execute_positive_test(vertex_shader_source, fragment_shader_source, false, false);
4719 /* We are now ready to verify whether the returned size is correct. */
4720 unsigned char buffer[4] = { 0 };
4721 glw::GLuint framebuffer_object_id = 0;
4722 glw::GLuint texture_object_id = 0;
4723 glw::GLuint vao_id = 0;
4725 gl.useProgram(this->program_object_id);
4726 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram() failed.");
4728 gl.genTextures(1, &texture_object_id);
4729 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures() failed.");
4731 gl.bindTexture(GL_TEXTURE_2D, texture_object_id);
4732 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture() failed.");
4734 gl.texStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 1, 1);
4735 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage2D() failed.");
4737 gl.genFramebuffers(1, &framebuffer_object_id);
4738 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers() failed.");
4740 gl.bindFramebuffer(GL_FRAMEBUFFER, framebuffer_object_id);
4741 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer() failed.");
4743 gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_object_id, 0);
4744 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferTexture2D() failed.");
4746 gl.viewport(0, 0, 1, 1);
4747 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport() failed.");
4749 gl.genVertexArrays(1, &vao_id);
4750 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenVertexArrays() failed.");
4752 gl.bindVertexArray(vao_id);
4753 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray() failed.");
4755 switch (tested_shader_type)
4757 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE: /* Fall through */
4758 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
4759 gl.drawArrays(GL_TRIANGLE_FAN, 0, 4);
4760 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
4763 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE: /* Fall through */
4764 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
4765 /* Tesselation patch set up */
4766 gl.patchParameteri(GL_PATCH_VERTICES, 1);
4767 GLU_EXPECT_NO_ERROR(gl.getError(), "PatchParameteri");
4769 gl.drawArrays(GL_PATCHES, 0, 1);
4770 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
4773 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
4774 gl.drawArrays(GL_POINTS, 0, 1);
4775 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
4779 TCU_FAIL("Invalid enum");
4783 gl.readBuffer(GL_COLOR_ATTACHMENT0);
4784 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadBuffer() failed.");
4786 gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
4787 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels() failed.");
4789 if (buffer[0] != 255)
4791 TCU_FAIL("Invalid array size was returned.");
4794 /* Delete generated objects. */
4795 gl.bindTexture(GL_TEXTURE_2D, 0);
4796 gl.bindFramebuffer(GL_FRAMEBUFFER, 0);
4797 gl.bindVertexArray(0);
4798 gl.deleteTextures(1, &texture_object_id);
4799 gl.deleteFramebuffers(1, &framebuffer_object_id);
4800 gl.deleteVertexArrays(1, &vao_id);
4801 GLU_EXPECT_NO_ERROR(gl.getError(), "An error ocurred while deleting generated objects.");
4806 * @tparam API Tested API descriptor
4808 * @param tested_shader_type The type of shader that is being tested
4809 * @param function_definition Definition used to prepare shader
4810 * @param function_use Snippet that makes use of defined function
4811 * @param verification Snippet that verifies results
4813 template <class API>
4814 std::string InteractionFunctionCalls1<API>::prepare_compute_shader(
4815 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& function_definition,
4816 const std::string& function_use, const std::string& verification)
4818 std::string compute_shader_source;
4820 if (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type)
4822 compute_shader_source = "writeonly uniform image2D uni_image;\n"
4825 /* User-defined function definition. */
4826 compute_shader_source += function_definition;
4827 compute_shader_source += "\n\n";
4829 /* Main function definition. */
4830 compute_shader_source += shader_start;
4831 compute_shader_source += function_use;
4832 compute_shader_source += "\n\n";
4833 compute_shader_source += verification;
4834 compute_shader_source += "\n\n";
4835 compute_shader_source += "\n"
4836 " imageStore(uni_image, ivec2(gl_GlobalInvocationID.xy), vec4(result, 0, 0, 0));\n"
4841 return compute_shader_source;
4846 * @tparam API Tested API descriptor
4848 * @param tested_shader_type The type of shader that is being tested
4849 * @param function_definition Definition used to prepare shader
4850 * @param function_use Snippet that makes use of defined function
4851 * @param verification Snippet that verifies results
4853 template <class API>
4854 std::string InteractionFunctionCalls1<API>::prepare_fragment_shader(
4855 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& function_definition,
4856 const std::string& function_use, const std::string& verification)
4858 std::string fragment_shader_source;
4860 switch (tested_shader_type)
4862 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
4865 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
4866 fragment_shader_source = "out vec4 colour;\n\n";
4868 /* User-defined function definition. */
4869 fragment_shader_source += function_definition;
4870 fragment_shader_source += "\n\n";
4872 /* Main function definition. */
4873 fragment_shader_source += shader_start;
4874 fragment_shader_source += function_use;
4875 fragment_shader_source += "\n\n";
4876 fragment_shader_source += verification;
4877 fragment_shader_source += "\n\n";
4878 fragment_shader_source += " colour = vec4(result);\n";
4879 fragment_shader_source += shader_end;
4882 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
4883 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
4884 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
4885 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
4886 fragment_shader_source = "in float fs_result;\n\n"
4887 "out vec4 colour;\n\n"
4890 " colour = vec4(fs_result);\n"
4896 TCU_FAIL("Unrecognized shader object type.");
4900 return fragment_shader_source;
4905 * @tparam API Tested API descriptor
4907 * @param tested_shader_type The type of shader that is being tested
4908 * @param function_definition Definition used to prepare shader
4909 * @param function_use Snippet that makes use of defined function
4910 * @param verification Snippet that verifies results
4912 template <class API>
4913 std::string InteractionFunctionCalls1<API>::prepare_geometry_shader(
4914 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& function_definition,
4915 const std::string& function_use, const std::string& verification)
4917 std::string geometry_shader_source;
4919 switch (tested_shader_type)
4921 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
4922 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
4923 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
4926 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
4927 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
4928 geometry_shader_source = "layout(points) in;\n"
4929 "layout(triangle_strip, max_vertices = 4) out;\n"
4931 "in float tes_result[];\n"
4932 "out float fs_result;\n"
4936 " gl_Position = vec4(-1, -1, 0, 1);\n"
4937 " fs_result = tes_result[0];\n"
4939 " gl_Position = vec4(-1, 1, 0, 1);\n"
4940 " fs_result = tes_result[0];\n"
4942 " gl_Position = vec4(1, -1, 0, 1);\n"
4943 " fs_result = tes_result[0];\n"
4945 " gl_Position = vec4(1, 1, 0, 1);\n"
4946 " fs_result = tes_result[0];\n"
4951 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
4952 geometry_shader_source = "layout(points) in;\n"
4953 "layout(triangle_strip, max_vertices = 4) out;\n"
4955 "out float fs_result;\n"
4958 /* User-defined function definition. */
4959 geometry_shader_source += function_definition;
4960 geometry_shader_source += "\n\n";
4962 /* Main function definition. */
4963 geometry_shader_source += shader_start;
4964 geometry_shader_source += function_use;
4965 geometry_shader_source += "\n\n";
4966 geometry_shader_source += verification;
4967 geometry_shader_source += "\n\n";
4968 geometry_shader_source += "\n gl_Position = vec4(-1, -1, 0, 1);\n"
4969 " fs_result = result;\n"
4971 " gl_Position = vec4(-1, 1, 0, 1);\n"
4972 " fs_result = result;\n"
4974 " gl_Position = vec4(1, -1, 0, 1);\n"
4975 " fs_result = result;\n"
4977 " gl_Position = vec4(1, 1, 0, 1);\n"
4978 " fs_result = result;\n"
4984 TCU_FAIL("Unrecognized shader object type.");
4988 return geometry_shader_source;
4993 * @tparam API Tested API descriptor
4995 * @param tested_shader_type The type of shader that is being tested
4996 * @param function_definition Definition used to prepare shader
4997 * @param function_use Snippet that makes use of defined function
4998 * @param verification Snippet that verifies results
5000 template <class API>
5001 std::string InteractionFunctionCalls1<API>::prepare_tess_ctrl_shader(
5002 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& function_definition,
5003 const std::string& function_use, const std::string& verification)
5005 std::string tess_ctrl_shader_source;
5007 switch (tested_shader_type)
5009 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
5010 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
5011 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
5012 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
5015 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
5016 tess_ctrl_shader_source = "layout(vertices = 1) out;\n"
5018 "out float tcs_result[];\n"
5021 /* User-defined function definition. */
5022 tess_ctrl_shader_source += function_definition;
5023 tess_ctrl_shader_source += "\n\n";
5025 /* Main function definition. */
5026 tess_ctrl_shader_source += shader_start;
5027 tess_ctrl_shader_source += function_use;
5028 tess_ctrl_shader_source += "\n\n";
5029 tess_ctrl_shader_source += verification;
5030 tess_ctrl_shader_source += "\n\n";
5031 tess_ctrl_shader_source += " tcs_result[gl_InvocationID] = result;\n"
5033 " gl_TessLevelOuter[0] = 1.0;\n"
5034 " gl_TessLevelOuter[1] = 1.0;\n"
5035 " gl_TessLevelOuter[2] = 1.0;\n"
5036 " gl_TessLevelOuter[3] = 1.0;\n"
5037 " gl_TessLevelInner[0] = 1.0;\n"
5038 " gl_TessLevelInner[1] = 1.0;\n"
5042 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
5043 tess_ctrl_shader_source = default_tc_shader_source;
5047 TCU_FAIL("Unrecognized shader object type.");
5051 return tess_ctrl_shader_source;
5056 * @tparam API Tested API descriptor
5058 * @param tested_shader_type The type of shader that is being tested
5059 * @param function_definition Definition used to prepare shader
5060 * @param function_use Snippet that makes use of defined function
5061 * @param verification Snippet that verifies results
5063 template <class API>
5064 std::string InteractionFunctionCalls1<API>::prepare_tess_eval_shader(
5065 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& function_definition,
5066 const std::string& function_use, const std::string& verification)
5068 std::string tess_eval_shader_source;
5070 switch (tested_shader_type)
5072 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
5073 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
5074 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
5075 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
5078 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
5079 tess_eval_shader_source = "layout(isolines, point_mode) in;\n"
5081 "in float tcs_result[];\n"
5082 "out float tes_result;\n"
5086 " tes_result = tcs_result[0];\n"
5090 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
5091 tess_eval_shader_source = "layout(isolines, point_mode) in;\n"
5093 "out float tes_result;\n"
5096 /* User-defined function definition. */
5097 tess_eval_shader_source += function_definition;
5098 tess_eval_shader_source += "\n\n";
5100 /* Main function definition. */
5101 tess_eval_shader_source += shader_start;
5102 tess_eval_shader_source += function_use;
5103 tess_eval_shader_source += "\n\n";
5104 tess_eval_shader_source += verification;
5105 tess_eval_shader_source += "\n\n";
5106 tess_eval_shader_source += " tes_result = result;\n"
5111 TCU_FAIL("Unrecognized shader object type.");
5115 return tess_eval_shader_source;
5120 * @tparam API Tested API descriptor
5122 * @param tested_shader_type The type of shader that is being tested
5123 * @param function_definition Definition used to prepare shader
5124 * @param function_use Snippet that makes use of defined function
5125 * @param verification Snippet that verifies results
5127 template <class API>
5128 std::string InteractionFunctionCalls1<API>::prepare_vertex_shader(
5129 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& function_definition,
5130 const std::string& function_use, const std::string& verification)
5132 std::string vertex_shader_source;
5134 switch (tested_shader_type)
5136 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
5139 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
5140 vertex_shader_source = "/** GL_TRIANGLE_FAN-type quad vertex data. */\n"
5141 "const vec4 vertex_positions[4] = vec4[4](vec4( 1.0, -1.0, 0.0, 1.0),\n"
5142 " vec4(-1.0, -1.0, 0.0, 1.0),\n"
5143 " vec4(-1.0, 1.0, 0.0, 1.0),\n"
5144 " vec4( 1.0, 1.0, 0.0, 1.0) );\n"
5148 " gl_Position = vertex_positions[gl_VertexID];"
5152 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
5153 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
5154 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
5155 vertex_shader_source = default_vertex_shader_source;
5158 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
5159 /* Vertex shader source. */
5160 vertex_shader_source = "out float fs_result;\n\n";
5161 vertex_shader_source += "/** GL_TRIANGLE_FAN-type quad vertex data. */\n"
5162 "const vec4 vertex_positions[4] = vec4[4](vec4( 1.0, -1.0, 0.0, 1.0),\n"
5163 " vec4(-1.0, -1.0, 0.0, 1.0),\n"
5164 " vec4(-1.0, 1.0, 0.0, 1.0),\n"
5165 " vec4( 1.0, 1.0, 0.0, 1.0) );\n\n";
5167 /* User-defined function definition. */
5168 vertex_shader_source += function_definition;
5169 vertex_shader_source += "\n\n";
5171 /* Main function definition. */
5172 vertex_shader_source += shader_start;
5173 vertex_shader_source += function_use;
5174 vertex_shader_source += "\n\n";
5175 vertex_shader_source += verification;
5176 vertex_shader_source += "\n\n";
5177 vertex_shader_source += " fs_result = result;\n"
5178 " gl_Position = vertex_positions[gl_VertexID];\n";
5179 vertex_shader_source += shader_end;
5183 TCU_FAIL("Unrecognized shader object type.");
5187 return vertex_shader_source;
5190 /* Generates the shader source code for the InteractionFunctionCalls2
5191 * array tests, and attempts to compile each test shader, for both
5192 * vertex and fragment shaders.
5194 * @tparam API Tested API descriptor
5196 * @param tested_shader_type The type of shader that is being tested
5197 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
5199 template <class API>
5200 void InteractionFunctionCalls2<API>::test_shader_compilation(
5201 typename TestCaseBase<API>::TestShaderType tested_shader_type)
5203 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_IVEC2,
5204 VAR_TYPE_IVEC3, VAR_TYPE_IVEC4, VAR_TYPE_VEC2,
5205 VAR_TYPE_VEC3, VAR_TYPE_VEC4, VAR_TYPE_MAT2,
5206 VAR_TYPE_MAT3, VAR_TYPE_MAT4 };
5207 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
5209 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_IVEC2,
5210 VAR_TYPE_IVEC3, VAR_TYPE_IVEC4, VAR_TYPE_VEC2,
5211 VAR_TYPE_VEC3, VAR_TYPE_VEC4, VAR_TYPE_MAT2,
5212 VAR_TYPE_MAT3, VAR_TYPE_MAT4, VAR_TYPE_DOUBLE,
5213 VAR_TYPE_DMAT2, VAR_TYPE_DMAT3, VAR_TYPE_DMAT4 };
5214 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
5216 const std::string iteration_loop_end = " }\n"
5224 const std::string iteration_loop_start = " for (uint a = 0u; a < 2u; a++)\n"
5226 " for (uint b = 0u; b < 2u; b++)\n"
5228 " for (uint c = 0u; c < 2u; c++)\n"
5230 " for (uint d = 0u; d < 2u; d++)\n"
5232 " for (uint e = 0u; e < 2u; e++)\n"
5234 " for (uint f = 0u; f < 2u; f++)\n"
5236 " for (uint g = 0u; g < 2u; g++)\n"
5238 " for (uint h = 0u; h < 2u; h++)\n"
5240 const std::string multiplier_array = "const int[] multiplier_array = int[]( 1, 2, 3, 4, 5, 6, 7, 8,\n"
5241 " 11, 12, 13, 14, 15, 16, 17, 18,\n"
5242 " 21, 22, 23, 24, 25, 26, 27, 28,\n"
5243 " 31, 32, 33, 34, 35, 36, 37, 38,\n"
5244 " 41, 42, 43, 44, 45, 46, 47, 48,\n"
5245 " 51, 52, 53, 54, 55, 56, 57, 58,\n"
5246 " 61, 62, 63, 64, 65, 66, 67, 68,\n"
5247 " 71, 72, 73, 74, 75, 76, 77, 78,\n"
5248 " 81, 82, 83, 84, 85, 86, 87, 88);\n";
5249 const glcts::test_var_type* var_types_set = var_types_set_es;
5250 size_t num_var_types = num_var_types_es;
5251 const bool test_compute = (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type);
5253 if (API::USE_DOUBLE)
5255 var_types_set = var_types_set_gl;
5256 num_var_types = num_var_types_gl;
5259 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
5261 _supported_variable_types_map_const_iterator var_iterator =
5262 supported_variable_types_map.find(var_types_set[var_type_index]);
5264 if (var_iterator != supported_variable_types_map.end())
5266 std::string function_definition;
5267 std::string function_use;
5268 std::string verification;
5270 function_definition += multiplier_array;
5271 function_definition += "void my_function(inout ";
5272 function_definition += var_iterator->second.type;
5273 function_definition += " inout_array[2][2][2][2][2][2][2][2]) {\n"
5275 function_definition += iteration_loop_start;
5276 function_definition += " inout_array[a][b][c][d][e][f][g][h] *= " +
5277 var_iterator->second.iterator_type + "(multiplier_array[i % 64u]);\n";
5278 function_definition += " i+= 1u;\n";
5279 function_definition += iteration_loop_end;
5280 function_definition += "}";
5282 function_use += " float result = 1.0;\n";
5283 function_use += " uint iterator = 0u;\n";
5284 function_use += " " + var_iterator->second.type + " my_array[2][2][2][2][2][2][2][2];\n";
5285 function_use += iteration_loop_start;
5286 function_use += " my_array[a][b][c][d][e][f][g][h] = " +
5287 var_iterator->second.variable_type_initializer2 + ";\n";
5288 function_use += iteration_loop_end;
5289 function_use += " my_function(my_array);";
5291 verification += iteration_loop_start;
5292 verification += " if (my_array[a][b][c][d][e][f][g][h] " +
5293 var_iterator->second.specific_element + "!= " + var_iterator->second.iterator_type +
5294 "(multiplier_array[iterator % 64u]))\n"
5298 " iterator += 1u;\n";
5299 verification += iteration_loop_end;
5301 if (false == test_compute)
5303 this->execute_draw_test(tested_shader_type, function_definition, function_use, verification);
5307 this->execute_dispatch_test(tested_shader_type, function_definition, function_use, verification);
5310 /* Deallocate any resources used. */
5311 this->delete_objects();
5312 } /* if var_type iterator found */
5315 TCU_FAIL("Type not found.");
5317 } /* for (int var_type_index = 0; ...) */
5320 /* Generates the shader source code for the InteractionArgumentAliasing1
5321 * array tests, and attempts to compile each test shader, for both
5322 * vertex and fragment shaders.
5324 * @tparam API Tested API descriptor
5326 * @param tested_shader_type The type of shader that is being tested
5327 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
5329 template <class API>
5330 void InteractionArgumentAliasing1<API>::test_shader_compilation(
5331 typename TestCaseBase<API>::TestShaderType tested_shader_type)
5333 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_MAT4 };
5334 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
5336 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_MAT4,
5337 VAR_TYPE_DOUBLE, VAR_TYPE_DMAT4 };
5338 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
5340 const std::string iteration_loop_end = " }\n"
5348 const std::string iteration_loop_start = " for (uint a = 0u; a < 2u; a++)\n"
5350 " for (uint b = 0u; b < 2u; b++)\n"
5352 " for (uint c = 0u; c < 2u; c++)\n"
5354 " for (uint d = 0u; d < 2u; d++)\n"
5356 " for (uint e = 0u; e < 2u; e++)\n"
5358 " for (uint f = 0u; f < 2u; f++)\n"
5360 " for (uint g = 0u; g < 2u; g++)\n"
5362 " for (uint h = 0u; h < 2u; h++)\n"
5364 const glcts::test_var_type* var_types_set = var_types_set_es;
5365 size_t num_var_types = num_var_types_es;
5366 const bool test_compute = (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type);
5368 if (API::USE_DOUBLE)
5370 var_types_set = var_types_set_gl;
5371 num_var_types = num_var_types_gl;
5374 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
5376 _supported_variable_types_map_const_iterator var_iterator =
5377 supported_variable_types_map.find(var_types_set[var_type_index]);
5379 if (var_iterator != supported_variable_types_map.end())
5381 std::string array_declaration = var_iterator->second.type + " z[2][2][2][2][2][2][2][2];\n\n";
5383 std::string function_definition;
5384 std::string function_use;
5385 std::string verification;
5387 function_definition += "bool gfunc(" + var_iterator->second.type + " x[2][2][2][2][2][2][2][2], ";
5388 function_definition += var_iterator->second.type + " y[2][2][2][2][2][2][2][2])\n";
5389 function_definition += "{\n";
5390 function_definition += " " + iteration_loop_start;
5391 function_definition +=
5392 " x[a][b][c][d][e][f][g][h] = " + var_iterator->second.type + "(123);\n";
5393 function_definition += " " + iteration_loop_end;
5394 function_definition += "\n";
5395 function_definition += " " + iteration_loop_start;
5396 function_definition += " if(y[a][b][c][d][e][f][g][h]";
5397 if (var_iterator->second.type == "mat4") // mat4 comparison
5399 function_definition += "[0][0]";
5400 function_definition += " != float";
5402 else if (var_iterator->second.type == "dmat4") // dmat4 comparison
5404 function_definition += "[0][0]";
5405 function_definition += " != double";
5409 function_definition += " != ";
5410 function_definition += var_iterator->second.type;
5412 function_definition += "(((a*128u)+(b*64u)+(c*32u)+(d*16u)+(e*8u)+(f*4u)+(g*2u)+h))) {return false;}\n";
5413 function_definition += " " + iteration_loop_end;
5414 function_definition += " return true;\n";
5415 function_definition += "}";
5417 function_use += " " + array_declaration;
5418 function_use += " " + iteration_loop_start;
5419 function_use += " z[a][b][c][d][e][f][g][h] = ";
5420 function_use += var_iterator->second.type;
5421 function_use += "(((a*128u)+(b*64u)+(c*32u)+(d*16u)+(e*8u)+(f*4u)+(g*2u)+h));\n";
5422 function_use += " " + iteration_loop_end;
5424 verification += " float result = 0.0;\n";
5425 verification += " if(gfunc(z, z) == true)\n";
5426 verification += " {\n";
5427 verification += " result = 1.0;\n\n";
5428 verification += " }\n";
5429 verification += " else\n";
5430 verification += " {\n";
5431 verification += " result = 0.0;\n\n";
5432 verification += " }\n";
5434 if (false == test_compute)
5436 this->execute_draw_test(tested_shader_type, function_definition, function_use, verification);
5440 this->execute_dispatch_test(tested_shader_type, function_definition, function_use, verification);
5443 /* Deallocate any resources used. */
5444 this->delete_objects();
5445 } /* if var_type iterator found */
5448 TCU_FAIL("Type not found.");
5453 /* Generates the shader source code for the InteractionArgumentAliasing2
5454 * array tests, and attempts to compile each test shader, for both
5455 * vertex and fragment shaders.
5457 * @tparam API Tested API descriptor
5459 * @param tested_shader_type The type of shader that is being tested
5460 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
5462 template <class API>
5463 void InteractionArgumentAliasing2<API>::test_shader_compilation(
5464 typename TestCaseBase<API>::TestShaderType tested_shader_type)
5466 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_MAT4 };
5467 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
5469 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_MAT4,
5470 VAR_TYPE_DOUBLE, VAR_TYPE_DMAT4 };
5471 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
5473 const std::string iteration_loop_end = " }\n"
5481 const std::string iteration_loop_start = " for (uint a = 0u; a < 2u; a++)\n"
5483 " for (uint b = 0u; b < 2u; b++)\n"
5485 " for (uint c = 0u; c < 2u; c++)\n"
5487 " for (uint d = 0u; d < 2u; d++)\n"
5489 " for (uint e = 0u; e < 2u; e++)\n"
5491 " for (uint f = 0u; f < 2u; f++)\n"
5493 " for (uint g = 0u; g < 2u; g++)\n"
5495 " for (uint h = 0u; h < 2u; h++)\n"
5497 const glcts::test_var_type* var_types_set = var_types_set_es;
5498 size_t num_var_types = num_var_types_es;
5499 const bool test_compute = (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type);
5501 if (API::USE_DOUBLE)
5503 var_types_set = var_types_set_gl;
5504 num_var_types = num_var_types_gl;
5507 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
5509 _supported_variable_types_map_const_iterator var_iterator =
5510 supported_variable_types_map.find(var_types_set[var_type_index]);
5512 if (var_iterator != supported_variable_types_map.end())
5514 std::string array_declaration = var_iterator->second.type + " z[2][2][2][2][2][2][2][2];\n\n";
5516 std::string function_definition;
5517 std::string function_use;
5518 std::string verification;
5520 function_definition += "bool gfunc(" + var_iterator->second.type + " x[2][2][2][2][2][2][2][2], ";
5521 function_definition += var_iterator->second.type + " y[2][2][2][2][2][2][2][2])\n";
5522 function_definition += "{\n";
5523 function_definition += " " + iteration_loop_start;
5524 function_definition +=
5525 " y[a][b][c][d][e][f][g][h] = " + var_iterator->second.type +
5527 function_definition += " " + iteration_loop_end;
5528 function_definition += "\n";
5529 function_definition += " " + iteration_loop_start;
5530 function_definition += " if(x[a][b][c][d][e][f][g][h]";
5531 if (var_iterator->second.type == "mat4") // mat4 comparison
5533 function_definition += "[0][0]";
5534 function_definition += " != float";
5536 else if (var_iterator->second.type == "dmat4") // dmat4 comparison
5538 function_definition += "[0][0]";
5539 function_definition += " != double";
5543 function_definition += " != ";
5544 function_definition += var_iterator->second.type;
5546 function_definition += "(((a*128u)+(b*64u)+(c*32u)+(d*16u)+(e*8u)+(f*4u)+(g*2u)+h))) {return false;}\n";
5547 function_definition += " " + iteration_loop_end;
5548 function_definition += " return true;\n";
5549 function_definition += "}";
5551 function_use += " " + array_declaration;
5552 function_use += " " + iteration_loop_start;
5553 function_use += " z[a][b][c][d][e][f][g][h] = ";
5554 function_use += var_iterator->second.type;
5555 function_use += "(((a*128u)+(b*64u)+(c*32u)+(d*16u)+(e*8u)+(f*4u)+(g*2u)+h));\n";
5556 function_use += " " + iteration_loop_end;
5558 verification += " float result = 0.0;\n";
5559 verification += " if(gfunc(z, z) == true)\n";
5560 verification += " {\n";
5561 verification += " result = 1.0;\n\n";
5562 verification += " }\n";
5563 verification += " else\n";
5564 verification += " {\n";
5565 verification += " result = 0.0;\n\n";
5566 verification += " }\n";
5568 if (false == test_compute)
5570 this->execute_draw_test(tested_shader_type, function_definition, function_use, verification);
5574 this->execute_dispatch_test(tested_shader_type, function_definition, function_use, verification);
5577 /* Deallocate any resources used. */
5578 this->delete_objects();
5579 } /* if var_type iterator found */
5582 TCU_FAIL("Type not found.");
5587 /* Generates the shader source code for the InteractionArgumentAliasing3
5588 * array tests, and attempts to compile each test shader, for both
5589 * vertex and fragment shaders.
5591 * @tparam API Tested API descriptor
5593 * @param tested_shader_type The type of shader that is being tested
5594 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
5596 template <class API>
5597 void InteractionArgumentAliasing3<API>::test_shader_compilation(
5598 typename TestCaseBase<API>::TestShaderType tested_shader_type)
5600 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_MAT4 };
5601 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
5603 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_MAT4,
5604 VAR_TYPE_DOUBLE, VAR_TYPE_DMAT4 };
5605 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
5607 const std::string iteration_loop_end = " }\n"
5615 const std::string iteration_loop_start = " for (uint a = 0u; a < 2u; a++)\n"
5617 " for (uint b = 0u; b < 2u; b++)\n"
5619 " for (uint c = 0u; c < 2u; c++)\n"
5621 " for (uint d = 0u; d < 2u; d++)\n"
5623 " for (uint e = 0u; e < 2u; e++)\n"
5625 " for (uint f = 0u; f < 2u; f++)\n"
5627 " for (uint g = 0u; g < 2u; g++)\n"
5629 " for (uint h = 0u; h < 2u; h++)\n"
5631 const glcts::test_var_type* var_types_set = var_types_set_es;
5632 size_t num_var_types = num_var_types_es;
5633 const bool test_compute = (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type);
5635 if (API::USE_DOUBLE)
5637 var_types_set = var_types_set_gl;
5638 num_var_types = num_var_types_gl;
5641 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
5643 _supported_variable_types_map_const_iterator var_iterator =
5644 supported_variable_types_map.find(var_types_set[var_type_index]);
5646 if (var_iterator != supported_variable_types_map.end())
5648 std::string array_declaration = var_iterator->second.type + " z[2][2][2][2][2][2][2][2];\n\n";
5650 std::string function_definition;
5651 std::string function_use;
5652 std::string verification;
5654 function_definition += "bool gfunc(out " + var_iterator->second.type + " x[2][2][2][2][2][2][2][2], ";
5655 function_definition += var_iterator->second.type + " y[2][2][2][2][2][2][2][2])\n";
5656 function_definition += "{\n";
5657 function_definition += " " + iteration_loop_start;
5658 function_definition +=
5659 " x[a][b][c][d][e][f][g][h] = " + var_iterator->second.type +
5661 function_definition += " " + iteration_loop_end;
5662 function_definition += "\n";
5663 function_definition += " " + iteration_loop_start;
5664 function_definition += " if(y[a][b][c][d][e][f][g][h]";
5665 if (var_iterator->second.type == "mat4") // mat4 comparison
5667 function_definition += "[0][0]";
5668 function_definition += " != float";
5670 else if (var_iterator->second.type == "dmat4") // dmat4 comparison
5672 function_definition += "[0][0]";
5673 function_definition += " != double";
5677 function_definition += " != ";
5678 function_definition += var_iterator->second.type;
5680 function_definition += "(((a*128u)+(b*64u)+(c*32u)+(d*16u)+(e*8u)+(f*4u)+(g*2u)+h))) {return false;}\n";
5681 function_definition += " " + iteration_loop_end;
5682 function_definition += " return true;\n";
5683 function_definition += "}\n\n";
5685 function_use += " " + array_declaration;
5686 function_use += " " + iteration_loop_start;
5687 function_use += " z[a][b][c][d][e][f][g][h] = ";
5688 function_use += var_iterator->second.type;
5689 function_use += "(((a*128u)+(b*64u)+(c*32u)+(d*16u)+(e*8u)+(f*4u)+(g*2u)+h));\n";
5690 function_use += " " + iteration_loop_end;
5692 verification += " float result = 0.0;\n";
5693 verification += " if(gfunc(z, z) == true)\n";
5694 verification += " {\n";
5695 verification += " result = 1.0;\n\n";
5696 verification += " }\n";
5697 verification += " else\n";
5698 verification += " {\n";
5699 verification += " result = 0.0;\n\n";
5700 verification += " }\n";
5702 if (false == test_compute)
5704 this->execute_draw_test(tested_shader_type, function_definition, function_use, verification);
5708 this->execute_dispatch_test(tested_shader_type, function_definition, function_use, verification);
5711 /* Deallocate any resources used. */
5712 this->delete_objects();
5713 } /* if var_type iterator found */
5716 TCU_FAIL("Type not found.");
5721 /* Generates the shader source code for the InteractionArgumentAliasing4
5722 * array tests, and attempts to compile each test shader, for both
5723 * vertex and fragment shaders.
5725 * @tparam API Tested API descriptor
5727 * @param tested_shader_type The type of shader that is being tested
5728 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
5730 template <class API>
5731 void InteractionArgumentAliasing4<API>::test_shader_compilation(
5732 typename TestCaseBase<API>::TestShaderType tested_shader_type)
5734 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_MAT4 };
5735 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
5737 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_MAT4,
5738 VAR_TYPE_DOUBLE, VAR_TYPE_DMAT4 };
5739 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
5741 const std::string iteration_loop_end = " }\n"
5749 const std::string iteration_loop_start = " for (uint a = 0u; a < 2u; a++)\n"
5751 " for (uint b = 0u; b < 2u; b++)\n"
5753 " for (uint c = 0u; c < 2u; c++)\n"
5755 " for (uint d = 0u; d < 2u; d++)\n"
5757 " for (uint e = 0u; e < 2u; e++)\n"
5759 " for (uint f = 0u; f < 2u; f++)\n"
5761 " for (uint g = 0u; g < 2u; g++)\n"
5763 " for (uint h = 0u; h < 2u; h++)\n"
5765 const glcts::test_var_type* var_types_set = var_types_set_es;
5766 size_t num_var_types = num_var_types_es;
5767 const bool test_compute = (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type);
5769 if (API::USE_DOUBLE)
5771 var_types_set = var_types_set_gl;
5772 num_var_types = num_var_types_gl;
5775 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
5777 _supported_variable_types_map_const_iterator var_iterator =
5778 supported_variable_types_map.find(var_types_set[var_type_index]);
5780 if (var_iterator != supported_variable_types_map.end())
5782 std::string array_declaration = var_iterator->second.type + "[2][2][2][2][2][2][2][2] z;\n\n";
5784 std::string function_definition;
5785 std::string function_use;
5786 std::string verification;
5788 function_definition += "bool gfunc(" + var_iterator->second.type + " x[2][2][2][2][2][2][2][2], ";
5789 function_definition += "out " + var_iterator->second.type + " y[2][2][2][2][2][2][2][2])\n";
5790 function_definition += "{\n";
5791 function_definition += " " + iteration_loop_start;
5792 function_definition +=
5793 " y[a][b][c][d][e][f][g][h] = " + var_iterator->second.type +
5795 function_definition += " " + iteration_loop_end;
5796 function_definition += "\n";
5797 function_definition += " " + iteration_loop_start;
5798 function_definition += " if(x[a][b][c][d][e][f][g][h]";
5799 if (var_iterator->second.type == "mat4") // mat4 comparison
5801 function_definition += "[0][0]";
5802 function_definition += " != float";
5804 else if (var_iterator->second.type == "dmat4") // dmat4 comparison
5806 function_definition += "[0][0]";
5807 function_definition += " != double";
5811 function_definition += " != ";
5812 function_definition += var_iterator->second.type;
5814 function_definition += "(((a*128u)+(b*64u)+(c*32u)+(d*16u)+(e*8u)+(f*4u)+(g*2u)+h))) {return false;}\n";
5815 function_definition += " " + iteration_loop_end;
5816 function_definition += " return true;\n";
5817 function_definition += "}\n\n";
5819 function_use += " " + array_declaration;
5820 function_use += " " + iteration_loop_start;
5821 function_use += " z[a][b][c][d][e][f][g][h] = ";
5822 function_use += var_iterator->second.type;
5823 function_use += "(((a*128u)+(b*64u)+(c*32u)+(d*16u)+(e*8u)+(f*4u)+(g*2u)+h));\n";
5824 function_use += " " + iteration_loop_end;
5826 verification += " float result = 0.0;\n";
5827 verification += " if(gfunc(z, z) == true)\n";
5828 verification += " {\n";
5829 verification += " result = 1.0;\n\n";
5830 verification += " }\n";
5831 verification += " else\n";
5832 verification += " {\n";
5833 verification += " result = 0.0;\n\n";
5834 verification += " }\n";
5836 if (false == test_compute)
5838 this->execute_draw_test(tested_shader_type, function_definition, function_use, verification);
5842 this->execute_dispatch_test(tested_shader_type, function_definition, function_use, verification);
5845 /* Deallocate any resources used. */
5846 this->delete_objects();
5847 } /* if var_type iterator found */
5850 TCU_FAIL("Type not found.");
5855 /* Generates the shader source code for the InteractionArgumentAliasing3
5856 * array tests, and attempts to compile each test shader, for both
5857 * vertex and fragment shaders.
5859 * @tparam API Tested API descriptor
5861 * @param tested_shader_type The type of shader that is being tested
5862 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
5864 template <class API>
5865 void InteractionArgumentAliasing5<API>::test_shader_compilation(
5866 typename TestCaseBase<API>::TestShaderType tested_shader_type)
5868 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_MAT4 };
5869 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
5871 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_MAT4,
5872 VAR_TYPE_DOUBLE, VAR_TYPE_DMAT4 };
5873 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
5875 const std::string iteration_loop_end = " }\n"
5883 const std::string iteration_loop_start = " for (uint a = 0u; a < 2u; a++)\n"
5885 " for (uint b = 0u; b < 2u; b++)\n"
5887 " for (uint c = 0u; c < 2u; c++)\n"
5889 " for (uint d = 0u; d < 2u; d++)\n"
5891 " for (uint e = 0u; e < 2u; e++)\n"
5893 " for (uint f = 0u; f < 2u; f++)\n"
5895 " for (uint g = 0u; g < 2u; g++)\n"
5897 " for (uint h = 0u; h < 2u; h++)\n"
5899 const glcts::test_var_type* var_types_set = var_types_set_es;
5900 size_t num_var_types = num_var_types_es;
5901 const bool test_compute = (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type);
5903 if (API::USE_DOUBLE)
5905 var_types_set = var_types_set_gl;
5906 num_var_types = num_var_types_gl;
5909 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
5911 _supported_variable_types_map_const_iterator var_iterator =
5912 supported_variable_types_map.find(var_types_set[var_type_index]);
5914 if (var_iterator != supported_variable_types_map.end())
5916 std::string array_declaration = var_iterator->second.type + "[2][2][2][2][2][2][2][2] z;\n\n";
5918 std::string function_definition;
5919 std::string function_use;
5920 std::string verification;
5922 function_definition += "bool gfunc(inout " + var_iterator->second.type + " x[2][2][2][2][2][2][2][2], ";
5923 function_definition += var_iterator->second.type + " y[2][2][2][2][2][2][2][2])\n";
5924 function_definition += "{\n";
5925 function_definition += " " + iteration_loop_start;
5926 function_definition +=
5927 " x[a][b][c][d][e][f][g][h] = " + var_iterator->second.type +
5929 function_definition += " " + iteration_loop_end;
5930 function_definition += "\n";
5931 function_definition += " " + iteration_loop_start;
5932 function_definition += " if(y[a][b][c][d][e][f][g][h]";
5933 if (var_iterator->second.type == "mat4") // mat4 comparison
5935 function_definition += "[0][0]";
5936 function_definition += " != float";
5938 else if (var_iterator->second.type == "dmat4") // dmat4 comparison
5940 function_definition += "[0][0]";
5941 function_definition += " != double";
5945 function_definition += " != ";
5946 function_definition += var_iterator->second.type;
5948 function_definition += "(((a*128u)+(b*64u)+(c*32u)+(d*16u)+(e*8u)+(f*4u)+(g*2u)+h))) {return false;}\n";
5949 function_definition += " " + iteration_loop_end;
5950 function_definition += " return true;\n";
5951 function_definition += "}\n\n";
5953 function_use += " " + array_declaration;
5954 function_use += " " + iteration_loop_start;
5955 function_use += " z[a][b][c][d][e][f][g][h] = ";
5956 function_use += var_iterator->second.type;
5957 function_use += "(((a*128u)+(b*64u)+(c*32u)+(d*16u)+(e*8u)+(f*4u)+(g*2u)+h));\n";
5958 function_use += " " + iteration_loop_end;
5960 verification += " float result = 0.0;\n";
5961 verification += " if(gfunc(z, z) == true)\n";
5962 verification += " {\n";
5963 verification += " result = 1.0;\n\n";
5964 verification += " }\n";
5965 verification += " else\n";
5966 verification += " {\n";
5967 verification += " result = 0.0;\n\n";
5968 verification += " }\n";
5970 if (false == test_compute)
5972 this->execute_draw_test(tested_shader_type, function_definition, function_use, verification);
5976 this->execute_dispatch_test(tested_shader_type, function_definition, function_use, verification);
5979 /* Deallocate any resources used. */
5980 this->delete_objects();
5981 } /* if var_type iterator found */
5984 TCU_FAIL("Type not found.");
5989 /* Generates the shader source code for the InteractionArgumentAliasing4
5990 * array tests, and attempts to compile each test shader, for both
5991 * vertex and fragment shaders.
5993 * @tparam API Tested API descriptor
5995 * @param tested_shader_type The type of shader that is being tested
5996 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
5998 template <class API>
5999 void InteractionArgumentAliasing6<API>::test_shader_compilation(
6000 typename TestCaseBase<API>::TestShaderType tested_shader_type)
6002 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_MAT4 };
6003 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
6005 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_MAT4,
6006 VAR_TYPE_DOUBLE, VAR_TYPE_DMAT4 };
6007 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
6009 const std::string iteration_loop_end = " }\n"
6017 const std::string iteration_loop_start = " for (uint a = 0u; a < 2u; a++)\n"
6019 " for (uint b = 0u; b < 2u; b++)\n"
6021 " for (uint c = 0u; c < 2u; c++)\n"
6023 " for (uint d = 0u; d < 2u; d++)\n"
6025 " for (uint e = 0u; e < 2u; e++)\n"
6027 " for (uint f = 0u; f < 2u; f++)\n"
6029 " for (uint g = 0u; g < 2u; g++)\n"
6031 " for (uint h = 0u; h < 2u; h++)\n"
6033 const glcts::test_var_type* var_types_set = var_types_set_es;
6034 size_t num_var_types = num_var_types_es;
6035 const bool test_compute = (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type);
6037 if (API::USE_DOUBLE)
6039 var_types_set = var_types_set_gl;
6040 num_var_types = num_var_types_gl;
6043 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
6045 _supported_variable_types_map_const_iterator var_iterator =
6046 supported_variable_types_map.find(var_types_set[var_type_index]);
6048 if (var_iterator != supported_variable_types_map.end())
6050 std::string array_declaration = var_iterator->second.type + "[2][2][2][2][2][2][2][2] z;\n\n";
6052 std::string function_definition;
6053 std::string function_use;
6054 std::string verification;
6056 function_definition += "bool gfunc(" + var_iterator->second.type + " x[2][2][2][2][2][2][2][2], ";
6057 function_definition += "inout " + var_iterator->second.type + " y[2][2][2][2][2][2][2][2])\n";
6058 function_definition += "{\n";
6059 function_definition += " " + iteration_loop_start;
6060 function_definition +=
6061 " y[a][b][c][d][e][f][g][h] = " + var_iterator->second.type +
6063 function_definition += " " + iteration_loop_end;
6064 function_definition += "\n";
6065 function_definition += " " + iteration_loop_start;
6066 function_definition += " if(x[a][b][c][d][e][f][g][h]";
6067 if (var_iterator->second.type == "mat4") // mat4 comparison
6069 function_definition += "[0][0]";
6070 function_definition += " != float";
6072 else if (var_iterator->second.type == "dmat4") // dmat4 comparison
6074 function_definition += "[0][0]";
6075 function_definition += " != double";
6079 function_definition += " != ";
6080 function_definition += var_iterator->second.type;
6082 function_definition += "(((a*128u)+(b*64u)+(c*32u)+(d*16u)+(e*8u)+(f*4u)+(g*2u)+h))) {return false;}\n";
6083 function_definition += " " + iteration_loop_end;
6084 function_definition += " return true;\n";
6085 function_definition += "}\n\n";
6087 function_use += " " + array_declaration;
6088 function_use += " " + iteration_loop_start;
6089 function_use += " z[a][b][c][d][e][f][g][h] = ";
6090 function_use += var_iterator->second.type;
6091 function_use += "(((a*128u)+(b*64u)+(c*32u)+(d*16u)+(e*8u)+(f*4u)+(g*2u)+h));\n";
6092 function_use += " " + iteration_loop_end;
6094 verification += " float result = 0.0;\n";
6095 verification += " if(gfunc(z, z) == true)\n";
6096 verification += " {\n";
6097 verification += " result = 1.0;\n\n";
6098 verification += " }\n";
6099 verification += " else\n";
6100 verification += " {\n";
6101 verification += " result = 0.0;\n\n";
6102 verification += " }\n";
6104 if (false == test_compute)
6106 this->execute_draw_test(tested_shader_type, function_definition, function_use, verification);
6110 this->execute_dispatch_test(tested_shader_type, function_definition, function_use, verification);
6113 /* Deallocate any resources used. */
6114 this->delete_objects();
6115 } /* if var_type iterator found */
6118 TCU_FAIL("Type not found.");
6123 /* Generates the shader source code for the InteractionUniforms1
6124 * array tests, and attempts to compile each test shader, for both
6125 * vertex and fragment shaders.
6127 * @tparam API Tested API descriptor
6129 * @param tested_shader_type The type of shader that is being tested
6130 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
6132 template <class API>
6133 void InteractionUniforms1<API>::test_shader_compilation(typename TestCaseBase<API>::TestShaderType tested_shader_type)
6135 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_FLOAT, VAR_TYPE_INT, VAR_TYPE_UINT };
6136 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
6138 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_FLOAT, VAR_TYPE_INT, VAR_TYPE_UINT,
6140 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
6142 const glw::Functions& gl = this->context_id.getRenderContext().getFunctions();
6143 const glcts::test_var_type* var_types_set = var_types_set_es;
6144 size_t num_var_types = num_var_types_es;
6146 if (API::USE_DOUBLE)
6148 var_types_set = var_types_set_gl;
6149 num_var_types = num_var_types_gl;
6152 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
6154 _supported_variable_types_map_const_iterator var_iterator =
6155 supported_variable_types_map.find(var_types_set[var_type_index]);
6157 if (var_iterator != supported_variable_types_map.end())
6159 std::string uniform_definition;
6160 std::string uniform_use;
6162 uniform_definition += "uniform ";
6163 uniform_definition += var_iterator->second.precision;
6164 uniform_definition += " ";
6165 uniform_definition += var_iterator->second.type;
6166 uniform_definition += " my_uniform_1[1][1][1][1];\n\n";
6168 uniform_use = " float result = float(my_uniform_1[0][0][0][0]);\n";
6170 if (API::USE_ALL_SHADER_STAGES)
6172 const std::string& compute_shader_source =
6173 this->prepare_compute_shader(tested_shader_type, uniform_definition, uniform_use);
6174 const std::string& fragment_shader_source =
6175 this->prepare_fragment_shader(tested_shader_type, uniform_definition, uniform_use);
6176 const std::string& geometry_shader_source =
6177 this->prepare_geometry_shader(tested_shader_type, uniform_definition, uniform_use);
6178 const std::string& tess_ctrl_shader_source =
6179 this->prepare_tess_ctrl_shader(tested_shader_type, uniform_definition, uniform_use);
6180 const std::string& tess_eval_shader_source =
6181 this->prepare_tess_eval_shader(tested_shader_type, uniform_definition, uniform_use);
6182 const std::string& vertex_shader_source =
6183 this->prepare_vertex_shader(tested_shader_type, uniform_definition, uniform_use);
6185 switch (tested_shader_type)
6187 case TestCaseBase<API>::VERTEX_SHADER_TYPE: /* Fall through */
6188 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
6189 this->execute_positive_test(vertex_shader_source, fragment_shader_source, false, false);
6192 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
6193 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
6194 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE: /* Fall through */
6195 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
6196 this->execute_positive_test(vertex_shader_source, tess_ctrl_shader_source, tess_eval_shader_source,
6197 geometry_shader_source, fragment_shader_source, compute_shader_source,
6202 TCU_FAIL("Invalid enum");
6208 const std::string& fragment_shader_source =
6209 this->prepare_fragment_shader(tested_shader_type, uniform_definition, uniform_use);
6210 const std::string& vertex_shader_source =
6211 this->prepare_vertex_shader(tested_shader_type, uniform_definition, uniform_use);
6213 this->execute_positive_test(vertex_shader_source, fragment_shader_source, false, false);
6216 glw::GLint uniform_location = -1;
6218 /* Make program object active. */
6219 gl.useProgram(this->program_object_id);
6220 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram() failed.");
6222 /* Get uniform location. */
6223 uniform_location = gl.getUniformLocation(this->program_object_id, "my_uniform_1[0][0][0][0]");
6224 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation() failed.");
6226 if (uniform_location == -1)
6228 TCU_FAIL("Uniform is not found or is considered as not active.");
6231 switch (var_type_index)
6233 case 0: //float type of uniform is considered
6235 glw::GLfloat uniform_value = 1.0f;
6237 gl.uniform1f(uniform_location, uniform_value);
6238 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1f() failed.");
6242 case 1: //int type of uniform is considered
6244 glw::GLint uniform_value = 1;
6246 gl.uniform1i(uniform_location, uniform_value);
6247 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i() failed.");
6251 case 2: //uint type of uniform is considered
6253 glw::GLuint uniform_value = 1;
6255 gl.uniform1ui(uniform_location, uniform_value);
6256 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1ui() failed.");
6260 case 3: //double type of uniform is considered
6262 glw::GLdouble uniform_value = 1.0;
6264 gl.uniform1d(uniform_location, uniform_value);
6265 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1d() failed.");
6271 TCU_FAIL("Invalid variable-type index.");
6275 } /* switch (var_type_index) */
6277 /* Deallocate any resources used. */
6278 this->delete_objects();
6279 } /* if var_type iterator found */
6282 TCU_FAIL("Type not found.");
6284 } /* for (int var_type_index = 0; ...) */
6289 * @tparam API Tested API descriptor
6291 * @param tested_shader_type The type of shader that is being tested
6292 * @param uniform_definition Definition used to prepare shader
6293 * @param uniform_use Snippet that use defined uniform
6295 template <class API>
6296 std::string InteractionUniforms1<API>::prepare_compute_shader(
6297 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& uniform_definition,
6298 const std::string& uniform_use)
6300 std::string compute_shader_source;
6302 if (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type)
6304 compute_shader_source = "writeonly uniform image2D uni_image;\n"
6307 /* User-defined function definition. */
6308 compute_shader_source += uniform_definition;
6309 compute_shader_source += "\n\n";
6311 /* Main function definition. */
6312 compute_shader_source += shader_start;
6313 compute_shader_source += uniform_use;
6314 compute_shader_source += "\n\n";
6315 compute_shader_source += "\n"
6316 " imageStore(uni_image, ivec2(gl_GlobalInvocationID.xy), vec4(result, 0, 0, 0));\n"
6321 return compute_shader_source;
6326 * @tparam API Tested API descriptor
6328 * @param tested_shader_type The type of shader that is being tested
6329 * @param uniform_definition Definition used to prepare shader
6330 * @param uniform_use Snippet that use defined uniform
6332 template <class API>
6333 std::string InteractionUniforms1<API>::prepare_fragment_shader(
6334 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& uniform_definition,
6335 const std::string& uniform_use)
6337 std::string fragment_shader_source;
6339 switch (tested_shader_type)
6341 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
6344 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
6345 fragment_shader_source = "out vec4 colour;\n\n";
6347 /* User-defined function definition. */
6348 fragment_shader_source += uniform_definition;
6349 fragment_shader_source += "\n\n";
6351 /* Main function definition. */
6352 fragment_shader_source += shader_start;
6353 fragment_shader_source += uniform_use;
6354 fragment_shader_source += "\n\n";
6355 fragment_shader_source += " colour = vec4(result);\n";
6356 fragment_shader_source += shader_end;
6359 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
6360 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
6361 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
6362 fragment_shader_source = "in float fs_result;\n\n"
6363 "out vec4 colour;\n\n"
6366 " colour = vec4(fs_result);\n"
6371 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
6372 fragment_shader_source = default_fragment_shader_source;
6376 TCU_FAIL("Unrecognized shader object type.");
6380 return fragment_shader_source;
6385 * @tparam API Tested API descriptor
6387 * @param tested_shader_type The type of shader that is being tested
6388 * @param uniform_definition Definition used to prepare shader
6389 * @param uniform_use Snippet that use defined uniform
6391 template <class API>
6392 std::string InteractionUniforms1<API>::prepare_geometry_shader(
6393 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& uniform_definition,
6394 const std::string& uniform_use)
6396 std::string geometry_shader_source;
6398 switch (tested_shader_type)
6400 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
6401 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
6402 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
6405 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
6406 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
6407 geometry_shader_source = "layout(points) in;\n"
6408 "layout(triangle_strip, max_vertices = 4) out;\n"
6410 "in float tes_result[];\n"
6411 "out float fs_result;\n"
6415 " gl_Position = vec4(-1, -1, 0, 1);\n"
6416 " fs_result = tes_result[0];\n"
6418 " gl_Position = vec4(-1, 1, 0, 1);\n"
6419 " fs_result = tes_result[0];\n"
6421 " gl_Position = vec4(1, -1, 0, 1);\n"
6422 " fs_result = tes_result[0];\n"
6424 " gl_Position = vec4(1, 1, 0, 1);\n"
6425 " fs_result = tes_result[0];\n"
6430 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
6431 geometry_shader_source = "layout(points) in;\n"
6432 "layout(triangle_strip, max_vertices = 4) out;\n"
6434 "out float fs_result;\n"
6437 /* User-defined function definition. */
6438 geometry_shader_source += uniform_definition;
6439 geometry_shader_source += "\n\n";
6441 /* Main function definition. */
6442 geometry_shader_source += shader_start;
6443 geometry_shader_source += uniform_use;
6444 geometry_shader_source += "\n\n";
6445 geometry_shader_source += "\n gl_Position = vec4(-1, -1, 0, 1);\n"
6446 " fs_result = result;\n"
6448 " gl_Position = vec4(-1, 1, 0, 1);\n"
6449 " fs_result = result;\n"
6451 " gl_Position = vec4(1, -1, 0, 1);\n"
6452 " fs_result = result;\n"
6454 " gl_Position = vec4(1, 1, 0, 1);\n"
6455 " fs_result = result;\n"
6461 TCU_FAIL("Unrecognized shader object type.");
6465 return geometry_shader_source;
6470 * @tparam API Tested API descriptor
6472 * @param tested_shader_type The type of shader that is being tested
6473 * @param uniform_definition Definition used to prepare shader
6474 * @param uniform_use Snippet that use defined uniform
6476 template <class API>
6477 std::string InteractionUniforms1<API>::prepare_tess_ctrl_shader(
6478 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& uniform_definition,
6479 const std::string& uniform_use)
6481 std::string tess_ctrl_shader_source;
6483 switch (tested_shader_type)
6485 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
6486 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
6487 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
6488 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
6491 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
6492 tess_ctrl_shader_source = "layout(vertices = 1) out;\n"
6494 "out float tcs_result[];\n"
6497 /* User-defined function definition. */
6498 tess_ctrl_shader_source += uniform_definition;
6499 tess_ctrl_shader_source += "\n\n";
6501 /* Main function definition. */
6502 tess_ctrl_shader_source += shader_start;
6503 tess_ctrl_shader_source += uniform_use;
6504 tess_ctrl_shader_source += "\n\n";
6505 tess_ctrl_shader_source += " tcs_result[gl_InvocationID] = result;\n"
6507 " gl_TessLevelOuter[0] = 1.0;\n"
6508 " gl_TessLevelOuter[1] = 1.0;\n"
6509 " gl_TessLevelOuter[2] = 1.0;\n"
6510 " gl_TessLevelOuter[3] = 1.0;\n"
6511 " gl_TessLevelInner[0] = 1.0;\n"
6512 " gl_TessLevelInner[1] = 1.0;\n"
6516 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
6517 tess_ctrl_shader_source = default_tc_shader_source;
6521 TCU_FAIL("Unrecognized shader object type.");
6525 return tess_ctrl_shader_source;
6530 * @tparam API Tested API descriptor
6532 * @param tested_shader_type The type of shader that is being tested
6533 * @param uniform_definition Definition used to prepare shader
6534 * @param uniform_use Snippet that use defined uniform
6536 template <class API>
6537 std::string InteractionUniforms1<API>::prepare_tess_eval_shader(
6538 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& uniform_definition,
6539 const std::string& uniform_use)
6541 std::string tess_eval_shader_source;
6543 switch (tested_shader_type)
6545 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
6546 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
6547 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
6548 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
6551 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
6552 tess_eval_shader_source = "layout(isolines, point_mode) in;\n"
6554 "in float tcs_result[];\n"
6555 "out float tes_result;\n"
6559 " tes_result = tcs_result[0];\n"
6563 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
6564 tess_eval_shader_source = "layout(isolines, point_mode) in;\n"
6566 "out float tes_result;\n"
6569 /* User-defined function definition. */
6570 tess_eval_shader_source += uniform_definition;
6571 tess_eval_shader_source += "\n\n";
6573 /* Main function definition. */
6574 tess_eval_shader_source += shader_start;
6575 tess_eval_shader_source += uniform_use;
6576 tess_eval_shader_source += "\n\n";
6577 tess_eval_shader_source += " tes_result = result;\n"
6582 TCU_FAIL("Unrecognized shader object type.");
6586 return tess_eval_shader_source;
6591 * @tparam API Tested API descriptor
6593 * @param tested_shader_type The type of shader that is being tested
6594 * @param uniform_definition Definition used to prepare shader
6595 * @param uniform_use Snippet that use defined uniform
6597 template <class API>
6598 std::string InteractionUniforms1<API>::prepare_vertex_shader(
6599 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& uniform_definition,
6600 const std::string& uniform_use)
6602 std::string vertex_shader_source;
6604 switch (tested_shader_type)
6606 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
6609 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
6610 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
6611 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
6612 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
6613 vertex_shader_source = default_vertex_shader_source;
6616 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
6617 /* User-defined function definition. */
6618 vertex_shader_source += uniform_definition;
6620 /* Main function definition. */
6621 vertex_shader_source += shader_start;
6622 vertex_shader_source += uniform_use;
6623 vertex_shader_source += " gl_Position = vec4(result);\n";
6624 vertex_shader_source += shader_end;
6628 TCU_FAIL("Unrecognized shader object type.");
6632 return vertex_shader_source;
6635 /* Generates the shader source code for the InteractionUniforms2
6636 * array tests, and attempts to compile each test shader, for both
6637 * vertex and fragment shaders.
6639 * @tparam API Tested API descriptor
6641 * @param tested_shader_type The type of shader that is being tested
6642 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
6644 template <class API>
6645 void InteractionUniforms2<API>::test_shader_compilation(typename TestCaseBase<API>::TestShaderType tested_shader_type)
6647 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_MAT4 };
6648 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
6650 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_MAT4,
6651 VAR_TYPE_DOUBLE, VAR_TYPE_DMAT4 };
6652 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
6654 const std::string array_initializers[] = { "int[2][2][2][2](\n"
6667 " int[2](11, 12),\n"
6671 " int[2](15, 16),\n"
6677 "float[2][2][2][2](\n"
6678 " float[2][2][2](\n"
6680 " float[2](1.0, 2.0),\n"
6681 " float[2](3.0, 4.0)),\n"
6683 " float[2](5.0, 6.0),\n"
6684 " float[2](7.0, 8.0))),\n"
6685 " float[2][2][2](\n"
6687 " float[2](1.1, 2.1),\n"
6688 " float[2](3.1, 4.1)\n"
6691 " float[2](5.1, 6.1),\n"
6692 " float[2](7.1, 8.1)\n"
6697 "mat4[2][2][2][2](\n"
6700 " mat4[2]( mat4(1), mat4(2)),\n"
6701 " mat4[2]( mat4(3), mat4(4))\n"
6704 " mat4[2](mat4(5), mat4(6)),\n"
6705 " mat4[2](mat4(7), mat4(8))\n"
6710 " mat4[2](mat4(9), mat4(10)),\n"
6711 " mat4[2](mat4(11), mat4(12))\n"
6714 " mat4[2](mat4(13), mat4(14)),\n"
6715 " mat4[2](mat4(15), mat4(16))\n"
6720 "double[2][2][2][2](\n"
6721 " double[2][2][2](\n"
6723 " double[2](1.0, 2.0),\n"
6724 " double[2](3.0, 4.0)),\n"
6726 " double[2](5.0, 6.0),\n"
6727 " double[2](7.0, 8.0))),\n"
6728 " double[2][2][2](\n"
6730 " double[2](1.1, 2.1),\n"
6731 " double[2](3.1, 4.1)\n"
6734 " double[2](5.1, 6.1),\n"
6735 " double[2](7.1, 8.1)\n"
6740 "dmat4[2][2][2][2](\n"
6741 " dmat4[2][2][2](\n"
6743 " dmat4[2]( dmat4(1), dmat4(2)),\n"
6744 " dmat4[2]( dmat4(3), dmat4(4))\n"
6747 " dmat4[2](dmat4(5), dmat4(6)),\n"
6748 " dmat4[2](dmat4(7), dmat4(8))\n"
6751 " dmat4[2][2][2](\n"
6753 " dmat4[2](dmat4(9), dmat4(10)),\n"
6754 " dmat4[2](dmat4(11), dmat4(12))\n"
6757 " dmat4[2](dmat4(13), dmat4(14)),\n"
6758 " dmat4[2](dmat4(15), dmat4(16))\n"
6763 const glcts::test_var_type* var_types_set = var_types_set_es;
6764 size_t num_var_types = num_var_types_es;
6766 if (API::USE_DOUBLE)
6768 var_types_set = var_types_set_gl;
6769 num_var_types = num_var_types_gl;
6772 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
6774 _supported_variable_types_map_const_iterator var_iterator =
6775 supported_variable_types_map.find(var_types_set[var_type_index]);
6777 if (var_iterator != supported_variable_types_map.end())
6779 std::string base_variable_string;
6781 for (int initialiser_selector = 1; initialiser_selector >= 0; initialiser_selector--)
6783 // We normally do all 16 possible permutations of [4][4][4][4] items (15..0).
6784 // However, in this case we will skip the case that will work,
6785 // so we'll merely process permutations 14..0
6786 for (int permutation_index = 14; permutation_index >= 0; permutation_index--)
6788 base_variable_string =
6789 "uniform " + var_iterator->second.precision + " " + var_iterator->second.type + " x";
6791 // for all 4 possible sub_script entries
6792 for (int sub_script_entry_index = 3; sub_script_entry_index >= 0; sub_script_entry_index--)
6794 if (permutation_index & (1 << sub_script_entry_index))
6796 // In this case, we'll use a valid sub_script
6797 base_variable_string += "[2]";
6801 // In this case, we'll use an invalid sub_script
6802 base_variable_string += "[]";
6806 if (initialiser_selector == 0)
6808 // We'll use an initialiser
6809 base_variable_string += " = " + array_initializers[var_type_index];
6812 base_variable_string += ";\n\n";
6814 std::string shader_source = base_variable_string + shader_start;
6817 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
6821 * This will succeed in case of allowed unsized
6822 * declarations and when at least one of these is
6824 * 1. There is an initialiser.
6825 * 2. Only the outermost dimension is unsized,
6826 * as in [][2][2][2].
6828 EXECUTE_SHADER_TEST(API::ALLOW_UNSIZED_DECLARATION &&
6829 (initialiser_selector == 0 || permutation_index == 7),
6830 tested_shader_type, shader_source);
6831 } /* for (int permutation_index = 14; ...) */
6832 } /* for (int initialiser_selector = 1; ...) */
6833 } /* if var_type iterator found */
6836 TCU_FAIL("Type not found.");
6838 } /* for (int var_type_index = 0; ...) */
6841 /* Generates the shader source code for the InteractionUniformBuffers1
6842 * array tests, and attempts to compile each test shader, for both
6843 * vertex and fragment shaders.
6845 * @tparam API Tested API descriptor
6847 * @param tested_shader_type The type of shader that is being tested
6848 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
6850 template <class API>
6851 void InteractionUniformBuffers1<API>::test_shader_compilation(
6852 typename TestCaseBase<API>::TestShaderType tested_shader_type)
6854 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_FLOAT, VAR_TYPE_INT, VAR_TYPE_UINT };
6855 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
6857 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_FLOAT, VAR_TYPE_INT, VAR_TYPE_UINT,
6859 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
6861 const glcts::test_var_type* var_types_set = var_types_set_es;
6862 size_t num_var_types = num_var_types_es;
6864 if (API::USE_DOUBLE)
6866 var_types_set = var_types_set_gl;
6867 num_var_types = num_var_types_gl;
6870 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
6872 _supported_variable_types_map_const_iterator var_iterator =
6873 supported_variable_types_map.find(var_types_set[var_type_index]);
6875 if (var_iterator != supported_variable_types_map.end())
6877 std::string shader_source;
6879 shader_source += "uniform uBlocka {\n";
6880 shader_source += " " + var_iterator->second.type + " x[1][1][1][1][1][1];\n";
6881 shader_source += "};\n\n";
6882 shader_source += shader_start;
6885 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
6888 EXECUTE_POSITIVE_TEST(tested_shader_type, shader_source, true, false);
6889 } /* if var_type iterator found */
6892 TCU_FAIL("Type not found.");
6897 /* Generates the shader source code for the InteractionUniformBuffers2
6898 * array tests, and attempts to compile each test shader, for both
6899 * vertex and fragment shaders.
6901 * @tparam API Tested API descriptor
6903 * @param tested_shader_type The type of shader that is being tested
6904 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
6906 template <class API>
6907 void InteractionUniformBuffers2<API>::test_shader_compilation(
6908 typename TestCaseBase<API>::TestShaderType tested_shader_type)
6910 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_FLOAT, VAR_TYPE_INT, VAR_TYPE_UINT };
6911 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
6913 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_FLOAT, VAR_TYPE_INT, VAR_TYPE_UINT,
6915 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
6917 const glw::Functions& gl = this->context_id.getRenderContext().getFunctions();
6918 const glcts::test_var_type* var_types_set = var_types_set_es;
6919 size_t num_var_types = num_var_types_es;
6921 if (API::USE_DOUBLE)
6923 var_types_set = var_types_set_gl;
6924 num_var_types = num_var_types_gl;
6927 /* Iterate through float / int / uint values. */
6928 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
6930 _supported_variable_types_map_const_iterator var_iterator =
6931 supported_variable_types_map.find(var_types_set[var_type_index]);
6933 if (var_iterator != supported_variable_types_map.end())
6935 std::string uniform_definition;
6936 std::string uniform_use;
6938 uniform_definition += "layout (std140) uniform uniform_block_name\n"
6940 uniform_definition += " ";
6941 uniform_definition += var_iterator->second.type;
6942 uniform_definition += " my_uniform_1[1][1][1][1];\n"
6945 uniform_use = " float result = float(my_uniform_1[0][0][0][0]);\n";
6947 if (API::USE_ALL_SHADER_STAGES)
6949 const std::string& compute_shader_source =
6950 this->prepare_compute_shader(tested_shader_type, uniform_definition, uniform_use);
6951 const std::string& fragment_shader_source =
6952 this->prepare_fragment_shader(tested_shader_type, uniform_definition, uniform_use);
6953 const std::string& geometry_shader_source =
6954 this->prepare_geometry_shader(tested_shader_type, uniform_definition, uniform_use);
6955 const std::string& tess_ctrl_shader_source =
6956 this->prepare_tess_ctrl_shader(tested_shader_type, uniform_definition, uniform_use);
6957 const std::string& tess_eval_shader_source =
6958 this->prepare_tess_eval_shader(tested_shader_type, uniform_definition, uniform_use);
6959 const std::string& vertex_shader_source =
6960 this->prepare_vertex_shader(tested_shader_type, uniform_definition, uniform_use);
6962 switch (tested_shader_type)
6964 case TestCaseBase<API>::VERTEX_SHADER_TYPE: /* Fall through */
6965 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
6966 this->execute_positive_test(vertex_shader_source, fragment_shader_source, false, false);
6969 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
6970 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
6971 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE: /* Fall through */
6972 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
6973 this->execute_positive_test(vertex_shader_source, tess_ctrl_shader_source, tess_eval_shader_source,
6974 geometry_shader_source, fragment_shader_source, compute_shader_source,
6979 TCU_FAIL("Invalid enum");
6985 const std::string& fragment_shader_source =
6986 this->prepare_fragment_shader(tested_shader_type, uniform_definition, uniform_use);
6987 const std::string& vertex_shader_source =
6988 this->prepare_vertex_shader(tested_shader_type, uniform_definition, uniform_use);
6990 this->execute_positive_test(vertex_shader_source, fragment_shader_source, false, false);
6993 glw::GLuint buffer_object_id = 0;
6994 glw::GLint my_uniform_block_index = GL_INVALID_INDEX;
6996 gl.useProgram(this->program_object_id);
6997 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram() failed.");
6999 my_uniform_block_index = gl.getUniformBlockIndex(this->program_object_id, "uniform_block_name");
7000 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformBlockIndex() failed.");
7002 if ((unsigned)my_uniform_block_index == GL_INVALID_INDEX)
7004 TCU_FAIL("Uniform block not found or is considered as not active.");
7007 gl.genBuffers(1, &buffer_object_id);
7008 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenBuffers() failed.");
7010 gl.bindBuffer(GL_UNIFORM_BUFFER, buffer_object_id);
7011 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer() failed.");
7013 switch (var_type_index)
7015 case 0: //float type of uniform is considered
7017 glw::GLfloat buffer_data[] = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f,
7018 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f };
7020 gl.bufferData(GL_UNIFORM_BUFFER, sizeof(buffer_data), buffer_data, GL_STATIC_DRAW);
7021 GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferData() failed.");
7025 case 1: //int type of uniform is considered
7028 glw::GLint buffer_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
7030 gl.bufferData(GL_UNIFORM_BUFFER, sizeof(buffer_data), buffer_data, GL_STATIC_DRAW);
7031 GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferData() failed.");
7035 case 2: //uint type of uniform is considered
7037 glw::GLuint buffer_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
7039 gl.bufferData(GL_UNIFORM_BUFFER, sizeof(buffer_data), buffer_data, GL_STATIC_DRAW);
7040 GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferData() failed.");
7044 case 3: //double type of uniform is considered
7046 glw::GLdouble buffer_data[] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0,
7047 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0 };
7049 gl.bufferData(GL_UNIFORM_BUFFER, sizeof(buffer_data), buffer_data, GL_STATIC_DRAW);
7050 GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferData() failed.");
7056 TCU_FAIL("Invalid variable-type index.");
7060 } /* switch (var_type_index) */
7062 gl.uniformBlockBinding(this->program_object_id, my_uniform_block_index, 0);
7063 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniformBlockBinding() failed.");
7065 gl.bindBufferBase(GL_UNIFORM_BUFFER, 0, buffer_object_id);
7066 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBufferBase() failed.");
7068 if (TestCaseBase<API>::COMPUTE_SHADER_TYPE != tested_shader_type)
7070 execute_draw_test(tested_shader_type);
7074 execute_dispatch_test();
7077 /* Deallocate any resources used. */
7078 gl.deleteBuffers(1, &buffer_object_id);
7079 this->delete_objects();
7080 } /* if var_type iterator found */
7083 TCU_FAIL("Type not found.");
7085 } /* for (int var_type_index = 0; ...) */
7088 /** Executes test for compute program
7090 * @tparam API Tested API descriptor
7092 template <class API>
7093 void InteractionUniformBuffers2<API>::execute_dispatch_test()
7095 const glw::Functions& gl = this->context_id.getRenderContext().getFunctions();
7097 gl.dispatchCompute(1, 1, 1);
7098 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
7101 /** Executes test for draw program
7103 * @tparam API Tested API descriptor
7105 * @param tested_shader_type The type of shader that is being tested
7107 template <class API>
7108 void InteractionUniformBuffers2<API>::execute_draw_test(typename TestCaseBase<API>::TestShaderType tested_shader_type)
7110 const glw::Functions& gl = this->context_id.getRenderContext().getFunctions();
7112 glw::GLuint vao_id = 0;
7114 gl.genVertexArrays(1, &vao_id);
7115 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenVertexArrays() failed.");
7117 gl.bindVertexArray(vao_id);
7118 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray() failed.");
7120 switch (tested_shader_type)
7122 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
7123 case TestCaseBase<API>::VERTEX_SHADER_TYPE: /* Fall through */
7124 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
7125 gl.drawArrays(GL_POINTS, 0, 1);
7126 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
7129 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE: /* Fall through */
7130 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
7131 /* Tesselation patch set up */
7132 gl.patchParameteri(GL_PATCH_VERTICES, 1);
7133 GLU_EXPECT_NO_ERROR(gl.getError(), "PatchParameteri");
7135 gl.drawArrays(GL_PATCHES, 0, 1);
7136 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
7140 TCU_FAIL("Invalid enum");
7144 gl.deleteVertexArrays(1, &vao_id);
7145 GLU_EXPECT_NO_ERROR(gl.getError(), "glDeleteVertexArrays() failed.");
7148 /* Generates the shader source code for the InteractionUniformBuffers3
7149 * array tests, and attempts to compile each test shader, for both
7150 * vertex and fragment shaders.
7152 * @tparam API Tested API descriptor
7154 * @param tested_shader_type The type of shader that is being tested
7155 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
7157 template <class API>
7158 void InteractionUniformBuffers3<API>::test_shader_compilation(
7159 typename TestCaseBase<API>::TestShaderType tested_shader_type)
7161 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_FLOAT, VAR_TYPE_INT, VAR_TYPE_UINT };
7162 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
7164 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_FLOAT, VAR_TYPE_INT, VAR_TYPE_UINT,
7166 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
7168 const std::string invalid_size_declarations[] = { "[2][2][2][]", "[2][2][][2]", "[2][][2][2]", "[][2][2][2]",
7169 "[2][2][][]", "[2][][2][]", "[][2][2][]", "[2][][][2]",
7170 "[][2][][2]", "[][][2][2]", "[2][][][]", "[][2][][]",
7171 "[][][2][]", "[][][][2]", "[][][][]" };
7173 const std::string array_initializers[] = { "float[2][2][2][2](float[2][2][2](float[2][2](float[2](1.0, 2.0),"
7174 "float[2](3.0, 4.0)),"
7175 "float[2][2](float[2](5.0, 6.0),"
7176 "float[2](7.0, 8.0))),"
7177 "float[2][2][2](float[2][2](float[2](1.1, 2.1),"
7178 "float[2](3.1, 4.1)),"
7179 "float[2][2](float[2](5.1, 6.1),"
7180 "float[2](7.1, 8.1))));\n",
7182 "int[2][2][2][2](int[2][2][2](int[2][2](int[2]( 1, 2),"
7184 "int[2][2](int[2]( 5, 6),"
7186 "int[2][2][2](int[2][2](int[2](11, 12),"
7188 "int[2][2](int[2](15, 16),"
7189 "int[2](17, 18))));\n",
7191 "uint[2][2][2][2](uint[2][2][2](uint[2][2](uint[2]( 1u, 2u),"
7192 "uint[2]( 3u, 4u)),"
7193 "uint[2][2](uint[2]( 5u, 6u),"
7194 "uint[2]( 7u, 8u))),"
7195 "uint[2][2][2](uint[2][2](uint[2](11u, 12u),"
7196 "uint[2](13u, 14u)),"
7197 "uint[2][2](uint[2](15u, 16u),"
7198 "uint[2](17u, 18u))));\n",
7200 "double[2][2][2][2](double[2][2][2](double[2][2](double[2](1.0, 2.0),"
7201 "double[2](3.0, 4.0)),"
7202 "double[2][2](double[2](5.0, 6.0),"
7203 "double[2](7.0, 8.0))),"
7204 "double[2][2][2](double[2][2](double[2](1.1, 2.1),"
7205 "double[2](3.1, 4.1)),"
7206 "double[2][2](double[2](5.1, 6.1),"
7207 "double[2](7.1, 8.1))));\n" };
7208 const glcts::test_var_type* var_types_set = var_types_set_es;
7209 size_t num_var_types = num_var_types_es;
7211 if (API::USE_DOUBLE)
7213 var_types_set = var_types_set_gl;
7214 num_var_types = num_var_types_gl;
7217 /* Iterate through float/ int/ uint types.
7218 * Case: without initializer.
7220 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
7222 _supported_variable_types_map_const_iterator var_iterator =
7223 supported_variable_types_map.find(var_types_set[var_type_index]);
7225 if (var_iterator != supported_variable_types_map.end())
7227 for (size_t invalid_size_declarations_index = 0;
7228 invalid_size_declarations_index <
7229 sizeof(invalid_size_declarations) / sizeof(invalid_size_declarations[0]);
7230 invalid_size_declarations_index++)
7232 std::string shader_source;
7234 shader_source = "layout (std140) uniform MyUniform {\n";
7235 shader_source += " " + var_iterator->second.type +
7236 invalid_size_declarations[invalid_size_declarations_index] + " my_variable;\n";
7237 shader_source += "};\n\n";
7238 shader_source += shader_start;
7241 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
7244 EXECUTE_SHADER_TEST(API::ALLOW_UNSIZED_DECLARATION && invalid_size_declarations_index == 3,
7245 tested_shader_type, shader_source);
7246 } /* for (int invalid_size_declarations_index = 0; ...) */
7250 TCU_FAIL("Type not found.");
7252 } /* for (int var_type_index = 0; ...) */
7254 /* Iterate through float/ int/ uint types.
7255 * Case: with initializer.
7257 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
7259 _supported_variable_types_map_const_iterator var_iterator =
7260 supported_variable_types_map.find(var_types_set[var_type_index]);
7262 if (var_iterator != supported_variable_types_map.end())
7264 for (size_t invalid_size_declarations_index = 0;
7265 invalid_size_declarations_index <
7266 sizeof(invalid_size_declarations) / sizeof(invalid_size_declarations[0]);
7267 invalid_size_declarations_index++)
7269 std::string shader_source;
7271 shader_source = "layout (std140) uniform MyUniform {\n";
7272 shader_source += " " + var_iterator->second.type +
7273 invalid_size_declarations[invalid_size_declarations_index] +
7274 " my_variable = " + array_initializers[var_type_index];
7276 var_iterator->second.type + invalid_size_declarations[invalid_size_declarations_index] +
7277 " my_variable = " + array_initializers[var_type_index];
7278 shader_source += "};\n\n";
7279 shader_source += shader_start;
7282 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
7285 this->execute_negative_test(tested_shader_type, shader_source);
7286 } /* for (int invalid_size_declarations_index = 0; ...) */
7287 } /* if var_type iterator found */
7290 TCU_FAIL("Type not found.");
7292 } /* for (int var_type_index = 0; ...) */
7295 /* Generates the shader source code for the InteractionStorageBuffers1
7296 * array tests, and attempts to compile each test shader, for both
7297 * vertex and fragment shaders.
7299 * @tparam API Tested API descriptor
7301 * @param tested_shader_type The type of shader that is being tested
7302 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
7304 template <class API>
7305 void InteractionStorageBuffers1<API>::test_shader_compilation(
7306 typename TestCaseBase<API>::TestShaderType tested_shader_type)
7308 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_FLOAT, VAR_TYPE_INT, VAR_TYPE_UINT };
7309 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
7311 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_FLOAT, VAR_TYPE_INT, VAR_TYPE_UINT,
7313 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
7315 const glcts::test_var_type* var_types_set = var_types_set_es;
7316 size_t num_var_types = num_var_types_es;
7318 if (API::USE_DOUBLE)
7320 var_types_set = var_types_set_gl;
7321 num_var_types = num_var_types_gl;
7324 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
7326 _supported_variable_types_map_const_iterator var_iterator =
7327 supported_variable_types_map.find(var_types_set[var_type_index]);
7329 if (var_iterator != supported_variable_types_map.end())
7331 std::string shader_source;
7333 shader_source += "buffer uBlocka {\n";
7334 shader_source += " " + var_iterator->second.type + " x[1][1][1][1][1][1];\n";
7335 shader_source += "};\n\n";
7336 shader_source += shader_start;
7339 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
7342 EXECUTE_POSITIVE_TEST(tested_shader_type, shader_source, true, false);
7343 } /* if var_type iterator found */
7346 TCU_FAIL("Type not found.");
7351 /* Generates the shader source code for the InteractionUniformBuffers2
7352 * array tests, and attempts to compile each test shader, for both
7353 * vertex and fragment shaders.
7355 * @tparam API Tested API descriptor
7357 * @param tested_shader_type The type of shader that is being tested
7358 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
7360 template <class API>
7361 void InteractionStorageBuffers2<API>::test_shader_compilation(
7362 typename TestCaseBase<API>::TestShaderType tested_shader_type)
7364 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_FLOAT, VAR_TYPE_INT, VAR_TYPE_UINT };
7365 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
7367 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_FLOAT, VAR_TYPE_INT, VAR_TYPE_UINT,
7369 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
7371 const glw::Functions& gl = this->context_id.getRenderContext().getFunctions();
7372 const glcts::test_var_type* var_types_set = var_types_set_es;
7373 size_t num_var_types = num_var_types_es;
7375 if (API::USE_DOUBLE)
7377 var_types_set = var_types_set_gl;
7378 num_var_types = num_var_types_gl;
7381 /* Iterate through float / int / uint values. */
7382 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
7384 _supported_variable_types_map_const_iterator var_iterator =
7385 supported_variable_types_map.find(var_types_set[var_type_index]);
7387 if (var_iterator != supported_variable_types_map.end())
7389 std::string uniform_definition;
7390 std::string uniform_use;
7392 uniform_definition += "layout (std140) buffer storage_block_name\n"
7394 uniform_definition += " ";
7395 uniform_definition += var_iterator->second.type;
7396 uniform_definition += " my_storage_1[1][1][1][1];\n"
7399 uniform_use = " float result = float(my_storage_1[0][0][0][0]);\n";
7401 if (API::USE_ALL_SHADER_STAGES)
7403 const std::string& compute_shader_source =
7404 this->prepare_compute_shader(tested_shader_type, uniform_definition, uniform_use);
7405 const std::string& fragment_shader_source =
7406 this->prepare_fragment_shader(tested_shader_type, uniform_definition, uniform_use);
7407 const std::string& geometry_shader_source =
7408 this->prepare_geometry_shader(tested_shader_type, uniform_definition, uniform_use);
7409 const std::string& tess_ctrl_shader_source =
7410 this->prepare_tess_ctrl_shader(tested_shader_type, uniform_definition, uniform_use);
7411 const std::string& tess_eval_shader_source =
7412 this->prepare_tess_eval_shader(tested_shader_type, uniform_definition, uniform_use);
7413 const std::string& vertex_shader_source =
7414 this->prepare_vertex_shader(tested_shader_type, uniform_definition, uniform_use);
7416 switch (tested_shader_type)
7418 case TestCaseBase<API>::VERTEX_SHADER_TYPE: /* Fall through */
7419 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
7420 this->execute_positive_test(vertex_shader_source, fragment_shader_source, false, false);
7423 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
7424 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
7425 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE: /* Fall through */
7426 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
7427 this->execute_positive_test(vertex_shader_source, tess_ctrl_shader_source, tess_eval_shader_source,
7428 geometry_shader_source, fragment_shader_source, compute_shader_source,
7433 TCU_FAIL("Invalid enum");
7439 const std::string& fragment_shader_source =
7440 this->prepare_fragment_shader(tested_shader_type, uniform_definition, uniform_use);
7441 const std::string& vertex_shader_source =
7442 this->prepare_vertex_shader(tested_shader_type, uniform_definition, uniform_use);
7444 this->execute_positive_test(vertex_shader_source, fragment_shader_source, false, false);
7447 glw::GLuint buffer_object_id = 0;
7448 glw::GLint my_storage_block_index = GL_INVALID_INDEX;
7450 gl.useProgram(this->program_object_id);
7451 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram() failed.");
7453 my_storage_block_index =
7454 gl.getProgramResourceIndex(this->program_object_id, GL_SHADER_STORAGE_BLOCK, "storage_block_name");
7455 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramResourceIndex() failed.");
7457 if ((unsigned)my_storage_block_index == GL_INVALID_INDEX)
7459 TCU_FAIL("Uniform block not found or is considered as not active.");
7462 gl.genBuffers(1, &buffer_object_id);
7463 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenBuffers() failed.");
7465 gl.bindBuffer(GL_SHADER_STORAGE_BUFFER, buffer_object_id);
7466 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer() failed.");
7468 switch (var_type_index)
7470 case 0: //float type of uniform is considered
7472 glw::GLfloat buffer_data[] = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f,
7473 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f };
7475 gl.bufferData(GL_SHADER_STORAGE_BUFFER, sizeof(buffer_data), buffer_data, GL_STATIC_DRAW);
7476 GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferData() failed.");
7480 case 1: //int type of uniform is considered
7483 glw::GLint buffer_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
7485 gl.bufferData(GL_SHADER_STORAGE_BUFFER, sizeof(buffer_data), buffer_data, GL_STATIC_DRAW);
7486 GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferData() failed.");
7490 case 2: //uint type of uniform is considered
7492 glw::GLuint buffer_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
7494 gl.bufferData(GL_SHADER_STORAGE_BUFFER, sizeof(buffer_data), buffer_data, GL_STATIC_DRAW);
7495 GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferData() failed.");
7499 case 3: //double type of uniform is considered
7501 glw::GLdouble buffer_data[] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0,
7502 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0 };
7504 gl.bufferData(GL_SHADER_STORAGE_BUFFER, sizeof(buffer_data), buffer_data, GL_STATIC_DRAW);
7505 GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferData() failed.");
7511 TCU_FAIL("Invalid variable-type index.");
7515 } /* switch (var_type_index) */
7517 gl.shaderStorageBlockBinding(this->program_object_id, my_storage_block_index, 0);
7518 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniformBlockBinding() failed.");
7520 gl.bindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, buffer_object_id);
7521 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBufferBase() failed.");
7523 if (TestCaseBase<API>::COMPUTE_SHADER_TYPE != tested_shader_type)
7525 execute_draw_test(tested_shader_type);
7529 execute_dispatch_test();
7532 /* Deallocate any resources used. */
7533 gl.deleteBuffers(1, &buffer_object_id);
7534 this->delete_objects();
7535 } /* if var_type iterator found */
7538 TCU_FAIL("Type not found.");
7540 } /* for (int var_type_index = 0; ...) */
7543 /** Executes test for compute program
7545 * @tparam API Tested API descriptor
7547 template <class API>
7548 void InteractionStorageBuffers2<API>::execute_dispatch_test()
7550 const glw::Functions& gl = this->context_id.getRenderContext().getFunctions();
7552 gl.dispatchCompute(1, 1, 1);
7553 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
7556 /** Executes test for draw program
7558 * @tparam API Tested API descriptor
7560 * @param tested_shader_type The type of shader that is being tested
7562 template <class API>
7563 void InteractionStorageBuffers2<API>::execute_draw_test(typename TestCaseBase<API>::TestShaderType tested_shader_type)
7565 const glw::Functions& gl = this->context_id.getRenderContext().getFunctions();
7567 glw::GLuint vao_id = 0;
7569 gl.genVertexArrays(1, &vao_id);
7570 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenVertexArrays() failed.");
7572 gl.bindVertexArray(vao_id);
7573 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray() failed.");
7575 switch (tested_shader_type)
7577 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
7578 case TestCaseBase<API>::VERTEX_SHADER_TYPE: /* Fall through */
7579 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
7580 gl.drawArrays(GL_POINTS, 0, 1);
7581 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
7584 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE: /* Fall through */
7585 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
7586 /* Tesselation patch set up */
7587 gl.patchParameteri(GL_PATCH_VERTICES, 1);
7588 GLU_EXPECT_NO_ERROR(gl.getError(), "PatchParameteri");
7590 gl.drawArrays(GL_PATCHES, 0, 1);
7591 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
7595 TCU_FAIL("Invalid enum");
7599 gl.deleteVertexArrays(1, &vao_id);
7600 GLU_EXPECT_NO_ERROR(gl.getError(), "glDeleteVertexArrays() failed.");
7603 /* Generates the shader source code for the InteractionUniformBuffers3
7604 * array tests, and attempts to compile each test shader, for both
7605 * vertex and fragment shaders.
7607 * @tparam API Tested API descriptor
7609 * @param tested_shader_type The type of shader that is being tested
7610 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
7612 template <class API>
7613 void InteractionStorageBuffers3<API>::test_shader_compilation(
7614 typename TestCaseBase<API>::TestShaderType tested_shader_type)
7616 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_FLOAT, VAR_TYPE_INT, VAR_TYPE_UINT };
7617 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
7619 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_FLOAT, VAR_TYPE_INT, VAR_TYPE_UINT,
7621 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
7623 const std::string invalid_size_declarations[] = { "[2][2][2][]", "[2][2][][2]", "[2][][2][2]", "[][2][2][2]",
7624 "[2][2][][]", "[2][][2][]", "[][2][2][]", "[2][][][2]",
7625 "[][2][][2]", "[][][2][2]", "[2][][][]", "[][2][][]",
7626 "[][][2][]", "[][][][2]", "[][][][]" };
7627 const std::string array_initializers[] = { "float[2][2][2][2](float[2][2][2](float[2][2](float[2](1.0, 2.0),"
7628 "float[2](3.0, 4.0)),"
7629 "float[2][2](float[2](5.0, 6.0),"
7630 "float[2](7.0, 8.0))),"
7631 "float[2][2][2](float[2][2](float[2](1.1, 2.1),"
7632 "float[2](3.1, 4.1)),"
7633 "float[2][2](float[2](5.1, 6.1),"
7634 "float[2](7.1, 8.1))));\n",
7636 "int[2][2][2][2](int[2][2][2](int[2][2](int[2]( 1, 2),"
7638 "int[2][2](int[2]( 5, 6),"
7640 "int[2][2][2](int[2][2](int[2](11, 12),"
7642 "int[2][2](int[2](15, 16),"
7643 "int[2](17, 18))));\n",
7645 "uint[2][2][2][2](uint[2][2][2](uint[2][2](uint[2]( 1u, 2u),"
7646 "uint[2]( 3u, 4u)),"
7647 "uint[2][2](uint[2]( 5u, 6u),"
7648 "uint[2]( 7u, 8u))),"
7649 "uint[2][2][2](uint[2][2](uint[2](11u, 12u),"
7650 "uint[2](13u, 14u)),"
7651 "uint[2][2](uint[2](15u, 16u),"
7652 "uint[2](17u, 18u))));\n",
7654 "double[2][2][2][2](double[2][2][2](double[2][2](double[2](1.0, 2.0),"
7655 "double[2](3.0, 4.0)),"
7656 "double[2][2](double[2](5.0, 6.0),"
7657 "double[2](7.0, 8.0))),"
7658 "double[2][2][2](double[2][2](double[2](1.1, 2.1),"
7659 "double[2](3.1, 4.1)),"
7660 "double[2][2](double[2](5.1, 6.1),"
7661 "double[2](7.1, 8.1))));\n" };
7662 const glcts::test_var_type* var_types_set = var_types_set_es;
7663 size_t num_var_types = num_var_types_es;
7665 if (API::USE_DOUBLE)
7667 var_types_set = var_types_set_gl;
7668 num_var_types = num_var_types_gl;
7671 /* Iterate through float/ int/ uint types.
7672 * Case: without initializer.
7674 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
7676 _supported_variable_types_map_const_iterator var_iterator =
7677 supported_variable_types_map.find(var_types_set[var_type_index]);
7679 if (var_iterator != supported_variable_types_map.end())
7681 for (size_t invalid_size_declarations_index = 0;
7682 invalid_size_declarations_index <
7683 sizeof(invalid_size_declarations) / sizeof(invalid_size_declarations[0]);
7684 invalid_size_declarations_index++)
7686 std::string shader_source;
7688 shader_source = "layout (std140) buffer MyStorage {\n";
7689 shader_source += " " + var_iterator->second.type +
7690 invalid_size_declarations[invalid_size_declarations_index] + " my_variable;\n";
7691 shader_source += "};\n\n";
7692 shader_source += shader_start;
7695 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
7698 EXECUTE_SHADER_TEST(API::ALLOW_UNSIZED_DECLARATION && invalid_size_declarations_index == 3,
7699 tested_shader_type, shader_source);
7700 } /* for (int invalid_size_declarations_index = 0; ...) */
7704 TCU_FAIL("Type not found.");
7706 } /* for (int var_type_index = 0; ...) */
7708 /* Iterate through float/ int/ uint types.
7709 * Case: with initializer.
7711 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
7713 _supported_variable_types_map_const_iterator var_iterator =
7714 supported_variable_types_map.find(var_types_set[var_type_index]);
7716 if (var_iterator != supported_variable_types_map.end())
7718 for (size_t invalid_size_declarations_index = 0;
7719 invalid_size_declarations_index <
7720 sizeof(invalid_size_declarations) / sizeof(invalid_size_declarations[0]);
7721 invalid_size_declarations_index++)
7723 std::string shader_source;
7725 shader_source = "layout (std140) buffer MyStorage {\n";
7726 shader_source += " " + var_iterator->second.type +
7727 invalid_size_declarations[invalid_size_declarations_index] +
7728 " my_variable = " + array_initializers[var_type_index];
7730 var_iterator->second.type + invalid_size_declarations[invalid_size_declarations_index] +
7731 " my_variable = " + array_initializers[var_type_index];
7732 shader_source += "};\n\n";
7733 shader_source += shader_start;
7736 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
7739 this->execute_negative_test(tested_shader_type, shader_source);
7740 } /* for (int invalid_size_declarations_index = 0; ...) */
7741 } /* if var_type iterator found */
7744 TCU_FAIL("Type not found.");
7746 } /* for (int var_type_index = 0; ...) */
7749 /* Generates the shader source code for the InteractionInterfaceArrays1
7750 * array test, and attempts to compile the test shader.
7752 * @tparam API Tested API descriptor
7754 * @param tested_shader_type The type of shader that is being tested.
7756 template <class API>
7757 void InteractionInterfaceArrays1<API>::test_shader_compilation(
7758 typename TestCaseBase<API>::TestShaderType tested_shader_type)
7760 /* Shader source with invalid buffer (buffer cannot be of arrays of arrays type). */
7761 const std::string invalid_buffer_shader_source = "layout(std140) buffer MyBuffer\n"
7766 "} myBuffers[2][2];\n\n"
7770 /* Verify that buffer arrays of arrays type is rejected. */
7772 std::string source = invalid_buffer_shader_source;
7774 DEFAULT_MAIN_ENDING(tested_shader_type, source);
7776 EXECUTE_SHADER_TEST(API::ALLOW_A_OF_A_ON_INTERFACE_BLOCKS, tested_shader_type, source);
7780 /* Generates the shader source code for the InteractionInterfaceArrays2
7781 * array test, and attempts to compile the test shader.
7783 * @tparam API Tested API descriptor
7785 * @param input_shader_type The type of shader that is being tested.
7787 template <class API>
7788 void InteractionInterfaceArrays2<API>::test_shader_compilation(
7789 typename TestCaseBase<API>::TestShaderType input_shader_type)
7791 /* Shader source with invalid input (input cannot be of arrays of arrays type). */
7792 const std::string input_variable_shader_source[] = { "in float inout_variable", "[2][2];\n"
7798 " = inout_variable", "[0][0];\n" };
7799 /* Shader source with invalid output (output cannot be of arrays of arrays type). */
7800 const std::string output_variable_shader_source[] = { "out float inout_variable",
7811 "[1][1] = 3.0;\n" };
7813 const typename TestCaseBase<API>::TestShaderType& output_shader_type =
7814 this->get_output_shader_type(input_shader_type);
7815 std::string input_source;
7816 std::string output_source;
7818 this->prepare_sources(input_shader_type, output_shader_type, input_variable_shader_source,
7819 output_variable_shader_source, input_source, output_source);
7821 /* Verify that INPUTs and OUTPUTs arrays of arrays type is rejected. */
7822 if (TestCaseBase<API>::COMPUTE_SHADER_TYPE != input_shader_type)
7824 if (API::ALLOW_A_OF_A_ON_INTERFACE_BLOCKS)
7827 if (API::USE_ALL_SHADER_STAGES)
7829 const std::string& compute_shader_source = empty_string;
7830 const std::string& fragment_shader_source =
7831 this->prepare_fragment_shader(input_shader_type, input_source, output_source);
7832 const std::string& geometry_shader_source =
7833 this->prepare_geometry_shader(input_shader_type, input_source, output_source);
7834 const std::string& tess_ctrl_shader_source =
7835 this->prepare_tess_ctrl_shader_source(input_shader_type, input_source, output_source);
7836 const std::string& tess_eval_shader_source =
7837 this->prepare_tess_eval_shader_source(input_shader_type, input_source, output_source);
7838 const std::string& vertex_shader_source =
7839 this->prepare_vertex_shader(input_shader_type, input_source, output_source);
7841 this->execute_positive_test(vertex_shader_source, tess_ctrl_shader_source, tess_eval_shader_source,
7842 geometry_shader_source, fragment_shader_source, compute_shader_source, true,
7847 const std::string& fragment_shader_source =
7848 this->prepare_fragment_shader(input_shader_type, input_source, output_source);
7849 const std::string& vertex_shader_source =
7850 this->prepare_vertex_shader(input_shader_type, input_source, output_source);
7852 this->execute_positive_test(vertex_shader_source, fragment_shader_source, true, false);
7857 this->execute_negative_test(input_shader_type, input_source);
7858 this->execute_negative_test(output_shader_type, output_source);
7863 /** Gets the shader type to test for the outputs
7865 * @tparam API Tested API descriptor
7867 * @param input_shader_type The type of input shader that is being tested
7869 template <class API>
7870 const typename TestCaseBase<API>::TestShaderType InteractionInterfaceArrays2<API>::get_output_shader_type(
7871 const typename TestCaseBase<API>::TestShaderType& input_shader_type)
7873 switch (input_shader_type)
7875 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
7876 return TestCaseBase<API>::FRAGMENT_SHADER_TYPE;
7878 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
7879 if (API::USE_ALL_SHADER_STAGES)
7881 return TestCaseBase<API>::GEOMETRY_SHADER_TYPE;
7885 return TestCaseBase<API>::VERTEX_SHADER_TYPE;
7888 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
7891 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
7892 return TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE;
7894 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
7895 return TestCaseBase<API>::VERTEX_SHADER_TYPE;
7897 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
7898 return TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE;
7901 TCU_FAIL("Unrecognized shader type.");
7905 return input_shader_type;
7908 /** Prepare fragment shader
7910 * @tparam API Tested API descriptor
7912 * @param input_shader_type The type of input shader that is being tested
7913 * @param input_source Shader in case we want to test inputs for this shader
7914 * @param output_source Shader in case we want to test outputs for this shader
7916 template <class API>
7917 const std::string InteractionInterfaceArrays2<API>::prepare_fragment_shader(
7918 const typename TestCaseBase<API>::TestShaderType& input_shader_type, const std::string& input_source,
7919 const std::string& output_source)
7921 switch (input_shader_type)
7923 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
7924 return output_source;
7926 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
7927 return input_source;
7929 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
7930 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
7931 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
7932 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
7936 TCU_FAIL("Unrecognized shader type.");
7940 return default_fragment_shader_source;
7943 /** Prepare geometry shader
7945 * @tparam API Tested API descriptor
7947 * @param input_shader_type The type of input shader that is being tested
7948 * @param input_source Shader in case we want to test inputs for this shader
7949 * @param output_source Shader in case we want to test outputs for this shader
7951 template <class API>
7952 const std::string InteractionInterfaceArrays2<API>::prepare_geometry_shader(
7953 const typename TestCaseBase<API>::TestShaderType& input_shader_type, const std::string& input_source,
7954 const std::string& output_source)
7956 switch (input_shader_type)
7958 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
7959 if (API::USE_ALL_SHADER_STAGES)
7961 return output_source;
7965 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
7966 return input_source;
7968 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
7969 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
7970 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
7971 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
7975 TCU_FAIL("Unrecognized shader type.");
7979 return default_geometry_shader_source;
7982 /** Prepare tessellation control shader
7984 * @tparam API Tested API descriptor
7986 * @param input_shader_type The type of input shader that is being tested
7987 * @param input_source Shader in case we want to test inputs for this shader
7988 * @param output_source Shader in case we want to test outputs for this shader
7990 template <class API>
7991 const std::string InteractionInterfaceArrays2<API>::prepare_tess_ctrl_shader_source(
7992 const typename TestCaseBase<API>::TestShaderType& input_shader_type, const std::string& input_source,
7993 const std::string& output_source)
7995 switch (input_shader_type)
7997 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
7998 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
7999 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
8000 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
8003 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
8004 return input_source;
8006 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
8007 return output_source;
8010 TCU_FAIL("Unrecognized shader type.");
8014 return default_tc_shader_source;
8017 /** Prepare tessellation evaluation shader
8019 * @tparam API Tested API descriptor
8021 * @param input_shader_type The type of input shader that is being tested
8022 * @param input_source Shader in case we want to test inputs for this shader
8023 * @param output_source Shader in case we want to test outputs for this shader
8025 template <class API>
8026 const std::string InteractionInterfaceArrays2<API>::prepare_tess_eval_shader_source(
8027 const typename TestCaseBase<API>::TestShaderType& input_shader_type, const std::string& input_source,
8028 const std::string& output_source)
8030 switch (input_shader_type)
8032 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
8033 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
8034 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
8035 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
8038 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
8039 return output_source;
8041 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
8042 return input_source;
8045 TCU_FAIL("Unrecognized shader type.");
8049 return default_te_shader_source;
8052 /** Prepare vertex shader
8054 * @tparam API Tested API descriptor
8056 * @param input_shader_type The type of input shader that is being tested
8057 * @param input_source Shader in case we want to test inputs for this shader
8058 * @param output_source Shader in case we want to test outputs for this shader
8060 template <class API>
8061 const std::string InteractionInterfaceArrays2<API>::prepare_vertex_shader(
8062 const typename TestCaseBase<API>::TestShaderType& input_shader_type, const std::string& input_source,
8063 const std::string& output_source)
8065 switch (input_shader_type)
8067 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
8068 return input_source;
8070 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
8071 if (!API::USE_ALL_SHADER_STAGES)
8073 return output_source;
8077 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
8078 return output_source;
8080 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
8081 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
8082 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
8086 TCU_FAIL("Unrecognized shader type.");
8090 return default_vertex_shader_source;
8093 /** Prepare the inputs and outputs shaders
8095 * @tparam API Tested API descriptor
8097 * @param input_shader_type The type of input shader that is being tested
8098 * @param output_shader_type The type of output shader that is being tested
8099 * @param input_shader_source Snippet used to prepare the input shader
8100 * @param output_shader_source Snippet used to prepare the output shader
8101 * @param input_source Resulting input shader
8102 * @param output_source Resulting output shader
8104 template <class API>
8105 void InteractionInterfaceArrays2<API>::prepare_sources(
8106 const typename TestCaseBase<API>::TestShaderType& input_shader_type,
8107 const typename TestCaseBase<API>::TestShaderType& output_shader_type, const std::string* input_shader_source,
8108 const std::string* output_shader_source, std::string& input_source, std::string& output_source)
8110 if (TestCaseBase<API>::COMPUTE_SHADER_TYPE != input_shader_type)
8112 input_source += input_shader_source[0];
8113 output_source += output_shader_source[0];
8115 if ((TestCaseBase<API>::GEOMETRY_SHADER_TYPE == input_shader_type) ||
8116 (TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE == input_shader_type) ||
8117 (TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE == input_shader_type))
8119 input_source += "[]";
8122 if (TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE == output_shader_type)
8124 output_source += "[]";
8127 input_source += input_shader_source[1];
8128 output_source += output_shader_source[1];
8130 if (TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE == input_shader_type)
8132 input_source += "[]";
8135 if (TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE == output_shader_type)
8137 output_source += "[gl_InvocationID]";
8140 input_source += input_shader_source[2];
8141 output_source += output_shader_source[2];
8143 if (TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE == input_shader_type)
8145 input_source += "[gl_InvocationID]";
8148 if (TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE == output_shader_type)
8150 output_source += "[gl_InvocationID]";
8153 input_source += input_shader_source[3];
8154 output_source += output_shader_source[3];
8156 if ((TestCaseBase<API>::GEOMETRY_SHADER_TYPE == input_shader_type) ||
8157 (TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE == input_shader_type))
8159 input_source += "[0]";
8162 if (TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE == input_shader_type)
8164 input_source += "[gl_InvocationID]";
8167 if (TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE == output_shader_type)
8169 output_source += "[gl_InvocationID]";
8172 input_source += input_shader_source[4];
8173 output_source += output_shader_source[4];
8175 if (TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE == output_shader_type)
8177 output_source += "[gl_InvocationID]";
8180 output_source += output_shader_source[5];
8182 DEFAULT_MAIN_ENDING(input_shader_type, input_source);
8183 DEFAULT_MAIN_ENDING(output_shader_type, output_source);
8187 /* Generates the shader source code for the InteractionInterfaceArrays3
8188 * array test, and attempts to compile the test shader.
8190 * @tparam API Tested API descriptor
8192 * @param tested_shader_type The type of shader that is being tested.
8194 template <class API>
8195 void InteractionInterfaceArrays3<API>::test_shader_compilation(
8196 typename TestCaseBase<API>::TestShaderType tested_shader_type)
8198 /* Shader source with invalid uniform block (uniform block cannot be of arrays of arrays type). */
8199 const std::string invalid_uniform_block_shader_source = "layout(std140) uniform MyUniformBlock\n"
8204 "} myUniformBlocks[2][2];\n\n"
8208 /* Verify that uniform block arrays of arrays type is rejected. */
8210 std::string source = invalid_uniform_block_shader_source;
8212 DEFAULT_MAIN_ENDING(tested_shader_type, source);
8214 EXECUTE_SHADER_TEST(API::ALLOW_A_OF_A_ON_INTERFACE_BLOCKS, tested_shader_type, source);
8218 /* Generates the shader source code for the InteractionInterfaceArrays4
8219 * array test, and attempts to compile the test shader.
8221 * @tparam API Tested API descriptor
8223 * @param input_shader_type The type of shader that is being tested.
8225 template <class API>
8226 void InteractionInterfaceArrays4<API>::test_shader_compilation(
8227 typename TestCaseBase<API>::TestShaderType input_shader_type)
8229 /* Shader source with invalid input (input cannot be of arrays of arrays type). */
8230 const std::string input_block_shader_source[] = { "in InOutBlock {\n"
8231 " float inout_variable;\n"
8239 " = inout_block", "[0][0].inout_variable;\n" };
8240 /* Shader source with invalid output (output cannot be of arrays of arrays type). */
8241 const std::string output_block_shader_source[] = { "out InOutBlock {\n"
8242 " float inout_variable;\n"
8249 "[0][0].inout_variable = 0.0;\n"
8251 "[0][1].inout_variable = 1.0;\n"
8253 "[1][0].inout_variable = 2.0;\n"
8255 "[1][1].inout_variable = 3.0;\n" };
8257 const typename TestCaseBase<API>::TestShaderType& output_shader_type =
8258 this->get_output_shader_type(input_shader_type);
8259 std::string input_source;
8260 std::string output_source;
8262 this->prepare_sources(input_shader_type, output_shader_type, input_block_shader_source, output_block_shader_source,
8263 input_source, output_source);
8265 /* Verify that INPUTs and OUTPUTs arrays of arrays type is rejected. */
8266 if ((TestCaseBase<API>::VERTEX_SHADER_TYPE != input_shader_type) &&
8267 (TestCaseBase<API>::COMPUTE_SHADER_TYPE != input_shader_type))
8269 if (API::ALLOW_A_OF_A_ON_INTERFACE_BLOCKS && API::ALLOW_IN_OUT_INTERFACE_BLOCKS)
8272 if (API::USE_ALL_SHADER_STAGES)
8274 const std::string& compute_shader_source = empty_string;
8275 const std::string& fragment_shader_source =
8276 this->prepare_fragment_shader(input_shader_type, input_source, output_source);
8277 const std::string& geometry_shader_source =
8278 this->prepare_geometry_shader(input_shader_type, input_source, output_source);
8279 const std::string& tess_ctrl_shader_source =
8280 this->prepare_tess_ctrl_shader_source(input_shader_type, input_source, output_source);
8281 const std::string& tess_eval_shader_source =
8282 this->prepare_tess_eval_shader_source(input_shader_type, input_source, output_source);
8283 const std::string& vertex_shader_source =
8284 this->prepare_vertex_shader(input_shader_type, input_source, output_source);
8286 this->execute_positive_test(vertex_shader_source, tess_ctrl_shader_source, tess_eval_shader_source,
8287 geometry_shader_source, fragment_shader_source, compute_shader_source, true,
8292 const std::string& fragment_shader_source =
8293 this->prepare_fragment_shader(input_shader_type, input_source, output_source);
8294 const std::string& vertex_shader_source =
8295 this->prepare_vertex_shader(input_shader_type, input_source, output_source);
8297 this->execute_positive_test(vertex_shader_source, fragment_shader_source, true, false);
8302 this->execute_negative_test(input_shader_type, input_source);
8303 this->execute_negative_test(output_shader_type, output_source);
8308 /** Calulate smallest denominator for values over 1
8310 * @param value Value in question
8312 * @return Smallest denominator
8314 size_t findSmallestDenominator(const size_t value)
8317 for (size_t i = 2; i < value; ++i)
8328 /** Check if left is bigger than right
8330 * @tparam T Type of values
8332 * @param l Left value
8333 * @param r Right value
8335 * @return true if l > r, false otherwise
8338 bool more(const T& l, const T& r)
8343 /** Prepare dimensions of array with given number of entries
8345 * @tparam API Tested API descriptor
8347 * @param n_entries Number of entries
8348 * @param dimensions Storage for dimesnions
8350 template <class API>
8351 void prepareDimensions(size_t n_entries, std::vector<size_t>& dimensions)
8353 if (dimensions.empty())
8356 const size_t last = dimensions.size() - 1;
8359 for (size_t i = 0; i < last; ++i)
8361 const size_t denom = findSmallestDenominator(n_entries);
8365 dimensions[i] = denom;
8368 dimensions[last] = n_entries;
8371 std::sort(dimensions.begin(), dimensions.end(), more<size_t>);
8374 /* Generates the shader source code for the AtomicDeclarationTest
8375 * and attempts to compile each shader
8377 * @tparam API Tested API descriptor
8379 * @param tested_shader_type The type of shader that is being tested
8381 template <class API>
8382 void AtomicDeclarationTest<API>::test_shader_compilation(typename TestCaseBase<API>::TestShaderType tested_shader_type)
8384 static const char* indent_step = " ";
8385 static const char* uniform_atomic_uint = "layout(binding = 0) uniform atomic_uint";
8387 const glw::Functions& gl = this->context_id.getRenderContext().getFunctions();
8389 std::string comment;
8390 std::vector<size_t> dimensions;
8392 std::string indexing;
8393 std::string invalid_definition = uniform_atomic_uint;
8394 std::string invalid_iteration;
8395 std::string invalid_shader_source;
8396 std::string loop_end;
8397 glw::GLint max_atomics = 0;
8398 glw::GLenum pname = 0;
8399 std::string valid_shader_source;
8400 std::string valid_definition = uniform_atomic_uint;
8401 std::string valid_iteration;
8403 /* Select pname of max for stage */
8404 switch (tested_shader_type)
8406 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
8407 pname = GL_MAX_COMPUTE_ATOMIC_COUNTERS;
8409 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
8410 pname = GL_MAX_FRAGMENT_ATOMIC_COUNTERS;
8412 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
8413 pname = GL_MAX_GEOMETRY_ATOMIC_COUNTERS;
8415 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
8416 pname = GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS;
8418 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
8419 pname = GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS;
8421 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
8422 pname = GL_MAX_VERTEX_ATOMIC_COUNTERS;
8425 TCU_FAIL("Invalid enum");
8430 gl.getIntegerv(pname, &max_atomics);
8431 GLU_EXPECT_NO_ERROR(gl.getError(), "GetIntegerv");
8433 if (0 == max_atomics)
8435 /* Not supported - skip */
8440 dimensions.resize(API::MAX_ARRAY_DIMENSIONS);
8441 prepareDimensions<API>(max_atomics, dimensions);
8444 /* Prepare parts of shader */
8445 for (size_t i = API::MAX_ARRAY_DIMENSIONS; i != 0; --i)
8450 indent += indent_step;
8452 loop_end.insert(0, "}\n");
8453 loop_end.insert(0, indent);
8455 sprintf(it, "i%u", (unsigned int)(API::MAX_ARRAY_DIMENSIONS - i));
8461 sprintf(max, "%u", (unsigned int)(dimensions[i - 1]));
8463 valid_definition += "[";
8464 valid_definition += max;
8465 valid_definition += "]";
8467 valid_iteration += indent;
8468 valid_iteration += "for (uint ";
8469 valid_iteration += it;
8470 valid_iteration += " = 0; ";
8471 valid_iteration += it;
8472 valid_iteration += " < ";
8473 valid_iteration += max;
8474 valid_iteration += "; ++";
8475 valid_iteration += it;
8476 valid_iteration += ")\n";
8477 valid_iteration += indent;
8478 valid_iteration += "{\n";
8482 sprintf(max, "%u", (unsigned int)(dimensions[i - 1] + 1));
8484 invalid_definition += "[";
8485 invalid_definition += max;
8486 invalid_definition += "]";
8488 invalid_iteration += indent;
8489 invalid_iteration += "for (uint ";
8490 invalid_iteration += it;
8491 invalid_iteration += " = 0; ";
8492 invalid_iteration += it;
8493 invalid_iteration += " < ";
8494 invalid_iteration += max;
8495 invalid_iteration += "; ++";
8496 invalid_iteration += it;
8497 invalid_iteration += ")\n";
8498 invalid_iteration += indent;
8499 invalid_iteration += "{\n";
8505 sprintf(max, "%u", (unsigned int)(max_atomics));
8506 comment += "/* MAX_*_ATOMIC_COUNTERS = ";
8511 /* Prepare invalid source */
8512 invalid_shader_source += comment;
8513 invalid_shader_source += invalid_definition;
8514 invalid_shader_source += " a;\n\nvoid main()\n{\n";
8515 invalid_shader_source += invalid_iteration;
8516 invalid_shader_source += indent;
8517 invalid_shader_source += indent_step;
8518 invalid_shader_source += "atomicCounterIncrement( a";
8519 invalid_shader_source += indexing;
8520 invalid_shader_source += " );\n";
8521 invalid_shader_source += loop_end;
8523 /* Prepare valid source */
8524 valid_shader_source += comment;
8525 valid_shader_source += valid_definition;
8526 valid_shader_source += " a;\n\nvoid main()\n{\n";
8527 valid_shader_source += valid_iteration;
8528 valid_shader_source += indent;
8529 valid_shader_source += indent_step;
8530 valid_shader_source += "atomicCounterIncrement( a";
8531 valid_shader_source += indexing;
8532 valid_shader_source += " );\n";
8533 valid_shader_source += loop_end;
8536 DEFAULT_MAIN_ENDING(tested_shader_type, invalid_shader_source);
8537 DEFAULT_MAIN_ENDING(tested_shader_type, valid_shader_source);
8540 EXECUTE_POSITIVE_TEST(tested_shader_type, valid_shader_source, true, false);
8542 /* Expect build failure for invalid shader source */
8544 bool negative_build_test_result = false;
8548 EXECUTE_POSITIVE_TEST(tested_shader_type, invalid_shader_source, true, false);
8552 negative_build_test_result = true;
8555 if (false == negative_build_test_result)
8557 TCU_FAIL("It was expected that build process will fail");
8562 /* Generates the shader source code for the AtomicUsageTest
8563 * and attempts to compile each shader
8565 * @tparam API Tested API descriptor
8567 * @param tested_shader_type The type of shader that is being tested
8569 template <class API>
8570 void AtomicUsageTest<API>::test_shader_compilation(typename TestCaseBase<API>::TestShaderType tested_shader_type)
8572 const glw::Functions& gl = this->context_id.getRenderContext().getFunctions();
8574 glw::GLint max_atomics = 0;
8575 glw::GLint max_bindings = 0;
8576 glw::GLint max_size = 0;
8577 glw::GLenum pname = 0;
8579 /* Select pname of max for stage */
8580 switch (tested_shader_type)
8582 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
8583 pname = GL_MAX_COMPUTE_ATOMIC_COUNTERS;
8585 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
8586 pname = GL_MAX_FRAGMENT_ATOMIC_COUNTERS;
8588 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
8589 pname = GL_MAX_GEOMETRY_ATOMIC_COUNTERS;
8591 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
8592 pname = GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS;
8594 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
8595 pname = GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS;
8597 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
8598 pname = GL_MAX_VERTEX_ATOMIC_COUNTERS;
8601 TCU_FAIL("Invalid enum");
8606 gl.getIntegerv(pname, &max_atomics);
8607 GLU_EXPECT_NO_ERROR(gl.getError(), "GetIntegerv");
8609 gl.getIntegerv(GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS, &max_bindings);
8610 GLU_EXPECT_NO_ERROR(gl.getError(), "GetIntegerv");
8612 gl.getIntegerv(GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE, &max_size);
8613 GLU_EXPECT_NO_ERROR(gl.getError(), "GetIntegerv");
8615 if (0 == max_atomics)
8617 /* Not supported - skip */
8621 const glw::GLuint last_binding = (glw::GLuint)max_bindings - 1;
8622 const glw::GLuint offset = (glw::GLuint)max_size / 2;
8623 glw::GLuint n_entries =
8624 std::min((glw::GLuint)(max_size - offset) / (glw::GLuint)sizeof(glw::GLuint), (glw::GLuint)max_atomics);
8626 if (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type)
8628 glw::GLint max_uniform_locations = 0;
8630 gl.getIntegerv(GL_MAX_UNIFORM_LOCATIONS, &max_uniform_locations);
8631 GLU_EXPECT_NO_ERROR(gl.getError(), "GetIntegerv");
8633 max_atomics = std::min(max_atomics, (max_uniform_locations - 1));
8634 n_entries = (glw::GLuint)std::min((glw::GLint)n_entries, (max_uniform_locations - 1));
8637 execute(tested_shader_type, last_binding, 0 /* offset */, max_atomics);
8638 execute(tested_shader_type, last_binding, offset, n_entries);
8641 /* Generates the shader source code for the AtomicUsageTest
8642 * and attempts to compile each shader
8644 * @tparam API Tested API descriptor
8646 * @param tested_shader_type The type of shader that is being tested
8647 * @param binding Binding index
8648 * @param offset Offset of data
8649 * @param n_entries Number of entries in array
8651 template <class API>
8652 void AtomicUsageTest<API>::execute(typename TestCaseBase<API>::TestShaderType tested_shader_type, glw::GLuint binding,
8653 glw::GLuint offset, glw::GLuint n_entries)
8655 static const char* indent_step = " ";
8656 static const char* layout_binding = "layout(binding = ";
8657 static const char* layout_offset = ", offset = ";
8658 static const char* uniform_atomic_uint = ") uniform atomic_uint";
8660 const glw::Functions& gl = this->context_id.getRenderContext().getFunctions();
8662 std::string comment;
8663 std::vector<size_t> dimensions;
8665 std::string indexing;
8666 std::string loop_end;
8668 std::string valid_shader_source;
8669 std::string valid_definition = layout_binding;
8670 std::string valid_iteration;
8671 std::string varying_definition;
8673 dimensions.resize(API::MAX_ARRAY_DIMENSIONS);
8674 prepareDimensions<API>(n_entries, dimensions);
8676 /* Prepare parts of shader */
8678 /* Append binding */
8681 sprintf(buffer, "%u", static_cast<unsigned int>(binding));
8682 valid_definition += buffer;
8683 valid_definition += layout_offset;
8684 sprintf(buffer, "%u", static_cast<unsigned int>(offset));
8685 valid_definition += buffer;
8686 valid_definition += uniform_atomic_uint;
8689 for (size_t i = API::MAX_ARRAY_DIMENSIONS; i != 0; --i)
8694 indent += indent_step;
8696 loop_end.insert(0, "}\n");
8697 loop_end.insert(0, indent);
8699 sprintf(it, "i%u", (unsigned int)(API::MAX_ARRAY_DIMENSIONS - i));
8705 sprintf(max, "%u", (unsigned int)(dimensions[i - 1]));
8706 valid_definition += "[";
8707 valid_definition += max;
8708 valid_definition += "]";
8710 valid_iteration += indent;
8711 valid_iteration += "for (uint ";
8712 valid_iteration += it;
8713 valid_iteration += " = 0; ";
8714 valid_iteration += it;
8715 valid_iteration += " < ";
8716 valid_iteration += max;
8717 valid_iteration += "; ++";
8718 valid_iteration += it;
8719 valid_iteration += ")\n";
8720 valid_iteration += indent;
8721 valid_iteration += "{\n";
8727 sprintf(max, "%u", (unsigned int)(n_entries));
8728 comment += "/* Number of atomic counters = ";
8733 /* Select varyings and result */
8734 switch (tested_shader_type)
8736 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
8737 result = " imageStore(uni_image, ivec2(gl_GlobalInvocationID.xy), vec4(result, 0, 0, 0));\n";
8738 varying_definition = "writeonly uniform image2D uni_image;\n"
8742 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
8743 result = " color = vec4(result);\n";
8744 varying_definition = "out vec4 color;\n"
8748 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
8749 result = " gl_Position = vec4(-1, -1, 0, 1);\n"
8750 " fs_result = result;\n"
8752 " gl_Position = vec4(-1, 1, 0, 1);\n"
8753 " fs_result = result;\n"
8755 " gl_Position = vec4(1, -1, 0, 1);\n"
8756 " fs_result = result;\n"
8758 " gl_Position = vec4(1, 1, 0, 1);\n"
8759 " fs_result = result;\n"
8761 varying_definition = "out float fs_result;\n"
8765 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
8766 result = " tcs_result[gl_InvocationID] = result;\n"
8768 " gl_TessLevelOuter[0] = 1.0;\n"
8769 " gl_TessLevelOuter[1] = 1.0;\n"
8770 " gl_TessLevelOuter[2] = 1.0;\n"
8771 " gl_TessLevelOuter[3] = 1.0;\n"
8772 " gl_TessLevelInner[0] = 1.0;\n"
8773 " gl_TessLevelInner[1] = 1.0;\n";
8774 varying_definition = "out float tcs_result[];\n"
8778 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
8779 result = " fs_result = result;\n";
8780 varying_definition = "out float fs_result;\n"
8784 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
8785 result = " fs_result = result;\n";
8786 varying_definition = "out float fs_result;\n"
8791 TCU_FAIL("Invalid enum");
8795 /* Prepare valid source */
8796 valid_shader_source += varying_definition;
8797 valid_shader_source += comment;
8798 valid_shader_source += valid_definition;
8799 valid_shader_source += " a;\n\nvoid main()\n{\n uint sum = 0u;\n";
8800 valid_shader_source += valid_iteration;
8801 valid_shader_source += indent;
8802 valid_shader_source += indent_step;
8803 valid_shader_source += "sum += atomicCounterIncrement( a";
8804 valid_shader_source += indexing;
8805 valid_shader_source += " );\n";
8806 valid_shader_source += loop_end;
8807 valid_shader_source += "\n"
8808 " float result = 0.0;\n"
8814 valid_shader_source += result;
8815 valid_shader_source += shader_end;
8819 const std::string* cs = &empty_string;
8820 const std::string* vs = &default_vertex_shader_source;
8821 const std::string* tcs = &empty_string;
8822 const std::string* tes = &empty_string;
8823 const std::string* gs = &empty_string;
8824 const std::string* fs = &pass_fragment_shader_source;
8826 switch (tested_shader_type)
8828 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
8829 cs = &valid_shader_source;
8834 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
8835 fs = &valid_shader_source;
8838 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
8839 gs = &valid_shader_source;
8842 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
8843 tcs = &valid_shader_source;
8844 tes = &pass_te_shader_source;
8847 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
8848 tcs = &default_tc_shader_source;
8849 tes = &valid_shader_source;
8852 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
8853 vs = &valid_shader_source;
8857 TCU_FAIL("Invalid enum");
8861 if (API::USE_ALL_SHADER_STAGES)
8863 this->execute_positive_test(*vs, *tcs, *tes, *gs, *fs, *cs, false, false);
8867 this->execute_positive_test(*vs, *fs, false, false);
8871 gl.useProgram(this->program_object_id);
8872 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram() failed.");
8874 /* Prepare buffer */
8875 glw::GLuint buffer_object_id = 0;
8876 std::vector<glw::GLuint> buffer_data;
8877 const size_t start_pos = offset / 4;
8878 const size_t last_pos = start_pos + n_entries;
8879 const size_t buffer_data_size = last_pos * sizeof(glw::GLuint);
8881 gl.genBuffers(1, &buffer_object_id);
8882 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenBuffers() failed.");
8884 gl.bindBuffer(GL_ATOMIC_COUNTER_BUFFER, buffer_object_id);
8885 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer() failed.");
8887 buffer_data.resize(start_pos + n_entries);
8888 for (size_t i = 0; i < n_entries; ++i)
8890 buffer_data[start_pos + i] = (glw::GLuint)i;
8893 gl.bufferData(GL_ATOMIC_COUNTER_BUFFER, buffer_data_size, &buffer_data[0], GL_STATIC_DRAW);
8894 GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferData() failed.");
8896 gl.bindBufferBase(GL_ATOMIC_COUNTER_BUFFER, binding, buffer_object_id);
8897 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBufferBase() failed.");
8900 if (TestCaseBase<API>::COMPUTE_SHADER_TYPE != tested_shader_type)
8902 glw::GLuint framebuffer_object_id = 0;
8903 glw::GLuint texture_object_id = 0;
8904 glw::GLuint vao_id = 0;
8906 gl.genTextures(1, &texture_object_id);
8907 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures() failed.");
8909 gl.bindTexture(GL_TEXTURE_2D, texture_object_id);
8910 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture() failed.");
8912 gl.texStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 1, 1);
8913 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage2D() failed.");
8915 gl.genFramebuffers(1, &framebuffer_object_id);
8916 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers() failed.");
8918 gl.bindFramebuffer(GL_FRAMEBUFFER, framebuffer_object_id);
8919 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer() failed.");
8921 gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_object_id, 0);
8922 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferTexture2D() failed.");
8924 gl.viewport(0, 0, 1, 1);
8925 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport() failed.");
8927 gl.genVertexArrays(1, &vao_id);
8928 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenVertexArrays() failed.");
8930 gl.bindVertexArray(vao_id);
8931 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray() failed.");
8933 switch (tested_shader_type)
8935 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
8936 case TestCaseBase<API>::VERTEX_SHADER_TYPE: /* Fall through */
8937 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
8938 gl.drawArrays(GL_POINTS, 0, 1);
8939 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
8942 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE: /* Fall through */
8943 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
8944 /* Tesselation patch set up */
8945 gl.patchParameteri(GL_PATCH_VERTICES, 1);
8946 GLU_EXPECT_NO_ERROR(gl.getError(), "PatchParameteri");
8948 gl.drawArrays(GL_PATCHES, 0, 1);
8949 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
8953 TCU_FAIL("Invalid enum");
8957 gl.memoryBarrier(GL_ALL_BARRIER_BITS);
8958 GLU_EXPECT_NO_ERROR(gl.getError(), "MemoryBarrier.");
8960 gl.bindTexture(GL_TEXTURE_2D, 0);
8961 gl.bindFramebuffer(GL_FRAMEBUFFER, 0);
8962 gl.bindVertexArray(0);
8963 gl.deleteTextures(1, &texture_object_id);
8964 gl.deleteFramebuffers(1, &framebuffer_object_id);
8965 gl.deleteVertexArrays(1, &vao_id);
8966 GLU_EXPECT_NO_ERROR(gl.getError(), "An error ocurred while deleting generated objects.");
8970 gl.dispatchCompute(1, 1, 1);
8971 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
8973 gl.memoryBarrier(GL_ALL_BARRIER_BITS);
8974 GLU_EXPECT_NO_ERROR(gl.getError(), "MemoryBarrier.");
8977 /* Verify results */
8978 bool test_result = true;
8980 const glw::GLuint* results =
8981 (glw::GLuint*)gl.mapBufferRange(GL_ATOMIC_COUNTER_BUFFER, 0 /* offset */, buffer_data_size, GL_MAP_READ_BIT);
8982 GLU_EXPECT_NO_ERROR(gl.getError(), "MapBufferRange");
8984 /* Anything before start position should be 0 */
8985 for (size_t i = 0; i < start_pos; ++i)
8987 if (0 != results[i])
8989 test_result = false;
8994 /* Anything from start_pos should be incremented by 1 */
8996 for (size_t i = 0; i < n_entries; ++i)
8998 /* Tesselation evaluation can be called several times
8999 In here, check the increment is consistent over all results.
9001 if (tested_shader_type == TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE)
9005 diff = static_cast<int>(results[i + start_pos]) - static_cast<int>(i);
9008 test_result = false;
9012 else if ((static_cast<int>(results[i + start_pos]) - static_cast<int>(i)) != diff)
9014 test_result = false;
9020 if (i + 1 != results[i + start_pos])
9022 test_result = false;
9028 gl.unmapBuffer(GL_ATOMIC_COUNTER_BUFFER);
9029 GLU_EXPECT_NO_ERROR(gl.getError(), "UnmapBuffer");
9031 /* Deallocate any resources used. */
9032 gl.deleteBuffers(1, &buffer_object_id);
9033 this->delete_objects();
9035 if (false == test_result)
9037 TCU_FAIL("Invalid results.");
9041 /* Generates the shader source code for the SubroutineFunctionCalls1
9042 * array tests, attempts to build and execute test program
9044 * @tparam API Tested API descriptor
9046 * @param tested_shader_type The type of shader that is being tested
9048 template <class API>
9049 void SubroutineFunctionCalls1<API>::test_shader_compilation(
9050 typename TestCaseBase<API>::TestShaderType tested_shader_type)
9052 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_IVEC2,
9053 VAR_TYPE_IVEC3, VAR_TYPE_IVEC4, VAR_TYPE_VEC2,
9054 VAR_TYPE_VEC3, VAR_TYPE_VEC4, VAR_TYPE_MAT2,
9055 VAR_TYPE_MAT3, VAR_TYPE_MAT4 };
9056 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
9058 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_IVEC2,
9059 VAR_TYPE_IVEC3, VAR_TYPE_IVEC4, VAR_TYPE_VEC2,
9060 VAR_TYPE_VEC3, VAR_TYPE_VEC4, VAR_TYPE_MAT2,
9061 VAR_TYPE_MAT3, VAR_TYPE_MAT4, VAR_TYPE_DOUBLE,
9062 VAR_TYPE_DMAT2, VAR_TYPE_DMAT3, VAR_TYPE_DMAT4 };
9063 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
9065 const std::string iteration_loop_end = " }\n"
9073 const std::string iteration_loop_start = " for (uint a = 0u; a < 2u; a++)\n"
9075 " for (uint b = 0u; b < 2u; b++)\n"
9077 " for (uint c = 0u; c < 2u; c++)\n"
9079 " for (uint d = 0u; d < 2u; d++)\n"
9081 " for (uint e = 0u; e < 2u; e++)\n"
9083 " for (uint f = 0u; f < 2u; f++)\n"
9085 " for (uint g = 0u; g < 2u; g++)\n"
9087 " for (uint h = 0u; h < 2u; h++)\n"
9089 const glcts::test_var_type* var_types_set = var_types_set_es;
9090 size_t num_var_types = num_var_types_es;
9091 const bool test_compute = (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type);
9093 if (API::USE_DOUBLE)
9095 var_types_set = var_types_set_gl;
9096 num_var_types = num_var_types_gl;
9099 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
9101 _supported_variable_types_map_const_iterator var_iterator =
9102 supported_variable_types_map.find(var_types_set[var_type_index]);
9104 if (var_iterator != supported_variable_types_map.end())
9106 std::string iterator_declaration = " " + var_iterator->second.iterator_type +
9107 " iterator = " + var_iterator->second.iterator_initialization + ";\n";
9109 std::string function_definition;
9110 std::string function_use;
9111 std::string verification;
9113 function_definition += "// Subroutine types\n"
9114 "subroutine void out_routine_type(out ";
9115 function_definition += var_iterator->second.type;
9116 function_definition += " output_array[2][2][2][2][2][2][2][2]);\n\n"
9117 "// Subroutine definitions\n"
9118 "subroutine(out_routine_type) void original_routine(out ";
9119 function_definition += var_iterator->second.type;
9120 function_definition += " output_array[2][2][2][2][2][2][2][2]) {\n";
9121 function_definition += iterator_declaration;
9122 function_definition += iteration_loop_start;
9123 function_definition += " output_array[a][b][c][d][e][f][g][h] = " +
9124 var_iterator->second.variable_type_initializer1 + ";\n";
9125 function_definition +=
9126 " iterator += " + var_iterator->second.iterator_type + "(1);\n";
9127 function_definition += iteration_loop_end;
9128 function_definition += "}\n\n";
9129 function_definition += "subroutine(out_routine_type) void new_routine(out ";
9130 function_definition += var_iterator->second.type;
9131 function_definition += " output_array[2][2][2][2][2][2][2][2]) {\n";
9132 function_definition += iterator_declaration;
9133 function_definition += iteration_loop_start;
9134 function_definition += " output_array[a][b][c][d][e][f][g][h] = " +
9135 var_iterator->second.variable_type_initializer1 + ";\n";
9136 function_definition +=
9137 " iterator -= " + var_iterator->second.iterator_type + "(1);\n";
9138 function_definition += iteration_loop_end;
9139 function_definition += "}\n\n"
9140 "// Subroutine uniform\n"
9141 "subroutine uniform out_routine_type routine;\n";
9143 function_use = " " + var_iterator->second.type + " my_array[2][2][2][2][2][2][2][2];\n";
9144 function_use += " routine(my_array);";
9146 verification = iterator_declaration;
9147 verification += " float result = 1.0;\n";
9148 verification += iteration_loop_start;
9149 verification += " if (my_array[a][b][c][d][e][f][g][h] " +
9150 var_iterator->second.specific_element +
9156 var_iterator->second.iterator_type + "(1);\n";
9157 verification += iteration_loop_end;
9159 if (false == test_compute)
9161 execute_draw_test(tested_shader_type, function_definition, function_use, verification, false, true);
9162 execute_draw_test(tested_shader_type, function_definition, function_use, verification, true, false);
9166 execute_dispatch_test(tested_shader_type, function_definition, function_use, verification, false, true);
9167 execute_dispatch_test(tested_shader_type, function_definition, function_use, verification, true, false);
9170 /* Deallocate any resources used. */
9171 this->delete_objects();
9172 } /* if var_type iterator found */
9175 TCU_FAIL("Type not found.");
9177 } /* for (int var_type_index = 0; ...) */
9180 /** Executes test for compute program
9182 * @tparam API Tested API descriptor
9184 * @param tested_shader_type The type of shader that is being tested
9185 * @param function_definition Definition used to prepare shader
9186 * @param function_use Use of definition
9187 * @param verification Result verification
9188 * @param use_original Selects if "original_routine" - true or "new_routine" is choosen
9189 * @param expect_invalid_result Does test expects invalid results
9191 template <class API>
9192 void SubroutineFunctionCalls1<API>::execute_dispatch_test(typename TestCaseBase<API>::TestShaderType tested_shader_type,
9193 const std::string& function_definition,
9194 const std::string& function_use,
9195 const std::string& verification, bool use_original,
9196 bool expect_invalid_result)
9198 const std::string& compute_shader_source =
9199 prepare_compute_shader(tested_shader_type, function_definition, function_use, verification);
9200 const glw::Functions& gl = this->context_id.getRenderContext().getFunctions();
9202 this->execute_positive_test(empty_string, empty_string, empty_string, empty_string, empty_string,
9203 compute_shader_source, false, false);
9205 /* We are now ready to verify whether the returned size is correct. */
9206 unsigned char buffer[4] = { 0 };
9207 glw::GLuint framebuffer_object_id = 0;
9208 glw::GLint location = -1;
9209 glw::GLuint routine_index = -1;
9210 glw::GLuint routine_location = -1;
9211 const glw::GLchar* routine_name = "original_routine";
9212 const glw::GLenum shader_type = GL_COMPUTE_SHADER;
9213 glw::GLuint texture_object_id = 0;
9215 if (false == use_original)
9217 routine_name = "new_routine";
9220 gl.useProgram(this->program_object_id);
9221 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram() failed.");
9223 /* Select subroutine */
9224 routine_index = gl.getSubroutineIndex(this->program_object_id, shader_type, routine_name);
9225 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetSubroutineIndex() failed.");
9227 routine_location = gl.getSubroutineUniformLocation(this->program_object_id, shader_type, "routine");
9228 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetSubroutineUniformLocation() failed.");
9230 if (0 != routine_location)
9232 TCU_FAIL("Subroutine location is invalid");
9235 gl.uniformSubroutinesuiv(shader_type, 1, &routine_index);
9236 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniformSubroutinesuiv() failed.");
9238 /* Prepare texture */
9239 gl.genTextures(1, &texture_object_id);
9240 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures() failed.");
9242 gl.bindTexture(GL_TEXTURE_2D, texture_object_id);
9243 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture() failed.");
9245 gl.texStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 1, 1);
9246 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage2D() failed.");
9248 gl.bindImageTexture(0 /* image unit */, texture_object_id, 0 /* level */, GL_FALSE /* layered */, 0 /* layer */,
9249 GL_WRITE_ONLY, GL_RGBA8);
9250 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindImageTexture() failed.");
9252 location = gl.getUniformLocation(this->program_object_id, "uni_image");
9253 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation() failed.");
9257 TCU_FAIL("Uniform is inactive");
9260 gl.uniform1i(location, 0 /* image unit */);
9261 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i() failed.");
9264 gl.dispatchCompute(1, 1, 1);
9265 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
9268 gl.genFramebuffers(1, &framebuffer_object_id);
9269 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers() failed.");
9271 gl.bindFramebuffer(GL_FRAMEBUFFER, framebuffer_object_id);
9272 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer() failed.");
9274 gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_object_id, 0);
9275 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferTexture2D() failed.");
9277 gl.viewport(0, 0, 1, 1);
9278 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport() failed.");
9280 gl.readBuffer(GL_COLOR_ATTACHMENT0);
9281 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadBuffer() failed.");
9283 gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
9284 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels() failed.");
9286 if ((buffer[0] != 255) != expect_invalid_result)
9288 TCU_FAIL("Invalid result was returned.");
9291 /* Delete generated objects. */
9292 gl.deleteTextures(1, &texture_object_id);
9293 gl.deleteFramebuffers(1, &framebuffer_object_id);
9294 GLU_EXPECT_NO_ERROR(gl.getError(), "An error ocurred while deleting generated objects.");
9297 /** Executes test for draw program
9299 * @tparam API Tested API descriptor
9301 * @param tested_shader_type The type of shader that is being tested
9302 * @param function_definition Definition used to prepare shader
9303 * @param function_use Use of definition
9304 * @param verification Result verification
9305 * @param use_original Selects if "original_routine" - true or "new_routine" is choosen
9306 * @param expect_invalid_result Does test expects invalid results
9308 template <class API>
9309 void SubroutineFunctionCalls1<API>::execute_draw_test(typename TestCaseBase<API>::TestShaderType tested_shader_type,
9310 const std::string& function_definition,
9311 const std::string& function_use, const std::string& verification,
9312 bool use_original, bool expect_invalid_result)
9314 const glw::Functions& gl = this->context_id.getRenderContext().getFunctions();
9316 if (API::USE_ALL_SHADER_STAGES)
9318 const std::string& compute_shader_source = empty_string;
9319 const std::string& fragment_shader_source =
9320 this->prepare_fragment_shader(tested_shader_type, function_definition, function_use, verification);
9321 const std::string& geometry_shader_source =
9322 this->prepare_geometry_shader(tested_shader_type, function_definition, function_use, verification);
9323 const std::string& tess_ctrl_shader_source =
9324 this->prepare_tess_ctrl_shader(tested_shader_type, function_definition, function_use, verification);
9325 const std::string& tess_eval_shader_source =
9326 this->prepare_tess_eval_shader(tested_shader_type, function_definition, function_use, verification);
9327 const std::string& vertex_shader_source =
9328 this->prepare_vertex_shader(tested_shader_type, function_definition, function_use, verification);
9330 switch (tested_shader_type)
9332 case TestCaseBase<API>::VERTEX_SHADER_TYPE: /* Fall through */
9333 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
9334 this->execute_positive_test(vertex_shader_source, fragment_shader_source, false, false);
9337 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
9338 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
9339 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE: /* Fall through */
9340 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
9341 this->execute_positive_test(vertex_shader_source, tess_ctrl_shader_source, tess_eval_shader_source,
9342 geometry_shader_source, fragment_shader_source, compute_shader_source, false,
9347 TCU_FAIL("Invalid enum");
9353 const std::string& fragment_shader_source =
9354 this->prepare_fragment_shader(tested_shader_type, function_definition, function_use, verification);
9355 const std::string& vertex_shader_source =
9356 this->prepare_vertex_shader(tested_shader_type, function_definition, function_use, verification);
9358 this->execute_positive_test(vertex_shader_source, fragment_shader_source, false, false);
9361 /* We are now ready to verify whether the returned size is correct. */
9362 unsigned char buffer[4] = { 0 };
9363 glw::GLuint framebuffer_object_id = 0;
9364 glw::GLuint routine_index = -1;
9365 glw::GLuint routine_location = -1;
9366 const glw::GLchar* routine_name = "original_routine";
9367 glw::GLenum shader_type = 0;
9368 glw::GLuint texture_object_id = 0;
9369 glw::GLuint vao_id = 0;
9371 switch (tested_shader_type)
9373 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
9374 shader_type = GL_FRAGMENT_SHADER;
9376 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
9377 shader_type = GL_VERTEX_SHADER;
9379 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
9380 shader_type = GL_COMPUTE_SHADER;
9382 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
9383 shader_type = GL_GEOMETRY_SHADER;
9385 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
9386 shader_type = GL_TESS_CONTROL_SHADER;
9388 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
9389 shader_type = GL_TESS_EVALUATION_SHADER;
9392 TCU_FAIL("Invalid shader type");
9396 if (false == use_original)
9398 routine_name = "new_routine";
9401 gl.useProgram(this->program_object_id);
9402 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram() failed.");
9404 /* Select subroutine */
9405 routine_index = gl.getSubroutineIndex(this->program_object_id, shader_type, routine_name);
9406 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetSubroutineIndex() failed.");
9408 routine_location = gl.getSubroutineUniformLocation(this->program_object_id, shader_type, "routine");
9409 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetSubroutineUniformLocation() failed.");
9411 if (0 != routine_location)
9413 TCU_FAIL("Subroutine location is invalid");
9416 gl.uniformSubroutinesuiv(shader_type, 1, &routine_index);
9417 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniformSubroutinesuiv() failed.");
9419 /* Prepre texture */
9420 assert(0 == texture_object_id);
9421 gl.genTextures(1, &texture_object_id);
9422 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures() failed.");
9424 gl.bindTexture(GL_TEXTURE_2D, texture_object_id);
9425 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture() failed.");
9427 gl.texStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 1, 1);
9428 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage2D() failed.");
9430 /* Prepare framebuffer */
9431 assert(0 == framebuffer_object_id);
9432 gl.genFramebuffers(1, &framebuffer_object_id);
9433 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers() failed.");
9435 gl.bindFramebuffer(GL_FRAMEBUFFER, framebuffer_object_id);
9436 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer() failed.");
9438 gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_object_id, 0);
9439 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferTexture2D() failed.");
9441 gl.viewport(0, 0, 1, 1);
9442 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport() failed.");
9445 assert(0 == vao_id);
9446 gl.genVertexArrays(1, &vao_id);
9447 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenVertexArrays() failed.");
9449 gl.bindVertexArray(vao_id);
9450 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray() failed.");
9452 switch (tested_shader_type)
9454 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE: /* Fall through */
9455 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
9456 gl.drawArrays(GL_TRIANGLE_FAN, 0, 4);
9457 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
9460 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE: /* Fall through */
9461 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
9462 /* Tesselation patch set up */
9463 gl.patchParameteri(GL_PATCH_VERTICES, 1);
9464 GLU_EXPECT_NO_ERROR(gl.getError(), "PatchParameteri");
9466 gl.drawArrays(GL_PATCHES, 0, 1);
9467 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
9470 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
9471 gl.drawArrays(GL_POINTS, 0, 1);
9472 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
9476 TCU_FAIL("Invalid enum");
9481 gl.readBuffer(GL_COLOR_ATTACHMENT0);
9482 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadBuffer() failed.");
9484 gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
9485 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels() failed.");
9487 const bool result = ((buffer[0] != 255) == expect_invalid_result);
9489 /* Delete generated objects. */
9491 gl.bindTexture(GL_TEXTURE_2D, 0);
9492 gl.bindFramebuffer(GL_FRAMEBUFFER, 0);
9493 gl.bindVertexArray(0);
9495 gl.deleteProgram(this->program_object_id);
9496 this->program_object_id = 0;
9498 gl.deleteTextures(1, &texture_object_id);
9499 texture_object_id = 0;
9501 gl.deleteFramebuffers(1, &framebuffer_object_id);
9502 framebuffer_object_id = 0;
9504 gl.deleteVertexArrays(1, &vao_id);
9507 GLU_EXPECT_NO_ERROR(gl.getError(), "An error ocurred while deleting generated objects.");
9511 TCU_FAIL("Invalid result was returned.");
9517 * @tparam API Tested API descriptor
9519 * @param tested_shader_type The type of shader that is being tested
9520 * @param function_definition Definition used to prepare shader
9521 * @param function_use Use of definition
9522 * @param verification Result verification
9524 template <class API>
9525 std::string SubroutineFunctionCalls1<API>::prepare_compute_shader(
9526 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& function_definition,
9527 const std::string& function_use, const std::string& verification)
9529 std::string compute_shader_source;
9531 if (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type)
9533 compute_shader_source = "writeonly uniform image2D uni_image;\n"
9536 /* User-defined function definition. */
9537 compute_shader_source += function_definition;
9538 compute_shader_source += "\n\n";
9540 /* Main function definition. */
9541 compute_shader_source += shader_start;
9542 compute_shader_source += function_use;
9543 compute_shader_source += "\n\n";
9544 compute_shader_source += verification;
9545 compute_shader_source += "\n\n";
9546 compute_shader_source += "\n"
9547 " imageStore(uni_image, ivec2(gl_GlobalInvocationID.xy), vec4(result, 0, 0, 0));\n"
9552 return compute_shader_source;
9557 * @tparam API Tested API descriptor
9559 * @param tested_shader_type The type of shader that is being tested
9560 * @param function_definition Definition used to prepare shader
9561 * @param function_use Use of definition
9562 * @param verification Result verification
9564 template <class API>
9565 std::string SubroutineFunctionCalls1<API>::prepare_fragment_shader(
9566 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& function_definition,
9567 const std::string& function_use, const std::string& verification)
9569 std::string fragment_shader_source;
9571 switch (tested_shader_type)
9573 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
9576 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
9577 fragment_shader_source = "out vec4 colour;\n\n";
9579 /* User-defined function definition. */
9580 fragment_shader_source += function_definition;
9581 fragment_shader_source += "\n\n";
9583 /* Main function definition. */
9584 fragment_shader_source += shader_start;
9585 fragment_shader_source += function_use;
9586 fragment_shader_source += "\n\n";
9587 fragment_shader_source += verification;
9588 fragment_shader_source += "\n\n";
9589 fragment_shader_source += " colour = vec4(result);\n";
9590 fragment_shader_source += shader_end;
9593 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
9594 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
9595 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE: /* Fall through */
9596 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
9597 fragment_shader_source = "in float fs_result;\n\n"
9598 "out vec4 colour;\n\n"
9601 " colour = vec4(fs_result);\n"
9607 TCU_FAIL("Unrecognized shader object type.");
9611 return fragment_shader_source;
9616 * @tparam API Tested API descriptor
9618 * @param tested_shader_type The type of shader that is being tested
9619 * @param function_definition Definition used to prepare shader
9620 * @param function_use Use of definition
9621 * @param verification Result verification
9623 template <class API>
9624 std::string SubroutineFunctionCalls1<API>::prepare_geometry_shader(
9625 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& function_definition,
9626 const std::string& function_use, const std::string& verification)
9628 std::string geometry_shader_source;
9630 switch (tested_shader_type)
9632 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
9633 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE: /* Fall through */
9634 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
9637 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE: /* Fall through */
9638 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
9639 geometry_shader_source = "layout(points) in;\n"
9640 "layout(triangle_strip, max_vertices = 4) out;\n"
9642 "in float tes_result[];\n"
9643 "out float fs_result;\n"
9647 " gl_Position = vec4(-1, -1, 0, 1);\n"
9648 " fs_result = tes_result[0];\n"
9650 " gl_Position = vec4(-1, 1, 0, 1);\n"
9651 " fs_result = tes_result[0];\n"
9653 " gl_Position = vec4(1, -1, 0, 1);\n"
9654 " fs_result = tes_result[0];\n"
9656 " gl_Position = vec4(1, 1, 0, 1);\n"
9657 " fs_result = tes_result[0];\n"
9662 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
9663 geometry_shader_source = "layout(points) in;\n"
9664 "layout(triangle_strip, max_vertices = 4) out;\n"
9666 "out float fs_result;\n"
9669 /* User-defined function definition. */
9670 geometry_shader_source += function_definition;
9671 geometry_shader_source += "\n\n";
9673 /* Main function definition. */
9674 geometry_shader_source += shader_start;
9675 geometry_shader_source += function_use;
9676 geometry_shader_source += "\n\n";
9677 geometry_shader_source += verification;
9678 geometry_shader_source += "\n\n";
9679 geometry_shader_source += "\n gl_Position = vec4(-1, -1, 0, 1);\n"
9680 " fs_result = result;\n"
9682 " gl_Position = vec4(-1, 1, 0, 1);\n"
9683 " fs_result = result;\n"
9685 " gl_Position = vec4(1, -1, 0, 1);\n"
9686 " fs_result = result;\n"
9688 " gl_Position = vec4(1, 1, 0, 1);\n"
9689 " fs_result = result;\n"
9695 TCU_FAIL("Unrecognized shader object type.");
9699 return geometry_shader_source;
9704 * @tparam API Tested API descriptor
9706 * @param tested_shader_type The type of shader that is being tested
9707 * @param function_definition Definition used to prepare shader
9708 * @param function_use Use of definition
9709 * @param verification Result verification
9711 template <class API>
9712 std::string SubroutineFunctionCalls1<API>::prepare_tess_ctrl_shader(
9713 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& function_definition,
9714 const std::string& function_use, const std::string& verification)
9716 std::string tess_ctrl_shader_source;
9718 switch (tested_shader_type)
9720 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
9721 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
9722 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
9723 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
9726 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
9727 tess_ctrl_shader_source = "layout(vertices = 1) out;\n"
9729 "out float tcs_result[];\n"
9732 /* User-defined function definition. */
9733 tess_ctrl_shader_source += function_definition;
9734 tess_ctrl_shader_source += "\n\n";
9736 /* Main function definition. */
9737 tess_ctrl_shader_source += shader_start;
9738 tess_ctrl_shader_source += function_use;
9739 tess_ctrl_shader_source += "\n\n";
9740 tess_ctrl_shader_source += verification;
9741 tess_ctrl_shader_source += "\n\n";
9742 tess_ctrl_shader_source += " tcs_result[gl_InvocationID] = result;\n"
9744 " gl_TessLevelOuter[0] = 1.0;\n"
9745 " gl_TessLevelOuter[1] = 1.0;\n"
9746 " gl_TessLevelOuter[2] = 1.0;\n"
9747 " gl_TessLevelOuter[3] = 1.0;\n"
9748 " gl_TessLevelInner[0] = 1.0;\n"
9749 " gl_TessLevelInner[1] = 1.0;\n"
9753 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
9754 tess_ctrl_shader_source = default_tc_shader_source;
9758 TCU_FAIL("Unrecognized shader object type.");
9762 return tess_ctrl_shader_source;
9767 * @tparam API Tested API descriptor
9769 * @param tested_shader_type The type of shader that is being tested
9770 * @param function_definition Definition used to prepare shader
9771 * @param function_use Use of definition
9772 * @param verification Result verification
9774 template <class API>
9775 std::string SubroutineFunctionCalls1<API>::prepare_tess_eval_shader(
9776 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& function_definition,
9777 const std::string& function_use, const std::string& verification)
9779 std::string tess_eval_shader_source;
9781 switch (tested_shader_type)
9783 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
9784 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
9785 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
9786 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
9789 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
9790 tess_eval_shader_source = "layout(isolines, point_mode) in;\n"
9792 "in float tcs_result[];\n"
9793 "out float tes_result;\n"
9797 " tes_result = tcs_result[0];\n"
9801 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
9802 tess_eval_shader_source = "layout(isolines, point_mode) in;\n"
9804 "out float tes_result;\n"
9807 /* User-defined function definition. */
9808 tess_eval_shader_source += function_definition;
9809 tess_eval_shader_source += "\n\n";
9811 /* Main function definition. */
9812 tess_eval_shader_source += shader_start;
9813 tess_eval_shader_source += function_use;
9814 tess_eval_shader_source += "\n\n";
9815 tess_eval_shader_source += verification;
9816 tess_eval_shader_source += "\n\n";
9817 tess_eval_shader_source += " tes_result = result;\n"
9822 TCU_FAIL("Unrecognized shader object type.");
9826 return tess_eval_shader_source;
9831 * @tparam API Tested API descriptor
9833 * @param tested_shader_type The type of shader that is being tested
9834 * @param function_definition Definition used to prepare shader
9835 * @param function_use Use of definition
9836 * @param verification Result verification
9838 template <class API>
9839 std::string SubroutineFunctionCalls1<API>::prepare_vertex_shader(
9840 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& function_definition,
9841 const std::string& function_use, const std::string& verification)
9843 std::string vertex_shader_source;
9845 switch (tested_shader_type)
9847 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
9850 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
9851 vertex_shader_source = "/** GL_TRIANGLE_FAN-type quad vertex data. */\n"
9852 "const vec4 vertex_positions[4] = vec4[4](vec4( 1.0, -1.0, 0.0, 1.0),\n"
9853 " vec4(-1.0, -1.0, 0.0, 1.0),\n"
9854 " vec4(-1.0, 1.0, 0.0, 1.0),\n"
9855 " vec4( 1.0, 1.0, 0.0, 1.0) );\n"
9859 " gl_Position = vertex_positions[gl_VertexID];"
9863 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
9864 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
9865 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
9866 vertex_shader_source = default_vertex_shader_source;
9869 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
9870 /* Vertex shader source. */
9871 vertex_shader_source = "out float fs_result;\n\n";
9872 vertex_shader_source += "/** GL_TRIANGLE_FAN-type quad vertex data. */\n"
9873 "const vec4 vertex_positions[4] = vec4[4](vec4( 1.0, -1.0, 0.0, 1.0),\n"
9874 " vec4(-1.0, -1.0, 0.0, 1.0),\n"
9875 " vec4(-1.0, 1.0, 0.0, 1.0),\n"
9876 " vec4( 1.0, 1.0, 0.0, 1.0) );\n\n";
9878 /* User-defined function definition. */
9879 vertex_shader_source += function_definition;
9880 vertex_shader_source += "\n\n";
9882 /* Main function definition. */
9883 vertex_shader_source += shader_start;
9884 vertex_shader_source += function_use;
9885 vertex_shader_source += "\n\n";
9886 vertex_shader_source += verification;
9887 vertex_shader_source += "\n\n";
9888 vertex_shader_source += " fs_result = result;\n"
9889 " gl_Position = vertex_positions[gl_VertexID];\n";
9890 vertex_shader_source += shader_end;
9894 TCU_FAIL("Unrecognized shader object type.");
9898 return vertex_shader_source;
9901 /* Generates the shader source code for the InteractionFunctionCalls2
9902 * array tests, and attempts to build and execute test program.
9904 * @tparam API Tested API descriptor
9906 * @param tested_shader_type The type of shader that is being tested
9908 template <class API>
9909 void SubroutineFunctionCalls2<API>::test_shader_compilation(
9910 typename TestCaseBase<API>::TestShaderType tested_shader_type)
9912 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_IVEC2,
9913 VAR_TYPE_IVEC3, VAR_TYPE_IVEC4, VAR_TYPE_VEC2,
9914 VAR_TYPE_VEC3, VAR_TYPE_VEC4, VAR_TYPE_MAT2,
9915 VAR_TYPE_MAT3, VAR_TYPE_MAT4 };
9916 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
9918 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_IVEC2,
9919 VAR_TYPE_IVEC3, VAR_TYPE_IVEC4, VAR_TYPE_VEC2,
9920 VAR_TYPE_VEC3, VAR_TYPE_VEC4, VAR_TYPE_MAT2,
9921 VAR_TYPE_MAT3, VAR_TYPE_MAT4, VAR_TYPE_DOUBLE,
9922 VAR_TYPE_DMAT2, VAR_TYPE_DMAT3, VAR_TYPE_DMAT4 };
9923 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
9925 const std::string iteration_loop_end = " }\n"
9933 const std::string iteration_loop_start = " for (uint a = 0u; a < 2u; a++)\n"
9935 " for (uint b = 0u; b < 2u; b++)\n"
9937 " for (uint c = 0u; c < 2u; c++)\n"
9939 " for (uint d = 0u; d < 2u; d++)\n"
9941 " for (uint e = 0u; e < 2u; e++)\n"
9943 " for (uint f = 0u; f < 2u; f++)\n"
9945 " for (uint g = 0u; g < 2u; g++)\n"
9947 " for (uint h = 0u; h < 2u; h++)\n"
9949 const std::string multiplier_array = "const int[] multiplier_array = int[]( 1, 2, 3, 4, 5, 6, 7, 8,\n"
9950 " 11, 12, 13, 14, 15, 16, 17, 18,\n"
9951 " 21, 22, 23, 24, 25, 26, 27, 28,\n"
9952 " 31, 32, 33, 34, 35, 36, 37, 38,\n"
9953 " 41, 42, 43, 44, 45, 46, 47, 48,\n"
9954 " 51, 52, 53, 54, 55, 56, 57, 58,\n"
9955 " 61, 62, 63, 64, 65, 66, 67, 68,\n"
9956 " 71, 72, 73, 74, 75, 76, 77, 78,\n"
9957 " 81, 82, 83, 84, 85, 86, 87, 88);\n";
9958 const glcts::test_var_type* var_types_set = var_types_set_es;
9959 size_t num_var_types = num_var_types_es;
9960 const bool test_compute = (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type);
9962 if (API::USE_DOUBLE)
9964 var_types_set = var_types_set_gl;
9965 num_var_types = num_var_types_gl;
9968 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
9970 _supported_variable_types_map_const_iterator var_iterator =
9971 supported_variable_types_map.find(var_types_set[var_type_index]);
9973 if (var_iterator != supported_variable_types_map.end())
9975 std::string function_definition;
9976 std::string function_use;
9977 std::string verification;
9979 function_definition += multiplier_array;
9981 function_definition += "// Subroutine types\n"
9982 "subroutine void inout_routine_type(inout ";
9983 function_definition += var_iterator->second.type;
9984 function_definition += " inout_array[2][2][2][2][2][2][2][2]);\n\n"
9985 "// Subroutine definitions\n"
9986 "subroutine(inout_routine_type) void original_routine(inout ";
9987 function_definition += var_iterator->second.type;
9988 function_definition += " inout_array[2][2][2][2][2][2][2][2]) {\n"
9990 function_definition += iteration_loop_start;
9991 function_definition += " inout_array[a][b][c][d][e][f][g][h] *= " +
9992 var_iterator->second.iterator_type + "(multiplier_array[i % 64u]);\n";
9993 function_definition += " i+= 1u;\n";
9994 function_definition += iteration_loop_end;
9995 function_definition += "}\n\n"
9996 "subroutine(inout_routine_type) void new_routine(inout ";
9997 function_definition += var_iterator->second.type;
9998 function_definition += " inout_array[2][2][2][2][2][2][2][2]) {\n"
10000 function_definition += iteration_loop_start;
10001 function_definition += " inout_array[a][b][c][d][e][f][g][h] /= " +
10002 var_iterator->second.iterator_type + "(multiplier_array[i % 64u]);\n";
10003 function_definition += " i+= 1u;\n";
10004 function_definition += iteration_loop_end;
10005 function_definition += "}\n\n"
10006 "// Subroutine uniform\n"
10007 "subroutine uniform inout_routine_type routine;\n";
10009 function_use += " float result = 1.0;\n";
10010 function_use += " uint iterator = 0u;\n";
10011 function_use += " " + var_iterator->second.type + " my_array[2][2][2][2][2][2][2][2];\n";
10012 function_use += iteration_loop_start;
10013 function_use += " my_array[a][b][c][d][e][f][g][h] = " +
10014 var_iterator->second.variable_type_initializer2 + ";\n";
10015 function_use += iteration_loop_end;
10016 function_use += " routine(my_array);";
10018 verification += iteration_loop_start;
10019 verification += " if (my_array[a][b][c][d][e][f][g][h] " +
10020 var_iterator->second.specific_element + "!= " + var_iterator->second.iterator_type +
10021 "(multiplier_array[iterator % 64u]))\n"
10025 " iterator += 1u;\n";
10026 verification += iteration_loop_end;
10028 if (false == test_compute)
10030 this->execute_draw_test(tested_shader_type, function_definition, function_use, verification, false,
10032 this->execute_draw_test(tested_shader_type, function_definition, function_use, verification, true,
10037 this->execute_dispatch_test(tested_shader_type, function_definition, function_use, verification, false,
10039 this->execute_dispatch_test(tested_shader_type, function_definition, function_use, verification, true,
10043 /* Deallocate any resources used. */
10044 this->delete_objects();
10045 } /* if var_type iterator found */
10048 TCU_FAIL("Type not found.");
10050 } /* for (int var_type_index = 0; ...) */
10053 /* Generates the shader source code for the SubroutineArgumentAliasing1
10054 * array tests, attempts to build and execute test program
10056 * @tparam API Tested API descriptor
10058 * @param tested_shader_type The type of shader that is being tested
10060 template <class API>
10061 void SubroutineArgumentAliasing1<API>::test_shader_compilation(
10062 typename TestCaseBase<API>::TestShaderType tested_shader_type)
10064 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_IVEC2,
10065 VAR_TYPE_IVEC3, VAR_TYPE_IVEC4, VAR_TYPE_VEC2,
10066 VAR_TYPE_VEC3, VAR_TYPE_VEC4, VAR_TYPE_MAT2,
10067 VAR_TYPE_MAT3, VAR_TYPE_MAT4 };
10068 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
10070 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_IVEC2,
10071 VAR_TYPE_IVEC3, VAR_TYPE_IVEC4, VAR_TYPE_VEC2,
10072 VAR_TYPE_VEC3, VAR_TYPE_VEC4, VAR_TYPE_MAT2,
10073 VAR_TYPE_MAT3, VAR_TYPE_MAT4, VAR_TYPE_DOUBLE,
10074 VAR_TYPE_DMAT2, VAR_TYPE_DMAT3, VAR_TYPE_DMAT4 };
10075 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
10077 const std::string iteration_loop_end = " }\n"
10083 const std::string iteration_loop_start = " for (uint a = 0u; a < 2u; a++)\n"
10085 " for (uint b = 0u; b < 2u; b++)\n"
10087 " for (uint c = 0u; c < 2u; c++)\n"
10089 " for (uint d = 0u; d < 2u; d++)\n"
10091 " for (uint e = 0u; e < 2u; e++)\n"
10093 " for (uint f = 0u; f < 2u; f++)\n"
10095 const glcts::test_var_type* var_types_set = var_types_set_es;
10096 size_t num_var_types = num_var_types_es;
10097 const bool test_compute = (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type);
10099 if (API::USE_DOUBLE)
10101 var_types_set = var_types_set_gl;
10102 num_var_types = num_var_types_gl;
10105 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
10107 _supported_variable_types_map_const_iterator var_iterator =
10108 supported_variable_types_map.find(var_types_set[var_type_index]);
10110 if (var_iterator != supported_variable_types_map.end())
10112 std::string function_definition;
10113 std::string function_use;
10114 std::string verification;
10116 function_definition += "// Subroutine types\n"
10117 "subroutine bool in_routine_type(";
10118 function_definition += var_iterator->second.type;
10119 function_definition += " x[2][2][2][2][2][2], ";
10120 function_definition += var_iterator->second.type;
10121 function_definition += " y[2][2][2][2][2][2]);\n\n"
10122 "// Subroutine definitions\n"
10123 "subroutine(in_routine_type) bool original_routine(";
10124 function_definition += var_iterator->second.type;
10125 function_definition += " x[2][2][2][2][2][2], ";
10126 function_definition += var_iterator->second.type;
10127 function_definition += " y[2][2][2][2][2][2])\n{\n";
10128 function_definition += iteration_loop_start;
10129 function_definition +=
10130 " x[a][b][c][d][e][f] = " + var_iterator->second.type + "(123);\n";
10131 function_definition += iteration_loop_end;
10132 function_definition += "\n";
10133 function_definition += iteration_loop_start;
10134 function_definition += " if(y[a][b][c][d][e][f]";
10135 if (var_iterator->second.type == "mat4") // mat4 comparison
10137 function_definition += "[0][0]";
10138 function_definition += " != float";
10140 else if (var_iterator->second.type == "dmat4") // dmat4 comparison
10142 function_definition += "[0][0]";
10143 function_definition += " != double";
10147 function_definition += " != ";
10148 function_definition += var_iterator->second.type;
10150 function_definition += "(((a*32u)+(b*16u)+(c*8u)+(d*4u)+(e*2u)+f))) {return false;}\n";
10151 function_definition += iteration_loop_end;
10152 function_definition += "\n return true;\n";
10153 function_definition += "}\n\n"
10154 "subroutine(in_routine_type) bool new_routine(";
10155 function_definition += var_iterator->second.type;
10156 function_definition += " x[2][2][2][2][2][2], ";
10157 function_definition += var_iterator->second.type;
10158 function_definition += " y[2][2][2][2][2][2])\n{\n";
10159 function_definition += iteration_loop_start;
10160 function_definition +=
10161 " y[a][b][c][d][e][f] = " + var_iterator->second.type + "(123);\n";
10162 function_definition += iteration_loop_end;
10163 function_definition += "\n";
10164 function_definition += iteration_loop_start;
10165 function_definition += " if(x[a][b][c][d][e][f]";
10166 if (var_iterator->second.type == "mat4") // mat4 comparison
10168 function_definition += "[0][0]";
10169 function_definition += " != float";
10171 else if (var_iterator->second.type == "dmat4") // dmat4 comparison
10173 function_definition += "[0][0]";
10174 function_definition += " != double";
10178 function_definition += " != ";
10179 function_definition += var_iterator->second.type;
10181 function_definition += "(((a*32u)+(b*16u)+(c*8u)+(d*4u)+(e*2u)+f))) {return false;}\n";
10182 function_definition += iteration_loop_end;
10183 function_definition += "\n return true;\n";
10184 function_definition += "}\n\n"
10185 "// Subroutine uniform\n"
10186 "subroutine uniform in_routine_type routine;\n";
10188 function_use += " " + var_iterator->second.type + " z[2][2][2][2][2][2];\n";
10189 function_use += iteration_loop_start;
10190 function_use += " z[a][b][c][d][e][f] = ";
10191 function_use += var_iterator->second.type;
10192 function_use += "(((a*32u)+(b*16u)+(c*8u)+(d*4u)+(e*2u)+f));\n";
10193 function_use += iteration_loop_end;
10195 verification = " float result = 0.0;\n"
10196 " if(routine(z, z) == true)\n"
10205 if (false == test_compute)
10207 this->execute_draw_test(tested_shader_type, function_definition, function_use, verification, false,
10209 this->execute_draw_test(tested_shader_type, function_definition, function_use, verification, true,
10214 this->execute_dispatch_test(tested_shader_type, function_definition, function_use, verification, false,
10216 this->execute_dispatch_test(tested_shader_type, function_definition, function_use, verification, true,
10220 /* Deallocate any resources used. */
10221 this->delete_objects();
10222 } /* if var_type iterator found */
10225 TCU_FAIL("Type not found.");
10227 } /* for (int var_type_index = 0; ...) */
10230 /* Generates the shader source code for the SubroutineArgumentAliasing1
10231 * array tests, attempts to build and execute test program
10233 * @tparam API Tested API descriptor
10235 * @param tested_shader_type The type of shader that is being tested
10237 template <class API>
10238 void SubroutineArgumentAliasing2<API>::test_shader_compilation(
10239 typename TestCaseBase<API>::TestShaderType tested_shader_type)
10241 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_IVEC2,
10242 VAR_TYPE_IVEC3, VAR_TYPE_IVEC4, VAR_TYPE_VEC2,
10243 VAR_TYPE_VEC3, VAR_TYPE_VEC4, VAR_TYPE_MAT2,
10244 VAR_TYPE_MAT3, VAR_TYPE_MAT4 };
10245 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
10247 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_IVEC2,
10248 VAR_TYPE_IVEC3, VAR_TYPE_IVEC4, VAR_TYPE_VEC2,
10249 VAR_TYPE_VEC3, VAR_TYPE_VEC4, VAR_TYPE_MAT2,
10250 VAR_TYPE_MAT3, VAR_TYPE_MAT4, VAR_TYPE_DOUBLE,
10251 VAR_TYPE_DMAT2, VAR_TYPE_DMAT3, VAR_TYPE_DMAT4 };
10252 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
10254 const std::string iteration_loop_end = " }\n"
10260 const std::string iteration_loop_start = " for (uint a = 0u; a < 2u; a++)\n"
10262 " for (uint b = 0u; b < 2u; b++)\n"
10264 " for (uint c = 0u; c < 2u; c++)\n"
10266 " for (uint d = 0u; d < 2u; d++)\n"
10268 " for (uint e = 0u; e < 2u; e++)\n"
10270 " for (uint f = 0u; f < 2u; f++)\n"
10272 const glcts::test_var_type* var_types_set = var_types_set_es;
10273 size_t num_var_types = num_var_types_es;
10274 const bool test_compute = (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type);
10276 if (API::USE_DOUBLE)
10278 var_types_set = var_types_set_gl;
10279 num_var_types = num_var_types_gl;
10282 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
10284 _supported_variable_types_map_const_iterator var_iterator =
10285 supported_variable_types_map.find(var_types_set[var_type_index]);
10287 if (var_iterator != supported_variable_types_map.end())
10289 std::string function_definition;
10290 std::string function_use;
10291 std::string verification;
10293 function_definition += "// Subroutine types\n"
10294 "subroutine bool inout_routine_type(inout ";
10295 function_definition += var_iterator->second.type;
10296 function_definition += " x[2][2][2][2][2][2], inout ";
10297 function_definition += var_iterator->second.type;
10298 function_definition += " y[2][2][2][2][2][2]);\n\n"
10299 "// Subroutine definitions\n"
10300 "subroutine(inout_routine_type) bool original_routine(inout ";
10301 function_definition += var_iterator->second.type;
10302 function_definition += " x[2][2][2][2][2][2], inout ";
10303 function_definition += var_iterator->second.type;
10304 function_definition += " y[2][2][2][2][2][2])\n{\n";
10305 function_definition += iteration_loop_start;
10306 function_definition +=
10307 " x[a][b][c][d][e][f] = " + var_iterator->second.type + "(123);\n";
10308 function_definition += iteration_loop_end;
10309 function_definition += "\n";
10310 function_definition += iteration_loop_start;
10311 function_definition += " if(y[a][b][c][d][e][f]";
10312 if (var_iterator->second.type == "mat4") // mat4 comparison
10314 function_definition += "[0][0]";
10315 function_definition += " != float";
10317 else if (var_iterator->second.type == "dmat4") // dmat4 comparison
10319 function_definition += "[0][0]";
10320 function_definition += " != double";
10324 function_definition += " != ";
10325 function_definition += var_iterator->second.type;
10327 function_definition += "(((a*32u)+(b*16u)+(c*8u)+(d*4u)+(e*2u)+f))) {return false;}\n";
10328 function_definition += iteration_loop_end;
10329 function_definition += "\n return true;\n";
10330 function_definition += "}\n\n"
10331 "subroutine(inout_routine_type) bool new_routine(inout ";
10332 function_definition += var_iterator->second.type;
10333 function_definition += " x[2][2][2][2][2][2], inout ";
10334 function_definition += var_iterator->second.type;
10335 function_definition += " y[2][2][2][2][2][2])\n{\n";
10336 function_definition += iteration_loop_start;
10337 function_definition +=
10338 " y[a][b][c][d][e][f] = " + var_iterator->second.type + "(123);\n";
10339 function_definition += iteration_loop_end;
10340 function_definition += "\n";
10341 function_definition += iteration_loop_start;
10342 function_definition += " if(x[a][b][c][d][e][f]";
10343 if (var_iterator->second.type == "mat4") // mat4 comparison
10345 function_definition += "[0][0]";
10346 function_definition += " != float";
10348 else if (var_iterator->second.type == "dmat4") // dmat4 comparison
10350 function_definition += "[0][0]";
10351 function_definition += " != double";
10355 function_definition += " != ";
10356 function_definition += var_iterator->second.type;
10358 function_definition += "(((a*32u)+(b*16u)+(c*8u)+(d*4u)+(e*2u)+f))) {return false;}\n";
10359 function_definition += iteration_loop_end;
10360 function_definition += "\n return true;\n";
10361 function_definition += "}\n\n"
10362 "// Subroutine uniform\n"
10363 "subroutine uniform inout_routine_type routine;\n";
10365 function_use += " " + var_iterator->second.type + " z[2][2][2][2][2][2];\n";
10366 function_use += iteration_loop_start;
10367 function_use += " z[a][b][c][d][e][f] = ";
10368 function_use += var_iterator->second.type;
10369 function_use += "(((a*32u)+(b*16u)+(c*8u)+(d*4u)+(e*2u)+f));\n";
10370 function_use += iteration_loop_end;
10372 verification = " float result = 0.0;\n"
10373 " if(routine(z, z) == true)\n"
10382 if (false == test_compute)
10384 this->execute_draw_test(tested_shader_type, function_definition, function_use, verification, false,
10386 this->execute_draw_test(tested_shader_type, function_definition, function_use, verification, true,
10391 this->execute_dispatch_test(tested_shader_type, function_definition, function_use, verification, false,
10393 this->execute_dispatch_test(tested_shader_type, function_definition, function_use, verification, true,
10397 /* Deallocate any resources used. */
10398 this->delete_objects();
10399 } /* if var_type iterator found */
10402 TCU_FAIL("Type not found.");
10404 } /* for (int var_type_index = 0; ...) */
10407 /* Generates the shader source code for the SubroutineArgumentAliasing1
10408 * array tests, attempts to build and execute test program
10410 * @tparam API Tested API descriptor
10412 * @param tested_shader_type The type of shader that is being tested
10414 template <class API>
10415 void SubroutineArgumentAliasing3<API>::test_shader_compilation(
10416 typename TestCaseBase<API>::TestShaderType tested_shader_type)
10418 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_IVEC2,
10419 VAR_TYPE_IVEC3, VAR_TYPE_IVEC4, VAR_TYPE_VEC2,
10420 VAR_TYPE_VEC3, VAR_TYPE_VEC4, VAR_TYPE_MAT2,
10421 VAR_TYPE_MAT3, VAR_TYPE_MAT4 };
10422 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
10424 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_IVEC2,
10425 VAR_TYPE_IVEC3, VAR_TYPE_IVEC4, VAR_TYPE_VEC2,
10426 VAR_TYPE_VEC3, VAR_TYPE_VEC4, VAR_TYPE_MAT2,
10427 VAR_TYPE_MAT3, VAR_TYPE_MAT4, VAR_TYPE_DOUBLE,
10428 VAR_TYPE_DMAT2, VAR_TYPE_DMAT3, VAR_TYPE_DMAT4 };
10429 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
10431 const std::string iteration_loop_end = " }\n"
10437 const std::string iteration_loop_start = " for (uint a = 0u; a < 2u; a++)\n"
10439 " for (uint b = 0u; b < 2u; b++)\n"
10441 " for (uint c = 0u; c < 2u; c++)\n"
10443 " for (uint d = 0u; d < 2u; d++)\n"
10445 " for (uint e = 0u; e < 2u; e++)\n"
10447 " for (uint f = 0u; f < 2u; f++)\n"
10449 const glcts::test_var_type* var_types_set = var_types_set_es;
10450 size_t num_var_types = num_var_types_es;
10451 const bool test_compute = (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type);
10453 if (API::USE_DOUBLE)
10455 var_types_set = var_types_set_gl;
10456 num_var_types = num_var_types_gl;
10459 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
10461 _supported_variable_types_map_const_iterator var_iterator =
10462 supported_variable_types_map.find(var_types_set[var_type_index]);
10464 if (var_iterator != supported_variable_types_map.end())
10466 std::string function_definition;
10467 std::string function_use;
10468 std::string verification;
10470 function_definition += "// Subroutine types\n"
10471 "subroutine bool out_routine_type(out ";
10472 function_definition += var_iterator->second.type;
10473 function_definition += " x[2][2][2][2][2][2], ";
10474 function_definition += var_iterator->second.type;
10475 function_definition += " y[2][2][2][2][2][2]);\n\n"
10476 "// Subroutine definitions\n"
10477 "subroutine(out_routine_type) bool original_routine(out ";
10478 function_definition += var_iterator->second.type;
10479 function_definition += " x[2][2][2][2][2][2], ";
10480 function_definition += var_iterator->second.type;
10481 function_definition += " y[2][2][2][2][2][2])\n{\n";
10482 function_definition += iteration_loop_start;
10483 function_definition +=
10484 " x[a][b][c][d][e][f] = " + var_iterator->second.type + "(123);\n";
10485 function_definition += iteration_loop_end;
10486 function_definition += "\n";
10487 function_definition += iteration_loop_start;
10488 function_definition += " if(y[a][b][c][d][e][f]";
10489 if (var_iterator->second.type == "mat4") // mat4 comparison
10491 function_definition += "[0][0]";
10492 function_definition += " != float";
10494 else if (var_iterator->second.type == "dmat4") // dmat4 comparison
10496 function_definition += "[0][0]";
10497 function_definition += " != double";
10501 function_definition += " != ";
10502 function_definition += var_iterator->second.type;
10504 function_definition += "(((a*32u)+(b*16u)+(c*8u)+(d*4u)+(e*2u)+f))) {return false;}\n";
10505 function_definition += iteration_loop_end;
10506 function_definition += "\n return true;\n";
10507 function_definition += "}\n\n"
10508 "subroutine(out_routine_type) bool new_routine(out ";
10509 function_definition += var_iterator->second.type;
10510 function_definition += " x[2][2][2][2][2][2], ";
10511 function_definition += var_iterator->second.type;
10512 function_definition += " y[2][2][2][2][2][2])\n{\n";
10513 function_definition += iteration_loop_start;
10514 function_definition +=
10515 " x[a][b][c][d][e][f] = " + var_iterator->second.type + "(321);\n";
10516 function_definition += iteration_loop_end;
10517 function_definition += "\n";
10518 function_definition += iteration_loop_start;
10519 function_definition += " if(y[a][b][c][d][e][f]";
10520 if (var_iterator->second.type == "mat4") // mat4 comparison
10522 function_definition += "[0][0]";
10523 function_definition += " != float";
10525 else if (var_iterator->second.type == "dmat4") // dmat4 comparison
10527 function_definition += "[0][0]";
10528 function_definition += " != double";
10532 function_definition += " != ";
10533 function_definition += var_iterator->second.type;
10535 function_definition += "(((a*32u)+(b*16u)+(c*8u)+(d*4u)+(e*2u)+f))) {return false;}\n";
10536 function_definition += iteration_loop_end;
10537 function_definition += "\n return true;\n";
10538 function_definition += "}\n\n"
10539 "// Subroutine uniform\n"
10540 "subroutine uniform out_routine_type routine;\n";
10542 function_use += " " + var_iterator->second.type + " z[2][2][2][2][2][2];\n";
10543 function_use += iteration_loop_start;
10544 function_use += " z[a][b][c][d][e][f] = ";
10545 function_use += var_iterator->second.type;
10546 function_use += "(((a*32u)+(b*16u)+(c*8u)+(d*4u)+(e*2u)+f));\n";
10547 function_use += iteration_loop_end;
10549 verification = " float result = 0.0;\n"
10550 " if(routine(z, z) == true)\n"
10559 if (false == test_compute)
10561 this->execute_draw_test(tested_shader_type, function_definition, function_use, verification, false,
10563 this->execute_draw_test(tested_shader_type, function_definition, function_use, verification, true,
10568 this->execute_dispatch_test(tested_shader_type, function_definition, function_use, verification, false,
10570 this->execute_dispatch_test(tested_shader_type, function_definition, function_use, verification, true,
10574 /* Deallocate any resources used. */
10575 this->delete_objects();
10576 } /* if var_type iterator found */
10579 TCU_FAIL("Type not found.");
10581 } /* for (int var_type_index = 0; ...) */
10584 /* Generates the shader source code for the SubroutineArgumentAliasing1
10585 * array tests, attempts to build and execute test program
10587 * @tparam API Tested API descriptor
10589 * @param tested_shader_type The type of shader that is being tested
10591 template <class API>
10592 void SubroutineArgumentAliasing4<API>::test_shader_compilation(
10593 typename TestCaseBase<API>::TestShaderType tested_shader_type)
10595 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_IVEC2,
10596 VAR_TYPE_IVEC3, VAR_TYPE_IVEC4, VAR_TYPE_VEC2,
10597 VAR_TYPE_VEC3, VAR_TYPE_VEC4, VAR_TYPE_MAT2,
10598 VAR_TYPE_MAT3, VAR_TYPE_MAT4 };
10599 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
10601 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_IVEC2,
10602 VAR_TYPE_IVEC3, VAR_TYPE_IVEC4, VAR_TYPE_VEC2,
10603 VAR_TYPE_VEC3, VAR_TYPE_VEC4, VAR_TYPE_MAT2,
10604 VAR_TYPE_MAT3, VAR_TYPE_MAT4, VAR_TYPE_DOUBLE,
10605 VAR_TYPE_DMAT2, VAR_TYPE_DMAT3, VAR_TYPE_DMAT4 };
10606 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
10608 const std::string iteration_loop_end = " }\n"
10614 const std::string iteration_loop_start = " for (uint a = 0u; a < 2u; a++)\n"
10616 " for (uint b = 0u; b < 2u; b++)\n"
10618 " for (uint c = 0u; c < 2u; c++)\n"
10620 " for (uint d = 0u; d < 2u; d++)\n"
10622 " for (uint e = 0u; e < 2u; e++)\n"
10624 " for (uint f = 0u; f < 2u; f++)\n"
10626 const glcts::test_var_type* var_types_set = var_types_set_es;
10627 size_t num_var_types = num_var_types_es;
10628 const bool test_compute = (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type);
10630 if (API::USE_DOUBLE)
10632 var_types_set = var_types_set_gl;
10633 num_var_types = num_var_types_gl;
10636 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
10638 _supported_variable_types_map_const_iterator var_iterator =
10639 supported_variable_types_map.find(var_types_set[var_type_index]);
10641 if (var_iterator != supported_variable_types_map.end())
10643 std::string function_definition;
10644 std::string function_use;
10645 std::string verification;
10647 function_definition += "// Subroutine types\n"
10648 "subroutine bool out_routine_type(";
10649 function_definition += var_iterator->second.type;
10650 function_definition += " x[2][2][2][2][2][2], out ";
10651 function_definition += var_iterator->second.type;
10652 function_definition += " y[2][2][2][2][2][2]);\n\n"
10653 "// Subroutine definitions\n"
10654 "subroutine(out_routine_type) bool original_routine(";
10655 function_definition += var_iterator->second.type;
10656 function_definition += " x[2][2][2][2][2][2], out ";
10657 function_definition += var_iterator->second.type;
10658 function_definition += " y[2][2][2][2][2][2])\n{\n";
10659 function_definition += iteration_loop_start;
10660 function_definition +=
10661 " y[a][b][c][d][e][f] = " + var_iterator->second.type + "(123);\n";
10662 function_definition += iteration_loop_end;
10663 function_definition += "\n";
10664 function_definition += iteration_loop_start;
10665 function_definition += " if(x[a][b][c][d][e][f]";
10666 if (var_iterator->second.type == "mat4") // mat4 comparison
10668 function_definition += "[0][0]";
10669 function_definition += " != float";
10671 else if (var_iterator->second.type == "dmat4") // dmat4 comparison
10673 function_definition += "[0][0]";
10674 function_definition += " != double";
10678 function_definition += " != ";
10679 function_definition += var_iterator->second.type;
10681 function_definition += "(((a*32u)+(b*16u)+(c*8u)+(d*4u)+(e*2u)+f))) {return false;}\n";
10682 function_definition += iteration_loop_end;
10683 function_definition += "\n return true;\n";
10684 function_definition += "}\n\n"
10685 "subroutine(out_routine_type) bool new_routine(";
10686 function_definition += var_iterator->second.type;
10687 function_definition += " x[2][2][2][2][2][2], out ";
10688 function_definition += var_iterator->second.type;
10689 function_definition += " y[2][2][2][2][2][2])\n{\n";
10690 function_definition += iteration_loop_start;
10691 function_definition +=
10692 " y[a][b][c][d][e][f] = " + var_iterator->second.type + "(321);\n";
10693 function_definition += iteration_loop_end;
10694 function_definition += "\n";
10695 function_definition += iteration_loop_start;
10696 function_definition += " if(x[a][b][c][d][e][f]";
10697 if (var_iterator->second.type == "mat4") // mat4 comparison
10699 function_definition += "[0][0]";
10700 function_definition += " != float";
10702 else if (var_iterator->second.type == "dmat4") // dmat4 comparison
10704 function_definition += "[0][0]";
10705 function_definition += " != double";
10709 function_definition += " != ";
10710 function_definition += var_iterator->second.type;
10712 function_definition += "(((a*32u)+(b*16u)+(c*8u)+(d*4u)+(e*2u)+f))) {return false;}\n";
10713 function_definition += iteration_loop_end;
10714 function_definition += "\n return true;\n";
10715 function_definition += "}\n\n"
10716 "// Subroutine uniform\n"
10717 "subroutine uniform out_routine_type routine;\n";
10719 function_use += " " + var_iterator->second.type + " z[2][2][2][2][2][2];\n";
10720 function_use += iteration_loop_start;
10721 function_use += " z[a][b][c][d][e][f] = ";
10722 function_use += var_iterator->second.type;
10723 function_use += "(((a*32u)+(b*16u)+(c*8u)+(d*4u)+(e*2u)+f));\n";
10724 function_use += iteration_loop_end;
10726 verification = " float result = 0.0;\n"
10727 " if(routine(z, z) == true)\n"
10736 if (false == test_compute)
10738 this->execute_draw_test(tested_shader_type, function_definition, function_use, verification, false,
10740 this->execute_draw_test(tested_shader_type, function_definition, function_use, verification, true,
10745 this->execute_dispatch_test(tested_shader_type, function_definition, function_use, verification, false,
10747 this->execute_dispatch_test(tested_shader_type, function_definition, function_use, verification, true,
10751 /* Deallocate any resources used. */
10752 this->delete_objects();
10753 } /* if var_type iterator found */
10756 TCU_FAIL("Type not found.");
10758 } /* for (int var_type_index = 0; ...) */
10761 /** Instantiates all tests and adds them as children to the node
10763 * @tparam API Tested API descriptor
10765 * @param context CTS context
10767 template <class API>
10768 void initTests(TestCaseGroup& group, glcts::Context& context)
10771 ArraysOfArrays::initializeMap<API>();
10773 group.addChild(new glcts::ArraysOfArrays::SizedDeclarationsPrimitive<API>(context));
10774 group.addChild(new glcts::ArraysOfArrays::SizedDeclarationsStructTypes1<API>(context));
10775 group.addChild(new glcts::ArraysOfArrays::SizedDeclarationsStructTypes2<API>(context));
10776 group.addChild(new glcts::ArraysOfArrays::SizedDeclarationsStructTypes3<API>(context));
10777 group.addChild(new glcts::ArraysOfArrays::SizedDeclarationsStructTypes4<API>(context));
10778 group.addChild(new glcts::ArraysOfArrays::SizedDeclarationsTypenameStyle1<API>(context));
10779 group.addChild(new glcts::ArraysOfArrays::SizedDeclarationsTypenameStyle2<API>(context));
10780 group.addChild(new glcts::ArraysOfArrays::SizedDeclarationsTypenameStyle3<API>(context));
10781 group.addChild(new glcts::ArraysOfArrays::SizedDeclarationsTypenameStyle4<API>(context));
10782 group.addChild(new glcts::ArraysOfArrays::SizedDeclarationsTypenameStyle5<API>(context));
10783 group.addChild(new glcts::ArraysOfArrays::SizedDeclarationsFunctionParams<API>(context));
10784 group.addChild(new glcts::ArraysOfArrays::sized_declarations_invalid_sizes1<API>(context));
10785 group.addChild(new glcts::ArraysOfArrays::sized_declarations_invalid_sizes2<API>(context));
10786 group.addChild(new glcts::ArraysOfArrays::sized_declarations_invalid_sizes3<API>(context));
10787 group.addChild(new glcts::ArraysOfArrays::sized_declarations_invalid_sizes4<API>(context));
10788 group.addChild(new glcts::ArraysOfArrays::ConstructorsAndUnsizedDeclConstructors1<API>(context));
10789 group.addChild(new glcts::ArraysOfArrays::ConstructorsAndUnsizedDeclConstructors2<API>(context));
10790 group.addChild(new glcts::ArraysOfArrays::ConstructorsAndUnsizedDeclUnsizedConstructors<API>(context));
10791 group.addChild(new glcts::ArraysOfArrays::ConstructorsAndUnsizedDeclConst<API>(context));
10793 group.addChild(new glcts::ArraysOfArrays::ConstructorsAndUnsizedDeclInvalidConstructors1<API>(context));
10794 group.addChild(new glcts::ArraysOfArrays::ConstructorsAndUnsizedDeclInvalidConstructors2<API>(context));
10795 group.addChild(new glcts::ArraysOfArrays::ConstructorsAndUnsizedDeclInvalidConstructors3<API>(context));
10796 group.addChild(new glcts::ArraysOfArrays::ConstructorsAndUnsizedDeclInvalidConstructors4<API>(context));
10797 group.addChild(new glcts::ArraysOfArrays::ConstructorsAndUnsizedDeclConstructorSizing1<API>(context));
10798 group.addChild(new glcts::ArraysOfArrays::ConstructorsAndUnsizedDeclConstructorSizing2<API>(context));
10799 group.addChild(new glcts::ArraysOfArrays::ConstructorsAndUnsizedDeclStructConstructors<API>(context));
10800 group.addChild(new glcts::ArraysOfArrays::ConstructorsAndUnsizedDeclUnsizedArrays1<API>(context));
10801 group.addChild(new glcts::ArraysOfArrays::ConstructorsAndUnsizedDeclUnsizedArrays2<API>(context));
10802 group.addChild(new glcts::ArraysOfArrays::ConstructorsAndUnsizedDeclUnsizedArrays3<API>(context));
10803 group.addChild(new glcts::ArraysOfArrays::ConstructorsAndUnsizedDeclUnsizedArrays4<API>(context));
10804 group.addChild(new glcts::ArraysOfArrays::ExpressionsAssignment1<API>(context));
10805 group.addChild(new glcts::ArraysOfArrays::ExpressionsAssignment2<API>(context));
10806 group.addChild(new glcts::ArraysOfArrays::ExpressionsAssignment3<API>(context));
10807 group.addChild(new glcts::ArraysOfArrays::ExpressionsTypeRestrictions1<API>(context));
10808 group.addChild(new glcts::ArraysOfArrays::ExpressionsTypeRestrictions2<API>(context));
10809 group.addChild(new glcts::ArraysOfArrays::ExpressionsIndexingScalar1<API>(context));
10810 group.addChild(new glcts::ArraysOfArrays::ExpressionsIndexingScalar2<API>(context));
10811 group.addChild(new glcts::ArraysOfArrays::ExpressionsIndexingScalar3<API>(context));
10812 group.addChild(new glcts::ArraysOfArrays::ExpressionsIndexingScalar4<API>(context));
10813 group.addChild(new glcts::ArraysOfArrays::ExpressionsIndexingArray1<API>(context));
10814 group.addChild(new glcts::ArraysOfArrays::ExpressionsIndexingArray2<API>(context));
10815 group.addChild(new glcts::ArraysOfArrays::ExpressionsIndexingArray3<API>(context));
10816 group.addChild(new glcts::ArraysOfArrays::ExpressionsDynamicIndexing1<API>(context));
10817 group.addChild(new glcts::ArraysOfArrays::ExpressionsDynamicIndexing2<API>(context));
10818 group.addChild(new glcts::ArraysOfArrays::ExpressionsEquality1<API>(context));
10819 group.addChild(new glcts::ArraysOfArrays::ExpressionsEquality2<API>(context));
10820 group.addChild(new glcts::ArraysOfArrays::ExpressionsLength1<API>(context));
10821 group.addChild(new glcts::ArraysOfArrays::ExpressionsLength2<API>(context));
10822 group.addChild(new glcts::ArraysOfArrays::ExpressionsLength3<API>(context));
10823 group.addChild(new glcts::ArraysOfArrays::ExpressionsInvalid1<API>(context));
10824 group.addChild(new glcts::ArraysOfArrays::ExpressionsInvalid2<API>(context));
10826 group.addChild(new glcts::ArraysOfArrays::InteractionFunctionCalls1<API>(context));
10827 group.addChild(new glcts::ArraysOfArrays::InteractionFunctionCalls2<API>(context));
10828 group.addChild(new glcts::ArraysOfArrays::InteractionArgumentAliasing1<API>(context));
10829 group.addChild(new glcts::ArraysOfArrays::InteractionArgumentAliasing2<API>(context));
10830 group.addChild(new glcts::ArraysOfArrays::InteractionArgumentAliasing3<API>(context));
10831 group.addChild(new glcts::ArraysOfArrays::InteractionArgumentAliasing4<API>(context));
10832 group.addChild(new glcts::ArraysOfArrays::InteractionArgumentAliasing5<API>(context));
10833 group.addChild(new glcts::ArraysOfArrays::InteractionArgumentAliasing6<API>(context));
10835 group.addChild(new glcts::ArraysOfArrays::InteractionUniforms1<API>(context));
10836 group.addChild(new glcts::ArraysOfArrays::InteractionUniforms2<API>(context));
10837 group.addChild(new glcts::ArraysOfArrays::InteractionUniformBuffers1<API>(context));
10838 group.addChild(new glcts::ArraysOfArrays::InteractionUniformBuffers2<API>(context));
10839 group.addChild(new glcts::ArraysOfArrays::InteractionUniformBuffers3<API>(context));
10840 group.addChild(new glcts::ArraysOfArrays::InteractionInterfaceArrays1<API>(context));
10841 group.addChild(new glcts::ArraysOfArrays::InteractionInterfaceArrays2<API>(context));
10842 group.addChild(new glcts::ArraysOfArrays::InteractionInterfaceArrays3<API>(context));
10843 group.addChild(new glcts::ArraysOfArrays::InteractionInterfaceArrays4<API>(context));
10845 if (API::USE_STORAGE_BLOCK)
10847 group.addChild(new glcts::ArraysOfArrays::InteractionStorageBuffers1<API>(context));
10848 group.addChild(new glcts::ArraysOfArrays::InteractionStorageBuffers2<API>(context));
10849 group.addChild(new glcts::ArraysOfArrays::InteractionStorageBuffers3<API>(context));
10852 if (API::USE_ATOMIC)
10854 group.addChild(new glcts::ArraysOfArrays::AtomicDeclarationTest<API>(context));
10855 group.addChild(new glcts::ArraysOfArrays::AtomicUsageTest<API>(context));
10858 if (API::USE_SUBROUTINE)
10860 group.addChild(new glcts::ArraysOfArrays::SubroutineFunctionCalls1<API>(context));
10861 group.addChild(new glcts::ArraysOfArrays::SubroutineFunctionCalls2<API>(context));
10862 group.addChild(new glcts::ArraysOfArrays::SubroutineArgumentAliasing1<API>(context));
10863 group.addChild(new glcts::ArraysOfArrays::SubroutineArgumentAliasing2<API>(context));
10864 group.addChild(new glcts::ArraysOfArrays::SubroutineArgumentAliasing3<API>(context));
10865 group.addChild(new glcts::ArraysOfArrays::SubroutineArgumentAliasing4<API>(context));
10868 } /* namespace ArraysOfArrays */
10872 * @param context CTS context
10874 ArrayOfArraysTestGroup::ArrayOfArraysTestGroup(Context& context)
10875 : TestCaseGroup(context, "arrays_of_arrays", "Groups all tests that verify 'arrays of arrays' functionality.")
10877 /* Left blank on purpose */
10880 /* Instantiates all tests and adds them as children to the node */
10881 void ArrayOfArraysTestGroup::init(void)
10883 ArraysOfArrays::initTests<ArraysOfArrays::Interface::ES>(*this, m_context);
10888 * @param context CTS context
10890 ArrayOfArraysTestGroupGL::ArrayOfArraysTestGroupGL(Context& context)
10891 : TestCaseGroup(context, "arrays_of_arrays_gl", "Groups all tests that verify 'arrays of arrays' functionality.")
10893 /* Left blank on purpose */
10896 /* Instantiates all tests and adds them as children to the node */
10897 void ArrayOfArraysTestGroupGL::init(void)
10899 ArraysOfArrays::initTests<ArraysOfArrays::Interface::GL>(*this, m_context);
10901 } /* namespace glcts */