xref: /aosp_15_r20/external/deqp/external/openglcts/modules/glesext/esextcTestCaseBase.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker  * OpenGL Conformance Test Suite
3*35238bceSAndroid Build Coastguard Worker  * -----------------------------
4*35238bceSAndroid Build Coastguard Worker  *
5*35238bceSAndroid Build Coastguard Worker  * Copyright (c) 2014-2016 The Khronos Group Inc.
6*35238bceSAndroid Build Coastguard Worker  *
7*35238bceSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
8*35238bceSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
9*35238bceSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
10*35238bceSAndroid Build Coastguard Worker  *
11*35238bceSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
12*35238bceSAndroid Build Coastguard Worker  *
13*35238bceSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
14*35238bceSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
15*35238bceSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16*35238bceSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
17*35238bceSAndroid Build Coastguard Worker  * limitations under the License.
18*35238bceSAndroid Build Coastguard Worker  *
19*35238bceSAndroid Build Coastguard Worker  */ /*!
20*35238bceSAndroid Build Coastguard Worker  * \file
21*35238bceSAndroid Build Coastguard Worker  * \brief
22*35238bceSAndroid Build Coastguard Worker  */ /*-------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker 
24*35238bceSAndroid Build Coastguard Worker #include "esextcTestCaseBase.hpp"
25*35238bceSAndroid Build Coastguard Worker #include "gluContextInfo.hpp"
26*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "glwFunctions.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "tcuStringTemplate.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
30*35238bceSAndroid Build Coastguard Worker #include <algorithm>
31*35238bceSAndroid Build Coastguard Worker #include <cstdarg>
32*35238bceSAndroid Build Coastguard Worker #include <iostream>
33*35238bceSAndroid Build Coastguard Worker 
34*35238bceSAndroid Build Coastguard Worker namespace glcts
35*35238bceSAndroid Build Coastguard Worker {
36*35238bceSAndroid Build Coastguard Worker 
37*35238bceSAndroid Build Coastguard Worker /* Predefined shader source code */
38*35238bceSAndroid Build Coastguard Worker const char *TestCaseBase::m_boilerplate_vs_code = "${VERSION}\n"
39*35238bceSAndroid Build Coastguard Worker                                                   "\n"
40*35238bceSAndroid Build Coastguard Worker                                                   "precision highp float;\n"
41*35238bceSAndroid Build Coastguard Worker                                                   "\n"
42*35238bceSAndroid Build Coastguard Worker                                                   "void main()\n"
43*35238bceSAndroid Build Coastguard Worker                                                   "{\n"
44*35238bceSAndroid Build Coastguard Worker                                                   "    gl_Position = vec4(gl_VertexID, 0, 0, 1);\n"
45*35238bceSAndroid Build Coastguard Worker                                                   "}\n";
46*35238bceSAndroid Build Coastguard Worker 
47*35238bceSAndroid Build Coastguard Worker const float TestCaseBase::m_epsilon_float = 0.0001f;
48*35238bceSAndroid Build Coastguard Worker 
49*35238bceSAndroid Build Coastguard Worker /** Constructor
50*35238bceSAndroid Build Coastguard Worker  *
51*35238bceSAndroid Build Coastguard Worker  * @param context       Test context
52*35238bceSAndroid Build Coastguard Worker  * @param name          Test case's name
53*35238bceSAndroid Build Coastguard Worker  * @param description   Test case's description
54*35238bceSAndroid Build Coastguard Worker  **/
TestCaseBase(Context & context,const ExtParameters & extParam,const char * name,const char * description)55*35238bceSAndroid Build Coastguard Worker TestCaseBase::TestCaseBase(Context &context, const ExtParameters &extParam, const char *name, const char *description)
56*35238bceSAndroid Build Coastguard Worker     : tcu::TestCase(context.getTestContext(), name, description)
57*35238bceSAndroid Build Coastguard Worker     , m_context(context)
58*35238bceSAndroid Build Coastguard Worker     , m_glslVersion(extParam.glslVersion)
59*35238bceSAndroid Build Coastguard Worker     , m_extType(extParam.extType)
60*35238bceSAndroid Build Coastguard Worker     , m_is_framebuffer_no_attachments_supported(false)
61*35238bceSAndroid Build Coastguard Worker     , m_is_geometry_shader_extension_supported(false)
62*35238bceSAndroid Build Coastguard Worker     , m_is_geometry_shader_point_size_supported(false)
63*35238bceSAndroid Build Coastguard Worker     , m_is_gpu_shader5_supported(false)
64*35238bceSAndroid Build Coastguard Worker     , m_is_program_interface_query_supported(false)
65*35238bceSAndroid Build Coastguard Worker     , m_is_shader_image_load_store_supported(false)
66*35238bceSAndroid Build Coastguard Worker     , m_is_shader_image_atomic_supported(false)
67*35238bceSAndroid Build Coastguard Worker     , m_is_texture_storage_multisample_supported(false)
68*35238bceSAndroid Build Coastguard Worker     , m_is_texture_storage_multisample_2d_array_supported(false)
69*35238bceSAndroid Build Coastguard Worker     , m_is_tessellation_shader_supported(false)
70*35238bceSAndroid Build Coastguard Worker     , m_is_tessellation_shader_point_size_supported(false)
71*35238bceSAndroid Build Coastguard Worker     , m_is_texture_cube_map_array_supported(false)
72*35238bceSAndroid Build Coastguard Worker     , m_is_texture_border_clamp_supported(false)
73*35238bceSAndroid Build Coastguard Worker     , m_is_texture_buffer_supported(false)
74*35238bceSAndroid Build Coastguard Worker     , m_is_viewport_array_supported(false)
75*35238bceSAndroid Build Coastguard Worker     , m_is_texture_float_linear_supported(false)
76*35238bceSAndroid Build Coastguard Worker     , seed_value(1)
77*35238bceSAndroid Build Coastguard Worker {
78*35238bceSAndroid Build Coastguard Worker     m_glExtTokens.init(context.getRenderContext().getType());
79*35238bceSAndroid Build Coastguard Worker }
80*35238bceSAndroid Build Coastguard Worker 
81*35238bceSAndroid Build Coastguard Worker /** Initializes base class that all geometry shader test implementations derive from.
82*35238bceSAndroid Build Coastguard Worker  *
83*35238bceSAndroid Build Coastguard Worker  **/
init(void)84*35238bceSAndroid Build Coastguard Worker void TestCaseBase::init(void)
85*35238bceSAndroid Build Coastguard Worker {
86*35238bceSAndroid Build Coastguard Worker     initExtensions();
87*35238bceSAndroid Build Coastguard Worker     initGLSLSpecializationMap();
88*35238bceSAndroid Build Coastguard Worker }
89*35238bceSAndroid Build Coastguard Worker 
90*35238bceSAndroid Build Coastguard Worker /** Initializes function pointers for ES3.1 extensions, as well as determines
91*35238bceSAndroid Build Coastguard Worker  *  availability of these extensions.
92*35238bceSAndroid Build Coastguard Worker  **/
initExtensions()93*35238bceSAndroid Build Coastguard Worker void TestCaseBase::initExtensions()
94*35238bceSAndroid Build Coastguard Worker {
95*35238bceSAndroid Build Coastguard Worker     const glu::ContextType &context_type = m_context.getRenderContext().getType();
96*35238bceSAndroid Build Coastguard Worker 
97*35238bceSAndroid Build Coastguard Worker     /* OpenGL 4.0 or higher is minimum expectation for any of these tests */
98*35238bceSAndroid Build Coastguard Worker     if (glu::contextSupports(context_type, glu::ApiType::core(4, 0)))
99*35238bceSAndroid Build Coastguard Worker     {
100*35238bceSAndroid Build Coastguard Worker         m_is_geometry_shader_extension_supported      = true;
101*35238bceSAndroid Build Coastguard Worker         m_is_geometry_shader_point_size_supported     = true;
102*35238bceSAndroid Build Coastguard Worker         m_is_gpu_shader5_supported                    = true;
103*35238bceSAndroid Build Coastguard Worker         m_is_tessellation_shader_supported            = true;
104*35238bceSAndroid Build Coastguard Worker         m_is_tessellation_shader_point_size_supported = true;
105*35238bceSAndroid Build Coastguard Worker         m_is_texture_cube_map_array_supported         = true;
106*35238bceSAndroid Build Coastguard Worker         m_is_texture_border_clamp_supported           = true;
107*35238bceSAndroid Build Coastguard Worker         m_is_texture_buffer_supported                 = true;
108*35238bceSAndroid Build Coastguard Worker         m_is_texture_float_linear_supported           = true;
109*35238bceSAndroid Build Coastguard Worker         m_is_shader_image_atomic_supported            = glu::contextSupports(context_type, glu::ApiType::core(4, 2));
110*35238bceSAndroid Build Coastguard Worker         m_is_texture_storage_multisample_2d_array_supported =
111*35238bceSAndroid Build Coastguard Worker             glu::contextSupports(context_type, glu::ApiType::core(4, 3));
112*35238bceSAndroid Build Coastguard Worker         m_is_framebuffer_no_attachments_supported  = glu::contextSupports(context_type, glu::ApiType::core(4, 3));
113*35238bceSAndroid Build Coastguard Worker         m_is_program_interface_query_supported     = glu::contextSupports(context_type, glu::ApiType::core(4, 3));
114*35238bceSAndroid Build Coastguard Worker         m_is_texture_storage_multisample_supported = glu::contextSupports(context_type, glu::ApiType::core(4, 3));
115*35238bceSAndroid Build Coastguard Worker         m_is_shader_image_load_store_supported     = glu::contextSupports(context_type, glu::ApiType::core(4, 2));
116*35238bceSAndroid Build Coastguard Worker         m_is_viewport_array_supported              = glu::contextSupports(context_type, glu::ApiType::core(4, 1));
117*35238bceSAndroid Build Coastguard Worker     }
118*35238bceSAndroid Build Coastguard Worker     else if (glu::contextSupports(context_type, glu::ApiType::es(3, 2)))
119*35238bceSAndroid Build Coastguard Worker     {
120*35238bceSAndroid Build Coastguard Worker         m_is_geometry_shader_extension_supported            = true;
121*35238bceSAndroid Build Coastguard Worker         m_is_gpu_shader5_supported                          = true;
122*35238bceSAndroid Build Coastguard Worker         m_is_tessellation_shader_supported                  = true;
123*35238bceSAndroid Build Coastguard Worker         m_is_texture_cube_map_array_supported               = true;
124*35238bceSAndroid Build Coastguard Worker         m_is_texture_border_clamp_supported                 = true;
125*35238bceSAndroid Build Coastguard Worker         m_is_texture_buffer_supported                       = true;
126*35238bceSAndroid Build Coastguard Worker         m_is_shader_image_atomic_supported                  = true;
127*35238bceSAndroid Build Coastguard Worker         m_is_texture_storage_multisample_2d_array_supported = true;
128*35238bceSAndroid Build Coastguard Worker         m_is_framebuffer_no_attachments_supported           = true;
129*35238bceSAndroid Build Coastguard Worker         m_is_program_interface_query_supported              = true;
130*35238bceSAndroid Build Coastguard Worker         m_is_texture_storage_multisample_supported          = true;
131*35238bceSAndroid Build Coastguard Worker         m_is_shader_image_load_store_supported              = true;
132*35238bceSAndroid Build Coastguard Worker         m_is_geometry_shader_point_size_supported =
133*35238bceSAndroid Build Coastguard Worker             isExtensionSupported("GL_OES_geometry_point_size") || isExtensionSupported("GL_EXT_geometry_point_size");
134*35238bceSAndroid Build Coastguard Worker         m_is_tessellation_shader_point_size_supported = isExtensionSupported("GL_OES_tessellation_point_size") ||
135*35238bceSAndroid Build Coastguard Worker                                                         isExtensionSupported("GL_EXT_tessellation_point_size");
136*35238bceSAndroid Build Coastguard Worker         m_is_viewport_array_supported       = isExtensionSupported("GL_OES_viewport_array");
137*35238bceSAndroid Build Coastguard Worker         m_is_texture_float_linear_supported = isExtensionSupported("GL_OES_texture_float_linear");
138*35238bceSAndroid Build Coastguard Worker     }
139*35238bceSAndroid Build Coastguard Worker     else
140*35238bceSAndroid Build Coastguard Worker     {
141*35238bceSAndroid Build Coastguard Worker         /* ES3.1 core functionality is assumed*/
142*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(isContextTypeES(context_type));
143*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(glu::contextSupports(context_type, glu::ApiType::es(3, 1)));
144*35238bceSAndroid Build Coastguard Worker 
145*35238bceSAndroid Build Coastguard Worker         /* these are part of ES 3.1 */
146*35238bceSAndroid Build Coastguard Worker         m_is_framebuffer_no_attachments_supported  = true;
147*35238bceSAndroid Build Coastguard Worker         m_is_program_interface_query_supported     = true;
148*35238bceSAndroid Build Coastguard Worker         m_is_texture_storage_multisample_supported = true;
149*35238bceSAndroid Build Coastguard Worker         m_is_shader_image_load_store_supported     = true;
150*35238bceSAndroid Build Coastguard Worker 
151*35238bceSAndroid Build Coastguard Worker         /* AEP extensions - either test OES variants or EXT variants */
152*35238bceSAndroid Build Coastguard Worker         if (m_extType == EXTENSIONTYPE_OES)
153*35238bceSAndroid Build Coastguard Worker         {
154*35238bceSAndroid Build Coastguard Worker             /* These are all ES 3.1 extensions */
155*35238bceSAndroid Build Coastguard Worker             m_is_geometry_shader_extension_supported      = isExtensionSupported("GL_OES_geometry_shader");
156*35238bceSAndroid Build Coastguard Worker             m_is_geometry_shader_point_size_supported     = isExtensionSupported("GL_OES_geometry_point_size");
157*35238bceSAndroid Build Coastguard Worker             m_is_gpu_shader5_supported                    = isExtensionSupported("GL_OES_gpu_shader5");
158*35238bceSAndroid Build Coastguard Worker             m_is_tessellation_shader_supported            = isExtensionSupported("GL_OES_tessellation_shader");
159*35238bceSAndroid Build Coastguard Worker             m_is_tessellation_shader_point_size_supported = isExtensionSupported("GL_OES_tessellation_point_size");
160*35238bceSAndroid Build Coastguard Worker             m_is_texture_cube_map_array_supported         = isExtensionSupported("GL_OES_texture_cube_map_array");
161*35238bceSAndroid Build Coastguard Worker             m_is_texture_border_clamp_supported           = isExtensionSupported("GL_OES_texture_border_clamp");
162*35238bceSAndroid Build Coastguard Worker             m_is_texture_buffer_supported                 = isExtensionSupported("GL_OES_texture_buffer");
163*35238bceSAndroid Build Coastguard Worker         }
164*35238bceSAndroid Build Coastguard Worker         else
165*35238bceSAndroid Build Coastguard Worker         {
166*35238bceSAndroid Build Coastguard Worker             DE_ASSERT(m_extType == EXTENSIONTYPE_EXT);
167*35238bceSAndroid Build Coastguard Worker 
168*35238bceSAndroid Build Coastguard Worker             /* These are all ES 3.1 extensions */
169*35238bceSAndroid Build Coastguard Worker             m_is_geometry_shader_extension_supported      = isExtensionSupported("GL_EXT_geometry_shader");
170*35238bceSAndroid Build Coastguard Worker             m_is_geometry_shader_point_size_supported     = isExtensionSupported("GL_EXT_geometry_point_size");
171*35238bceSAndroid Build Coastguard Worker             m_is_gpu_shader5_supported                    = isExtensionSupported("GL_EXT_gpu_shader5");
172*35238bceSAndroid Build Coastguard Worker             m_is_tessellation_shader_supported            = isExtensionSupported("GL_EXT_tessellation_shader");
173*35238bceSAndroid Build Coastguard Worker             m_is_tessellation_shader_point_size_supported = isExtensionSupported("GL_EXT_tessellation_point_size");
174*35238bceSAndroid Build Coastguard Worker             m_is_texture_cube_map_array_supported         = isExtensionSupported("GL_EXT_texture_cube_map_array");
175*35238bceSAndroid Build Coastguard Worker             m_is_texture_border_clamp_supported           = isExtensionSupported("GL_EXT_texture_border_clamp");
176*35238bceSAndroid Build Coastguard Worker             m_is_texture_buffer_supported                 = isExtensionSupported("GL_EXT_texture_buffer");
177*35238bceSAndroid Build Coastguard Worker             m_is_fragment_shading_rate_supported          = isExtensionSupported("GL_EXT_fragment_shading_rate");
178*35238bceSAndroid Build Coastguard Worker             m_is_fragment_shading_rate_primitive_supported =
179*35238bceSAndroid Build Coastguard Worker                 isExtensionSupported("GL_EXT_fragment_shading_rate_primitive");
180*35238bceSAndroid Build Coastguard Worker             m_is_fragment_shading_rate_attachment_supported =
181*35238bceSAndroid Build Coastguard Worker                 isExtensionSupported("GL_EXT_fragment_shading_rate_attachment");
182*35238bceSAndroid Build Coastguard Worker         }
183*35238bceSAndroid Build Coastguard Worker 
184*35238bceSAndroid Build Coastguard Worker         /* other ES 3.1 extensions */
185*35238bceSAndroid Build Coastguard Worker         m_is_shader_image_atomic_supported = isExtensionSupported("GL_OES_shader_image_atomic");
186*35238bceSAndroid Build Coastguard Worker         m_is_texture_storage_multisample_2d_array_supported =
187*35238bceSAndroid Build Coastguard Worker             isExtensionSupported("GL_OES_texture_storage_multisample_2d_array");
188*35238bceSAndroid Build Coastguard Worker         m_is_viewport_array_supported       = isExtensionSupported("GL_OES_viewport_array");
189*35238bceSAndroid Build Coastguard Worker         m_is_multiview_ovr_supported        = isExtensionSupported("GL_OVR_multiview");
190*35238bceSAndroid Build Coastguard Worker         m_is_texture_float_linear_supported = isExtensionSupported("GL_OES_texture_float_linear");
191*35238bceSAndroid Build Coastguard Worker     }
192*35238bceSAndroid Build Coastguard Worker }
193*35238bceSAndroid Build Coastguard Worker 
194*35238bceSAndroid Build Coastguard Worker /** Initializes function pointers for ES3.1 extensions, as well as determines
195*35238bceSAndroid Build Coastguard Worker  *  availability of these extensions.
196*35238bceSAndroid Build Coastguard Worker  **/
initGLSLSpecializationMap()197*35238bceSAndroid Build Coastguard Worker void TestCaseBase::initGLSLSpecializationMap()
198*35238bceSAndroid Build Coastguard Worker {
199*35238bceSAndroid Build Coastguard Worker     m_specializationMap["VERSION"] = glu::getGLSLVersionDeclaration(m_glslVersion);
200*35238bceSAndroid Build Coastguard Worker     m_specializationMap["SHADER_IO_BLOCKS_ENABLE"] =
201*35238bceSAndroid Build Coastguard Worker         getGLSLExtDirective(m_extType, EXTENSIONNAME_SHADER_IO_BLOCKS, EXTENSIONBEHAVIOR_ENABLE);
202*35238bceSAndroid Build Coastguard Worker     m_specializationMap["SHADER_IO_BLOCKS_REQUIRE"] =
203*35238bceSAndroid Build Coastguard Worker         getGLSLExtDirective(m_extType, EXTENSIONNAME_SHADER_IO_BLOCKS, EXTENSIONBEHAVIOR_REQUIRE);
204*35238bceSAndroid Build Coastguard Worker     m_specializationMap["GEOMETRY_SHADER_ENABLE"] =
205*35238bceSAndroid Build Coastguard Worker         getGLSLExtDirective(m_extType, EXTENSIONNAME_GEOMETRY_SHADER, EXTENSIONBEHAVIOR_ENABLE);
206*35238bceSAndroid Build Coastguard Worker     m_specializationMap["GEOMETRY_SHADER_REQUIRE"] =
207*35238bceSAndroid Build Coastguard Worker         getGLSLExtDirective(m_extType, EXTENSIONNAME_GEOMETRY_SHADER, EXTENSIONBEHAVIOR_REQUIRE);
208*35238bceSAndroid Build Coastguard Worker     m_specializationMap["GEOMETRY_POINT_SIZE_ENABLE"] =
209*35238bceSAndroid Build Coastguard Worker         getGLSLExtDirective(m_extType, EXTENSIONNAME_GEOMETRY_POINT_SIZE, EXTENSIONBEHAVIOR_ENABLE);
210*35238bceSAndroid Build Coastguard Worker     m_specializationMap["GEOMETRY_POINT_SIZE_REQUIRE"] =
211*35238bceSAndroid Build Coastguard Worker         getGLSLExtDirective(m_extType, EXTENSIONNAME_GEOMETRY_POINT_SIZE, EXTENSIONBEHAVIOR_REQUIRE);
212*35238bceSAndroid Build Coastguard Worker     m_specializationMap["TESSELLATION_SHADER_ENABLE"] =
213*35238bceSAndroid Build Coastguard Worker         getGLSLExtDirective(m_extType, EXTENSIONNAME_TESSELLATION_SHADER, EXTENSIONBEHAVIOR_ENABLE);
214*35238bceSAndroid Build Coastguard Worker     m_specializationMap["TESSELLATION_SHADER_REQUIRE"] =
215*35238bceSAndroid Build Coastguard Worker         getGLSLExtDirective(m_extType, EXTENSIONNAME_TESSELLATION_SHADER, EXTENSIONBEHAVIOR_REQUIRE);
216*35238bceSAndroid Build Coastguard Worker     m_specializationMap["TESSELLATION_POINT_SIZE_ENABLE"] =
217*35238bceSAndroid Build Coastguard Worker         getGLSLExtDirective(m_extType, EXTENSIONNAME_TESSELLATION_POINT_SIZE, EXTENSIONBEHAVIOR_ENABLE);
218*35238bceSAndroid Build Coastguard Worker     m_specializationMap["TESSELLATION_POINT_SIZE_REQUIRE"] =
219*35238bceSAndroid Build Coastguard Worker         getGLSLExtDirective(m_extType, EXTENSIONNAME_TESSELLATION_POINT_SIZE, EXTENSIONBEHAVIOR_REQUIRE);
220*35238bceSAndroid Build Coastguard Worker     m_specializationMap["GPU_SHADER5_ENABLE"] =
221*35238bceSAndroid Build Coastguard Worker         getGLSLExtDirective(m_extType, EXTENSIONNAME_GPU_SHADER5, EXTENSIONBEHAVIOR_ENABLE);
222*35238bceSAndroid Build Coastguard Worker     m_specializationMap["GPU_SHADER5_REQUIRE"] =
223*35238bceSAndroid Build Coastguard Worker         getGLSLExtDirective(m_extType, EXTENSIONNAME_GPU_SHADER5, EXTENSIONBEHAVIOR_REQUIRE);
224*35238bceSAndroid Build Coastguard Worker     m_specializationMap["TEXTURE_BUFFER_ENABLE"] =
225*35238bceSAndroid Build Coastguard Worker         getGLSLExtDirective(m_extType, EXTENSIONNAME_TEXTURE_BUFFER, EXTENSIONBEHAVIOR_ENABLE);
226*35238bceSAndroid Build Coastguard Worker     m_specializationMap["TEXTURE_BUFFER_REQUIRE"] =
227*35238bceSAndroid Build Coastguard Worker         getGLSLExtDirective(m_extType, EXTENSIONNAME_TEXTURE_BUFFER, EXTENSIONBEHAVIOR_REQUIRE);
228*35238bceSAndroid Build Coastguard Worker     m_specializationMap["TEXTURE_CUBE_MAP_ARRAY_ENABLE"] =
229*35238bceSAndroid Build Coastguard Worker         getGLSLExtDirective(m_extType, EXTENSIONNAME_TEXTURE_CUBE_MAP_ARRAY, EXTENSIONBEHAVIOR_ENABLE);
230*35238bceSAndroid Build Coastguard Worker     m_specializationMap["TEXTURE_CUBE_MAP_ARRAY_REQUIRE"] =
231*35238bceSAndroid Build Coastguard Worker         getGLSLExtDirective(m_extType, EXTENSIONNAME_TEXTURE_CUBE_MAP_ARRAY, EXTENSIONBEHAVIOR_REQUIRE);
232*35238bceSAndroid Build Coastguard Worker     m_specializationMap["SHADER_IMAGE_ATOMIC_ENABLE"] =
233*35238bceSAndroid Build Coastguard Worker         getGLSLExtDirective(m_extType, EXTENSIONNAME_SHADER_IMAGE_ATOMIC, EXTENSIONBEHAVIOR_ENABLE);
234*35238bceSAndroid Build Coastguard Worker     m_specializationMap["SHADER_IMAGE_ATOMIC_REQUIRE"] =
235*35238bceSAndroid Build Coastguard Worker         getGLSLExtDirective(m_extType, EXTENSIONNAME_SHADER_IMAGE_ATOMIC, EXTENSIONBEHAVIOR_REQUIRE);
236*35238bceSAndroid Build Coastguard Worker     m_specializationMap["VIEWPORT_ARRAY_ENABLE"] =
237*35238bceSAndroid Build Coastguard Worker         getGLSLExtDirective(m_extType, EXTENSIONNAME_VIEWPORT_ARRAY, EXTENSIONBEHAVIOR_ENABLE);
238*35238bceSAndroid Build Coastguard Worker     m_specializationMap["VIEWPORT_ARRAY_REQUIRE"] =
239*35238bceSAndroid Build Coastguard Worker         getGLSLExtDirective(m_extType, EXTENSIONNAME_VIEWPORT_ARRAY, EXTENSIONBEHAVIOR_REQUIRE);
240*35238bceSAndroid Build Coastguard Worker 
241*35238bceSAndroid Build Coastguard Worker     if (glu::isContextTypeES(m_context.getRenderContext().getType()))
242*35238bceSAndroid Build Coastguard Worker     {
243*35238bceSAndroid Build Coastguard Worker         m_specializationMap["IN_PER_VERTEX_DECL_ARRAY"]             = "\n";
244*35238bceSAndroid Build Coastguard Worker         m_specializationMap["IN_PER_VERTEX_DECL_ARRAY_POINT_SIZE"]  = "\n";
245*35238bceSAndroid Build Coastguard Worker         m_specializationMap["OUT_PER_VERTEX_DECL"]                  = "\n";
246*35238bceSAndroid Build Coastguard Worker         m_specializationMap["OUT_PER_VERTEX_DECL_POINT_SIZE"]       = "\n";
247*35238bceSAndroid Build Coastguard Worker         m_specializationMap["OUT_PER_VERTEX_DECL_ARRAY"]            = "\n";
248*35238bceSAndroid Build Coastguard Worker         m_specializationMap["OUT_PER_VERTEX_DECL_ARRAY_POINT_SIZE"] = "\n";
249*35238bceSAndroid Build Coastguard Worker         m_specializationMap["IN_DATA_DECL"]                         = "\n";
250*35238bceSAndroid Build Coastguard Worker         m_specializationMap["POSITION_WITH_IN_DATA"]                = "gl_Position = gl_in[0].gl_Position;\n";
251*35238bceSAndroid Build Coastguard Worker     }
252*35238bceSAndroid Build Coastguard Worker     else
253*35238bceSAndroid Build Coastguard Worker     {
254*35238bceSAndroid Build Coastguard Worker         m_specializationMap["IN_PER_VERTEX_DECL_ARRAY"]             = "in gl_PerVertex {\n"
255*35238bceSAndroid Build Coastguard Worker                                                                       "    vec4 gl_Position;\n"
256*35238bceSAndroid Build Coastguard Worker                                                                       "} gl_in[];\n";
257*35238bceSAndroid Build Coastguard Worker         m_specializationMap["IN_PER_VERTEX_DECL_ARRAY_POINT_SIZE"]  = "in gl_PerVertex {\n"
258*35238bceSAndroid Build Coastguard Worker                                                                       "    vec4 gl_Position;\n"
259*35238bceSAndroid Build Coastguard Worker                                                                       "    float gl_PointSize;\n"
260*35238bceSAndroid Build Coastguard Worker                                                                       "} gl_in[];\n";
261*35238bceSAndroid Build Coastguard Worker         m_specializationMap["OUT_PER_VERTEX_DECL"]                  = "out gl_PerVertex {\n"
262*35238bceSAndroid Build Coastguard Worker                                                                       "    vec4 gl_Position;\n"
263*35238bceSAndroid Build Coastguard Worker                                                                       "};\n";
264*35238bceSAndroid Build Coastguard Worker         m_specializationMap["OUT_PER_VERTEX_DECL_POINT_SIZE"]       = "out gl_PerVertex {\n"
265*35238bceSAndroid Build Coastguard Worker                                                                       "    vec4 gl_Position;\n"
266*35238bceSAndroid Build Coastguard Worker                                                                       "    float gl_PointSize;\n"
267*35238bceSAndroid Build Coastguard Worker                                                                       "};\n";
268*35238bceSAndroid Build Coastguard Worker         m_specializationMap["OUT_PER_VERTEX_DECL_ARRAY"]            = "out gl_PerVertex {\n"
269*35238bceSAndroid Build Coastguard Worker                                                                       "    vec4 gl_Position;\n"
270*35238bceSAndroid Build Coastguard Worker                                                                       "} gl_out[];\n";
271*35238bceSAndroid Build Coastguard Worker         m_specializationMap["OUT_PER_VERTEX_DECL_ARRAY_POINT_SIZE"] = "out gl_PerVertex {\n"
272*35238bceSAndroid Build Coastguard Worker                                                                       "    vec4 gl_Position;\n"
273*35238bceSAndroid Build Coastguard Worker                                                                       "    float gl_PointSize;\n"
274*35238bceSAndroid Build Coastguard Worker                                                                       "} gl_out[];\n";
275*35238bceSAndroid Build Coastguard Worker         m_specializationMap["IN_DATA_DECL"]                         = "in Data {\n"
276*35238bceSAndroid Build Coastguard Worker                                                                       "    vec4 pos;\n"
277*35238bceSAndroid Build Coastguard Worker                                                                       "} input_data[1];\n";
278*35238bceSAndroid Build Coastguard Worker         m_specializationMap["POSITION_WITH_IN_DATA"]                = "gl_Position = input_data[0].pos;\n";
279*35238bceSAndroid Build Coastguard Worker     }
280*35238bceSAndroid Build Coastguard Worker }
281*35238bceSAndroid Build Coastguard Worker 
282*35238bceSAndroid Build Coastguard Worker /** Sets the seed for the random generator
283*35238bceSAndroid Build Coastguard Worker  *  @param seed - seed for the random generator
284*35238bceSAndroid Build Coastguard Worker  */
randomSeed(const glw::GLuint seed)285*35238bceSAndroid Build Coastguard Worker void TestCaseBase::randomSeed(const glw::GLuint seed)
286*35238bceSAndroid Build Coastguard Worker {
287*35238bceSAndroid Build Coastguard Worker     seed_value = seed;
288*35238bceSAndroid Build Coastguard Worker }
289*35238bceSAndroid Build Coastguard Worker 
290*35238bceSAndroid Build Coastguard Worker /** Returns random unsigned integer from the range [0,max)
291*35238bceSAndroid Build Coastguard Worker  *  @param  max - the value that is the upper boundary for the returned random numbers
292*35238bceSAndroid Build Coastguard Worker  *  @return random unsigned integer from the range [0,max)
293*35238bceSAndroid Build Coastguard Worker  */
randomFormula(const glw::GLuint max)294*35238bceSAndroid Build Coastguard Worker glw::GLuint TestCaseBase::randomFormula(const glw::GLuint max)
295*35238bceSAndroid Build Coastguard Worker {
296*35238bceSAndroid Build Coastguard Worker     static const glw::GLuint a = 11;
297*35238bceSAndroid Build Coastguard Worker     static const glw::GLuint b = 17;
298*35238bceSAndroid Build Coastguard Worker 
299*35238bceSAndroid Build Coastguard Worker     seed_value = (a * seed_value + b) % max;
300*35238bceSAndroid Build Coastguard Worker 
301*35238bceSAndroid Build Coastguard Worker     return seed_value;
302*35238bceSAndroid Build Coastguard Worker }
303*35238bceSAndroid Build Coastguard Worker 
304*35238bceSAndroid Build Coastguard Worker /** Executes the test.
305*35238bceSAndroid Build Coastguard Worker  *  Sets the test result to QP_TEST_RESULT_FAIL if the test failed, QP_TEST_RESULT_PASS otherwise.
306*35238bceSAndroid Build Coastguard Worker  *
307*35238bceSAndroid Build Coastguard Worker  *  @return STOP if the test has finished, CONTINUE to indicate iterate should be called once again.
308*35238bceSAndroid Build Coastguard Worker  *
309*35238bceSAndroid Build Coastguard Worker  *  Note the function throws exception should an error occur!
310*35238bceSAndroid Build Coastguard Worker  **/
iterate(void)311*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult TestCaseBase::iterate(void)
312*35238bceSAndroid Build Coastguard Worker {
313*35238bceSAndroid Build Coastguard Worker     qpTestResult result = QP_TEST_RESULT_FAIL;
314*35238bceSAndroid Build Coastguard Worker 
315*35238bceSAndroid Build Coastguard Worker     m_testCtx.setTestResult(result, "This location should never be called.");
316*35238bceSAndroid Build Coastguard Worker 
317*35238bceSAndroid Build Coastguard Worker     return STOP;
318*35238bceSAndroid Build Coastguard Worker }
319*35238bceSAndroid Build Coastguard Worker 
320*35238bceSAndroid Build Coastguard Worker /** Deinitializes base class that all test implementations inherit from.
321*35238bceSAndroid Build Coastguard Worker  *
322*35238bceSAndroid Build Coastguard Worker  **/
deinit(void)323*35238bceSAndroid Build Coastguard Worker void TestCaseBase::deinit(void)
324*35238bceSAndroid Build Coastguard Worker {
325*35238bceSAndroid Build Coastguard Worker     /* Left empty on purpose */
326*35238bceSAndroid Build Coastguard Worker }
327*35238bceSAndroid Build Coastguard Worker 
328*35238bceSAndroid Build Coastguard Worker /** Tells whether particular extension is supported.
329*35238bceSAndroid Build Coastguard Worker  *
330*35238bceSAndroid Build Coastguard Worker  *  @param extName: The name of the extension
331*35238bceSAndroid Build Coastguard Worker  *
332*35238bceSAndroid Build Coastguard Worker  *  @return true   if given extension name is reported as supported, false otherwise.
333*35238bceSAndroid Build Coastguard Worker  **/
isExtensionSupported(const std::string & extName) const334*35238bceSAndroid Build Coastguard Worker bool TestCaseBase::isExtensionSupported(const std::string &extName) const
335*35238bceSAndroid Build Coastguard Worker {
336*35238bceSAndroid Build Coastguard Worker     const std::vector<std::string> &extensions = m_context.getContextInfo().getExtensions();
337*35238bceSAndroid Build Coastguard Worker 
338*35238bceSAndroid Build Coastguard Worker     if (std::find(extensions.begin(), extensions.end(), extName) != extensions.end())
339*35238bceSAndroid Build Coastguard Worker     {
340*35238bceSAndroid Build Coastguard Worker         return true;
341*35238bceSAndroid Build Coastguard Worker     }
342*35238bceSAndroid Build Coastguard Worker 
343*35238bceSAndroid Build Coastguard Worker     return false;
344*35238bceSAndroid Build Coastguard Worker }
345*35238bceSAndroid Build Coastguard Worker 
346*35238bceSAndroid Build Coastguard Worker /** Helper method for specializing a shader */
specializeShader(const unsigned int parts,const char * const * code) const347*35238bceSAndroid Build Coastguard Worker std::string TestCaseBase::specializeShader(const unsigned int parts, const char *const *code) const
348*35238bceSAndroid Build Coastguard Worker {
349*35238bceSAndroid Build Coastguard Worker     std::stringstream code_merged;
350*35238bceSAndroid Build Coastguard Worker     for (unsigned int i = 0; i < parts; i++)
351*35238bceSAndroid Build Coastguard Worker     {
352*35238bceSAndroid Build Coastguard Worker         code_merged << code[i];
353*35238bceSAndroid Build Coastguard Worker     }
354*35238bceSAndroid Build Coastguard Worker     return tcu::StringTemplate(code_merged.str().c_str()).specialize(m_specializationMap);
355*35238bceSAndroid Build Coastguard Worker }
356*35238bceSAndroid Build Coastguard Worker 
shaderSourceSpecialized(glw::GLuint shader_id,glw::GLsizei shader_count,const glw::GLchar * const * shader_string)357*35238bceSAndroid Build Coastguard Worker void TestCaseBase::shaderSourceSpecialized(glw::GLuint shader_id, glw::GLsizei shader_count,
358*35238bceSAndroid Build Coastguard Worker                                            const glw::GLchar *const *shader_string)
359*35238bceSAndroid Build Coastguard Worker {
360*35238bceSAndroid Build Coastguard Worker     const glw::Functions &gl = m_context.getRenderContext().getFunctions();
361*35238bceSAndroid Build Coastguard Worker 
362*35238bceSAndroid Build Coastguard Worker     std::string specialized      = specializeShader(shader_count, shader_string);
363*35238bceSAndroid Build Coastguard Worker     const char *specialized_cstr = specialized.c_str();
364*35238bceSAndroid Build Coastguard Worker     gl.shaderSource(shader_id, 1, &specialized_cstr, NULL);
365*35238bceSAndroid Build Coastguard Worker }
366*35238bceSAndroid Build Coastguard Worker 
getShaderTypeName(glw::GLenum shader_type)367*35238bceSAndroid Build Coastguard Worker std::string getShaderTypeName(glw::GLenum shader_type)
368*35238bceSAndroid Build Coastguard Worker {
369*35238bceSAndroid Build Coastguard Worker     switch (shader_type)
370*35238bceSAndroid Build Coastguard Worker     {
371*35238bceSAndroid Build Coastguard Worker     case GL_VERTEX_SHADER:
372*35238bceSAndroid Build Coastguard Worker         return "Vertex shader";
373*35238bceSAndroid Build Coastguard Worker     case GL_TESS_CONTROL_SHADER:
374*35238bceSAndroid Build Coastguard Worker         return "Tessellation control shader";
375*35238bceSAndroid Build Coastguard Worker     case GL_TESS_EVALUATION_SHADER:
376*35238bceSAndroid Build Coastguard Worker         return "Tessellation evaluation shader";
377*35238bceSAndroid Build Coastguard Worker     case GL_GEOMETRY_SHADER:
378*35238bceSAndroid Build Coastguard Worker         return "Geometry shader";
379*35238bceSAndroid Build Coastguard Worker     case GL_FRAGMENT_SHADER:
380*35238bceSAndroid Build Coastguard Worker         return "Fragment shader";
381*35238bceSAndroid Build Coastguard Worker     case GL_COMPUTE_SHADER:
382*35238bceSAndroid Build Coastguard Worker         return "Compute shader";
383*35238bceSAndroid Build Coastguard Worker     default:
384*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(0);
385*35238bceSAndroid Build Coastguard Worker         return "??? shader";
386*35238bceSAndroid Build Coastguard Worker     }
387*35238bceSAndroid Build Coastguard Worker }
388*35238bceSAndroid Build Coastguard Worker 
389*35238bceSAndroid Build Coastguard Worker /** Compiles and links program with variable amount of shaders
390*35238bceSAndroid Build Coastguard Worker  *
391*35238bceSAndroid Build Coastguard Worker  * @param po_id                      Program handle
392*35238bceSAndroid Build Coastguard Worker  * @param out_has_compilation_failed Deref will be set to true, if shader compilation
393*35238bceSAndroid Build Coastguard Worker  *                                   failed for any of the submitted shaders.
394*35238bceSAndroid Build Coastguard Worker  *                                   Will be set to false otherwise. Can be NULL.
395*35238bceSAndroid Build Coastguard Worker  * @param sh_stages                  Shader stages
396*35238bceSAndroid Build Coastguard Worker  * @for all shader stages
397*35238bceSAndroid Build Coastguard Worker  * {
398*35238bceSAndroid Build Coastguard Worker  *   @param sh_id          Shader handle. 0 means "skip"
399*35238bceSAndroid Build Coastguard Worker  *   @param sh_parts       Number of shader source code parts.
400*35238bceSAndroid Build Coastguard Worker  *                         0 means that it's already compiled.
401*35238bceSAndroid Build Coastguard Worker  *   @param sh_code        Shader source code.
402*35238bceSAndroid Build Coastguard Worker  * }
403*35238bceSAndroid Build Coastguard Worker  **/
buildProgramVA(glw::GLuint po_id,bool * out_has_compilation_failed,unsigned int sh_stages,...)404*35238bceSAndroid Build Coastguard Worker bool TestCaseBase::buildProgramVA(glw::GLuint po_id, bool *out_has_compilation_failed, unsigned int sh_stages, ...)
405*35238bceSAndroid Build Coastguard Worker {
406*35238bceSAndroid Build Coastguard Worker     const glw::Functions &gl = m_context.getRenderContext().getFunctions();
407*35238bceSAndroid Build Coastguard Worker     std::vector<glw::GLuint> vec_sh_id;
408*35238bceSAndroid Build Coastguard Worker 
409*35238bceSAndroid Build Coastguard Worker     va_list values;
410*35238bceSAndroid Build Coastguard Worker     va_start(values, sh_stages);
411*35238bceSAndroid Build Coastguard Worker 
412*35238bceSAndroid Build Coastguard Worker     /* Shaders compilation */
413*35238bceSAndroid Build Coastguard Worker     glw::GLint compilation_status = GL_FALSE;
414*35238bceSAndroid Build Coastguard Worker 
415*35238bceSAndroid Build Coastguard Worker     for (unsigned int stage = 0; stage < sh_stages; ++stage)
416*35238bceSAndroid Build Coastguard Worker     {
417*35238bceSAndroid Build Coastguard Worker         glw::GLuint sh_id          = va_arg(values, glw::GLuint);
418*35238bceSAndroid Build Coastguard Worker         unsigned int sh_parts      = va_arg(values, unsigned int);
419*35238bceSAndroid Build Coastguard Worker         const char *const *sh_code = va_arg(values, const char *const *);
420*35238bceSAndroid Build Coastguard Worker 
421*35238bceSAndroid Build Coastguard Worker         if (sh_id == 0)
422*35238bceSAndroid Build Coastguard Worker         {
423*35238bceSAndroid Build Coastguard Worker             continue;
424*35238bceSAndroid Build Coastguard Worker         }
425*35238bceSAndroid Build Coastguard Worker 
426*35238bceSAndroid Build Coastguard Worker         if (sh_parts != 0)
427*35238bceSAndroid Build Coastguard Worker         {
428*35238bceSAndroid Build Coastguard Worker             std::string sh_merged_string = specializeShader(sh_parts, sh_code);
429*35238bceSAndroid Build Coastguard Worker             const char *sh_merged_ptr    = sh_merged_string.c_str();
430*35238bceSAndroid Build Coastguard Worker 
431*35238bceSAndroid Build Coastguard Worker             gl.shaderSource(sh_id, 1, &sh_merged_ptr, NULL);
432*35238bceSAndroid Build Coastguard Worker             GLU_EXPECT_NO_ERROR(gl.getError(), "glShaderSource() failed!");
433*35238bceSAndroid Build Coastguard Worker 
434*35238bceSAndroid Build Coastguard Worker             gl.compileShader(sh_id);
435*35238bceSAndroid Build Coastguard Worker             GLU_EXPECT_NO_ERROR(gl.getError(), "glCompileShader() failed!");
436*35238bceSAndroid Build Coastguard Worker 
437*35238bceSAndroid Build Coastguard Worker             gl.getShaderiv(sh_id, GL_COMPILE_STATUS, &compilation_status);
438*35238bceSAndroid Build Coastguard Worker             GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv() failed!");
439*35238bceSAndroid Build Coastguard Worker 
440*35238bceSAndroid Build Coastguard Worker             if (compilation_status != GL_TRUE)
441*35238bceSAndroid Build Coastguard Worker             {
442*35238bceSAndroid Build Coastguard Worker                 glw::GLint shader_type = 0;
443*35238bceSAndroid Build Coastguard Worker                 std::string info_log   = getCompilationInfoLog(sh_id);
444*35238bceSAndroid Build Coastguard Worker 
445*35238bceSAndroid Build Coastguard Worker                 gl.getShaderiv(sh_id, GL_SHADER_TYPE, &shader_type);
446*35238bceSAndroid Build Coastguard Worker                 std::string shader_type_str = getShaderTypeName(shader_type);
447*35238bceSAndroid Build Coastguard Worker 
448*35238bceSAndroid Build Coastguard Worker                 m_testCtx.getLog() << tcu::TestLog::Message << shader_type_str << " compilation failure:\n\n"
449*35238bceSAndroid Build Coastguard Worker                                    << info_log << "\n\n"
450*35238bceSAndroid Build Coastguard Worker                                    << shader_type_str << " source:\n\n"
451*35238bceSAndroid Build Coastguard Worker                                    << sh_merged_string << "\n\n"
452*35238bceSAndroid Build Coastguard Worker                                    << tcu::TestLog::EndMessage;
453*35238bceSAndroid Build Coastguard Worker 
454*35238bceSAndroid Build Coastguard Worker                 break;
455*35238bceSAndroid Build Coastguard Worker             }
456*35238bceSAndroid Build Coastguard Worker         }
457*35238bceSAndroid Build Coastguard Worker 
458*35238bceSAndroid Build Coastguard Worker         gl.attachShader(po_id, sh_id);
459*35238bceSAndroid Build Coastguard Worker         GLU_EXPECT_NO_ERROR(gl.getError(), "glAttachShader(VERTEX_SHADER) call failed");
460*35238bceSAndroid Build Coastguard Worker 
461*35238bceSAndroid Build Coastguard Worker         vec_sh_id.push_back(sh_id);
462*35238bceSAndroid Build Coastguard Worker     }
463*35238bceSAndroid Build Coastguard Worker 
464*35238bceSAndroid Build Coastguard Worker     va_end(values);
465*35238bceSAndroid Build Coastguard Worker 
466*35238bceSAndroid Build Coastguard Worker     if (out_has_compilation_failed != NULL)
467*35238bceSAndroid Build Coastguard Worker     {
468*35238bceSAndroid Build Coastguard Worker         *out_has_compilation_failed = (compilation_status == GL_FALSE);
469*35238bceSAndroid Build Coastguard Worker     }
470*35238bceSAndroid Build Coastguard Worker 
471*35238bceSAndroid Build Coastguard Worker     if (compilation_status != GL_TRUE)
472*35238bceSAndroid Build Coastguard Worker     {
473*35238bceSAndroid Build Coastguard Worker         return false;
474*35238bceSAndroid Build Coastguard Worker     }
475*35238bceSAndroid Build Coastguard Worker 
476*35238bceSAndroid Build Coastguard Worker     /* Linking the program */
477*35238bceSAndroid Build Coastguard Worker 
478*35238bceSAndroid Build Coastguard Worker     glw::GLint link_status = GL_FALSE;
479*35238bceSAndroid Build Coastguard Worker     gl.linkProgram(po_id);
480*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(gl.getError(), "glLinkProgram() failed!");
481*35238bceSAndroid Build Coastguard Worker 
482*35238bceSAndroid Build Coastguard Worker     gl.getProgramiv(po_id, GL_LINK_STATUS, &link_status);
483*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramiv() failed!");
484*35238bceSAndroid Build Coastguard Worker 
485*35238bceSAndroid Build Coastguard Worker     if (link_status != GL_TRUE)
486*35238bceSAndroid Build Coastguard Worker     {
487*35238bceSAndroid Build Coastguard Worker         /* Dump link log */
488*35238bceSAndroid Build Coastguard Worker         std::string link_log = getLinkingInfoLog(po_id);
489*35238bceSAndroid Build Coastguard Worker         m_testCtx.getLog() << tcu::TestLog::Message << "Link failure:\n\n"
490*35238bceSAndroid Build Coastguard Worker                            << link_log << "\n\n"
491*35238bceSAndroid Build Coastguard Worker                            << tcu::TestLog::EndMessage;
492*35238bceSAndroid Build Coastguard Worker 
493*35238bceSAndroid Build Coastguard Worker         /* Dump shader source */
494*35238bceSAndroid Build Coastguard Worker         for (std::vector<glw::GLuint>::iterator it = vec_sh_id.begin(); it != vec_sh_id.end(); ++it)
495*35238bceSAndroid Build Coastguard Worker         {
496*35238bceSAndroid Build Coastguard Worker             glw::GLint shader_type = 0;
497*35238bceSAndroid Build Coastguard Worker             gl.getShaderiv(*it, GL_SHADER_TYPE, &shader_type);
498*35238bceSAndroid Build Coastguard Worker             std::string shader_type_str = getShaderTypeName(shader_type);
499*35238bceSAndroid Build Coastguard Worker             std::string shader_source   = getShaderSource(*it);
500*35238bceSAndroid Build Coastguard Worker             m_testCtx.getLog() << tcu::TestLog::Message << shader_type_str << " source:\n\n"
501*35238bceSAndroid Build Coastguard Worker                                << shader_source << "\n\n"
502*35238bceSAndroid Build Coastguard Worker                                << tcu::TestLog::EndMessage;
503*35238bceSAndroid Build Coastguard Worker         }
504*35238bceSAndroid Build Coastguard Worker 
505*35238bceSAndroid Build Coastguard Worker         return false;
506*35238bceSAndroid Build Coastguard Worker     }
507*35238bceSAndroid Build Coastguard Worker 
508*35238bceSAndroid Build Coastguard Worker     return true;
509*35238bceSAndroid Build Coastguard Worker }
510*35238bceSAndroid Build Coastguard Worker 
511*35238bceSAndroid Build Coastguard Worker /** Builds an OpenGL ES program by configuring contents of 1 shader object,
512*35238bceSAndroid Build Coastguard Worker  *  compiling it, attaching to specified program object, and finally
513*35238bceSAndroid Build Coastguard Worker  *  by linking the program object.
514*35238bceSAndroid Build Coastguard Worker  *
515*35238bceSAndroid Build Coastguard Worker  *  Implementation assumes all aforementioned objects have already been
516*35238bceSAndroid Build Coastguard Worker  *  generated.
517*35238bceSAndroid Build Coastguard Worker  *
518*35238bceSAndroid Build Coastguard Worker  *  @param po_id            ID of program object
519*35238bceSAndroid Build Coastguard Worker  *  @param sh1_shader_id    ID of first shader to configure.
520*35238bceSAndroid Build Coastguard Worker  *  @param n_sh1_body_parts Number of elements of @param sh1_body_parts array.
521*35238bceSAndroid Build Coastguard Worker  *  @param sh1_body_parts   Pointer to array of strings to make up first shader's body.
522*35238bceSAndroid Build Coastguard Worker  *                          Can be NULL.
523*35238bceSAndroid Build Coastguard Worker  *
524*35238bceSAndroid Build Coastguard Worker  *  @return GTFtrue if successful, false otherwise.
525*35238bceSAndroid Build Coastguard Worker  */
buildProgram(glw::GLuint po_id,glw::GLuint sh1_shader_id,unsigned int n_sh1_body_parts,const char * const * sh1_body_parts,bool * out_has_compilation_failed)526*35238bceSAndroid Build Coastguard Worker bool TestCaseBase::buildProgram(glw::GLuint po_id, glw::GLuint sh1_shader_id, unsigned int n_sh1_body_parts,
527*35238bceSAndroid Build Coastguard Worker                                 const char *const *sh1_body_parts, bool *out_has_compilation_failed)
528*35238bceSAndroid Build Coastguard Worker {
529*35238bceSAndroid Build Coastguard Worker     return buildProgramVA(po_id, out_has_compilation_failed, 1, sh1_shader_id, n_sh1_body_parts, sh1_body_parts);
530*35238bceSAndroid Build Coastguard Worker }
531*35238bceSAndroid Build Coastguard Worker 
532*35238bceSAndroid Build Coastguard Worker /** Builds an OpenGL ES program by configuring contents of 2 shader objects,
533*35238bceSAndroid Build Coastguard Worker  *  compiling them, attaching to specified program object, and finally
534*35238bceSAndroid Build Coastguard Worker  *  by linking the program object.
535*35238bceSAndroid Build Coastguard Worker  *
536*35238bceSAndroid Build Coastguard Worker  *  Implementation assumes all aforementioned objects have already been
537*35238bceSAndroid Build Coastguard Worker  *  generated.
538*35238bceSAndroid Build Coastguard Worker  *
539*35238bceSAndroid Build Coastguard Worker  *  @param po_id            ID of program object
540*35238bceSAndroid Build Coastguard Worker  *  @param sh1_shader_id    ID of first shader to configure.
541*35238bceSAndroid Build Coastguard Worker  *  @param n_sh1_body_parts Number of elements of @param sh1_body_parts array.
542*35238bceSAndroid Build Coastguard Worker  *  @param sh1_body_parts   Pointer to array of strings to make up first shader's body.
543*35238bceSAndroid Build Coastguard Worker  *                          Can be NULL.
544*35238bceSAndroid Build Coastguard Worker  *  @param sh2_shader_id    ID of second shader to configure.
545*35238bceSAndroid Build Coastguard Worker  *  @param n_sh2_body_parts Number of elements of @param sh2_body_parts array.
546*35238bceSAndroid Build Coastguard Worker  *  @param sh2_body_parts   Pointer to array of strings to make up second shader's body.
547*35238bceSAndroid Build Coastguard Worker  *                          Can be NULL.
548*35238bceSAndroid Build Coastguard Worker  *
549*35238bceSAndroid Build Coastguard Worker  *  @return GTFtrue if successful, false otherwise.
550*35238bceSAndroid Build Coastguard Worker  */
buildProgram(glw::GLuint po_id,glw::GLuint sh1_shader_id,unsigned int n_sh1_body_parts,const char * const * sh1_body_parts,glw::GLuint sh2_shader_id,unsigned int n_sh2_body_parts,const char * const * sh2_body_parts,bool * out_has_compilation_failed)551*35238bceSAndroid Build Coastguard Worker bool TestCaseBase::buildProgram(glw::GLuint po_id, glw::GLuint sh1_shader_id, unsigned int n_sh1_body_parts,
552*35238bceSAndroid Build Coastguard Worker                                 const char *const *sh1_body_parts, glw::GLuint sh2_shader_id,
553*35238bceSAndroid Build Coastguard Worker                                 unsigned int n_sh2_body_parts, const char *const *sh2_body_parts,
554*35238bceSAndroid Build Coastguard Worker                                 bool *out_has_compilation_failed)
555*35238bceSAndroid Build Coastguard Worker {
556*35238bceSAndroid Build Coastguard Worker     return buildProgramVA(po_id, out_has_compilation_failed, 2, sh1_shader_id, n_sh1_body_parts, sh1_body_parts,
557*35238bceSAndroid Build Coastguard Worker                           sh2_shader_id, n_sh2_body_parts, sh2_body_parts);
558*35238bceSAndroid Build Coastguard Worker }
559*35238bceSAndroid Build Coastguard Worker 
560*35238bceSAndroid Build Coastguard Worker /** Builds an OpenGL ES program by configuring contents of 3 shader objects,
561*35238bceSAndroid Build Coastguard Worker  *  compiling them, attaching to specified program object, and finally
562*35238bceSAndroid Build Coastguard Worker  *  by linking the program object.
563*35238bceSAndroid Build Coastguard Worker  *
564*35238bceSAndroid Build Coastguard Worker  *  Implementation assumes all aforementioned objects have already been
565*35238bceSAndroid Build Coastguard Worker  *  generated.
566*35238bceSAndroid Build Coastguard Worker  *
567*35238bceSAndroid Build Coastguard Worker  *  @param po_id                  ID of program object
568*35238bceSAndroid Build Coastguard Worker  *  @param sh1_shader_id          ID of first shader to configure.
569*35238bceSAndroid Build Coastguard Worker  *  @param n_sh1_body_parts       Number of elements of @param sh1_body_parts array.
570*35238bceSAndroid Build Coastguard Worker  *  @param sh1_body_parts         Pointer to array of strings to make up first shader's body.
571*35238bceSAndroid Build Coastguard Worker  *                                Can be NULL.
572*35238bceSAndroid Build Coastguard Worker  *  @param sh2_shader_id          ID of second shader to configure.
573*35238bceSAndroid Build Coastguard Worker  *  @param n_sh2_body_parts       Number of elements of @param sh2_body_parts array.
574*35238bceSAndroid Build Coastguard Worker  *  @param sh2_body_parts         Pointer to array of strings to make up second shader's body.
575*35238bceSAndroid Build Coastguard Worker  *                                Can be NULL.
576*35238bceSAndroid Build Coastguard Worker  *  @param sh3_shader_id          ID of third shader to configure.
577*35238bceSAndroid Build Coastguard Worker  *  @param n_sh3_body_parts       Number of elements of @param sh3_body_parts array.
578*35238bceSAndroid Build Coastguard Worker  *  @param sh3_body_parts         Pointer to array of strings to make up third shader's body.
579*35238bceSAndroid Build Coastguard Worker  *                                Can be NULL.
580*35238bceSAndroid Build Coastguard Worker  *  @param has_compilation_failed Deref will be set to true if shader compilation failed,
581*35238bceSAndroid Build Coastguard Worker  *                                false if shader compilation was successful. Can be NULL.
582*35238bceSAndroid Build Coastguard Worker  *
583*35238bceSAndroid Build Coastguard Worker  *  @return GTFtrue if successful, false otherwise.
584*35238bceSAndroid Build Coastguard Worker  */
buildProgram(glw::GLuint po_id,glw::GLuint sh1_shader_id,unsigned int n_sh1_body_parts,const char * const * sh1_body_parts,glw::GLuint sh2_shader_id,unsigned int n_sh2_body_parts,const char * const * sh2_body_parts,glw::GLuint sh3_shader_id,unsigned int n_sh3_body_parts,const char * const * sh3_body_parts,bool * out_has_compilation_failed)585*35238bceSAndroid Build Coastguard Worker bool TestCaseBase::buildProgram(glw::GLuint po_id, glw::GLuint sh1_shader_id, unsigned int n_sh1_body_parts,
586*35238bceSAndroid Build Coastguard Worker                                 const char *const *sh1_body_parts, glw::GLuint sh2_shader_id,
587*35238bceSAndroid Build Coastguard Worker                                 unsigned int n_sh2_body_parts, const char *const *sh2_body_parts,
588*35238bceSAndroid Build Coastguard Worker                                 glw::GLuint sh3_shader_id, unsigned int n_sh3_body_parts,
589*35238bceSAndroid Build Coastguard Worker                                 const char *const *sh3_body_parts, bool *out_has_compilation_failed)
590*35238bceSAndroid Build Coastguard Worker {
591*35238bceSAndroid Build Coastguard Worker     return buildProgramVA(po_id, out_has_compilation_failed, 3, sh1_shader_id, n_sh1_body_parts, sh1_body_parts,
592*35238bceSAndroid Build Coastguard Worker                           sh2_shader_id, n_sh2_body_parts, sh2_body_parts, sh3_shader_id, n_sh3_body_parts,
593*35238bceSAndroid Build Coastguard Worker                           sh3_body_parts);
594*35238bceSAndroid Build Coastguard Worker }
595*35238bceSAndroid Build Coastguard Worker 
596*35238bceSAndroid Build Coastguard Worker /** Builds an OpenGL ES program by configuring contents of 4 shader objects,
597*35238bceSAndroid Build Coastguard Worker  *  compiling them, attaching to specified program object, and finally
598*35238bceSAndroid Build Coastguard Worker  *  by linking the program object.
599*35238bceSAndroid Build Coastguard Worker  *
600*35238bceSAndroid Build Coastguard Worker  *  Implementation assumes all aforementioned objects have already been
601*35238bceSAndroid Build Coastguard Worker  *  generated.
602*35238bceSAndroid Build Coastguard Worker  *
603*35238bceSAndroid Build Coastguard Worker  *  @param po_id            ID of program object
604*35238bceSAndroid Build Coastguard Worker  *  @param sh1_shader_id    ID of first shader to configure.
605*35238bceSAndroid Build Coastguard Worker  *  @param n_sh1_body_parts Number of elements of @param sh1_body_parts array.
606*35238bceSAndroid Build Coastguard Worker  *  @param sh1_body_parts   Pointer to array of strings to make up first shader's body.
607*35238bceSAndroid Build Coastguard Worker  *                          Can be NULL.
608*35238bceSAndroid Build Coastguard Worker  *  @param sh2_shader_id    ID of second shader to configure.
609*35238bceSAndroid Build Coastguard Worker  *  @param n_sh2_body_parts Number of elements of @param sh2_body_parts array.
610*35238bceSAndroid Build Coastguard Worker  *  @param sh2_body_parts   Pointer to array of strings to make up second shader's body.
611*35238bceSAndroid Build Coastguard Worker  *                          Can be NULL.
612*35238bceSAndroid Build Coastguard Worker  *  @param sh3_shader_id    ID of third shader to configure.
613*35238bceSAndroid Build Coastguard Worker  *  @param n_sh3_body_parts Number of elements of @param sh3_body_parts array.
614*35238bceSAndroid Build Coastguard Worker  *  @param sh3_body_parts   Pointer to array of strings to make up third shader's body.
615*35238bceSAndroid Build Coastguard Worker  *                          Can be NULL.
616*35238bceSAndroid Build Coastguard Worker  *  @param sh4_shader_id    ID of fourth shader to configure.
617*35238bceSAndroid Build Coastguard Worker  *  @param n_sh4_body_parts Number of elements of @param sh4_body_parts array.
618*35238bceSAndroid Build Coastguard Worker  *  @param sh4_body_parts   Pointer to array of strings to make up fourth shader's body.
619*35238bceSAndroid Build Coastguard Worker  *                          Can be NULL.
620*35238bceSAndroid Build Coastguard Worker  *
621*35238bceSAndroid Build Coastguard Worker  *  @return GTFtrue if successful, false otherwise.
622*35238bceSAndroid Build Coastguard Worker  */
buildProgram(glw::GLuint po_id,glw::GLuint sh1_shader_id,unsigned int n_sh1_body_parts,const char * const * sh1_body_parts,glw::GLuint sh2_shader_id,unsigned int n_sh2_body_parts,const char * const * sh2_body_parts,glw::GLuint sh3_shader_id,unsigned int n_sh3_body_parts,const char * const * sh3_body_parts,glw::GLuint sh4_shader_id,unsigned int n_sh4_body_parts,const char * const * sh4_body_parts,bool * out_has_compilation_failed)623*35238bceSAndroid Build Coastguard Worker bool TestCaseBase::buildProgram(glw::GLuint po_id, glw::GLuint sh1_shader_id, unsigned int n_sh1_body_parts,
624*35238bceSAndroid Build Coastguard Worker                                 const char *const *sh1_body_parts, glw::GLuint sh2_shader_id,
625*35238bceSAndroid Build Coastguard Worker                                 unsigned int n_sh2_body_parts, const char *const *sh2_body_parts,
626*35238bceSAndroid Build Coastguard Worker                                 glw::GLuint sh3_shader_id, unsigned int n_sh3_body_parts,
627*35238bceSAndroid Build Coastguard Worker                                 const char *const *sh3_body_parts, glw::GLuint sh4_shader_id,
628*35238bceSAndroid Build Coastguard Worker                                 unsigned int n_sh4_body_parts, const char *const *sh4_body_parts,
629*35238bceSAndroid Build Coastguard Worker                                 bool *out_has_compilation_failed)
630*35238bceSAndroid Build Coastguard Worker {
631*35238bceSAndroid Build Coastguard Worker     return buildProgramVA(po_id, out_has_compilation_failed, 4, sh1_shader_id, n_sh1_body_parts, sh1_body_parts,
632*35238bceSAndroid Build Coastguard Worker                           sh2_shader_id, n_sh2_body_parts, sh2_body_parts, sh3_shader_id, n_sh3_body_parts,
633*35238bceSAndroid Build Coastguard Worker                           sh3_body_parts, sh4_shader_id, n_sh4_body_parts, sh4_body_parts);
634*35238bceSAndroid Build Coastguard Worker }
635*35238bceSAndroid Build Coastguard Worker 
636*35238bceSAndroid Build Coastguard Worker /** Builds an OpenGL ES program by configuring contents of 5 shader objects,
637*35238bceSAndroid Build Coastguard Worker  *  compiling them, attaching to specified program object, and finally
638*35238bceSAndroid Build Coastguard Worker  *  by linking the program object.
639*35238bceSAndroid Build Coastguard Worker  *
640*35238bceSAndroid Build Coastguard Worker  *  Implementation assumes all aforementioned objects have already been
641*35238bceSAndroid Build Coastguard Worker  *  generated.
642*35238bceSAndroid Build Coastguard Worker  *
643*35238bceSAndroid Build Coastguard Worker  *  @param po_id            ID of program object
644*35238bceSAndroid Build Coastguard Worker  *  @param sh1_shader_id    ID of first shader to configure.
645*35238bceSAndroid Build Coastguard Worker  *  @param n_sh1_body_parts Number of elements of @param sh1_body_parts array.
646*35238bceSAndroid Build Coastguard Worker  *  @param sh1_body_parts   Pointer to array of strings to make up first shader's body.
647*35238bceSAndroid Build Coastguard Worker  *                          Can be NULL.
648*35238bceSAndroid Build Coastguard Worker  *  @param sh2_shader_id    ID of second shader to configure.
649*35238bceSAndroid Build Coastguard Worker  *  @param n_sh2_body_parts Number of elements of @param sh2_body_parts array.
650*35238bceSAndroid Build Coastguard Worker  *  @param sh2_body_parts   Pointer to array of strings to make up second shader's body.
651*35238bceSAndroid Build Coastguard Worker  *                          Can be NULL.
652*35238bceSAndroid Build Coastguard Worker  *  @param sh3_shader_id    ID of third shader to configure.
653*35238bceSAndroid Build Coastguard Worker  *  @param n_sh3_body_parts Number of elements of @param sh3_body_parts array.
654*35238bceSAndroid Build Coastguard Worker  *  @param sh3_body_parts   Pointer to array of strings to make up third shader's body.
655*35238bceSAndroid Build Coastguard Worker  *                          Can be NULL.
656*35238bceSAndroid Build Coastguard Worker  *  @param sh4_shader_id    ID of fourth shader to configure.
657*35238bceSAndroid Build Coastguard Worker  *  @param n_sh4_body_parts Number of elements of @param sh4_body_parts array.
658*35238bceSAndroid Build Coastguard Worker  *  @param sh4_body_parts   Pointer to array of strings to make up fourth shader's body.
659*35238bceSAndroid Build Coastguard Worker  *                          Can be NULL.
660*35238bceSAndroid Build Coastguard Worker  *  @param sh5_shader_id    ID of fifth shader to configure.
661*35238bceSAndroid Build Coastguard Worker  *  @param n_sh5_body_parts Number of elements of @param sh5_body_parts array.
662*35238bceSAndroid Build Coastguard Worker  *  @param sh5_body_parts   Pointer to array of strings to make up fifth shader's body.
663*35238bceSAndroid Build Coastguard Worker  *                          Can be NULL.
664*35238bceSAndroid Build Coastguard Worker  *
665*35238bceSAndroid Build Coastguard Worker  *  @return GTFtrue if successful, false otherwise.
666*35238bceSAndroid Build Coastguard Worker  */
buildProgram(glw::GLuint po_id,glw::GLuint sh1_shader_id,unsigned int n_sh1_body_parts,const char * const * sh1_body_parts,glw::GLuint sh2_shader_id,unsigned int n_sh2_body_parts,const char * const * sh2_body_parts,glw::GLuint sh3_shader_id,unsigned int n_sh3_body_parts,const char * const * sh3_body_parts,glw::GLuint sh4_shader_id,unsigned int n_sh4_body_parts,const char * const * sh4_body_parts,glw::GLuint sh5_shader_id,unsigned int n_sh5_body_parts,const char * const * sh5_body_parts,bool * out_has_compilation_failed)667*35238bceSAndroid Build Coastguard Worker bool TestCaseBase::buildProgram(glw::GLuint po_id, glw::GLuint sh1_shader_id, unsigned int n_sh1_body_parts,
668*35238bceSAndroid Build Coastguard Worker                                 const char *const *sh1_body_parts, glw::GLuint sh2_shader_id,
669*35238bceSAndroid Build Coastguard Worker                                 unsigned int n_sh2_body_parts, const char *const *sh2_body_parts,
670*35238bceSAndroid Build Coastguard Worker                                 glw::GLuint sh3_shader_id, unsigned int n_sh3_body_parts,
671*35238bceSAndroid Build Coastguard Worker                                 const char *const *sh3_body_parts, glw::GLuint sh4_shader_id,
672*35238bceSAndroid Build Coastguard Worker                                 unsigned int n_sh4_body_parts, const char *const *sh4_body_parts,
673*35238bceSAndroid Build Coastguard Worker                                 glw::GLuint sh5_shader_id, unsigned int n_sh5_body_parts,
674*35238bceSAndroid Build Coastguard Worker                                 const char *const *sh5_body_parts, bool *out_has_compilation_failed)
675*35238bceSAndroid Build Coastguard Worker {
676*35238bceSAndroid Build Coastguard Worker     return buildProgramVA(po_id, out_has_compilation_failed, 5, sh1_shader_id, n_sh1_body_parts, sh1_body_parts,
677*35238bceSAndroid Build Coastguard Worker                           sh2_shader_id, n_sh2_body_parts, sh2_body_parts, sh3_shader_id, n_sh3_body_parts,
678*35238bceSAndroid Build Coastguard Worker                           sh3_body_parts, sh4_shader_id, n_sh4_body_parts, sh4_body_parts, sh5_shader_id,
679*35238bceSAndroid Build Coastguard Worker                           n_sh5_body_parts, sh5_body_parts);
680*35238bceSAndroid Build Coastguard Worker }
681*35238bceSAndroid Build Coastguard Worker 
682*35238bceSAndroid Build Coastguard Worker /** Compare pixel's color with specified value.
683*35238bceSAndroid Build Coastguard Worker  *  Assumptions:
684*35238bceSAndroid Build Coastguard Worker  *  - size of each channel is 1 byte
685*35238bceSAndroid Build Coastguard Worker  *  - channel order is R G B A
686*35238bceSAndroid Build Coastguard Worker  *  - lines are stored one after another, without any additional data
687*35238bceSAndroid Build Coastguard Worker  *
688*35238bceSAndroid Build Coastguard Worker  * @param buffer            Image data
689*35238bceSAndroid Build Coastguard Worker  * @param x                 X coordinate of pixel
690*35238bceSAndroid Build Coastguard Worker  * @param y                 Y coordinate of pixel
691*35238bceSAndroid Build Coastguard Worker  * @param width             Image width
692*35238bceSAndroid Build Coastguard Worker  * @param height            Image height
693*35238bceSAndroid Build Coastguard Worker  * @param pixel_size        Size of single pixel in bytes, eg. for RGBA8 it should be set to 4
694*35238bceSAndroid Build Coastguard Worker  * @param expected_red      Expected value of red channel, default is 0
695*35238bceSAndroid Build Coastguard Worker  * @param expected_green    Expected value of green channel, default is 0
696*35238bceSAndroid Build Coastguard Worker  * @param expected_blue     Expected value of blue channel, default is 0
697*35238bceSAndroid Build Coastguard Worker  * @param expected_alpha    Expected value of alpha channel, default is 0
698*35238bceSAndroid Build Coastguard Worker  *
699*35238bceSAndroid Build Coastguard Worker  * @retrun true    When pixel color matches expected values
700*35238bceSAndroid Build Coastguard Worker  *         false   When:
701*35238bceSAndroid Build Coastguard Worker  *                  - buffer is null_ptr
702*35238bceSAndroid Build Coastguard Worker  *                  - offset of pixel exceeds size of image
703*35238bceSAndroid Build Coastguard Worker  *                  - pixel_size is not in range <1 ; 4>
704*35238bceSAndroid Build Coastguard Worker  *                  - pixel color does not match expected values
705*35238bceSAndroid Build Coastguard Worker  **/
comparePixel(const unsigned char * buffer,unsigned int x,unsigned int y,unsigned int width,unsigned int height,unsigned int pixel_size,unsigned char expected_red,unsigned char expected_green,unsigned char expected_blue,unsigned char expected_alpha) const706*35238bceSAndroid Build Coastguard Worker bool TestCaseBase::comparePixel(const unsigned char *buffer, unsigned int x, unsigned int y, unsigned int width,
707*35238bceSAndroid Build Coastguard Worker                                 unsigned int height, unsigned int pixel_size, unsigned char expected_red,
708*35238bceSAndroid Build Coastguard Worker                                 unsigned char expected_green, unsigned char expected_blue,
709*35238bceSAndroid Build Coastguard Worker                                 unsigned char expected_alpha) const
710*35238bceSAndroid Build Coastguard Worker {
711*35238bceSAndroid Build Coastguard Worker     const unsigned int line_size    = width * pixel_size;
712*35238bceSAndroid Build Coastguard Worker     const unsigned int image_size   = height * line_size;
713*35238bceSAndroid Build Coastguard Worker     const unsigned int texel_offset = y * line_size + x * pixel_size;
714*35238bceSAndroid Build Coastguard Worker 
715*35238bceSAndroid Build Coastguard Worker     bool result = true;
716*35238bceSAndroid Build Coastguard Worker 
717*35238bceSAndroid Build Coastguard Worker     /* Quick checks */
718*35238bceSAndroid Build Coastguard Worker     if (0 == buffer)
719*35238bceSAndroid Build Coastguard Worker     {
720*35238bceSAndroid Build Coastguard Worker         return false;
721*35238bceSAndroid Build Coastguard Worker     }
722*35238bceSAndroid Build Coastguard Worker 
723*35238bceSAndroid Build Coastguard Worker     if (image_size < texel_offset)
724*35238bceSAndroid Build Coastguard Worker     {
725*35238bceSAndroid Build Coastguard Worker         return false;
726*35238bceSAndroid Build Coastguard Worker     }
727*35238bceSAndroid Build Coastguard Worker 
728*35238bceSAndroid Build Coastguard Worker     switch (pixel_size)
729*35238bceSAndroid Build Coastguard Worker     {
730*35238bceSAndroid Build Coastguard Worker     /* Fall through by design */
731*35238bceSAndroid Build Coastguard Worker     case 4:
732*35238bceSAndroid Build Coastguard Worker     {
733*35238bceSAndroid Build Coastguard Worker         result &= (expected_alpha == buffer[texel_offset + 3]);
734*35238bceSAndroid Build Coastguard Worker     }
735*35238bceSAndroid Build Coastguard Worker         /* Fallthrough */
736*35238bceSAndroid Build Coastguard Worker 
737*35238bceSAndroid Build Coastguard Worker     case 3:
738*35238bceSAndroid Build Coastguard Worker     {
739*35238bceSAndroid Build Coastguard Worker         result &= (expected_blue == buffer[texel_offset + 2]);
740*35238bceSAndroid Build Coastguard Worker     }
741*35238bceSAndroid Build Coastguard Worker         /* Fallthrough */
742*35238bceSAndroid Build Coastguard Worker 
743*35238bceSAndroid Build Coastguard Worker     case 2:
744*35238bceSAndroid Build Coastguard Worker     {
745*35238bceSAndroid Build Coastguard Worker         result &= (expected_green == buffer[texel_offset + 1]);
746*35238bceSAndroid Build Coastguard Worker     }
747*35238bceSAndroid Build Coastguard Worker         /* Fallthrough */
748*35238bceSAndroid Build Coastguard Worker 
749*35238bceSAndroid Build Coastguard Worker     case 1:
750*35238bceSAndroid Build Coastguard Worker     {
751*35238bceSAndroid Build Coastguard Worker         result &= (expected_red == buffer[texel_offset + 0]);
752*35238bceSAndroid Build Coastguard Worker 
753*35238bceSAndroid Build Coastguard Worker         break;
754*35238bceSAndroid Build Coastguard Worker     }
755*35238bceSAndroid Build Coastguard Worker 
756*35238bceSAndroid Build Coastguard Worker     default:
757*35238bceSAndroid Build Coastguard Worker     {
758*35238bceSAndroid Build Coastguard Worker         return false;
759*35238bceSAndroid Build Coastguard Worker     }
760*35238bceSAndroid Build Coastguard Worker     } /* switch (pixel_size) */
761*35238bceSAndroid Build Coastguard Worker 
762*35238bceSAndroid Build Coastguard Worker     return result;
763*35238bceSAndroid Build Coastguard Worker }
764*35238bceSAndroid Build Coastguard Worker 
765*35238bceSAndroid Build Coastguard Worker /** Checks whether a combination of fragment/geometry/vertex shader objects compiles and links into a program
766*35238bceSAndroid Build Coastguard Worker  *
767*35238bceSAndroid Build Coastguard Worker  *  @param n_fs_body_parts Number of elements of @param fs_body_parts array.
768*35238bceSAndroid Build Coastguard Worker  *  @param fs_body_parts   Pointer to array of strings to make up fragment shader's body.
769*35238bceSAndroid Build Coastguard Worker  *                         Must not be NULL.
770*35238bceSAndroid Build Coastguard Worker  *
771*35238bceSAndroid Build Coastguard Worker  *  @param n_gs_body_parts Number of elements of @param gs_body_parts array.
772*35238bceSAndroid Build Coastguard Worker  *  @param gs_body_parts   Pointer to array of strings to make up geometry shader's body.
773*35238bceSAndroid Build Coastguard Worker  *                         Can be NULL.
774*35238bceSAndroid Build Coastguard Worker  *
775*35238bceSAndroid Build Coastguard Worker  *  @param n_vs_body_parts Number of elements of @param vs_body_parts array.
776*35238bceSAndroid Build Coastguard Worker  *  @param vs_body_parts   Pointer to array of strings to make up vertex shader's body.
777*35238bceSAndroid Build Coastguard Worker  *                         Must not be NULL.
778*35238bceSAndroid Build Coastguard Worker  *
779*35238bceSAndroid Build Coastguard Worker  *  @return true if program creation was successful, false otherwise.
780*35238bceSAndroid Build Coastguard Worker  **/
doesProgramBuild(unsigned int n_fs_body_parts,const char * const * fs_body_parts,unsigned int n_gs_body_parts,const char * const * gs_body_parts,unsigned int n_vs_body_parts,const char * const * vs_body_parts)781*35238bceSAndroid Build Coastguard Worker bool TestCaseBase::doesProgramBuild(unsigned int n_fs_body_parts, const char *const *fs_body_parts,
782*35238bceSAndroid Build Coastguard Worker                                     unsigned int n_gs_body_parts, const char *const *gs_body_parts,
783*35238bceSAndroid Build Coastguard Worker                                     unsigned int n_vs_body_parts, const char *const *vs_body_parts)
784*35238bceSAndroid Build Coastguard Worker {
785*35238bceSAndroid Build Coastguard Worker     /* General variables */
786*35238bceSAndroid Build Coastguard Worker     const glw::Functions &gl = m_context.getRenderContext().getFunctions();
787*35238bceSAndroid Build Coastguard Worker     bool result              = false;
788*35238bceSAndroid Build Coastguard Worker 
789*35238bceSAndroid Build Coastguard Worker     /* Shaders */
790*35238bceSAndroid Build Coastguard Worker     glw::GLuint vertex_shader_id   = 0;
791*35238bceSAndroid Build Coastguard Worker     glw::GLuint geometry_shader_id = 0;
792*35238bceSAndroid Build Coastguard Worker     glw::GLuint fragment_shader_id = 0;
793*35238bceSAndroid Build Coastguard Worker 
794*35238bceSAndroid Build Coastguard Worker     /* Program */
795*35238bceSAndroid Build Coastguard Worker     glw::GLuint program_object_id = 0;
796*35238bceSAndroid Build Coastguard Worker 
797*35238bceSAndroid Build Coastguard Worker     /* Create shaders */
798*35238bceSAndroid Build Coastguard Worker     vertex_shader_id   = gl.createShader(GL_VERTEX_SHADER);
799*35238bceSAndroid Build Coastguard Worker     geometry_shader_id = gl.createShader(m_glExtTokens.GEOMETRY_SHADER);
800*35238bceSAndroid Build Coastguard Worker     fragment_shader_id = gl.createShader(GL_FRAGMENT_SHADER);
801*35238bceSAndroid Build Coastguard Worker 
802*35238bceSAndroid Build Coastguard Worker     /* Create program */
803*35238bceSAndroid Build Coastguard Worker     program_object_id = gl.createProgram();
804*35238bceSAndroid Build Coastguard Worker 
805*35238bceSAndroid Build Coastguard Worker     /* Check createProgram call for errors */
806*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateProgram() call failed.");
807*35238bceSAndroid Build Coastguard Worker 
808*35238bceSAndroid Build Coastguard Worker     /* Compile and link the program */
809*35238bceSAndroid Build Coastguard Worker     result = buildProgram(program_object_id, fragment_shader_id, n_fs_body_parts, fs_body_parts, geometry_shader_id,
810*35238bceSAndroid Build Coastguard Worker                           n_gs_body_parts, gs_body_parts, vertex_shader_id, n_vs_body_parts, vs_body_parts);
811*35238bceSAndroid Build Coastguard Worker 
812*35238bceSAndroid Build Coastguard Worker     if (program_object_id != 0)
813*35238bceSAndroid Build Coastguard Worker         gl.deleteProgram(program_object_id);
814*35238bceSAndroid Build Coastguard Worker     if (fragment_shader_id != 0)
815*35238bceSAndroid Build Coastguard Worker         gl.deleteShader(fragment_shader_id);
816*35238bceSAndroid Build Coastguard Worker     if (geometry_shader_id != 0)
817*35238bceSAndroid Build Coastguard Worker         gl.deleteShader(geometry_shader_id);
818*35238bceSAndroid Build Coastguard Worker     if (vertex_shader_id != 0)
819*35238bceSAndroid Build Coastguard Worker         gl.deleteShader(vertex_shader_id);
820*35238bceSAndroid Build Coastguard Worker 
821*35238bceSAndroid Build Coastguard Worker     return result;
822*35238bceSAndroid Build Coastguard Worker }
823*35238bceSAndroid Build Coastguard Worker 
824*35238bceSAndroid Build Coastguard Worker /** Retrieves source for a shader object with GLES id @param shader_id.
825*35238bceSAndroid Build Coastguard Worker  *
826*35238bceSAndroid Build Coastguard Worker  *  @param shader_id GLES id of a shader object to retrieve source for.
827*35238bceSAndroid Build Coastguard Worker  *
828*35238bceSAndroid Build Coastguard Worker  *  @return String instance containing the shader source.
829*35238bceSAndroid Build Coastguard Worker  **/
getShaderSource(glw::GLuint shader_id)830*35238bceSAndroid Build Coastguard Worker std::string TestCaseBase::getShaderSource(glw::GLuint shader_id)
831*35238bceSAndroid Build Coastguard Worker {
832*35238bceSAndroid Build Coastguard Worker     const glw::Functions &gl = m_context.getRenderContext().getFunctions();
833*35238bceSAndroid Build Coastguard Worker 
834*35238bceSAndroid Build Coastguard Worker     glw::GLint length = 0;
835*35238bceSAndroid Build Coastguard Worker 
836*35238bceSAndroid Build Coastguard Worker     gl.getShaderiv(shader_id, GL_SHADER_SOURCE_LENGTH, &length);
837*35238bceSAndroid Build Coastguard Worker 
838*35238bceSAndroid Build Coastguard Worker     std::vector<char> result_vec(length + 1);
839*35238bceSAndroid Build Coastguard Worker 
840*35238bceSAndroid Build Coastguard Worker     gl.getShaderSource(shader_id, length + 1, NULL, &result_vec[0]);
841*35238bceSAndroid Build Coastguard Worker 
842*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(gl.getError(), "Could not retrieve shader source!");
843*35238bceSAndroid Build Coastguard Worker 
844*35238bceSAndroid Build Coastguard Worker     return std::string(&result_vec[0]);
845*35238bceSAndroid Build Coastguard Worker }
846*35238bceSAndroid Build Coastguard Worker 
847*35238bceSAndroid Build Coastguard Worker /** Retrieves compilation info log for a shader object with GLES id
848*35238bceSAndroid Build Coastguard Worker  *  @param shader_id.
849*35238bceSAndroid Build Coastguard Worker  *
850*35238bceSAndroid Build Coastguard Worker  *  @param shader_id GLES id of a shader object to retrieve compilation
851*35238bceSAndroid Build Coastguard Worker  *          info log for.
852*35238bceSAndroid Build Coastguard Worker  *
853*35238bceSAndroid Build Coastguard Worker  *  @return String instance containing the log.
854*35238bceSAndroid Build Coastguard Worker  **/
getCompilationInfoLog(glw::GLuint shader_id)855*35238bceSAndroid Build Coastguard Worker std::string TestCaseBase::getCompilationInfoLog(glw::GLuint shader_id)
856*35238bceSAndroid Build Coastguard Worker {
857*35238bceSAndroid Build Coastguard Worker     return getInfoLog(LT_SHADER_OBJECT, shader_id);
858*35238bceSAndroid Build Coastguard Worker }
859*35238bceSAndroid Build Coastguard Worker 
860*35238bceSAndroid Build Coastguard Worker /** Retrieves linking info log for a program object with GLES id
861*35238bceSAndroid Build Coastguard Worker  *  @param po_id.
862*35238bceSAndroid Build Coastguard Worker  *
863*35238bceSAndroid Build Coastguard Worker  *  @param po_id GLES id of a program object to retrieve linking
864*35238bceSAndroid Build Coastguard Worker  *               info log for.
865*35238bceSAndroid Build Coastguard Worker  *
866*35238bceSAndroid Build Coastguard Worker  *  @return String instance containing the log.
867*35238bceSAndroid Build Coastguard Worker  **/
getLinkingInfoLog(glw::GLuint po_id)868*35238bceSAndroid Build Coastguard Worker std::string TestCaseBase::getLinkingInfoLog(glw::GLuint po_id)
869*35238bceSAndroid Build Coastguard Worker {
870*35238bceSAndroid Build Coastguard Worker     return getInfoLog(LT_PROGRAM_OBJECT, po_id);
871*35238bceSAndroid Build Coastguard Worker }
872*35238bceSAndroid Build Coastguard Worker 
873*35238bceSAndroid Build Coastguard Worker /** Retrieves linking info log for a pipeline object with GLES id
874*35238bceSAndroid Build Coastguard Worker  *  @param ppo_id.
875*35238bceSAndroid Build Coastguard Worker  *
876*35238bceSAndroid Build Coastguard Worker  *  @param ppo_id GLES id of a pipeline object to retrieve validation
877*35238bceSAndroid Build Coastguard Worker  *               info log for.
878*35238bceSAndroid Build Coastguard Worker  *
879*35238bceSAndroid Build Coastguard Worker  *  @return String instance containing the log.
880*35238bceSAndroid Build Coastguard Worker  **/
getPipelineInfoLog(glw::GLuint ppo_id)881*35238bceSAndroid Build Coastguard Worker std::string TestCaseBase::getPipelineInfoLog(glw::GLuint ppo_id)
882*35238bceSAndroid Build Coastguard Worker {
883*35238bceSAndroid Build Coastguard Worker     return getInfoLog(LT_PIPELINE_OBJECT, ppo_id);
884*35238bceSAndroid Build Coastguard Worker }
885*35238bceSAndroid Build Coastguard Worker 
886*35238bceSAndroid Build Coastguard Worker /** Retrieves compilation OR linking info log for a shader/program object with GLES id
887*35238bceSAndroid Build Coastguard Worker  *  @param id.
888*35238bceSAndroid Build Coastguard Worker  *
889*35238bceSAndroid Build Coastguard Worker  *  @param is_compilation_info_log true if @param id is a GLES id of a shader object;
890*35238bceSAndroid Build Coastguard Worker  *                                 false if it represents a program object.
891*35238bceSAndroid Build Coastguard Worker  *  @param id                      GLES id of a shader OR a program object to
892*35238bceSAndroid Build Coastguard Worker  *                                 retrieve info log for.
893*35238bceSAndroid Build Coastguard Worker  *
894*35238bceSAndroid Build Coastguard Worker  *  @return String instance containing the log..
895*35238bceSAndroid Build Coastguard Worker  **/
getInfoLog(LOG_TYPE log_type,glw::GLuint id)896*35238bceSAndroid Build Coastguard Worker std::string TestCaseBase::getInfoLog(LOG_TYPE log_type, glw::GLuint id)
897*35238bceSAndroid Build Coastguard Worker {
898*35238bceSAndroid Build Coastguard Worker     const glw::Functions &gl = m_context.getRenderContext().getFunctions();
899*35238bceSAndroid Build Coastguard Worker 
900*35238bceSAndroid Build Coastguard Worker     glw::GLint n_characters = 0;
901*35238bceSAndroid Build Coastguard Worker     /* Retrieve amount of characters needed to store the info log (terminator-inclusive) */
902*35238bceSAndroid Build Coastguard Worker     switch (log_type)
903*35238bceSAndroid Build Coastguard Worker     {
904*35238bceSAndroid Build Coastguard Worker     case LT_SHADER_OBJECT:
905*35238bceSAndroid Build Coastguard Worker         gl.getShaderiv(id, GL_INFO_LOG_LENGTH, &n_characters);
906*35238bceSAndroid Build Coastguard Worker         break;
907*35238bceSAndroid Build Coastguard Worker     case LT_PROGRAM_OBJECT:
908*35238bceSAndroid Build Coastguard Worker         gl.getProgramiv(id, GL_INFO_LOG_LENGTH, &n_characters);
909*35238bceSAndroid Build Coastguard Worker         break;
910*35238bceSAndroid Build Coastguard Worker     case LT_PIPELINE_OBJECT:
911*35238bceSAndroid Build Coastguard Worker         gl.getProgramPipelineiv(id, GL_INFO_LOG_LENGTH, &n_characters);
912*35238bceSAndroid Build Coastguard Worker         break;
913*35238bceSAndroid Build Coastguard Worker     default:
914*35238bceSAndroid Build Coastguard Worker         TCU_FAIL("Invalid parameter");
915*35238bceSAndroid Build Coastguard Worker     }
916*35238bceSAndroid Build Coastguard Worker 
917*35238bceSAndroid Build Coastguard Worker     /* Check if everything is fine so far */
918*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(gl.getError(), "Could not query info log length!");
919*35238bceSAndroid Build Coastguard Worker 
920*35238bceSAndroid Build Coastguard Worker     /* Allocate buffer */
921*35238bceSAndroid Build Coastguard Worker     std::vector<char> result_vec(n_characters + 1);
922*35238bceSAndroid Build Coastguard Worker 
923*35238bceSAndroid Build Coastguard Worker     /* Retrieve the info log */
924*35238bceSAndroid Build Coastguard Worker     switch (log_type)
925*35238bceSAndroid Build Coastguard Worker     {
926*35238bceSAndroid Build Coastguard Worker     case LT_SHADER_OBJECT:
927*35238bceSAndroid Build Coastguard Worker         gl.getShaderInfoLog(id, n_characters + 1, 0, &result_vec[0]);
928*35238bceSAndroid Build Coastguard Worker         break;
929*35238bceSAndroid Build Coastguard Worker     case LT_PROGRAM_OBJECT:
930*35238bceSAndroid Build Coastguard Worker         gl.getProgramInfoLog(id, n_characters + 1, 0, &result_vec[0]);
931*35238bceSAndroid Build Coastguard Worker         break;
932*35238bceSAndroid Build Coastguard Worker     case LT_PIPELINE_OBJECT:
933*35238bceSAndroid Build Coastguard Worker         gl.getProgramPipelineInfoLog(id, n_characters + 1, 0, &result_vec[0]);
934*35238bceSAndroid Build Coastguard Worker         break;
935*35238bceSAndroid Build Coastguard Worker     }
936*35238bceSAndroid Build Coastguard Worker 
937*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(gl.getError(), "Could not retrieve info log!");
938*35238bceSAndroid Build Coastguard Worker 
939*35238bceSAndroid Build Coastguard Worker     return std::string(&result_vec[0]);
940*35238bceSAndroid Build Coastguard Worker }
941*35238bceSAndroid Build Coastguard Worker 
942*35238bceSAndroid Build Coastguard Worker /** Setup frame buffer:
943*35238bceSAndroid Build Coastguard Worker  * 1 allocate texture storage for specified format and dimensions,
944*35238bceSAndroid Build Coastguard Worker  * 2 bind framebuffer and attach texture to GL_COLOR_ATTACHMENT0
945*35238bceSAndroid Build Coastguard Worker  * 3 setup viewport to specified dimensions
946*35238bceSAndroid Build Coastguard Worker  *
947*35238bceSAndroid Build Coastguard Worker  * @param framebuffer_object_id FBO handle
948*35238bceSAndroid Build Coastguard Worker  * @param color_texture_id      Texture handle
949*35238bceSAndroid Build Coastguard Worker  * @param texture_format        Requested texture format, eg. GL_RGBA8
950*35238bceSAndroid Build Coastguard Worker  * @param texture_width         Requested texture width
951*35238bceSAndroid Build Coastguard Worker  * @param texture_height        Requested texture height
952*35238bceSAndroid Build Coastguard Worker  *
953*35238bceSAndroid Build Coastguard Worker  * @return true  All operations succeded
954*35238bceSAndroid Build Coastguard Worker  *         false In case of any error
955*35238bceSAndroid Build Coastguard Worker  **/
setupFramebufferWithTextureAsAttachment(glw::GLuint framebuffer_object_id,glw::GLuint color_texture_id,glw::GLenum texture_format,glw::GLuint texture_width,glw::GLuint texture_height) const956*35238bceSAndroid Build Coastguard Worker bool TestCaseBase::setupFramebufferWithTextureAsAttachment(glw::GLuint framebuffer_object_id,
957*35238bceSAndroid Build Coastguard Worker                                                            glw::GLuint color_texture_id, glw::GLenum texture_format,
958*35238bceSAndroid Build Coastguard Worker                                                            glw::GLuint texture_width, glw::GLuint texture_height) const
959*35238bceSAndroid Build Coastguard Worker {
960*35238bceSAndroid Build Coastguard Worker     const glw::Functions &gl = m_context.getRenderContext().getFunctions();
961*35238bceSAndroid Build Coastguard Worker 
962*35238bceSAndroid Build Coastguard Worker     /* Allocate texture storage */
963*35238bceSAndroid Build Coastguard Worker     gl.bindTexture(GL_TEXTURE_2D, color_texture_id);
964*35238bceSAndroid Build Coastguard Worker     gl.texStorage2D(GL_TEXTURE_2D, 1 /* levels */, texture_format, texture_width, texture_height);
965*35238bceSAndroid Build Coastguard Worker 
966*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(gl.getError(), "Could not allocate texture storage!");
967*35238bceSAndroid Build Coastguard Worker 
968*35238bceSAndroid Build Coastguard Worker     /* Setup framebuffer */
969*35238bceSAndroid Build Coastguard Worker     gl.bindFramebuffer(GL_FRAMEBUFFER, framebuffer_object_id);
970*35238bceSAndroid Build Coastguard Worker     gl.framebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, color_texture_id, 0 /* level */);
971*35238bceSAndroid Build Coastguard Worker 
972*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(gl.getError(), "Could not setup framebuffer!");
973*35238bceSAndroid Build Coastguard Worker 
974*35238bceSAndroid Build Coastguard Worker     /* Setup viewport */
975*35238bceSAndroid Build Coastguard Worker     gl.viewport(0, 0, texture_width, texture_height);
976*35238bceSAndroid Build Coastguard Worker 
977*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(gl.getError(), "Could not setup viewport!");
978*35238bceSAndroid Build Coastguard Worker 
979*35238bceSAndroid Build Coastguard Worker     /* Success */
980*35238bceSAndroid Build Coastguard Worker     return true;
981*35238bceSAndroid Build Coastguard Worker }
982*35238bceSAndroid Build Coastguard Worker 
983*35238bceSAndroid Build Coastguard Worker /** Check Framebuffer Status.
984*35238bceSAndroid Build Coastguard Worker  *   Throws a TestError exception, should the framebuffer be found incomplete.
985*35238bceSAndroid Build Coastguard Worker  *
986*35238bceSAndroid Build Coastguard Worker  *  @param framebuffer - GL_DRAW_FRAMEBUFFER, GL_READ_FRAMEBUFFER or GL_FRAMEBUFFER
987*35238bceSAndroid Build Coastguard Worker  *
988*35238bceSAndroid Build Coastguard Worker  */
checkFramebufferStatus(glw::GLenum framebuffer) const989*35238bceSAndroid Build Coastguard Worker void TestCaseBase::checkFramebufferStatus(glw::GLenum framebuffer) const
990*35238bceSAndroid Build Coastguard Worker {
991*35238bceSAndroid Build Coastguard Worker     /* Get GL entry points */
992*35238bceSAndroid Build Coastguard Worker     const glw::Functions &gl = m_context.getRenderContext().getFunctions();
993*35238bceSAndroid Build Coastguard Worker 
994*35238bceSAndroid Build Coastguard Worker     glw::GLenum framebuffer_status = gl.checkFramebufferStatus(framebuffer);
995*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(gl.getError(), "Error getting framebuffer status!");
996*35238bceSAndroid Build Coastguard Worker 
997*35238bceSAndroid Build Coastguard Worker     if (GL_FRAMEBUFFER_COMPLETE != framebuffer_status)
998*35238bceSAndroid Build Coastguard Worker     {
999*35238bceSAndroid Build Coastguard Worker         switch (framebuffer_status)
1000*35238bceSAndroid Build Coastguard Worker         {
1001*35238bceSAndroid Build Coastguard Worker         case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
1002*35238bceSAndroid Build Coastguard Worker         {
1003*35238bceSAndroid Build Coastguard Worker             TCU_FAIL("Framebuffer incomplete, status: GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT");
1004*35238bceSAndroid Build Coastguard Worker         }
1005*35238bceSAndroid Build Coastguard Worker 
1006*35238bceSAndroid Build Coastguard Worker         case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
1007*35238bceSAndroid Build Coastguard Worker         {
1008*35238bceSAndroid Build Coastguard Worker             TCU_FAIL("Framebuffer incomplete, status: GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS");
1009*35238bceSAndroid Build Coastguard Worker         }
1010*35238bceSAndroid Build Coastguard Worker 
1011*35238bceSAndroid Build Coastguard Worker         case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
1012*35238bceSAndroid Build Coastguard Worker         {
1013*35238bceSAndroid Build Coastguard Worker             TCU_FAIL("Framebuffer incomplete, status: GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT");
1014*35238bceSAndroid Build Coastguard Worker         }
1015*35238bceSAndroid Build Coastguard Worker 
1016*35238bceSAndroid Build Coastguard Worker         case GL_FRAMEBUFFER_UNSUPPORTED:
1017*35238bceSAndroid Build Coastguard Worker         {
1018*35238bceSAndroid Build Coastguard Worker             TCU_FAIL("Framebuffer incomplete, status: Error: GL_FRAMEBUFFER_UNSUPPORTED");
1019*35238bceSAndroid Build Coastguard Worker         }
1020*35238bceSAndroid Build Coastguard Worker 
1021*35238bceSAndroid Build Coastguard Worker         default:
1022*35238bceSAndroid Build Coastguard Worker         {
1023*35238bceSAndroid Build Coastguard Worker             TCU_FAIL("Framebuffer incomplete, status not recognized");
1024*35238bceSAndroid Build Coastguard Worker         }
1025*35238bceSAndroid Build Coastguard Worker         } /* switch (framebuffer_status) */
1026*35238bceSAndroid Build Coastguard Worker     }     /* if (GL_FRAMEBUFFER_COMPLETE != framebuffer_status) */
1027*35238bceSAndroid Build Coastguard Worker }
1028*35238bceSAndroid Build Coastguard Worker 
getGLSLExtDirective(ExtensionType type,ExtensionName name,ExtensionBehavior behavior)1029*35238bceSAndroid Build Coastguard Worker std::string TestCaseBase::getGLSLExtDirective(ExtensionType type, ExtensionName name, ExtensionBehavior behavior)
1030*35238bceSAndroid Build Coastguard Worker {
1031*35238bceSAndroid Build Coastguard Worker     if (type == EXTENSIONTYPE_NONE && name != EXTENSIONNAME_GEOMETRY_POINT_SIZE &&
1032*35238bceSAndroid Build Coastguard Worker         name != EXTENSIONNAME_TESSELLATION_POINT_SIZE)
1033*35238bceSAndroid Build Coastguard Worker     {
1034*35238bceSAndroid Build Coastguard Worker         return "";
1035*35238bceSAndroid Build Coastguard Worker     }
1036*35238bceSAndroid Build Coastguard Worker 
1037*35238bceSAndroid Build Coastguard Worker     const char *type_str     = NULL;
1038*35238bceSAndroid Build Coastguard Worker     const char *name_str     = NULL;
1039*35238bceSAndroid Build Coastguard Worker     const char *behavior_str = NULL;
1040*35238bceSAndroid Build Coastguard Worker 
1041*35238bceSAndroid Build Coastguard Worker     if (name == EXTENSIONNAME_SHADER_IMAGE_ATOMIC)
1042*35238bceSAndroid Build Coastguard Worker     {
1043*35238bceSAndroid Build Coastguard Worker         // There is no EXT version of shader_image_atomic; use OES
1044*35238bceSAndroid Build Coastguard Worker         type = EXTENSIONTYPE_OES;
1045*35238bceSAndroid Build Coastguard Worker     }
1046*35238bceSAndroid Build Coastguard Worker 
1047*35238bceSAndroid Build Coastguard Worker     if (name == EXTENSIONNAME_TESSELLATION_POINT_SIZE)
1048*35238bceSAndroid Build Coastguard Worker     {
1049*35238bceSAndroid Build Coastguard Worker         // there is no core version of tessellation_point_size, use OES or EXT
1050*35238bceSAndroid Build Coastguard Worker         if (isExtensionSupported("GL_OES_tessellation_point_size"))
1051*35238bceSAndroid Build Coastguard Worker         {
1052*35238bceSAndroid Build Coastguard Worker             type = EXTENSIONTYPE_OES;
1053*35238bceSAndroid Build Coastguard Worker         }
1054*35238bceSAndroid Build Coastguard Worker         else if (isExtensionSupported("GL_EXT_tessellation_point_size"))
1055*35238bceSAndroid Build Coastguard Worker         {
1056*35238bceSAndroid Build Coastguard Worker             type = EXTENSIONTYPE_EXT;
1057*35238bceSAndroid Build Coastguard Worker         }
1058*35238bceSAndroid Build Coastguard Worker         else
1059*35238bceSAndroid Build Coastguard Worker         {
1060*35238bceSAndroid Build Coastguard Worker             return "";
1061*35238bceSAndroid Build Coastguard Worker         }
1062*35238bceSAndroid Build Coastguard Worker     }
1063*35238bceSAndroid Build Coastguard Worker 
1064*35238bceSAndroid Build Coastguard Worker     if (name == EXTENSIONNAME_GEOMETRY_POINT_SIZE)
1065*35238bceSAndroid Build Coastguard Worker     {
1066*35238bceSAndroid Build Coastguard Worker         // there is no core version of geometry_point_size, use OES or EXT
1067*35238bceSAndroid Build Coastguard Worker         if (isExtensionSupported("GL_OES_geometry_point_size"))
1068*35238bceSAndroid Build Coastguard Worker         {
1069*35238bceSAndroid Build Coastguard Worker             type = EXTENSIONTYPE_OES;
1070*35238bceSAndroid Build Coastguard Worker         }
1071*35238bceSAndroid Build Coastguard Worker         else if (isExtensionSupported("GL_EXT_geometry_point_size"))
1072*35238bceSAndroid Build Coastguard Worker         {
1073*35238bceSAndroid Build Coastguard Worker             type = EXTENSIONTYPE_EXT;
1074*35238bceSAndroid Build Coastguard Worker         }
1075*35238bceSAndroid Build Coastguard Worker         else
1076*35238bceSAndroid Build Coastguard Worker         {
1077*35238bceSAndroid Build Coastguard Worker             return "";
1078*35238bceSAndroid Build Coastguard Worker         }
1079*35238bceSAndroid Build Coastguard Worker     }
1080*35238bceSAndroid Build Coastguard Worker 
1081*35238bceSAndroid Build Coastguard Worker     switch (type)
1082*35238bceSAndroid Build Coastguard Worker     {
1083*35238bceSAndroid Build Coastguard Worker     case EXTENSIONTYPE_EXT:
1084*35238bceSAndroid Build Coastguard Worker         type_str = "EXT_";
1085*35238bceSAndroid Build Coastguard Worker         break;
1086*35238bceSAndroid Build Coastguard Worker     case EXTENSIONTYPE_OES:
1087*35238bceSAndroid Build Coastguard Worker         type_str = "OES_";
1088*35238bceSAndroid Build Coastguard Worker         break;
1089*35238bceSAndroid Build Coastguard Worker     default:
1090*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(0);
1091*35238bceSAndroid Build Coastguard Worker         return "#error unknown extension type\n";
1092*35238bceSAndroid Build Coastguard Worker     }
1093*35238bceSAndroid Build Coastguard Worker 
1094*35238bceSAndroid Build Coastguard Worker     switch (name)
1095*35238bceSAndroid Build Coastguard Worker     {
1096*35238bceSAndroid Build Coastguard Worker     case EXTENSIONNAME_SHADER_IMAGE_ATOMIC:
1097*35238bceSAndroid Build Coastguard Worker         name_str = "shader_image_atomic";
1098*35238bceSAndroid Build Coastguard Worker         break;
1099*35238bceSAndroid Build Coastguard Worker     case EXTENSIONNAME_SHADER_IO_BLOCKS:
1100*35238bceSAndroid Build Coastguard Worker         name_str = "shader_io_blocks";
1101*35238bceSAndroid Build Coastguard Worker         break;
1102*35238bceSAndroid Build Coastguard Worker     case EXTENSIONNAME_GEOMETRY_SHADER:
1103*35238bceSAndroid Build Coastguard Worker         name_str = "geometry_shader";
1104*35238bceSAndroid Build Coastguard Worker         break;
1105*35238bceSAndroid Build Coastguard Worker     case EXTENSIONNAME_GEOMETRY_POINT_SIZE:
1106*35238bceSAndroid Build Coastguard Worker         name_str = "geometry_point_size";
1107*35238bceSAndroid Build Coastguard Worker         break;
1108*35238bceSAndroid Build Coastguard Worker     case EXTENSIONNAME_TESSELLATION_SHADER:
1109*35238bceSAndroid Build Coastguard Worker         name_str = "tessellation_shader";
1110*35238bceSAndroid Build Coastguard Worker         break;
1111*35238bceSAndroid Build Coastguard Worker     case EXTENSIONNAME_TESSELLATION_POINT_SIZE:
1112*35238bceSAndroid Build Coastguard Worker         name_str = "tessellation_point_size";
1113*35238bceSAndroid Build Coastguard Worker         break;
1114*35238bceSAndroid Build Coastguard Worker     case EXTENSIONNAME_TEXTURE_BUFFER:
1115*35238bceSAndroid Build Coastguard Worker         name_str = "texture_buffer";
1116*35238bceSAndroid Build Coastguard Worker         break;
1117*35238bceSAndroid Build Coastguard Worker     case EXTENSIONNAME_TEXTURE_CUBE_MAP_ARRAY:
1118*35238bceSAndroid Build Coastguard Worker         name_str = "texture_cube_map_array";
1119*35238bceSAndroid Build Coastguard Worker         break;
1120*35238bceSAndroid Build Coastguard Worker     case EXTENSIONNAME_GPU_SHADER5:
1121*35238bceSAndroid Build Coastguard Worker         name_str = "gpu_shader5";
1122*35238bceSAndroid Build Coastguard Worker         break;
1123*35238bceSAndroid Build Coastguard Worker     case EXTENSIONNAME_VIEWPORT_ARRAY:
1124*35238bceSAndroid Build Coastguard Worker         name_str = "viewport_array";
1125*35238bceSAndroid Build Coastguard Worker         break;
1126*35238bceSAndroid Build Coastguard Worker     default:
1127*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(0);
1128*35238bceSAndroid Build Coastguard Worker         return "#error unknown extension name\n";
1129*35238bceSAndroid Build Coastguard Worker     }
1130*35238bceSAndroid Build Coastguard Worker 
1131*35238bceSAndroid Build Coastguard Worker     switch (behavior)
1132*35238bceSAndroid Build Coastguard Worker     {
1133*35238bceSAndroid Build Coastguard Worker     case EXTENSIONBEHAVIOR_DISABLE:
1134*35238bceSAndroid Build Coastguard Worker         behavior_str = "disable";
1135*35238bceSAndroid Build Coastguard Worker         break;
1136*35238bceSAndroid Build Coastguard Worker     case EXTENSIONBEHAVIOR_WARN:
1137*35238bceSAndroid Build Coastguard Worker         behavior_str = "warn";
1138*35238bceSAndroid Build Coastguard Worker         break;
1139*35238bceSAndroid Build Coastguard Worker     case EXTENSIONBEHAVIOR_ENABLE:
1140*35238bceSAndroid Build Coastguard Worker         behavior_str = "enable";
1141*35238bceSAndroid Build Coastguard Worker         break;
1142*35238bceSAndroid Build Coastguard Worker     case EXTENSIONBEHAVIOR_REQUIRE:
1143*35238bceSAndroid Build Coastguard Worker         behavior_str = "require";
1144*35238bceSAndroid Build Coastguard Worker         break;
1145*35238bceSAndroid Build Coastguard Worker     default:
1146*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(0);
1147*35238bceSAndroid Build Coastguard Worker         return "#error unknown extension behavior";
1148*35238bceSAndroid Build Coastguard Worker     }
1149*35238bceSAndroid Build Coastguard Worker 
1150*35238bceSAndroid Build Coastguard Worker     std::stringstream str;
1151*35238bceSAndroid Build Coastguard Worker     str << "#extension GL_" << type_str << name_str << " : " << behavior_str;
1152*35238bceSAndroid Build Coastguard Worker     return str.str();
1153*35238bceSAndroid Build Coastguard Worker }
1154*35238bceSAndroid Build Coastguard Worker 
1155*35238bceSAndroid Build Coastguard Worker } // namespace glcts
1156