OPCODE_ERROR, /* raise compiled-in error */
OPCODE_CONTINUE,
OPCODE_END_OF_LIST,
- OPCODE_DRV_0
+ OPCODE_EXT_0
} OpCode;
/* 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) {
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
}
-/* 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;
}
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) {
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) {
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 );
};
-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;
};
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 */