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"
4473 const std::string iteration_loop_start = " for (uint a = 0u; a < 2u; a++)\n"
4475 " for (uint b = 0u; b < 2u; b++)\n"
4477 " for (uint c = 0u; c < 2u; c++)\n"
4479 " for (uint d = 0u; d < 2u; d++)\n"
4481 const glcts::test_var_type* var_types_set = var_types_set_es;
4482 size_t num_var_types = num_var_types_es;
4483 const bool test_compute = (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type);
4485 if (API::USE_DOUBLE)
4487 var_types_set = var_types_set_gl;
4488 num_var_types = num_var_types_gl;
4491 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
4493 _supported_variable_types_map_const_iterator var_iterator =
4494 supported_variable_types_map.find(var_types_set[var_type_index]);
4496 if (var_iterator != supported_variable_types_map.end())
4498 std::string iterator_declaration = " " + var_iterator->second.iterator_type +
4499 " iterator = " + var_iterator->second.iterator_initialization + ";\n";
4501 std::string function_definition;
4502 std::string function_use;
4503 std::string verification;
4505 function_definition = "void my_function(out ";
4506 function_definition += var_iterator->second.type;
4507 function_definition += " output_array[2][2][2][2]) {\n";
4508 function_definition += iterator_declaration;
4509 function_definition += iteration_loop_start;
4510 function_definition += " output_array[a][b][c][d] = " +
4511 var_iterator->second.variable_type_initializer1 + ";\n";
4512 function_definition +=
4513 " iterator += " + var_iterator->second.iterator_type + "(1);\n";
4514 function_definition += iteration_loop_end;
4515 function_definition += "}";
4517 function_use = " " + var_iterator->second.type + " my_array[2][2][2][2];\n";
4518 function_use += " my_function(my_array);";
4520 verification = iterator_declaration;
4521 verification += " float result = 1.0;\n";
4522 verification += iteration_loop_start;
4523 verification += " if (my_array[a][b][c][d] " +
4524 var_iterator->second.specific_element +
4530 var_iterator->second.iterator_type + "(1);\n";
4531 verification += iteration_loop_end;
4533 if (false == test_compute)
4535 execute_draw_test(tested_shader_type, function_definition, function_use, verification);
4539 execute_dispatch_test(tested_shader_type, function_definition, function_use, verification);
4542 /* Deallocate any resources used. */
4543 this->delete_objects();
4544 } /* if var_type iterator found */
4547 TCU_FAIL("Type not found.");
4549 } /* for (int var_type_index = 0; ...) */
4552 /** Executes test for compute program
4554 * @tparam API Tested API descriptor
4556 * @param tested_shader_type The type of shader that is being tested
4557 * @param function_definition Definition used to prepare shader
4558 * @param function_use Snippet that makes use of defined function
4559 * @param verification Snippet that verifies results
4561 template <class API>
4562 void InteractionFunctionCalls1<API>::execute_dispatch_test(
4563 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& function_definition,
4564 const std::string& function_use, const std::string& verification)
4566 const std::string& compute_shader_source =
4567 prepare_compute_shader(tested_shader_type, function_definition, function_use, verification);
4568 const glw::Functions& gl = this->context_id.getRenderContext().getFunctions();
4570 this->execute_positive_test(empty_string, empty_string, empty_string, empty_string, empty_string,
4571 compute_shader_source, false, false);
4573 /* We are now ready to verify whether the returned size is correct. */
4574 unsigned char buffer[4] = { 0 };
4575 glw::GLuint framebuffer_object_id = 0;
4576 glw::GLint location = -1;
4577 glw::GLuint texture_object_id = 0;
4578 glw::GLuint vao_id = 0;
4580 gl.useProgram(this->program_object_id);
4581 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram() failed.");
4583 gl.genTextures(1, &texture_object_id);
4584 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures() failed.");
4586 gl.bindTexture(GL_TEXTURE_2D, texture_object_id);
4587 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture() failed.");
4589 gl.texStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 1, 1);
4590 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage2D() failed.");
4592 gl.bindImageTexture(0 /* image unit */, texture_object_id, 0 /* level */, GL_FALSE /* layered */, 0 /* layer */,
4593 GL_WRITE_ONLY, GL_RGBA8);
4594 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindImageTexture() failed.");
4596 location = gl.getUniformLocation(this->program_object_id, "uni_image");
4597 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation() failed.");
4601 TCU_FAIL("Uniform is inactive");
4604 gl.uniform1i(location, 0 /* image unit */);
4605 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i() failed.");
4607 gl.genVertexArrays(1, &vao_id);
4608 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenVertexArrays() failed.");
4610 gl.bindVertexArray(vao_id);
4611 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray() failed.");
4613 gl.dispatchCompute(1, 1, 1);
4614 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
4616 gl.genFramebuffers(1, &framebuffer_object_id);
4617 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers() failed.");
4619 gl.bindFramebuffer(GL_FRAMEBUFFER, framebuffer_object_id);
4620 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer() failed.");
4622 gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_object_id, 0);
4623 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferTexture2D() failed.");
4625 gl.viewport(0, 0, 1, 1);
4626 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport() failed.");
4628 gl.readBuffer(GL_COLOR_ATTACHMENT0);
4629 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadBuffer() failed.");
4631 gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
4632 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels() failed.");
4634 if (buffer[0] != 255)
4636 TCU_FAIL("Invalid array size was returned.");
4639 /* Delete generated objects. */
4640 gl.deleteTextures(1, &texture_object_id);
4641 gl.deleteFramebuffers(1, &framebuffer_object_id);
4642 gl.deleteVertexArrays(1, &vao_id);
4643 GLU_EXPECT_NO_ERROR(gl.getError(), "An error ocurred while deleting generated objects.");
4646 /** Executes test for draw program
4648 * @tparam API Tested API descriptor
4650 * @param tested_shader_type The type of shader that is being tested
4651 * @param function_definition Definition used to prepare shader
4652 * @param function_use Snippet that makes use of defined function
4653 * @param verification Snippet that verifies results
4655 template <class API>
4656 void InteractionFunctionCalls1<API>::execute_draw_test(typename TestCaseBase<API>::TestShaderType tested_shader_type,
4657 const std::string& function_definition,
4658 const std::string& function_use, const std::string& verification)
4660 const glw::Functions& gl = this->context_id.getRenderContext().getFunctions();
4662 if (API::USE_ALL_SHADER_STAGES)
4664 const std::string& compute_shader_source = empty_string;
4665 const std::string& fragment_shader_source =
4666 this->prepare_fragment_shader(tested_shader_type, function_definition, function_use, verification);
4667 const std::string& geometry_shader_source =
4668 this->prepare_geometry_shader(tested_shader_type, function_definition, function_use, verification);
4669 const std::string& tess_ctrl_shader_source =
4670 this->prepare_tess_ctrl_shader(tested_shader_type, function_definition, function_use, verification);
4671 const std::string& tess_eval_shader_source =
4672 this->prepare_tess_eval_shader(tested_shader_type, function_definition, function_use, verification);
4673 const std::string& vertex_shader_source =
4674 this->prepare_vertex_shader(tested_shader_type, function_definition, function_use, verification);
4676 switch (tested_shader_type)
4678 case TestCaseBase<API>::VERTEX_SHADER_TYPE: /* Fall through */
4679 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
4680 this->execute_positive_test(vertex_shader_source, fragment_shader_source, false, false);
4683 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
4684 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
4685 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE: /* Fall through */
4686 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
4687 this->execute_positive_test(vertex_shader_source, tess_ctrl_shader_source, tess_eval_shader_source,
4688 geometry_shader_source, fragment_shader_source, compute_shader_source, false,
4693 TCU_FAIL("Invalid enum");
4699 const std::string& fragment_shader_source =
4700 this->prepare_fragment_shader(tested_shader_type, function_definition, function_use, verification);
4701 const std::string& vertex_shader_source =
4702 this->prepare_vertex_shader(tested_shader_type, function_definition, function_use, verification);
4704 this->execute_positive_test(vertex_shader_source, fragment_shader_source, false, false);
4707 /* We are now ready to verify whether the returned size is correct. */
4708 unsigned char buffer[4] = { 0 };
4709 glw::GLuint framebuffer_object_id = 0;
4710 glw::GLuint texture_object_id = 0;
4711 glw::GLuint vao_id = 0;
4713 gl.useProgram(this->program_object_id);
4714 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram() failed.");
4716 gl.genTextures(1, &texture_object_id);
4717 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures() failed.");
4719 gl.bindTexture(GL_TEXTURE_2D, texture_object_id);
4720 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture() failed.");
4722 gl.texStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 1, 1);
4723 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage2D() failed.");
4725 gl.genFramebuffers(1, &framebuffer_object_id);
4726 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers() failed.");
4728 gl.bindFramebuffer(GL_FRAMEBUFFER, framebuffer_object_id);
4729 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer() failed.");
4731 gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_object_id, 0);
4732 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferTexture2D() failed.");
4734 gl.viewport(0, 0, 1, 1);
4735 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport() failed.");
4737 gl.genVertexArrays(1, &vao_id);
4738 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenVertexArrays() failed.");
4740 gl.bindVertexArray(vao_id);
4741 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray() failed.");
4743 switch (tested_shader_type)
4745 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE: /* Fall through */
4746 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
4747 gl.drawArrays(GL_TRIANGLE_FAN, 0, 4);
4748 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
4751 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE: /* Fall through */
4752 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
4753 /* Tesselation patch set up */
4754 gl.patchParameteri(GL_PATCH_VERTICES, 1);
4755 GLU_EXPECT_NO_ERROR(gl.getError(), "PatchParameteri");
4757 gl.drawArrays(GL_PATCHES, 0, 1);
4758 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
4761 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
4762 gl.drawArrays(GL_POINTS, 0, 1);
4763 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
4767 TCU_FAIL("Invalid enum");
4771 gl.readBuffer(GL_COLOR_ATTACHMENT0);
4772 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadBuffer() failed.");
4774 gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
4775 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels() failed.");
4777 if (buffer[0] != 255)
4779 TCU_FAIL("Invalid array size was returned.");
4782 /* Delete generated objects. */
4783 gl.bindTexture(GL_TEXTURE_2D, 0);
4784 gl.bindFramebuffer(GL_FRAMEBUFFER, 0);
4785 gl.bindVertexArray(0);
4786 gl.deleteTextures(1, &texture_object_id);
4787 gl.deleteFramebuffers(1, &framebuffer_object_id);
4788 gl.deleteVertexArrays(1, &vao_id);
4789 GLU_EXPECT_NO_ERROR(gl.getError(), "An error ocurred while deleting generated objects.");
4794 * @tparam API Tested API descriptor
4796 * @param tested_shader_type The type of shader that is being tested
4797 * @param function_definition Definition used to prepare shader
4798 * @param function_use Snippet that makes use of defined function
4799 * @param verification Snippet that verifies results
4801 template <class API>
4802 std::string InteractionFunctionCalls1<API>::prepare_compute_shader(
4803 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& function_definition,
4804 const std::string& function_use, const std::string& verification)
4806 std::string compute_shader_source;
4808 if (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type)
4810 compute_shader_source = "writeonly uniform image2D uni_image;\n"
4813 /* User-defined function definition. */
4814 compute_shader_source += function_definition;
4815 compute_shader_source += "\n\n";
4817 /* Main function definition. */
4818 compute_shader_source += shader_start;
4819 compute_shader_source += function_use;
4820 compute_shader_source += "\n\n";
4821 compute_shader_source += verification;
4822 compute_shader_source += "\n\n";
4823 compute_shader_source += "\n"
4824 " imageStore(uni_image, ivec2(gl_GlobalInvocationID.xy), vec4(result, 0, 0, 0));\n"
4829 return compute_shader_source;
4834 * @tparam API Tested API descriptor
4836 * @param tested_shader_type The type of shader that is being tested
4837 * @param function_definition Definition used to prepare shader
4838 * @param function_use Snippet that makes use of defined function
4839 * @param verification Snippet that verifies results
4841 template <class API>
4842 std::string InteractionFunctionCalls1<API>::prepare_fragment_shader(
4843 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& function_definition,
4844 const std::string& function_use, const std::string& verification)
4846 std::string fragment_shader_source;
4848 switch (tested_shader_type)
4850 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
4853 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
4854 fragment_shader_source = "out vec4 colour;\n\n";
4856 /* User-defined function definition. */
4857 fragment_shader_source += function_definition;
4858 fragment_shader_source += "\n\n";
4860 /* Main function definition. */
4861 fragment_shader_source += shader_start;
4862 fragment_shader_source += function_use;
4863 fragment_shader_source += "\n\n";
4864 fragment_shader_source += verification;
4865 fragment_shader_source += "\n\n";
4866 fragment_shader_source += " colour = vec4(result);\n";
4867 fragment_shader_source += shader_end;
4870 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
4871 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
4872 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
4873 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
4874 fragment_shader_source = "in float fs_result;\n\n"
4875 "out vec4 colour;\n\n"
4878 " colour = vec4(fs_result);\n"
4884 TCU_FAIL("Unrecognized shader object type.");
4888 return fragment_shader_source;
4893 * @tparam API Tested API descriptor
4895 * @param tested_shader_type The type of shader that is being tested
4896 * @param function_definition Definition used to prepare shader
4897 * @param function_use Snippet that makes use of defined function
4898 * @param verification Snippet that verifies results
4900 template <class API>
4901 std::string InteractionFunctionCalls1<API>::prepare_geometry_shader(
4902 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& function_definition,
4903 const std::string& function_use, const std::string& verification)
4905 std::string geometry_shader_source;
4907 switch (tested_shader_type)
4909 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
4910 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
4911 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
4914 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
4915 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
4916 geometry_shader_source = "layout(points) in;\n"
4917 "layout(triangle_strip, max_vertices = 4) out;\n"
4919 "in float tes_result[];\n"
4920 "out float fs_result;\n"
4924 " gl_Position = vec4(-1, -1, 0, 1);\n"
4925 " fs_result = tes_result[0];\n"
4927 " gl_Position = vec4(-1, 1, 0, 1);\n"
4928 " fs_result = tes_result[0];\n"
4930 " gl_Position = vec4(1, -1, 0, 1);\n"
4931 " fs_result = tes_result[0];\n"
4933 " gl_Position = vec4(1, 1, 0, 1);\n"
4934 " fs_result = tes_result[0];\n"
4939 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
4940 geometry_shader_source = "layout(points) in;\n"
4941 "layout(triangle_strip, max_vertices = 4) out;\n"
4943 "out float fs_result;\n"
4946 /* User-defined function definition. */
4947 geometry_shader_source += function_definition;
4948 geometry_shader_source += "\n\n";
4950 /* Main function definition. */
4951 geometry_shader_source += shader_start;
4952 geometry_shader_source += function_use;
4953 geometry_shader_source += "\n\n";
4954 geometry_shader_source += verification;
4955 geometry_shader_source += "\n\n";
4956 geometry_shader_source += "\n gl_Position = vec4(-1, -1, 0, 1);\n"
4957 " fs_result = result;\n"
4959 " gl_Position = vec4(-1, 1, 0, 1);\n"
4960 " fs_result = result;\n"
4962 " gl_Position = vec4(1, -1, 0, 1);\n"
4963 " fs_result = result;\n"
4965 " gl_Position = vec4(1, 1, 0, 1);\n"
4966 " fs_result = result;\n"
4972 TCU_FAIL("Unrecognized shader object type.");
4976 return geometry_shader_source;
4981 * @tparam API Tested API descriptor
4983 * @param tested_shader_type The type of shader that is being tested
4984 * @param function_definition Definition used to prepare shader
4985 * @param function_use Snippet that makes use of defined function
4986 * @param verification Snippet that verifies results
4988 template <class API>
4989 std::string InteractionFunctionCalls1<API>::prepare_tess_ctrl_shader(
4990 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& function_definition,
4991 const std::string& function_use, const std::string& verification)
4993 std::string tess_ctrl_shader_source;
4995 switch (tested_shader_type)
4997 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
4998 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
4999 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
5000 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
5003 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
5004 tess_ctrl_shader_source = "layout(vertices = 1) out;\n"
5006 "out float tcs_result[];\n"
5009 /* User-defined function definition. */
5010 tess_ctrl_shader_source += function_definition;
5011 tess_ctrl_shader_source += "\n\n";
5013 /* Main function definition. */
5014 tess_ctrl_shader_source += shader_start;
5015 tess_ctrl_shader_source += function_use;
5016 tess_ctrl_shader_source += "\n\n";
5017 tess_ctrl_shader_source += verification;
5018 tess_ctrl_shader_source += "\n\n";
5019 tess_ctrl_shader_source += " tcs_result[gl_InvocationID] = result;\n"
5021 " gl_TessLevelOuter[0] = 1.0;\n"
5022 " gl_TessLevelOuter[1] = 1.0;\n"
5023 " gl_TessLevelOuter[2] = 1.0;\n"
5024 " gl_TessLevelOuter[3] = 1.0;\n"
5025 " gl_TessLevelInner[0] = 1.0;\n"
5026 " gl_TessLevelInner[1] = 1.0;\n"
5030 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
5031 tess_ctrl_shader_source = default_tc_shader_source;
5035 TCU_FAIL("Unrecognized shader object type.");
5039 return tess_ctrl_shader_source;
5044 * @tparam API Tested API descriptor
5046 * @param tested_shader_type The type of shader that is being tested
5047 * @param function_definition Definition used to prepare shader
5048 * @param function_use Snippet that makes use of defined function
5049 * @param verification Snippet that verifies results
5051 template <class API>
5052 std::string InteractionFunctionCalls1<API>::prepare_tess_eval_shader(
5053 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& function_definition,
5054 const std::string& function_use, const std::string& verification)
5056 std::string tess_eval_shader_source;
5058 switch (tested_shader_type)
5060 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
5061 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
5062 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
5063 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
5066 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
5067 tess_eval_shader_source = "layout(isolines, point_mode) in;\n"
5069 "in float tcs_result[];\n"
5070 "out float tes_result;\n"
5074 " tes_result = tcs_result[0];\n"
5078 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
5079 tess_eval_shader_source = "layout(isolines, point_mode) in;\n"
5081 "out float tes_result;\n"
5084 /* User-defined function definition. */
5085 tess_eval_shader_source += function_definition;
5086 tess_eval_shader_source += "\n\n";
5088 /* Main function definition. */
5089 tess_eval_shader_source += shader_start;
5090 tess_eval_shader_source += function_use;
5091 tess_eval_shader_source += "\n\n";
5092 tess_eval_shader_source += verification;
5093 tess_eval_shader_source += "\n\n";
5094 tess_eval_shader_source += " tes_result = result;\n"
5099 TCU_FAIL("Unrecognized shader object type.");
5103 return tess_eval_shader_source;
5108 * @tparam API Tested API descriptor
5110 * @param tested_shader_type The type of shader that is being tested
5111 * @param function_definition Definition used to prepare shader
5112 * @param function_use Snippet that makes use of defined function
5113 * @param verification Snippet that verifies results
5115 template <class API>
5116 std::string InteractionFunctionCalls1<API>::prepare_vertex_shader(
5117 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& function_definition,
5118 const std::string& function_use, const std::string& verification)
5120 std::string vertex_shader_source;
5122 switch (tested_shader_type)
5124 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
5127 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
5128 vertex_shader_source = "/** GL_TRIANGLE_FAN-type quad vertex data. */\n"
5129 "const vec4 vertex_positions[4] = vec4[4](vec4( 1.0, -1.0, 0.0, 1.0),\n"
5130 " vec4(-1.0, -1.0, 0.0, 1.0),\n"
5131 " vec4(-1.0, 1.0, 0.0, 1.0),\n"
5132 " vec4( 1.0, 1.0, 0.0, 1.0) );\n"
5136 " gl_Position = vertex_positions[gl_VertexID];"
5140 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
5141 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
5142 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
5143 vertex_shader_source = default_vertex_shader_source;
5146 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
5147 /* Vertex shader source. */
5148 vertex_shader_source = "out float fs_result;\n\n";
5149 vertex_shader_source += "/** GL_TRIANGLE_FAN-type quad vertex data. */\n"
5150 "const vec4 vertex_positions[4] = vec4[4](vec4( 1.0, -1.0, 0.0, 1.0),\n"
5151 " vec4(-1.0, -1.0, 0.0, 1.0),\n"
5152 " vec4(-1.0, 1.0, 0.0, 1.0),\n"
5153 " vec4( 1.0, 1.0, 0.0, 1.0) );\n\n";
5155 /* User-defined function definition. */
5156 vertex_shader_source += function_definition;
5157 vertex_shader_source += "\n\n";
5159 /* Main function definition. */
5160 vertex_shader_source += shader_start;
5161 vertex_shader_source += function_use;
5162 vertex_shader_source += "\n\n";
5163 vertex_shader_source += verification;
5164 vertex_shader_source += "\n\n";
5165 vertex_shader_source += " fs_result = result;\n"
5166 " gl_Position = vertex_positions[gl_VertexID];\n";
5167 vertex_shader_source += shader_end;
5171 TCU_FAIL("Unrecognized shader object type.");
5175 return vertex_shader_source;
5178 /* Generates the shader source code for the InteractionFunctionCalls2
5179 * array tests, and attempts to compile each test shader, for both
5180 * vertex and fragment shaders.
5182 * @tparam API Tested API descriptor
5184 * @param tested_shader_type The type of shader that is being tested
5185 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
5187 template <class API>
5188 void InteractionFunctionCalls2<API>::test_shader_compilation(
5189 typename TestCaseBase<API>::TestShaderType tested_shader_type)
5191 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_IVEC2,
5192 VAR_TYPE_IVEC3, VAR_TYPE_IVEC4, VAR_TYPE_VEC2,
5193 VAR_TYPE_VEC3, VAR_TYPE_VEC4, VAR_TYPE_MAT2,
5194 VAR_TYPE_MAT3, VAR_TYPE_MAT4 };
5195 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
5197 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_IVEC2,
5198 VAR_TYPE_IVEC3, VAR_TYPE_IVEC4, VAR_TYPE_VEC2,
5199 VAR_TYPE_VEC3, VAR_TYPE_VEC4, VAR_TYPE_MAT2,
5200 VAR_TYPE_MAT3, VAR_TYPE_MAT4, VAR_TYPE_DOUBLE,
5201 VAR_TYPE_DMAT2, VAR_TYPE_DMAT3, VAR_TYPE_DMAT4 };
5202 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
5204 const std::string iteration_loop_end = " }\n"
5208 const std::string iteration_loop_start = " for (uint a = 0u; a < 2u; a++)\n"
5210 " for (uint b = 0u; b < 2u; b++)\n"
5212 " for (uint c = 0u; c < 2u; c++)\n"
5214 " for (uint d = 0u; d < 2u; d++)\n"
5216 const std::string multiplier_array = "const int[] multiplier_array = int[]( 1, 2, 3, 4, 5, 6, 7, 8,\n"
5217 " 11, 12, 13, 14, 15, 16, 17, 18,\n"
5218 " 21, 22, 23, 24, 25, 26, 27, 28,\n"
5219 " 31, 32, 33, 34, 35, 36, 37, 38,\n"
5220 " 41, 42, 43, 44, 45, 46, 47, 48,\n"
5221 " 51, 52, 53, 54, 55, 56, 57, 58,\n"
5222 " 61, 62, 63, 64, 65, 66, 67, 68,\n"
5223 " 71, 72, 73, 74, 75, 76, 77, 78,\n"
5224 " 81, 82, 83, 84, 85, 86, 87, 88);\n";
5225 const glcts::test_var_type* var_types_set = var_types_set_es;
5226 size_t num_var_types = num_var_types_es;
5227 const bool test_compute = (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type);
5229 if (API::USE_DOUBLE)
5231 var_types_set = var_types_set_gl;
5232 num_var_types = num_var_types_gl;
5235 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
5237 _supported_variable_types_map_const_iterator var_iterator =
5238 supported_variable_types_map.find(var_types_set[var_type_index]);
5240 if (var_iterator != supported_variable_types_map.end())
5242 std::string function_definition;
5243 std::string function_use;
5244 std::string verification;
5246 function_definition += multiplier_array;
5247 function_definition += "void my_function(inout ";
5248 function_definition += var_iterator->second.type;
5249 function_definition += " inout_array[2][2][2][2]) {\n"
5251 function_definition += iteration_loop_start;
5252 function_definition += " inout_array[a][b][c][d] *= " +
5253 var_iterator->second.iterator_type + "(multiplier_array[i % 64u]);\n";
5254 function_definition += " i+= 1u;\n";
5255 function_definition += iteration_loop_end;
5256 function_definition += "}";
5258 function_use += " float result = 1.0;\n";
5259 function_use += " uint iterator = 0u;\n";
5260 function_use += " " + var_iterator->second.type + " my_array[2][2][2][2];\n";
5261 function_use += iteration_loop_start;
5262 function_use += " my_array[a][b][c][d] = " +
5263 var_iterator->second.variable_type_initializer2 + ";\n";
5264 function_use += iteration_loop_end;
5265 function_use += " my_function(my_array);";
5267 verification += iteration_loop_start;
5268 verification += " if (my_array[a][b][c][d] " +
5269 var_iterator->second.specific_element + "!= " + var_iterator->second.iterator_type +
5270 "(multiplier_array[iterator % 64u]))\n"
5274 " iterator += 1u;\n";
5275 verification += iteration_loop_end;
5277 if (false == test_compute)
5279 this->execute_draw_test(tested_shader_type, function_definition, function_use, verification);
5283 this->execute_dispatch_test(tested_shader_type, function_definition, function_use, verification);
5286 /* Deallocate any resources used. */
5287 this->delete_objects();
5288 } /* if var_type iterator found */
5291 TCU_FAIL("Type not found.");
5293 } /* for (int var_type_index = 0; ...) */
5296 /* Generates the shader source code for the InteractionArgumentAliasing1
5297 * array tests, and attempts to compile each test shader, for both
5298 * vertex and fragment shaders.
5300 * @tparam API Tested API descriptor
5302 * @param tested_shader_type The type of shader that is being tested
5303 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
5305 template <class API>
5306 void InteractionArgumentAliasing1<API>::test_shader_compilation(
5307 typename TestCaseBase<API>::TestShaderType tested_shader_type)
5309 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_MAT4 };
5310 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
5312 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_MAT4,
5313 VAR_TYPE_DOUBLE, VAR_TYPE_DMAT4 };
5314 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
5316 const std::string iteration_loop_end = " }\n"
5320 const std::string iteration_loop_start = " for (uint a = 0u; a < 2u; a++)\n"
5322 " for (uint b = 0u; b < 2u; b++)\n"
5324 " for (uint c = 0u; c < 2u; c++)\n"
5326 " for (uint d = 0u; d < 2u; d++)\n"
5328 const glcts::test_var_type* var_types_set = var_types_set_es;
5329 size_t num_var_types = num_var_types_es;
5330 const bool test_compute = (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type);
5332 if (API::USE_DOUBLE)
5334 var_types_set = var_types_set_gl;
5335 num_var_types = num_var_types_gl;
5338 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
5340 _supported_variable_types_map_const_iterator var_iterator =
5341 supported_variable_types_map.find(var_types_set[var_type_index]);
5343 if (var_iterator != supported_variable_types_map.end())
5345 std::string array_declaration = var_iterator->second.type + " z[2][2][2][2];\n\n";
5347 std::string function_definition;
5348 std::string function_use;
5349 std::string verification;
5351 function_definition += "bool gfunc(" + var_iterator->second.type + " x[2][2][2][2], ";
5352 function_definition += var_iterator->second.type + " y[2][2][2][2])\n";
5353 function_definition += "{\n";
5354 function_definition += " " + iteration_loop_start;
5355 function_definition +=
5356 " x[a][b][c][d] = " + var_iterator->second.type + "(123);\n";
5357 function_definition += " " + iteration_loop_end;
5358 function_definition += "\n";
5359 function_definition += " " + iteration_loop_start;
5360 function_definition += " if(y[a][b][c][d]";
5361 if (var_iterator->second.type == "mat4") // mat4 comparison
5363 function_definition += "[0][0]";
5364 function_definition += " != float";
5366 else if (var_iterator->second.type == "dmat4") // dmat4 comparison
5368 function_definition += "[0][0]";
5369 function_definition += " != double";
5373 function_definition += " != ";
5374 function_definition += var_iterator->second.type;
5376 function_definition += "(((a*8u)+(b*4u)+(c*2u)+d))) {return false;}\n";
5377 function_definition += " " + iteration_loop_end;
5378 function_definition += " return true;\n";
5379 function_definition += "}";
5381 function_use += " " + array_declaration;
5382 function_use += " " + iteration_loop_start;
5383 function_use += " z[a][b][c][d] = ";
5384 function_use += var_iterator->second.type;
5385 function_use += "(((a*8u)+(b*4u)+(c*2u)+d));\n";
5386 function_use += " " + iteration_loop_end;
5388 verification += " float result = 0.0;\n";
5389 verification += " if(gfunc(z, z) == true)\n";
5390 verification += " {\n";
5391 verification += " result = 1.0;\n\n";
5392 verification += " }\n";
5393 verification += " else\n";
5394 verification += " {\n";
5395 verification += " result = 0.0;\n\n";
5396 verification += " }\n";
5398 if (false == test_compute)
5400 this->execute_draw_test(tested_shader_type, function_definition, function_use, verification);
5404 this->execute_dispatch_test(tested_shader_type, function_definition, function_use, verification);
5407 /* Deallocate any resources used. */
5408 this->delete_objects();
5409 } /* if var_type iterator found */
5412 TCU_FAIL("Type not found.");
5417 /* Generates the shader source code for the InteractionArgumentAliasing2
5418 * array tests, and attempts to compile each test shader, for both
5419 * vertex and fragment shaders.
5421 * @tparam API Tested API descriptor
5423 * @param tested_shader_type The type of shader that is being tested
5424 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
5426 template <class API>
5427 void InteractionArgumentAliasing2<API>::test_shader_compilation(
5428 typename TestCaseBase<API>::TestShaderType tested_shader_type)
5430 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_MAT4 };
5431 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
5433 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_MAT4,
5434 VAR_TYPE_DOUBLE, VAR_TYPE_DMAT4 };
5435 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
5437 const std::string iteration_loop_end = " }\n"
5441 const std::string iteration_loop_start = " for (uint a = 0u; a < 2u; a++)\n"
5443 " for (uint b = 0u; b < 2u; b++)\n"
5445 " for (uint c = 0u; c < 2u; c++)\n"
5447 " for (uint d = 0u; d < 2u; d++)\n"
5449 const glcts::test_var_type* var_types_set = var_types_set_es;
5450 size_t num_var_types = num_var_types_es;
5451 const bool test_compute = (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type);
5453 if (API::USE_DOUBLE)
5455 var_types_set = var_types_set_gl;
5456 num_var_types = num_var_types_gl;
5459 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
5461 _supported_variable_types_map_const_iterator var_iterator =
5462 supported_variable_types_map.find(var_types_set[var_type_index]);
5464 if (var_iterator != supported_variable_types_map.end())
5466 std::string array_declaration = var_iterator->second.type + " z[2][2][2][2];\n\n";
5468 std::string function_definition;
5469 std::string function_use;
5470 std::string verification;
5472 function_definition += "bool gfunc(" + var_iterator->second.type + " x[2][2][2][2], ";
5473 function_definition += var_iterator->second.type + " y[2][2][2][2])\n";
5474 function_definition += "{\n";
5475 function_definition += " " + iteration_loop_start;
5476 function_definition +=
5477 " y[a][b][c][d] = " + var_iterator->second.type +
5479 function_definition += " " + iteration_loop_end;
5480 function_definition += "\n";
5481 function_definition += " " + iteration_loop_start;
5482 function_definition += " if(x[a][b][c][d]";
5483 if (var_iterator->second.type == "mat4") // mat4 comparison
5485 function_definition += "[0][0]";
5486 function_definition += " != float";
5488 else if (var_iterator->second.type == "dmat4") // dmat4 comparison
5490 function_definition += "[0][0]";
5491 function_definition += " != double";
5495 function_definition += " != ";
5496 function_definition += var_iterator->second.type;
5498 function_definition += "(((a*8u)+(b*4u)+(c*2u)+d))) {return false;}\n";
5499 function_definition += " " + iteration_loop_end;
5500 function_definition += " return true;\n";
5501 function_definition += "}";
5503 function_use += " " + array_declaration;
5504 function_use += " " + iteration_loop_start;
5505 function_use += " z[a][b][c][d] = ";
5506 function_use += var_iterator->second.type;
5507 function_use += "(((a*8u)+(b*4u)+(c*2u)+d));\n";
5508 function_use += " " + iteration_loop_end;
5510 verification += " float result = 0.0;\n";
5511 verification += " if(gfunc(z, z) == true)\n";
5512 verification += " {\n";
5513 verification += " result = 1.0;\n\n";
5514 verification += " }\n";
5515 verification += " else\n";
5516 verification += " {\n";
5517 verification += " result = 0.0;\n\n";
5518 verification += " }\n";
5520 if (false == test_compute)
5522 this->execute_draw_test(tested_shader_type, function_definition, function_use, verification);
5526 this->execute_dispatch_test(tested_shader_type, function_definition, function_use, verification);
5529 /* Deallocate any resources used. */
5530 this->delete_objects();
5531 } /* if var_type iterator found */
5534 TCU_FAIL("Type not found.");
5539 /* Generates the shader source code for the InteractionArgumentAliasing3
5540 * array tests, and attempts to compile each test shader, for both
5541 * vertex and fragment shaders.
5543 * @tparam API Tested API descriptor
5545 * @param tested_shader_type The type of shader that is being tested
5546 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
5548 template <class API>
5549 void InteractionArgumentAliasing3<API>::test_shader_compilation(
5550 typename TestCaseBase<API>::TestShaderType tested_shader_type)
5552 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_MAT4 };
5553 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
5555 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_MAT4,
5556 VAR_TYPE_DOUBLE, VAR_TYPE_DMAT4 };
5557 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
5559 const std::string iteration_loop_end = " }\n"
5563 const std::string iteration_loop_start = " for (uint a = 0u; a < 2u; a++)\n"
5565 " for (uint b = 0u; b < 2u; b++)\n"
5567 " for (uint c = 0u; c < 2u; c++)\n"
5569 " for (uint d = 0u; d < 2u; d++)\n"
5571 const glcts::test_var_type* var_types_set = var_types_set_es;
5572 size_t num_var_types = num_var_types_es;
5573 const bool test_compute = (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type);
5575 if (API::USE_DOUBLE)
5577 var_types_set = var_types_set_gl;
5578 num_var_types = num_var_types_gl;
5581 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
5583 _supported_variable_types_map_const_iterator var_iterator =
5584 supported_variable_types_map.find(var_types_set[var_type_index]);
5586 if (var_iterator != supported_variable_types_map.end())
5588 std::string array_declaration = var_iterator->second.type + " z[2][2][2][2];\n\n";
5590 std::string function_definition;
5591 std::string function_use;
5592 std::string verification;
5594 function_definition += "bool gfunc(out " + var_iterator->second.type + " x[2][2][2][2], ";
5595 function_definition += var_iterator->second.type + " y[2][2][2][2])\n";
5596 function_definition += "{\n";
5597 function_definition += " " + iteration_loop_start;
5598 function_definition +=
5599 " x[a][b][c][d] = " + var_iterator->second.type +
5601 function_definition += " " + iteration_loop_end;
5602 function_definition += "\n";
5603 function_definition += " " + iteration_loop_start;
5604 function_definition += " if(y[a][b][c][d]";
5605 if (var_iterator->second.type == "mat4") // mat4 comparison
5607 function_definition += "[0][0]";
5608 function_definition += " != float";
5610 else if (var_iterator->second.type == "dmat4") // dmat4 comparison
5612 function_definition += "[0][0]";
5613 function_definition += " != double";
5617 function_definition += " != ";
5618 function_definition += var_iterator->second.type;
5620 function_definition += "(((a*8u)+(b*4u)+(c*2u)+d))) {return false;}\n";
5621 function_definition += " " + iteration_loop_end;
5622 function_definition += " return true;\n";
5623 function_definition += "}\n\n";
5625 function_use += " " + array_declaration;
5626 function_use += " " + iteration_loop_start;
5627 function_use += " z[a][b][c][d] = ";
5628 function_use += var_iterator->second.type;
5629 function_use += "(((a*8u)+(b*4u)+(c*2u)+d));\n";
5630 function_use += " " + iteration_loop_end;
5632 verification += " float result = 0.0;\n";
5633 verification += " if(gfunc(z, z) == true)\n";
5634 verification += " {\n";
5635 verification += " result = 1.0;\n\n";
5636 verification += " }\n";
5637 verification += " else\n";
5638 verification += " {\n";
5639 verification += " result = 0.0;\n\n";
5640 verification += " }\n";
5642 if (false == test_compute)
5644 this->execute_draw_test(tested_shader_type, function_definition, function_use, verification);
5648 this->execute_dispatch_test(tested_shader_type, function_definition, function_use, verification);
5651 /* Deallocate any resources used. */
5652 this->delete_objects();
5653 } /* if var_type iterator found */
5656 TCU_FAIL("Type not found.");
5661 /* Generates the shader source code for the InteractionArgumentAliasing4
5662 * array tests, and attempts to compile each test shader, for both
5663 * vertex and fragment shaders.
5665 * @tparam API Tested API descriptor
5667 * @param tested_shader_type The type of shader that is being tested
5668 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
5670 template <class API>
5671 void InteractionArgumentAliasing4<API>::test_shader_compilation(
5672 typename TestCaseBase<API>::TestShaderType tested_shader_type)
5674 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_MAT4 };
5675 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
5677 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_MAT4,
5678 VAR_TYPE_DOUBLE, VAR_TYPE_DMAT4 };
5679 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
5681 const std::string iteration_loop_end = " }\n"
5685 const std::string iteration_loop_start = " for (uint a = 0u; a < 2u; a++)\n"
5687 " for (uint b = 0u; b < 2u; b++)\n"
5689 " for (uint c = 0u; c < 2u; c++)\n"
5691 " for (uint d = 0u; d < 2u; d++)\n"
5693 const glcts::test_var_type* var_types_set = var_types_set_es;
5694 size_t num_var_types = num_var_types_es;
5695 const bool test_compute = (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type);
5697 if (API::USE_DOUBLE)
5699 var_types_set = var_types_set_gl;
5700 num_var_types = num_var_types_gl;
5703 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
5705 _supported_variable_types_map_const_iterator var_iterator =
5706 supported_variable_types_map.find(var_types_set[var_type_index]);
5708 if (var_iterator != supported_variable_types_map.end())
5710 std::string array_declaration = var_iterator->second.type + "[2][2][2][2] z;\n\n";
5712 std::string function_definition;
5713 std::string function_use;
5714 std::string verification;
5716 function_definition += "bool gfunc(" + var_iterator->second.type + " x[2][2][2][2], ";
5717 function_definition += "out " + var_iterator->second.type + " y[2][2][2][2])\n";
5718 function_definition += "{\n";
5719 function_definition += " " + iteration_loop_start;
5720 function_definition +=
5721 " y[a][b][c][d] = " + var_iterator->second.type +
5723 function_definition += " " + iteration_loop_end;
5724 function_definition += "\n";
5725 function_definition += " " + iteration_loop_start;
5726 function_definition += " if(x[a][b][c][d]";
5727 if (var_iterator->second.type == "mat4") // mat4 comparison
5729 function_definition += "[0][0]";
5730 function_definition += " != float";
5732 else if (var_iterator->second.type == "dmat4") // dmat4 comparison
5734 function_definition += "[0][0]";
5735 function_definition += " != double";
5739 function_definition += " != ";
5740 function_definition += var_iterator->second.type;
5742 function_definition += "(((a*8u)+(b*4u)+(c*2u)+d))) {return false;}\n";
5743 function_definition += " " + iteration_loop_end;
5744 function_definition += " return true;\n";
5745 function_definition += "}\n\n";
5747 function_use += " " + array_declaration;
5748 function_use += " " + iteration_loop_start;
5749 function_use += " z[a][b][c][d] = ";
5750 function_use += var_iterator->second.type;
5751 function_use += "(((a*8u)+(b*4u)+(c*2u)+d));\n";
5752 function_use += " " + iteration_loop_end;
5754 verification += " float result = 0.0;\n";
5755 verification += " if(gfunc(z, z) == true)\n";
5756 verification += " {\n";
5757 verification += " result = 1.0;\n\n";
5758 verification += " }\n";
5759 verification += " else\n";
5760 verification += " {\n";
5761 verification += " result = 0.0;\n\n";
5762 verification += " }\n";
5764 if (false == test_compute)
5766 this->execute_draw_test(tested_shader_type, function_definition, function_use, verification);
5770 this->execute_dispatch_test(tested_shader_type, function_definition, function_use, verification);
5773 /* Deallocate any resources used. */
5774 this->delete_objects();
5775 } /* if var_type iterator found */
5778 TCU_FAIL("Type not found.");
5783 /* Generates the shader source code for the InteractionArgumentAliasing3
5784 * array tests, and attempts to compile each test shader, for both
5785 * vertex and fragment shaders.
5787 * @tparam API Tested API descriptor
5789 * @param tested_shader_type The type of shader that is being tested
5790 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
5792 template <class API>
5793 void InteractionArgumentAliasing5<API>::test_shader_compilation(
5794 typename TestCaseBase<API>::TestShaderType tested_shader_type)
5796 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_MAT4 };
5797 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
5799 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_MAT4,
5800 VAR_TYPE_DOUBLE, VAR_TYPE_DMAT4 };
5801 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
5803 const std::string iteration_loop_end = " }\n"
5807 const std::string iteration_loop_start = " for (uint a = 0u; a < 2u; a++)\n"
5809 " for (uint b = 0u; b < 2u; b++)\n"
5811 " for (uint c = 0u; c < 2u; c++)\n"
5813 " for (uint d = 0u; d < 2u; d++)\n"
5815 const glcts::test_var_type* var_types_set = var_types_set_es;
5816 size_t num_var_types = num_var_types_es;
5817 const bool test_compute = (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type);
5819 if (API::USE_DOUBLE)
5821 var_types_set = var_types_set_gl;
5822 num_var_types = num_var_types_gl;
5825 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
5827 _supported_variable_types_map_const_iterator var_iterator =
5828 supported_variable_types_map.find(var_types_set[var_type_index]);
5830 if (var_iterator != supported_variable_types_map.end())
5832 std::string array_declaration = var_iterator->second.type + "[2][2][2][2] z;\n\n";
5834 std::string function_definition;
5835 std::string function_use;
5836 std::string verification;
5838 function_definition += "bool gfunc(inout " + var_iterator->second.type + " x[2][2][2][2], ";
5839 function_definition += var_iterator->second.type + " y[2][2][2][2])\n";
5840 function_definition += "{\n";
5841 function_definition += " " + iteration_loop_start;
5842 function_definition +=
5843 " x[a][b][c][d] = " + var_iterator->second.type +
5845 function_definition += " " + iteration_loop_end;
5846 function_definition += "\n";
5847 function_definition += " " + iteration_loop_start;
5848 function_definition += " if(y[a][b][c][d]";
5849 if (var_iterator->second.type == "mat4") // mat4 comparison
5851 function_definition += "[0][0]";
5852 function_definition += " != float";
5854 else if (var_iterator->second.type == "dmat4") // dmat4 comparison
5856 function_definition += "[0][0]";
5857 function_definition += " != double";
5861 function_definition += " != ";
5862 function_definition += var_iterator->second.type;
5864 function_definition += "(((a*8u)+(b*4u)+(c*2u)+d))) {return false;}\n";
5865 function_definition += " " + iteration_loop_end;
5866 function_definition += " return true;\n";
5867 function_definition += "}\n\n";
5869 function_use += " " + array_declaration;
5870 function_use += " " + iteration_loop_start;
5871 function_use += " z[a][b][c][d] = ";
5872 function_use += var_iterator->second.type;
5873 function_use += "(((a*8u)+(b*4u)+(c*2u)+d));\n";
5874 function_use += " " + iteration_loop_end;
5876 verification += " float result = 0.0;\n";
5877 verification += " if(gfunc(z, z) == true)\n";
5878 verification += " {\n";
5879 verification += " result = 1.0;\n\n";
5880 verification += " }\n";
5881 verification += " else\n";
5882 verification += " {\n";
5883 verification += " result = 0.0;\n\n";
5884 verification += " }\n";
5886 if (false == test_compute)
5888 this->execute_draw_test(tested_shader_type, function_definition, function_use, verification);
5892 this->execute_dispatch_test(tested_shader_type, function_definition, function_use, verification);
5895 /* Deallocate any resources used. */
5896 this->delete_objects();
5897 } /* if var_type iterator found */
5900 TCU_FAIL("Type not found.");
5905 /* Generates the shader source code for the InteractionArgumentAliasing4
5906 * array tests, and attempts to compile each test shader, for both
5907 * vertex and fragment shaders.
5909 * @tparam API Tested API descriptor
5911 * @param tested_shader_type The type of shader that is being tested
5912 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
5914 template <class API>
5915 void InteractionArgumentAliasing6<API>::test_shader_compilation(
5916 typename TestCaseBase<API>::TestShaderType tested_shader_type)
5918 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_MAT4 };
5919 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
5921 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_MAT4,
5922 VAR_TYPE_DOUBLE, VAR_TYPE_DMAT4 };
5923 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
5925 const std::string iteration_loop_end = " }\n"
5929 const std::string iteration_loop_start = " for (uint a = 0u; a < 2u; a++)\n"
5931 " for (uint b = 0u; b < 2u; b++)\n"
5933 " for (uint c = 0u; c < 2u; c++)\n"
5935 " for (uint d = 0u; d < 2u; d++)\n"
5937 const glcts::test_var_type* var_types_set = var_types_set_es;
5938 size_t num_var_types = num_var_types_es;
5939 const bool test_compute = (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type);
5941 if (API::USE_DOUBLE)
5943 var_types_set = var_types_set_gl;
5944 num_var_types = num_var_types_gl;
5947 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
5949 _supported_variable_types_map_const_iterator var_iterator =
5950 supported_variable_types_map.find(var_types_set[var_type_index]);
5952 if (var_iterator != supported_variable_types_map.end())
5954 std::string array_declaration = var_iterator->second.type + "[2][2][2][2] z;\n\n";
5956 std::string function_definition;
5957 std::string function_use;
5958 std::string verification;
5960 function_definition += "bool gfunc(" + var_iterator->second.type + " x[2][2][2][2], ";
5961 function_definition += "inout " + var_iterator->second.type + " y[2][2][2][2])\n";
5962 function_definition += "{\n";
5963 function_definition += " " + iteration_loop_start;
5964 function_definition +=
5965 " y[a][b][c][d] = " + var_iterator->second.type +
5967 function_definition += " " + iteration_loop_end;
5968 function_definition += "\n";
5969 function_definition += " " + iteration_loop_start;
5970 function_definition += " if(x[a][b][c][d]";
5971 if (var_iterator->second.type == "mat4") // mat4 comparison
5973 function_definition += "[0][0]";
5974 function_definition += " != float";
5976 else if (var_iterator->second.type == "dmat4") // dmat4 comparison
5978 function_definition += "[0][0]";
5979 function_definition += " != double";
5983 function_definition += " != ";
5984 function_definition += var_iterator->second.type;
5986 function_definition += "(((a*8u)+(b*4u)+(c*2u)+d))) {return false;}\n";
5987 function_definition += " " + iteration_loop_end;
5988 function_definition += " return true;\n";
5989 function_definition += "}\n\n";
5991 function_use += " " + array_declaration;
5992 function_use += " " + iteration_loop_start;
5993 function_use += " z[a][b][c][d] = ";
5994 function_use += var_iterator->second.type;
5995 function_use += "(((a*8u)+(b*4u)+(c*2u)+d));\n";
5996 function_use += " " + iteration_loop_end;
5998 verification += " float result = 0.0;\n";
5999 verification += " if(gfunc(z, z) == true)\n";
6000 verification += " {\n";
6001 verification += " result = 1.0;\n\n";
6002 verification += " }\n";
6003 verification += " else\n";
6004 verification += " {\n";
6005 verification += " result = 0.0;\n\n";
6006 verification += " }\n";
6008 if (false == test_compute)
6010 this->execute_draw_test(tested_shader_type, function_definition, function_use, verification);
6014 this->execute_dispatch_test(tested_shader_type, function_definition, function_use, verification);
6017 /* Deallocate any resources used. */
6018 this->delete_objects();
6019 } /* if var_type iterator found */
6022 TCU_FAIL("Type not found.");
6027 /* Generates the shader source code for the InteractionUniforms1
6028 * array tests, and attempts to compile each test shader, for both
6029 * vertex and fragment shaders.
6031 * @tparam API Tested API descriptor
6033 * @param tested_shader_type The type of shader that is being tested
6034 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
6036 template <class API>
6037 void InteractionUniforms1<API>::test_shader_compilation(typename TestCaseBase<API>::TestShaderType tested_shader_type)
6039 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_FLOAT, VAR_TYPE_INT, VAR_TYPE_UINT };
6040 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
6042 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_FLOAT, VAR_TYPE_INT, VAR_TYPE_UINT,
6044 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
6046 const glw::Functions& gl = this->context_id.getRenderContext().getFunctions();
6047 const glcts::test_var_type* var_types_set = var_types_set_es;
6048 size_t num_var_types = num_var_types_es;
6050 if (API::USE_DOUBLE)
6052 var_types_set = var_types_set_gl;
6053 num_var_types = num_var_types_gl;
6056 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
6058 _supported_variable_types_map_const_iterator var_iterator =
6059 supported_variable_types_map.find(var_types_set[var_type_index]);
6061 if (var_iterator != supported_variable_types_map.end())
6063 std::string uniform_definition;
6064 std::string uniform_use;
6066 uniform_definition += "uniform ";
6067 uniform_definition += var_iterator->second.precision;
6068 uniform_definition += " ";
6069 uniform_definition += var_iterator->second.type;
6070 uniform_definition += " my_uniform_1[1][1][1][1];\n\n";
6072 uniform_use = " float result = float(my_uniform_1[0][0][0][0]);\n";
6074 if (API::USE_ALL_SHADER_STAGES)
6076 const std::string& compute_shader_source =
6077 this->prepare_compute_shader(tested_shader_type, uniform_definition, uniform_use);
6078 const std::string& fragment_shader_source =
6079 this->prepare_fragment_shader(tested_shader_type, uniform_definition, uniform_use);
6080 const std::string& geometry_shader_source =
6081 this->prepare_geometry_shader(tested_shader_type, uniform_definition, uniform_use);
6082 const std::string& tess_ctrl_shader_source =
6083 this->prepare_tess_ctrl_shader(tested_shader_type, uniform_definition, uniform_use);
6084 const std::string& tess_eval_shader_source =
6085 this->prepare_tess_eval_shader(tested_shader_type, uniform_definition, uniform_use);
6086 const std::string& vertex_shader_source =
6087 this->prepare_vertex_shader(tested_shader_type, uniform_definition, uniform_use);
6089 switch (tested_shader_type)
6091 case TestCaseBase<API>::VERTEX_SHADER_TYPE: /* Fall through */
6092 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
6093 this->execute_positive_test(vertex_shader_source, fragment_shader_source, false, false);
6096 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
6097 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
6098 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE: /* Fall through */
6099 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
6100 this->execute_positive_test(vertex_shader_source, tess_ctrl_shader_source, tess_eval_shader_source,
6101 geometry_shader_source, fragment_shader_source, compute_shader_source,
6106 TCU_FAIL("Invalid enum");
6112 const std::string& fragment_shader_source =
6113 this->prepare_fragment_shader(tested_shader_type, uniform_definition, uniform_use);
6114 const std::string& vertex_shader_source =
6115 this->prepare_vertex_shader(tested_shader_type, uniform_definition, uniform_use);
6117 this->execute_positive_test(vertex_shader_source, fragment_shader_source, false, false);
6120 glw::GLint uniform_location = -1;
6122 /* Make program object active. */
6123 gl.useProgram(this->program_object_id);
6124 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram() failed.");
6126 /* Get uniform location. */
6127 uniform_location = gl.getUniformLocation(this->program_object_id, "my_uniform_1[0][0][0][0]");
6128 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation() failed.");
6130 if (uniform_location == -1)
6132 TCU_FAIL("Uniform is not found or is considered as not active.");
6135 switch (var_type_index)
6137 case 0: //float type of uniform is considered
6139 glw::GLfloat uniform_value = 1.0f;
6141 gl.uniform1f(uniform_location, uniform_value);
6142 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1f() failed.");
6146 case 1: //int type of uniform is considered
6148 glw::GLint uniform_value = 1;
6150 gl.uniform1i(uniform_location, uniform_value);
6151 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i() failed.");
6155 case 2: //uint type of uniform is considered
6157 glw::GLuint uniform_value = 1;
6159 gl.uniform1ui(uniform_location, uniform_value);
6160 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1ui() failed.");
6164 case 3: //double type of uniform is considered
6166 glw::GLdouble uniform_value = 1.0;
6168 gl.uniform1d(uniform_location, uniform_value);
6169 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1d() failed.");
6175 TCU_FAIL("Invalid variable-type index.");
6179 } /* switch (var_type_index) */
6181 /* Deallocate any resources used. */
6182 this->delete_objects();
6183 } /* if var_type iterator found */
6186 TCU_FAIL("Type not found.");
6188 } /* for (int var_type_index = 0; ...) */
6193 * @tparam API Tested API descriptor
6195 * @param tested_shader_type The type of shader that is being tested
6196 * @param uniform_definition Definition used to prepare shader
6197 * @param uniform_use Snippet that use defined uniform
6199 template <class API>
6200 std::string InteractionUniforms1<API>::prepare_compute_shader(
6201 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& uniform_definition,
6202 const std::string& uniform_use)
6204 std::string compute_shader_source;
6206 if (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type)
6208 compute_shader_source = "writeonly uniform image2D uni_image;\n"
6211 /* User-defined function definition. */
6212 compute_shader_source += uniform_definition;
6213 compute_shader_source += "\n\n";
6215 /* Main function definition. */
6216 compute_shader_source += shader_start;
6217 compute_shader_source += uniform_use;
6218 compute_shader_source += "\n\n";
6219 compute_shader_source += "\n"
6220 " imageStore(uni_image, ivec2(gl_GlobalInvocationID.xy), vec4(result, 0, 0, 0));\n"
6225 return compute_shader_source;
6230 * @tparam API Tested API descriptor
6232 * @param tested_shader_type The type of shader that is being tested
6233 * @param uniform_definition Definition used to prepare shader
6234 * @param uniform_use Snippet that use defined uniform
6236 template <class API>
6237 std::string InteractionUniforms1<API>::prepare_fragment_shader(
6238 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& uniform_definition,
6239 const std::string& uniform_use)
6241 std::string fragment_shader_source;
6243 switch (tested_shader_type)
6245 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
6248 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
6249 fragment_shader_source = "out vec4 colour;\n\n";
6251 /* User-defined function definition. */
6252 fragment_shader_source += uniform_definition;
6253 fragment_shader_source += "\n\n";
6255 /* Main function definition. */
6256 fragment_shader_source += shader_start;
6257 fragment_shader_source += uniform_use;
6258 fragment_shader_source += "\n\n";
6259 fragment_shader_source += " colour = vec4(result);\n";
6260 fragment_shader_source += shader_end;
6263 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
6264 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
6265 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
6266 fragment_shader_source = "in float fs_result;\n\n"
6267 "out vec4 colour;\n\n"
6270 " colour = vec4(fs_result);\n"
6275 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
6276 fragment_shader_source = default_fragment_shader_source;
6280 TCU_FAIL("Unrecognized shader object type.");
6284 return fragment_shader_source;
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_geometry_shader(
6297 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& uniform_definition,
6298 const std::string& uniform_use)
6300 std::string geometry_shader_source;
6302 switch (tested_shader_type)
6304 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
6305 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
6306 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
6309 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
6310 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
6311 geometry_shader_source = "layout(points) in;\n"
6312 "layout(triangle_strip, max_vertices = 4) out;\n"
6314 "in float tes_result[];\n"
6315 "out float fs_result;\n"
6319 " gl_Position = vec4(-1, -1, 0, 1);\n"
6320 " fs_result = tes_result[0];\n"
6322 " gl_Position = vec4(-1, 1, 0, 1);\n"
6323 " fs_result = tes_result[0];\n"
6325 " gl_Position = vec4(1, -1, 0, 1);\n"
6326 " fs_result = tes_result[0];\n"
6328 " gl_Position = vec4(1, 1, 0, 1);\n"
6329 " fs_result = tes_result[0];\n"
6334 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
6335 geometry_shader_source = "layout(points) in;\n"
6336 "layout(triangle_strip, max_vertices = 4) out;\n"
6338 "out float fs_result;\n"
6341 /* User-defined function definition. */
6342 geometry_shader_source += uniform_definition;
6343 geometry_shader_source += "\n\n";
6345 /* Main function definition. */
6346 geometry_shader_source += shader_start;
6347 geometry_shader_source += uniform_use;
6348 geometry_shader_source += "\n\n";
6349 geometry_shader_source += "\n gl_Position = vec4(-1, -1, 0, 1);\n"
6350 " fs_result = result;\n"
6352 " gl_Position = vec4(-1, 1, 0, 1);\n"
6353 " fs_result = result;\n"
6355 " gl_Position = vec4(1, -1, 0, 1);\n"
6356 " fs_result = result;\n"
6358 " gl_Position = vec4(1, 1, 0, 1);\n"
6359 " fs_result = result;\n"
6365 TCU_FAIL("Unrecognized shader object type.");
6369 return geometry_shader_source;
6374 * @tparam API Tested API descriptor
6376 * @param tested_shader_type The type of shader that is being tested
6377 * @param uniform_definition Definition used to prepare shader
6378 * @param uniform_use Snippet that use defined uniform
6380 template <class API>
6381 std::string InteractionUniforms1<API>::prepare_tess_ctrl_shader(
6382 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& uniform_definition,
6383 const std::string& uniform_use)
6385 std::string tess_ctrl_shader_source;
6387 switch (tested_shader_type)
6389 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
6390 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
6391 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
6392 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
6395 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
6396 tess_ctrl_shader_source = "layout(vertices = 1) out;\n"
6398 "out float tcs_result[];\n"
6401 /* User-defined function definition. */
6402 tess_ctrl_shader_source += uniform_definition;
6403 tess_ctrl_shader_source += "\n\n";
6405 /* Main function definition. */
6406 tess_ctrl_shader_source += shader_start;
6407 tess_ctrl_shader_source += uniform_use;
6408 tess_ctrl_shader_source += "\n\n";
6409 tess_ctrl_shader_source += " tcs_result[gl_InvocationID] = result;\n"
6411 " gl_TessLevelOuter[0] = 1.0;\n"
6412 " gl_TessLevelOuter[1] = 1.0;\n"
6413 " gl_TessLevelOuter[2] = 1.0;\n"
6414 " gl_TessLevelOuter[3] = 1.0;\n"
6415 " gl_TessLevelInner[0] = 1.0;\n"
6416 " gl_TessLevelInner[1] = 1.0;\n"
6420 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
6421 tess_ctrl_shader_source = default_tc_shader_source;
6425 TCU_FAIL("Unrecognized shader object type.");
6429 return tess_ctrl_shader_source;
6434 * @tparam API Tested API descriptor
6436 * @param tested_shader_type The type of shader that is being tested
6437 * @param uniform_definition Definition used to prepare shader
6438 * @param uniform_use Snippet that use defined uniform
6440 template <class API>
6441 std::string InteractionUniforms1<API>::prepare_tess_eval_shader(
6442 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& uniform_definition,
6443 const std::string& uniform_use)
6445 std::string tess_eval_shader_source;
6447 switch (tested_shader_type)
6449 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
6450 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
6451 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
6452 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
6455 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
6456 tess_eval_shader_source = "layout(isolines, point_mode) in;\n"
6458 "in float tcs_result[];\n"
6459 "out float tes_result;\n"
6463 " tes_result = tcs_result[0];\n"
6467 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
6468 tess_eval_shader_source = "layout(isolines, point_mode) in;\n"
6470 "out float tes_result;\n"
6473 /* User-defined function definition. */
6474 tess_eval_shader_source += uniform_definition;
6475 tess_eval_shader_source += "\n\n";
6477 /* Main function definition. */
6478 tess_eval_shader_source += shader_start;
6479 tess_eval_shader_source += uniform_use;
6480 tess_eval_shader_source += "\n\n";
6481 tess_eval_shader_source += " tes_result = result;\n"
6486 TCU_FAIL("Unrecognized shader object type.");
6490 return tess_eval_shader_source;
6495 * @tparam API Tested API descriptor
6497 * @param tested_shader_type The type of shader that is being tested
6498 * @param uniform_definition Definition used to prepare shader
6499 * @param uniform_use Snippet that use defined uniform
6501 template <class API>
6502 std::string InteractionUniforms1<API>::prepare_vertex_shader(
6503 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& uniform_definition,
6504 const std::string& uniform_use)
6506 std::string vertex_shader_source;
6508 switch (tested_shader_type)
6510 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
6513 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
6514 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
6515 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
6516 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
6517 vertex_shader_source = default_vertex_shader_source;
6520 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
6521 /* User-defined function definition. */
6522 vertex_shader_source += uniform_definition;
6524 /* Main function definition. */
6525 vertex_shader_source += shader_start;
6526 vertex_shader_source += uniform_use;
6527 vertex_shader_source += " gl_Position = vec4(result);\n";
6528 vertex_shader_source += shader_end;
6532 TCU_FAIL("Unrecognized shader object type.");
6536 return vertex_shader_source;
6539 /* Generates the shader source code for the InteractionUniforms2
6540 * array tests, and attempts to compile each test shader, for both
6541 * vertex and fragment shaders.
6543 * @tparam API Tested API descriptor
6545 * @param tested_shader_type The type of shader that is being tested
6546 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
6548 template <class API>
6549 void InteractionUniforms2<API>::test_shader_compilation(typename TestCaseBase<API>::TestShaderType tested_shader_type)
6551 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_MAT4 };
6552 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
6554 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_MAT4,
6555 VAR_TYPE_DOUBLE, VAR_TYPE_DMAT4 };
6556 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
6558 const std::string array_initializers[] = { "int[2][2][2][2](\n"
6571 " int[2](11, 12),\n"
6575 " int[2](15, 16),\n"
6581 "float[2][2][2][2](\n"
6582 " float[2][2][2](\n"
6584 " float[2](1.0, 2.0),\n"
6585 " float[2](3.0, 4.0)),\n"
6587 " float[2](5.0, 6.0),\n"
6588 " float[2](7.0, 8.0))),\n"
6589 " float[2][2][2](\n"
6591 " float[2](1.1, 2.1),\n"
6592 " float[2](3.1, 4.1)\n"
6595 " float[2](5.1, 6.1),\n"
6596 " float[2](7.1, 8.1)\n"
6601 "mat4[2][2][2][2](\n"
6604 " mat4[2]( mat4(1), mat4(2)),\n"
6605 " mat4[2]( mat4(3), mat4(4))\n"
6608 " mat4[2](mat4(5), mat4(6)),\n"
6609 " mat4[2](mat4(7), mat4(8))\n"
6614 " mat4[2](mat4(9), mat4(10)),\n"
6615 " mat4[2](mat4(11), mat4(12))\n"
6618 " mat4[2](mat4(13), mat4(14)),\n"
6619 " mat4[2](mat4(15), mat4(16))\n"
6624 "double[2][2][2][2](\n"
6625 " double[2][2][2](\n"
6627 " double[2](1.0, 2.0),\n"
6628 " double[2](3.0, 4.0)),\n"
6630 " double[2](5.0, 6.0),\n"
6631 " double[2](7.0, 8.0))),\n"
6632 " double[2][2][2](\n"
6634 " double[2](1.1, 2.1),\n"
6635 " double[2](3.1, 4.1)\n"
6638 " double[2](5.1, 6.1),\n"
6639 " double[2](7.1, 8.1)\n"
6644 "dmat4[2][2][2][2](\n"
6645 " dmat4[2][2][2](\n"
6647 " dmat4[2]( dmat4(1), dmat4(2)),\n"
6648 " dmat4[2]( dmat4(3), dmat4(4))\n"
6651 " dmat4[2](dmat4(5), dmat4(6)),\n"
6652 " dmat4[2](dmat4(7), dmat4(8))\n"
6655 " dmat4[2][2][2](\n"
6657 " dmat4[2](dmat4(9), dmat4(10)),\n"
6658 " dmat4[2](dmat4(11), dmat4(12))\n"
6661 " dmat4[2](dmat4(13), dmat4(14)),\n"
6662 " dmat4[2](dmat4(15), dmat4(16))\n"
6667 const glcts::test_var_type* var_types_set = var_types_set_es;
6668 size_t num_var_types = num_var_types_es;
6670 if (API::USE_DOUBLE)
6672 var_types_set = var_types_set_gl;
6673 num_var_types = num_var_types_gl;
6676 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
6678 _supported_variable_types_map_const_iterator var_iterator =
6679 supported_variable_types_map.find(var_types_set[var_type_index]);
6681 if (var_iterator != supported_variable_types_map.end())
6683 std::string base_variable_string;
6685 for (int initialiser_selector = 1; initialiser_selector >= 0; initialiser_selector--)
6687 // We normally do all 16 possible permutations of [4][4][4][4] items (15..0).
6688 // However, in this case we will skip the case that will work,
6689 // so we'll merely process permutations 14..0
6690 for (int permutation_index = 14; permutation_index >= 0; permutation_index--)
6692 base_variable_string =
6693 "uniform " + var_iterator->second.precision + " " + var_iterator->second.type + " x";
6695 // for all 4 possible sub_script entries
6696 for (int sub_script_entry_index = 3; sub_script_entry_index >= 0; sub_script_entry_index--)
6698 if (permutation_index & (1 << sub_script_entry_index))
6700 // In this case, we'll use a valid sub_script
6701 base_variable_string += "[2]";
6705 // In this case, we'll use an invalid sub_script
6706 base_variable_string += "[]";
6710 if (initialiser_selector == 0)
6712 // We'll use an initialiser
6713 base_variable_string += " = " + array_initializers[var_type_index];
6716 base_variable_string += ";\n\n";
6718 std::string shader_source = base_variable_string + shader_start;
6721 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
6725 * This will succeed in case of allowed unsized
6726 * declarations and when at least one of these is
6728 * 1. There is an initialiser.
6729 * 2. Only the outermost dimension is unsized,
6730 * as in [][2][2][2].
6732 EXECUTE_SHADER_TEST(API::ALLOW_UNSIZED_DECLARATION &&
6733 (initialiser_selector == 0 || permutation_index == 7),
6734 tested_shader_type, shader_source);
6735 } /* for (int permutation_index = 14; ...) */
6736 } /* for (int initialiser_selector = 1; ...) */
6737 } /* if var_type iterator found */
6740 TCU_FAIL("Type not found.");
6742 } /* for (int var_type_index = 0; ...) */
6745 /* Generates the shader source code for the InteractionUniformBuffers1
6746 * array tests, and attempts to compile each test shader, for both
6747 * vertex and fragment shaders.
6749 * @tparam API Tested API descriptor
6751 * @param tested_shader_type The type of shader that is being tested
6752 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
6754 template <class API>
6755 void InteractionUniformBuffers1<API>::test_shader_compilation(
6756 typename TestCaseBase<API>::TestShaderType tested_shader_type)
6758 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_FLOAT, VAR_TYPE_INT, VAR_TYPE_UINT };
6759 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
6761 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_FLOAT, VAR_TYPE_INT, VAR_TYPE_UINT,
6763 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
6765 const glcts::test_var_type* var_types_set = var_types_set_es;
6766 size_t num_var_types = num_var_types_es;
6768 if (API::USE_DOUBLE)
6770 var_types_set = var_types_set_gl;
6771 num_var_types = num_var_types_gl;
6774 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
6776 _supported_variable_types_map_const_iterator var_iterator =
6777 supported_variable_types_map.find(var_types_set[var_type_index]);
6779 if (var_iterator != supported_variable_types_map.end())
6781 std::string shader_source;
6783 shader_source += "uniform uBlocka {\n";
6784 shader_source += " " + var_iterator->second.type + " x[1][1][1][1][1][1];\n";
6785 shader_source += "};\n\n";
6786 shader_source += shader_start;
6789 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
6792 EXECUTE_POSITIVE_TEST(tested_shader_type, shader_source, true, false);
6793 } /* if var_type iterator found */
6796 TCU_FAIL("Type not found.");
6801 /* Generates the shader source code for the InteractionUniformBuffers2
6802 * array tests, and attempts to compile each test shader, for both
6803 * vertex and fragment shaders.
6805 * @tparam API Tested API descriptor
6807 * @param tested_shader_type The type of shader that is being tested
6808 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
6810 template <class API>
6811 void InteractionUniformBuffers2<API>::test_shader_compilation(
6812 typename TestCaseBase<API>::TestShaderType tested_shader_type)
6814 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_FLOAT, VAR_TYPE_INT, VAR_TYPE_UINT };
6815 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
6817 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_FLOAT, VAR_TYPE_INT, VAR_TYPE_UINT,
6819 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
6821 const glw::Functions& gl = this->context_id.getRenderContext().getFunctions();
6822 const glcts::test_var_type* var_types_set = var_types_set_es;
6823 size_t num_var_types = num_var_types_es;
6825 if (API::USE_DOUBLE)
6827 var_types_set = var_types_set_gl;
6828 num_var_types = num_var_types_gl;
6831 /* Iterate through float / int / uint values. */
6832 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
6834 _supported_variable_types_map_const_iterator var_iterator =
6835 supported_variable_types_map.find(var_types_set[var_type_index]);
6837 if (var_iterator != supported_variable_types_map.end())
6839 std::string uniform_definition;
6840 std::string uniform_use;
6842 uniform_definition += "layout (std140) uniform uniform_block_name\n"
6844 uniform_definition += " ";
6845 uniform_definition += var_iterator->second.type;
6846 uniform_definition += " my_uniform_1[1][1][1][1];\n"
6849 uniform_use = " float result = float(my_uniform_1[0][0][0][0]);\n";
6851 if (API::USE_ALL_SHADER_STAGES)
6853 const std::string& compute_shader_source =
6854 this->prepare_compute_shader(tested_shader_type, uniform_definition, uniform_use);
6855 const std::string& fragment_shader_source =
6856 this->prepare_fragment_shader(tested_shader_type, uniform_definition, uniform_use);
6857 const std::string& geometry_shader_source =
6858 this->prepare_geometry_shader(tested_shader_type, uniform_definition, uniform_use);
6859 const std::string& tess_ctrl_shader_source =
6860 this->prepare_tess_ctrl_shader(tested_shader_type, uniform_definition, uniform_use);
6861 const std::string& tess_eval_shader_source =
6862 this->prepare_tess_eval_shader(tested_shader_type, uniform_definition, uniform_use);
6863 const std::string& vertex_shader_source =
6864 this->prepare_vertex_shader(tested_shader_type, uniform_definition, uniform_use);
6866 switch (tested_shader_type)
6868 case TestCaseBase<API>::VERTEX_SHADER_TYPE: /* Fall through */
6869 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
6870 this->execute_positive_test(vertex_shader_source, fragment_shader_source, false, false);
6873 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
6874 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
6875 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE: /* Fall through */
6876 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
6877 this->execute_positive_test(vertex_shader_source, tess_ctrl_shader_source, tess_eval_shader_source,
6878 geometry_shader_source, fragment_shader_source, compute_shader_source,
6883 TCU_FAIL("Invalid enum");
6889 const std::string& fragment_shader_source =
6890 this->prepare_fragment_shader(tested_shader_type, uniform_definition, uniform_use);
6891 const std::string& vertex_shader_source =
6892 this->prepare_vertex_shader(tested_shader_type, uniform_definition, uniform_use);
6894 this->execute_positive_test(vertex_shader_source, fragment_shader_source, false, false);
6897 glw::GLuint buffer_object_id = 0;
6898 glw::GLint my_uniform_block_index = GL_INVALID_INDEX;
6900 gl.useProgram(this->program_object_id);
6901 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram() failed.");
6903 my_uniform_block_index = gl.getUniformBlockIndex(this->program_object_id, "uniform_block_name");
6904 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformBlockIndex() failed.");
6906 if ((unsigned)my_uniform_block_index == GL_INVALID_INDEX)
6908 TCU_FAIL("Uniform block not found or is considered as not active.");
6911 gl.genBuffers(1, &buffer_object_id);
6912 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenBuffers() failed.");
6914 gl.bindBuffer(GL_UNIFORM_BUFFER, buffer_object_id);
6915 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer() failed.");
6917 switch (var_type_index)
6919 case 0: //float type of uniform is considered
6921 glw::GLfloat buffer_data[] = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f,
6922 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f };
6924 gl.bufferData(GL_UNIFORM_BUFFER, sizeof(buffer_data), buffer_data, GL_STATIC_DRAW);
6925 GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferData() failed.");
6929 case 1: //int type of uniform is considered
6932 glw::GLint buffer_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
6934 gl.bufferData(GL_UNIFORM_BUFFER, sizeof(buffer_data), buffer_data, GL_STATIC_DRAW);
6935 GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferData() failed.");
6939 case 2: //uint type of uniform is considered
6941 glw::GLuint buffer_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
6943 gl.bufferData(GL_UNIFORM_BUFFER, sizeof(buffer_data), buffer_data, GL_STATIC_DRAW);
6944 GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferData() failed.");
6948 case 3: //double type of uniform is considered
6950 glw::GLdouble buffer_data[] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0,
6951 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0 };
6953 gl.bufferData(GL_UNIFORM_BUFFER, sizeof(buffer_data), buffer_data, GL_STATIC_DRAW);
6954 GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferData() failed.");
6960 TCU_FAIL("Invalid variable-type index.");
6964 } /* switch (var_type_index) */
6966 gl.uniformBlockBinding(this->program_object_id, my_uniform_block_index, 0);
6967 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniformBlockBinding() failed.");
6969 gl.bindBufferBase(GL_UNIFORM_BUFFER, 0, buffer_object_id);
6970 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBufferBase() failed.");
6972 if (TestCaseBase<API>::COMPUTE_SHADER_TYPE != tested_shader_type)
6974 execute_draw_test(tested_shader_type);
6978 execute_dispatch_test();
6981 /* Deallocate any resources used. */
6982 gl.deleteBuffers(1, &buffer_object_id);
6983 this->delete_objects();
6984 } /* if var_type iterator found */
6987 TCU_FAIL("Type not found.");
6989 } /* for (int var_type_index = 0; ...) */
6992 /** Executes test for compute program
6994 * @tparam API Tested API descriptor
6996 template <class API>
6997 void InteractionUniformBuffers2<API>::execute_dispatch_test()
6999 const glw::Functions& gl = this->context_id.getRenderContext().getFunctions();
7001 gl.dispatchCompute(1, 1, 1);
7002 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
7005 /** Executes test for draw program
7007 * @tparam API Tested API descriptor
7009 * @param tested_shader_type The type of shader that is being tested
7011 template <class API>
7012 void InteractionUniformBuffers2<API>::execute_draw_test(typename TestCaseBase<API>::TestShaderType tested_shader_type)
7014 const glw::Functions& gl = this->context_id.getRenderContext().getFunctions();
7016 glw::GLuint vao_id = 0;
7018 gl.genVertexArrays(1, &vao_id);
7019 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenVertexArrays() failed.");
7021 gl.bindVertexArray(vao_id);
7022 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray() failed.");
7024 switch (tested_shader_type)
7026 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
7027 case TestCaseBase<API>::VERTEX_SHADER_TYPE: /* Fall through */
7028 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
7029 gl.drawArrays(GL_POINTS, 0, 1);
7030 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
7033 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE: /* Fall through */
7034 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
7035 /* Tesselation patch set up */
7036 gl.patchParameteri(GL_PATCH_VERTICES, 1);
7037 GLU_EXPECT_NO_ERROR(gl.getError(), "PatchParameteri");
7039 gl.drawArrays(GL_PATCHES, 0, 1);
7040 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
7044 TCU_FAIL("Invalid enum");
7048 gl.deleteVertexArrays(1, &vao_id);
7049 GLU_EXPECT_NO_ERROR(gl.getError(), "glDeleteVertexArrays() failed.");
7052 /* Generates the shader source code for the InteractionUniformBuffers3
7053 * array tests, and attempts to compile each test shader, for both
7054 * vertex and fragment shaders.
7056 * @tparam API Tested API descriptor
7058 * @param tested_shader_type The type of shader that is being tested
7059 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
7061 template <class API>
7062 void InteractionUniformBuffers3<API>::test_shader_compilation(
7063 typename TestCaseBase<API>::TestShaderType tested_shader_type)
7065 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_FLOAT, VAR_TYPE_INT, VAR_TYPE_UINT };
7066 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
7068 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_FLOAT, VAR_TYPE_INT, VAR_TYPE_UINT,
7070 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
7072 const std::string invalid_size_declarations[] = { "[2][2][2][]", "[2][2][][2]", "[2][][2][2]", "[][2][2][2]",
7073 "[2][2][][]", "[2][][2][]", "[][2][2][]", "[2][][][2]",
7074 "[][2][][2]", "[][][2][2]", "[2][][][]", "[][2][][]",
7075 "[][][2][]", "[][][][2]", "[][][][]" };
7077 const std::string array_initializers[] = { "float[2][2][2][2](float[2][2][2](float[2][2](float[2](1.0, 2.0),"
7078 "float[2](3.0, 4.0)),"
7079 "float[2][2](float[2](5.0, 6.0),"
7080 "float[2](7.0, 8.0))),"
7081 "float[2][2][2](float[2][2](float[2](1.1, 2.1),"
7082 "float[2](3.1, 4.1)),"
7083 "float[2][2](float[2](5.1, 6.1),"
7084 "float[2](7.1, 8.1))));\n",
7086 "int[2][2][2][2](int[2][2][2](int[2][2](int[2]( 1, 2),"
7088 "int[2][2](int[2]( 5, 6),"
7090 "int[2][2][2](int[2][2](int[2](11, 12),"
7092 "int[2][2](int[2](15, 16),"
7093 "int[2](17, 18))));\n",
7095 "uint[2][2][2][2](uint[2][2][2](uint[2][2](uint[2]( 1u, 2u),"
7096 "uint[2]( 3u, 4u)),"
7097 "uint[2][2](uint[2]( 5u, 6u),"
7098 "uint[2]( 7u, 8u))),"
7099 "uint[2][2][2](uint[2][2](uint[2](11u, 12u),"
7100 "uint[2](13u, 14u)),"
7101 "uint[2][2](uint[2](15u, 16u),"
7102 "uint[2](17u, 18u))));\n",
7104 "double[2][2][2][2](double[2][2][2](double[2][2](double[2](1.0, 2.0),"
7105 "double[2](3.0, 4.0)),"
7106 "double[2][2](double[2](5.0, 6.0),"
7107 "double[2](7.0, 8.0))),"
7108 "double[2][2][2](double[2][2](double[2](1.1, 2.1),"
7109 "double[2](3.1, 4.1)),"
7110 "double[2][2](double[2](5.1, 6.1),"
7111 "double[2](7.1, 8.1))));\n" };
7112 const glcts::test_var_type* var_types_set = var_types_set_es;
7113 size_t num_var_types = num_var_types_es;
7115 if (API::USE_DOUBLE)
7117 var_types_set = var_types_set_gl;
7118 num_var_types = num_var_types_gl;
7121 /* Iterate through float/ int/ uint types.
7122 * Case: without initializer.
7124 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
7126 _supported_variable_types_map_const_iterator var_iterator =
7127 supported_variable_types_map.find(var_types_set[var_type_index]);
7129 if (var_iterator != supported_variable_types_map.end())
7131 for (size_t invalid_size_declarations_index = 0;
7132 invalid_size_declarations_index <
7133 sizeof(invalid_size_declarations) / sizeof(invalid_size_declarations[0]);
7134 invalid_size_declarations_index++)
7136 std::string shader_source;
7138 shader_source = "layout (std140) uniform MyUniform {\n";
7139 shader_source += " " + var_iterator->second.type +
7140 invalid_size_declarations[invalid_size_declarations_index] + " my_variable;\n";
7141 shader_source += "};\n\n";
7142 shader_source += shader_start;
7145 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
7148 EXECUTE_SHADER_TEST(API::ALLOW_UNSIZED_DECLARATION && invalid_size_declarations_index == 3,
7149 tested_shader_type, shader_source);
7150 } /* for (int invalid_size_declarations_index = 0; ...) */
7154 TCU_FAIL("Type not found.");
7156 } /* for (int var_type_index = 0; ...) */
7158 /* Iterate through float/ int/ uint types.
7159 * Case: with initializer.
7161 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
7163 _supported_variable_types_map_const_iterator var_iterator =
7164 supported_variable_types_map.find(var_types_set[var_type_index]);
7166 if (var_iterator != supported_variable_types_map.end())
7168 for (size_t invalid_size_declarations_index = 0;
7169 invalid_size_declarations_index <
7170 sizeof(invalid_size_declarations) / sizeof(invalid_size_declarations[0]);
7171 invalid_size_declarations_index++)
7173 std::string shader_source;
7175 shader_source = "layout (std140) uniform MyUniform {\n";
7176 shader_source += " " + var_iterator->second.type +
7177 invalid_size_declarations[invalid_size_declarations_index] +
7178 " my_variable = " + array_initializers[var_type_index];
7180 var_iterator->second.type + invalid_size_declarations[invalid_size_declarations_index] +
7181 " my_variable = " + array_initializers[var_type_index];
7182 shader_source += "};\n\n";
7183 shader_source += shader_start;
7186 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
7189 this->execute_negative_test(tested_shader_type, shader_source);
7190 } /* for (int invalid_size_declarations_index = 0; ...) */
7191 } /* if var_type iterator found */
7194 TCU_FAIL("Type not found.");
7196 } /* for (int var_type_index = 0; ...) */
7199 /* Generates the shader source code for the InteractionStorageBuffers1
7200 * array tests, and attempts to compile each test shader, for both
7201 * vertex and fragment shaders.
7203 * @tparam API Tested API descriptor
7205 * @param tested_shader_type The type of shader that is being tested
7206 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
7208 template <class API>
7209 void InteractionStorageBuffers1<API>::test_shader_compilation(
7210 typename TestCaseBase<API>::TestShaderType tested_shader_type)
7212 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_FLOAT, VAR_TYPE_INT, VAR_TYPE_UINT };
7213 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
7215 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_FLOAT, VAR_TYPE_INT, VAR_TYPE_UINT,
7217 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
7219 const glcts::test_var_type* var_types_set = var_types_set_es;
7220 size_t num_var_types = num_var_types_es;
7222 if (API::USE_DOUBLE)
7224 var_types_set = var_types_set_gl;
7225 num_var_types = num_var_types_gl;
7228 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
7230 _supported_variable_types_map_const_iterator var_iterator =
7231 supported_variable_types_map.find(var_types_set[var_type_index]);
7233 if (var_iterator != supported_variable_types_map.end())
7235 std::string shader_source;
7237 shader_source += "buffer uBlocka {\n";
7238 shader_source += " " + var_iterator->second.type + " x[1][1][1][1][1][1];\n";
7239 shader_source += "};\n\n";
7240 shader_source += shader_start;
7243 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
7246 EXECUTE_POSITIVE_TEST(tested_shader_type, shader_source, true, false);
7247 } /* if var_type iterator found */
7250 TCU_FAIL("Type not found.");
7255 /* Generates the shader source code for the InteractionUniformBuffers2
7256 * array tests, and attempts to compile each test shader, for both
7257 * vertex and fragment shaders.
7259 * @tparam API Tested API descriptor
7261 * @param tested_shader_type The type of shader that is being tested
7262 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
7264 template <class API>
7265 void InteractionStorageBuffers2<API>::test_shader_compilation(
7266 typename TestCaseBase<API>::TestShaderType tested_shader_type)
7268 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_FLOAT, VAR_TYPE_INT, VAR_TYPE_UINT };
7269 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
7271 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_FLOAT, VAR_TYPE_INT, VAR_TYPE_UINT,
7273 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
7275 const glw::Functions& gl = this->context_id.getRenderContext().getFunctions();
7276 const glcts::test_var_type* var_types_set = var_types_set_es;
7277 size_t num_var_types = num_var_types_es;
7279 if (API::USE_DOUBLE)
7281 var_types_set = var_types_set_gl;
7282 num_var_types = num_var_types_gl;
7285 /* Iterate through float / int / uint values. */
7286 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
7288 _supported_variable_types_map_const_iterator var_iterator =
7289 supported_variable_types_map.find(var_types_set[var_type_index]);
7291 if (var_iterator != supported_variable_types_map.end())
7293 std::string uniform_definition;
7294 std::string uniform_use;
7296 uniform_definition += "layout (std140) buffer storage_block_name\n"
7298 uniform_definition += " ";
7299 uniform_definition += var_iterator->second.type;
7300 uniform_definition += " my_storage_1[1][1][1][1];\n"
7303 uniform_use = " float result = float(my_storage_1[0][0][0][0]);\n";
7305 if (API::USE_ALL_SHADER_STAGES)
7307 const std::string& compute_shader_source =
7308 this->prepare_compute_shader(tested_shader_type, uniform_definition, uniform_use);
7309 const std::string& fragment_shader_source =
7310 this->prepare_fragment_shader(tested_shader_type, uniform_definition, uniform_use);
7311 const std::string& geometry_shader_source =
7312 this->prepare_geometry_shader(tested_shader_type, uniform_definition, uniform_use);
7313 const std::string& tess_ctrl_shader_source =
7314 this->prepare_tess_ctrl_shader(tested_shader_type, uniform_definition, uniform_use);
7315 const std::string& tess_eval_shader_source =
7316 this->prepare_tess_eval_shader(tested_shader_type, uniform_definition, uniform_use);
7317 const std::string& vertex_shader_source =
7318 this->prepare_vertex_shader(tested_shader_type, uniform_definition, uniform_use);
7320 switch (tested_shader_type)
7322 case TestCaseBase<API>::VERTEX_SHADER_TYPE: /* Fall through */
7323 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
7324 this->execute_positive_test(vertex_shader_source, fragment_shader_source, false, false);
7327 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
7328 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
7329 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE: /* Fall through */
7330 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
7331 this->execute_positive_test(vertex_shader_source, tess_ctrl_shader_source, tess_eval_shader_source,
7332 geometry_shader_source, fragment_shader_source, compute_shader_source,
7337 TCU_FAIL("Invalid enum");
7343 const std::string& fragment_shader_source =
7344 this->prepare_fragment_shader(tested_shader_type, uniform_definition, uniform_use);
7345 const std::string& vertex_shader_source =
7346 this->prepare_vertex_shader(tested_shader_type, uniform_definition, uniform_use);
7348 this->execute_positive_test(vertex_shader_source, fragment_shader_source, false, false);
7351 glw::GLuint buffer_object_id = 0;
7352 glw::GLint my_storage_block_index = GL_INVALID_INDEX;
7354 gl.useProgram(this->program_object_id);
7355 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram() failed.");
7357 my_storage_block_index =
7358 gl.getProgramResourceIndex(this->program_object_id, GL_SHADER_STORAGE_BLOCK, "storage_block_name");
7359 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramResourceIndex() failed.");
7361 if ((unsigned)my_storage_block_index == GL_INVALID_INDEX)
7363 TCU_FAIL("Uniform block not found or is considered as not active.");
7366 gl.genBuffers(1, &buffer_object_id);
7367 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenBuffers() failed.");
7369 gl.bindBuffer(GL_SHADER_STORAGE_BUFFER, buffer_object_id);
7370 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer() failed.");
7372 switch (var_type_index)
7374 case 0: //float type of uniform is considered
7376 glw::GLfloat buffer_data[] = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f,
7377 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f };
7379 gl.bufferData(GL_SHADER_STORAGE_BUFFER, sizeof(buffer_data), buffer_data, GL_STATIC_DRAW);
7380 GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferData() failed.");
7384 case 1: //int type of uniform is considered
7387 glw::GLint buffer_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
7389 gl.bufferData(GL_SHADER_STORAGE_BUFFER, sizeof(buffer_data), buffer_data, GL_STATIC_DRAW);
7390 GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferData() failed.");
7394 case 2: //uint type of uniform is considered
7396 glw::GLuint buffer_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
7398 gl.bufferData(GL_SHADER_STORAGE_BUFFER, sizeof(buffer_data), buffer_data, GL_STATIC_DRAW);
7399 GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferData() failed.");
7403 case 3: //double type of uniform is considered
7405 glw::GLdouble buffer_data[] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0,
7406 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0 };
7408 gl.bufferData(GL_SHADER_STORAGE_BUFFER, sizeof(buffer_data), buffer_data, GL_STATIC_DRAW);
7409 GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferData() failed.");
7415 TCU_FAIL("Invalid variable-type index.");
7419 } /* switch (var_type_index) */
7421 gl.shaderStorageBlockBinding(this->program_object_id, my_storage_block_index, 0);
7422 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniformBlockBinding() failed.");
7424 gl.bindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, buffer_object_id);
7425 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBufferBase() failed.");
7427 if (TestCaseBase<API>::COMPUTE_SHADER_TYPE != tested_shader_type)
7429 execute_draw_test(tested_shader_type);
7433 execute_dispatch_test();
7436 /* Deallocate any resources used. */
7437 gl.deleteBuffers(1, &buffer_object_id);
7438 this->delete_objects();
7439 } /* if var_type iterator found */
7442 TCU_FAIL("Type not found.");
7444 } /* for (int var_type_index = 0; ...) */
7447 /** Executes test for compute program
7449 * @tparam API Tested API descriptor
7451 template <class API>
7452 void InteractionStorageBuffers2<API>::execute_dispatch_test()
7454 const glw::Functions& gl = this->context_id.getRenderContext().getFunctions();
7456 gl.dispatchCompute(1, 1, 1);
7457 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
7460 /** Executes test for draw program
7462 * @tparam API Tested API descriptor
7464 * @param tested_shader_type The type of shader that is being tested
7466 template <class API>
7467 void InteractionStorageBuffers2<API>::execute_draw_test(typename TestCaseBase<API>::TestShaderType tested_shader_type)
7469 const glw::Functions& gl = this->context_id.getRenderContext().getFunctions();
7471 glw::GLuint vao_id = 0;
7473 gl.genVertexArrays(1, &vao_id);
7474 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenVertexArrays() failed.");
7476 gl.bindVertexArray(vao_id);
7477 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray() failed.");
7479 switch (tested_shader_type)
7481 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
7482 case TestCaseBase<API>::VERTEX_SHADER_TYPE: /* Fall through */
7483 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
7484 gl.drawArrays(GL_POINTS, 0, 1);
7485 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
7488 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE: /* Fall through */
7489 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
7490 /* Tesselation patch set up */
7491 gl.patchParameteri(GL_PATCH_VERTICES, 1);
7492 GLU_EXPECT_NO_ERROR(gl.getError(), "PatchParameteri");
7494 gl.drawArrays(GL_PATCHES, 0, 1);
7495 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
7499 TCU_FAIL("Invalid enum");
7503 gl.deleteVertexArrays(1, &vao_id);
7504 GLU_EXPECT_NO_ERROR(gl.getError(), "glDeleteVertexArrays() failed.");
7507 /* Generates the shader source code for the InteractionUniformBuffers3
7508 * array tests, and attempts to compile each test shader, for both
7509 * vertex and fragment shaders.
7511 * @tparam API Tested API descriptor
7513 * @param tested_shader_type The type of shader that is being tested
7514 * (either TestCaseBase<API>::VERTEX_SHADER_TYPE or TestCaseBase<API>::FRAGMENT_SHADER_TYPE).
7516 template <class API>
7517 void InteractionStorageBuffers3<API>::test_shader_compilation(
7518 typename TestCaseBase<API>::TestShaderType tested_shader_type)
7520 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_FLOAT, VAR_TYPE_INT, VAR_TYPE_UINT };
7521 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
7523 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_FLOAT, VAR_TYPE_INT, VAR_TYPE_UINT,
7525 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
7527 const std::string invalid_size_declarations[] = { "[2][2][2][]", "[2][2][][2]", "[2][][2][2]", "[][2][2][2]",
7528 "[2][2][][]", "[2][][2][]", "[][2][2][]", "[2][][][2]",
7529 "[][2][][2]", "[][][2][2]", "[2][][][]", "[][2][][]",
7530 "[][][2][]", "[][][][2]", "[][][][]" };
7531 const std::string array_initializers[] = { "float[2][2][2][2](float[2][2][2](float[2][2](float[2](1.0, 2.0),"
7532 "float[2](3.0, 4.0)),"
7533 "float[2][2](float[2](5.0, 6.0),"
7534 "float[2](7.0, 8.0))),"
7535 "float[2][2][2](float[2][2](float[2](1.1, 2.1),"
7536 "float[2](3.1, 4.1)),"
7537 "float[2][2](float[2](5.1, 6.1),"
7538 "float[2](7.1, 8.1))));\n",
7540 "int[2][2][2][2](int[2][2][2](int[2][2](int[2]( 1, 2),"
7542 "int[2][2](int[2]( 5, 6),"
7544 "int[2][2][2](int[2][2](int[2](11, 12),"
7546 "int[2][2](int[2](15, 16),"
7547 "int[2](17, 18))));\n",
7549 "uint[2][2][2][2](uint[2][2][2](uint[2][2](uint[2]( 1u, 2u),"
7550 "uint[2]( 3u, 4u)),"
7551 "uint[2][2](uint[2]( 5u, 6u),"
7552 "uint[2]( 7u, 8u))),"
7553 "uint[2][2][2](uint[2][2](uint[2](11u, 12u),"
7554 "uint[2](13u, 14u)),"
7555 "uint[2][2](uint[2](15u, 16u),"
7556 "uint[2](17u, 18u))));\n",
7558 "double[2][2][2][2](double[2][2][2](double[2][2](double[2](1.0, 2.0),"
7559 "double[2](3.0, 4.0)),"
7560 "double[2][2](double[2](5.0, 6.0),"
7561 "double[2](7.0, 8.0))),"
7562 "double[2][2][2](double[2][2](double[2](1.1, 2.1),"
7563 "double[2](3.1, 4.1)),"
7564 "double[2][2](double[2](5.1, 6.1),"
7565 "double[2](7.1, 8.1))));\n" };
7566 const glcts::test_var_type* var_types_set = var_types_set_es;
7567 size_t num_var_types = num_var_types_es;
7569 if (API::USE_DOUBLE)
7571 var_types_set = var_types_set_gl;
7572 num_var_types = num_var_types_gl;
7575 /* Iterate through float/ int/ uint types.
7576 * Case: without initializer.
7578 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
7580 _supported_variable_types_map_const_iterator var_iterator =
7581 supported_variable_types_map.find(var_types_set[var_type_index]);
7583 if (var_iterator != supported_variable_types_map.end())
7585 for (size_t invalid_size_declarations_index = 0;
7586 invalid_size_declarations_index <
7587 sizeof(invalid_size_declarations) / sizeof(invalid_size_declarations[0]);
7588 invalid_size_declarations_index++)
7590 std::string shader_source;
7592 shader_source = "layout (std140) buffer MyStorage {\n";
7593 shader_source += " " + var_iterator->second.type +
7594 invalid_size_declarations[invalid_size_declarations_index] + " my_variable;\n";
7595 shader_source += "};\n\n";
7596 shader_source += shader_start;
7599 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
7602 EXECUTE_SHADER_TEST(API::ALLOW_UNSIZED_DECLARATION && invalid_size_declarations_index == 3,
7603 tested_shader_type, shader_source);
7604 } /* for (int invalid_size_declarations_index = 0; ...) */
7608 TCU_FAIL("Type not found.");
7610 } /* for (int var_type_index = 0; ...) */
7612 /* Iterate through float/ int/ uint types.
7613 * Case: with initializer.
7615 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
7617 _supported_variable_types_map_const_iterator var_iterator =
7618 supported_variable_types_map.find(var_types_set[var_type_index]);
7620 if (var_iterator != supported_variable_types_map.end())
7622 for (size_t invalid_size_declarations_index = 0;
7623 invalid_size_declarations_index <
7624 sizeof(invalid_size_declarations) / sizeof(invalid_size_declarations[0]);
7625 invalid_size_declarations_index++)
7627 std::string shader_source;
7629 shader_source = "layout (std140) buffer MyStorage {\n";
7630 shader_source += " " + var_iterator->second.type +
7631 invalid_size_declarations[invalid_size_declarations_index] +
7632 " my_variable = " + array_initializers[var_type_index];
7634 var_iterator->second.type + invalid_size_declarations[invalid_size_declarations_index] +
7635 " my_variable = " + array_initializers[var_type_index];
7636 shader_source += "};\n\n";
7637 shader_source += shader_start;
7640 DEFAULT_MAIN_ENDING(tested_shader_type, shader_source);
7643 this->execute_negative_test(tested_shader_type, shader_source);
7644 } /* for (int invalid_size_declarations_index = 0; ...) */
7645 } /* if var_type iterator found */
7648 TCU_FAIL("Type not found.");
7650 } /* for (int var_type_index = 0; ...) */
7653 /* Generates the shader source code for the InteractionInterfaceArrays1
7654 * array test, and attempts to compile the test shader.
7656 * @tparam API Tested API descriptor
7658 * @param tested_shader_type The type of shader that is being tested.
7660 template <class API>
7661 void InteractionInterfaceArrays1<API>::test_shader_compilation(
7662 typename TestCaseBase<API>::TestShaderType tested_shader_type)
7664 /* Shader source with invalid buffer (buffer cannot be of arrays of arrays type). */
7665 const std::string invalid_buffer_shader_source = "layout(std140) buffer MyBuffer\n"
7670 "} myBuffers[2][2];\n\n"
7674 /* Verify that buffer arrays of arrays type is rejected. */
7676 std::string source = invalid_buffer_shader_source;
7678 DEFAULT_MAIN_ENDING(tested_shader_type, source);
7680 EXECUTE_SHADER_TEST(API::ALLOW_A_OF_A_ON_INTERFACE_BLOCKS, tested_shader_type, source);
7684 /* Generates the shader source code for the InteractionInterfaceArrays2
7685 * array test, and attempts to compile the test shader.
7687 * @tparam API Tested API descriptor
7689 * @param input_shader_type The type of shader that is being tested.
7691 template <class API>
7692 void InteractionInterfaceArrays2<API>::test_shader_compilation(
7693 typename TestCaseBase<API>::TestShaderType input_shader_type)
7695 /* Shader source with invalid input (input cannot be of arrays of arrays type). */
7696 const std::string input_variable_shader_source[] = { "in float inout_variable", "[2][2];\n"
7702 " = inout_variable", "[0][0];\n" };
7703 /* Shader source with invalid output (output cannot be of arrays of arrays type). */
7704 const std::string output_variable_shader_source[] = { "out float inout_variable",
7715 "[1][1] = 3.0;\n" };
7717 const typename TestCaseBase<API>::TestShaderType& output_shader_type =
7718 this->get_output_shader_type(input_shader_type);
7719 std::string input_source;
7720 std::string output_source;
7722 this->prepare_sources(input_shader_type, output_shader_type, input_variable_shader_source,
7723 output_variable_shader_source, input_source, output_source);
7725 /* Verify that INPUTs and OUTPUTs arrays of arrays type is rejected. */
7726 if (TestCaseBase<API>::COMPUTE_SHADER_TYPE != input_shader_type)
7728 if (API::ALLOW_A_OF_A_ON_INTERFACE_BLOCKS)
7731 if (API::USE_ALL_SHADER_STAGES)
7733 const std::string& compute_shader_source = empty_string;
7734 const std::string& fragment_shader_source =
7735 this->prepare_fragment_shader(input_shader_type, input_source, output_source);
7736 const std::string& geometry_shader_source =
7737 this->prepare_geometry_shader(input_shader_type, input_source, output_source);
7738 const std::string& tess_ctrl_shader_source =
7739 this->prepare_tess_ctrl_shader_source(input_shader_type, input_source, output_source);
7740 const std::string& tess_eval_shader_source =
7741 this->prepare_tess_eval_shader_source(input_shader_type, input_source, output_source);
7742 const std::string& vertex_shader_source =
7743 this->prepare_vertex_shader(input_shader_type, input_source, output_source);
7745 this->execute_positive_test(vertex_shader_source, tess_ctrl_shader_source, tess_eval_shader_source,
7746 geometry_shader_source, fragment_shader_source, compute_shader_source, true,
7751 const std::string& fragment_shader_source =
7752 this->prepare_fragment_shader(input_shader_type, input_source, output_source);
7753 const std::string& vertex_shader_source =
7754 this->prepare_vertex_shader(input_shader_type, input_source, output_source);
7756 this->execute_positive_test(vertex_shader_source, fragment_shader_source, true, false);
7761 this->execute_negative_test(input_shader_type, input_source);
7762 this->execute_negative_test(output_shader_type, output_source);
7767 /** Gets the shader type to test for the outputs
7769 * @tparam API Tested API descriptor
7771 * @param input_shader_type The type of input shader that is being tested
7773 template <class API>
7774 const typename TestCaseBase<API>::TestShaderType InteractionInterfaceArrays2<API>::get_output_shader_type(
7775 const typename TestCaseBase<API>::TestShaderType& input_shader_type)
7777 switch (input_shader_type)
7779 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
7780 return TestCaseBase<API>::FRAGMENT_SHADER_TYPE;
7782 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
7783 if (API::USE_ALL_SHADER_STAGES)
7785 return TestCaseBase<API>::GEOMETRY_SHADER_TYPE;
7789 return TestCaseBase<API>::VERTEX_SHADER_TYPE;
7792 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
7795 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
7796 return TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE;
7798 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
7799 return TestCaseBase<API>::VERTEX_SHADER_TYPE;
7801 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
7802 return TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE;
7805 TCU_FAIL("Unrecognized shader type.");
7809 return input_shader_type;
7812 /** Prepare fragment shader
7814 * @tparam API Tested API descriptor
7816 * @param input_shader_type The type of input shader that is being tested
7817 * @param input_source Shader in case we want to test inputs for this shader
7818 * @param output_source Shader in case we want to test outputs for this shader
7820 template <class API>
7821 const std::string InteractionInterfaceArrays2<API>::prepare_fragment_shader(
7822 const typename TestCaseBase<API>::TestShaderType& input_shader_type, const std::string& input_source,
7823 const std::string& output_source)
7825 switch (input_shader_type)
7827 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
7828 return output_source;
7830 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
7831 return input_source;
7833 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
7834 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
7835 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
7836 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
7840 TCU_FAIL("Unrecognized shader type.");
7844 return default_fragment_shader_source;
7847 /** Prepare geometry shader
7849 * @tparam API Tested API descriptor
7851 * @param input_shader_type The type of input shader that is being tested
7852 * @param input_source Shader in case we want to test inputs for this shader
7853 * @param output_source Shader in case we want to test outputs for this shader
7855 template <class API>
7856 const std::string InteractionInterfaceArrays2<API>::prepare_geometry_shader(
7857 const typename TestCaseBase<API>::TestShaderType& input_shader_type, const std::string& input_source,
7858 const std::string& output_source)
7860 switch (input_shader_type)
7862 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
7863 if (API::USE_ALL_SHADER_STAGES)
7865 return output_source;
7869 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
7870 return input_source;
7872 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
7873 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
7874 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
7875 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
7879 TCU_FAIL("Unrecognized shader type.");
7883 return default_geometry_shader_source;
7886 /** Prepare tessellation control shader
7888 * @tparam API Tested API descriptor
7890 * @param input_shader_type The type of input shader that is being tested
7891 * @param input_source Shader in case we want to test inputs for this shader
7892 * @param output_source Shader in case we want to test outputs for this shader
7894 template <class API>
7895 const std::string InteractionInterfaceArrays2<API>::prepare_tess_ctrl_shader_source(
7896 const typename TestCaseBase<API>::TestShaderType& input_shader_type, const std::string& input_source,
7897 const std::string& output_source)
7899 switch (input_shader_type)
7901 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
7902 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
7903 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
7904 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
7907 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
7908 return input_source;
7910 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
7911 return output_source;
7914 TCU_FAIL("Unrecognized shader type.");
7918 return default_tc_shader_source;
7921 /** Prepare tessellation evaluation shader
7923 * @tparam API Tested API descriptor
7925 * @param input_shader_type The type of input shader that is being tested
7926 * @param input_source Shader in case we want to test inputs for this shader
7927 * @param output_source Shader in case we want to test outputs for this shader
7929 template <class API>
7930 const std::string InteractionInterfaceArrays2<API>::prepare_tess_eval_shader_source(
7931 const typename TestCaseBase<API>::TestShaderType& input_shader_type, const std::string& input_source,
7932 const std::string& output_source)
7934 switch (input_shader_type)
7936 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
7937 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
7938 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
7939 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
7942 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
7943 return output_source;
7945 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
7946 return input_source;
7949 TCU_FAIL("Unrecognized shader type.");
7953 return default_te_shader_source;
7956 /** Prepare vertex shader
7958 * @tparam API Tested API descriptor
7960 * @param input_shader_type The type of input shader that is being tested
7961 * @param input_source Shader in case we want to test inputs for this shader
7962 * @param output_source Shader in case we want to test outputs for this shader
7964 template <class API>
7965 const std::string InteractionInterfaceArrays2<API>::prepare_vertex_shader(
7966 const typename TestCaseBase<API>::TestShaderType& input_shader_type, const std::string& input_source,
7967 const std::string& output_source)
7969 switch (input_shader_type)
7971 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
7972 return input_source;
7974 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
7975 if (!API::USE_ALL_SHADER_STAGES)
7977 return output_source;
7981 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
7982 return output_source;
7984 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
7985 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
7986 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
7990 TCU_FAIL("Unrecognized shader type.");
7994 return default_vertex_shader_source;
7997 /** Prepare the inputs and outputs shaders
7999 * @tparam API Tested API descriptor
8001 * @param input_shader_type The type of input shader that is being tested
8002 * @param output_shader_type The type of output shader that is being tested
8003 * @param input_shader_source Snippet used to prepare the input shader
8004 * @param output_shader_source Snippet used to prepare the output shader
8005 * @param input_source Resulting input shader
8006 * @param output_source Resulting output shader
8008 template <class API>
8009 void InteractionInterfaceArrays2<API>::prepare_sources(
8010 const typename TestCaseBase<API>::TestShaderType& input_shader_type,
8011 const typename TestCaseBase<API>::TestShaderType& output_shader_type, const std::string* input_shader_source,
8012 const std::string* output_shader_source, std::string& input_source, std::string& output_source)
8014 if (TestCaseBase<API>::COMPUTE_SHADER_TYPE != input_shader_type)
8016 input_source += input_shader_source[0];
8017 output_source += output_shader_source[0];
8019 if ((TestCaseBase<API>::GEOMETRY_SHADER_TYPE == input_shader_type) ||
8020 (TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE == input_shader_type) ||
8021 (TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE == input_shader_type))
8023 input_source += "[]";
8026 if (TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE == output_shader_type)
8028 output_source += "[]";
8031 input_source += input_shader_source[1];
8032 output_source += output_shader_source[1];
8034 if (TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE == input_shader_type)
8036 input_source += "[]";
8039 if (TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE == output_shader_type)
8041 output_source += "[gl_InvocationID]";
8044 input_source += input_shader_source[2];
8045 output_source += output_shader_source[2];
8047 if (TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE == input_shader_type)
8049 input_source += "[gl_InvocationID]";
8052 if (TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE == output_shader_type)
8054 output_source += "[gl_InvocationID]";
8057 input_source += input_shader_source[3];
8058 output_source += output_shader_source[3];
8060 if ((TestCaseBase<API>::GEOMETRY_SHADER_TYPE == input_shader_type) ||
8061 (TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE == input_shader_type))
8063 input_source += "[0]";
8066 if (TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE == input_shader_type)
8068 input_source += "[gl_InvocationID]";
8071 if (TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE == output_shader_type)
8073 output_source += "[gl_InvocationID]";
8076 input_source += input_shader_source[4];
8077 output_source += output_shader_source[4];
8079 if (TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE == output_shader_type)
8081 output_source += "[gl_InvocationID]";
8084 output_source += output_shader_source[5];
8086 DEFAULT_MAIN_ENDING(input_shader_type, input_source);
8087 DEFAULT_MAIN_ENDING(output_shader_type, output_source);
8091 /* Generates the shader source code for the InteractionInterfaceArrays3
8092 * array test, and attempts to compile the test shader.
8094 * @tparam API Tested API descriptor
8096 * @param tested_shader_type The type of shader that is being tested.
8098 template <class API>
8099 void InteractionInterfaceArrays3<API>::test_shader_compilation(
8100 typename TestCaseBase<API>::TestShaderType tested_shader_type)
8102 /* Shader source with invalid uniform block (uniform block cannot be of arrays of arrays type). */
8103 const std::string invalid_uniform_block_shader_source = "layout(std140) uniform MyUniformBlock\n"
8108 "} myUniformBlocks[2][2];\n\n"
8112 /* Verify that uniform block arrays of arrays type is rejected. */
8114 std::string source = invalid_uniform_block_shader_source;
8116 DEFAULT_MAIN_ENDING(tested_shader_type, source);
8118 EXECUTE_SHADER_TEST(API::ALLOW_A_OF_A_ON_INTERFACE_BLOCKS, tested_shader_type, source);
8122 /* Generates the shader source code for the InteractionInterfaceArrays4
8123 * array test, and attempts to compile the test shader.
8125 * @tparam API Tested API descriptor
8127 * @param input_shader_type The type of shader that is being tested.
8129 template <class API>
8130 void InteractionInterfaceArrays4<API>::test_shader_compilation(
8131 typename TestCaseBase<API>::TestShaderType input_shader_type)
8133 /* Shader source with invalid input (input cannot be of arrays of arrays type). */
8134 const std::string input_block_shader_source[] = { "in InOutBlock {\n"
8135 " float inout_variable;\n"
8143 " = inout_block", "[0][0].inout_variable;\n" };
8144 /* Shader source with invalid output (output cannot be of arrays of arrays type). */
8145 const std::string output_block_shader_source[] = { "out InOutBlock {\n"
8146 " float inout_variable;\n"
8153 "[0][0].inout_variable = 0.0;\n"
8155 "[0][1].inout_variable = 1.0;\n"
8157 "[1][0].inout_variable = 2.0;\n"
8159 "[1][1].inout_variable = 3.0;\n" };
8161 const typename TestCaseBase<API>::TestShaderType& output_shader_type =
8162 this->get_output_shader_type(input_shader_type);
8163 std::string input_source;
8164 std::string output_source;
8166 this->prepare_sources(input_shader_type, output_shader_type, input_block_shader_source, output_block_shader_source,
8167 input_source, output_source);
8169 /* Verify that INPUTs and OUTPUTs arrays of arrays type is rejected. */
8170 if ((TestCaseBase<API>::VERTEX_SHADER_TYPE != input_shader_type) &&
8171 (TestCaseBase<API>::COMPUTE_SHADER_TYPE != input_shader_type))
8173 if (API::ALLOW_A_OF_A_ON_INTERFACE_BLOCKS && API::ALLOW_IN_OUT_INTERFACE_BLOCKS)
8176 if (API::USE_ALL_SHADER_STAGES)
8178 const std::string& compute_shader_source = empty_string;
8179 const std::string& fragment_shader_source =
8180 this->prepare_fragment_shader(input_shader_type, input_source, output_source);
8181 const std::string& geometry_shader_source =
8182 this->prepare_geometry_shader(input_shader_type, input_source, output_source);
8183 const std::string& tess_ctrl_shader_source =
8184 this->prepare_tess_ctrl_shader_source(input_shader_type, input_source, output_source);
8185 const std::string& tess_eval_shader_source =
8186 this->prepare_tess_eval_shader_source(input_shader_type, input_source, output_source);
8187 const std::string& vertex_shader_source =
8188 this->prepare_vertex_shader(input_shader_type, input_source, output_source);
8190 this->execute_positive_test(vertex_shader_source, tess_ctrl_shader_source, tess_eval_shader_source,
8191 geometry_shader_source, fragment_shader_source, compute_shader_source, true,
8196 const std::string& fragment_shader_source =
8197 this->prepare_fragment_shader(input_shader_type, input_source, output_source);
8198 const std::string& vertex_shader_source =
8199 this->prepare_vertex_shader(input_shader_type, input_source, output_source);
8201 this->execute_positive_test(vertex_shader_source, fragment_shader_source, true, false);
8206 this->execute_negative_test(input_shader_type, input_source);
8207 this->execute_negative_test(output_shader_type, output_source);
8212 /** Calulate smallest denominator for values over 1
8214 * @param value Value in question
8216 * @return Smallest denominator
8218 size_t findSmallestDenominator(const size_t value)
8221 for (size_t i = 2; i < value; ++i)
8232 /** Check if left is bigger than right
8234 * @tparam T Type of values
8236 * @param l Left value
8237 * @param r Right value
8239 * @return true if l > r, false otherwise
8242 bool more(const T& l, const T& r)
8247 /** Prepare dimensions of array with given number of entries
8249 * @tparam API Tested API descriptor
8251 * @param n_entries Number of entries
8252 * @param dimensions Storage for dimesnions
8254 template <class API>
8255 void prepareDimensions(size_t n_entries, std::vector<size_t>& dimensions)
8257 if (dimensions.empty())
8260 const size_t last = dimensions.size() - 1;
8263 for (size_t i = 0; i < last; ++i)
8265 const size_t denom = findSmallestDenominator(n_entries);
8269 dimensions[i] = denom;
8272 dimensions[last] = n_entries;
8275 std::sort(dimensions.begin(), dimensions.end(), more<size_t>);
8278 /* Generates the shader source code for the AtomicDeclarationTest
8279 * and attempts to compile each shader
8281 * @tparam API Tested API descriptor
8283 * @param tested_shader_type The type of shader that is being tested
8285 template <class API>
8286 void AtomicDeclarationTest<API>::test_shader_compilation(typename TestCaseBase<API>::TestShaderType tested_shader_type)
8288 static const char* indent_step = " ";
8289 static const char* uniform_atomic_uint = "layout(binding = 0) uniform atomic_uint";
8291 const glw::Functions& gl = this->context_id.getRenderContext().getFunctions();
8293 std::string comment;
8294 std::vector<size_t> dimensions;
8296 std::string indexing;
8297 std::string invalid_definition = uniform_atomic_uint;
8298 std::string invalid_iteration;
8299 std::string invalid_shader_source;
8300 std::string loop_end;
8301 glw::GLint max_atomics = 0;
8302 glw::GLenum pname = 0;
8303 std::string valid_shader_source;
8304 std::string valid_definition = uniform_atomic_uint;
8305 std::string valid_iteration;
8307 /* Select pname of max for stage */
8308 switch (tested_shader_type)
8310 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
8311 pname = GL_MAX_COMPUTE_ATOMIC_COUNTERS;
8313 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
8314 pname = GL_MAX_FRAGMENT_ATOMIC_COUNTERS;
8316 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
8317 pname = GL_MAX_GEOMETRY_ATOMIC_COUNTERS;
8319 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
8320 pname = GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS;
8322 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
8323 pname = GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS;
8325 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
8326 pname = GL_MAX_VERTEX_ATOMIC_COUNTERS;
8329 TCU_FAIL("Invalid enum");
8334 gl.getIntegerv(pname, &max_atomics);
8335 GLU_EXPECT_NO_ERROR(gl.getError(), "GetIntegerv");
8337 if (0 == max_atomics)
8339 /* Not supported - skip */
8344 dimensions.resize(API::MAX_ARRAY_DIMENSIONS);
8345 prepareDimensions<API>(max_atomics, dimensions);
8348 /* Prepare parts of shader */
8349 for (size_t i = API::MAX_ARRAY_DIMENSIONS; i != 0; --i)
8354 indent += indent_step;
8356 loop_end.insert(0, "}\n");
8357 loop_end.insert(0, indent);
8359 sprintf(it, "i%u", (unsigned int)(API::MAX_ARRAY_DIMENSIONS - i));
8365 sprintf(max, "%u", (unsigned int)(dimensions[i - 1]));
8367 valid_definition += "[";
8368 valid_definition += max;
8369 valid_definition += "]";
8371 valid_iteration += indent;
8372 valid_iteration += "for (uint ";
8373 valid_iteration += it;
8374 valid_iteration += " = 0; ";
8375 valid_iteration += it;
8376 valid_iteration += " < ";
8377 valid_iteration += max;
8378 valid_iteration += "; ++";
8379 valid_iteration += it;
8380 valid_iteration += ")\n";
8381 valid_iteration += indent;
8382 valid_iteration += "{\n";
8386 sprintf(max, "%u", (unsigned int)(dimensions[i - 1] + 1));
8388 invalid_definition += "[";
8389 invalid_definition += max;
8390 invalid_definition += "]";
8392 invalid_iteration += indent;
8393 invalid_iteration += "for (uint ";
8394 invalid_iteration += it;
8395 invalid_iteration += " = 0; ";
8396 invalid_iteration += it;
8397 invalid_iteration += " < ";
8398 invalid_iteration += max;
8399 invalid_iteration += "; ++";
8400 invalid_iteration += it;
8401 invalid_iteration += ")\n";
8402 invalid_iteration += indent;
8403 invalid_iteration += "{\n";
8409 sprintf(max, "%u", (unsigned int)(max_atomics));
8410 comment += "/* MAX_*_ATOMIC_COUNTERS = ";
8415 /* Prepare invalid source */
8416 invalid_shader_source += comment;
8417 invalid_shader_source += invalid_definition;
8418 invalid_shader_source += " a;\n\nvoid main()\n{\n";
8419 invalid_shader_source += invalid_iteration;
8420 invalid_shader_source += indent;
8421 invalid_shader_source += indent_step;
8422 invalid_shader_source += "atomicCounterIncrement( a";
8423 invalid_shader_source += indexing;
8424 invalid_shader_source += " );\n";
8425 invalid_shader_source += loop_end;
8427 /* Prepare valid source */
8428 valid_shader_source += comment;
8429 valid_shader_source += valid_definition;
8430 valid_shader_source += " a;\n\nvoid main()\n{\n";
8431 valid_shader_source += valid_iteration;
8432 valid_shader_source += indent;
8433 valid_shader_source += indent_step;
8434 valid_shader_source += "atomicCounterIncrement( a";
8435 valid_shader_source += indexing;
8436 valid_shader_source += " );\n";
8437 valid_shader_source += loop_end;
8440 DEFAULT_MAIN_ENDING(tested_shader_type, invalid_shader_source);
8441 DEFAULT_MAIN_ENDING(tested_shader_type, valid_shader_source);
8444 EXECUTE_POSITIVE_TEST(tested_shader_type, valid_shader_source, true, false);
8446 /* Expect build failure for invalid shader source */
8448 bool negative_build_test_result = false;
8452 EXECUTE_POSITIVE_TEST(tested_shader_type, invalid_shader_source, true, false);
8456 negative_build_test_result = true;
8459 if (false == negative_build_test_result)
8461 TCU_FAIL("It was expected that build process will fail");
8466 /* Generates the shader source code for the AtomicUsageTest
8467 * and attempts to compile each shader
8469 * @tparam API Tested API descriptor
8471 * @param tested_shader_type The type of shader that is being tested
8473 template <class API>
8474 void AtomicUsageTest<API>::test_shader_compilation(typename TestCaseBase<API>::TestShaderType tested_shader_type)
8476 const glw::Functions& gl = this->context_id.getRenderContext().getFunctions();
8478 glw::GLint max_atomics = 0;
8479 glw::GLint max_bindings = 0;
8480 glw::GLint max_size = 0;
8481 glw::GLenum pname = 0;
8483 /* Select pname of max for stage */
8484 switch (tested_shader_type)
8486 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
8487 pname = GL_MAX_COMPUTE_ATOMIC_COUNTERS;
8489 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
8490 pname = GL_MAX_FRAGMENT_ATOMIC_COUNTERS;
8492 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
8493 pname = GL_MAX_GEOMETRY_ATOMIC_COUNTERS;
8495 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
8496 pname = GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS;
8498 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
8499 pname = GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS;
8501 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
8502 pname = GL_MAX_VERTEX_ATOMIC_COUNTERS;
8505 TCU_FAIL("Invalid enum");
8510 gl.getIntegerv(pname, &max_atomics);
8511 GLU_EXPECT_NO_ERROR(gl.getError(), "GetIntegerv");
8513 gl.getIntegerv(GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS, &max_bindings);
8514 GLU_EXPECT_NO_ERROR(gl.getError(), "GetIntegerv");
8516 gl.getIntegerv(GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE, &max_size);
8517 GLU_EXPECT_NO_ERROR(gl.getError(), "GetIntegerv");
8519 if (0 == max_atomics)
8521 /* Not supported - skip */
8525 const glw::GLuint last_binding = (glw::GLuint)max_bindings - 1;
8526 const glw::GLuint offset = (glw::GLuint)max_size / 2;
8527 glw::GLuint n_entries =
8528 std::min((glw::GLuint)(max_size - offset) / (glw::GLuint)sizeof(glw::GLuint), (glw::GLuint)max_atomics);
8530 if (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type)
8532 glw::GLint max_uniform_locations = 0;
8534 gl.getIntegerv(GL_MAX_UNIFORM_LOCATIONS, &max_uniform_locations);
8535 GLU_EXPECT_NO_ERROR(gl.getError(), "GetIntegerv");
8537 max_atomics = std::min(max_atomics, (max_uniform_locations - 1));
8538 n_entries = (glw::GLuint)std::min((glw::GLint)n_entries, (max_uniform_locations - 1));
8541 execute(tested_shader_type, last_binding, 0 /* offset */, max_atomics);
8542 execute(tested_shader_type, last_binding, offset, n_entries);
8545 /* Generates the shader source code for the AtomicUsageTest
8546 * and attempts to compile each shader
8548 * @tparam API Tested API descriptor
8550 * @param tested_shader_type The type of shader that is being tested
8551 * @param binding Binding index
8552 * @param offset Offset of data
8553 * @param n_entries Number of entries in array
8555 template <class API>
8556 void AtomicUsageTest<API>::execute(typename TestCaseBase<API>::TestShaderType tested_shader_type, glw::GLuint binding,
8557 glw::GLuint offset, glw::GLuint n_entries)
8559 static const char* indent_step = " ";
8560 static const char* layout_binding = "layout(binding = ";
8561 static const char* layout_offset = ", offset = ";
8562 static const char* uniform_atomic_uint = ") uniform atomic_uint";
8564 const glw::Functions& gl = this->context_id.getRenderContext().getFunctions();
8566 std::string comment;
8567 std::vector<size_t> dimensions;
8569 std::string indexing;
8570 std::string loop_end;
8572 std::string valid_shader_source;
8573 std::string valid_definition = layout_binding;
8574 std::string valid_iteration;
8575 std::string varying_definition;
8577 dimensions.resize(API::MAX_ARRAY_DIMENSIONS);
8578 prepareDimensions<API>(n_entries, dimensions);
8580 /* Prepare parts of shader */
8582 /* Append binding */
8585 sprintf(buffer, "%u", static_cast<unsigned int>(binding));
8586 valid_definition += buffer;
8587 valid_definition += layout_offset;
8588 sprintf(buffer, "%u", static_cast<unsigned int>(offset));
8589 valid_definition += buffer;
8590 valid_definition += uniform_atomic_uint;
8593 for (size_t i = API::MAX_ARRAY_DIMENSIONS; i != 0; --i)
8598 indent += indent_step;
8600 loop_end.insert(0, "}\n");
8601 loop_end.insert(0, indent);
8603 sprintf(it, "i%u", (unsigned int)(API::MAX_ARRAY_DIMENSIONS - i));
8609 sprintf(max, "%u", (unsigned int)(dimensions[i - 1]));
8610 valid_definition += "[";
8611 valid_definition += max;
8612 valid_definition += "]";
8614 valid_iteration += indent;
8615 valid_iteration += "for (uint ";
8616 valid_iteration += it;
8617 valid_iteration += " = 0; ";
8618 valid_iteration += it;
8619 valid_iteration += " < ";
8620 valid_iteration += max;
8621 valid_iteration += "; ++";
8622 valid_iteration += it;
8623 valid_iteration += ")\n";
8624 valid_iteration += indent;
8625 valid_iteration += "{\n";
8631 sprintf(max, "%u", (unsigned int)(n_entries));
8632 comment += "/* Number of atomic counters = ";
8637 /* Select varyings and result */
8638 switch (tested_shader_type)
8640 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
8641 result = " imageStore(uni_image, ivec2(gl_GlobalInvocationID.xy), vec4(result, 0, 0, 0));\n";
8642 varying_definition = "writeonly uniform image2D uni_image;\n"
8646 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
8647 result = " color = vec4(result);\n";
8648 varying_definition = "out vec4 color;\n"
8652 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
8653 result = " gl_Position = vec4(-1, -1, 0, 1);\n"
8654 " fs_result = result;\n"
8656 " gl_Position = vec4(-1, 1, 0, 1);\n"
8657 " fs_result = result;\n"
8659 " gl_Position = vec4(1, -1, 0, 1);\n"
8660 " fs_result = result;\n"
8662 " gl_Position = vec4(1, 1, 0, 1);\n"
8663 " fs_result = result;\n"
8665 varying_definition = "out float fs_result;\n"
8669 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
8670 result = " tcs_result[gl_InvocationID] = result;\n"
8672 " gl_TessLevelOuter[0] = 1.0;\n"
8673 " gl_TessLevelOuter[1] = 1.0;\n"
8674 " gl_TessLevelOuter[2] = 1.0;\n"
8675 " gl_TessLevelOuter[3] = 1.0;\n"
8676 " gl_TessLevelInner[0] = 1.0;\n"
8677 " gl_TessLevelInner[1] = 1.0;\n";
8678 varying_definition = "out float tcs_result[];\n"
8682 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
8683 result = " fs_result = result;\n";
8684 varying_definition = "out float fs_result;\n"
8688 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
8689 result = " fs_result = result;\n";
8690 varying_definition = "out float fs_result;\n"
8695 TCU_FAIL("Invalid enum");
8699 /* Prepare valid source */
8700 valid_shader_source += varying_definition;
8701 valid_shader_source += comment;
8702 valid_shader_source += valid_definition;
8703 valid_shader_source += " a;\n\nvoid main()\n{\n uint sum = 0u;\n";
8704 valid_shader_source += valid_iteration;
8705 valid_shader_source += indent;
8706 valid_shader_source += indent_step;
8707 valid_shader_source += "sum += atomicCounterIncrement( a";
8708 valid_shader_source += indexing;
8709 valid_shader_source += " );\n";
8710 valid_shader_source += loop_end;
8711 valid_shader_source += "\n"
8712 " float result = 0.0;\n"
8718 valid_shader_source += result;
8719 valid_shader_source += shader_end;
8723 const std::string* cs = &empty_string;
8724 const std::string* vs = &default_vertex_shader_source;
8725 const std::string* tcs = &empty_string;
8726 const std::string* tes = &empty_string;
8727 const std::string* gs = &empty_string;
8728 const std::string* fs = &pass_fragment_shader_source;
8730 switch (tested_shader_type)
8732 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
8733 cs = &valid_shader_source;
8738 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
8739 fs = &valid_shader_source;
8742 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
8743 gs = &valid_shader_source;
8746 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
8747 tcs = &valid_shader_source;
8748 tes = &pass_te_shader_source;
8751 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
8752 tcs = &default_tc_shader_source;
8753 tes = &valid_shader_source;
8756 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
8757 vs = &valid_shader_source;
8761 TCU_FAIL("Invalid enum");
8765 if (API::USE_ALL_SHADER_STAGES)
8767 this->execute_positive_test(*vs, *tcs, *tes, *gs, *fs, *cs, false, false);
8771 this->execute_positive_test(*vs, *fs, false, false);
8775 gl.useProgram(this->program_object_id);
8776 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram() failed.");
8778 /* Prepare buffer */
8779 glw::GLuint buffer_object_id = 0;
8780 std::vector<glw::GLuint> buffer_data;
8781 const size_t start_pos = offset / 4;
8782 const size_t last_pos = start_pos + n_entries;
8783 const size_t buffer_data_size = last_pos * sizeof(glw::GLuint);
8785 gl.genBuffers(1, &buffer_object_id);
8786 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenBuffers() failed.");
8788 gl.bindBuffer(GL_ATOMIC_COUNTER_BUFFER, buffer_object_id);
8789 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer() failed.");
8791 buffer_data.resize(start_pos + n_entries);
8792 for (size_t i = 0; i < n_entries; ++i)
8794 buffer_data[start_pos + i] = (glw::GLuint)i;
8797 gl.bufferData(GL_ATOMIC_COUNTER_BUFFER, buffer_data_size, &buffer_data[0], GL_STATIC_DRAW);
8798 GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferData() failed.");
8800 gl.bindBufferBase(GL_ATOMIC_COUNTER_BUFFER, binding, buffer_object_id);
8801 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBufferBase() failed.");
8804 if (TestCaseBase<API>::COMPUTE_SHADER_TYPE != tested_shader_type)
8806 glw::GLuint framebuffer_object_id = 0;
8807 glw::GLuint texture_object_id = 0;
8808 glw::GLuint vao_id = 0;
8810 gl.genTextures(1, &texture_object_id);
8811 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures() failed.");
8813 gl.bindTexture(GL_TEXTURE_2D, texture_object_id);
8814 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture() failed.");
8816 gl.texStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 1, 1);
8817 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage2D() failed.");
8819 gl.genFramebuffers(1, &framebuffer_object_id);
8820 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers() failed.");
8822 gl.bindFramebuffer(GL_FRAMEBUFFER, framebuffer_object_id);
8823 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer() failed.");
8825 gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_object_id, 0);
8826 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferTexture2D() failed.");
8828 gl.viewport(0, 0, 1, 1);
8829 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport() failed.");
8831 gl.genVertexArrays(1, &vao_id);
8832 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenVertexArrays() failed.");
8834 gl.bindVertexArray(vao_id);
8835 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray() failed.");
8837 switch (tested_shader_type)
8839 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
8840 case TestCaseBase<API>::VERTEX_SHADER_TYPE: /* Fall through */
8841 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
8842 gl.drawArrays(GL_POINTS, 0, 1);
8843 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
8846 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE: /* Fall through */
8847 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
8848 /* Tesselation patch set up */
8849 gl.patchParameteri(GL_PATCH_VERTICES, 1);
8850 GLU_EXPECT_NO_ERROR(gl.getError(), "PatchParameteri");
8852 gl.drawArrays(GL_PATCHES, 0, 1);
8853 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
8857 TCU_FAIL("Invalid enum");
8861 gl.memoryBarrier(GL_ALL_BARRIER_BITS);
8862 GLU_EXPECT_NO_ERROR(gl.getError(), "MemoryBarrier.");
8864 gl.bindTexture(GL_TEXTURE_2D, 0);
8865 gl.bindFramebuffer(GL_FRAMEBUFFER, 0);
8866 gl.bindVertexArray(0);
8867 gl.deleteTextures(1, &texture_object_id);
8868 gl.deleteFramebuffers(1, &framebuffer_object_id);
8869 gl.deleteVertexArrays(1, &vao_id);
8870 GLU_EXPECT_NO_ERROR(gl.getError(), "An error ocurred while deleting generated objects.");
8874 gl.dispatchCompute(1, 1, 1);
8875 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
8877 gl.memoryBarrier(GL_ALL_BARRIER_BITS);
8878 GLU_EXPECT_NO_ERROR(gl.getError(), "MemoryBarrier.");
8881 /* Verify results */
8882 bool test_result = true;
8884 const glw::GLuint* results =
8885 (glw::GLuint*)gl.mapBufferRange(GL_ATOMIC_COUNTER_BUFFER, 0 /* offset */, buffer_data_size, GL_MAP_READ_BIT);
8886 GLU_EXPECT_NO_ERROR(gl.getError(), "MapBufferRange");
8888 /* Anything before start position should be 0 */
8889 for (size_t i = 0; i < start_pos; ++i)
8891 if (0 != results[i])
8893 test_result = false;
8898 /* Anything from start_pos should be incremented by 1 */
8900 for (size_t i = 0; i < n_entries; ++i)
8902 /* Tesselation evaluation can be called several times
8903 In here, check the increment is consistent over all results.
8905 if (tested_shader_type == TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE)
8909 diff = static_cast<int>(results[i + start_pos]) - static_cast<int>(i);
8912 test_result = false;
8916 else if ((static_cast<int>(results[i + start_pos]) - static_cast<int>(i)) != diff)
8918 test_result = false;
8924 if (i + 1 != results[i + start_pos])
8926 test_result = false;
8932 gl.unmapBuffer(GL_ATOMIC_COUNTER_BUFFER);
8933 GLU_EXPECT_NO_ERROR(gl.getError(), "UnmapBuffer");
8935 /* Deallocate any resources used. */
8936 gl.deleteBuffers(1, &buffer_object_id);
8937 this->delete_objects();
8939 if (false == test_result)
8941 TCU_FAIL("Invalid results.");
8945 /* Generates the shader source code for the SubroutineFunctionCalls1
8946 * array tests, attempts to build and execute test program
8948 * @tparam API Tested API descriptor
8950 * @param tested_shader_type The type of shader that is being tested
8952 template <class API>
8953 void SubroutineFunctionCalls1<API>::test_shader_compilation(
8954 typename TestCaseBase<API>::TestShaderType tested_shader_type)
8956 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_IVEC2,
8957 VAR_TYPE_IVEC3, VAR_TYPE_IVEC4, VAR_TYPE_VEC2,
8958 VAR_TYPE_VEC3, VAR_TYPE_VEC4, VAR_TYPE_MAT2,
8959 VAR_TYPE_MAT3, VAR_TYPE_MAT4 };
8960 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
8962 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_IVEC2,
8963 VAR_TYPE_IVEC3, VAR_TYPE_IVEC4, VAR_TYPE_VEC2,
8964 VAR_TYPE_VEC3, VAR_TYPE_VEC4, VAR_TYPE_MAT2,
8965 VAR_TYPE_MAT3, VAR_TYPE_MAT4, VAR_TYPE_DOUBLE,
8966 VAR_TYPE_DMAT2, VAR_TYPE_DMAT3, VAR_TYPE_DMAT4 };
8967 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
8969 const std::string iteration_loop_end = " }\n"
8973 const std::string iteration_loop_start = " for (uint a = 0u; a < 2u; a++)\n"
8975 " for (uint b = 0u; b < 2u; b++)\n"
8977 " for (uint c = 0u; c < 2u; c++)\n"
8979 " for (uint d = 0u; d < 2u; d++)\n"
8981 const glcts::test_var_type* var_types_set = var_types_set_es;
8982 size_t num_var_types = num_var_types_es;
8983 const bool test_compute = (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type);
8985 if (API::USE_DOUBLE)
8987 var_types_set = var_types_set_gl;
8988 num_var_types = num_var_types_gl;
8991 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
8993 _supported_variable_types_map_const_iterator var_iterator =
8994 supported_variable_types_map.find(var_types_set[var_type_index]);
8996 if (var_iterator != supported_variable_types_map.end())
8998 std::string iterator_declaration = " " + var_iterator->second.iterator_type +
8999 " iterator = " + var_iterator->second.iterator_initialization + ";\n";
9001 std::string function_definition;
9002 std::string function_use;
9003 std::string verification;
9005 function_definition += "// Subroutine types\n"
9006 "subroutine void out_routine_type(out ";
9007 function_definition += var_iterator->second.type;
9008 function_definition += " output_array[2][2][2][2]);\n\n"
9009 "// Subroutine definitions\n"
9010 "subroutine(out_routine_type) void original_routine(out ";
9011 function_definition += var_iterator->second.type;
9012 function_definition += " output_array[2][2][2][2]) {\n";
9013 function_definition += iterator_declaration;
9014 function_definition += iteration_loop_start;
9015 function_definition += " output_array[a][b][c][d] = " +
9016 var_iterator->second.variable_type_initializer1 + ";\n";
9017 function_definition +=
9018 " iterator += " + var_iterator->second.iterator_type + "(1);\n";
9019 function_definition += iteration_loop_end;
9020 function_definition += "}\n\n";
9021 function_definition += "subroutine(out_routine_type) void new_routine(out ";
9022 function_definition += var_iterator->second.type;
9023 function_definition += " output_array[2][2][2][2]) {\n";
9024 function_definition += iterator_declaration;
9025 function_definition += iteration_loop_start;
9026 function_definition += " output_array[a][b][c][d] = " +
9027 var_iterator->second.variable_type_initializer1 + ";\n";
9028 function_definition +=
9029 " iterator -= " + var_iterator->second.iterator_type + "(1);\n";
9030 function_definition += iteration_loop_end;
9031 function_definition += "}\n\n"
9032 "// Subroutine uniform\n"
9033 "subroutine uniform out_routine_type routine;\n";
9035 function_use = " " + var_iterator->second.type + " my_array[2][2][2][2];\n";
9036 function_use += " routine(my_array);";
9038 verification = iterator_declaration;
9039 verification += " float result = 1.0;\n";
9040 verification += iteration_loop_start;
9041 verification += " if (my_array[a][b][c][d] " +
9042 var_iterator->second.specific_element +
9048 var_iterator->second.iterator_type + "(1);\n";
9049 verification += iteration_loop_end;
9051 if (false == test_compute)
9053 execute_draw_test(tested_shader_type, function_definition, function_use, verification, false, true);
9054 execute_draw_test(tested_shader_type, function_definition, function_use, verification, true, false);
9058 execute_dispatch_test(tested_shader_type, function_definition, function_use, verification, false, true);
9059 execute_dispatch_test(tested_shader_type, function_definition, function_use, verification, true, false);
9062 /* Deallocate any resources used. */
9063 this->delete_objects();
9064 } /* if var_type iterator found */
9067 TCU_FAIL("Type not found.");
9069 } /* for (int var_type_index = 0; ...) */
9072 /** Executes test for compute program
9074 * @tparam API Tested API descriptor
9076 * @param tested_shader_type The type of shader that is being tested
9077 * @param function_definition Definition used to prepare shader
9078 * @param function_use Use of definition
9079 * @param verification Result verification
9080 * @param use_original Selects if "original_routine" - true or "new_routine" is choosen
9081 * @param expect_invalid_result Does test expects invalid results
9083 template <class API>
9084 void SubroutineFunctionCalls1<API>::execute_dispatch_test(typename TestCaseBase<API>::TestShaderType tested_shader_type,
9085 const std::string& function_definition,
9086 const std::string& function_use,
9087 const std::string& verification, bool use_original,
9088 bool expect_invalid_result)
9090 const std::string& compute_shader_source =
9091 prepare_compute_shader(tested_shader_type, function_definition, function_use, verification);
9092 const glw::Functions& gl = this->context_id.getRenderContext().getFunctions();
9094 this->execute_positive_test(empty_string, empty_string, empty_string, empty_string, empty_string,
9095 compute_shader_source, false, false);
9097 /* We are now ready to verify whether the returned size is correct. */
9098 unsigned char buffer[4] = { 0 };
9099 glw::GLuint framebuffer_object_id = 0;
9100 glw::GLint location = -1;
9101 glw::GLuint routine_index = -1;
9102 glw::GLuint routine_location = -1;
9103 const glw::GLchar* routine_name = "original_routine";
9104 const glw::GLenum shader_type = GL_COMPUTE_SHADER;
9105 glw::GLuint texture_object_id = 0;
9107 if (false == use_original)
9109 routine_name = "new_routine";
9112 gl.useProgram(this->program_object_id);
9113 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram() failed.");
9115 /* Select subroutine */
9116 routine_index = gl.getSubroutineIndex(this->program_object_id, shader_type, routine_name);
9117 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetSubroutineIndex() failed.");
9119 routine_location = gl.getSubroutineUniformLocation(this->program_object_id, shader_type, "routine");
9120 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetSubroutineUniformLocation() failed.");
9122 if (0 != routine_location)
9124 TCU_FAIL("Subroutine location is invalid");
9127 gl.uniformSubroutinesuiv(shader_type, 1, &routine_index);
9128 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniformSubroutinesuiv() failed.");
9130 /* Prepare texture */
9131 gl.genTextures(1, &texture_object_id);
9132 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures() failed.");
9134 gl.bindTexture(GL_TEXTURE_2D, texture_object_id);
9135 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture() failed.");
9137 gl.texStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 1, 1);
9138 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage2D() failed.");
9140 gl.bindImageTexture(0 /* image unit */, texture_object_id, 0 /* level */, GL_FALSE /* layered */, 0 /* layer */,
9141 GL_WRITE_ONLY, GL_RGBA8);
9142 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindImageTexture() failed.");
9144 location = gl.getUniformLocation(this->program_object_id, "uni_image");
9145 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation() failed.");
9149 TCU_FAIL("Uniform is inactive");
9152 gl.uniform1i(location, 0 /* image unit */);
9153 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i() failed.");
9156 gl.dispatchCompute(1, 1, 1);
9157 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
9160 gl.genFramebuffers(1, &framebuffer_object_id);
9161 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers() failed.");
9163 gl.bindFramebuffer(GL_FRAMEBUFFER, framebuffer_object_id);
9164 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer() failed.");
9166 gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_object_id, 0);
9167 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferTexture2D() failed.");
9169 gl.viewport(0, 0, 1, 1);
9170 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport() failed.");
9172 gl.readBuffer(GL_COLOR_ATTACHMENT0);
9173 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadBuffer() failed.");
9175 gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
9176 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels() failed.");
9178 if ((buffer[0] != 255) != expect_invalid_result)
9180 TCU_FAIL("Invalid result was returned.");
9183 /* Delete generated objects. */
9185 gl.bindTexture(GL_TEXTURE_2D, 0);
9186 gl.bindFramebuffer(GL_FRAMEBUFFER, 0);
9188 gl.deleteProgram(this->program_object_id);
9189 this->program_object_id = 0;
9191 gl.deleteTextures(1, &texture_object_id);
9192 gl.deleteFramebuffers(1, &framebuffer_object_id);
9193 GLU_EXPECT_NO_ERROR(gl.getError(), "An error ocurred while deleting generated objects.");
9196 /** Executes test for draw program
9198 * @tparam API Tested API descriptor
9200 * @param tested_shader_type The type of shader that is being tested
9201 * @param function_definition Definition used to prepare shader
9202 * @param function_use Use of definition
9203 * @param verification Result verification
9204 * @param use_original Selects if "original_routine" - true or "new_routine" is choosen
9205 * @param expect_invalid_result Does test expects invalid results
9207 template <class API>
9208 void SubroutineFunctionCalls1<API>::execute_draw_test(typename TestCaseBase<API>::TestShaderType tested_shader_type,
9209 const std::string& function_definition,
9210 const std::string& function_use, const std::string& verification,
9211 bool use_original, bool expect_invalid_result)
9213 const glw::Functions& gl = this->context_id.getRenderContext().getFunctions();
9215 if (API::USE_ALL_SHADER_STAGES)
9217 const std::string& compute_shader_source = empty_string;
9218 const std::string& fragment_shader_source =
9219 this->prepare_fragment_shader(tested_shader_type, function_definition, function_use, verification);
9220 const std::string& geometry_shader_source =
9221 this->prepare_geometry_shader(tested_shader_type, function_definition, function_use, verification);
9222 const std::string& tess_ctrl_shader_source =
9223 this->prepare_tess_ctrl_shader(tested_shader_type, function_definition, function_use, verification);
9224 const std::string& tess_eval_shader_source =
9225 this->prepare_tess_eval_shader(tested_shader_type, function_definition, function_use, verification);
9226 const std::string& vertex_shader_source =
9227 this->prepare_vertex_shader(tested_shader_type, function_definition, function_use, verification);
9229 switch (tested_shader_type)
9231 case TestCaseBase<API>::VERTEX_SHADER_TYPE: /* Fall through */
9232 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
9233 this->execute_positive_test(vertex_shader_source, fragment_shader_source, false, false);
9236 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
9237 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
9238 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE: /* Fall through */
9239 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
9240 this->execute_positive_test(vertex_shader_source, tess_ctrl_shader_source, tess_eval_shader_source,
9241 geometry_shader_source, fragment_shader_source, compute_shader_source, false,
9246 TCU_FAIL("Invalid enum");
9252 const std::string& fragment_shader_source =
9253 this->prepare_fragment_shader(tested_shader_type, function_definition, function_use, verification);
9254 const std::string& vertex_shader_source =
9255 this->prepare_vertex_shader(tested_shader_type, function_definition, function_use, verification);
9257 this->execute_positive_test(vertex_shader_source, fragment_shader_source, false, false);
9260 /* We are now ready to verify whether the returned size is correct. */
9261 unsigned char buffer[4] = { 0 };
9262 glw::GLuint framebuffer_object_id = 0;
9263 glw::GLuint routine_index = -1;
9264 glw::GLuint routine_location = -1;
9265 const glw::GLchar* routine_name = "original_routine";
9266 glw::GLenum shader_type = 0;
9267 glw::GLuint texture_object_id = 0;
9268 glw::GLuint vao_id = 0;
9270 switch (tested_shader_type)
9272 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
9273 shader_type = GL_FRAGMENT_SHADER;
9275 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
9276 shader_type = GL_VERTEX_SHADER;
9278 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
9279 shader_type = GL_COMPUTE_SHADER;
9281 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
9282 shader_type = GL_GEOMETRY_SHADER;
9284 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
9285 shader_type = GL_TESS_CONTROL_SHADER;
9287 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
9288 shader_type = GL_TESS_EVALUATION_SHADER;
9291 TCU_FAIL("Invalid shader type");
9295 if (false == use_original)
9297 routine_name = "new_routine";
9300 gl.useProgram(this->program_object_id);
9301 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram() failed.");
9303 /* Select subroutine */
9304 routine_index = gl.getSubroutineIndex(this->program_object_id, shader_type, routine_name);
9305 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetSubroutineIndex() failed.");
9307 routine_location = gl.getSubroutineUniformLocation(this->program_object_id, shader_type, "routine");
9308 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetSubroutineUniformLocation() failed.");
9310 if (0 != routine_location)
9312 TCU_FAIL("Subroutine location is invalid");
9315 gl.uniformSubroutinesuiv(shader_type, 1, &routine_index);
9316 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniformSubroutinesuiv() failed.");
9318 /* Prepre texture */
9319 assert(0 == texture_object_id);
9320 gl.genTextures(1, &texture_object_id);
9321 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures() failed.");
9323 gl.bindTexture(GL_TEXTURE_2D, texture_object_id);
9324 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture() failed.");
9326 gl.texStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 1, 1);
9327 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage2D() failed.");
9329 /* Prepare framebuffer */
9330 assert(0 == framebuffer_object_id);
9331 gl.genFramebuffers(1, &framebuffer_object_id);
9332 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers() failed.");
9334 gl.bindFramebuffer(GL_FRAMEBUFFER, framebuffer_object_id);
9335 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer() failed.");
9337 gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_object_id, 0);
9338 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferTexture2D() failed.");
9340 gl.viewport(0, 0, 1, 1);
9341 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport() failed.");
9344 assert(0 == vao_id);
9345 gl.genVertexArrays(1, &vao_id);
9346 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenVertexArrays() failed.");
9348 gl.bindVertexArray(vao_id);
9349 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray() failed.");
9351 switch (tested_shader_type)
9353 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE: /* Fall through */
9354 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
9355 gl.drawArrays(GL_TRIANGLE_FAN, 0, 4);
9356 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
9359 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE: /* Fall through */
9360 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
9361 /* Tesselation patch set up */
9362 gl.patchParameteri(GL_PATCH_VERTICES, 1);
9363 GLU_EXPECT_NO_ERROR(gl.getError(), "PatchParameteri");
9365 gl.drawArrays(GL_PATCHES, 0, 1);
9366 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
9369 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
9370 gl.drawArrays(GL_POINTS, 0, 1);
9371 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() failed.");
9375 TCU_FAIL("Invalid enum");
9380 gl.readBuffer(GL_COLOR_ATTACHMENT0);
9381 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadBuffer() failed.");
9383 gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
9384 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels() failed.");
9386 const bool result = ((buffer[0] != 255) == expect_invalid_result);
9388 /* Delete generated objects. */
9390 gl.bindTexture(GL_TEXTURE_2D, 0);
9391 gl.bindFramebuffer(GL_FRAMEBUFFER, 0);
9392 gl.bindVertexArray(0);
9394 gl.deleteProgram(this->program_object_id);
9395 this->program_object_id = 0;
9397 gl.deleteTextures(1, &texture_object_id);
9398 texture_object_id = 0;
9400 gl.deleteFramebuffers(1, &framebuffer_object_id);
9401 framebuffer_object_id = 0;
9403 gl.deleteVertexArrays(1, &vao_id);
9406 GLU_EXPECT_NO_ERROR(gl.getError(), "An error ocurred while deleting generated objects.");
9410 TCU_FAIL("Invalid result was returned.");
9416 * @tparam API Tested API descriptor
9418 * @param tested_shader_type The type of shader that is being tested
9419 * @param function_definition Definition used to prepare shader
9420 * @param function_use Use of definition
9421 * @param verification Result verification
9423 template <class API>
9424 std::string SubroutineFunctionCalls1<API>::prepare_compute_shader(
9425 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& function_definition,
9426 const std::string& function_use, const std::string& verification)
9428 std::string compute_shader_source;
9430 if (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type)
9432 compute_shader_source = "writeonly uniform image2D uni_image;\n"
9435 /* User-defined function definition. */
9436 compute_shader_source += function_definition;
9437 compute_shader_source += "\n\n";
9439 /* Main function definition. */
9440 compute_shader_source += shader_start;
9441 compute_shader_source += function_use;
9442 compute_shader_source += "\n\n";
9443 compute_shader_source += verification;
9444 compute_shader_source += "\n\n";
9445 compute_shader_source += "\n"
9446 " imageStore(uni_image, ivec2(gl_GlobalInvocationID.xy), vec4(result, 0, 0, 0));\n"
9451 return compute_shader_source;
9456 * @tparam API Tested API descriptor
9458 * @param tested_shader_type The type of shader that is being tested
9459 * @param function_definition Definition used to prepare shader
9460 * @param function_use Use of definition
9461 * @param verification Result verification
9463 template <class API>
9464 std::string SubroutineFunctionCalls1<API>::prepare_fragment_shader(
9465 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& function_definition,
9466 const std::string& function_use, const std::string& verification)
9468 std::string fragment_shader_source;
9470 switch (tested_shader_type)
9472 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
9475 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
9476 fragment_shader_source = "out vec4 colour;\n\n";
9478 /* User-defined function definition. */
9479 fragment_shader_source += function_definition;
9480 fragment_shader_source += "\n\n";
9482 /* Main function definition. */
9483 fragment_shader_source += shader_start;
9484 fragment_shader_source += function_use;
9485 fragment_shader_source += "\n\n";
9486 fragment_shader_source += verification;
9487 fragment_shader_source += "\n\n";
9488 fragment_shader_source += " colour = vec4(result);\n";
9489 fragment_shader_source += shader_end;
9492 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
9493 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
9494 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE: /* Fall through */
9495 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
9496 fragment_shader_source = "in float fs_result;\n\n"
9497 "out vec4 colour;\n\n"
9500 " colour = vec4(fs_result);\n"
9506 TCU_FAIL("Unrecognized shader object type.");
9510 return fragment_shader_source;
9515 * @tparam API Tested API descriptor
9517 * @param tested_shader_type The type of shader that is being tested
9518 * @param function_definition Definition used to prepare shader
9519 * @param function_use Use of definition
9520 * @param verification Result verification
9522 template <class API>
9523 std::string SubroutineFunctionCalls1<API>::prepare_geometry_shader(
9524 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& function_definition,
9525 const std::string& function_use, const std::string& verification)
9527 std::string geometry_shader_source;
9529 switch (tested_shader_type)
9531 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
9532 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE: /* Fall through */
9533 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
9536 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE: /* Fall through */
9537 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
9538 geometry_shader_source = "layout(points) in;\n"
9539 "layout(triangle_strip, max_vertices = 4) out;\n"
9541 "in float tes_result[];\n"
9542 "out float fs_result;\n"
9546 " gl_Position = vec4(-1, -1, 0, 1);\n"
9547 " fs_result = tes_result[0];\n"
9549 " gl_Position = vec4(-1, 1, 0, 1);\n"
9550 " fs_result = tes_result[0];\n"
9552 " gl_Position = vec4(1, -1, 0, 1);\n"
9553 " fs_result = tes_result[0];\n"
9555 " gl_Position = vec4(1, 1, 0, 1);\n"
9556 " fs_result = tes_result[0];\n"
9561 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
9562 geometry_shader_source = "layout(points) in;\n"
9563 "layout(triangle_strip, max_vertices = 4) out;\n"
9565 "out float fs_result;\n"
9568 /* User-defined function definition. */
9569 geometry_shader_source += function_definition;
9570 geometry_shader_source += "\n\n";
9572 /* Main function definition. */
9573 geometry_shader_source += shader_start;
9574 geometry_shader_source += function_use;
9575 geometry_shader_source += "\n\n";
9576 geometry_shader_source += verification;
9577 geometry_shader_source += "\n\n";
9578 geometry_shader_source += "\n gl_Position = vec4(-1, -1, 0, 1);\n"
9579 " fs_result = result;\n"
9581 " gl_Position = vec4(-1, 1, 0, 1);\n"
9582 " fs_result = result;\n"
9584 " gl_Position = vec4(1, -1, 0, 1);\n"
9585 " fs_result = result;\n"
9587 " gl_Position = vec4(1, 1, 0, 1);\n"
9588 " fs_result = result;\n"
9594 TCU_FAIL("Unrecognized shader object type.");
9598 return geometry_shader_source;
9603 * @tparam API Tested API descriptor
9605 * @param tested_shader_type The type of shader that is being tested
9606 * @param function_definition Definition used to prepare shader
9607 * @param function_use Use of definition
9608 * @param verification Result verification
9610 template <class API>
9611 std::string SubroutineFunctionCalls1<API>::prepare_tess_ctrl_shader(
9612 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& function_definition,
9613 const std::string& function_use, const std::string& verification)
9615 std::string tess_ctrl_shader_source;
9617 switch (tested_shader_type)
9619 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
9620 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
9621 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
9622 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
9625 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
9626 tess_ctrl_shader_source = "layout(vertices = 1) out;\n"
9628 "out float tcs_result[];\n"
9631 /* User-defined function definition. */
9632 tess_ctrl_shader_source += function_definition;
9633 tess_ctrl_shader_source += "\n\n";
9635 /* Main function definition. */
9636 tess_ctrl_shader_source += shader_start;
9637 tess_ctrl_shader_source += function_use;
9638 tess_ctrl_shader_source += "\n\n";
9639 tess_ctrl_shader_source += verification;
9640 tess_ctrl_shader_source += "\n\n";
9641 tess_ctrl_shader_source += " tcs_result[gl_InvocationID] = result;\n"
9643 " gl_TessLevelOuter[0] = 1.0;\n"
9644 " gl_TessLevelOuter[1] = 1.0;\n"
9645 " gl_TessLevelOuter[2] = 1.0;\n"
9646 " gl_TessLevelOuter[3] = 1.0;\n"
9647 " gl_TessLevelInner[0] = 1.0;\n"
9648 " gl_TessLevelInner[1] = 1.0;\n"
9652 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
9653 tess_ctrl_shader_source = default_tc_shader_source;
9657 TCU_FAIL("Unrecognized shader object type.");
9661 return tess_ctrl_shader_source;
9666 * @tparam API Tested API descriptor
9668 * @param tested_shader_type The type of shader that is being tested
9669 * @param function_definition Definition used to prepare shader
9670 * @param function_use Use of definition
9671 * @param verification Result verification
9673 template <class API>
9674 std::string SubroutineFunctionCalls1<API>::prepare_tess_eval_shader(
9675 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& function_definition,
9676 const std::string& function_use, const std::string& verification)
9678 std::string tess_eval_shader_source;
9680 switch (tested_shader_type)
9682 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
9683 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
9684 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
9685 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
9688 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
9689 tess_eval_shader_source = "layout(isolines, point_mode) in;\n"
9691 "in float tcs_result[];\n"
9692 "out float tes_result;\n"
9696 " tes_result = tcs_result[0];\n"
9700 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
9701 tess_eval_shader_source = "layout(isolines, point_mode) in;\n"
9703 "out float tes_result;\n"
9706 /* User-defined function definition. */
9707 tess_eval_shader_source += function_definition;
9708 tess_eval_shader_source += "\n\n";
9710 /* Main function definition. */
9711 tess_eval_shader_source += shader_start;
9712 tess_eval_shader_source += function_use;
9713 tess_eval_shader_source += "\n\n";
9714 tess_eval_shader_source += verification;
9715 tess_eval_shader_source += "\n\n";
9716 tess_eval_shader_source += " tes_result = result;\n"
9721 TCU_FAIL("Unrecognized shader object type.");
9725 return tess_eval_shader_source;
9730 * @tparam API Tested API descriptor
9732 * @param tested_shader_type The type of shader that is being tested
9733 * @param function_definition Definition used to prepare shader
9734 * @param function_use Use of definition
9735 * @param verification Result verification
9737 template <class API>
9738 std::string SubroutineFunctionCalls1<API>::prepare_vertex_shader(
9739 typename TestCaseBase<API>::TestShaderType tested_shader_type, const std::string& function_definition,
9740 const std::string& function_use, const std::string& verification)
9742 std::string vertex_shader_source;
9744 switch (tested_shader_type)
9746 case TestCaseBase<API>::COMPUTE_SHADER_TYPE:
9749 case TestCaseBase<API>::FRAGMENT_SHADER_TYPE:
9750 vertex_shader_source = "/** GL_TRIANGLE_FAN-type quad vertex data. */\n"
9751 "const vec4 vertex_positions[4] = vec4[4](vec4( 1.0, -1.0, 0.0, 1.0),\n"
9752 " vec4(-1.0, -1.0, 0.0, 1.0),\n"
9753 " vec4(-1.0, 1.0, 0.0, 1.0),\n"
9754 " vec4( 1.0, 1.0, 0.0, 1.0) );\n"
9758 " gl_Position = vertex_positions[gl_VertexID];"
9762 case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
9763 case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
9764 case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
9765 vertex_shader_source = default_vertex_shader_source;
9768 case TestCaseBase<API>::VERTEX_SHADER_TYPE:
9769 /* Vertex shader source. */
9770 vertex_shader_source = "out float fs_result;\n\n";
9771 vertex_shader_source += "/** GL_TRIANGLE_FAN-type quad vertex data. */\n"
9772 "const vec4 vertex_positions[4] = vec4[4](vec4( 1.0, -1.0, 0.0, 1.0),\n"
9773 " vec4(-1.0, -1.0, 0.0, 1.0),\n"
9774 " vec4(-1.0, 1.0, 0.0, 1.0),\n"
9775 " vec4( 1.0, 1.0, 0.0, 1.0) );\n\n";
9777 /* User-defined function definition. */
9778 vertex_shader_source += function_definition;
9779 vertex_shader_source += "\n\n";
9781 /* Main function definition. */
9782 vertex_shader_source += shader_start;
9783 vertex_shader_source += function_use;
9784 vertex_shader_source += "\n\n";
9785 vertex_shader_source += verification;
9786 vertex_shader_source += "\n\n";
9787 vertex_shader_source += " fs_result = result;\n"
9788 " gl_Position = vertex_positions[gl_VertexID];\n";
9789 vertex_shader_source += shader_end;
9793 TCU_FAIL("Unrecognized shader object type.");
9797 return vertex_shader_source;
9800 /* Generates the shader source code for the InteractionFunctionCalls2
9801 * array tests, and attempts to build and execute test program.
9803 * @tparam API Tested API descriptor
9805 * @param tested_shader_type The type of shader that is being tested
9807 template <class API>
9808 void SubroutineFunctionCalls2<API>::test_shader_compilation(
9809 typename TestCaseBase<API>::TestShaderType tested_shader_type)
9811 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_IVEC2,
9812 VAR_TYPE_IVEC3, VAR_TYPE_IVEC4, VAR_TYPE_VEC2,
9813 VAR_TYPE_VEC3, VAR_TYPE_VEC4, VAR_TYPE_MAT2,
9814 VAR_TYPE_MAT3, VAR_TYPE_MAT4 };
9815 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
9817 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_IVEC2,
9818 VAR_TYPE_IVEC3, VAR_TYPE_IVEC4, VAR_TYPE_VEC2,
9819 VAR_TYPE_VEC3, VAR_TYPE_VEC4, VAR_TYPE_MAT2,
9820 VAR_TYPE_MAT3, VAR_TYPE_MAT4, VAR_TYPE_DOUBLE,
9821 VAR_TYPE_DMAT2, VAR_TYPE_DMAT3, VAR_TYPE_DMAT4 };
9822 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
9824 const std::string iteration_loop_end = " }\n"
9828 const std::string iteration_loop_start = " for (uint a = 0u; a < 2u; a++)\n"
9830 " for (uint b = 0u; b < 2u; b++)\n"
9832 " for (uint c = 0u; c < 2u; c++)\n"
9834 " for (uint d = 0u; d < 2u; d++)\n"
9836 const std::string multiplier_array = "const int[] multiplier_array = int[]( 1, 2, 3, 4, 5, 6, 7, 8,\n"
9837 " 11, 12, 13, 14, 15, 16, 17, 18,\n"
9838 " 21, 22, 23, 24, 25, 26, 27, 28,\n"
9839 " 31, 32, 33, 34, 35, 36, 37, 38,\n"
9840 " 41, 42, 43, 44, 45, 46, 47, 48,\n"
9841 " 51, 52, 53, 54, 55, 56, 57, 58,\n"
9842 " 61, 62, 63, 64, 65, 66, 67, 68,\n"
9843 " 71, 72, 73, 74, 75, 76, 77, 78,\n"
9844 " 81, 82, 83, 84, 85, 86, 87, 88);\n";
9845 const glcts::test_var_type* var_types_set = var_types_set_es;
9846 size_t num_var_types = num_var_types_es;
9847 const bool test_compute = (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type);
9849 if (API::USE_DOUBLE)
9851 var_types_set = var_types_set_gl;
9852 num_var_types = num_var_types_gl;
9855 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
9857 _supported_variable_types_map_const_iterator var_iterator =
9858 supported_variable_types_map.find(var_types_set[var_type_index]);
9860 if (var_iterator != supported_variable_types_map.end())
9862 std::string function_definition;
9863 std::string function_use;
9864 std::string verification;
9866 function_definition += multiplier_array;
9868 function_definition += "// Subroutine types\n"
9869 "subroutine void inout_routine_type(inout ";
9870 function_definition += var_iterator->second.type;
9871 function_definition += " inout_array[2][2][2][2]);\n\n"
9872 "// Subroutine definitions\n"
9873 "subroutine(inout_routine_type) void original_routine(inout ";
9874 function_definition += var_iterator->second.type;
9875 function_definition += " inout_array[2][2][2][2]) {\n"
9877 function_definition += iteration_loop_start;
9878 function_definition += " inout_array[a][b][c][d] *= " +
9879 var_iterator->second.iterator_type + "(multiplier_array[i % 64u]);\n";
9880 function_definition += " i+= 1u;\n";
9881 function_definition += iteration_loop_end;
9882 function_definition += "}\n\n"
9883 "subroutine(inout_routine_type) void new_routine(inout ";
9884 function_definition += var_iterator->second.type;
9885 function_definition += " inout_array[2][2][2][2]) {\n"
9887 function_definition += iteration_loop_start;
9888 function_definition += " inout_array[a][b][c][d] /= " +
9889 var_iterator->second.iterator_type + "(multiplier_array[i % 64u]);\n";
9890 function_definition += " i+= 1u;\n";
9891 function_definition += iteration_loop_end;
9892 function_definition += "}\n\n"
9893 "// Subroutine uniform\n"
9894 "subroutine uniform inout_routine_type routine;\n";
9896 function_use += " float result = 1.0;\n";
9897 function_use += " uint iterator = 0u;\n";
9898 function_use += " " + var_iterator->second.type + " my_array[2][2][2][2];\n";
9899 function_use += iteration_loop_start;
9900 function_use += " my_array[a][b][c][d] = " +
9901 var_iterator->second.variable_type_initializer2 + ";\n";
9902 function_use += iteration_loop_end;
9903 function_use += " routine(my_array);";
9905 verification += iteration_loop_start;
9906 verification += " if (my_array[a][b][c][d] " +
9907 var_iterator->second.specific_element + "!= " + var_iterator->second.iterator_type +
9908 "(multiplier_array[iterator % 64u]))\n"
9912 " iterator += 1u;\n";
9913 verification += iteration_loop_end;
9915 if (false == test_compute)
9917 this->execute_draw_test(tested_shader_type, function_definition, function_use, verification, false,
9919 this->execute_draw_test(tested_shader_type, function_definition, function_use, verification, true,
9924 this->execute_dispatch_test(tested_shader_type, function_definition, function_use, verification, false,
9926 this->execute_dispatch_test(tested_shader_type, function_definition, function_use, verification, true,
9930 /* Deallocate any resources used. */
9931 this->delete_objects();
9932 } /* if var_type iterator found */
9935 TCU_FAIL("Type not found.");
9937 } /* for (int var_type_index = 0; ...) */
9940 /* Generates the shader source code for the SubroutineArgumentAliasing1
9941 * array tests, attempts to build and execute test program
9943 * @tparam API Tested API descriptor
9945 * @param tested_shader_type The type of shader that is being tested
9947 template <class API>
9948 void SubroutineArgumentAliasing1<API>::test_shader_compilation(
9949 typename TestCaseBase<API>::TestShaderType tested_shader_type)
9951 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_IVEC2,
9952 VAR_TYPE_IVEC3, VAR_TYPE_IVEC4, VAR_TYPE_VEC2,
9953 VAR_TYPE_VEC3, VAR_TYPE_VEC4, VAR_TYPE_MAT2,
9954 VAR_TYPE_MAT3, VAR_TYPE_MAT4 };
9955 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
9957 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_IVEC2,
9958 VAR_TYPE_IVEC3, VAR_TYPE_IVEC4, VAR_TYPE_VEC2,
9959 VAR_TYPE_VEC3, VAR_TYPE_VEC4, VAR_TYPE_MAT2,
9960 VAR_TYPE_MAT3, VAR_TYPE_MAT4, VAR_TYPE_DOUBLE,
9961 VAR_TYPE_DMAT2, VAR_TYPE_DMAT3, VAR_TYPE_DMAT4 };
9962 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
9964 const std::string iteration_loop_end = " }\n"
9968 const std::string iteration_loop_start = " for (uint a = 0u; a < 2u; a++)\n"
9970 " for (uint b = 0u; b < 2u; b++)\n"
9972 " for (uint c = 0u; c < 2u; c++)\n"
9974 " for (uint d = 0u; d < 2u; d++)\n"
9976 const glcts::test_var_type* var_types_set = var_types_set_es;
9977 size_t num_var_types = num_var_types_es;
9978 const bool test_compute = (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type);
9980 if (API::USE_DOUBLE)
9982 var_types_set = var_types_set_gl;
9983 num_var_types = num_var_types_gl;
9986 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
9988 _supported_variable_types_map_const_iterator var_iterator =
9989 supported_variable_types_map.find(var_types_set[var_type_index]);
9991 if (var_iterator != supported_variable_types_map.end())
9993 std::string function_definition;
9994 std::string function_use;
9995 std::string verification;
9997 function_definition += "// Subroutine types\n"
9998 "subroutine bool in_routine_type(";
9999 function_definition += var_iterator->second.type;
10000 function_definition += " x[2][2][2][2], ";
10001 function_definition += var_iterator->second.type;
10002 function_definition += " y[2][2][2][2]);\n\n"
10003 "// Subroutine definitions\n"
10004 "subroutine(in_routine_type) bool original_routine(";
10005 function_definition += var_iterator->second.type;
10006 function_definition += " x[2][2][2][2], ";
10007 function_definition += var_iterator->second.type;
10008 function_definition += " y[2][2][2][2])\n{\n";
10009 function_definition += iteration_loop_start;
10010 function_definition +=
10011 " x[a][b][c][d] = " + var_iterator->second.type + "(123);\n";
10012 function_definition += iteration_loop_end;
10013 function_definition += "\n";
10014 function_definition += iteration_loop_start;
10015 function_definition += " if(y[a][b][c][d]";
10016 if (var_iterator->second.type == "mat4") // mat4 comparison
10018 function_definition += "[0][0]";
10019 function_definition += " != float";
10021 else if (var_iterator->second.type == "dmat4") // dmat4 comparison
10023 function_definition += "[0][0]";
10024 function_definition += " != double";
10028 function_definition += " != ";
10029 function_definition += var_iterator->second.type;
10031 function_definition += "(((a*8u)+(b*4u)+(c*2u)+d))) {return false;}\n";
10032 function_definition += iteration_loop_end;
10033 function_definition += "\n return true;\n";
10034 function_definition += "}\n\n"
10035 "subroutine(in_routine_type) bool new_routine(";
10036 function_definition += var_iterator->second.type;
10037 function_definition += " x[2][2][2][2], ";
10038 function_definition += var_iterator->second.type;
10039 function_definition += " y[2][2][2][2])\n{\n";
10040 function_definition += iteration_loop_start;
10041 function_definition +=
10042 " y[a][b][c][d] = " + var_iterator->second.type + "(123);\n";
10043 function_definition += iteration_loop_end;
10044 function_definition += "\n";
10045 function_definition += iteration_loop_start;
10046 function_definition += " if(x[a][b][c][d]";
10047 if (var_iterator->second.type == "mat4") // mat4 comparison
10049 function_definition += "[0][0]";
10050 function_definition += " != float";
10052 else if (var_iterator->second.type == "dmat4") // dmat4 comparison
10054 function_definition += "[0][0]";
10055 function_definition += " != double";
10059 function_definition += " != ";
10060 function_definition += var_iterator->second.type;
10062 function_definition += "(((a*8u)+(b*4u)+(c*2u)+d))) {return false;}\n";
10063 function_definition += iteration_loop_end;
10064 function_definition += "\n return true;\n";
10065 function_definition += "}\n\n"
10066 "// Subroutine uniform\n"
10067 "subroutine uniform in_routine_type routine;\n";
10069 function_use += " " + var_iterator->second.type + " z[2][2][2][2];\n";
10070 function_use += iteration_loop_start;
10071 function_use += " z[a][b][c][d] = ";
10072 function_use += var_iterator->second.type;
10073 function_use += "(((a*8u)+(b*4u)+(c*2u)+d));\n";
10074 function_use += iteration_loop_end;
10076 verification = " float result = 0.0;\n"
10077 " if(routine(z, z) == true)\n"
10086 if (false == test_compute)
10088 this->execute_draw_test(tested_shader_type, function_definition, function_use, verification, false,
10090 this->execute_draw_test(tested_shader_type, function_definition, function_use, verification, true,
10095 this->execute_dispatch_test(tested_shader_type, function_definition, function_use, verification, false,
10097 this->execute_dispatch_test(tested_shader_type, function_definition, function_use, verification, true,
10101 /* Deallocate any resources used. */
10102 this->delete_objects();
10103 } /* if var_type iterator found */
10106 TCU_FAIL("Type not found.");
10108 } /* for (int var_type_index = 0; ...) */
10111 /* Generates the shader source code for the SubroutineArgumentAliasing1
10112 * array tests, attempts to build and execute test program
10114 * @tparam API Tested API descriptor
10116 * @param tested_shader_type The type of shader that is being tested
10118 template <class API>
10119 void SubroutineArgumentAliasing2<API>::test_shader_compilation(
10120 typename TestCaseBase<API>::TestShaderType tested_shader_type)
10122 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_IVEC2,
10123 VAR_TYPE_IVEC3, VAR_TYPE_IVEC4, VAR_TYPE_VEC2,
10124 VAR_TYPE_VEC3, VAR_TYPE_VEC4, VAR_TYPE_MAT2,
10125 VAR_TYPE_MAT3, VAR_TYPE_MAT4 };
10126 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
10128 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_IVEC2,
10129 VAR_TYPE_IVEC3, VAR_TYPE_IVEC4, VAR_TYPE_VEC2,
10130 VAR_TYPE_VEC3, VAR_TYPE_VEC4, VAR_TYPE_MAT2,
10131 VAR_TYPE_MAT3, VAR_TYPE_MAT4, VAR_TYPE_DOUBLE,
10132 VAR_TYPE_DMAT2, VAR_TYPE_DMAT3, VAR_TYPE_DMAT4 };
10133 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
10135 const std::string iteration_loop_end = " }\n"
10139 const std::string iteration_loop_start = " for (uint a = 0u; a < 2u; a++)\n"
10141 " for (uint b = 0u; b < 2u; b++)\n"
10143 " for (uint c = 0u; c < 2u; c++)\n"
10145 " for (uint d = 0u; d < 2u; d++)\n"
10147 const glcts::test_var_type* var_types_set = var_types_set_es;
10148 size_t num_var_types = num_var_types_es;
10149 const bool test_compute = (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type);
10151 if (API::USE_DOUBLE)
10153 var_types_set = var_types_set_gl;
10154 num_var_types = num_var_types_gl;
10157 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
10159 _supported_variable_types_map_const_iterator var_iterator =
10160 supported_variable_types_map.find(var_types_set[var_type_index]);
10162 if (var_iterator != supported_variable_types_map.end())
10164 std::string function_definition;
10165 std::string function_use;
10166 std::string verification;
10168 function_definition += "// Subroutine types\n"
10169 "subroutine bool inout_routine_type(inout ";
10170 function_definition += var_iterator->second.type;
10171 function_definition += " x[2][2][2][2], inout ";
10172 function_definition += var_iterator->second.type;
10173 function_definition += " y[2][2][2][2]);\n\n"
10174 "// Subroutine definitions\n"
10175 "subroutine(inout_routine_type) bool original_routine(inout ";
10176 function_definition += var_iterator->second.type;
10177 function_definition += " x[2][2][2][2], inout ";
10178 function_definition += var_iterator->second.type;
10179 function_definition += " y[2][2][2][2])\n{\n";
10180 function_definition += iteration_loop_start;
10181 function_definition +=
10182 " x[a][b][c][d] = " + var_iterator->second.type + "(123);\n";
10183 function_definition += iteration_loop_end;
10184 function_definition += "\n";
10185 function_definition += iteration_loop_start;
10186 function_definition += " if(y[a][b][c][d]";
10187 if (var_iterator->second.type == "mat4") // mat4 comparison
10189 function_definition += "[0][0]";
10190 function_definition += " != float";
10192 else if (var_iterator->second.type == "dmat4") // dmat4 comparison
10194 function_definition += "[0][0]";
10195 function_definition += " != double";
10199 function_definition += " != ";
10200 function_definition += var_iterator->second.type;
10202 function_definition += "(((a*8u)+(b*4u)+(c*2u)+d))) {return false;}\n";
10203 function_definition += iteration_loop_end;
10204 function_definition += "\n return true;\n";
10205 function_definition += "}\n\n"
10206 "subroutine(inout_routine_type) bool new_routine(inout ";
10207 function_definition += var_iterator->second.type;
10208 function_definition += " x[2][2][2][2], inout ";
10209 function_definition += var_iterator->second.type;
10210 function_definition += " y[2][2][2][2])\n{\n";
10211 function_definition += iteration_loop_start;
10212 function_definition +=
10213 " y[a][b][c][d] = " + var_iterator->second.type + "(123);\n";
10214 function_definition += iteration_loop_end;
10215 function_definition += "\n";
10216 function_definition += iteration_loop_start;
10217 function_definition += " if(x[a][b][c][d]";
10218 if (var_iterator->second.type == "mat4") // mat4 comparison
10220 function_definition += "[0][0]";
10221 function_definition += " != float";
10223 else if (var_iterator->second.type == "dmat4") // dmat4 comparison
10225 function_definition += "[0][0]";
10226 function_definition += " != double";
10230 function_definition += " != ";
10231 function_definition += var_iterator->second.type;
10233 function_definition += "(((a*8u)+(b*4u)+(c*2u)+d))) {return false;}\n";
10234 function_definition += iteration_loop_end;
10235 function_definition += "\n return true;\n";
10236 function_definition += "}\n\n"
10237 "// Subroutine uniform\n"
10238 "subroutine uniform inout_routine_type routine;\n";
10240 function_use += " " + var_iterator->second.type + " z[2][2][2][2];\n";
10241 function_use += iteration_loop_start;
10242 function_use += " z[a][b][c][d] = ";
10243 function_use += var_iterator->second.type;
10244 function_use += "(((a*8u)+(b*4u)+(c*2u)+d));\n";
10245 function_use += iteration_loop_end;
10247 verification = " float result = 0.0;\n"
10248 " if(routine(z, z) == true)\n"
10257 if (false == test_compute)
10259 this->execute_draw_test(tested_shader_type, function_definition, function_use, verification, false,
10261 this->execute_draw_test(tested_shader_type, function_definition, function_use, verification, true,
10266 this->execute_dispatch_test(tested_shader_type, function_definition, function_use, verification, false,
10268 this->execute_dispatch_test(tested_shader_type, function_definition, function_use, verification, true,
10272 /* Deallocate any resources used. */
10273 this->delete_objects();
10274 } /* if var_type iterator found */
10277 TCU_FAIL("Type not found.");
10279 } /* for (int var_type_index = 0; ...) */
10282 /* Generates the shader source code for the SubroutineArgumentAliasing1
10283 * array tests, attempts to build and execute test program
10285 * @tparam API Tested API descriptor
10287 * @param tested_shader_type The type of shader that is being tested
10289 template <class API>
10290 void SubroutineArgumentAliasing3<API>::test_shader_compilation(
10291 typename TestCaseBase<API>::TestShaderType tested_shader_type)
10293 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_IVEC2,
10294 VAR_TYPE_IVEC3, VAR_TYPE_IVEC4, VAR_TYPE_VEC2,
10295 VAR_TYPE_VEC3, VAR_TYPE_VEC4, VAR_TYPE_MAT2,
10296 VAR_TYPE_MAT3, VAR_TYPE_MAT4 };
10297 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
10299 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_IVEC2,
10300 VAR_TYPE_IVEC3, VAR_TYPE_IVEC4, VAR_TYPE_VEC2,
10301 VAR_TYPE_VEC3, VAR_TYPE_VEC4, VAR_TYPE_MAT2,
10302 VAR_TYPE_MAT3, VAR_TYPE_MAT4, VAR_TYPE_DOUBLE,
10303 VAR_TYPE_DMAT2, VAR_TYPE_DMAT3, VAR_TYPE_DMAT4 };
10304 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
10306 const std::string iteration_loop_end = " }\n"
10310 const std::string iteration_loop_start = " for (uint a = 0u; a < 2u; a++)\n"
10312 " for (uint b = 0u; b < 2u; b++)\n"
10314 " for (uint c = 0u; c < 2u; c++)\n"
10316 " for (uint d = 0u; d < 2u; d++)\n"
10318 const glcts::test_var_type* var_types_set = var_types_set_es;
10319 size_t num_var_types = num_var_types_es;
10320 const bool test_compute = (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type);
10322 if (API::USE_DOUBLE)
10324 var_types_set = var_types_set_gl;
10325 num_var_types = num_var_types_gl;
10328 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
10330 _supported_variable_types_map_const_iterator var_iterator =
10331 supported_variable_types_map.find(var_types_set[var_type_index]);
10333 if (var_iterator != supported_variable_types_map.end())
10335 std::string function_definition;
10336 std::string function_use;
10337 std::string verification;
10339 function_definition += "// Subroutine types\n"
10340 "subroutine bool out_routine_type(out ";
10341 function_definition += var_iterator->second.type;
10342 function_definition += " x[2][2][2][2], ";
10343 function_definition += var_iterator->second.type;
10344 function_definition += " y[2][2][2][2]);\n\n"
10345 "// Subroutine definitions\n"
10346 "subroutine(out_routine_type) bool original_routine(out ";
10347 function_definition += var_iterator->second.type;
10348 function_definition += " x[2][2][2][2], ";
10349 function_definition += var_iterator->second.type;
10350 function_definition += " y[2][2][2][2])\n{\n";
10351 function_definition += iteration_loop_start;
10352 function_definition +=
10353 " x[a][b][c][d] = " + var_iterator->second.type + "(123);\n";
10354 function_definition += iteration_loop_end;
10355 function_definition += "\n";
10356 function_definition += iteration_loop_start;
10357 function_definition += " if(y[a][b][c][d]";
10358 if (var_iterator->second.type == "mat4") // mat4 comparison
10360 function_definition += "[0][0]";
10361 function_definition += " != float";
10363 else if (var_iterator->second.type == "dmat4") // dmat4 comparison
10365 function_definition += "[0][0]";
10366 function_definition += " != double";
10370 function_definition += " != ";
10371 function_definition += var_iterator->second.type;
10373 function_definition += "(((a*8u)+(b*4u)+(c*2u)+d))) {return false;}\n";
10374 function_definition += iteration_loop_end;
10375 function_definition += "\n return true;\n";
10376 function_definition += "}\n\n"
10377 "subroutine(out_routine_type) bool new_routine(out ";
10378 function_definition += var_iterator->second.type;
10379 function_definition += " x[2][2][2][2], ";
10380 function_definition += var_iterator->second.type;
10381 function_definition += " y[2][2][2][2])\n{\n";
10382 function_definition += iteration_loop_start;
10383 function_definition +=
10384 " x[a][b][c][d] = " + var_iterator->second.type + "(321);\n";
10385 function_definition += iteration_loop_end;
10386 function_definition += "\n";
10387 function_definition += iteration_loop_start;
10388 function_definition += " if(y[a][b][c][d]";
10389 if (var_iterator->second.type == "mat4") // mat4 comparison
10391 function_definition += "[0][0]";
10392 function_definition += " != float";
10394 else if (var_iterator->second.type == "dmat4") // dmat4 comparison
10396 function_definition += "[0][0]";
10397 function_definition += " != double";
10401 function_definition += " != ";
10402 function_definition += var_iterator->second.type;
10404 function_definition += "(((a*8u)+(b*4u)+(c*2u)+d))) {return false;}\n";
10405 function_definition += iteration_loop_end;
10406 function_definition += "\n return true;\n";
10407 function_definition += "}\n\n"
10408 "// Subroutine uniform\n"
10409 "subroutine uniform out_routine_type routine;\n";
10411 function_use += " " + var_iterator->second.type + " z[2][2][2][2];\n";
10412 function_use += iteration_loop_start;
10413 function_use += " z[a][b][c][d] = ";
10414 function_use += var_iterator->second.type;
10415 function_use += "(((a*8u)+(b*4u)+(c*2u)+d));\n";
10416 function_use += iteration_loop_end;
10418 verification = " float result = 0.0;\n"
10419 " if(routine(z, z) == true)\n"
10428 if (false == test_compute)
10430 this->execute_draw_test(tested_shader_type, function_definition, function_use, verification, false,
10432 this->execute_draw_test(tested_shader_type, function_definition, function_use, verification, true,
10437 this->execute_dispatch_test(tested_shader_type, function_definition, function_use, verification, false,
10439 this->execute_dispatch_test(tested_shader_type, function_definition, function_use, verification, true,
10443 /* Deallocate any resources used. */
10444 this->delete_objects();
10445 } /* if var_type iterator found */
10448 TCU_FAIL("Type not found.");
10450 } /* for (int var_type_index = 0; ...) */
10453 /* Generates the shader source code for the SubroutineArgumentAliasing1
10454 * array tests, attempts to build and execute test program
10456 * @tparam API Tested API descriptor
10458 * @param tested_shader_type The type of shader that is being tested
10460 template <class API>
10461 void SubroutineArgumentAliasing4<API>::test_shader_compilation(
10462 typename TestCaseBase<API>::TestShaderType tested_shader_type)
10464 static const glcts::test_var_type var_types_set_es[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_IVEC2,
10465 VAR_TYPE_IVEC3, VAR_TYPE_IVEC4, VAR_TYPE_VEC2,
10466 VAR_TYPE_VEC3, VAR_TYPE_VEC4, VAR_TYPE_MAT2,
10467 VAR_TYPE_MAT3, VAR_TYPE_MAT4 };
10468 static const size_t num_var_types_es = sizeof(var_types_set_es) / sizeof(var_types_set_es[0]);
10470 static const glcts::test_var_type var_types_set_gl[] = { VAR_TYPE_INT, VAR_TYPE_FLOAT, VAR_TYPE_IVEC2,
10471 VAR_TYPE_IVEC3, VAR_TYPE_IVEC4, VAR_TYPE_VEC2,
10472 VAR_TYPE_VEC3, VAR_TYPE_VEC4, VAR_TYPE_MAT2,
10473 VAR_TYPE_MAT3, VAR_TYPE_MAT4, VAR_TYPE_DOUBLE,
10474 VAR_TYPE_DMAT2, VAR_TYPE_DMAT3, VAR_TYPE_DMAT4 };
10475 static const size_t num_var_types_gl = sizeof(var_types_set_gl) / sizeof(var_types_set_gl[0]);
10477 const std::string iteration_loop_end = " }\n"
10481 const std::string iteration_loop_start = " for (uint a = 0u; a < 2u; a++)\n"
10483 " for (uint b = 0u; b < 2u; b++)\n"
10485 " for (uint c = 0u; c < 2u; c++)\n"
10487 " for (uint d = 0u; d < 2u; d++)\n"
10489 const glcts::test_var_type* var_types_set = var_types_set_es;
10490 size_t num_var_types = num_var_types_es;
10491 const bool test_compute = (TestCaseBase<API>::COMPUTE_SHADER_TYPE == tested_shader_type);
10493 if (API::USE_DOUBLE)
10495 var_types_set = var_types_set_gl;
10496 num_var_types = num_var_types_gl;
10499 for (size_t var_type_index = 0; var_type_index < num_var_types; var_type_index++)
10501 _supported_variable_types_map_const_iterator var_iterator =
10502 supported_variable_types_map.find(var_types_set[var_type_index]);
10504 if (var_iterator != supported_variable_types_map.end())
10506 std::string function_definition;
10507 std::string function_use;
10508 std::string verification;
10510 function_definition += "// Subroutine types\n"
10511 "subroutine bool out_routine_type(";
10512 function_definition += var_iterator->second.type;
10513 function_definition += " x[2][2][2][2], out ";
10514 function_definition += var_iterator->second.type;
10515 function_definition += " y[2][2][2][2]);\n\n"
10516 "// Subroutine definitions\n"
10517 "subroutine(out_routine_type) bool original_routine(";
10518 function_definition += var_iterator->second.type;
10519 function_definition += " x[2][2][2][2], out ";
10520 function_definition += var_iterator->second.type;
10521 function_definition += " y[2][2][2][2])\n{\n";
10522 function_definition += iteration_loop_start;
10523 function_definition +=
10524 " y[a][b][c][d] = " + var_iterator->second.type + "(123);\n";
10525 function_definition += iteration_loop_end;
10526 function_definition += "\n";
10527 function_definition += iteration_loop_start;
10528 function_definition += " if(x[a][b][c][d]";
10529 if (var_iterator->second.type == "mat4") // mat4 comparison
10531 function_definition += "[0][0]";
10532 function_definition += " != float";
10534 else if (var_iterator->second.type == "dmat4") // dmat4 comparison
10536 function_definition += "[0][0]";
10537 function_definition += " != double";
10541 function_definition += " != ";
10542 function_definition += var_iterator->second.type;
10544 function_definition += "(((a*8u)+(b*4u)+(c*2u)+d))) {return false;}\n";
10545 function_definition += iteration_loop_end;
10546 function_definition += "\n return true;\n";
10547 function_definition += "}\n\n"
10548 "subroutine(out_routine_type) bool new_routine(";
10549 function_definition += var_iterator->second.type;
10550 function_definition += " x[2][2][2][2], out ";
10551 function_definition += var_iterator->second.type;
10552 function_definition += " y[2][2][2][2])\n{\n";
10553 function_definition += iteration_loop_start;
10554 function_definition +=
10555 " y[a][b][c][d] = " + var_iterator->second.type + "(321);\n";
10556 function_definition += iteration_loop_end;
10557 function_definition += "\n";
10558 function_definition += iteration_loop_start;
10559 function_definition += " if(x[a][b][c][d]";
10560 if (var_iterator->second.type == "mat4") // mat4 comparison
10562 function_definition += "[0][0]";
10563 function_definition += " != float";
10565 else if (var_iterator->second.type == "dmat4") // dmat4 comparison
10567 function_definition += "[0][0]";
10568 function_definition += " != double";
10572 function_definition += " != ";
10573 function_definition += var_iterator->second.type;
10575 function_definition += "(((a*8u)+(b*4u)+(c*2u)+d))) {return false;}\n";
10576 function_definition += iteration_loop_end;
10577 function_definition += "\n return true;\n";
10578 function_definition += "}\n\n"
10579 "// Subroutine uniform\n"
10580 "subroutine uniform out_routine_type routine;\n";
10582 function_use += " " + var_iterator->second.type + " z[2][2][2][2];\n";
10583 function_use += iteration_loop_start;
10584 function_use += " z[a][b][c][d] = ";
10585 function_use += var_iterator->second.type;
10586 function_use += "(((a*8u)+(b*4u)+(c*2u)+d));\n";
10587 function_use += iteration_loop_end;
10589 verification = " float result = 0.0;\n"
10590 " if(routine(z, z) == true)\n"
10599 if (false == test_compute)
10601 this->execute_draw_test(tested_shader_type, function_definition, function_use, verification, false,
10603 this->execute_draw_test(tested_shader_type, function_definition, function_use, verification, true,
10608 this->execute_dispatch_test(tested_shader_type, function_definition, function_use, verification, false,
10610 this->execute_dispatch_test(tested_shader_type, function_definition, function_use, verification, true,
10614 /* Deallocate any resources used. */
10615 this->delete_objects();
10616 } /* if var_type iterator found */
10619 TCU_FAIL("Type not found.");
10621 } /* for (int var_type_index = 0; ...) */
10624 /** Instantiates all tests and adds them as children to the node
10626 * @tparam API Tested API descriptor
10628 * @param context CTS context
10630 template <class API>
10631 void initTests(TestCaseGroup& group, glcts::Context& context)
10634 ArraysOfArrays::initializeMap<API>();
10636 group.addChild(new glcts::ArraysOfArrays::SizedDeclarationsPrimitive<API>(context));
10637 group.addChild(new glcts::ArraysOfArrays::SizedDeclarationsStructTypes1<API>(context));
10638 group.addChild(new glcts::ArraysOfArrays::SizedDeclarationsStructTypes2<API>(context));
10639 group.addChild(new glcts::ArraysOfArrays::SizedDeclarationsStructTypes3<API>(context));
10640 group.addChild(new glcts::ArraysOfArrays::SizedDeclarationsStructTypes4<API>(context));
10641 group.addChild(new glcts::ArraysOfArrays::SizedDeclarationsTypenameStyle1<API>(context));
10642 group.addChild(new glcts::ArraysOfArrays::SizedDeclarationsTypenameStyle2<API>(context));
10643 group.addChild(new glcts::ArraysOfArrays::SizedDeclarationsTypenameStyle3<API>(context));
10644 group.addChild(new glcts::ArraysOfArrays::SizedDeclarationsTypenameStyle4<API>(context));
10645 group.addChild(new glcts::ArraysOfArrays::SizedDeclarationsTypenameStyle5<API>(context));
10646 group.addChild(new glcts::ArraysOfArrays::SizedDeclarationsFunctionParams<API>(context));
10647 group.addChild(new glcts::ArraysOfArrays::sized_declarations_invalid_sizes1<API>(context));
10648 group.addChild(new glcts::ArraysOfArrays::sized_declarations_invalid_sizes2<API>(context));
10649 group.addChild(new glcts::ArraysOfArrays::sized_declarations_invalid_sizes3<API>(context));
10650 group.addChild(new glcts::ArraysOfArrays::sized_declarations_invalid_sizes4<API>(context));
10651 group.addChild(new glcts::ArraysOfArrays::ConstructorsAndUnsizedDeclConstructors1<API>(context));
10652 group.addChild(new glcts::ArraysOfArrays::ConstructorsAndUnsizedDeclConstructors2<API>(context));
10653 group.addChild(new glcts::ArraysOfArrays::ConstructorsAndUnsizedDeclUnsizedConstructors<API>(context));
10654 group.addChild(new glcts::ArraysOfArrays::ConstructorsAndUnsizedDeclConst<API>(context));
10656 group.addChild(new glcts::ArraysOfArrays::ConstructorsAndUnsizedDeclInvalidConstructors1<API>(context));
10657 group.addChild(new glcts::ArraysOfArrays::ConstructorsAndUnsizedDeclInvalidConstructors2<API>(context));
10658 group.addChild(new glcts::ArraysOfArrays::ConstructorsAndUnsizedDeclInvalidConstructors3<API>(context));
10659 group.addChild(new glcts::ArraysOfArrays::ConstructorsAndUnsizedDeclInvalidConstructors4<API>(context));
10660 group.addChild(new glcts::ArraysOfArrays::ConstructorsAndUnsizedDeclConstructorSizing1<API>(context));
10661 group.addChild(new glcts::ArraysOfArrays::ConstructorsAndUnsizedDeclConstructorSizing2<API>(context));
10662 group.addChild(new glcts::ArraysOfArrays::ConstructorsAndUnsizedDeclStructConstructors<API>(context));
10663 group.addChild(new glcts::ArraysOfArrays::ConstructorsAndUnsizedDeclUnsizedArrays1<API>(context));
10664 group.addChild(new glcts::ArraysOfArrays::ConstructorsAndUnsizedDeclUnsizedArrays2<API>(context));
10665 group.addChild(new glcts::ArraysOfArrays::ConstructorsAndUnsizedDeclUnsizedArrays3<API>(context));
10666 group.addChild(new glcts::ArraysOfArrays::ConstructorsAndUnsizedDeclUnsizedArrays4<API>(context));
10667 group.addChild(new glcts::ArraysOfArrays::ExpressionsAssignment1<API>(context));
10668 group.addChild(new glcts::ArraysOfArrays::ExpressionsAssignment2<API>(context));
10669 group.addChild(new glcts::ArraysOfArrays::ExpressionsAssignment3<API>(context));
10670 group.addChild(new glcts::ArraysOfArrays::ExpressionsTypeRestrictions1<API>(context));
10671 group.addChild(new glcts::ArraysOfArrays::ExpressionsTypeRestrictions2<API>(context));
10672 group.addChild(new glcts::ArraysOfArrays::ExpressionsIndexingScalar1<API>(context));
10673 group.addChild(new glcts::ArraysOfArrays::ExpressionsIndexingScalar2<API>(context));
10674 group.addChild(new glcts::ArraysOfArrays::ExpressionsIndexingScalar3<API>(context));
10675 group.addChild(new glcts::ArraysOfArrays::ExpressionsIndexingScalar4<API>(context));
10676 group.addChild(new glcts::ArraysOfArrays::ExpressionsIndexingArray1<API>(context));
10677 group.addChild(new glcts::ArraysOfArrays::ExpressionsIndexingArray2<API>(context));
10678 group.addChild(new glcts::ArraysOfArrays::ExpressionsIndexingArray3<API>(context));
10679 group.addChild(new glcts::ArraysOfArrays::ExpressionsDynamicIndexing1<API>(context));
10680 group.addChild(new glcts::ArraysOfArrays::ExpressionsDynamicIndexing2<API>(context));
10681 group.addChild(new glcts::ArraysOfArrays::ExpressionsEquality1<API>(context));
10682 group.addChild(new glcts::ArraysOfArrays::ExpressionsEquality2<API>(context));
10683 group.addChild(new glcts::ArraysOfArrays::ExpressionsLength1<API>(context));
10684 group.addChild(new glcts::ArraysOfArrays::ExpressionsLength2<API>(context));
10685 group.addChild(new glcts::ArraysOfArrays::ExpressionsLength3<API>(context));
10686 group.addChild(new glcts::ArraysOfArrays::ExpressionsInvalid1<API>(context));
10687 group.addChild(new glcts::ArraysOfArrays::ExpressionsInvalid2<API>(context));
10689 group.addChild(new glcts::ArraysOfArrays::InteractionFunctionCalls1<API>(context));
10690 group.addChild(new glcts::ArraysOfArrays::InteractionFunctionCalls2<API>(context));
10691 group.addChild(new glcts::ArraysOfArrays::InteractionArgumentAliasing1<API>(context));
10692 group.addChild(new glcts::ArraysOfArrays::InteractionArgumentAliasing2<API>(context));
10693 group.addChild(new glcts::ArraysOfArrays::InteractionArgumentAliasing3<API>(context));
10694 group.addChild(new glcts::ArraysOfArrays::InteractionArgumentAliasing4<API>(context));
10695 group.addChild(new glcts::ArraysOfArrays::InteractionArgumentAliasing5<API>(context));
10696 group.addChild(new glcts::ArraysOfArrays::InteractionArgumentAliasing6<API>(context));
10698 group.addChild(new glcts::ArraysOfArrays::InteractionUniforms1<API>(context));
10699 group.addChild(new glcts::ArraysOfArrays::InteractionUniforms2<API>(context));
10700 group.addChild(new glcts::ArraysOfArrays::InteractionUniformBuffers1<API>(context));
10701 group.addChild(new glcts::ArraysOfArrays::InteractionUniformBuffers2<API>(context));
10702 group.addChild(new glcts::ArraysOfArrays::InteractionUniformBuffers3<API>(context));
10703 group.addChild(new glcts::ArraysOfArrays::InteractionInterfaceArrays1<API>(context));
10704 group.addChild(new glcts::ArraysOfArrays::InteractionInterfaceArrays2<API>(context));
10705 group.addChild(new glcts::ArraysOfArrays::InteractionInterfaceArrays3<API>(context));
10706 group.addChild(new glcts::ArraysOfArrays::InteractionInterfaceArrays4<API>(context));
10708 if (API::USE_STORAGE_BLOCK)
10710 group.addChild(new glcts::ArraysOfArrays::InteractionStorageBuffers1<API>(context));
10711 group.addChild(new glcts::ArraysOfArrays::InteractionStorageBuffers2<API>(context));
10712 group.addChild(new glcts::ArraysOfArrays::InteractionStorageBuffers3<API>(context));
10715 if (API::USE_ATOMIC)
10717 group.addChild(new glcts::ArraysOfArrays::AtomicDeclarationTest<API>(context));
10718 group.addChild(new glcts::ArraysOfArrays::AtomicUsageTest<API>(context));
10721 if (API::USE_SUBROUTINE)
10723 group.addChild(new glcts::ArraysOfArrays::SubroutineFunctionCalls1<API>(context));
10724 group.addChild(new glcts::ArraysOfArrays::SubroutineFunctionCalls2<API>(context));
10725 group.addChild(new glcts::ArraysOfArrays::SubroutineArgumentAliasing1<API>(context));
10726 group.addChild(new glcts::ArraysOfArrays::SubroutineArgumentAliasing2<API>(context));
10727 group.addChild(new glcts::ArraysOfArrays::SubroutineArgumentAliasing3<API>(context));
10728 group.addChild(new glcts::ArraysOfArrays::SubroutineArgumentAliasing4<API>(context));
10731 } /* namespace ArraysOfArrays */
10735 * @param context CTS context
10737 ArrayOfArraysTestGroup::ArrayOfArraysTestGroup(Context& context)
10738 : TestCaseGroup(context, "arrays_of_arrays", "Groups all tests that verify 'arrays of arrays' functionality.")
10740 /* Left blank on purpose */
10743 /* Instantiates all tests and adds them as children to the node */
10744 void ArrayOfArraysTestGroup::init(void)
10746 ArraysOfArrays::initTests<ArraysOfArrays::Interface::ES>(*this, m_context);
10751 * @param context CTS context
10753 ArrayOfArraysTestGroupGL::ArrayOfArraysTestGroupGL(Context& context)
10754 : TestCaseGroup(context, "arrays_of_arrays_gl", "Groups all tests that verify 'arrays of arrays' functionality.")
10756 /* Left blank on purpose */
10759 /* Instantiates all tests and adds them as children to the node */
10760 void ArrayOfArraysTestGroupGL::init(void)
10762 ArraysOfArrays::initTests<ArraysOfArrays::Interface::GL>(*this, m_context);
10764 } /* namespace glcts */