aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/shader
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2009-06-17 13:48:52 -0600
committerBrian Paul <[email protected]>2009-06-26 13:16:32 -0600
commit625b0fe2684de462d1e7ea7fc8fcdfc8e3283949 (patch)
tree052f62f7e7a91f1a05c94055c6e51ebc2a86d461 /src/mesa/shader
parent4031ea1520f582fa36a6b964de7d565fe33a538d (diff)
Revert "slang: if/else/break & if/else/continue work for unrolled loops"
We should just check if the loop contains a continue/break in the _slang_can_unroll_for_loop() test function... This reverts commit 989856bde47d699d7e18798df4013fbf962e1d4b. Conflicts: src/mesa/shader/slang/slang_codegen.h
Diffstat (limited to 'src/mesa/shader')
-rw-r--r--src/mesa/shader/slang/slang_codegen.c44
-rw-r--r--src/mesa/shader/slang/slang_codegen.h1
2 files changed, 7 insertions, 38 deletions
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index 6d693c9027a..f19da41b0d6 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -2582,20 +2582,6 @@ _slang_can_unroll_for_loop(slang_assemble_ctx * A, const slang_operation *oper)
}
-static void
-_unroll_loop_inc(slang_assemble_ctx * A)
-{
- A->UnrollLoop++;
-}
-
-
-static void
-_unroll_loop_dec(slang_assemble_ctx * A)
-{
- A->UnrollLoop--;
-}
-
-
/**
* Unroll a for-loop.
* First we determine the number of iterations to unroll.
@@ -2612,9 +2598,6 @@ _slang_unroll_for_loop(slang_assemble_ctx * A, const slang_operation *oper)
slang_ir_node *n, *root = NULL;
slang_atom varId;
- /* Set flag so code generator knows we're unrolling loops */
- _unroll_loop_inc( A );
-
if (oper->children[0].type == SLANG_OPER_BLOCK_NO_NEW_SCOPE) {
/* for (int i=0; ... */
slang_variable *var;
@@ -2637,15 +2620,11 @@ _slang_unroll_for_loop(slang_assemble_ctx * A, const slang_operation *oper)
/* make a copy of the loop body */
body = slang_operation_new(1);
- if (!body) {
- _unroll_loop_dec( A );
+ if (!body)
return NULL;
- }
- if (!slang_operation_copy(body, &oper->children[3])) {
- _unroll_loop_dec( A );
+ if (!slang_operation_copy(body, &oper->children[3]))
return NULL;
- }
/* in body, replace instances of 'varId' with literal 'iter' */
{
@@ -2656,7 +2635,6 @@ _slang_unroll_for_loop(slang_assemble_ctx * A, const slang_operation *oper)
if (!oldVar) {
/* undeclared loop variable */
slang_operation_delete(body);
- _unroll_loop_dec( A );
return NULL;
}
@@ -2671,18 +2649,14 @@ _slang_unroll_for_loop(slang_assemble_ctx * A, const slang_operation *oper)
/* do IR codegen for body */
n = _slang_gen_operation(A, body);
- if (!n) {
- _unroll_loop_dec( A );
+ if (!n)
return NULL;
- }
root = new_seq(root, n);
slang_operation_delete(body);
}
- _unroll_loop_dec( A );
-
return root;
}
@@ -2819,7 +2793,7 @@ _slang_gen_if(slang_assemble_ctx * A, const slang_operation *oper)
if (is_operation_type(&oper->children[1], SLANG_OPER_BREAK)
&& !haveElseClause) {
/* Special case: generate a conditional break */
- if (!A->CurLoop && A->UnrollLoop) /* trying to unroll */
+ if (!A->CurLoop) /* probably trying to unroll */
return NULL;
ifBody = new_break_if_true(A->CurLoop, cond);
return ifBody;
@@ -2827,7 +2801,7 @@ _slang_gen_if(slang_assemble_ctx * A, const slang_operation *oper)
else if (is_operation_type(&oper->children[1], SLANG_OPER_CONTINUE)
&& !haveElseClause) {
/* Special case: generate a conditional continue */
- if (!A->CurLoop && A->UnrollLoop) /* trying to unroll */
+ if (!A->CurLoop) /* probably trying to unroll */
return NULL;
ifBody = new_cont_if_true(A->CurLoop, cond);
return ifBody;
@@ -2835,8 +2809,6 @@ _slang_gen_if(slang_assemble_ctx * A, const slang_operation *oper)
else {
/* general case */
ifBody = _slang_gen_operation(A, &oper->children[1]);
- if (!ifBody)
- return NULL;
if (haveElseClause)
elseBody = _slang_gen_operation(A, &oper->children[2]);
else
@@ -4049,15 +4021,13 @@ _slang_gen_operation(slang_assemble_ctx * A, slang_operation *oper)
return _slang_gen_while(A, oper);
case SLANG_OPER_BREAK:
if (!A->CurLoop) {
- if (!A->UnrollLoop)
- slang_info_log_error(A->log, "'break' not in loop");
+ slang_info_log_error(A->log, "'break' not in loop");
return NULL;
}
return new_break(A->CurLoop);
case SLANG_OPER_CONTINUE:
if (!A->CurLoop) {
- if (!A->UnrollLoop)
- slang_info_log_error(A->log, "'continue' not in loop");
+ slang_info_log_error(A->log, "'continue' not in loop");
return NULL;
}
return _slang_gen_continue(A, oper);
diff --git a/src/mesa/shader/slang/slang_codegen.h b/src/mesa/shader/slang/slang_codegen.h
index d80013ad341..ce6cc7cb8f0 100644
--- a/src/mesa/shader/slang/slang_codegen.h
+++ b/src/mesa/shader/slang/slang_codegen.h
@@ -42,7 +42,6 @@ typedef struct slang_assemble_ctx_
struct slang_label_ *curFuncEndLabel;
struct slang_ir_node_ *CurLoop;
struct slang_function_ *CurFunction;
- GLuint UnrollLoop;
GLboolean UnresolvedRefs;
} slang_assemble_ctx;