[Mesa-dev] [PATCH 12/22] compiler/link: add linker_util.h, move linker_error/warning to it
Timothy Arceri
tarceri at itsqueeze.com
Thu May 3 02:43:20 UTC 2018
NAK as per discussion about moving nir helpers into src/compiler/glsl
this patch should no longer be needed.
On 18/04/18 00:36, Alejandro Piñeiro wrote:
> Linker utilities common to glsl and nir. As a first step, it moves
> linker_error/warning from glsl/linker.h
> ---
> src/compiler/Makefile.sources | 2 +
> .../glsl/link_uniform_block_active_visitor.cpp | 1 +
> src/compiler/glsl/linker.cpp | 27 ------------
> src/compiler/glsl/linker.h | 8 +---
> src/compiler/glsl/program.h | 8 ----
> src/compiler/linker_util.cpp | 51 ++++++++++++++++++++++
> src/compiler/linker_util.h | 43 ++++++++++++++++++
> src/compiler/meson.build | 2 +
> 8 files changed, 101 insertions(+), 41 deletions(-)
> create mode 100644 src/compiler/linker_util.cpp
> create mode 100644 src/compiler/linker_util.h
>
> diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources
> index aca9dab476e..bb86972ea1a 100644
> --- a/src/compiler/Makefile.sources
> +++ b/src/compiler/Makefile.sources
> @@ -4,6 +4,8 @@ LIBCOMPILER_FILES = \
> builtin_type_macros.h \
> glsl_types.cpp \
> glsl_types.h \
> + linker_util.h \
> + linker_util.cpp \
> nir_types.cpp \
> nir_types.h \
> shader_enums.c \
> diff --git a/src/compiler/glsl/link_uniform_block_active_visitor.cpp b/src/compiler/glsl/link_uniform_block_active_visitor.cpp
> index cd1baf78e80..578a201b0f0 100644
> --- a/src/compiler/glsl/link_uniform_block_active_visitor.cpp
> +++ b/src/compiler/glsl/link_uniform_block_active_visitor.cpp
> @@ -23,6 +23,7 @@
>
> #include "link_uniform_block_active_visitor.h"
> #include "program.h"
> +#include "compiler/linker_util.h"
>
> static link_uniform_block_active *
> process_block(void *mem_ctx, struct hash_table *ht, ir_variable *var)
> diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
> index f060c5316fa..09488cbd4d2 100644
> --- a/src/compiler/glsl/linker.cpp
> +++ b/src/compiler/glsl/linker.cpp
> @@ -447,33 +447,6 @@ private:
>
> } /* anonymous namespace */
>
> -void
> -linker_error(gl_shader_program *prog, const char *fmt, ...)
> -{
> - va_list ap;
> -
> - ralloc_strcat(&prog->data->InfoLog, "error: ");
> - va_start(ap, fmt);
> - ralloc_vasprintf_append(&prog->data->InfoLog, fmt, ap);
> - va_end(ap);
> -
> - prog->data->LinkStatus = LINKING_FAILURE;
> -}
> -
> -
> -void
> -linker_warning(gl_shader_program *prog, const char *fmt, ...)
> -{
> - va_list ap;
> -
> - ralloc_strcat(&prog->data->InfoLog, "warning: ");
> - va_start(ap, fmt);
> - ralloc_vasprintf_append(&prog->data->InfoLog, fmt, ap);
> - va_end(ap);
> -
> -}
> -
> -
> /**
> * Given a string identifying a program resource, break it into a base name
> * and an optional array index in square brackets.
> diff --git a/src/compiler/glsl/linker.h b/src/compiler/glsl/linker.h
> index 454b65aebdf..20dbd7adcfa 100644
> --- a/src/compiler/glsl/linker.h
> +++ b/src/compiler/glsl/linker.h
> @@ -29,6 +29,8 @@ struct gl_shader_program;
> struct gl_shader;
> struct gl_linked_shader;
>
> +#include "compiler/linker_util.h"
> +
> extern bool
> link_function_calls(gl_shader_program *prog, gl_linked_shader *main,
> gl_shader **shader_list, unsigned num_shaders);
> @@ -192,12 +194,6 @@ private:
> const glsl_struct_field *named_ifc_member);
> };
>
> -void
> -linker_error(gl_shader_program *prog, const char *fmt, ...);
> -
> -void
> -linker_warning(gl_shader_program *prog, const char *fmt, ...);
> -
> /**
> * Sometimes there are empty slots left over in UniformRemapTable after we
> * allocate slots to explicit locations. This struct represents a single
> diff --git a/src/compiler/glsl/program.h b/src/compiler/glsl/program.h
> index 480379b10b8..9df42ddc1c4 100644
> --- a/src/compiler/glsl/program.h
> +++ b/src/compiler/glsl/program.h
> @@ -48,14 +48,6 @@ extern void
> build_program_resource_list(struct gl_context *ctx,
> struct gl_shader_program *shProg);
>
> -extern void
> -linker_error(struct gl_shader_program *prog, const char *fmt, ...)
> - PRINTFLIKE(2, 3);
> -
> -extern void
> -linker_warning(struct gl_shader_program *prog, const char *fmt, ...)
> - PRINTFLIKE(2, 3);
> -
> extern long
> parse_program_resource_name(const GLchar *name,
> const GLchar **out_base_name_end);
> diff --git a/src/compiler/linker_util.cpp b/src/compiler/linker_util.cpp
> new file mode 100644
> index 00000000000..c7d26616245
> --- /dev/null
> +++ b/src/compiler/linker_util.cpp
> @@ -0,0 +1,51 @@
> +/*
> + * Copyright © 2018 Intel Corporation
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> + * IN THE SOFTWARE.
> + *
> + */
> +#include "main/mtypes.h"
> +#include "linker_util.h"
> +
> +void
> +linker_error(struct gl_shader_program *prog, const char *fmt, ...)
> +{
> + va_list ap;
> +
> + ralloc_strcat(&prog->data->InfoLog, "error: ");
> + va_start(ap, fmt);
> + ralloc_vasprintf_append(&prog->data->InfoLog, fmt, ap);
> + va_end(ap);
> +
> + prog->data->LinkStatus = LINKING_FAILURE;
> +}
> +
> +
> +void
> +linker_warning(struct gl_shader_program *prog, const char *fmt, ...)
> +{
> + va_list ap;
> +
> + ralloc_strcat(&prog->data->InfoLog, "warning: ");
> + va_start(ap, fmt);
> + ralloc_vasprintf_append(&prog->data->InfoLog, fmt, ap);
> + va_end(ap);
> +
> +}
> diff --git a/src/compiler/linker_util.h b/src/compiler/linker_util.h
> new file mode 100644
> index 00000000000..162db3e532f
> --- /dev/null
> +++ b/src/compiler/linker_util.h
> @@ -0,0 +1,43 @@
> +/*
> + * Copyright © 2018 Intel Corporation
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
> + * DEALINGS IN THE SOFTWARE.
> + */
> +
> +#ifndef GLSL_LINKER_UTIL_H
> +#define GLSL_LINKER_UTIL_H
> +
> +struct gl_shader_program;
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +void
> +linker_error(struct gl_shader_program *prog, const char *fmt, ...);
> +
> +void
> +linker_warning(struct gl_shader_program *prog, const char *fmt, ...);
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif /* GLSL_LINKER_UTIL_H */
> diff --git a/src/compiler/meson.build b/src/compiler/meson.build
> index da2464d7b8c..9a567d0ffa1 100644
> --- a/src/compiler/meson.build
> +++ b/src/compiler/meson.build
> @@ -29,6 +29,8 @@ files_libcompiler = files(
> 'builtin_type_macros.h',
> 'glsl_types.cpp',
> 'glsl_types.h',
> + 'linker_util.h',
> + 'linker_util.cpp',
> 'nir_types.cpp',
> 'nir_types.h',
> 'shader_enums.c',
>
More information about the mesa-dev
mailing list