changed allocation/initialization of API dispatch tables

This commit is contained in:
Brian Paul 2000-05-24 15:04:45 +00:00
parent f658ab0e2e
commit 5fb84d263b
6 changed files with 42 additions and 35 deletions

View File

@ -1,4 +1,4 @@
/* $Id: context.c,v 1.68 2000/05/23 23:23:00 brianp Exp $ */
/* $Id: context.c,v 1.69 2000/05/24 15:04:45 brianp Exp $ */
/*
* Mesa 3-D graphics library
@ -1341,6 +1341,8 @@ _mesa_initialize_context( GLcontext *ctx,
void *driver_ctx,
GLboolean direct )
{
GLuint dispatchSize;
(void) direct; /* not used */
/* misc one-time initializations */
@ -1421,9 +1423,17 @@ _mesa_initialize_context( GLcontext *ctx,
_glapi_add_entrypoint("glCompressedTexSubImage1DARB", 559);
_glapi_add_entrypoint("glGetCompressedTexImageARB", 560);
/* Find the larger of Mesa's dispatch table and libGL's dispatch table.
* In practice, this'll be the same for stand-alone Mesa. But for DRI
* Mesa we do this to accomodate different versions of libGL and various
* DRI drivers.
*/
dispatchSize = MAX2(_glapi_get_dispatch_table_size(),
sizeof(struct _glapi_table) / sizeof(void *));
/* setup API dispatch tables */
ctx->Exec = (struct _glapi_table *) CALLOC(_glapi_get_dispatch_table_size() * sizeof(void *));
ctx->Save = (struct _glapi_table *) CALLOC(_glapi_get_dispatch_table_size() * sizeof(void *));
ctx->Exec = (struct _glapi_table *) CALLOC(dispatchSize * sizeof(void*));
ctx->Save = (struct _glapi_table *) CALLOC(dispatchSize * sizeof(void*));
if (!ctx->Exec || !ctx->Save) {
free_shared_state(ctx, ctx->Shared);
FREE(ctx->VB);
@ -1432,8 +1442,8 @@ _mesa_initialize_context( GLcontext *ctx,
FREE(ctx->Exec);
FREE(ctx);
}
_mesa_init_exec_table( ctx->Exec );
_mesa_init_dlist_table( ctx->Save );
_mesa_init_exec_table(ctx->Exec, dispatchSize);
_mesa_init_dlist_table(ctx->Save, dispatchSize);
ctx->CurrentDispatch = ctx->Exec;
return GL_TRUE;

View File

@ -1,4 +1,4 @@
/* $Id: context.h,v 1.17 2000/05/04 13:53:55 brianp Exp $ */
/* $Id: context.h,v 1.18 2000/05/24 15:04:45 brianp Exp $ */
/*
* Mesa 3-D graphics library
@ -253,11 +253,4 @@ _mesa_Flush( void );
extern void
_mesa_init_no_op_table(struct _glapi_table *exec);
extern void
_mesa_init_exec_table(struct _glapi_table *exec);
#endif

View File

@ -1,4 +1,4 @@
/* $Id: dlist.c,v 1.40 2000/05/23 20:10:49 brianp Exp $ */
/* $Id: dlist.c,v 1.41 2000/05/24 15:04:45 brianp Exp $ */
/*
* Mesa 3-D graphics library
@ -4723,13 +4723,13 @@ _mesa_ListBase( GLuint base )
/*
* Assign all the pointers in 'table' to point to Mesa's display list
* Assign all the pointers in <table> to point to Mesa's display list
* building functions.
*/
void
_mesa_init_dlist_table( struct _glapi_table *table )
_mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize )
{
_mesa_init_no_op_table(table);
_mesa_init_no_op_table(table, tableSize);
/* GL 1.0 */
table->Accum = save_Accum;

View File

@ -1,4 +1,4 @@
/* $Id: dlist.h,v 1.3 2000/04/05 14:40:04 brianp Exp $ */
/* $Id: dlist.h,v 1.4 2000/05/24 15:04:45 brianp Exp $ */
/*
* Mesa 3-D graphics library
@ -65,7 +65,7 @@ extern void _mesa_ListBase( GLuint base );
extern void _mesa_NewList( GLuint list, GLenum mode );
extern void _mesa_init_dlist_table( struct _glapi_table *table );
extern void _mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize );
extern void gl_compile_cassette( GLcontext *ctx );

View File

@ -1,4 +1,4 @@
/* $Id: state.c,v 1.13 2000/05/23 20:10:50 brianp Exp $ */
/* $Id: state.c,v 1.14 2000/05/24 15:04:45 brianp Exp $ */
/*
* Mesa 3-D graphics library
@ -99,20 +99,17 @@ generic_noop(void)
}
/*
* Set all pointers in the given dispatch table to point to a
* generic no-op function.
*/
void
_mesa_init_no_op_table(struct _glapi_table *table)
_mesa_init_no_op_table(struct _glapi_table *table, GLuint tableSize)
{
/* Check to be sure the dispatcher's table is at least as big as Mesa's. */
const GLuint size = sizeof(struct _glapi_table) / sizeof(void *);
assert(_glapi_get_dispatch_table_size() >= size);
{
const GLuint n = _glapi_get_dispatch_table_size();
GLuint i;
void **dispatch = (void **) table;
for (i = 0; i < n; i++) {
dispatch[i] = (void *) generic_noop;
}
GLuint i;
void **dispatch = (void **) table;
for (i = 0; i < tableSize; i++) {
dispatch[i] = (void *) generic_noop;
}
}
@ -122,10 +119,10 @@ _mesa_init_no_op_table(struct _glapi_table *table)
* immediate-mode commands.
*/
void
_mesa_init_exec_table(struct _glapi_table *exec)
_mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize)
{
/* first initialize all dispatch slots to no-op */
_mesa_init_no_op_table(exec);
_mesa_init_no_op_table(exec, tableSize);
/* load the dispatch slots we understand */
exec->Accum = _mesa_Accum;

View File

@ -1,4 +1,4 @@
/* $Id: state.h,v 1.1 2000/02/02 19:15:19 brianp Exp $ */
/* $Id: state.h,v 1.2 2000/05/24 15:04:45 brianp Exp $ */
/*
* Mesa 3-D graphics library
@ -31,6 +31,13 @@
#include "types.h"
extern void
_mesa_init_no_op_table(struct _glapi_table *exec, GLuint tableSize);
extern void
_mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize);
extern void gl_update_state( GLcontext *ctx );