Major rip-up of internal function insertion interface. The old

_glapi_add_entrypoint has been replaced by a new routine called
_glapi_add_dispatch.  This new routine dynamically assignes dispatch offsets
to functions added.  This allows IHVs to add support for extension functions
that do not have assigned dispatch offsets.

It also means that a driver has no idea what offset will be assigned to a
function.  The vast majority of the changes in this commit account for that.
An additional table, driDispatchRemapTable, is added.  Functions not in the
Linux OpenGL ABI (i.e., anything not in GL 1.2 + ARB_multitexture) has a
fixed offset in this new table.  The entry in this table specifies the
offset in of the function in the real dispatch table.

The internal interface was also bumped from version 20050725 to 20050727.

This has been tested with various programs in progs/demos on:

radeon (Radeon Mobility M6)
r128 (Rage 128 Pro)
mga (G400)
This commit is contained in:
Ian Romanick
2005-07-28 00:29:51 +00:00
parent 9f23a3a1bf
commit 1585c234e0
42 changed files with 2995 additions and 996 deletions

View File

@@ -113,7 +113,7 @@ typedef void *(CREATENEWSCREENFUNC)(__DRInativeDisplay *dpy, int scrn,
const __DRIinterfaceMethods * interface,
__GLcontextModes ** driver_modes);
typedef CREATENEWSCREENFUNC* PFNCREATENEWSCREENFUNC;
extern CREATENEWSCREENFUNC __driCreateNewScreen_20050725;
extern CREATENEWSCREENFUNC __driCreateNewScreen_20050727;
/**
@@ -377,7 +377,7 @@ struct __DRIcontextRec {
/**
* Method to bind a DRI drawable to a DRI graphics context.
*
* \since Internal API version 20050725.
* \since Internal API version 20050727.
*/
GLboolean (*bindContext)(__DRInativeDisplay *dpy, int scrn, __DRIid draw,
__DRIid read, __DRIcontext *ctx);
@@ -385,7 +385,7 @@ struct __DRIcontextRec {
/**
* Method to unbind a DRI drawable from a DRI graphics context.
*
* \since Internal API version 20050725.
* \since Internal API version 20050727.
*/
GLboolean (*unbindContext)(__DRInativeDisplay *dpy, int scrn, __DRIid draw,
__DRIid read, __DRIcontext *ctx);

View File

@@ -166,7 +166,7 @@ ExtractDir(int index, const char *paths, int dirLen, char *dir)
* \todo
* Create a macro or something so that this is automatically updated.
*/
static const char createNewScreenName[] = "__driCreateNewScreen_20050725";
static const char createNewScreenName[] = "__driCreateNewScreen_20050727";
/**

View File

@@ -2886,10 +2886,10 @@ int __glXGetInternalVersion(void)
* 20040415 - Added support for bindContext3 and unbindContext3.
* 20040602 - Add __glXGetDrawableInfo. I though that was there
* months ago. :(
* 20050725 - Gut all the old interfaces. This breaks compatability with
* 20050727 - Gut all the old interfaces. This breaks compatability with
* any DRI driver built to any previous version.
*/
return 20050725;
return 20050727;
}

File diff suppressed because it is too large Load Diff

View File

@@ -34,6 +34,9 @@
#include "mtypes.h"
#include "extensions.h"
#include "utils.h"
#include "dispatch.h"
unsigned driDispatchRemapTable[ driDispatchRemapTable_size ];
#if defined(USE_X86_ASM)
#include "x86/common_x86_asm.h"
@@ -176,6 +179,30 @@ driGetRendererString( char * buffer, const char * hardware_name,
#define need_GL_ARB_multisample
#define need_GL_ARB_transpose_matrix
#define need_GL_ARB_window_pos
#define need_GL_EXT_compiled_vertex_array
#define need_GL_EXT_polygon_offset
#define need_GL_EXT_texture_object
#define need_GL_EXT_vertex_array
#define need_GL_MESA_window_pos
#include "extension_helper.h"
static const struct dri_extension all_mesa_extensions[] = {
{ "GL_ARB_multisample", GL_ARB_multisample_functions },
{ "GL_ARB_transpose_matrix", GL_ARB_transpose_matrix_functions },
{ "GL_ARB_window_pos", GL_ARB_window_pos_functions },
{ "GL_EXT_compiled_vertex_array", GL_EXT_compiled_vertex_array_functions },
{ "GL_EXT_polygon_offset", GL_EXT_polygon_offset_functions },
{ "GL_EXT_texture_object", GL_EXT_texture_object_functions },
{ "GL_EXT_vertex_array", GL_EXT_vertex_array_functions },
{ "GL_MESA_window_pos", GL_MESA_window_pos_functions },
{ NULL, NULL }
};
/**
* Enable extensions supported by the driver.
*
@@ -189,9 +216,15 @@ void driInitExtensions( GLcontext * ctx,
const struct dri_extension * extensions_to_enable,
GLboolean enable_imaging )
{
static int first_time = 1;
unsigned i;
if ( enable_imaging ) {
if ( first_time ) {
first_time = 0;
driInitExtensions( ctx, all_mesa_extensions, GL_FALSE );
}
if ( (ctx != NULL) && enable_imaging ) {
_mesa_enable_imaging_extensions( ctx );
}
@@ -220,12 +253,14 @@ void driInitSingleExtension( GLcontext * ctx,
{
unsigned i;
if ( ext->functions != NULL ) {
for ( i = 0 ; ext->functions[i].strings != NULL ; i++ ) {
const char * functions[16];
const char * parameter_signature;
const char * str = ext->functions[i].strings;
unsigned j;
unsigned offset;
/* Separate the parameter signature from the rest of the string.
@@ -260,14 +295,23 @@ void driInitSingleExtension( GLcontext * ctx,
/* Add each entry-point to the dispatch table.
*/
for ( j = 0 ; functions[j] != NULL ; j++ ) {
_glapi_add_entrypoint( functions[j],
ext->functions[i].offset );
offset = _glapi_add_dispatch( functions, parameter_signature );
if ( ext->functions[i].remap_index != -1 ) {
driDispatchRemapTable[ ext->functions[i].remap_index ] = offset;
}
if ( (ext->functions[i].offset != -1)
&& (ext->functions[i].offset != offset) ) {
fprintf(stderr, "DISPATCH ERROR! %s -> %u != %u\n", functions[0],
driDispatchRemapTable[ ext->functions[i].remap_index ],
ext->functions[i].offset);
}
}
}
_mesa_enable_extension( ctx, ext->name );
if ( ctx != NULL ) {
_mesa_enable_extension( ctx, ext->name );
}
}

