2 * Copyright © 2012 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
25 * \name dispatch_sanity.cpp
27 * Verify that only set of functions that should be available in a particular
28 * API are available in that API.
30 * The list of expected functions originally came from the functions set by
31 * api_exec_es2.c. This file no longer exists in Mesa (but api_exec_es1.c was
32 * still generated at the time this test was written). It was the generated
33 * file that configured the dispatch table for ES2 contexts. This test
34 * verifies that all of the functions set by the old api_exec_es2.c (with the
35 * recent addition of VAO functions) are set in the dispatch table and
36 * everything else is a NOP.
38 * When adding extensions that add new functions, this test will need to be
39 * modified to expect dispatch functions for the new extension functions.
43 #include "main/mfeatures.h"
46 #include <gtest/gtest.h>
51 #include "main/compiler.h"
52 #include "main/api_exec.h"
53 #include "main/context.h"
54 #include "main/remap.h"
55 #include "glapi/glapi.h"
56 #include "drivers/common/driverfuncs.h"
58 #include "swrast/swrast.h"
61 #include "swrast_setup/swrast_setup.h"
64 #define GLAPIENTRYP GL_APIENTRYP
67 #include "main/dispatch.h"
75 extern const struct function gles2_functions_possible
[];
77 class DispatchSanity_test
: public ::testing::Test
{
81 struct gl_config visual
;
82 struct dd_function_table driver_functions
;
83 struct gl_context share_list
;
84 struct gl_context ctx
;
88 DispatchSanity_test::SetUp()
90 memset(&visual
, 0, sizeof(visual
));
91 memset(&driver_functions
, 0, sizeof(driver_functions
));
92 memset(&share_list
, 0, sizeof(share_list
));
93 memset(&ctx
, 0, sizeof(ctx
));
95 _mesa_init_driver_functions(&driver_functions
);
99 validate_functions(_glapi_proc
*table
, const struct function
*function_table
)
101 for (unsigned i
= 0; function_table
[i
].name
!= NULL
; i
++) {
102 const int offset
= (function_table
[i
].offset
!= -1)
103 ? function_table
[i
].offset
104 : _glapi_get_proc_offset(function_table
[i
].name
);
106 ASSERT_NE(-1, offset
)
107 << "Function: " << function_table
[i
].name
;
109 _glapi_get_proc_offset(function_table
[i
].name
))
110 << "Function: " << function_table
[i
].name
;
111 EXPECT_NE((_glapi_proc
) _mesa_generic_nop
, table
[offset
])
112 << "Function: " << function_table
[i
].name
113 << " at offset " << offset
;
115 table
[offset
] = (_glapi_proc
) _mesa_generic_nop
;
118 const unsigned size
= _glapi_get_dispatch_table_size();
119 for (unsigned i
= 0; i
< size
; i
++) {
120 EXPECT_EQ((_glapi_proc
) _mesa_generic_nop
, table
[i
]) << "i = " << i
;
124 TEST_F(DispatchSanity_test
, GLES2
)
127 _mesa_initialize_context(&ctx
,
128 API_OPENGLES2
, //api,
133 _swrast_CreateContext(&ctx
);
134 _vbo_CreateContext(&ctx
);
135 _tnl_CreateContext(&ctx
);
136 _swsetup_CreateContext(&ctx
);
138 validate_functions((_glapi_proc
*) ctx
.Exec
, gles2_functions_possible
);
141 const struct function gles2_functions_possible
[] = {
142 { "glActiveTexture", _gloffset_ActiveTextureARB
},
143 { "glAttachShader", -1 },
144 { "glBindAttribLocation", -1 },
145 { "glBindBuffer", -1 },
146 { "glBindFramebuffer", -1 },
147 { "glBindRenderbuffer", -1 },
148 { "glBindTexture", _gloffset_BindTexture
},
149 { "glBindVertexArrayOES", -1 },
150 { "glBlendColor", _gloffset_BlendColor
},
151 { "glBlendEquation", _gloffset_BlendEquation
},
152 { "glBlendEquationSeparate", -1 },
153 { "glBlendFunc", _gloffset_BlendFunc
},
154 { "glBlendFuncSeparate", -1 },
155 { "glBufferData", -1 },
156 { "glBufferSubData", -1 },
157 { "glCheckFramebufferStatus", -1 },
158 { "glClear", _gloffset_Clear
},
159 { "glClearColor", _gloffset_ClearColor
},
160 { "glClearDepthf", -1 },
161 { "glClearStencil", _gloffset_ClearStencil
},
162 { "glColorMask", _gloffset_ColorMask
},
163 { "glCompileShader", -1 },
164 { "glCompressedTexImage2D", -1 },
165 { "glCompressedTexImage3DOES", -1 },
166 { "glCompressedTexSubImage2D", -1 },
167 { "glCompressedTexSubImage3DOES", -1 },
168 { "glCopyTexImage2D", _gloffset_CopyTexImage2D
},
169 { "glCopyTexSubImage2D", _gloffset_CopyTexSubImage2D
},
170 { "glCopyTexSubImage3DOES", _gloffset_CopyTexSubImage3D
},
171 { "glCreateProgram", -1 },
172 { "glCreateShader", -1 },
173 { "glCullFace", _gloffset_CullFace
},
174 { "glDeleteBuffers", -1 },
175 { "glDeleteFramebuffers", -1 },
176 { "glDeleteProgram", -1 },
177 { "glDeleteRenderbuffers", -1 },
178 { "glDeleteShader", -1 },
179 { "glDeleteTextures", _gloffset_DeleteTextures
},
180 { "glDeleteVertexArraysOES", -1 },
181 { "glDepthFunc", _gloffset_DepthFunc
},
182 { "glDepthMask", _gloffset_DepthMask
},
183 { "glDepthRangef", -1 },
184 { "glDetachShader", -1 },
185 { "glDisable", _gloffset_Disable
},
186 { "glDisableVertexAttribArray", -1 },
187 { "glDrawArrays", _gloffset_DrawArrays
},
188 { "glDrawBuffersNV", -1 },
189 { "glDrawElements", _gloffset_DrawElements
},
190 { "glEGLImageTargetRenderbufferStorageOES", -1 },
191 { "glEGLImageTargetTexture2DOES", -1 },
192 { "glEnable", _gloffset_Enable
},
193 { "glEnableVertexAttribArray", -1 },
194 { "glFinish", _gloffset_Finish
},
195 { "glFlush", _gloffset_Flush
},
196 { "glFlushMappedBufferRangeEXT", -1 },
197 { "glFramebufferRenderbuffer", -1 },
198 { "glFramebufferTexture2D", -1 },
199 { "glFramebufferTexture3DOES", -1 },
200 { "glFrontFace", _gloffset_FrontFace
},
201 { "glGenBuffers", -1 },
202 { "glGenFramebuffers", -1 },
203 { "glGenRenderbuffers", -1 },
204 { "glGenTextures", _gloffset_GenTextures
},
205 { "glGenVertexArraysOES", -1 },
206 { "glGenerateMipmap", -1 },
207 { "glGetActiveAttrib", -1 },
208 { "glGetActiveUniform", -1 },
209 { "glGetAttachedShaders", -1 },
210 { "glGetAttribLocation", -1 },
211 { "glGetBooleanv", _gloffset_GetBooleanv
},
212 { "glGetBufferParameteriv", -1 },
213 { "glGetBufferPointervOES", -1 },
214 { "glGetError", _gloffset_GetError
},
215 { "glGetFloatv", _gloffset_GetFloatv
},
216 { "glGetFramebufferAttachmentParameteriv", -1 },
217 { "glGetIntegerv", _gloffset_GetIntegerv
},
218 { "glGetProgramInfoLog", -1 },
219 { "glGetProgramiv", -1 },
220 { "glGetRenderbufferParameteriv", -1 },
221 { "glGetShaderInfoLog", -1 },
222 { "glGetShaderPrecisionFormat", -1 },
223 { "glGetShaderSource", -1 },
224 { "glGetShaderiv", -1 },
225 { "glGetString", _gloffset_GetString
},
226 { "glGetTexParameterfv", _gloffset_GetTexParameterfv
},
227 { "glGetTexParameteriv", _gloffset_GetTexParameteriv
},
228 { "glGetUniformLocation", -1 },
229 { "glGetUniformfv", -1 },
230 { "glGetUniformiv", -1 },
231 { "glGetVertexAttribPointerv", -1 },
232 { "glGetVertexAttribfv", -1 },
233 { "glGetVertexAttribiv", -1 },
234 { "glHint", _gloffset_Hint
},
235 { "glIsBuffer", -1 },
236 { "glIsEnabled", _gloffset_IsEnabled
},
237 { "glIsFramebuffer", -1 },
238 { "glIsProgram", -1 },
239 { "glIsRenderbuffer", -1 },
240 { "glIsShader", -1 },
241 { "glIsTexture", _gloffset_IsTexture
},
242 { "glIsVertexArrayOES", -1 },
243 { "glLineWidth", _gloffset_LineWidth
},
244 { "glLinkProgram", -1 },
245 { "glMapBufferOES", -1 },
246 { "glMapBufferRangeEXT", -1 },
247 { "glMultiDrawArraysEXT", -1 },
248 { "glMultiDrawElementsEXT", -1 },
249 { "glPixelStorei", _gloffset_PixelStorei
},
250 { "glPolygonOffset", _gloffset_PolygonOffset
},
251 { "glReadBufferNV", _gloffset_ReadBuffer
},
252 { "glReadPixels", _gloffset_ReadPixels
},
253 { "glReleaseShaderCompiler", -1 },
254 { "glRenderbufferStorage", -1 },
255 { "glSampleCoverage", -1 },
256 { "glScissor", _gloffset_Scissor
},
257 { "glShaderBinary", -1 },
258 { "glShaderSource", -1 },
259 { "glStencilFunc", _gloffset_StencilFunc
},
260 { "glStencilFuncSeparate", -1 },
261 { "glStencilMask", _gloffset_StencilMask
},
262 { "glStencilMaskSeparate", -1 },
263 { "glStencilOp", _gloffset_StencilOp
},
264 { "glStencilOpSeparate", -1 },
265 { "glTexImage2D", _gloffset_TexImage2D
},
266 { "glTexImage3DOES", _gloffset_TexImage3D
},
267 { "glTexParameterf", _gloffset_TexParameterf
},
268 { "glTexParameterfv", _gloffset_TexParameterfv
},
269 { "glTexParameteri", _gloffset_TexParameteri
},
270 { "glTexParameteriv", _gloffset_TexParameteriv
},
271 { "glTexSubImage2D", _gloffset_TexSubImage2D
},
272 { "glTexSubImage3DOES", _gloffset_TexSubImage3D
},
273 { "glUniform1f", -1 },
274 { "glUniform1fv", -1 },
275 { "glUniform1i", -1 },
276 { "glUniform1iv", -1 },
277 { "glUniform2f", -1 },
278 { "glUniform2fv", -1 },
279 { "glUniform2i", -1 },
280 { "glUniform2iv", -1 },
281 { "glUniform3f", -1 },
282 { "glUniform3fv", -1 },
283 { "glUniform3i", -1 },
284 { "glUniform3iv", -1 },
285 { "glUniform4f", -1 },
286 { "glUniform4fv", -1 },
287 { "glUniform4i", -1 },
288 { "glUniform4iv", -1 },
289 { "glUniformMatrix2fv", -1 },
290 { "glUniformMatrix3fv", -1 },
291 { "glUniformMatrix4fv", -1 },
292 { "glUnmapBufferOES", -1 },
293 { "glUseProgram", -1 },
294 { "glValidateProgram", -1 },
295 { "glVertexAttrib1f", -1 },
296 { "glVertexAttrib1fv", -1 },
297 { "glVertexAttrib2f", -1 },
298 { "glVertexAttrib2fv", -1 },
299 { "glVertexAttrib3f", -1 },
300 { "glVertexAttrib3fv", -1 },
301 { "glVertexAttrib4f", -1 },
302 { "glVertexAttrib4fv", -1 },
303 { "glVertexAttribPointer", -1 },
304 { "glViewport", _gloffset_Viewport
},