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 \ renderpix.c \
renderpixswap.c \ renderpixswap.c \
rensize.c \ rensize.c \
rensizetab.c \
single2.c \ single2.c \
single2swap.c \ single2swap.c \
singlepix.c \ singlepix.c \

View File

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

View File

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

View File

@ -202,8 +202,6 @@ typedef struct {
int bytes; int bytes;
gl_proto_size_func varsize; gl_proto_size_func varsize;
} __GLXrenderSizeData; } __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) return (func_index < 0)
? NULL ? 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) { if (dispatch_info->size_table != NULL) {
const int func_index = get_decode_index(dispatch_info, opcode); 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 = const int var_offset =
dispatch_info->size_table[func_index][1]; dispatch_info->size_table[func_index][1];
data->bytes = dispatch_info->size_table[func_index][0]; data->bytes = dispatch_info->size_table[func_index][0];
data->varsize = (var_offset != ~0) data->varsize = (var_offset != ~0)
? dispatch_info->size_table[func_index] ? dispatch_info->size_func_table[var_offset]
: NULL; : NULL;
return 0; return 0;

File diff suppressed because it is too large Load Diff