summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2010-04-22 12:40:47 -0400
committerKristian Høgsberg <krh@bitplanet.net>2010-05-03 11:49:30 -0400
commit2180ba68f12833aed0ee7974d981733dc12cbaed (patch)
tree7adcf811f32d6d73cf58081f2308df349a2bab50
parent2a2f8580b776bc317968170a83deadb1ee900bec (diff)
mesa: Move struct _glapi_table allocation out of context.c
We now allocate the table from api_exec.c and dlist.c where we fill out the table. This way, context.c doesn't need to know the actual contents of struct _glapi_table.
-rw-r--r--src/mesa/es/main/es_generator.py12
-rw-r--r--src/mesa/main/api_exec.c12
-rw-r--r--src/mesa/main/api_exec.h6
-rw-r--r--src/mesa/main/context.c26
-rw-r--r--src/mesa/main/dlist.c12
-rw-r--r--src/mesa/main/dlist.h2
6 files changed, 48 insertions, 22 deletions
diff --git a/src/mesa/es/main/es_generator.py b/src/mesa/es/main/es_generator.py
index f736792dec..dbb516a4c1 100644
--- a/src/mesa/es/main/es_generator.py
+++ b/src/mesa/es/main/es_generator.py
@@ -667,9 +667,15 @@ for funcName in keys:
# end for each function
-print "void"
-print "_mesa_init_exec_table(struct _glapi_table *exec)"
+print "struct _glapi_table *"
+print "_mesa_create_exec_table(void)"
print "{"
+print " struct _glapi_table *exec;"
+print " exec = _mesa_alloc_dispatch_table(sizeof *exec);"
+print " if (exec == NULL)"
+print " return NULL;"
+print ""
+
for func in keys:
prefix = "_es_" if func not in allSpecials else "_check_"
for spec in apiutil.Categories(func):
@@ -682,4 +688,6 @@ for func in keys:
suffix = ext[0].split("_")[0]
entry += suffix
print " SET_%s(exec, %s%s);" % (entry, prefix, entry)
+print ""
+print " return exec;"
print "}"
diff --git a/src/mesa/main/api_exec.c b/src/mesa/main/api_exec.c
index fa8d409caa..7474de5d68 100644
--- a/src/mesa/main/api_exec.c
+++ b/src/mesa/main/api_exec.c
@@ -118,9 +118,15 @@
* \param ctx GL context to which \c exec belongs.
* \param exec dispatch table.
*/
-void
-_mesa_init_exec_table(struct _glapi_table *exec)
+struct _glapi_table *
+_mesa_create_exec_table(void)
{
+ struct _glapi_table *exec;
+
+ exec = _mesa_alloc_dispatch_table(sizeof *exec);
+ if (exec == NULL)
+ return NULL;
+
#if _HAVE_FULL_GL
_mesa_loopback_init_api_table( exec );
#endif
@@ -764,4 +770,6 @@ _mesa_init_exec_table(struct _glapi_table *exec)
SET_ObjectUnpurgeableAPPLE(exec, _mesa_ObjectUnpurgeableAPPLE);
SET_GetObjectParameterivAPPLE(exec, _mesa_GetObjectParameterivAPPLE);
#endif
+
+ return exec;
}
diff --git a/src/mesa/main/api_exec.h b/src/mesa/main/api_exec.h
index 4bd715053a..dd8d500865 100644
--- a/src/mesa/main/api_exec.h
+++ b/src/mesa/main/api_exec.h
@@ -29,9 +29,11 @@
struct _glapi_table;
+extern struct _glapi_table *
+_mesa_alloc_dispatch_table(int size);
-extern void
-_mesa_init_exec_table(struct _glapi_table *exec);
+extern struct _glapi_table *
+_mesa_create_exec_table(void);
#endif
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 314594911d..36b7451641 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -128,8 +128,6 @@
#include "version.h"
#include "viewport.h"
#include "vtxfmt.h"
-#include "glapi/glthread.h"
-#include "glapi/glapitable.h"
#include "shader/program.h"
#include "shader/prog_print.h"
#include "shader/shader_api.h"
@@ -739,8 +737,8 @@ generic_nop(void)
/**
* Allocate and initialize a new dispatch table.
*/
-static struct _glapi_table *
-alloc_dispatch_table(void)
+struct _glapi_table *
+_mesa_alloc_dispatch_table(int size)
{
/* 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
@@ -748,7 +746,7 @@ alloc_dispatch_table(void)
* DRI drivers.
*/
GLint numEntries = MAX2(_glapi_get_dispatch_table_size(),
- sizeof(struct _glapi_table) / sizeof(_glapi_proc));
+ size / sizeof(_glapi_proc));
struct _glapi_table *table =
(struct _glapi_table *) malloc(numEntries * sizeof(_glapi_proc));
if (table) {
@@ -843,22 +841,24 @@ _mesa_initialize_context_for_api(GLcontext *ctx,
return GL_FALSE;
}
+#if FEATURE_dispatch
/* setup the API dispatch tables */
- ctx->Exec = alloc_dispatch_table();
- ctx->Save = alloc_dispatch_table();
- if (!ctx->Exec || !ctx->Save) {
+ ctx->Exec = _mesa_create_exec_table();
+ if (!ctx->Exec) {
_mesa_release_shared_state(ctx, ctx->Shared);
- if (ctx->Exec)
- free(ctx->Exec);
return GL_FALSE;
}
-#if FEATURE_dispatch
- _mesa_init_exec_table(ctx->Exec);
#endif
ctx->CurrentDispatch = ctx->Exec;
#if FEATURE_dlist
- _mesa_init_save_table(ctx->Save);
+ ctx->Save = _mesa_create_save_table();
+ if (!ctx->Save) {
+ _mesa_release_shared_state(ctx, ctx->Shared);
+ free(ctx->Exec);
+ return GL_FALSE;
+ }
+
_mesa_install_save_vtxfmt( ctx, &ctx->ListState.ListVtxfmt );
#endif
diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index 43aadb1de5..1bec21a917 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -8707,9 +8707,15 @@ exec_MultiModeDrawElementsIBM(const GLenum * mode,
* initialized from _mesa_init_api_defaults and from the active vtxfmt
* struct.
*/
-void
-_mesa_init_save_table(struct _glapi_table *table)
+struct _glapi_table *
+_mesa_create_save_table(void)
{
+ struct _glapi_table *table;
+
+ table = _mesa_alloc_dispatch_table(sizeof *table);
+ if (table == NULL)
+ return NULL;
+
_mesa_loopback_init_api_table(table);
/* GL 1.0 */
@@ -9303,6 +9309,8 @@ _mesa_init_save_table(struct _glapi_table *table)
(void) save_ClearBufferfv;
(void) save_ClearBufferfi;
#endif
+
+ return table;
}
diff --git a/src/mesa/main/dlist.h b/src/mesa/main/dlist.h
index f37a93a7f4..f8255facc5 100644
--- a/src/mesa/main/dlist.h
+++ b/src/mesa/main/dlist.h
@@ -72,7 +72,7 @@ extern void _mesa_delete_list(GLcontext *ctx, struct gl_display_list *dlist);
extern void _mesa_save_vtxfmt_init( GLvertexformat *vfmt );
-extern void _mesa_init_save_table( struct _glapi_table *table );
+extern struct _glapi_table *_mesa_create_save_table(void);
extern void _mesa_install_dlist_vtxfmt(struct _glapi_table *disp,
const GLvertexformat *vfmt);