[Mesa-dev] [PATCH 2/4] tgsi: try and handle overflowing shaders.

Marek Olšák maraeo at gmail.com
Tue Oct 13 03:42:11 PDT 2015


On Tue, Oct 13, 2015 at 6:40 AM, Dave Airlie <airlied at gmail.com> wrote:
> From: Dave Airlie <airlied at redhat.com>
>
> This is used to detect error in virgl if we overflow the shader
> dumping buffers.
>
> Signed-off-by: Dave Airlie <airlied at redhat.com>
> ---
>  src/gallium/auxiliary/tgsi/tgsi_dump.c | 10 ++++++++--
>  src/gallium/auxiliary/tgsi/tgsi_dump.h |  2 +-
>  2 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c
> index 33f6a56..f341783 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_dump.c
> +++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c
> @@ -708,6 +708,7 @@ struct str_dump_ctx
>     char *str;
>     char *ptr;
>     int left;
> +   bool nospace;
>  };
>
>  static void
> @@ -730,10 +731,11 @@ str_dump_ctx_printf(struct dump_ctx *ctx, const char *format, ...)
>           sctx->ptr += written;
>           sctx->left -= written;
>        }
> -   }
> +   } else
> +      sctx->nospace = true;
>  }
>
> -void
> +int
>  tgsi_dump_str(
>     const struct tgsi_token *tokens,
>     uint flags,
> @@ -760,6 +762,7 @@ tgsi_dump_str(
>     ctx.str[0] = 0;
>     ctx.ptr = str;
>     ctx.left = (int)size;
> +   ctx.nospace = false;
>
>     if (flags & TGSI_DUMP_FLOAT_AS_HEX)
>        ctx.base.dump_float_as_hex = TRUE;
> @@ -767,6 +770,8 @@ tgsi_dump_str(
>        ctx.base.dump_float_as_hex = FALSE;
>
>     tgsi_iterate_shader( tokens, &ctx.base.iter );
> +
> +   return (ctx.nospace == true) ? -1 : 0;

Why not just return bool meaning success/failure?

Anyway:

Reviewed-by: Marek Olšák <marek.olsak at amd.com>

Marek


More information about the mesa-dev mailing list