diff options
author | Brian <[email protected]> | 2008-03-24 16:24:32 -0600 |
---|---|---|
committer | Brian <[email protected]> | 2008-03-24 16:35:24 -0600 |
commit | 648e26aa95b519f1f4abc429b5a23abaf4a5195b (patch) | |
tree | c053ef7b891302917922a4bbd087acd31cd01e1d /src/gallium | |
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')
-rw-r--r-- | src/gallium/auxiliary/tgsi/util/tgsi_parse.c | 13 | ||||
-rw-r--r-- | src/gallium/auxiliary/tgsi/util/tgsi_parse.h | 4 |
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 bf6b89ce564..c3526cb71ff 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 40083728d64..a98e88e3437 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 |