/**
* Display list opcodes.
- *
- * The fact that these identifiers are assigned consecutive
- * integer values starting at 0 is very important, see InstSize array usage)
*/
typedef enum
{
*/
union gl_dlist_node
{
- OpCode opcode;
+ struct {
+#if !DETECT_OS_WINDOWS
+ OpCode opcode:16;
+#else
+ /* sizeof(Node) is 8 with MSVC/mingw, so use an explicit 16 bits type. */
+ uint16_t opcode;
+#endif
+ uint16_t InstSize;
+ };
GLboolean b;
GLbitfield bf;
GLubyte ub;
#define BLOCK_SIZE 256
-
-/**
- * Number of nodes of storage needed for each instruction.
- * Sizes for dynamically allocated opcodes are stored in the context struct.
- */
-static GLuint InstSize[OPCODE_END_OF_LIST + 1];
-
-
void mesa_print_display_list(GLuint list);
{
const Node *n = dlist->Head;
if (n[0].opcode == OPCODE_BITMAP) {
- n += InstSize[OPCODE_BITMAP];
+ n += n[0].InstSize;
if (n[0].opcode == OPCODE_END_OF_LIST)
return true;
}
dlist->Name = name;
dlist->Head = malloc(sizeof(Node) * count);
dlist->Head[0].opcode = OPCODE_END_OF_LIST;
- /* All InstSize[] entries must be non-zero */
- InstSize[OPCODE_END_OF_LIST] = 1;
return dlist;
}
;
}
- assert(InstSize[opcode] > 0);
- n += InstSize[opcode];
+ assert(n[0].InstSize > 0);
+ n += n[0].InstSize;
}
}
assert(bytes <= BLOCK_SIZE * sizeof(Node));
- if (InstSize[opcode] == 0) {
- /* save instruction size now */
- InstSize[opcode] = numNodes;
- }
- else {
- /* make sure instruction size agrees */
- assert(numNodes == InstSize[opcode]);
- }
-
if (sizeof(void *) > sizeof(Node) && align8
&& ctx->ListState.CurrentPos % 2 == 0) {
/* The opcode would get placed at node[0] and the payload would start
if (nopNode) {
assert(ctx->ListState.CurrentPos % 2 == 0); /* even value */
n[0].opcode = OPCODE_NOP;
+ n[0].InstSize = 1;
n++;
/* The "real" opcode will now be at an odd location and the payload
* will be at an even location.
ctx->ListState.CurrentPos += nopNode + numNodes;
n[0].opcode = opcode;
+ n[0].InstSize = numNodes;
return n;
}
}
/* increment n to point to next compiled command */
- assert(InstSize[opcode] > 0);
- n += InstSize[opcode];
+ assert(n[0].InstSize > 0);
+ n += n[0].InstSize;
}
}
opcode, (void *) n);
} else {
fprintf(f, "command %d, %u operands\n", opcode,
- InstSize[opcode]);
+ n[0].InstSize);
break;
}
FALLTHROUGH;
}
/* increment n to point to next compiled command */
- assert(InstSize[opcode] > 0);
- n += InstSize[opcode];
+ assert(n[0].InstSize > 0);
+ n += n[0].InstSize;
}
}
}
/* increment n to point to next compiled command */
- assert(InstSize[opcode] > 0);
- n += InstSize[opcode];
+ assert(n[0].InstSize > 0);
+ n += n[0].InstSize;
}
}
void
_mesa_init_display_list(struct gl_context *ctx)
{
- static GLboolean tableInitialized = GL_FALSE;
GLvertexformat *vfmt = &ctx->ListState.ListVtxfmt;
- /* zero-out the instruction size table, just once */
- if (!tableInitialized) {
- memset(InstSize, 0, sizeof(InstSize));
- tableInitialized = GL_TRUE;
- }
-
/* Display list */
ctx->ListState.CallDepth = 0;
ctx->ExecuteFlag = GL_TRUE;
/* Display List group */
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
#define NAME(x) save_##x