[Mesa-dev] [PATCH 01/59] glsl/linker: Allow link_intrastage_shaders when there is no main()
Iago Toral
itoral at igalia.com
Wed Oct 26 08:07:39 UTC 2016
Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>
On Tue, 2016-10-25 at 17:59 -0700, Ian Romanick wrote:
> From: Ian Romanick <ian.d.romanick at intel.com>
>
> This enables a sort of par-linking. The primary use for this feature
> is
> resolving built-in functions in the stand-alone compiler.
>
> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> ---
> src/compiler/glsl/linker.cpp | 28 +++++++++++++++++-----------
> src/compiler/glsl/linker.h | 9 +++++++++
> 2 files changed, 26 insertions(+), 11 deletions(-)
>
> diff --git a/src/compiler/glsl/linker.cpp
> b/src/compiler/glsl/linker.cpp
> index af0e29d..7fca121 100644
> --- a/src/compiler/glsl/linker.cpp
> +++ b/src/compiler/glsl/linker.cpp
> @@ -2076,12 +2076,13 @@ link_cs_input_layout_qualifiers(struct
> gl_shader_program *prog,
> * If this function is supplied a single shader, it is cloned, and
> the new
> * shader is returned.
> */
> -static struct gl_linked_shader *
> +struct gl_linked_shader *
> link_intrastage_shaders(void *mem_ctx,
> struct gl_context *ctx,
> struct gl_shader_program *prog,
> struct gl_shader **shader_list,
> - unsigned num_shaders)
> + unsigned num_shaders,
> + bool allow_missing_main)
> {
> struct gl_uniform_block *ubo_blocks = NULL;
> struct gl_uniform_block *ssbo_blocks = NULL;
> @@ -2159,6 +2160,9 @@ link_intrastage_shaders(void *mem_ctx,
> }
> }
>
> + if (main == NULL && allow_missing_main)
> + main = shader_list[0];
> +
> if (main == NULL) {
> linker_error(prog, "%s shader lacks `main'\n",
> _mesa_shader_stage_to_string(shader_list[0]-
> >Stage));
> @@ -2188,16 +2192,18 @@ link_intrastage_shaders(void *mem_ctx,
> /* Move any instructions other than variable declarations or
> function
> * declarations into main.
> */
> - exec_node *insertion_point =
> - move_non_declarations(linked->ir, (exec_node *) &main_sig-
> >body, false,
> - linked);
> + if (main_sig != NULL) {
> + exec_node *insertion_point =
> + move_non_declarations(linked->ir, (exec_node *) &main_sig-
> >body, false,
> + linked);
>
> - for (unsigned i = 0; i < num_shaders; i++) {
> - if (shader_list[i] == main)
> - continue;
> + for (unsigned i = 0; i < num_shaders; i++) {
> + if (shader_list[i] == main)
> + continue;
>
> - insertion_point = move_non_declarations(shader_list[i]->ir,
> - insertion_point, true,
> linked);
> + insertion_point = move_non_declarations(shader_list[i]->ir,
> + insertion_point,
> true, linked);
> + }
> }
>
> if (!link_function_calls(prog, linked, shader_list, num_shaders))
> {
> @@ -4767,7 +4773,7 @@ link_shaders(struct gl_context *ctx, struct
> gl_shader_program *prog)
> if (num_shaders[stage] > 0) {
> gl_linked_shader *const sh =
> link_intrastage_shaders(mem_ctx, ctx, prog,
> shader_list[stage],
> - num_shaders[stage]);
> + num_shaders[stage], false);
>
> if (!prog->LinkStatus) {
> if (sh)
> diff --git a/src/compiler/glsl/linker.h b/src/compiler/glsl/linker.h
> index 420abf9..eb6fbff 100644
> --- a/src/compiler/glsl/linker.h
> +++ b/src/compiler/glsl/linker.h
> @@ -85,6 +85,15 @@ extern void
> link_check_atomic_counter_resources(struct gl_context *ctx,
> struct gl_shader_program *prog);
>
> +
> +extern struct gl_linked_shader *
> +link_intrastage_shaders(void *mem_ctx,
> + struct gl_context *ctx,
> + struct gl_shader_program *prog,
> + struct gl_shader **shader_list,
> + unsigned num_shaders,
> + bool allow_missing_main);
> +
> /**
> * Class for processing all of the leaf fields of a variable that
> corresponds
> * to a program resource.
More information about the mesa-dev
mailing list