VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/spu_loader/glloader.py@ 78190

最後變更 在這個檔案從78190是 78190,由 vboxsync 提交於 6 年 前

Merge first stage of the Chromium cleanup from the branch:

  • r129818 (Remove VBOX_WITH_CR_DISPLAY_LISTS and accompanying code as it was disabled since r108676 and was never brought back (see ​bugref:3456 and ​bugref:8485))
  • r129819 (HostServices/SharedOpenGL: Remove unused main entry point from upstream server process based implementation)
  • r129820 (HostServices/SharedOpenGL: Started eliminating all backends other than HGCM. They are not used and probably wouldn't work anymore anyway)
  • r129821 (HostServices/SharedOpenGL,GuestHost/OpenGLAdditions/common/crOpenGL: Kill crTimer* API as it is not used anywhere)
  • r129822 (HostServices/SharedOpenGL,GuestHost/OpenGLAdditions/common/crOpenGL: Kill most from cr_process.h apart from two used methods)
  • r129823 (HostServices/SharedOpenGL,GuestHost/OpenGLAdditions/common/crOpenGL: Kill crList* API as it is unused)
  • r129824 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Kill crHullInteriorBox API as it is unused)
  • r129825 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Kill crWarpPoint API as it is unused)
  • r129826 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Kill CrSa* API as it is unused and not even compiled in)
  • r129827 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Kill cr_bbox.h as it is unused)
  • r129828 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove a few crParseUrl() two uses)
  • r129829 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove last crParseURL() use)
  • r129830 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove crParseURL())
  • r129831 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove VBOX_WITH_COCOA_QT and related code when not set as it is the default for years now and we don't support anything else anymore)
  • r129832 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused cr_logo.h)
  • r129833 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused crut_api.h and crut_clientapi.h)
  • r129834 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused cr_dmx.h)
  • r129835 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused cr_perf.h)
  • r129836 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove cr_rand.h and friends as it is not actively used anywhere)
  • r129837 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of all the swapped versions in the packer SPU, we never change endianess from guest to host and don't need it)
  • r129838 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove more swapper versions in the packer related code)
  • r129839 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove more swapper versions in the packer related code)
  • r129840 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused pack_pica.c)
  • r129841 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove more swapper versions in the packer related code)
  • r129842 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of cr_endianess.h and friends)
  • r129843 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of unused lowercase.py)
  • r129844 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of unused cr_calllists.h and friends)
  • r129845 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of completely unused idpool.c, not even compiled in)
  • r129846 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of unused cr_debugopcodes.h and friends)
  • r129847 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Make the cr_mem.h API inline and get rid of the implementation in the util library)
  • r129848 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of SPUOptions and related code as it is of no use for us)
  • r129849 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of cr_environment.h and friends and convert usage to RTEnv* APIs)
  • r129850 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of unused renderspu_agl.c)
  • r129851 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused code in cr_htable.h)
  • r129853 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Introduce a state paremeter for the unpacker workers instead of reyling on global variables, work in progress)
  • r129854 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Let the caller of crUnpack set up the initial state. This allows to get rid of the global return_ptr and writeback_ptr as they get supplied in the unpacker state by the server)
  • r129855 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of the cr_lastDispatch and cr_unpackDispatch as they are of no use now)
  • r129856 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of the global cr_unpackData and cr_unpackDataEnd symbols by indtroducing another hack to make it possible for certail server dispatch callbacks to access the data buffer)
  • r129857 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: build fix for release builds)
  • r129858 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Make the pointer to the unpacker state non const (is required for the access verification))
  • r129859 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: First iteration of the buffer size validation to prevent out of bound read access + added todos for places where additional checks are needed)
  • r129860 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129861 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129871 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129872 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Stop as soon as the unpacker encountered an error)
  • r129876 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129880 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129882 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Fixed some offsets in unpack_texture.c, 3DMark03 renders correctly again)
  • r130013 (HostServices/SharedOpenGL: Convert files to C++ so we can use C99 featuers on Windows with cl.exe)
  • r130014 (HostServices/SharedOpenGL,GuestHost/OpenGL: WIndows build fixes)
  • r130015 (HostServices/SharedOpenGL,GuestHost/OpenGL: More Windows build fixes)
  • r130036 (Config.kmk: Fix linker error on Windows by temporarily disabling the use of VBoxGuestR3DllMinW2K)
  • r130094 (src/VBox/GuestHost/OpenGL: Revert inlining the allocation/free functions in R3 completely as it doesn't work on Windows if memory is allocated and freed across different DLLs which don't share a common CRT, causes crashes in RtlValidtaeHeap())
  • r130095 (src/VBox/GuestHost/OpenGL,src/VBox/Additions/common/crOpenGL/pack: Don't use floating point specifiers in packspu_GetString() to avoid R6002 errors (couldn't fully understand why they occur suddenly after the rework but this gets rid of it))
  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Id Revision
