summaryrefslogtreecommitdiff
path: root/src/gallium
diff options
context:
space:
mode:
authorBrian <brian.paul@tungstengraphics.com>2008-03-24 16:24:32 -0600
committerBrian <brian.paul@tungstengraphics.com>2008-03-24 16:35:24 -0600
commit648e26aa95b519f1f4abc429b5a23abaf4a5195b (patch)
treec053ef7b891302917922a4bbd087acd31cd01e1d /src/gallium
parente8c6ea4f608296ed976f1597ffd46ac0b42fc84a (diff)
gallium: added tgsi_num_tokens() function to return number of tokens in token array.
Maybe move to a different file someday.
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/auxiliary/tgsi/util/tgsi_parse.c13
-rw-r--r--src/gallium/auxiliary/tgsi/util/tgsi_parse.h4
2 files changed, 17 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/tgsi/util/tgsi_parse.c b/src/gallium/auxiliary/tgsi/util/tgsi_parse.c
index bf6b89ce56..c3526cb71f 100644
--- a/src/gallium/auxiliary/tgsi/util/tgsi_parse.c
+++ b/src/gallium/auxiliary/tgsi/util/tgsi_parse.c
@@ -317,3 +317,16 @@ tgsi_parse_token(
}
}
+
+unsigned
+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);
+ return len;
+ }
+ return 0;
+}
diff --git a/src/gallium/auxiliary/tgsi/util/tgsi_parse.h b/src/gallium/auxiliary/tgsi/util/tgsi_parse.h
index 40083728d6..a98e88e343 100644
--- a/src/gallium/auxiliary/tgsi/util/tgsi_parse.h
+++ b/src/gallium/auxiliary/tgsi/util/tgsi_parse.h
@@ -113,6 +113,10 @@ void
tgsi_parse_token(
struct tgsi_parse_context *ctx );
+unsigned
+tgsi_num_tokens(const struct tgsi_token *tokens);
+
+
#if defined __cplusplus
}
#endif