Mesa (master): tgsi: fix tgsi transform's epilog callback

Brian Paul brianp at kemper.freedesktop.org
Mon Sep 22 22:59:46 UTC 2014


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

Author: Brian Paul <brianp at vmware.com>
Date:   Fri Sep 19 13:11:58 2014 -0600

tgsi: fix tgsi transform's epilog callback

We want to call the caller's epilog callback when we find the TGSI
END instruction, not after it.

Reviewed-by: Charmaine Lee <charmainel at vmware.com>

---

 src/gallium/auxiliary/tgsi/tgsi_transform.c |   22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_transform.c b/src/gallium/auxiliary/tgsi/tgsi_transform.c
index 93e5b98..9d316cc 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_transform.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_transform.c
@@ -171,10 +171,22 @@ tgsi_transform_shader(const struct tgsi_token *tokens_in,
                ctx->prolog(ctx);
             }
 
-            if (ctx->transform_instruction)
-               ctx->transform_instruction(ctx, fullinst);
-            else
+            /* XXX Note: we may also want to look for a main/top-level
+             * TGSI_OPCODE_RET instruction in the future.
+             */
+            if (fullinst->Instruction.Opcode == TGSI_OPCODE_END
+                && ctx->epilog) {
+               /* Emit caller's epilog */
+               ctx->epilog(ctx);
+               /* Emit END */
                ctx->emit_instruction(ctx, fullinst);
+            }
+            else {
+               if (ctx->transform_instruction)
+                  ctx->transform_instruction(ctx, fullinst);
+               else
+                  ctx->emit_instruction(ctx, fullinst);
+            }
 
             first_instruction = FALSE;
          }
@@ -220,10 +232,6 @@ tgsi_transform_shader(const struct tgsi_token *tokens_in,
       }
    }
 
-   if (ctx->epilog) {
-      ctx->epilog(ctx);
-   }
-
    tgsi_parse_free (&parse);
 
    return ctx->ti;




More information about the mesa-commit mailing list