}
+/**
+ * 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).
*
const struct dd_function_table *driverFunctions,
void *driverContext )
{
- GLuint dispatchSize;
-
ASSERT(driverContext);
assert(driverFunctions->NewTextureObject);
/* 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;
-/**********************************************************************/
-/** \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.
* \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
#endif /* FEATURE_ARB_shader_objects */
}
-/*@}*/
/**********************************************************************/
/*
* 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"),
#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 );