1 /**************************************************************************
2 *
3 * Copyright 2015 VMware, Inc.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 /**
29 * No-op GL API functions.
30 *
31 * Some OpenGL apps (like Viewperf12) call wglGetProcAddress() to get
32 * a pointer to an extension function, get a NULL pointer, but don't bother
33 * to check for NULL before jumping through the pointer. This causes a
34 * crash.
35 *
36 * As a work-around we provide some no-op functions here to avoid those
37 * crashes.
38 */
39
40 #include <GL/gl.h>
41 #include "stw_nopfuncs.h"
42 #include "util/u_debug.h"
43
44
45 static void
warning(const char * name)46 warning(const char *name)
47 {
48 /* use name+4 to skip "nop_" prefix */
49 _debug_printf("Application calling unsupported %s function\n", name+4);
50 }
51
52 static void APIENTRY
nop_glBindMultiTextureEXT(GLenum texunit,GLenum target,GLuint texture)53 nop_glBindMultiTextureEXT(GLenum texunit, GLenum target, GLuint texture)
54 {
55 warning(__func__);
56 }
57
58 static void APIENTRY
nop_glColor3hNV(GLhalfNV red,GLhalfNV green,GLhalfNV blue)59 nop_glColor3hNV(GLhalfNV red, GLhalfNV green, GLhalfNV blue)
60 {
61 warning(__func__);
62 }
63
64 static void APIENTRY
nop_glColor3hvNV(const GLhalfNV * v)65 nop_glColor3hvNV(const GLhalfNV *v)
66 {
67 warning(__func__);
68 }
69
70 static void APIENTRY
nop_glColor4hNV(GLhalfNV red,GLhalfNV green,GLhalfNV blue,GLhalfNV alpha)71 nop_glColor4hNV(GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha)
72 {
73 warning(__func__);
74 }
75
76 static void APIENTRY
nop_glColor4hvNV(const GLhalfNV * v)77 nop_glColor4hvNV(const GLhalfNV *v)
78 {
79 warning(__func__);
80 }
81
82 static void APIENTRY
nop_glDisableClientStateIndexedEXT(GLenum array,GLuint index)83 nop_glDisableClientStateIndexedEXT(GLenum array, GLuint index)
84 {
85 warning(__func__);
86 }
87
88 static void APIENTRY
nop_glEnableClientStateIndexedEXT(GLenum array,GLuint index)89 nop_glEnableClientStateIndexedEXT(GLenum array, GLuint index)
90 {
91 warning(__func__);
92 }
93
94 static void APIENTRY
nop_glFogCoordhNV(GLhalfNV fog)95 nop_glFogCoordhNV(GLhalfNV fog)
96 {
97 warning(__func__);
98 }
99
100 static void APIENTRY
nop_glFogCoordhvNV(const GLhalfNV * fog)101 nop_glFogCoordhvNV(const GLhalfNV *fog)
102 {
103 warning(__func__);
104 }
105
106 static void APIENTRY
nop_glGetNamedBufferParameterivEXT(GLuint buffer,GLenum pname,GLint * params)107 nop_glGetNamedBufferParameterivEXT(GLuint buffer, GLenum pname, GLint *params)
108 {
109 warning(__func__);
110 }
111
112 static void APIENTRY
nop_glGetNamedBufferSubDataEXT(GLuint buffer,GLintptr offset,GLsizeiptr size,void * data)113 nop_glGetNamedBufferSubDataEXT(GLuint buffer, GLintptr offset, GLsizeiptr size, void *data)
114 {
115 warning(__func__);
116 }
117
118 static void *APIENTRY
nop_glMapNamedBufferEXT(GLuint buffer,GLenum access)119 nop_glMapNamedBufferEXT(GLuint buffer, GLenum access)
120 {
121 warning(__func__);
122 return NULL;
123 }
124
125 static void APIENTRY
nop_glMatrixLoadfEXT(GLenum mode,const GLfloat * m)126 nop_glMatrixLoadfEXT(GLenum mode, const GLfloat *m)
127 {
128 warning(__func__);
129 }
130
131 static void APIENTRY
nop_glMatrixLoadIdentityEXT(GLenum mode)132 nop_glMatrixLoadIdentityEXT(GLenum mode)
133 {
134 warning(__func__);
135 }
136
137 static void APIENTRY
nop_glMultiTexCoord1hNV(GLenum target,GLhalfNV s)138 nop_glMultiTexCoord1hNV(GLenum target, GLhalfNV s)
139 {
140 warning(__func__);
141 }
142
143 static void APIENTRY
nop_glMultiTexCoord1hvNV(GLenum target,const GLhalfNV * v)144 nop_glMultiTexCoord1hvNV(GLenum target, const GLhalfNV *v)
145 {
146 warning(__func__);
147 }
148
149 static void APIENTRY
nop_glMultiTexCoord2hNV(GLenum target,GLhalfNV s,GLhalfNV t)150 nop_glMultiTexCoord2hNV(GLenum target, GLhalfNV s, GLhalfNV t)
151 {
152 warning(__func__);
153 }
154
155 static void APIENTRY
nop_glMultiTexCoord2hvNV(GLenum target,const GLhalfNV * v)156 nop_glMultiTexCoord2hvNV(GLenum target, const GLhalfNV *v)
157 {
158 warning(__func__);
159 }
160
161 static void APIENTRY
nop_glMultiTexCoord3hNV(GLenum target,GLhalfNV s,GLhalfNV t,GLhalfNV r)162 nop_glMultiTexCoord3hNV(GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r)
163 {
164 warning(__func__);
165 }
166
167 static void APIENTRY
nop_glMultiTexCoord3hvNV(GLenum target,const GLhalfNV * v)168 nop_glMultiTexCoord3hvNV(GLenum target, const GLhalfNV *v)
169 {
170 warning(__func__);
171 }
172
173 static void APIENTRY
nop_glMultiTexCoord4hNV(GLenum target,GLhalfNV s,GLhalfNV t,GLhalfNV r,GLhalfNV q)174 nop_glMultiTexCoord4hNV(GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q)
175 {
176 warning(__func__);
177 }
178
179 static void APIENTRY
nop_glMultiTexCoord4hvNV(GLenum target,const GLhalfNV * v)180 nop_glMultiTexCoord4hvNV(GLenum target, const GLhalfNV *v)
181 {
182 warning(__func__);
183 }
184
185 static void APIENTRY
nop_glMultiTexCoordPointerEXT(GLenum texunit,GLint size,GLenum type,GLsizei stride,const void * pointer)186 nop_glMultiTexCoordPointerEXT(GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer)
187 {
188 warning(__func__);
189 }
190
191 static void APIENTRY
nop_glMultiTexEnvfEXT(GLenum texunit,GLenum target,GLenum pname,GLfloat param)192 nop_glMultiTexEnvfEXT(GLenum texunit, GLenum target, GLenum pname, GLfloat param)
193 {
194 warning(__func__);
195 }
196
197 static void APIENTRY
nop_glMultiTexEnvfvEXT(GLenum texunit,GLenum target,GLenum pname,const GLfloat * params)198 nop_glMultiTexEnvfvEXT(GLenum texunit, GLenum target, GLenum pname, const GLfloat *params)
199 {
200 warning(__func__);
201 }
202
203 static void APIENTRY
nop_glMultiTexEnviEXT(GLenum texunit,GLenum target,GLenum pname,GLint param)204 nop_glMultiTexEnviEXT(GLenum texunit, GLenum target, GLenum pname, GLint param)
205 {
206 warning(__func__);
207 }
208
209 static void APIENTRY
nop_glMultiTexGenfvEXT(GLenum texunit,GLenum coord,GLenum pname,const GLfloat * params)210 nop_glMultiTexGenfvEXT(GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params)
211 {
212 warning(__func__);
213 }
214
215 static void APIENTRY
nop_glMultiTexGeniEXT(GLenum texunit,GLenum coord,GLenum pname,GLint param)216 nop_glMultiTexGeniEXT(GLenum texunit, GLenum coord, GLenum pname, GLint param)
217 {
218 warning(__func__);
219 }
220
221 static void APIENTRY
nop_glNamedBufferDataEXT(GLuint buffer,GLsizeiptr size,const void * data,GLenum usage)222 nop_glNamedBufferDataEXT(GLuint buffer, GLsizeiptr size, const void *data, GLenum usage)
223 {
224 warning(__func__);
225 }
226
227 static void APIENTRY
nop_glNamedBufferSubDataEXT(GLuint buffer,GLintptr offset,GLsizeiptr size,const void * data)228 nop_glNamedBufferSubDataEXT(GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data)
229 {
230 warning(__func__);
231 }
232
233 static void APIENTRY
nop_glNamedProgramLocalParameter4fvEXT(GLuint program,GLenum target,GLuint index,const GLfloat * params)234 nop_glNamedProgramLocalParameter4fvEXT(GLuint program, GLenum target, GLuint index, const GLfloat *params)
235 {
236 warning(__func__);
237 }
238
239 static void APIENTRY
nop_glNamedProgramLocalParameters4fvEXT(GLuint program,GLenum target,GLuint index,GLsizei count,const GLfloat * params)240 nop_glNamedProgramLocalParameters4fvEXT(GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params)
241 {
242 warning(__func__);
243 }
244
245 static void APIENTRY
nop_glNormal3hNV(GLhalfNV nx,GLhalfNV ny,GLhalfNV nz)246 nop_glNormal3hNV(GLhalfNV nx, GLhalfNV ny, GLhalfNV nz)
247 {
248 warning(__func__);
249 }
250
251 static void APIENTRY
nop_glNormal3hvNV(const GLhalfNV * v)252 nop_glNormal3hvNV(const GLhalfNV *v)
253 {
254 warning(__func__);
255 }
256
257 static void APIENTRY
nop_glPatchParameterfv(GLenum pname,const GLfloat * values)258 nop_glPatchParameterfv(GLenum pname, const GLfloat *values)
259 {
260 warning(__func__);
261 }
262
263 static void APIENTRY
nop_glPatchParameteri(GLenum pname,GLint value)264 nop_glPatchParameteri(GLenum pname, GLint value)
265 {
266 warning(__func__);
267 }
268
269 static void APIENTRY
nop_glSecondaryColor3hNV(GLhalfNV red,GLhalfNV green,GLhalfNV blue)270 nop_glSecondaryColor3hNV(GLhalfNV red, GLhalfNV green, GLhalfNV blue)
271 {
272 warning(__func__);
273 }
274
275 static void APIENTRY
nop_glSecondaryColor3hvNV(const GLhalfNV * v)276 nop_glSecondaryColor3hvNV(const GLhalfNV *v)
277 {
278 warning(__func__);
279 }
280
281 static void APIENTRY
nop_glTexCoord1hNV(GLhalfNV s)282 nop_glTexCoord1hNV(GLhalfNV s)
283 {
284 warning(__func__);
285 }
286
287 static void APIENTRY
nop_glTexCoord1hvNV(const GLhalfNV * v)288 nop_glTexCoord1hvNV(const GLhalfNV *v)
289 {
290 warning(__func__);
291 }
292
293 static void APIENTRY
nop_glTexCoord2hNV(GLhalfNV s,GLhalfNV t)294 nop_glTexCoord2hNV(GLhalfNV s, GLhalfNV t)
295 {
296 warning(__func__);
297 }
298
299 static void APIENTRY
nop_glTexCoord2hvNV(const GLhalfNV * v)300 nop_glTexCoord2hvNV(const GLhalfNV *v)
301 {
302 warning(__func__);
303 }
304
305 static void APIENTRY
nop_glTexCoord3hNV(GLhalfNV s,GLhalfNV t,GLhalfNV r)306 nop_glTexCoord3hNV(GLhalfNV s, GLhalfNV t, GLhalfNV r)
307 {
308 warning(__func__);
309 }
310
311 static void APIENTRY
nop_glTexCoord3hvNV(const GLhalfNV * v)312 nop_glTexCoord3hvNV(const GLhalfNV *v)
313 {
314 warning(__func__);
315 }
316
317 static void APIENTRY
nop_glTexCoord4hNV(GLhalfNV s,GLhalfNV t,GLhalfNV r,GLhalfNV q)318 nop_glTexCoord4hNV(GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q)
319 {
320 warning(__func__);
321 }
322
323 static void APIENTRY
nop_glTexCoord4hvNV(const GLhalfNV * v)324 nop_glTexCoord4hvNV(const GLhalfNV *v)
325 {
326 warning(__func__);
327 }
328
329 static void APIENTRY
nop_glTextureParameterfEXT(GLuint texture,GLenum target,GLenum pname,GLfloat param)330 nop_glTextureParameterfEXT(GLuint texture, GLenum target, GLenum pname, GLfloat param)
331 {
332 warning(__func__);
333 }
334
335 static void APIENTRY
nop_glTextureParameterfvEXT(GLuint texture,GLenum target,GLenum pname,const GLfloat * params)336 nop_glTextureParameterfvEXT(GLuint texture, GLenum target, GLenum pname, const GLfloat *params)
337 {
338 warning(__func__);
339 }
340
341 static void APIENTRY
nop_glTextureParameteriEXT(GLuint texture,GLenum target,GLenum pname,GLint param)342 nop_glTextureParameteriEXT(GLuint texture, GLenum target, GLenum pname, GLint param)
343 {
344 warning(__func__);
345 }
346
347 static GLboolean APIENTRY
nop_glUnmapNamedBufferEXT(GLuint buffer)348 nop_glUnmapNamedBufferEXT(GLuint buffer)
349 {
350 warning(__func__);
351 return GL_FALSE;
352 }
353
354 static void APIENTRY
nop_glVertex2hNV(GLhalfNV x,GLhalfNV y)355 nop_glVertex2hNV(GLhalfNV x, GLhalfNV y)
356 {
357 warning(__func__);
358 }
359
360 static void APIENTRY
nop_glVertex2hvNV(const GLhalfNV * v)361 nop_glVertex2hvNV(const GLhalfNV *v)
362 {
363 warning(__func__);
364 }
365
366 static void APIENTRY
nop_glVertex3hNV(GLhalfNV x,GLhalfNV y,GLhalfNV z)367 nop_glVertex3hNV(GLhalfNV x, GLhalfNV y, GLhalfNV z)
368 {
369 warning(__func__);
370 }
371
372 static void APIENTRY
nop_glVertex3hvNV(const GLhalfNV * v)373 nop_glVertex3hvNV(const GLhalfNV *v)
374 {
375 warning(__func__);
376 }
377
378 static void APIENTRY
nop_glVertex4hNV(GLhalfNV x,GLhalfNV y,GLhalfNV z,GLhalfNV w)379 nop_glVertex4hNV(GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w)
380 {
381 warning(__func__);
382 }
383
384 static void APIENTRY
nop_glVertex4hvNV(const GLhalfNV * v)385 nop_glVertex4hvNV(const GLhalfNV *v)
386 {
387 warning(__func__);
388 }
389
390
391 PROC
stw_get_nop_function(const char * name)392 stw_get_nop_function(const char *name)
393 {
394 struct {
395 const char *name;
396 PROC p;
397 } table[] = {
398 { "glBindMultiTextureEXT", (PROC) nop_glBindMultiTextureEXT },
399 { "glColor3hNV", (PROC) nop_glColor3hNV },
400 { "glColor3hvNV", (PROC) nop_glColor3hvNV },
401 { "glColor4hNV", (PROC) nop_glColor4hNV },
402 { "glColor4hvNV", (PROC) nop_glColor4hvNV },
403 { "glDisableClientStateIndexedEXT", (PROC) nop_glDisableClientStateIndexedEXT },
404 { "glEnableClientStateIndexedEXT", (PROC) nop_glEnableClientStateIndexedEXT },
405 { "glFogCoordhNV", (PROC) nop_glFogCoordhNV },
406 { "glFogCoordhvNV", (PROC) nop_glFogCoordhvNV },
407 { "glGetNamedBufferParameterivEXT", (PROC) nop_glGetNamedBufferParameterivEXT },
408 { "glGetNamedBufferSubDataEXT", (PROC) nop_glGetNamedBufferSubDataEXT },
409 { "glMapNamedBufferEXT", (PROC) nop_glMapNamedBufferEXT },
410 { "glMatrixLoadfEXT", (PROC) nop_glMatrixLoadfEXT },
411 { "glMatrixLoadIdentityEXT", (PROC) nop_glMatrixLoadIdentityEXT },
412 { "glMultiTexCoord1hNV", (PROC) nop_glMultiTexCoord1hNV },
413 { "glMultiTexCoord1hvNV", (PROC) nop_glMultiTexCoord1hvNV },
414 { "glMultiTexCoord2hNV", (PROC) nop_glMultiTexCoord2hNV },
415 { "glMultiTexCoord2hvNV", (PROC) nop_glMultiTexCoord2hvNV },
416 { "glMultiTexCoord3hNV", (PROC) nop_glMultiTexCoord3hNV },
417 { "glMultiTexCoord3hvNV", (PROC) nop_glMultiTexCoord3hvNV },
418 { "glMultiTexCoord4hNV", (PROC) nop_glMultiTexCoord4hNV },
419 { "glMultiTexCoord4hvNV", (PROC) nop_glMultiTexCoord4hvNV },
420 { "glMultiTexCoordPointerEXT", (PROC) nop_glMultiTexCoordPointerEXT },
421 { "glMultiTexEnvfEXT", (PROC) nop_glMultiTexEnvfEXT },
422 { "glMultiTexEnvfvEXT", (PROC) nop_glMultiTexEnvfvEXT },
423 { "glMultiTexEnviEXT", (PROC) nop_glMultiTexEnviEXT },
424 { "glMultiTexGenfvEXT", (PROC) nop_glMultiTexGenfvEXT },
425 { "glMultiTexGeniEXT", (PROC) nop_glMultiTexGeniEXT },
426 { "glNamedBufferDataEXT", (PROC) nop_glNamedBufferDataEXT },
427 { "glNamedBufferSubDataEXT", (PROC) nop_glNamedBufferSubDataEXT },
428 { "glNamedProgramLocalParameter4fvEXT", (PROC) nop_glNamedProgramLocalParameter4fvEXT },
429 { "glNamedProgramLocalParameters4fvEXT", (PROC) nop_glNamedProgramLocalParameters4fvEXT },
430 { "glNormal3hNV", (PROC) nop_glNormal3hNV },
431 { "glNormal3hvNV", (PROC) nop_glNormal3hvNV },
432 { "glPatchParameterfv", (PROC) nop_glPatchParameterfv },
433 { "glPatchParameteri", (PROC) nop_glPatchParameteri },
434 { "glSecondaryColor3hNV", (PROC) nop_glSecondaryColor3hNV },
435 { "glSecondaryColor3hvNV", (PROC) nop_glSecondaryColor3hvNV },
436 { "glTexCoord1hNV", (PROC) nop_glTexCoord1hNV },
437 { "glTexCoord1hvNV", (PROC) nop_glTexCoord1hvNV },
438 { "glTexCoord2hNV", (PROC) nop_glTexCoord2hNV },
439 { "glTexCoord2hvNV", (PROC) nop_glTexCoord2hvNV },
440 { "glTexCoord3hNV", (PROC) nop_glTexCoord3hNV },
441 { "glTexCoord3hvNV", (PROC) nop_glTexCoord3hvNV },
442 { "glTexCoord4hNV", (PROC) nop_glTexCoord4hNV },
443 { "glTexCoord4hvNV", (PROC) nop_glTexCoord4hvNV },
444 { "glTextureParameterfEXT", (PROC) nop_glTextureParameterfEXT },
445 { "glTextureParameterfvEXT", (PROC) nop_glTextureParameterfvEXT },
446 { "glTextureParameteriEXT", (PROC) nop_glTextureParameteriEXT },
447 { "glUnmapNamedBufferEXT", (PROC) nop_glUnmapNamedBufferEXT },
448 { "glVertex2hNV", (PROC) nop_glVertex2hNV },
449 { "glVertex2hvNV", (PROC) nop_glVertex2hvNV },
450 { "glVertex3hNV", (PROC) nop_glVertex3hNV },
451 { "glVertex3hvNV", (PROC) nop_glVertex3hvNV },
452 { "glVertex4hNV", (PROC) nop_glVertex4hNV },
453 { "glVertex4hvNV", (PROC) nop_glVertex4hvNV },
454 { NULL, NULL }
455 };
456
457 int i;
458
459 for (i = 0; table[i].name; i++) {
460 if (strcmp(table[i].name, name) == 0)
461 return table[i].p;
462 }
463 return NULL;
464 }
465