X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fdlist.c;h=76b33150346daa21ad6c3d6b9623ff63f03e2d98;hb=19dff5efc1e348d037b1b3cdfb9ac91020ecde4d;hp=cafe8072ee04253e8389f657748611feeb065377;hpb=cc7dd4fc1b3c765ca1ecd943d189bb156dae529d;p=mesa.git diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index cafe8072ee0..76b33150346 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -41,7 +41,6 @@ #endif #include "arrayobj.h" #include "clip.h" -#include "colormac.h" #include "colortab.h" #include "context.h" #include "convolve.h" @@ -86,7 +85,6 @@ #endif #include "math/m_matrix.h" -#include "math/m_xform.h" #include "glapi/dispatch.h" @@ -371,7 +369,7 @@ typedef enum * contiguous nodes in memory. * Each node is the union of a variety of data types. */ -union node +union gl_dlist_node { OpCode opcode; GLboolean b; @@ -388,6 +386,9 @@ union node }; +typedef union gl_dlist_node Node; + + /** * How many nodes to allocate at a time. * @@ -415,13 +416,13 @@ void mesa_print_display_list(GLuint list); * Make an empty display list. This is used by glGenLists() to * reserve display list IDs. */ -static struct mesa_display_list * -make_list(GLuint list, GLuint count) +static struct gl_display_list * +make_list(GLuint name, GLuint count) { - struct mesa_display_list *dlist = CALLOC_STRUCT(mesa_display_list); - dlist->id = list; - dlist->node = (Node *) _mesa_malloc(sizeof(Node) * count); - dlist->node[0].opcode = OPCODE_END_OF_LIST; + struct gl_display_list *dlist = CALLOC_STRUCT(gl_display_list); + dlist->Name = name; + dlist->Head = (Node *) _mesa_malloc(sizeof(Node) * count); + dlist->Head[0].opcode = OPCODE_END_OF_LIST; return dlist; } @@ -429,10 +430,10 @@ make_list(GLuint list, GLuint count) /** * Lookup function to just encapsulate casting. */ -static INLINE struct mesa_display_list * +static INLINE struct gl_display_list * lookup_list(GLcontext *ctx, GLuint list) { - return (struct mesa_display_list *) + return (struct gl_display_list *) _mesa_HashLookup(ctx->Shared->DisplayList, list); } @@ -443,12 +444,12 @@ lookup_list(GLcontext *ctx, GLuint list) * \param dlist - display list pointer */ void -_mesa_delete_list(GLcontext *ctx, struct mesa_display_list *dlist) +_mesa_delete_list(GLcontext *ctx, struct gl_display_list *dlist) { Node *n, *block; GLboolean done; - n = block = dlist->node; + n = block = dlist->Head; done = block ? GL_FALSE : GL_TRUE; while (!done) { @@ -597,7 +598,7 @@ _mesa_delete_list(GLcontext *ctx, struct mesa_display_list *dlist) static void destroy_list(GLcontext *ctx, GLuint list) { - struct mesa_display_list *dlist; + struct gl_display_list *dlist; if (list == 0) return; @@ -2005,7 +2006,7 @@ save_Lightfv(GLenum light, GLenum pname, const GLfloat *params) Node *n; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); n = ALLOC_INSTRUCTION(ctx, OPCODE_LIGHT, 6); - if (OPCODE_LIGHT) { + if (n) { GLint i, nParams; n[1].e = light; n[2].e = pname; @@ -2522,12 +2523,12 @@ save_MultMatrixd(const GLdouble * m) static void GLAPIENTRY -save_NewList(GLuint list, GLenum mode) +save_NewList(GLuint name, GLenum mode) { GET_CURRENT_CONTEXT(ctx); /* It's an error to call this function while building a display list */ _mesa_error(ctx, GL_INVALID_OPERATION, "glNewList"); - (void) list; + (void) name; (void) mode; } @@ -5732,7 +5733,7 @@ islist(GLcontext *ctx, GLuint list) static void execute_list(GLcontext *ctx, GLuint list) { - struct mesa_display_list *dlist; + struct gl_display_list *dlist; Node *n; GLboolean done; @@ -5753,7 +5754,7 @@ execute_list(GLcontext *ctx, GLuint list) if (ctx->Driver.BeginCallList) ctx->Driver.BeginCallList(ctx, dlist); - n = dlist->node; + n = dlist->Head; done = GL_FALSE; while (!done) { @@ -6724,7 +6725,7 @@ _mesa_GenLists(GLsizei range) * Begin a new display list. */ void GLAPIENTRY -_mesa_NewList(GLuint list, GLenum mode) +_mesa_NewList(GLuint name, GLenum mode) { GET_CURRENT_CONTEXT(ctx); GLint i; @@ -6733,10 +6734,10 @@ _mesa_NewList(GLuint list, GLenum mode) ASSERT_OUTSIDE_BEGIN_END(ctx); if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glNewList %u %s\n", list, + _mesa_debug(ctx, "glNewList %u %s\n", name, _mesa_lookup_enum_by_nr(mode)); - if (list == 0) { + if (name == 0) { _mesa_error(ctx, GL_INVALID_VALUE, "glNewList"); return; } @@ -6746,7 +6747,7 @@ _mesa_NewList(GLuint list, GLenum mode) return; } - if (ctx->ListState.CurrentListPtr) { + if (ctx->ListState.CurrentList) { /* already compiling a display list */ _mesa_error(ctx, GL_INVALID_OPERATION, "glNewList"); return; @@ -6756,10 +6757,8 @@ _mesa_NewList(GLuint list, GLenum mode) ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE); /* Allocate new display list */ - ctx->ListState.CurrentListNum = list; - ctx->ListState.CurrentList = make_list(list, BLOCK_SIZE); - ctx->ListState.CurrentBlock = ctx->ListState.CurrentList->node; - ctx->ListState.CurrentListPtr = ctx->ListState.CurrentBlock; + ctx->ListState.CurrentList = make_list(name, BLOCK_SIZE); + ctx->ListState.CurrentBlock = ctx->ListState.CurrentList->Head; ctx->ListState.CurrentPos = 0; /* Reset acumulated list state: @@ -6771,7 +6770,7 @@ _mesa_NewList(GLuint list, GLenum mode) ctx->ListState.ActiveMaterialSize[i] = 0; ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN; - ctx->Driver.NewList(ctx, list, mode); + ctx->Driver.NewList(ctx, name, mode); ctx->CurrentDispatch = ctx->Save; _glapi_set_dispatch(ctx->CurrentDispatch); @@ -6792,28 +6791,31 @@ _mesa_EndList(void) _mesa_debug(ctx, "glEndList\n"); /* Check that a list is under construction */ - if (!ctx->ListState.CurrentListPtr) { + if (!ctx->ListState.CurrentList) { _mesa_error(ctx, GL_INVALID_OPERATION, "glEndList"); return; } + + /* Call before emitting END_OF_LIST, in case the driver wants to + * emit opcodes itself. + */ + ctx->Driver.EndList(ctx); (void) ALLOC_INSTRUCTION(ctx, OPCODE_END_OF_LIST, 0); /* Destroy old list, if any */ - destroy_list(ctx, ctx->ListState.CurrentListNum); - /* Install the list */ - _mesa_HashInsert(ctx->Shared->DisplayList, ctx->ListState.CurrentListNum, + destroy_list(ctx, ctx->ListState.CurrentList->Name); + + /* Install the new list */ + _mesa_HashInsert(ctx->Shared->DisplayList, + ctx->ListState.CurrentList->Name, ctx->ListState.CurrentList); if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST) - mesa_print_display_list(ctx->ListState.CurrentListNum); - - ctx->Driver.EndList(ctx); + mesa_print_display_list(ctx->ListState.CurrentList->Name); ctx->ListState.CurrentList = NULL; - ctx->ListState.CurrentListNum = 0; - ctx->ListState.CurrentListPtr = NULL; ctx->ExecuteFlag = GL_TRUE; ctx->CompileFlag = GL_FALSE; @@ -8207,7 +8209,7 @@ enum_string(GLenum k) static void GLAPIENTRY print_list(GLcontext *ctx, GLuint list) { - struct mesa_display_list *dlist; + struct gl_display_list *dlist; Node *n; GLboolean done; @@ -8220,7 +8222,7 @@ print_list(GLcontext *ctx, GLuint list) if (!dlist) return; - n = dlist->node; + n = dlist->Head; _mesa_printf("START-LIST %u, address %p\n", list, (void *) n); @@ -8582,9 +8584,7 @@ _mesa_init_display_list(GLcontext *ctx) ctx->ListState.CallDepth = 0; ctx->ExecuteFlag = GL_TRUE; ctx->CompileFlag = GL_FALSE; - ctx->ListState.CurrentListPtr = NULL; ctx->ListState.CurrentBlock = NULL; - ctx->ListState.CurrentListNum = 0; ctx->ListState.CurrentPos = 0; /* Display List group */