Mesa (master): tgsi: fix some off-by-one errors in shader length, instruction length

Brian Paul brianp at kemper.freedesktop.org
Tue Dec 8 15:16:27 UTC 2009


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

Author: Brian Paul <brianp at vmware.com>
Date:   Mon Dec  7 14:12:28 2009 -0700

tgsi: fix some off-by-one errors in shader length, instruction length

The ureg and/or tgsi-simplification work introduced some inconsistencies
between the ureg and traditional TGSI construction code.

Now the tgsi_instruction::NrTokens field is consistant and the
tgsi_header::BodySize field isn't off by one.

Fixes bug 25455.

---

 src/gallium/auxiliary/tgsi/tgsi_build.c |    2 +-
 src/gallium/auxiliary/tgsi/tgsi_parse.c |    5 ++---
 src/gallium/auxiliary/tgsi/tgsi_ureg.c  |    2 +-
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_build.c b/src/gallium/auxiliary/tgsi/tgsi_build.c
index d75ab1b..4092f78 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_build.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_build.c
@@ -399,7 +399,7 @@ tgsi_default_instruction( void )
    struct tgsi_instruction instruction;
 
    instruction.Type = TGSI_TOKEN_TYPE_INSTRUCTION;
-   instruction.NrTokens = 1;
+   instruction.NrTokens = 0;
    instruction.Opcode = TGSI_OPCODE_MOV;
    instruction.Saturate = TGSI_SAT_NONE;
    instruction.Predicate = 0;
diff --git a/src/gallium/auxiliary/tgsi/tgsi_parse.c b/src/gallium/auxiliary/tgsi/tgsi_parse.c
index 356b447..8f2b6a3 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_parse.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_parse.c
@@ -60,7 +60,7 @@ tgsi_parse_end_of_tokens(
    struct tgsi_parse_context *ctx )
 {
    return ctx->Position >=
-      1 + ctx->FullHeader.Header.HeaderSize + ctx->FullHeader.Header.BodySize;
+      ctx->FullHeader.Header.HeaderSize + ctx->FullHeader.Header.BodySize;
 }
 
 
@@ -232,8 +232,7 @@ tgsi_num_tokens(const struct tgsi_token *tokens)
    struct tgsi_parse_context ctx;
    if (tgsi_parse_init(&ctx, tokens) == TGSI_PARSE_OK) {
       unsigned len = (ctx.FullHeader.Header.HeaderSize +
-                      ctx.FullHeader.Header.BodySize +
-                      1);
+                      ctx.FullHeader.Header.BodySize);
       return len;
    }
    return 0;
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index 8f0b984..3f94384 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -1053,7 +1053,7 @@ fixup_header_size(struct ureg_program *ureg)
 {
    union tgsi_any_token *out = retrieve_token( ureg, DOMAIN_DECL, 0 );
 
-   out->header.BodySize = ureg->domain[DOMAIN_DECL].count - 3;
+   out->header.BodySize = ureg->domain[DOMAIN_DECL].count - 2;
 }
 
 




More information about the mesa-commit mailing list