[Mesa-dev] [PATCH 2/9] tgsi: fix tgsi transform's epilog callback

Brian Paul brianp at vmware.com
Mon Sep 22 08:44:58 PDT 2014


We want to call the caller's epilog callback when we find the TGSI
END instruction, not after it.
---
 src/gallium/auxiliary/tgsi/tgsi_transform.c |   19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_transform.c b/src/gallium/auxiliary/tgsi/tgsi_transform.c
index 93e5b98..5a5f56c 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_transform.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_transform.c
@@ -171,10 +171,19 @@ tgsi_transform_shader(const struct tgsi_token *tokens_in,
                ctx->prolog(ctx);
             }
 
-            if (ctx->transform_instruction)
-               ctx->transform_instruction(ctx, fullinst);
-            else
+            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 +229,6 @@ tgsi_transform_shader(const struct tgsi_token *tokens_in,
       }
    }
 
-   if (ctx->epilog) {
-      ctx->epilog(ctx);
-   }
-
    tgsi_parse_free (&parse);
 
    return ctx->ti;
-- 
1.7.10.4



More information about the mesa-dev mailing list