Mesa (master): gallium/ttn: fix cursor handling vs builder

Rob Clark robclark at kemper.freedesktop.org
Wed Sep 9 21:35:01 UTC 2015


Module: Mesa
Branch: master
Commit: 9ce2e3072696428277988040908c9ae7a0abf9ad
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9ce2e3072696428277988040908c9ae7a0abf9ad

Author: Rob Clark <robclark at freedesktop.org>
Date:   Wed Sep  9 17:27:17 2015 -0400

gallium/ttn: fix cursor handling vs builder

After inserting instructions the cursor.option becomes _after_instr
(even if it started life as an _after_block).  So we cannot simply stash
the current cursor on the if/loop_stack.  Otherwise we end up inserting
instructions after the endif/endloop in the block preceeding the if/
loop.

Signed-off-by: Rob Clark <robclark at freedesktop.org>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

---

 src/gallium/auxiliary/nir/tgsi_to_nir.c |   14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c b/src/gallium/auxiliary/nir/tgsi_to_nir.c
index db50734..cccc560 100644
--- a/src/gallium/auxiliary/nir/tgsi_to_nir.c
+++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c
@@ -921,10 +921,6 @@ ttn_if(struct ttn_compile *c, nir_ssa_def *src, bool is_uint)
 {
    nir_builder *b = &c->build;
 
-   /* Save the outside-of-the-if-statement node list. */
-   c->if_stack[c->if_stack_pos] = b->cursor;
-   c->if_stack_pos++;
-
    src = ttn_channel(b, src, X);
 
    nir_if *if_stmt = nir_if_create(b->shader);
@@ -935,6 +931,9 @@ ttn_if(struct ttn_compile *c, nir_ssa_def *src, bool is_uint)
    }
    nir_builder_cf_insert(b, &if_stmt->cf_node);
 
+   c->if_stack[c->if_stack_pos] = nir_after_cf_node(&if_stmt->cf_node);
+   c->if_stack_pos++;
+
    b->cursor = nir_after_cf_list(&if_stmt->then_list);
 
    c->if_stack[c->if_stack_pos] = nir_after_cf_list(&if_stmt->else_list);
@@ -963,13 +962,12 @@ ttn_bgnloop(struct ttn_compile *c)
 {
    nir_builder *b = &c->build;
 
-   /* Save the outside-of-the-loop node list. */
-   c->loop_stack[c->loop_stack_pos] = b->cursor;
-   c->loop_stack_pos++;
-
    nir_loop *loop = nir_loop_create(b->shader);
    nir_builder_cf_insert(b, &loop->cf_node);
 
+   c->loop_stack[c->loop_stack_pos] = nir_after_cf_node(&loop->cf_node);
+   c->loop_stack_pos++;
+
    b->cursor = nir_after_cf_list(&loop->body);
 }
 




More information about the mesa-commit mailing list