core | glapi | vbo | math | shader | swrast | swrast_setup | tnl | tnl_dd

glapi_getproc.c File Reference


Detailed Description

Code for implementing glXGetProcAddress(), etc.

This was originally in glapi.c but refactored out.

#include <stdlib.h>
#include <string.h>
#include "main/glheader.h"
#include "main/compiler.h"
#include "glapi.h"
#include "glapioffsets.h"
#include "glapitable.h"
#include "glprocs.h"

Data Structures

struct  _glapi_function
 Track information about a function added to the GL API. More...

Defines

#define NEED_FUNCTION_POINTER

Functions

static void fill_in_entrypoint_offset (_glapi_proc entrypoint, GLuint offset)
 This function inserts a new dispatch offset into the assembly language stub that was generated with the preceeding function.
static char * str_dup (const char *str)
 strdup() is actually not a standard ANSI C or POSIX routine.
static const glprocs_table_tfind_entry (const char *n)
 Search the table of static entrypoint functions for the named function and return the corresponding glprocs_table_t entry.
static GLint get_static_proc_offset (const char *funcName)
 Return dispatch table offset of the named static (built-in) function.
static _glapi_proc get_static_proc_address (const char *funcName)
 Return dispatch function address for the named static (built-in) function.
static const char * get_static_proc_name (GLuint offset)
 Return the name of the function at the given offset in the dispatch table.
static _glapi_proc generate_entrypoint (GLuint functionOffset)
 Generate a dispatch function (entrypoint) which jumps through the given slot number (offset) in the current dispatch table.
static struct _glapi_functionadd_function_name (const char *funcName)
 Generate new entrypoint.
PUBLIC int _glapi_add_dispatch (const char *const *function_names, const char *parameter_signature)
 Fill-in the dispatch stub for the named function.
PUBLIC GLint _glapi_get_proc_offset (const char *funcName)
 Return offset of entrypoint for named function within dispatch table.
_glapi_proc _glapi_get_proc_address (const char *funcName)
 Return pointer to the named function.
const char * _glapi_get_proc_name (GLuint offset)
 Return the name of the function at the given dispatch offset.

Variables

static struct _glapi_function ExtEntryTable [MAX_EXTENSION_FUNCS]
static GLuint NumExtEntryPoints = 0


Define Documentation

#define NEED_FUNCTION_POINTER


Function Documentation

PUBLIC int _glapi_add_dispatch ( const char *const *  function_names,
const char *  parameter_signature 
)

Fill-in the dispatch stub for the named function.

This function is intended to be called by a hardware driver. When called, a dispatch stub may be created created for the function. A pointer to this dispatch function will be returned by glXGetProcAddress.

Parameters:
function_names Array of pointers to function names that should share a common dispatch offset.
parameter_signature String representing the types of the parameters passed to the named function. Parameter types are converted to characters using the following rules:
  • 'i' for GLint, GLuint, and GLenum
  • 'p' for any pointer type
  • 'f' for GLfloat and GLclampf
  • 'd' for GLdouble and GLclampd
Returns:
The offset in the dispatch table of the named function. A pointer to the driver's implementation of the named function should be stored at dispatch_table[offset]. Return -1 if error/problem.
See also:
glXGetProcAddress
Warning:
This function can only handle up to 8 names at a time. As far as I know, the maximum number of names ever associated with an existing GL function is 4 (glPointParameterfSGIS, glPointParameterfEXT, glPointParameterfARB, and glPointParameterf), so this should not be too painful of a limitation.
Todo:
Determine whether or not parameter_signature should be allowed to be NULL. It doesn't seem like much of a hardship for drivers to have to pass in an empty string.
Todo:
Determine if code should be added to reject function names that start with 'glX'.
Bug:
Add code to compare parameter_signature with the parameter signature of a static function. In order to do that, we need to find a way to get the parameter signature of a static function.

_glapi_proc _glapi_get_proc_address ( const char *  funcName  ) 

Return pointer to the named function.

If the function name isn't found in the name of static functions, try generating a new API entrypoint on the fly with assembly language.

const char* _glapi_get_proc_name ( GLuint  offset  ) 

Return the name of the function at the given dispatch offset.

This is only intended for debugging.

PUBLIC GLint _glapi_get_proc_offset ( const char *  funcName  ) 

Return offset of entrypoint for named function within dispatch table.

static struct _glapi_function* add_function_name ( const char *  funcName  )  [static, read]

Generate new entrypoint.

Use a temporary dispatch offset of ~0 (i.e. -1). Later, when the driver calls _glapi_add_dispatch we'll put in the proper offset. If that never happens, and the user calls this function, he'll segfault. That's what you get when you try calling a GL function that doesn't really exist.

Parameters:
funcName Name of the function to create an entry-point for.
See also:
_glapi_add_entrypoint

static void fill_in_entrypoint_offset ( _glapi_proc  entrypoint,
GLuint  offset 
) [static]

This function inserts a new dispatch offset into the assembly language stub that was generated with the preceeding function.

static const glprocs_table_t* find_entry ( const char *  n  )  [static]

Search the table of static entrypoint functions for the named function and return the corresponding glprocs_table_t entry.

static _glapi_proc generate_entrypoint ( GLuint  functionOffset  )  [static]

Generate a dispatch function (entrypoint) which jumps through the given slot number (offset) in the current dispatch table.

We need assembly language in order to accomplish this.

static _glapi_proc get_static_proc_address ( const char *  funcName  )  [static]

Return dispatch function address for the named static (built-in) function.

Return NULL if function not found.

static const char* get_static_proc_name ( GLuint  offset  )  [static]

Return the name of the function at the given offset in the dispatch table.

For debugging only.

static GLint get_static_proc_offset ( const char *  funcName  )  [static]

Return dispatch table offset of the named static (built-in) function.

Return -1 if function not found.

static char* str_dup ( const char *  str  )  [static]

strdup() is actually not a standard ANSI C or POSIX routine.

Irix will not define it if ANSI mode is in effect.


Variable Documentation

struct _glapi_function ExtEntryTable[MAX_EXTENSION_FUNCS] [static]

GLuint NumExtEntryPoints = 0 [static]


Generated on Sun Sep 27 06:47:56 2009 for Mesa GL API dispatcher by  doxygen 1.5.4