檔案大小: 13.8 KB
 
1# Copyright (c) 2001, Stanford University
2# All rights reserved.
3#
4# See the file LICENSE.txt for information on redistributing this software.
5
6
7from __future__ import print_function
8import sys
9import apiutil
10
11
12keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
13
14apiutil.CopyrightC()
15
16print("""
17/* DO NOT EDIT - THIS FILE GENERATED BY THE glloader.py SCRIPT */
18#include "cr_error.h"
19#include "cr_dll.h"
20#include "cr_spu.h"
21#include "cr_string.h"
22#include "cr_error.h"
23
24#include <iprt/env.h>
25
26#include <stdio.h>
27#if defined(WINDOWS)
28# ifdef VBOX
29# include <iprt/win/windows.h>
30# else
31#include <windows.h>
32# endif
33#include <process.h>
34#include <direct.h>
35#define SYSTEM_GL "opengl32.dll"
36#elif defined (DARWIN)
37#define SYSTEM_GL "libGL.dylib"
38#define SYSTEM_CGL "OpenGL"
39#include <string.h> /* VBOX */
40#elif defined(IRIX) || defined(IRIX64) || defined(Linux) || defined(FreeBSD) || defined(AIX) || defined(SunOS) || defined(OSF1)
41#include <string.h>
42#if defined(AIX)
43#define SYSTEM_GL "libGL.o"
44#else
45#define SYSTEM_GL "libGL.so.1"
46#endif
47typedef void (*glxfuncptr)(void);
48extern glxfuncptr glxGetProcAddressARB( const GLubyte *name );
49#else
50#error I don't know where your system's GL lives. Too bad.
51#endif
52
53static CRDLL *glDll = NULL;
54
55#ifdef DARWIN
56#define SYSTEM_GL_LIB_DIR "/System/Library/Frameworks/OpenGL.framework/Libraries"
57#define SYSTEM_CGL_DIR "/System/Library/Frameworks/OpenGL.framework"
58static CRDLL *cglDll = NULL;
59#endif
60
61#if defined(WINDOWS)
62#define GLLOADER_APIENTRY __stdcall
63#else
64#define GLLOADER_APIENTRY
65#endif
66
67/*
68 * Add an entry to the SPUNamedFunctionTable
69 */
70static int
71fillin(SPUNamedFunctionTable *entry, const char *funcName, SPUGenericFunction funcPtr)
72{
73 if (funcPtr) {
74 entry->name = crStrdup(funcName);
75 entry->fn = funcPtr;
76 return 1;
77 }
78 return 0;
79}
80
81#ifndef WINDOWS
82/*static int FileExists(char *directory, char *filename)
83{
84 FILE *f;
85 char fullFilename[8096];
86
87 crStrcpy(fullFilename, directory);
88 crStrcat(fullFilename, "/");
89 crStrcat(fullFilename, filename);
90
91 f = fopen(fullFilename, "r");
92 if (f) {
93 fclose(f);
94 return 1;
95 }
96 else {
97 return 0;
98 }
99}*/
100#endif
101
102
103/*
104 * Locate the native OpenGL library, open it and return shared library
105 * handle.
106 */
107static CRDLL *
108__findSystemLib( const char *provided_system_path, char *lib )
109{
110 CRDLL *dll;
111 char system_path[8096];
112
113 memset(system_path, 0, sizeof(system_path));
114
115 if (provided_system_path && (crStrlen(provided_system_path) > 0) )
116 {
117 crStrcpy( system_path, provided_system_path );
118 }
119 else
120 {
121#if defined(WINDOWS)
122 GetSystemDirectory(system_path, MAX_PATH);
123#elif defined(IRIX) || defined(IRIX64)
124#ifdef IRIX_64BIT
125 crStrcpy( system_path, "/usr/lib64" );
126#else
127 crStrcpy( system_path, "/usr/lib32" );
128#endif
129#elif defined(PLAYSTATION2)
130 crStrcpy( system_path, "/usr/X11R6/lib" );
131#else
132 /* On RedHat 9, the correct default system directory
133 * is /usr/lib/tls/ (and if /usr/lib/ is used,
134 * the dynamic loader will generate a floating point
135 * exception SIGFPE). On other systems, including
136 * earlier versions of RedHat, the OpenGL library
137 * lives in /usr/lib. We'll use the /usr/lib/tls/
138 * version if it exists; otherwise, we'll use /usr/lib.
139 */
140 /*crStrcpy(system_path, "/usr/lib");*/
141#if defined(__linux__) && defined(__amd64__)
142 /*if (sizeof(void *) == 8 && FileExists("/usr/lib64", lib)) {
143 crStrcat(system_path, "64");
144 }*/
145#endif
146 /*if (FileExists("/usr/lib/tls", lib) ||
147 FileExists("/usr/lib64/tls", lib)) {
148 crStrcat(system_path, "/tls");
149 }*/
150#endif
151 }
152#if !defined(__linux__) && !defined(SunOS) && !defined(__FreeBSD__)
153 crStrcat( system_path, "/" );
154#endif
155#if !defined(CR_NO_GL_SYSTEM_PATH)
156 crStrcat( system_path, lib );
157 dll = crDLLOpen(system_path, 1 /*resolveGlobal*/);
158#else
159 dll = crDLLOpen(lib, 1 /*resolveGlobal*/);
160#endif
161 return dll;
162}
163
164
165static CRDLL *
166#ifdef DARWIN
167__findSystemGL( const char *provided_system_path, const char *default_system_path, char *provided_lib_name )
168#else
169__findSystemGL( const char *provided_system_path )
170#endif
171{
172#ifdef DARWIN
173 const char *the_path = (provided_system_path && crStrlen(provided_system_path) > 0) ? provided_system_path : default_system_path;
174
175 /* Fallback for loading frameworks */
176 if( !provided_lib_name )
177 return crDLLOpen( the_path, 1 );
178 else
179 return __findSystemLib( the_path, provided_lib_name );
180#else
181 return __findSystemLib( provided_system_path, SYSTEM_GL );
182#endif
183}
184
185static SPUGenericFunction
186findExtFunction( const crOpenGLInterface *interface, const char *funcName )
187{
188#ifdef WINDOWS
189 if (interface->wglGetProcAddress)
190 return (SPUGenericFunction) interface->wglGetProcAddress( funcName );
191 else
192 return (SPUGenericFunction) NULL;
193#else
194 /* XXX for some reason, the NVIDIA glXGetProcAddressARB() function
195 * returns pointers that cause Chromium to crash. If we use the
196 * pointer returned by crDLLGetNoError() instead, we're OK.
197 */
198 SPUGenericFunction f = crDLLGetNoError(glDll, funcName);
199 if (f)
200 return f;
201#if !defined(DARWIN)
202 else if (interface->glXGetProcAddressARB)
203 return interface->glXGetProcAddressARB( (const GLubyte *) funcName );
204#endif
205 else
206 return NULL;
207#endif
208}
209""")
210
211
212def IsExtensionFunc(func_name):
213 """Determine if the named function is a core function, or extension."""
214 cat = apiutil.Category(func_name)
215 if cat == "1.0" or cat == "1.1" or cat == "1.2" or cat == "1.3":
216 return 0
217 else:
218 return 1
219
220#
221# Generate a no-op function.
222#
223def GenerateNop(func_name):
224 return_type = apiutil.ReturnType(func_name);
225 params = apiutil.Parameters(func_name)
226 print('static %s GLLOADER_APIENTRY Nop%s(%s)' % (return_type, func_name, apiutil.MakeDeclarationString(params)))
227 print('{')
228 for (name, type, vecSize) in params:
229 if name != "":
230 print('\t(void) %s;' % name)
231 if apiutil.ReturnType(func_name) != 'void':
232 print('\treturn 0;')
233 print('}')
234 print('')
235
236
237
238#
239# Make no-op funcs for all OpenGL extension functions
240#
241for func_name in keys:
242 if IsExtensionFunc(func_name):
243 GenerateNop(func_name)
244
245
246#
247# Generate the crLoadOpenGL() function
248#
249print("""
250void
251crUnloadOpenGL( void )
252{
253 crDLLClose( glDll );
254 glDll = NULL;
255
256#ifdef DARWIN
257 crDLLClose( cglDll );
258 cglDll = NULL;
259#endif
260}
261
262/*
263 * Initialize the 'interface' structure with the WGL or GLX window system
264 * interface functions.
265 * Then, fill in the table with (name, pointer) pairs for all the core
266 * OpenGL entrypoint functions. But only if table is not NULL
267 * Return: number of entries placed in table[], or 0 if error.
268 */
269int
270crLoadOpenGL( crOpenGLInterface *interface, SPUNamedFunctionTable table[] )
271{
272 static const char *coreFunctions[] = {
273""")
274
275for func_name in keys:
276 if not IsExtensionFunc(func_name):
277 print('\t\t"gl%s",' % func_name)
278
279print("""
280 NULL
281 };
282 SPUNamedFunctionTable *entry = table;
283 int i;
284
285 const char *env_syspath = RTEnvGet( "CR_SYSTEM_GL_PATH" );
286#ifdef DARWIN
287 const char *env_cgl_syspath = RTEnvGet( "CR_SYSTEM_CGL_PATH" );
288#endif
289
290 crDebug( "Looking for the system's OpenGL library..." );
291#ifdef DARWIN
292 glDll = __findSystemGL( env_syspath, SYSTEM_GL_LIB_DIR, SYSTEM_GL );
293#else
294 glDll = __findSystemGL( env_syspath );
295#endif
296 if (!glDll)
297 {
298 crError("Unable to find system OpenGL!");
299 return 0;
300 }
301
302 crDebug( "Found it in %s.", !env_syspath ? "default path" : env_syspath );
303
304#ifdef DARWIN
305 crDebug( "Looking for the system's CGL library..." );
306 cglDll = __findSystemGL( env_cgl_syspath, SYSTEM_CGL_DIR, SYSTEM_CGL );
307 if (!cglDll)
308 {
309 crError("Unable to find system CGL!");
310 return 0;
311 }
312
313 crDebug( "Found it in %s.", !env_cgl_syspath ? "default path" : env_cgl_syspath );
314#endif
315""")
316
317useful_wgl_functions = [
318 "wglGetProcAddress",
319 "wglMakeCurrent",
320 "wglSwapBuffers",
321 "wglCreateContext",
322 "wglDeleteContext",
323 "wglShareLists",
324 "wglGetCurrentContext",
325 "wglChoosePixelFormat",
326 "wglDescribePixelFormat",
327 "wglSetPixelFormat",
328 "wglChoosePixelFormatEXT",
329 "wglGetPixelFormatAttribivEXT",
330 "wglGetPixelFormatAttribfvEXT",
331 "glGetString"
332]
333useful_agl_functions = [
334 "aglCreateContext",
335 "aglDestroyContext",
336 "aglSetCurrentContext",
337 "aglSwapBuffers",
338 "aglChoosePixelFormat",
339 "aglDestroyPixelFormat",
340 "aglDescribePixelFormat",
341 "aglGetCurrentContext",
342 "aglSetDrawable",
343 "aglGetDrawable",
344 "aglSetFullScreen",
345 "aglUpdateContext",
346 "aglUseFont",
347 "aglSetInteger",
348 "aglGetInteger",
349 "aglGetError",
350 "aglEnable",
351 "aglDisable"
352]
353in_gl_functions = [
354 "CGLGetCurrentContext",
355 "CGLSetCurrentContext"
356]
357useful_cgl_functions = [
358 "CGLChoosePixelFormat",
359 "CGLDestroyPixelFormat",
360 "CGLDescribePixelFormat",
361 "CGLQueryRendererInfo",
362 "CGLDestroyRendererInfo",
363 "CGLDescribeRenderer",
364 "CGLCreateContext",
365 "CGLDestroyContext",
366 "CGLCopyContext",
367 "CGLCreatePBuffer",
368 "CGLDestroyPBuffer",
369 "CGLDescribePBuffer",
370 "CGLTexImagePBuffer",
371 "CGLSetOffScreen",
372 "CGLGetOffScreen",
373 "CGLSetFullScreen",
374 "CGLSetPBuffer",
375 "CGLGetPBuffer",
376 "CGLClearDrawable",
377 "CGLFlushDrawable",
378 "CGLEnable",
379 "CGLDisable",
380 "CGLIsEnabled",
381 "CGLSetParameter",
382 "CGLGetParameter",
383 "CGLSetVirtualScreen",
384 "CGLGetVirtualScreen",
385 "CGLSetOption",
386 "CGLGetOption",
387 "CGLGetVersion",
388 "CGLErrorString",
389 "CGLSetSurface",
390 "CGLGetSurface",
391 "CGLUpdateContext",
392 "glGetString"
393]
394useful_glx_functions = [
395 "glXGetConfig",
396 "glXQueryExtension",
397 "glXQueryVersion",
398 "glXQueryExtensionsString",
399 "glXChooseVisual",
400 "glXCreateContext",
401 "glXDestroyContext",
402 "glXUseXFont",
403 "glXIsDirect",
404 "glXMakeCurrent",
405 "glGetString",
406 "glXSwapBuffers",
407 "glXGetCurrentDisplay",
408 "glXGetCurrentContext",
409 "glXGetClientString",
410 "glXWaitGL",
411 "glXWaitX",
412 "glXCopyContext"
413]
414possibly_useful_glx_functions = [
415 "glXGetProcAddressARB",
416 "glXJoinSwapGroupNV",
417 "glXBindSwapBarrierNV",
418 "glXQuerySwapGroupNV",
419 "glXQueryMaxSwapGroupsNV",
420 "glXQueryFrameCountNV",
421 "glXResetFrameCountNV",
422 "glXChooseFBConfig",
423 "glXGetFBConfigs",
424 "glXGetFBConfigAttrib",
425 "glXGetVisualFromFBConfig",
426 "glXCreateNewContext",
427 "glXCreatePbuffer",
428 "glXDestroyPbuffer",
429 "glXQueryContext",
430 "glXQueryDrawable",
431 "glXMakeContextCurrent",
432 "glXCreateWindow",
433 "glXGetVisualFromFBConfig",
434]
435
436print('#ifdef WINDOWS')
437
438for fun in useful_wgl_functions:
439 print('\tinterface->%s = (%sFunc_t) crDLLGetNoError(glDll, "%s");' % (fun,fun,fun))
440
441print('#elif defined(DARWIN)')
442for fun in useful_cgl_functions:
443 print('\tinterface->%s = (%sFunc_t) crDLLGetNoError(cglDll, "%s");' % (fun, fun,fun))
444
445for fun in in_gl_functions:
446 print('\tinterface->%s = (%sFunc_t) crDLLGetNoError(glDll, "%s");' % (fun, fun,fun))
447
448print('#else')
449print('\t/* GLX */')
450
451# XXX merge these loops?
452for fun in useful_glx_functions:
453 print('\tinterface->%s = (%sFunc_t) crDLLGetNoError(glDll, "%s");' % (fun, fun, fun))
454for fun in possibly_useful_glx_functions:
455 print('\tinterface->%s = (%sFunc_t) crDLLGetNoError(glDll, "%s");' % (fun, fun, fun))
456print('#endif')
457
458print("""
459 if (!entry)
460 return 1; /* token value */
461
462 for (i = 0; coreFunctions[i]; i++) {
463 const char *name = coreFunctions[i];
464 if (fillin(entry, name + 2, crDLLGetNoError(glDll, name)))
465 entry++;
466 else
467 crDebug("glLoader: NULL function %s", name);
468 }
469
470 /* end of table markers */
471 entry->name = NULL;
472 entry->fn = NULL;
473 return entry - table; /* number of entries filled */
474}
475
476
477/*
478 * Fill in table[] with all the OpenGL extension functions that we're
479 * interested in.
480 */
481int
482crLoadOpenGLExtensions( const crOpenGLInterface *interface, SPUNamedFunctionTable table[] )
483{
484 struct extfunc {
485 const char *funcName;""")
486max_aliases = apiutil.ReverseAliasesMaxCount()
487for i in range(1, 1 + max_aliases):
488 print("\t\tconst char *aliasName%d;" % i)
489print(""" SPUGenericFunction nopFunction;
490 };
491 static const struct extfunc functions[] = {
492""")
493
494for func_name in keys:
495 if IsExtensionFunc(func_name):
496 if apiutil.Category(func_name) == "Chromium":
497 prefix = "cr"
498 else:
499 prefix = "gl"
500 s = '\t\t{ "' + prefix + func_name + '"'
501 aliases = apiutil.ReverseAliases(func_name)
502 s += ''.join([', "' + prefix + a + '"' for a in aliases]) + ', NULL' * (max_aliases - len(aliases))
503 s += ', (SPUGenericFunction) Nop' + func_name + ' },'
504 print(s)
505
506print('\t\t{ NULL%s, NULL}' % (', NULL' * max_aliases))
507print("""
508 };
509 const struct extfunc *func;
510 SPUNamedFunctionTable *entry = table;
511
512#ifdef WINDOWS
513 if (interface->wglGetProcAddress == NULL)
514 crWarning("Unable to find wglGetProcAddress() in system GL library");
515#elif !defined(DARWIN)
516 if (interface->glXGetProcAddressARB == NULL)
517 crWarning("Unable to find glXGetProcAddressARB() in system GL library");
518#endif
519
520 for (func = functions; func->funcName; func++) {
521 SPUGenericFunction f = findExtFunction(interface, func->funcName);""")
522for i in range(1, 1 + max_aliases):
523 print(""" if (!f && func->aliasName%d) {
524 f = findExtFunction(interface, func->aliasName%d);
525 }"""% (i, i))
526print(""" if (!f) {
527 f = func->nopFunction;
528 }
529 (void) fillin(entry, func->funcName + 2 , f); /* +2 to skip "gl" */
530 entry++;
531 }
532
533 /* end of list */
534 entry->name = NULL;
535 entry->fn = NULL;
536 return entry - table; /* number of entries filled */
537}
538""")
539
540
541print("""
542
543#ifdef USE_OSMESA
544int crLoadOSMesa( OSMesaContext (**createContext)( GLenum format, OSMesaContext sharelist ),
545 GLboolean (**makeCurrent)( OSMesaContext ctx, GLubyte *buffer,
546 GLenum type, GLsizei width, GLsizei height ),
547 void (**destroyContext)( OSMesaContext ctx ))
548{
549 static CRDLL *osMesaDll = NULL;
550
551 const char *env_syspath = RTEnvGet( "CR_SYSTEM_GL_PATH" );
552
553 crDebug( "Looking for the system's OSMesa library..." );
554 osMesaDll = __findSystemLib( env_syspath, "libOSMesa.so" );
555 if (!osMesaDll)
556 {
557 crError("Unable to find system OSMesa!");
558 return 0;
559 }
560
561 crDebug( "Found it in %s.", !env_syspath ? "default path" : env_syspath );
562
563 *createContext = (OSMesaContext (*) ( GLenum format, OSMesaContext sharelist ))
564 crDLLGetNoError(osMesaDll, "OSMesaCreateContext");
565
566 *makeCurrent = (GLboolean (*) ( OSMesaContext ctx, GLubyte *buffer,
567 GLenum type, GLsizei width, GLsizei height ))
568 crDLLGetNoError(osMesaDll, "OSMesaMakeCurrent");
569
570 *destroyContext = (void (*) ( OSMesaContext ctx))
571 crDLLGetNoError(osMesaDll, "OSMesaDestroyContext");
572
573 return 1;
574}
575#endif
576
577""")
578
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette