[Mesa-dev] [PATCH] tgsi: fix incorrect tgsi_shader_info::num_tokens computation

Neha Bhende bhenden at vmware.com
Thu May 17 20:29:35 UTC 2018


Reviewed-by: Neha Bhende<bhenden at vmware.com>


Regards,

Neha

________________________________
From: Brian Paul <brianp at vmware.com>
Sent: Thursday, May 17, 2018 1:06:26 PM
To: mesa-dev at lists.freedesktop.org
Cc: Charmaine Lee; Neha Bhende; Roland Scheidegger
Subject: [PATCH] tgsi: fix incorrect tgsi_shader_info::num_tokens computation

We were incrementing num_tokens in each loop iteration while parsing
the shader.  But each call to tgsi_parse_token() can consume more than
one token (and often does).  Instead, just call the tgsi_num_tokens()
function.

Luckily, this issue doesn't seem to effect any current users of this
field (llvmpipe just checks for <= 1, for example).
---
 src/gallium/auxiliary/tgsi/tgsi_scan.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c b/src/gallium/auxiliary/tgsi/tgsi_scan.c
index 18488d7..685a413 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c
@@ -836,13 +836,12 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
           procType == PIPE_SHADER_TESS_EVAL ||
           procType == PIPE_SHADER_COMPUTE);
    info->processor = procType;
+   info->num_tokens = tgsi_num_tokens(parse.Tokens);

    /**
     ** Loop over incoming program tokens/instructions
     */
    while (!tgsi_parse_end_of_tokens(&parse)) {
-      info->num_tokens++;
-
       tgsi_parse_token( &parse );

       switch( parse.FullToken.Token.Type ) {
--
2.7.4

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180517/7ccf3fba/attachment.html>


More information about the mesa-dev mailing list