mesa: simplify terminating display list loops

Remove the done variable and return directly from switches.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8297>
This commit is contained in:
Marek Olšák 2020-12-23 16:51:01 -05:00 committed by Marge Bot
parent 64da877742
commit 451fae8258
1 changed files with 31 additions and 35 deletions

View File

@ -1157,12 +1157,16 @@ void
_mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dlist) _mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dlist)
{ {
Node *n, *block; Node *n, *block;
GLboolean done;
if (!dlist->Head) {
free(dlist->Label);
free(dlist);
return;
}
n = block = dlist->Head; n = block = dlist->Head;
done = block ? GL_FALSE : GL_TRUE; while (1) {
while (!done) {
const OpCode opcode = n[0].opcode; const OpCode opcode = n[0].opcode;
/* check for extension opcodes first */ /* check for extension opcodes first */
@ -1383,8 +1387,9 @@ _mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dlist)
continue; continue;
case OPCODE_END_OF_LIST: case OPCODE_END_OF_LIST:
free(block); free(block);
done = GL_TRUE; free(dlist->Label);
break; free(dlist);
return;
default: default:
/* just increment 'n' pointer, below */ /* just increment 'n' pointer, below */
; ;
@ -1394,9 +1399,6 @@ _mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dlist)
n += InstSize[opcode]; n += InstSize[opcode];
} }
} }
free(dlist->Label);
free(dlist);
} }
@ -11263,7 +11265,6 @@ execute_list(struct gl_context *ctx, GLuint list)
{ {
struct gl_display_list *dlist; struct gl_display_list *dlist;
Node *n; Node *n;
GLboolean done;
if (list == 0 || !_mesa_get_list(ctx, list, &dlist)) if (list == 0 || !_mesa_get_list(ctx, list, &dlist))
return; return;
@ -11279,8 +11280,7 @@ execute_list(struct gl_context *ctx, GLuint list)
n = dlist->Head; n = dlist->Head;
done = GL_FALSE; while (1) {
while (!done) {
const OpCode opcode = n[0].opcode; const OpCode opcode = n[0].opcode;
if (is_ext_opcode(opcode)) { if (is_ext_opcode(opcode)) {
@ -13461,9 +13461,6 @@ execute_list(struct gl_context *ctx, GLuint list)
case OPCODE_NOP: case OPCODE_NOP:
/* no-op */ /* no-op */
break; break;
case OPCODE_END_OF_LIST:
done = GL_TRUE;
break;
default: default:
{ {
char msg[1000]; char msg[1000];
@ -13471,7 +13468,11 @@ execute_list(struct gl_context *ctx, GLuint list)
(int) opcode); (int) opcode);
_mesa_problem(ctx, "%s", msg); _mesa_problem(ctx, "%s", msg);
} }
done = GL_TRUE; FALLTHROUGH;
case OPCODE_END_OF_LIST:
vbo_save_EndCallList(ctx);
ctx->ListState.CallDepth--;
return;
} }
/* increment n to point to next compiled command */ /* increment n to point to next compiled command */
@ -13479,10 +13480,6 @@ execute_list(struct gl_context *ctx, GLuint list)
n += InstSize[opcode]; n += InstSize[opcode];
} }
} }
vbo_save_EndCallList(ctx);
ctx->ListState.CallDepth--;
} }
@ -14612,7 +14609,6 @@ print_list(struct gl_context *ctx, GLuint list, const char *fname)
{ {
struct gl_display_list *dlist; struct gl_display_list *dlist;
Node *n; Node *n;
GLboolean done;
FILE *f = stdout; FILE *f = stdout;
if (fname) { if (fname) {
@ -14623,15 +14619,17 @@ print_list(struct gl_context *ctx, GLuint list, const char *fname)
if (!_mesa_get_list(ctx, list, &dlist)) { if (!_mesa_get_list(ctx, list, &dlist)) {
fprintf(f, "%u is not a display list ID\n", list); fprintf(f, "%u is not a display list ID\n", list);
goto out; fflush(f);
if (fname)
fclose(f);
return;
} }
n = dlist->Head; n = dlist->Head;
fprintf(f, "START-LIST %u, address %p\n", list, (void *) n); fprintf(f, "START-LIST %u, address %p\n", list, (void *) n);
done = n ? GL_FALSE : GL_TRUE; while (1) {
while (!done) {
const OpCode opcode = n[0].opcode; const OpCode opcode = n[0].opcode;
if (is_ext_opcode(opcode)) { if (is_ext_opcode(opcode)) {
@ -14882,32 +14880,30 @@ print_list(struct gl_context *ctx, GLuint list, const char *fname)
case OPCODE_NOP: case OPCODE_NOP:
fprintf(f, "NOP\n"); fprintf(f, "NOP\n");
break; break;
case OPCODE_END_OF_LIST:
fprintf(f, "END-LIST %u\n", list);
done = GL_TRUE;
break;
default: default:
if (opcode < 0 || opcode > OPCODE_END_OF_LIST) { if (opcode < 0 || opcode > OPCODE_END_OF_LIST) {
printf printf
("ERROR IN DISPLAY LIST: opcode = %d, address = %p\n", ("ERROR IN DISPLAY LIST: opcode = %d, address = %p\n",
opcode, (void *) n); opcode, (void *) n);
goto out; } else {
}
else {
fprintf(f, "command %d, %u operands\n", opcode, fprintf(f, "command %d, %u operands\n", opcode,
InstSize[opcode]); InstSize[opcode]);
break;
} }
FALLTHROUGH;
case OPCODE_END_OF_LIST:
fprintf(f, "END-LIST %u\n", list);
fflush(f);
if (fname)
fclose(f);
return;
} }
/* increment n to point to next compiled command */ /* increment n to point to next compiled command */
assert(InstSize[opcode] > 0); assert(InstSize[opcode] > 0);
n += InstSize[opcode]; n += InstSize[opcode];
} }
} }
out:
fflush(f);
if (fname)
fclose(f);
} }