[Mesa-dev] [PATCH 6/9] glcpp: Skip unnecessary line continuations removal
Timothy Arceri
tarceri at itsqueeze.com
Mon May 22 00:38:20 UTC 2017
Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
On 22/05/17 06:49, Thomas Helland wrote:
> From: Vladislav Egorov <vegorov180 at gmail.com>
>
> Overwhelming majority of shaders don't use line continuations. In my
> shader-db only shaders from the Talos Principle and Serious Sam used
> them, less than 1% out of all shaders. Optimize for this case, don't
> do any copying if no line continuation was found.
> ---
> src/compiler/glsl/glcpp/pp.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/src/compiler/glsl/glcpp/pp.c b/src/compiler/glsl/glcpp/pp.c
> index cd86e369b1..50237a87b6 100644
> --- a/src/compiler/glsl/glcpp/pp.c
> +++ b/src/compiler/glsl/glcpp/pp.c
> @@ -117,6 +117,12 @@ remove_line_continuations(glcpp_parser_t *ctx, const char *shader)
> int collapsed_newlines = 0;
> int separator_len;
>
> + backslash = strchr(shader, '\\');
> +
> + /* No line continuations were found in this shader, our job is done */
> + if (backslash == NULL)
> + return (char *) shader;
> +
> search_start = shader;
>
> /* Determine what flavor of newlines this shader is using. GLSL
> @@ -158,8 +164,6 @@ remove_line_continuations(glcpp_parser_t *ctx, const char *shader)
> separator_len = strlen(newline_separator);
>
> while (true) {
> - backslash = strchr(search_start, '\\');
> -
> /* If we have previously collapsed any line-continuations,
> * then we want to insert additional newlines at the next
> * occurrence of a newline character to avoid changing any
> @@ -207,6 +211,8 @@ remove_line_continuations(glcpp_parser_t *ctx, const char *shader)
> shader = skip_newline (backslash + 1);
> search_start = shader;
> }
> +
> + backslash = strchr(search_start, '\\');
> }
>
> _mesa_string_buffer_append(sb, shader);
>
More information about the mesa-dev
mailing list