diff options
author | Brian <brian.paul@tungstengraphics.com> | 2008-03-24 16:24:32 -0600 |
---|---|---|
committer | Brian <brian.paul@tungstengraphics.com> | 2008-03-24 16:35:24 -0600 |
commit | 648e26aa95b519f1f4abc429b5a23abaf4a5195b (patch) | |
tree | c053ef7b891302917922a4bbd087acd31cd01e1d /src/gallium/auxiliary/tgsi/util/tgsi_parse.c | |
parent | e8c6ea4f608296ed976f1597ffd46ac0b42fc84a (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/auxiliary/tgsi/util/tgsi_parse.c')
-rw-r--r-- | src/gallium/auxiliary/tgsi/util/tgsi_parse.c | 13 |
1 files changed, 13 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; +} |