diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/main/context.c | 64 | ||||
-rw-r--r-- | src/mesa/main/dlist.c | 4 | ||||
-rw-r--r-- | src/mesa/main/dlist.h | 3 | ||||
-rw-r--r-- | src/mesa/main/state.c | 43 | ||||
-rw-r--r-- | src/mesa/main/state.h | 9 |
5 files changed, 51 insertions, 72 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index f90751fd092..924359a389b 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1391,6 +1391,45 @@ add_newer_entrypoints(void) /** + * This is the default function we plug into all dispatch table slots + * This helps prevents a segfault when someone calls a GL function without + * first checking if the extension's supported. + */ +static int +generic_nop(void) +{ + _mesa_problem(NULL, "User called no-op dispatch function (an unsupported extension function?)"); + return 0; +} + + +/** + * Allocate and initialize a new dispatch table. + */ +static struct _glapi_table * +alloc_dispatch_table(void) +{ + /* 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. + */ + GLint numEntries = MAX2(_glapi_get_dispatch_table_size(), + sizeof(struct _glapi_table) / sizeof(_glapi_proc)); + struct _glapi_table *table = + (struct _glapi_table *) _mesa_malloc(numEntries * sizeof(_glapi_proc)); + if (table) { + _glapi_proc *entry = (_glapi_proc *) table; + GLuint i; + for (i = 0; i < numEntries; i++) { + entry[i] = (_glapi_proc) generic_nop; + } + } + return table; +} + + +/** * Initialize a GLcontext struct (rendering context). * * This includes allocating all the other structs and arrays which hang off of @@ -1423,8 +1462,6 @@ _mesa_initialize_context( GLcontext *ctx, const struct dd_function_table *driverFunctions, void *driverContext ) { - GLuint dispatchSize; - ASSERT(driverContext); assert(driverFunctions->NewTextureObject); @@ -1473,30 +1510,19 @@ _mesa_initialize_context( GLcontext *ctx, /* libGL ABI coordination */ add_newer_entrypoints(); - /* 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(dispatchSize * sizeof(void*)); - ctx->Save = (struct _glapi_table *) CALLOC(dispatchSize * sizeof(void*)); + /* setup the API dispatch tables */ + ctx->Exec = alloc_dispatch_table(); + ctx->Save = alloc_dispatch_table(); if (!ctx->Exec || !ctx->Save) { free_shared_state(ctx, ctx->Shared); if (ctx->Exec) - FREE( ctx->Exec ); + _mesa_free(ctx->Exec); } - _mesa_init_exec_table(ctx->Exec, dispatchSize); + _mesa_init_exec_table(ctx->Exec); ctx->CurrentDispatch = ctx->Exec; - #if _HAVE_FULL_GL - _mesa_init_dlist_table(ctx->Save, dispatchSize); + _mesa_init_dlist_table(ctx->Save); _mesa_install_save_vtxfmt( ctx, &ctx->ListState.ListVtxfmt ); - - /* Neutral tnl module stuff */ _mesa_init_exec_vtxfmt( ctx ); ctx->TnlModule.Current = NULL; diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index 1f36411a94a..9da97d8c75c 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -7154,10 +7154,8 @@ static void GLAPIENTRY exec_MultiModeDrawElementsIBM(const GLenum *mode, * struct. */ void -_mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize ) +_mesa_init_dlist_table( struct _glapi_table *table ) { - _mesa_init_no_op_table(table, tableSize); - _mesa_loopback_init_api_table( table ); /* GL 1.0 */ diff --git a/src/mesa/main/dlist.h b/src/mesa/main/dlist.h index 6245713f952..1a5b391e760 100644 --- a/src/mesa/main/dlist.h +++ b/src/mesa/main/dlist.h @@ -58,8 +58,7 @@ extern void GLAPIENTRY _mesa_ListBase( GLuint base ); extern void GLAPIENTRY _mesa_NewList( GLuint list, GLenum mode ); -extern void _mesa_init_dlist_table( struct _glapi_table *table, - GLuint tableSize ); +extern void _mesa_init_dlist_table( struct _glapi_table *table ); extern void _mesa_save_error( GLcontext *ctx, GLenum error, const char *s ); diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 517cf6819c7..babc1868e77 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -91,43 +91,6 @@ -/**********************************************************************/ -/** \name Dispatch table setup */ -/*@{*/ - -/** - * Generic no-op dispatch function. - * - * Used in replacement of the functions which are not part of Mesa subset. - * - * Displays a message. - */ -static int -generic_noop(void) -{ - _mesa_problem(NULL, "User called no-op dispatch function (an unsupported extension function?)"); - return 0; -} - - -/** - * Set all pointers in the given dispatch table to point to a - * generic no-op function - generic_noop(). - * - * \param table dispatch table. - * \param tableSize dispatch table size. - */ -void -_mesa_init_no_op_table(struct _glapi_table *table, GLuint tableSize) -{ - GLuint i; - _glapi_proc *dispatch = (_glapi_proc *) table; - for (i = 0; i < tableSize; i++) { - dispatch[i] = (_glapi_proc) generic_noop; - } -} - - /** * Initialize a dispatch table with pointers to Mesa's immediate-mode * commands. @@ -139,11 +102,8 @@ _mesa_init_no_op_table(struct _glapi_table *table, GLuint tableSize) * \param tableSize dispatch table size. */ void -_mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize) +_mesa_init_exec_table(struct _glapi_table *exec) { - /* first initialize all dispatch slots to no-op */ - _mesa_init_no_op_table(exec, tableSize); - #if _HAVE_FULL_GL _mesa_loopback_init_api_table( exec ); #endif @@ -787,7 +747,6 @@ _mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize) #endif /* FEATURE_ARB_shader_objects */ } -/*@}*/ /**********************************************************************/ diff --git a/src/mesa/main/state.h b/src/mesa/main/state.h index fe577a85637..58cfcc41462 100644 --- a/src/mesa/main/state.h +++ b/src/mesa/main/state.h @@ -5,9 +5,9 @@ /* * Mesa 3-D graphics library - * Version: 3.5 + * Version: 6.3 * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -34,10 +34,7 @@ #include "mtypes.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); +_mesa_init_exec_table(struct _glapi_table *exec); extern void _mesa_update_state( GLcontext *ctx ); |