diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 5c790a28e48..1189e50810d 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1381,9 +1381,6 @@ _mesa_free_context_data(struct gl_context *ctx, bool destroy_debug_output) /* Shared context state (display lists, textures, etc) */ _mesa_reference_shared_state(ctx, &ctx->Shared, NULL); - /* needs to be after freeing shared state */ - _mesa_free_display_list_data(ctx); - if (destroy_debug_output) _mesa_destroy_debug_output(ctx); diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index aa63abba454..db504cd1346 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -71,40 +71,13 @@ #include "vbo/vbo.h" #include "vbo/vbo_util.h" +#include "vbo/vbo_save.h" #include "util/format_r11g11b10f.h" #include "util/u_memory.h" #define USE_BITMAP_ATLAS 1 - - -/** - * Other parts of Mesa (such as the VBO module) can plug into the display - * list system. This structure describes new display list instructions. - */ -struct gl_list_instruction -{ - GLuint Size; - void (*Execute)( struct gl_context *ctx, void *data ); - void (*Destroy)( struct gl_context *ctx, void *data ); - void (*Print)( struct gl_context *ctx, void *data, FILE *f ); -}; - - -#define MAX_DLIST_EXT_OPCODES 16 - -/** - * Used by device drivers to hook new commands into display lists. - */ -struct gl_list_extensions -{ - struct gl_list_instruction Opcode[MAX_DLIST_EXT_OPCODES]; - GLuint NumOpcodes; -}; - - - /** * Flush vertices. * @@ -656,6 +629,8 @@ typedef enum OPCODE_NAMED_PROGRAM_STRING, OPCODE_NAMED_PROGRAM_LOCAL_PARAMETER, + OPCODE_VERTEX_LIST, + /* The following three are meta instructions */ OPCODE_ERROR, /* raise compiled-in error */ OPCODE_CONTINUE, @@ -815,6 +790,53 @@ static GLuint InstSize[OPCODE_END_OF_LIST + 1]; void mesa_print_display_list(GLuint list); +/** + * Called by display list code when a display list is being deleted. + */ +static void +vbo_destroy_vertex_list(struct gl_context *ctx, struct vbo_save_vertex_list *node) +{ + for (gl_vertex_processing_mode vpm = VP_MODE_FF; vpm < VP_MODE_MAX; ++vpm) + _mesa_reference_vao(ctx, &node->VAO[vpm], NULL); + + if (--node->prim_store->refcount == 0) { + free(node->prim_store->prims); + free(node->prim_store); + } + + free(node->merged.prims); + + _mesa_reference_buffer_object(ctx, &node->merged.ib.obj, NULL); + free(node->current_data); + node->current_data = NULL; +} + +static void +vbo_print_vertex_list(struct gl_context *ctx, struct vbo_save_vertex_list *node, FILE *f) +{ + GLuint i; + struct gl_buffer_object *buffer = node->VAO[0]->BufferBinding[0].BufferObj; + const GLuint vertex_size = _vbo_save_get_stride(node)/sizeof(GLfloat); + (void) ctx; + + fprintf(f, "VBO-VERTEX-LIST, %u vertices, %d primitives, %d vertsize, " + "buffer %p\n", + node->vertex_count, node->prim_count, vertex_size, + buffer); + + for (i = 0; i < node->prim_count; i++) { + struct _mesa_prim *prim = &node->prims[i]; + fprintf(f, " prim %d: %s %d..%d %s %s\n", + i, + _mesa_lookup_prim_by_nr(prim->mode), + prim->start, + prim->start + prim->count, + (prim->begin) ? "BEGIN" : "(wrap)", + (prim->end) ? "END" : "(wrap)"); + } +} + + /** * Does the given display list only contain a single glBitmap call? */ @@ -1105,50 +1127,6 @@ _mesa_lookup_list(struct gl_context *ctx, GLuint list) } -/** Is the given opcode an extension code? */ -static inline GLboolean -is_ext_opcode(OpCode opcode) -{ - return (opcode >= OPCODE_EXT_0); -} - - -/** Destroy an extended opcode instruction */ -static GLint -ext_opcode_destroy(struct gl_context *ctx, Node *node) -{ - const GLint i = node[0].opcode - OPCODE_EXT_0; - GLint step; - ctx->ListExt->Opcode[i].Destroy(ctx, &node[1]); - step = ctx->ListExt->Opcode[i].Size; - return step; -} - - -/** Execute an extended opcode instruction */ -static GLint -ext_opcode_execute(struct gl_context *ctx, Node *node) -{ - const GLint i = node[0].opcode - OPCODE_EXT_0; - GLint step; - ctx->ListExt->Opcode[i].Execute(ctx, &node[1]); - step = ctx->ListExt->Opcode[i].Size; - return step; -} - - -/** Print an extended opcode instruction */ -static GLint -ext_opcode_print(struct gl_context *ctx, Node *node, FILE *f) -{ - const GLint i = node[0].opcode - OPCODE_EXT_0; - GLint step; - ctx->ListExt->Opcode[i].Print(ctx, &node[1], f); - step = ctx->ListExt->Opcode[i].Size; - return step; -} - - /** * Delete the named display list, but don't remove from hash table. * \param dlist - display list pointer @@ -1169,12 +1147,7 @@ _mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dlist) while (1) { const OpCode opcode = n[0].opcode; - /* check for extension opcodes first */ - if (is_ext_opcode(opcode)) { - n += ext_opcode_destroy(ctx, n); - } - else { - switch (opcode) { + switch (opcode) { /* for some commands, we need to free malloc'd memory */ case OPCODE_MAP1: free(get_pointer(&n[6])); @@ -1380,6 +1353,9 @@ _mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dlist) case OPCODE_NAMED_PROGRAM_STRING: free(get_pointer(&n[5])); break; + case OPCODE_VERTEX_LIST: + vbo_destroy_vertex_list(ctx, (struct vbo_save_vertex_list *) &n[1]); + break; case OPCODE_CONTINUE: n = (Node *) get_pointer(&n[1]); free(block); @@ -1393,11 +1369,10 @@ _mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dlist) default: /* just increment 'n' pointer, below */ ; - } - - assert(InstSize[opcode] > 0); - n += InstSize[opcode]; } + + assert(InstSize[opcode] > 0); + n += InstSize[opcode]; } } @@ -1659,33 +1634,11 @@ _mesa_dlist_alloc_aligned(struct gl_context *ctx, GLuint opcode, GLuint bytes) } -/** - * 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 - */ -GLint -_mesa_dlist_alloc_opcode(struct gl_context *ctx, - GLuint size, - void (*execute) (struct gl_context *, void *), - void (*destroy) (struct gl_context *, void *), - void (*print) (struct gl_context *, void *, FILE *)) +void * +_mesa_dlist_alloc_vertex_list(struct gl_context *ctx) { - 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; + return _mesa_dlist_alloc_aligned(ctx, OPCODE_VERTEX_LIST, + sizeof(struct vbo_save_vertex_list)); } @@ -11283,11 +11236,7 @@ execute_list(struct gl_context *ctx, GLuint list) while (1) { const OpCode opcode = n[0].opcode; - if (is_ext_opcode(opcode)) { - n += ext_opcode_execute(ctx, n); - } - else { - switch (opcode) { + switch (opcode) { case OPCODE_ERROR: _mesa_error(ctx, n[1].e, "%s", (const char *) get_pointer(&n[2])); break; @@ -13455,6 +13404,10 @@ execute_list(struct gl_context *ctx, GLuint list) n[5].f, n[6].f, n[7].f)); break; + case OPCODE_VERTEX_LIST: + vbo_save_playback_vertex_list(ctx, &n[1]); + break; + case OPCODE_CONTINUE: n = (Node *) get_pointer(&n[1]); continue; @@ -13473,12 +13426,11 @@ execute_list(struct gl_context *ctx, GLuint list) vbo_save_EndCallList(ctx); ctx->ListState.CallDepth--; return; - } - - /* increment n to point to next compiled command */ - assert(InstSize[opcode] > 0); - n += InstSize[opcode]; } + + /* increment n to point to next compiled command */ + assert(InstSize[opcode] > 0); + n += InstSize[opcode]; } } @@ -14632,11 +14584,7 @@ print_list(struct gl_context *ctx, GLuint list, const char *fname) while (1) { const OpCode opcode = n[0].opcode; - if (is_ext_opcode(opcode)) { - n += ext_opcode_print(ctx, n, f); - } - else { - switch (opcode) { + switch (opcode) { case OPCODE_ACCUM: fprintf(f, "Accum %s %g\n", enum_string(n[1].e), n[2].f); break; @@ -14880,6 +14828,9 @@ print_list(struct gl_context *ctx, GLuint list, const char *fname) case OPCODE_NOP: fprintf(f, "NOP\n"); break; + case OPCODE_VERTEX_LIST: + vbo_print_vertex_list(ctx, (struct vbo_save_vertex_list *) &n[1], f); + break; default: if (opcode < 0 || opcode > OPCODE_END_OF_LIST) { printf @@ -14897,12 +14848,11 @@ print_list(struct gl_context *ctx, GLuint list, const char *fname) if (fname) fclose(f); return; - } - - /* increment n to point to next compiled command */ - assert(InstSize[opcode] > 0); - n += InstSize[opcode]; } + + /* increment n to point to next compiled command */ + assert(InstSize[opcode] > 0); + n += InstSize[opcode]; } } @@ -14924,10 +14874,7 @@ _mesa_glthread_execute_list(struct gl_context *ctx, GLuint list) while (1) { const OpCode opcode = n[0].opcode; - if (is_ext_opcode(opcode)) { - n += ctx->ListExt->Opcode[n[0].opcode - OPCODE_EXT_0].Size; - } else { - switch (opcode) { + switch (opcode) { case OPCODE_CALL_LIST: /* Generated by glCallList(), don't add ListBase */ if (ctx->GLThread.ListCallDepth < MAX_LIST_NESTING) @@ -14979,12 +14926,11 @@ _mesa_glthread_execute_list(struct gl_context *ctx, GLuint list) default: /* ignore */ break; - } - - /* increment n to point to next compiled command */ - assert(InstSize[opcode] > 0); - n += InstSize[opcode]; } + + /* increment n to point to next compiled command */ + assert(InstSize[opcode] > 0); + n += InstSize[opcode]; } } @@ -15030,9 +14976,6 @@ _mesa_init_display_list(struct gl_context *ctx) tableInitialized = GL_TRUE; } - /* extension info */ - ctx->ListExt = CALLOC_STRUCT(gl_list_extensions); - /* Display list */ ctx->ListState.CallDepth = 0; ctx->ExecuteFlag = GL_TRUE; @@ -15044,6 +14987,7 @@ _mesa_init_display_list(struct gl_context *ctx) ctx->List.ListBase = 0; InstSize[OPCODE_NOP] = 1; + InstSize[OPCODE_VERTEX_LIST] = 1 + align(sizeof(struct vbo_save_vertex_list), sizeof(Node)) / sizeof(Node); #define NAME_AE(x) _ae_##x #define NAME_CALLLIST(x) save_##x @@ -15052,11 +14996,3 @@ _mesa_init_display_list(struct gl_context *ctx) #include "vbo/vbo_init_tmp.h" } - - -void -_mesa_free_display_list_data(struct gl_context *ctx) -{ - free(ctx->ListExt); - ctx->ListExt = NULL; -} diff --git a/src/mesa/main/dlist.h b/src/mesa/main/dlist.h index 8fa09a7aec2..52aa9a3da7a 100644 --- a/src/mesa/main/dlist.h +++ b/src/mesa/main/dlist.h @@ -111,11 +111,8 @@ _mesa_dlist_alloc(struct gl_context *ctx, GLuint opcode, GLuint sz); void * _mesa_dlist_alloc_aligned(struct gl_context *ctx, GLuint opcode, GLuint bytes); -GLint -_mesa_dlist_alloc_opcode(struct gl_context *ctx, GLuint sz, - void (*execute)(struct gl_context *, void *), - void (*destroy)(struct gl_context *, void *), - void (*print)(struct gl_context *, void *, FILE *)); +void * +_mesa_dlist_alloc_vertex_list(struct gl_context *ctx); void _mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dlist); @@ -130,9 +127,6 @@ _mesa_install_dlist_vtxfmt(struct _glapi_table *disp, void _mesa_init_display_list(struct gl_context * ctx); -void -_mesa_free_display_list_data(struct gl_context *ctx); - bool _mesa_get_list(struct gl_context *ctx, GLuint list, struct gl_display_list **dlist); diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 38f2acfcc9b..5478b9220c7 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -5461,8 +5461,6 @@ struct gl_context GLuint TextureStateTimestamp; /**< detect changes to shared state */ - struct gl_list_extensions *ListExt; /**< driver dlist extensions */ - /** \name For debugging/development only */ /*@{*/ GLboolean FirstTimeCurrent; diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h index e946fd5356a..9ac0d5e3c84 100644 --- a/src/mesa/vbo/vbo.h +++ b/src/mesa/vbo/vbo.h @@ -189,8 +189,6 @@ struct vbo_save_context { GLuint max_vert; GLboolean dangling_attr_ref; - GLuint opcode_vertex_list; - struct vbo_save_copied_vtx copied; fi_type *current[VBO_ATTRIB_MAX]; /* points into ctx->ListState */ diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c index b5d7d670f91..854daefe90a 100644 --- a/src/mesa/vbo/vbo_save_api.c +++ b/src/mesa/vbo/vbo_save_api.c @@ -529,7 +529,7 @@ compile_vertex_list(struct gl_context *ctx) * being compiled. */ node = (struct vbo_save_vertex_list *) - _mesa_dlist_alloc_aligned(ctx, save->opcode_vertex_list, sizeof(*node)); + _mesa_dlist_alloc_vertex_list(ctx); if (!node) return; @@ -1922,57 +1922,6 @@ vbo_save_EndCallList(struct gl_context *ctx) } -/** - * Called by display list code when a display list is being deleted. - */ -static void -vbo_destroy_vertex_list(struct gl_context *ctx, void *data) -{ - struct vbo_save_vertex_list *node = (struct vbo_save_vertex_list *) data; - - for (gl_vertex_processing_mode vpm = VP_MODE_FF; vpm < VP_MODE_MAX; ++vpm) - _mesa_reference_vao(ctx, &node->VAO[vpm], NULL); - - if (--node->prim_store->refcount == 0) { - free(node->prim_store->prims); - free(node->prim_store); - } - - free(node->merged.prims); - - _mesa_reference_buffer_object(ctx, &node->merged.ib.obj, NULL); - free(node->current_data); - node->current_data = NULL; -} - - -static void -vbo_print_vertex_list(struct gl_context *ctx, void *data, FILE *f) -{ - struct vbo_save_vertex_list *node = (struct vbo_save_vertex_list *) data; - GLuint i; - struct gl_buffer_object *buffer = node->VAO[0]->BufferBinding[0].BufferObj; - const GLuint vertex_size = _vbo_save_get_stride(node)/sizeof(GLfloat); - (void) ctx; - - fprintf(f, "VBO-VERTEX-LIST, %u vertices, %d primitives, %d vertsize, " - "buffer %p\n", - node->vertex_count, node->prim_count, vertex_size, - buffer); - - for (i = 0; i < node->prim_count; i++) { - struct _mesa_prim *prim = &node->prims[i]; - fprintf(f, " prim %d: %s %d..%d %s %s\n", - i, - _mesa_lookup_prim_by_nr(prim->mode), - prim->start, - prim->start + prim->count, - (prim->begin) ? "BEGIN" : "(wrap)", - (prim->end) ? "END" : "(wrap)"); - } -} - - /** * Called during context creation/init. */ @@ -2006,13 +1955,6 @@ vbo_save_api_init(struct vbo_save_context *save) { struct gl_context *ctx = gl_context_from_vbo_save(save); - save->opcode_vertex_list = - _mesa_dlist_alloc_opcode(ctx, - sizeof(struct vbo_save_vertex_list), - vbo_save_playback_vertex_list, - vbo_destroy_vertex_list, - vbo_print_vertex_list); - vtxfmt_init(ctx); current_init(ctx); _mesa_noop_vtxfmt_init(ctx, &save->vtxfmt_noop);