Convert protocol decode tabels for Render and RenderLarge to use nice,

compact N-way search trees generated by scripts in Mesa.
This commit is contained in:
Ian Romanick 2006-08-23 16:05:37 -07:00
parent 7ae82b5fc8
commit f6fd7d8f83
7 changed files with 1073 additions and 2652 deletions

View File

@ -70,7 +70,6 @@ libglx_la_SOURCES = \
renderpix.c \
renderpixswap.c \
rensize.c \
rensizetab.c \
single2.c \
single2swap.c \
singlepix.c \

View File

@ -1746,9 +1746,10 @@ int __glXDisp_Render(__GLXclientState *cl, GLbyte *pc)
pc += sz_xGLXRenderReq;
left = (req->length << 2) - sz_xGLXRenderReq;
while (left > 0) {
__GLXrenderSizeData *entry;
__GLXrenderSizeData entry;
int extra;
void (* proc)(GLbyte *);
__GLXdispatchRenderProcPtr proc;
int err;
/*
** Verify that the header length and the overall length agree.
@ -1761,41 +1762,27 @@ int __glXDisp_Render(__GLXclientState *cl, GLbyte *pc)
/*
** Check for core opcodes and grab entry data.
*/
if ( (opcode >= __GLX_MIN_RENDER_OPCODE) &&
(opcode <= __GLX_MAX_RENDER_OPCODE) ) {
entry = &__glXRenderSizeTable[opcode];
proc = __glXRenderTable[opcode];
#if __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT
} else if ( (opcode >= __GLX_MIN_RENDER_OPCODE_EXT) &&
(opcode <= __GLX_MAX_RENDER_OPCODE_EXT) ) {
entry =
&__glXRenderSizeTable_EXT[opcode -
__GLX_MIN_RENDER_OPCODE_EXT];
proc = __glXRenderTable_EXT[opcode -
__GLX_MIN_RENDER_OPCODE_EXT];
#endif /* __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT */
} else {
err = __glXGetProtocolSizeData(& Render_dispatch_info, opcode, & entry);
proc = (__GLXdispatchRenderProcPtr)
__glXGetProtocolDecodeFunction(& Render_dispatch_info, opcode, 0);
if ((err < 0) || (proc == NULL)) {
client->errorValue = commandsDone;
return __glXError(GLXBadRenderRequest);
}
if (!entry->bytes) {
/* unused opcode */
client->errorValue = commandsDone;
return __glXError(GLXBadRenderRequest);
}
if (entry->varsize) {
if (entry.varsize) {
/* variable size command */
extra = (*entry->varsize)(pc + __GLX_RENDER_HDR_SIZE, False);
extra = (*entry.varsize)(pc + __GLX_RENDER_HDR_SIZE, False);
if (extra < 0) {
extra = 0;
}
if (cmdlen != __GLX_PAD(entry->bytes + extra)) {
if (cmdlen != __GLX_PAD(entry.bytes + extra)) {
return BadLength;
}
} else {
/* constant size command */
if (cmdlen != __GLX_PAD(entry->bytes)) {
if (cmdlen != __GLX_PAD(entry.bytes)) {
return BadLength;
}
}
@ -1827,7 +1814,7 @@ int __glXDisp_RenderLarge(__GLXclientState *cl, GLbyte *pc)
xGLXRenderLargeReq *req;
ClientPtr client= cl->client;
GLuint dataBytes;
void (*proc)(GLbyte *);
__GLXdispatchRenderProcPtr proc;
__GLXrenderLargeHeader *hdr;
__GLXcontext *glxc;
int error;
@ -1860,8 +1847,10 @@ int __glXDisp_RenderLarge(__GLXclientState *cl, GLbyte *pc)
pc += sz_xGLXRenderLargeReq;
if (cl->largeCmdRequestsSoFar == 0) {
__GLXrenderSizeData *entry;
__GLXrenderSizeData entry;
int extra, cmdlen;
int err;
/*
** This is the first request of a multi request command.
** Make enough space in the buffer, then copy the entire request.
@ -1878,42 +1867,36 @@ int __glXDisp_RenderLarge(__GLXclientState *cl, GLbyte *pc)
/*
** Check for core opcodes and grab entry data.
*/
if ( (opcode >= __GLX_MIN_RENDER_OPCODE) &&
(opcode <= __GLX_MAX_RENDER_OPCODE) ) {
entry = &__glXRenderSizeTable[opcode];
#if __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT
} else if ( (opcode >= __GLX_MIN_RENDER_OPCODE_EXT) &&
(opcode <= __GLX_MAX_RENDER_OPCODE_EXT) ) {
opcode -= __GLX_MIN_RENDER_OPCODE_EXT;
entry = &__glXRenderSizeTable_EXT[opcode];
#endif /* __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT */
} else {
err = __glXGetProtocolSizeData(& Render_dispatch_info, opcode, & entry);
if (err < 0) {
client->errorValue = opcode;
return __glXError(GLXBadLargeRequest);
}
if (!entry->bytes) {
/* unused opcode */
client->errorValue = opcode;
return __glXError(GLXBadLargeRequest);
}
if (entry->varsize) {
proc = (__GLXdispatchRenderProcPtr)
__glXGetProtocolDecodeFunction(& Render_dispatch_info, opcode, 0);
if (proc == NULL) {
client->errorValue = opcode;
return __glXError(GLXBadLargeRequest);
}
if (entry.varsize) {
/*
** If it's a variable-size command (a command whose length must
** be computed from its parameters), all the parameters needed
** will be in the 1st request, so it's okay to do this.
*/
extra = (*entry->varsize)(pc + __GLX_RENDER_LARGE_HDR_SIZE, False);
extra = (*entry.varsize)(pc + __GLX_RENDER_LARGE_HDR_SIZE, False);
if (extra < 0) {
extra = 0;
}
/* large command's header is 4 bytes longer, so add 4 */
if (cmdlen != __GLX_PAD(entry->bytes + 4 + extra)) {
if (cmdlen != __GLX_PAD(entry.bytes + 4 + extra)) {
return BadLength;
}
} else {
/* constant size command */
if (cmdlen != __GLX_PAD(entry->bytes + 4)) {
if (cmdlen != __GLX_PAD(entry.bytes + 4)) {
return BadLength;
}
}

View File

@ -669,9 +669,10 @@ int __glXDispSwap_Render(__GLXclientState *cl, GLbyte *pc)
pc += sz_xGLXRenderReq;
left = (req->length << 2) - sz_xGLXRenderReq;
while (left > 0) {
__GLXrenderSizeData *entry;
__GLXrenderSizeData entry;
int extra;
void (* proc)(GLbyte *);
__GLXdispatchRenderProcPtr proc;
int err;
/*
** Verify that the header length and the overall length agree.
@ -683,38 +684,27 @@ int __glXDispSwap_Render(__GLXclientState *cl, GLbyte *pc)
cmdlen = hdr->length;
opcode = hdr->opcode;
if ( (opcode >= __GLX_MIN_RENDER_OPCODE) &&
(opcode <= __GLX_MAX_RENDER_OPCODE) ) {
entry = &__glXRenderSizeTable[opcode];
proc = __glXSwapRenderTable[opcode];
#if __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT
} else if ( (opcode >= __GLX_MIN_RENDER_OPCODE_EXT) &&
(opcode <= __GLX_MAX_RENDER_OPCODE_EXT) ) {
int index = opcode - __GLX_MIN_RENDER_OPCODE_EXT;
entry = &__glXRenderSizeTable_EXT[index];
proc = __glXSwapRenderTable_EXT[index];
#endif /* __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT */
} else {
err = __glXGetProtocolSizeData(& Render_dispatch_info, opcode, & entry);
proc = (__GLXdispatchRenderProcPtr)
__glXGetProtocolDecodeFunction(& Render_dispatch_info, opcode, 1);
if ((err < 0) || (proc == NULL)) {
client->errorValue = commandsDone;
return __glXError(GLXBadRenderRequest);
}
if (!entry->bytes) {
/* unused opcode */
client->errorValue = commandsDone;
return __glXError(GLXBadRenderRequest);
}
if (entry->varsize) {
if (entry.varsize) {
/* variable size command */
extra = (*entry->varsize)(pc + __GLX_RENDER_HDR_SIZE, True);
extra = (*entry.varsize)(pc + __GLX_RENDER_HDR_SIZE, True);
if (extra < 0) {
extra = 0;
}
if (cmdlen != __GLX_PAD(entry->bytes + extra)) {
if (cmdlen != __GLX_PAD(entry.bytes + extra)) {
return BadLength;
}
} else {
/* constant size command */
if (cmdlen != __GLX_PAD(entry->bytes)) {
if (cmdlen != __GLX_PAD(entry.bytes)) {
return BadLength;
}
}
@ -746,7 +736,7 @@ int __glXDispSwap_RenderLarge(__GLXclientState *cl, GLbyte *pc)
xGLXRenderLargeReq *req;
ClientPtr client= cl->client;
size_t dataBytes;
void (*proc)(GLbyte *);
__GLXdispatchRenderProcPtr proc;
__GLXrenderLargeHeader *hdr;
__GLXcontext *cx;
int error;
@ -785,9 +775,11 @@ int __glXDispSwap_RenderLarge(__GLXclientState *cl, GLbyte *pc)
pc += sz_xGLXRenderLargeReq;
if (cl->largeCmdRequestsSoFar == 0) {
__GLXrenderSizeData *entry;
__GLXrenderSizeData entry;
int extra;
size_t cmdlen;
int err;
/*
** This is the first request of a multi request command.
** Make enough space in the buffer, then copy the entire request.
@ -802,44 +794,36 @@ int __glXDispSwap_RenderLarge(__GLXclientState *cl, GLbyte *pc)
cmdlen = hdr->length;
opcode = hdr->opcode;
if ( (opcode >= __GLX_MIN_RENDER_OPCODE) &&
(opcode <= __GLX_MAX_RENDER_OPCODE) ) {
entry = &__glXRenderSizeTable[opcode];
proc = __glXSwapRenderTable[opcode];
#if __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT
} else if ( (opcode >= __GLX_MIN_RENDER_OPCODE_EXT) &&
(opcode <= __GLX_MAX_RENDER_OPCODE_EXT) ) {
int index = opcode - __GLX_MIN_RENDER_OPCODE_EXT;
entry = &__glXRenderSizeTable_EXT[index];
proc = __glXSwapRenderTable_EXT[index];
#endif /* __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT */
} else {
err = __glXGetProtocolSizeData(& Render_dispatch_info, opcode, & entry);
if (err < 0) {
client->errorValue = opcode;
return __glXError(GLXBadLargeRequest);
}
if (!entry->bytes) {
/* unused opcode */
client->errorValue = opcode;
return __glXError(GLXBadLargeRequest);
}
if (entry->varsize) {
proc = (__GLXdispatchRenderProcPtr)
__glXGetProtocolDecodeFunction(& Render_dispatch_info, opcode, 0);
if (proc == NULL) {
client->errorValue = opcode;
return __glXError(GLXBadLargeRequest);
}
if (entry.varsize) {
/*
** If it's a variable-size command (a command whose length must
** be computed from its parameters), all the parameters needed
** will be in the 1st request, so it's okay to do this.
*/
extra = (*entry->varsize)(pc + __GLX_RENDER_LARGE_HDR_SIZE, True);
extra = (*entry.varsize)(pc + __GLX_RENDER_LARGE_HDR_SIZE, True);
if (extra < 0) {
extra = 0;
}
/* large command's header is 4 bytes longer, so add 4 */
if (cmdlen != __GLX_PAD(entry->bytes + 4 + extra)) {
if (cmdlen != __GLX_PAD(entry.bytes + 4 + extra)) {
return BadLength;
}
} else {
/* constant size command */
if (cmdlen != __GLX_PAD(entry->bytes + 4)) {
if (cmdlen != __GLX_PAD(entry.bytes + 4)) {
return BadLength;
}
}

View File

@ -202,8 +202,6 @@ typedef struct {
int bytes;
gl_proto_size_func varsize;
} __GLXrenderSizeData;
extern __GLXrenderSizeData __glXRenderSizeTable[];
extern __GLXrenderSizeData __glXRenderSizeTable_EXT[];
/************************************************************************/

File diff suppressed because it is too large Load Diff

View File

@ -289,7 +289,7 @@ __glXGetProtocolDecodeFunction(const struct __glXDispatchInfo *dispatch_info,
return (func_index < 0)
? NULL
: dispatch_info->dispatch_functions[func_index][swapped_version];
: (void *) dispatch_info->dispatch_functions[func_index][swapped_version];
}
@ -300,13 +300,14 @@ __glXGetProtocolSizeData(const struct __glXDispatchInfo *dispatch_info,
if (dispatch_info->size_table != NULL) {
const int func_index = get_decode_index(dispatch_info, opcode);
if (func_index >= 0) {
if ((func_index >= 0)
&& (dispatch_info->size_table[func_index][0] != 0)) {
const int var_offset =
dispatch_info->size_table[func_index][1];
data->bytes = dispatch_info->size_table[func_index][0];
data->varsize = (var_offset != ~0)
? dispatch_info->size_table[func_index]
? dispatch_info->size_func_table[var_offset]
: NULL;
return 0;

File diff suppressed because it is too large Load Diff