[Mesa-dev] [PATCH 4/7] util: simplify temp register selection in u_pstipple.c

Brian Paul brianp at vmware.com
Thu Oct 30 20:04:12 PDT 2014


---
 src/gallium/auxiliary/util/u_pstipple.c |   30 ++++++++++++------------------
 1 file changed, 12 insertions(+), 18 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_pstipple.c b/src/gallium/auxiliary/util/u_pstipple.c
index 5c6c8fc..ba80956 100644
--- a/src/gallium/auxiliary/util/u_pstipple.c
+++ b/src/gallium/auxiliary/util/u_pstipple.c
@@ -267,7 +267,6 @@ pstip_transform_inst(struct tgsi_transform_context *ctx,
 
       struct tgsi_full_declaration decl;
       struct tgsi_full_instruction newInst;
-      uint i;
       int wincoordInput;
 
       /* find free texture sampler */
@@ -280,17 +279,10 @@ pstip_transform_inst(struct tgsi_transform_context *ctx,
       else
          wincoordInput = pctx->wincoordInput;
 
-      /* find one free temp register */
-      for (i = 0; i < 32; i++) {
-         if ((pctx->tempsUsed & (1 << i)) == 0) {
-            /* found a free temp */
-            if (pctx->texTemp < 0)
-               pctx->texTemp  = i;
-            else
-               break;
-         }
-      }
-      assert(pctx->texTemp >= 0);
+      /* We can always use temp[0] since this code is before
+       * the rest of the shader.
+       */
+      pctx->texTemp = 0;
 
       if (pctx->wincoordInput < 0) {
          /* declare new position input reg */
@@ -313,12 +305,14 @@ pstip_transform_inst(struct tgsi_transform_context *ctx,
       decl.Range.Last = pctx->freeSampler;
       ctx->emit_declaration(ctx, &decl);
 
-      /* declare new temp regs */
-      decl = tgsi_default_full_declaration();
-      decl.Declaration.File = TGSI_FILE_TEMPORARY;
-      decl.Range.First = 
-      decl.Range.Last = pctx->texTemp;
-      ctx->emit_declaration(ctx, &decl);
+      /* declare temp[0] reg if not already declared */
+      if ((pctx->tempsUsed & 0x1) == 0) {
+         decl = tgsi_default_full_declaration();
+         decl.Declaration.File = TGSI_FILE_TEMPORARY;
+         decl.Range.First = 
+            decl.Range.Last = pctx->texTemp;
+         ctx->emit_declaration(ctx, &decl);
+      }
 
       /* emit immediate = {1/32, 1/32, 1, 1}
        * The index/position of this immediate will be pctx->numImmed
-- 
1.7.10.4



More information about the mesa-dev mailing list