View File

@@ -54,10 +54,16 @@ struct dri_extension_function {
const char * strings;
/**
* Location in the remap table where the dispatch offset should be
* stored.
*/
int remap_index;
/**
* Offset of the function in the dispatch table.
*/
unsigned offset;
int offset;
};
/**

View File

@@ -708,7 +708,7 @@ ffbFillInModes( unsigned pixel_bits, unsigned depth_bits,
* failure.
*/
PUBLIC
void * __driCreateNewScreen_20050725( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
const __GLcontextModes * modes,
const __DRIversion * ddx_version,
const __DRIversion * dri_version,

View File

@@ -424,7 +424,7 @@ static const struct __DriverAPIRec i810API = {
* failure.
*/
PUBLIC
void * __driCreateNewScreen_20050725( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
const __GLcontextModes * modes,
const __DRIversion * ddx_version,
const __DRIversion * dri_version,

View File

@@ -149,7 +149,7 @@ static void i830BufferSize(GLframebuffer *buffer,
/* Extension strings exported by the i830 driver.
*/
static const struct dri_extension card_extensions[] =
const struct dri_extension card_extensions[] =
{
{ "GL_ARB_multisample", GL_ARB_multisample_functions },
{ "GL_ARB_multitexture", NULL },

View File

@@ -67,6 +67,7 @@ DRI_CONF_BEGIN
DRI_CONF_END;
const GLuint __driNConfigOptions = 2;
extern const struct dri_extension card_extensions[];
static int i830_malloc_proxy_buf(drmBufMapPtr buffers)
{
@@ -502,7 +503,7 @@ i830FillInModes( unsigned pixel_bits, unsigned depth_bits,
* failure.
*/
PUBLIC
void * __driCreateNewScreen_20050725( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
const __GLcontextModes * modes,
const __DRIversion * ddx_version,
const __DRIversion * dri_version,
@@ -538,6 +539,16 @@ void * __driCreateNewScreen_20050725( __DRInativeDisplay *dpy, int scrn, __DRIsc
(dri_priv->cpp == 2) ? 16 : 24,
(dri_priv->cpp == 2) ? 0 : 8,
(dri_priv->backOffset != dri_priv->depthOffset) );
/* Calling driInitExtensions here, with a NULL context pointer, does not actually
* enable the extensions. It just makes sure that all the dispatch offsets for all
* the extensions that *might* be enables are known. This is needed because the
* dispatch offsets need to be known when _mesa_context_create is called, but we can't
* enable the extensions until we have a context pointer.
*
* Hello chicken. Hello egg. How are you two today?
*/
driInitExtensions( NULL, card_extensions, GL_FALSE );
}
return (void *) psp;

View File

@@ -38,7 +38,7 @@
* Mesa's Driver Functions
***************************************/
static const struct dri_extension card_extensions[] =
static const struct dri_extension i830_extensions[] =
{
{ "GL_ARB_texture_env_crossbar", NULL },
{ NULL, NULL }
@@ -109,7 +109,7 @@ GLboolean i830CreateContext( const __GLcontextModes *mesaVis,
intel->verts = TNL_CONTEXT(ctx)->clipspace.vertex_buf;
driInitExtensions( ctx, card_extensions, GL_FALSE );
driInitExtensions( ctx, i830_extensions, GL_FALSE );
i830InitState( i830 );

View File

@@ -45,7 +45,7 @@
* Mesa's Driver Functions
***************************************/
static const struct dri_extension card_extensions[] =
static const struct dri_extension i915_extensions[] =
{
{ "GL_ARB_depth_texture", NULL },
{ "GL_ARB_fragment_program", NULL },
@@ -166,7 +166,7 @@ GLboolean i915CreateContext( const __GLcontextModes *mesaVis,
ctx->Const.MaxFragmentProgramAddressRegs = 0; /* I don't think we have one */
driInitExtensions( ctx, card_extensions, GL_FALSE );
driInitExtensions( ctx, i915_extensions, GL_FALSE );
_tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12,

View File

@@ -153,7 +153,7 @@ static void intelBufferSize(GLframebuffer *buffer,
* It appears that ARB_texture_env_crossbar has "disappeared" compared to the
* old i830-specific driver.
*/
static const struct dri_extension card_extensions[] =
const struct dri_extension card_extensions[] =
{
{ "GL_ARB_multisample", GL_ARB_multisample_functions },
{ "GL_ARB_multitexture", NULL },

View File

@@ -54,6 +54,7 @@ DRI_CONF_BEGIN
DRI_CONF_END;
const GLuint __driNConfigOptions = 1;
extern const struct dri_extension card_extensions[];
static void intelPrintDRIInfo(intelScreenPrivate *intelScreen,
__DRIscreenPrivate *sPriv,
@@ -457,7 +458,7 @@ intelFillInModes( unsigned pixel_bits, unsigned depth_bits,
* failure.
*/
PUBLIC
void * __driCreateNewScreen_20050725( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
const __GLcontextModes * modes,
const __DRIversion * ddx_version,
const __DRIversion * dri_version,
@@ -493,6 +494,16 @@ void * __driCreateNewScreen_20050725( __DRInativeDisplay *dpy, int scrn, __DRIsc
(dri_priv->cpp == 2) ? 16 : 24,
(dri_priv->cpp == 2) ? 0 : 8,
(dri_priv->backOffset != dri_priv->depthOffset) );
/* Calling driInitExtensions here, with a NULL context pointer, does not actually
* enable the extensions. It just makes sure that all the dispatch offsets for all
* the extensions that *might* be enables are known. This is needed because the
* dispatch offsets need to be known when _mesa_context_create is called, but we can't
* enable the extensions until we have a context pointer.
*
* Hello chicken. Hello egg. How are you two today?
*/
driInitExtensions( NULL, card_extensions, GL_FALSE );
}
return (void *) psp;

View File

@@ -498,7 +498,7 @@ static struct __DriverAPIRec mach64API = {
* failure.
*/
PUBLIC
void * __driCreateNewScreen_20050725( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
const __GLcontextModes * modes,
const __DRIversion * ddx_version,
const __DRIversion * dri_version,

View File

@@ -934,7 +934,7 @@ static const struct __DriverAPIRec mgaAPI = {
* failure.
*/
PUBLIC
void * __driCreateNewScreen_20050725( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
const __GLcontextModes * modes,
const __DRIversion * ddx_version,
const __DRIversion * dri_version,
@@ -970,6 +970,20 @@ void * __driCreateNewScreen_20050725( __DRInativeDisplay *dpy, int scrn, __DRIsc
(dri_priv->cpp == 2) ? 16 : 24,
(dri_priv->cpp == 2) ? 0 : 8,
(dri_priv->backOffset != dri_priv->depthOffset) );
/* Calling driInitExtensions here, with a NULL context pointer, does not actually
* enable the extensions. It just makes sure that all the dispatch offsets for all
* the extensions that *might* be enables are known. This is needed because the
* dispatch offsets need to be known when _mesa_context_create is called, but we can't
* enable the extensions until we have a context pointer.
*
* Hello chicken. Hello egg. How are you two today?
*/
driInitExtensions( NULL, card_extensions, GL_FALSE );
driInitExtensions( NULL, g400_extensions, GL_FALSE );
driInitSingleExtension( NULL, ARB_vp_extension );
driInitExtensions( NULL, NV_vp_extensions, GL_FALSE );
}
return (void *) psp;

View File

@@ -71,7 +71,7 @@ int R128_DEBUG = 0;
#define need_GL_EXT_blend_minmax
#include "extension_helper.h"
static const struct dri_extension card_extensions[] =
const struct dri_extension card_extensions[] =
{
{ "GL_ARB_multisample", GL_ARB_multisample_functions },
{ "GL_ARB_multitexture", NULL },

View File

@@ -75,6 +75,8 @@ static const GLuint __driNConfigOptions = 4;
static const GLuint __driNConfigOptions = 3;
#endif
extern const struct dri_extension card_extensions[];
#if 1
/* Including xf86PciInfo.h introduces a bunch of errors...
*/
@@ -482,7 +484,7 @@ r128FillInModes( unsigned pixel_bits, unsigned depth_bits,
* failure.
*/
PUBLIC
void * __driCreateNewScreen_20050725( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
const __GLcontextModes * modes,
const __DRIversion * ddx_version,
const __DRIversion * dri_version,
@@ -519,6 +521,16 @@ void * __driCreateNewScreen_20050725( __DRInativeDisplay *dpy, int scrn, __DRIsc
(dri_priv->bpp == 16) ? 16 : 24,
(dri_priv->bpp == 16) ? 0 : 8,
(dri_priv->backOffset != dri_priv->depthOffset) );
/* Calling driInitExtensions here, with a NULL context pointer, does not actually
* enable the extensions. It just makes sure that all the dispatch offsets for all
* the extensions that *might* be enables are known. This is needed because the
* dispatch offsets need to be known when _mesa_context_create is called, but we can't
* enable the extensions until we have a context pointer.
*
* Hello chicken. Hello egg. How are you two today?
*/
driInitExtensions( NULL, card_extensions, GL_FALSE );
}
return (void *) psp;

View File

@@ -131,7 +131,7 @@ static const GLubyte *r200GetString( GLcontext *ctx, GLenum name )
/* Extension strings exported by the R200 driver.
*/
static const struct dri_extension card_extensions[] =
const struct dri_extension card_extensions[] =
{
{ "GL_ARB_multisample", GL_ARB_multisample_functions },
{ "GL_ARB_multitexture", NULL },
@@ -162,17 +162,17 @@ static const struct dri_extension card_extensions[] =
{ NULL, NULL }
};
static const struct dri_extension blend_extensions[] = {
const struct dri_extension blend_extensions[] = {
{ "GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions },
{ "GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions },
{ NULL, NULL }
};
static const struct dri_extension ARB_vp_extension[] = {
const struct dri_extension ARB_vp_extension[] = {
{ "GL_ARB_vertex_program", GL_ARB_vertex_program_functions }
};
static const struct dri_extension NV_vp_extension[] = {
const struct dri_extension NV_vp_extension[] = {
{ "GL_NV_vertex_program", GL_NV_vertex_program_functions }
};

View File

@@ -90,6 +90,11 @@ DRI_CONF_BEGIN
DRI_CONF_END;
static const GLuint __driNConfigOptions = 17;
extern const struct dri_extension card_extensions[];
extern const struct dri_extension blend_extensions[];
extern const struct dri_extension ARB_vp_extension[];
extern const struct dri_extension NV_vp_extension[];
#if 1
/* Including xf86PciInfo.h introduces a bunch of errors...
*/
@@ -642,7 +647,7 @@ static const struct __DriverAPIRec r200API = {
* failure.
*/
PUBLIC
void * __driCreateNewScreen_20050725( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
const __GLcontextModes * modes,
const __DRIversion * ddx_version,
const __DRIversion * dri_version,
@@ -678,6 +683,19 @@ void * __driCreateNewScreen_20050725( __DRInativeDisplay *dpy, int scrn, __DRIsc
(dri_priv->bpp == 16) ? 16 : 24,
(dri_priv->bpp == 16) ? 0 : 8,
(dri_priv->backOffset != dri_priv->depthOffset) );
/* Calling driInitExtensions here, with a NULL context pointer, does not actually
* enable the extensions. It just makes sure that all the dispatch offsets for all
* the extensions that *might* be enables are known. This is needed because the
* dispatch offsets need to be known when _mesa_context_create is called, but we can't
* enable the extensions until we have a context pointer.
*
* Hello chicken. Hello egg. How are you two today?
*/
driInitExtensions( NULL, card_extensions, GL_FALSE );
driInitExtensions( NULL, blend_extensions, GL_FALSE );
driInitSingleExtension( NULL, ARB_vp_extension );
driInitSingleExtension( NULL, NV_vp_extension );
}
return (void *) psp;

View File

@@ -73,7 +73,7 @@ int hw_tcl_on=0;
#define need_GL_EXT_blend_minmax
#include "extension_helper.h"
static const struct dri_extension card_extensions[] = {
const struct dri_extension card_extensions[] = {
{"GL_ARB_multisample", GL_ARB_multisample_functions},
{"GL_ARB_multitexture", NULL},
{"GL_ARB_texture_border_clamp", NULL},

View File

@@ -132,6 +132,7 @@ DRI_CONF_BEGIN
DRI_CONF_END;
static const GLuint __driR300NConfigOptions = 13;
extern const struct dri_extension card_extensions[];
#ifndef RADEON_DEBUG
int RADEON_DEBUG = 0;
@@ -789,7 +790,7 @@ static const struct __DriverAPIRec radeonAPI = {
* \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on
* failure.
*/
void *__driCreateNewScreen_20050725(__DRInativeDisplay * dpy, int scrn,
void *__driCreateNewScreen_20050727(__DRInativeDisplay * dpy, int scrn,
__DRIscreen * psc, const __GLcontextModes * modes,
const __DRIversion * ddx_version,
const __DRIversion * dri_version,
@@ -826,6 +827,15 @@ void *__driCreateNewScreen_20050725(__DRInativeDisplay * dpy, int scrn,
16) ? 0 : 8,
(dri_priv->backOffset !=
dri_priv->depthOffset));
/* Calling driInitExtensions here, with a NULL context pointer, does not actually
* enable the extensions. It just makes sure that all the dispatch offsets for all
* the extensions that *might* be enables are known. This is needed because the
* dispatch offsets need to be known when _mesa_context_create is called, but we can't
* enable the extensions until we have a context pointer.
*
* Hello chicken. Hello egg. How are you two today?
*/
driInitExtensions( NULL, card_extensions, GL_FALSE );
}
return (void *)psp;

View File

@@ -125,7 +125,7 @@ static const GLubyte *radeonGetString( GLcontext *ctx, GLenum name )
/* Extension strings exported by the R100 driver.
*/
static const struct dri_extension card_extensions[] =
const struct dri_extension card_extensions[] =
{
{ "GL_ARB_multisample", GL_ARB_multisample_functions },
{ "GL_ARB_multitexture", NULL },

View File

@@ -83,6 +83,8 @@ DRI_CONF_BEGIN
DRI_CONF_END;
static const GLuint __driNConfigOptions = 13;
extern const struct dri_extension card_extensions[];
#if 1
/* Including xf86PciInfo.h introduces a bunch of errors...
*/
@@ -566,7 +568,7 @@ static struct __DriverAPIRec radeonAPI = {
* failure.
*/
PUBLIC
void * __driCreateNewScreen_20050725( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
const __GLcontextModes * modes,
const __DRIversion * ddx_version,
const __DRIversion * dri_version,
@@ -602,6 +604,16 @@ void * __driCreateNewScreen_20050725( __DRInativeDisplay *dpy, int scrn, __DRIsc
(dri_priv->bpp == 16) ? 16 : 24,
(dri_priv->bpp == 16) ? 0 : 8,
(dri_priv->backOffset != dri_priv->depthOffset) );
/* Calling driInitExtensions here, with a NULL context pointer, does not actually
* enable the extensions. It just makes sure that all the dispatch offsets for all
* the extensions that *might* be enables are known. This is needed because the
* dispatch offsets need to be known when _mesa_context_create is called, but we can't
* enable the extensions until we have a context pointer.
*
* Hello chicken. Hello egg. How are you two today?
*/
driInitExtensions( NULL, card_extensions, GL_FALSE );
}
return (void *) psp;

View File

@@ -128,7 +128,7 @@ unsigned long time_sum=0;
struct timeval tv_s1,tv_f1;
#endif
static const struct dri_extension common_extensions[] =
static const struct dri_extension card_extensions[] =
{
{ "GL_ARB_multisample", GL_ARB_multisample_functions },
{ "GL_ARB_multitexture", NULL },
@@ -534,7 +534,7 @@ savageCreateContext( const __GLcontextModes *mesaVis,
debug_control );
#endif
driInitExtensions( ctx, common_extensions, GL_TRUE );
driInitExtensions( ctx, card_extensions, GL_TRUE );
if (savageScreen->chipset >= S3_SAVAGE4)
driInitExtensions( ctx, s4_extensions, GL_FALSE );
if (ctx->Mesa_DXTn ||
@@ -997,7 +997,7 @@ savageFillInModes( unsigned pixel_bits, unsigned depth_bits,
* failure.
*/
PUBLIC
void * __driCreateNewScreen_20050725( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
const __GLcontextModes * modes,
const __DRIversion * ddx_version,
const __DRIversion * dri_version,
@@ -1033,6 +1033,16 @@ void * __driCreateNewScreen_20050725( __DRInativeDisplay *dpy, int scrn, __DRIsc
(dri_priv->cpp == 2) ? 16 : 24,
(dri_priv->cpp == 2) ? 0 : 8,
(dri_priv->backOffset != dri_priv->depthOffset) );
/* Calling driInitExtensions here, with a NULL context pointer, does not actually
* enable the extensions. It just makes sure that all the dispatch offsets for all
* the extensions that *might* be enables are known. This is needed because the
* dispatch offsets need to be known when _mesa_context_create is called, but we can't
* enable the extensions until we have a context pointer.
*
* Hello chicken. Hello egg. How are you two today?
*/
driInitExtensions( NULL, card_extensions, GL_FALSE );
}
return (void *) psp;

View File

@@ -64,7 +64,7 @@ int GlobalCurrentHwcx = -1;
int GlobalHwcxCountBase = 1;
int GlobalCmdQueueLen = 0;
static const struct dri_extension card_extensions[] =
const struct dri_extension card_extensions[] =
{
{ "GL_ARB_multisample", GL_ARB_multisample_functions },
{ "GL_ARB_multitexture", NULL },

View File

@@ -413,7 +413,7 @@ static struct __DriverAPIRec sisAPI = {
* failure.
*/
PUBLIC
void * __driCreateNewScreen_20050725( __DRInativeDisplay *dpy, int scrn,
void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn,
__DRIscreen *psc,
const __GLcontextModes *modes,
const __DRIversion *ddx_version,

View File

@@ -83,7 +83,7 @@
/**
* Common extension strings exported by all cards
*/
static const struct dri_extension card_extensions[] =
const struct dri_extension card_extensions[] =
{
{ "GL_ARB_multisample", GL_ARB_multisample_functions },
{ "GL_ARB_texture_mirrored_repeat", NULL },
@@ -123,7 +123,7 @@ static const struct dri_extension card_extensions[] =
/**
* Extension strings exported only by Naplam (e.g., Voodoo4 & Voodoo5) cards.
*/
static const struct dri_extension napalm_extensions[] =
const struct dri_extension napalm_extensions[] =
{
{ "GL_ARB_texture_compression", GL_ARB_texture_compression_functions },
{ "GL_ARB_texture_env_combine", NULL },

View File

@@ -65,6 +65,9 @@ DRI_CONF_END;
static const GLuint __driNConfigOptions = 1;
extern const struct dri_extension card_extensions[];
extern const struct dri_extension napalm_extensions[];
static GLboolean
tdfxCreateScreen( __DRIscreenPrivate *sPriv )
{
@@ -426,7 +429,7 @@ static __GLcontextModes *tdfxFillInModes(unsigned pixel_bits,
* failure.
*/
PUBLIC
void * __driCreateNewScreen_20050725( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
const __GLcontextModes * modes,
const __DRIversion * ddx_version,
const __DRIversion * dri_version,
@@ -467,6 +470,17 @@ void * __driCreateNewScreen_20050725( __DRInativeDisplay *dpy, int scrn, __DRIsc
*driver_modes = tdfxFillInModes(bpp, (bpp == 16) ? 16 : 24,
(bpp == 16) ? 0 : 8,
(dri_priv->backOffset!=dri_priv->depthOffset));
/* Calling driInitExtensions here, with a NULL context pointer, does not actually
* enable the extensions. It just makes sure that all the dispatch offsets for all
* the extensions that *might* be enables are known. This is needed because the
* dispatch offsets need to be known when _mesa_context_create is called, but we can't
* enable the extensions until we have a context pointer.
*
* Hello chicken. Hello egg. How are you two today?
*/
driInitExtensions( NULL, card_extensions, GL_FALSE );
driInitExtensions( NULL, napalm_extensions, GL_FALSE );
}
return (void *)psp;

View File

@@ -426,7 +426,7 @@ static struct __DriverAPIRec tridentAPI = {
};
PUBLIC void *__driCreateNewScreen_20050725( __DRInativeDisplay *dpy, int scrn,
PUBLIC void *__driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn,
__DRIscreen *psc,
const __GLcontextModes * modes,
const __DRIversion * ddx_version,

View File

@@ -251,7 +251,7 @@ static void viaBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height)
/* Extension strings exported by the Unichrome driver.
*/
static const struct dri_extension card_extensions[] =
const struct dri_extension card_extensions[] =
{
{ "GL_ARB_multisample", GL_ARB_multisample_functions },
{ "GL_ARB_multitexture", NULL },

View File

@@ -61,6 +61,7 @@ DRI_CONF_BEGIN
DRI_CONF_END;
static const GLuint __driNConfigOptions = 3;
extern const struct dri_extension card_extensions[];
static int getSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo );
@@ -402,7 +403,7 @@ viaFillInModes( unsigned pixel_bits, GLboolean have_back_buffer )
* failure.
*/
PUBLIC
void * __driCreateNewScreen_20050725( __DRInativeDisplay *dpy, int scrn,
void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn,
__DRIscreen *psc,
const __GLcontextModes * modes,
const __DRIversion * ddx_version,
@@ -437,6 +438,16 @@ void * __driCreateNewScreen_20050725( __DRInativeDisplay *dpy, int scrn,
VIADRIPtr dri_priv = (VIADRIPtr) psp->pDevPriv;
*driver_modes = viaFillInModes( dri_priv->bytesPerPixel * 8,
GL_TRUE );
/* Calling driInitExtensions here, with a NULL context pointer, does not actually
* enable the extensions. It just makes sure that all the dispatch offsets for all
* the extensions that *might* be enables are known. This is needed because the
* dispatch offsets need to be known when _mesa_context_create is called, but we can't
* enable the extensions until we have a context pointer.
*
* Hello chicken. Hello egg. How are you two today?
*/
driInitExtensions( NULL, card_extensions, GL_FALSE );
}
fprintf(stderr, "%s - succeeded\n", __FUNCTION__);

File diff suppressed because it is too large Load Diff

View File

@@ -102,6 +102,24 @@ vtxfmt = [
"EvalMesh2", \
]
def all_entrypoints_in_abi(f, abi, api):
for n in f.entry_points:
[category, num] = api.get_category_for_name( n )
if category not in abi:
return 0
return 1
def any_entrypoints_in_abi(f, abi, api):
for n in f.entry_points:
[category, num] = api.get_category_for_name( n )
if category in abi:
return 1
return 0
def condition_for_function(f, abi, all_not_in_ABI):
"""Create a C-preprocessor condition for the function.
@@ -133,6 +151,7 @@ class PrintGlExtensionGlue(gl_XML.gl_print_base):
def printRealHeader(self):
print '#include "utils.h"'
print '#include "dispatch.h"'
print ''
return
@@ -178,7 +197,7 @@ class PrintGlExtensionGlue(gl_XML.gl_print_base):
if not category_list.has_key(c):
category_list[ c ] = []
category_list[ c ].append( [f.name, f.offset] )
category_list[ c ].append( f )
print ' "";'
print '#endif'
@@ -190,9 +209,17 @@ class PrintGlExtensionGlue(gl_XML.gl_print_base):
for category in keys:
print '#if defined(need_%s)' % (category)
print 'static const struct dri_extension_function %s_functions[] = {' % (category)
for [function, offset] in category_list[ category ]:
print ' { %s_names, %d },' % (function, offset)
print ' { NULL, 0 }'
for f in category_list[ category ]:
if any_entrypoints_in_abi(f, abi, api):
index_name = "-1"
else:
index_name = "%s_remap_index" % (f.name)
print ' { %s_names, %s, %d },' % (f.name, index_name, f.offset)
print ' { NULL, 0, 0 }'
print '};'
print '#endif'
print ''

View File

@@ -41,8 +41,14 @@ class PrintGlOffsets(gl_XML.gl_print_base):
return
def printBody(self, api):
last_static = 0
for f in api.functionIterateByOffset():
print '#define _gloffset_%s %d' % (f.name, f.offset)
if f.offset > last_static:
last_static = f.offset
print '#define _gloffset_FIRST_DYNAMIC %d' % (last_static + 1)
return
def show_usage():

View File

@@ -52,6 +52,8 @@ class PrintGlTable(gl_XML.gl_print_base):
print '#define GLAPIENTRYP'
print '#endif'
print ''
print 'typedef void (*_glapi_proc)(void); /* generic function pointer */'
print ''
print 'struct _glapi_table'
print '{'
return
@@ -93,15 +95,9 @@ class PrintRemapTable(gl_XML.gl_print_base):
print '#define GET_by_offset(disp, offset) \\'
print ' (((_glapi_proc *)(disp))[offset])'
print '#define SET_by_offset(disp, offset, fn) \\'
print ' ((((_glapi_proc *)(disp))[offset]) = fn)'
print ' ((((_glapi_proc *)(disp))[offset]) = (_glapi_proc) fn)'
print ''
for f in api.functionIterateByOffset():
print '#define CALL_%s(disp, parameters) (*((disp)->%s)) parameters' % (f.name, f.name)
print '#define GET_%s(disp) ((disp)->%s)' % (f.name, f.name)
print '#define SET_%s(disp, fn) ((disp)->%s = fn)' % (f.name, f.name)
return
abi = [ "1.0", "1.1", "1.2", "GL_ARB_multitexture" ]
functions = []
@@ -116,26 +112,44 @@ class PrintRemapTable(gl_XML.gl_print_base):
abi_functions.append( f )
print 'struct _mesa_dispatch_remap_table {'
for f in abi_functions:
print '#define CALL_%s(disp, parameters) (*((disp)->%s)) parameters' % (f.name, f.name)
print '#define GET_%s(disp) ((disp)->%s)' % (f.name, f.name)
print '#define SET_%s(disp, fn) ((disp)->%s = fn)' % (f.name, f.name)
print ''
print '#if !defined(IN_DRI_DRIVER)'
print ''
for [f, index] in functions:
print ' unsigned %s;' % (f.name)
print '#define CALL_%s(disp, parameters) (*((disp)->%s)) parameters' % (f.name, f.name)
print '#define GET_%s(disp) ((disp)->%s)' % (f.name, f.name)
print '#define SET_%s(disp, fn) ((disp)->%s = fn)' % (f.name, f.name)
print '};'
print ''
print '/* %u functions need remapping. */' % (count)
print '#else'
print ''
print '#define driDispatchRemapTable_size %u' % (count)
print 'extern unsigned driDispatchRemapTable[ driDispatchRemapTable_size ];'
print ''
for f in abi_functions:
print '#define CALL_%s(disp, parameters) (*disp->%s) parameters' % (f.name, f.name)
for [f, index] in functions:
print '#define %s_remap_index %u' % (f.name, index)
print ''
for [f, index] in functions:
arg_string = gl_XML.create_parameter_string( f.parameters, 0 )
cast = '%s (GLAPIENTRYP)(%s)' % (f.return_type, arg_string)
print '#define CALL_%s(disp, parameters) (* (%s) (((_glapi_proc *)disp)[dispatch_remap.%s])) parameters' % (f.name, cast, f.name)
print '#define CALL_%s(disp, parameters) CALL_by_offset(disp, (%s), driDispatchRemapTable[%s_remap_index], parameters)' % (f.name, cast, f.name)
print '#define GET_%s(disp) GET_by_offset(disp, driDispatchRemapTable[%s_remap_index])' % (f.name, f.name)
print '#define SET_%s(disp, fn) SET_by_offset(disp, driDispatchRemapTable[%s_remap_index], fn)' % (f.name, f.name)
print ''
print '#endif /* !defined(IN_DRI_DRIVER) */'
return

View File

@@ -671,14 +671,52 @@ get_static_proc_name( GLuint offset )
#define DISPATCH_TABLE_SIZE (sizeof(struct _glapi_table) / sizeof(void *) + MAX_EXTENSION_FUNCS)
struct name_address_offset {
const char *Name;
_glapi_proc Address;
GLuint Offset;
/**
* Track information about a function added to the GL API.
*/
struct _glapi_function {
/**
* Name of the function.
*/
const char * name;
/**
* Text string that describes the types of the parameters passed to the
* named function. Parameter types are converted to characters using the
* following rules:
* - 'i' for \c GLint, \c GLuint, and \c GLenum
* - 'p' for any pointer type
* - 'f' for \c GLfloat and \c GLclampf
* - 'd' for \c GLdouble and \c GLclampd
*/
const char * parameter_signature;
/**
* Offset in the dispatch table where the pointer to the real function is
* located. If the driver has not requested that the named function be
* added to the dispatch table, this will have the value ~0.
*/
unsigned dispatch_offset;
/**
* Pointer to the dispatch stub for the named function.
*
* \todo
* The semantic of this field should be changed slightly. Currently, it
* is always expected to be non-\c NULL. However, it would be better to
* only allocate the entry-point stub when the application requests the
* function via \c glXGetProcAddress. This would save memory for all the
* functions that the driver exports but that the application never wants
* to call.
*/
_glapi_proc dispatch_stub;
};
static struct name_address_offset ExtEntryTable[MAX_EXTENSION_FUNCS];
static struct _glapi_function ExtEntryTable[MAX_EXTENSION_FUNCS];
static GLuint NumExtEntryPoints = 0;
#ifdef USE_SPARC_ASM
@@ -814,76 +852,189 @@ fill_in_entrypoint_offset(_glapi_proc entrypoint, GLuint offset)
/**
* Add a new extension function entrypoint.
* Return: GL_TRUE = success or GL_FALSE = failure
* Generate new entrypoint
*
* Use a temporary dispatch offset of ~0 (i.e. -1). Later, when the driver
* calls \c _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.
*
* \param funcName Name of the function to create an entry-point for.
*
* \sa _glapi_add_entrypoint
*/
PUBLIC GLboolean
_glapi_add_entrypoint(const char *funcName, GLuint offset)
static struct _glapi_function *
add_function_name( const char * funcName )
{
/* trivial rejection test */
struct _glapi_function * entry = NULL;
if (NumExtEntryPoints < MAX_EXTENSION_FUNCS) {
_glapi_proc entrypoint = generate_entrypoint(~0);
if (entrypoint != NULL) {
entry = & ExtEntryTable[NumExtEntryPoints];
ExtEntryTable[NumExtEntryPoints].name = str_dup(funcName);
ExtEntryTable[NumExtEntryPoints].parameter_signature = NULL;
ExtEntryTable[NumExtEntryPoints].dispatch_offset = ~0;
ExtEntryTable[NumExtEntryPoints].dispatch_stub = entrypoint;
NumExtEntryPoints++;
}
}
return entry;
}
/**
* 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.
*
* \param function_names Array of pointers to function names that should
* share a common dispatch offset.
* \param 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 \c GLint, \c GLuint, and \c GLenum
* - 'p' for any pointer type
* - 'f' for \c GLfloat and \c GLclampf
* - 'd' for \c GLdouble and \c 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
* \c dispatch_table[\c offset].
*
* \sa 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 (\c glPointParameterfSGIS, \c glPointParameterfEXT,
* \c glPointParameterfARB, and \c glPointParameterf), so this should not be
* too painful of a limitation.
*
* \todo
* Determine whether or not \c parameter_signature should be allowed to be
* \c 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 \c parameter_signature with the parameter signature of
* a static function. In order to do that, we need to find a way to \b get
* the parameter signature of a static function.
*/
PUBLIC int
_glapi_add_dispatch( const char * const * function_names,
const char * parameter_signature )
{
static int next_dynamic_offset = _gloffset_FIRST_DYNAMIC;
const char * const real_sig = (parameter_signature != NULL)
? parameter_signature : "";
struct _glapi_function * entry[8];
GLboolean is_static[8];
unsigned i;
unsigned j;
int offset = ~0;
int new_offset;
(void) memset( is_static, 0, sizeof( is_static ) );
(void) memset( entry, 0, sizeof( entry ) );
for ( i = 0 ; function_names[i] != NULL ; i++ ) {
/* Do some trivial validation on the name of the function.
*/
#ifdef MANGLE
if (!funcName || funcName[0] != 'm' || funcName[1] != 'g' || funcName[2] != 'l')
return GL_FALSE;
if (!function_names[i] || function_names[i][0] != 'm' || function_names[i][1] != 'g' || function_names[i][2] != 'l')
return GL_FALSE;
#else
if (!funcName || funcName[0] != 'g' || funcName[1] != 'l')
return GL_FALSE;
if (!function_names[i] || function_names[i][0] != 'g' || function_names[i][1] != 'l')
return GL_FALSE;
#endif
/* Determine if the named function already exists. If the function does
* exist, it must have the same parameter signature as the function
* being added.
*/
/* first check if the named function is already statically present */
{
GLint index = get_static_proc_offset(funcName);
if (index >= 0) {
return (GLboolean) ((GLuint) index == offset); /* bad offset! */
new_offset = get_static_proc_offset(function_names[i]);
if (new_offset >= 0) {
/* FIXME: Make sure the parameter signatures match! How do we get
* FIXME: the parameter signature for static functions?
*/
if ( (offset != ~0) && (new_offset != offset) ) {
return -1;
}
is_static[i] = GL_TRUE;
offset = new_offset;
}
for ( j = 0 ; j < NumExtEntryPoints ; j++ ) {
if (strcmp(ExtEntryTable[j].name, function_names[i]) == 0) {
/* The offset may be ~0 if the function name was added by
* glXGetProcAddress but never filled in by the driver.
*/
if (ExtEntryTable[j].dispatch_offset != ~0) {
if (strcmp(real_sig, ExtEntryTable[j].parameter_signature)
!= 0) {
return -1;
}
if ( (offset != ~0) && (ExtEntryTable[j].dispatch_offset != offset) ) {
return -1;
}
offset = ExtEntryTable[j].dispatch_offset;
}
entry[i] = & ExtEntryTable[j];
break;
}
}
}
/* See if this function has already been dynamically added */
{
GLuint i;
for (i = 0; i < NumExtEntryPoints; i++) {
if (strcmp(ExtEntryTable[i].Name, funcName) == 0) {
/* function already registered */
if (ExtEntryTable[i].Offset == offset) {
return GL_TRUE; /* offsets match */
}
else if (ExtEntryTable[i].Offset == (GLuint) ~0
&& offset < DISPATCH_TABLE_SIZE) {
/* need to patch-up the dispatch code */
if (offset != (GLuint) ~0) {
fill_in_entrypoint_offset(ExtEntryTable[i].Address, offset);
ExtEntryTable[i].Offset = offset;
}
return GL_TRUE;
}
else {
return GL_FALSE; /* bad offset! */
}
}
if (offset == ~0) {
offset = next_dynamic_offset;
next_dynamic_offset++;
}
for ( i = 0 ; function_names[i] != NULL ; i++ ) {
if (! is_static[i] ) {
if (entry[i] == NULL) {
entry[i] = add_function_name( function_names[i] );
if (entry[i] == NULL) {
/* FIXME: Possible memory leak here.
*/
return -1;
}
}
entry[i]->parameter_signature = str_dup(real_sig);
fill_in_entrypoint_offset(entry[i]->dispatch_stub, offset);
entry[i]->dispatch_offset = offset;
}
}
/* This is a new function, try to add it. */
if (NumExtEntryPoints >= MAX_EXTENSION_FUNCS ||
offset >= DISPATCH_TABLE_SIZE) {
/* No space left */
return GL_FALSE;
}
else {
_glapi_proc entrypoint = generate_entrypoint(offset);
if (!entrypoint)
return GL_FALSE; /* couldn't generate assembly */
/* OK! */
ExtEntryTable[NumExtEntryPoints].Name = str_dup(funcName);
ExtEntryTable[NumExtEntryPoints].Offset = offset;
ExtEntryTable[NumExtEntryPoints].Address = entrypoint;
NumExtEntryPoints++;
return GL_TRUE; /* success */
}
/* should never get here, silence compiler warnings */
return GL_FALSE;
return offset;
}
@@ -896,8 +1047,8 @@ _glapi_get_proc_offset(const char *funcName)
/* search extension functions first */
GLuint i;
for (i = 0; i < NumExtEntryPoints; i++) {
if (strcmp(ExtEntryTable[i].Name, funcName) == 0) {
return ExtEntryTable[i].Offset;
if (strcmp(ExtEntryTable[i].name, funcName) == 0) {
return ExtEntryTable[i].dispatch_offset;
}
}
@@ -915,6 +1066,7 @@ _glapi_get_proc_offset(const char *funcName)
PUBLIC _glapi_proc
_glapi_get_proc_address(const char *funcName)
{
struct _glapi_function * entry;
GLuint i;
#ifdef MANGLE
@@ -927,8 +1079,8 @@ _glapi_get_proc_address(const char *funcName)
/* search extension functions first */
for (i = 0; i < NumExtEntryPoints; i++) {
if (strcmp(ExtEntryTable[i].Name, funcName) == 0) {
return ExtEntryTable[i].Address;
if (strcmp(ExtEntryTable[i].name, funcName) == 0) {
return ExtEntryTable[i].dispatch_stub;
}
}
@@ -939,28 +1091,8 @@ _glapi_get_proc_address(const char *funcName)
return func;
}
/* generate new entrypoint - use a temporary dispatch offset of
* ~0 (i.e. -1). Later, when the driver calls _glapi_add_entrypoint()
* 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.
*/
if (NumExtEntryPoints < MAX_EXTENSION_FUNCS) {
_glapi_proc entrypoint = generate_entrypoint(~0);
if (!entrypoint)
return GL_FALSE;
ExtEntryTable[NumExtEntryPoints].Name = str_dup(funcName);
ExtEntryTable[NumExtEntryPoints].Offset = ~0;
ExtEntryTable[NumExtEntryPoints].Address = entrypoint;
NumExtEntryPoints++;
return entrypoint;
}
else {
/* no space for new functions! */
return NULL;
}
entry = add_function_name(funcName);
return (entry == NULL) ? NULL : entry->dispatch_stub;
}
@@ -983,8 +1115,8 @@ _glapi_get_proc_name(GLuint offset)
/* search added extension functions */
for (i = 0; i < NumExtEntryPoints; i++) {
if (ExtEntryTable[i].Offset == offset) {
return ExtEntryTable[i].Name;
if (ExtEntryTable[i].dispatch_offset == offset) {
return ExtEntryTable[i].name;
}
}
return NULL;

View File

@@ -46,13 +46,10 @@
#include "GL/gl.h"
struct _glapi_table;
#include "glapitable.h"
typedef void (*_glapi_warning_func)(void *ctx, const char *str, ...);
typedef void (*_glapi_proc)(void); /* generic function pointer */
#if defined (GLX_USE_TLS)
@@ -140,9 +137,9 @@ extern void
_glapi_check_table(const struct _glapi_table *table);
extern GLboolean
_glapi_add_entrypoint(const char *funcName, GLuint offset);
extern int
_glapi_add_dispatch( const char * const * function_names,
const char * parameter_signature );
extern GLint
_glapi_get_proc_offset(const char *funcName);

View File

@@ -845,5 +845,6 @@
#define _gloffset_StencilFuncSeparate 813
#define _gloffset_StencilOpSeparate 814
#define _gloffset_StencilMaskSeparate 815
#define _gloffset_FIRST_DYNAMIC 816
#endif /* !defined( _GLAPI_OFFSETS_H_ ) */

View File

@@ -33,6 +33,8 @@
#define GLAPIENTRYP
#endif
typedef void (*_glapi_proc)(void); /* generic function pointer */
struct _glapi_table
{
void (GLAPIENTRYP NewList)(GLuint list, GLenum mode); /* 0 */

View File

@@ -2598,7 +2598,10 @@ struct gl_tnl_module
* On restore, only need to swap these functions back in.
*/
/*@{*/
void *Swapped[NUM_VERTEX_FORMAT_ENTRIES][2];
struct {
_glapi_proc * location;
_glapi_proc function;
} Swapped[NUM_VERTEX_FORMAT_ENTRIES];
GLuint SwapCount;
/*@}*/
};

View File

@@ -49,15 +49,14 @@
{ \
GET_CURRENT_CONTEXT(ctx); \
struct gl_tnl_module *tnl = &(ctx->TnlModule); \
typedef void (*func_ptr_t)(void); \
\
ASSERT( tnl->Current ); \
ASSERT( tnl->SwapCount < NUM_VERTEX_FORMAT_ENTRIES ); \
\
/* Save the swapped function's dispatch entry so it can be */ \
/* restored later. */ \
tnl->Swapped[tnl->SwapCount][0] = (void *)&(GET_ ## FUNC (ctx->Exec)); \
*(func_ptr_t *)(tnl->Swapped[tnl->SwapCount]+1) = (func_ptr_t)TAG(FUNC); \
tnl->Swapped[tnl->SwapCount].location = (_glapi_proc *) & (GET_ ## FUNC (ctx->Exec)); \
tnl->Swapped[tnl->SwapCount].function = (_glapi_proc)TAG(FUNC); \
tnl->SwapCount++; \
\
if ( 0 ) \
@@ -177,7 +176,7 @@ void _mesa_restore_exec_vtxfmt( GLcontext *ctx )
/* Restore the neutral tnl module wrapper.
*/
for ( i = 0 ; i < tnl->SwapCount ; i++ ) {
*(void **)tnl->Swapped[i][0] = tnl->Swapped[i][1];
*(tnl->Swapped[i].location) = tnl->Swapped[i].function;
}
tnl->SwapCount = 0;