From 648e26aa95b519f1f4abc429b5a23abaf4a5195b Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 24 Mar 2008 16:24:32 -0600 Subject: [PATCH] gallium: added tgsi_num_tokens() function to return number of tokens in token array. Maybe move to a different file someday. --- src/gallium/auxiliary/tgsi/util/tgsi_parse.c | 13 +++++++++++++ src/gallium/auxiliary/tgsi/util/tgsi_parse.h | 4 ++++ 2 files changed, 17 insertions(+) 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 -- 2.30.2