summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/dlist.c58
-rw-r--r--src/mesa/main/dlist.h8
-rw-r--r--src/mesa/main/mtypes.h18
3 files changed, 47 insertions, 37 deletions
diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index aada62d1f9..b9b96d0fb7 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -334,7 +334,7 @@ typedef enum {
OPCODE_ERROR, /* raise compiled-in error */
OPCODE_CONTINUE,
OPCODE_END_OF_LIST,
- OPCODE_DRV_0
+ OPCODE_EXT_0
} OpCode;
@@ -421,10 +421,10 @@ void _mesa_destroy_list( GLcontext *ctx, GLuint list )
/* check for extension opcodes first */
- GLint i = (GLint) n[0].opcode - (GLint) OPCODE_DRV_0;
- if (i >= 0 && i < (GLint) ctx->listext.nr_opcodes) {
- ctx->listext.opcode[i].destroy(ctx, &n[1]);
- n += ctx->listext.opcode[i].size;
+ GLint i = (GLint) n[0].opcode - (GLint) OPCODE_EXT_0;
+ if (i >= 0 && i < (GLint) ctx->ListExt.NumOpcodes) {
+ ctx->ListExt.Opcode[i].Destroy(ctx, &n[1]);
+ n += ctx->ListExt.Opcode[i].Size;
}
else {
switch (n[0].opcode) {
@@ -803,7 +803,7 @@ _mesa_alloc_instruction( GLcontext *ctx, int opcode, GLint sz )
GLuint count = 1 + (sz + sizeof(Node) - 1) / sizeof(Node);
#ifdef DEBUG
- if (opcode < (int) OPCODE_DRV_0) {
+ if (opcode < (int) OPCODE_EXT_0) {
assert( count == InstSize[opcode] );
}
#endif
@@ -831,22 +831,30 @@ _mesa_alloc_instruction( GLcontext *ctx, int opcode, GLint sz )
}
-/* Allow modules and drivers to get their own opcodes.
+/**
+ * This function allows modules and drivers to get their own opcodes
+ * for extending display list functionality.
+ * \param ctx the rendering context
+ * \param size number of bytes for storing the new display list command
+ * \param execute function to execute the new display list command
+ * \param destroy function to destroy the new display list command
+ * \param print function to print the new display list command
+ * \return the new opcode number or -1 if error
*/
-int
+GLint
_mesa_alloc_opcode( GLcontext *ctx,
- GLuint sz,
+ GLuint size,
void (*execute)( GLcontext *, void * ),
void (*destroy)( GLcontext *, void * ),
void (*print)( GLcontext *, void * ) )
{
- if (ctx->listext.nr_opcodes < GL_MAX_EXT_OPCODES) {
- GLuint i = ctx->listext.nr_opcodes++;
- ctx->listext.opcode[i].size = 1 + (sz + sizeof(Node) - 1)/sizeof(Node);
- ctx->listext.opcode[i].execute = execute;
- ctx->listext.opcode[i].destroy = destroy;
- ctx->listext.opcode[i].print = print;
- return i + OPCODE_DRV_0;
+ if (ctx->ListExt.NumOpcodes < MAX_DLIST_EXT_OPCODES) {
+ const GLuint i = ctx->ListExt.NumOpcodes++;
+ ctx->ListExt.Opcode[i].Size = 1 + (size + sizeof(Node) - 1)/sizeof(Node);
+ ctx->ListExt.Opcode[i].Execute = execute;
+ ctx->ListExt.Opcode[i].Destroy = destroy;
+ ctx->ListExt.Opcode[i].Print = print;
+ return i + OPCODE_EXT_0;
}
return -1;
}
@@ -5252,11 +5260,12 @@ execute_list( GLcontext *ctx, GLuint list )
done = GL_FALSE;
while (!done) {
OpCode opcode = n[0].opcode;
- int i = (int)n[0].opcode - (int)OPCODE_DRV_0;
+ int i = (int)n[0].opcode - (int)OPCODE_EXT_0;
- if (i >= 0 && i < (GLint) ctx->listext.nr_opcodes) {
- ctx->listext.opcode[i].execute(ctx, &n[1]);
- n += ctx->listext.opcode[i].size;
+ if (i >= 0 && i < (GLint) ctx->ListExt.NumOpcodes) {
+ /* this is a driver-extended opcode */
+ ctx->ListExt.Opcode[i].Execute(ctx, &n[1]);
+ n += ctx->ListExt.Opcode[i].Size;
}
else {
switch (opcode) {
@@ -7528,11 +7537,12 @@ static void GLAPIENTRY print_list( GLcontext *ctx, GLuint list )
done = n ? GL_FALSE : GL_TRUE;
while (!done) {
OpCode opcode = n[0].opcode;
- GLint i = (GLint) n[0].opcode - (GLint) OPCODE_DRV_0;
+ GLint i = (GLint) n[0].opcode - (GLint) OPCODE_EXT_0;
- if (i >= 0 && i < (GLint) ctx->listext.nr_opcodes) {
- ctx->listext.opcode[i].print(ctx, &n[1]);
- n += ctx->listext.opcode[i].size;
+ if (i >= 0 && i < (GLint) ctx->ListExt.NumOpcodes) {
+ /* this is a driver-extended opcode */
+ ctx->ListExt.Opcode[i].Print(ctx, &n[1]);
+ n += ctx->ListExt.Opcode[i].Size;
}
else {
switch (opcode) {
diff --git a/src/mesa/main/dlist.h b/src/mesa/main/dlist.h
index a6b9c363a1..6245713f95 100644
--- a/src/mesa/main/dlist.h
+++ b/src/mesa/main/dlist.h
@@ -68,10 +68,10 @@ extern void _mesa_compile_error( GLcontext *ctx, GLenum error, const char *s );
extern void *_mesa_alloc_instruction( GLcontext *ctx, int opcode, GLint sz );
-extern int _mesa_alloc_opcode( GLcontext *ctx, GLuint sz,
- void (*execute)( GLcontext *, void * ),
- void (*destroy)( GLcontext *, void * ),
- void (*print)( GLcontext *, void * ) );
+extern GLint _mesa_alloc_opcode( GLcontext *ctx, GLuint sz,
+ void (*execute)( GLcontext *, void * ),
+ void (*destroy)( GLcontext *, void * ),
+ void (*print)( GLcontext *, void * ) );
extern void GLAPIENTRY _mesa_save_EvalMesh2(GLenum mode, GLint i1, GLint i2,
GLint j1, GLint j2 );
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 1c03a05606..e090a3d683 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -767,18 +767,18 @@ struct gl_list_attrib {
};
-struct gl_list_opcode {
- GLuint size;
- void (*execute)( GLcontext *ctx, void *data );
- void (*destroy)( GLcontext *ctx, void *data );
- void (*print)( GLcontext *ctx, void *data );
+struct gl_list_instruction {
+ GLuint Size;
+ void (*Execute)( GLcontext *ctx, void *data );
+ void (*Destroy)( GLcontext *ctx, void *data );
+ void (*Print)( GLcontext *ctx, void *data );
};
-#define GL_MAX_EXT_OPCODES 16
+#define MAX_DLIST_EXT_OPCODES 16
struct gl_list_extensions {
- struct gl_list_opcode opcode[GL_MAX_EXT_OPCODES];
- GLuint nr_opcodes;
+ struct gl_list_instruction Opcode[MAX_DLIST_EXT_OPCODES];
+ GLuint NumOpcodes;
};
@@ -2301,7 +2301,7 @@ struct __GLcontextRec {
struct gl_shine_tab *_ShineTabList; /**< MRU list of inactive shine tables */
/**@}*/
- struct gl_list_extensions listext; /**< driver dlist extensions */
+ struct gl_list_extensions ListExt; /**< driver dlist extensions */
GLboolean OcclusionResult; /**< for GL_HP_occlusion_test */