[Mesa-dev] [PATCH 1/8] glsl: Create and use a new ir_variable::count_attribute_slots() wrapper.

Marek Olšák maraeo at gmail.com
Sat Jan 7 15:22:28 UTC 2017


Hi, this causes an assertion failure for many tessellation tests on radeonsi:

state_tracker/st_program.c:1295:st_translate_program_common: Assertion
`attr >= VARYING_SLOT_VAR0 || (attr >= VARYING_SLOT_TEX0 && attr <=
VARYING_SLOT_TEX7)' failed.

Test: piglit/bin/shader_runner
piglit/tests/spec/arb_arrays_of_arrays/execution/tessellation/tcs-tes-patch.shader_test
-auto

I won't look into it right now, maybe next week. Any idea what's wrong here?

Thanks,
Marek

On Wed, Jan 4, 2017 at 12:07 PM, Kenneth Graunke <kenneth at whitecape.org> wrote:
> This wraps glsl_type::count_attribute_slots(), but will soon contain a
> couple of overrides for a couple of GLSL built-ins variables.
>
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
>  src/compiler/glsl/ir.cpp                    | 7 +++++++
>  src/compiler/glsl/ir.h                      | 2 ++
>  src/compiler/glsl/ir_set_program_inouts.cpp | 9 +++------
>  src/compiler/glsl/link_varyings.cpp         | 4 ++--
>  src/compiler/glsl/linker.cpp                | 6 +++---
>  5 files changed, 17 insertions(+), 11 deletions(-)
>
> diff --git a/src/compiler/glsl/ir.cpp b/src/compiler/glsl/ir.cpp
> index 8e4b382ebd3..a77b9a9d857 100644
> --- a/src/compiler/glsl/ir.cpp
> +++ b/src/compiler/glsl/ir.cpp
> @@ -1618,6 +1618,13 @@ ir_variable::get_extension_warning() const
>        ? NULL : warn_extension_table[this->data.warn_extension_index];
>  }
>
> +unsigned
> +ir_variable::count_attribute_slots(bool is_vertex_stage) const
> +{
> +   bool is_vs_input = is_vertex_stage && this->data.mode == ir_var_shader_in;
> +   return this->type->count_attribute_slots(is_vs_input);
> +}
> +
>  ir_function_signature::ir_function_signature(const glsl_type *return_type,
>                                               builtin_available_predicate b)
>     : ir_instruction(ir_type_function_signature),
> diff --git a/src/compiler/glsl/ir.h b/src/compiler/glsl/ir.h
> index a11dccd2e9b..1cd6a60c081 100644
> --- a/src/compiler/glsl/ir.h
> +++ b/src/compiler/glsl/ir.h
> @@ -553,6 +553,8 @@ public:
>        return this->u.max_ifc_array_access;
>     }
>
> +   unsigned count_attribute_slots(bool is_vertex_stage) const;
> +
>     inline unsigned get_num_state_slots() const
>     {
>        assert(!this->is_interface_instance()
> diff --git a/src/compiler/glsl/ir_set_program_inouts.cpp b/src/compiler/glsl/ir_set_program_inouts.cpp
> index 90b06b9f417..66f0c1ebf08 100644
> --- a/src/compiler/glsl/ir_set_program_inouts.cpp
> +++ b/src/compiler/glsl/ir_set_program_inouts.cpp
> @@ -149,7 +149,7 @@ void
>  ir_set_program_inouts_visitor::mark_whole_variable(ir_variable *var)
>  {
>     const glsl_type *type = var->type;
> -   bool is_vertex_input = false;
> +
>     if (this->shader_stage == MESA_SHADER_GEOMETRY &&
>         var->data.mode == ir_var_shader_in && type->is_array()) {
>        type = type->fields.array;
> @@ -173,11 +173,8 @@ ir_set_program_inouts_visitor::mark_whole_variable(ir_variable *var)
>        type = type->fields.array;
>     }
>
> -   if (this->shader_stage == MESA_SHADER_VERTEX &&
> -       var->data.mode == ir_var_shader_in)
> -      is_vertex_input = true;
> -
> -   mark(this->prog, var, 0, type->count_attribute_slots(is_vertex_input),
> +   mark(this->prog, var, 0,
> +        var->count_attribute_slots(this->shader_stage == MESA_SHADER_VERTEX),
>          this->shader_stage);
>  }
>
> diff --git a/src/compiler/glsl/link_varyings.cpp b/src/compiler/glsl/link_varyings.cpp
> index e1a29b03549..c7ff6d041fb 100644
> --- a/src/compiler/glsl/link_varyings.cpp
> +++ b/src/compiler/glsl/link_varyings.cpp
> @@ -2301,7 +2301,7 @@ check_against_output_limit(struct gl_context *ctx,
>            var->data.mode == ir_var_shader_out &&
>            var_counts_against_varying_limit(producer->Stage, var)) {
>           /* outputs for fragment shader can't be doubles */
> -         output_vectors += var->type->count_attribute_slots(false);
> +         output_vectors += var->count_attribute_slots(false);
>        }
>     }
>
> @@ -2345,7 +2345,7 @@ check_against_input_limit(struct gl_context *ctx,
>            var->data.mode == ir_var_shader_in &&
>            var_counts_against_varying_limit(consumer->Stage, var)) {
>           /* vertex inputs aren't varying counted */
> -         input_vectors += var->type->count_attribute_slots(false);
> +         input_vectors += var->count_attribute_slots(false);
>        }
>     }
>
> diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
> index f4f918a34e7..371000a38f1 100644
> --- a/src/compiler/glsl/linker.cpp
> +++ b/src/compiler/glsl/linker.cpp
> @@ -2669,7 +2669,7 @@ assign_attribute_or_color_locations(void *mem_ctx,
>           return false;
>        }
>
> -      const unsigned slots = var->type->count_attribute_slots(target_index == MESA_SHADER_VERTEX);
> +      const unsigned slots = var->count_attribute_slots(target_index == MESA_SHADER_VERTEX);
>
>        /* If the variable is not a built-in and has a location statically
>         * assigned in the shader (presumably via a layout qualifier), make sure
> @@ -2781,7 +2781,7 @@ assign_attribute_or_color_locations(void *mem_ctx,
>                     */
>                    for (unsigned i = 0; i < assigned_attr; i++) {
>                       unsigned assigned_slots =
> -                        assigned[i]->type->count_attribute_slots(false);
> +                        assigned[i]->count_attribute_slots(false);
>                       unsigned assig_attr =
>                          assigned[i]->data.location - generic_base;
>                       unsigned assigned_use_mask = (1 << assigned_slots) - 1;
> @@ -3231,7 +3231,7 @@ check_image_resources(struct gl_context *ctx, struct gl_shader_program *prog)
>                 ir_variable *var = node->as_variable();
>                 if (var && var->data.mode == ir_var_shader_out)
>                    /* since there are no double fs outputs - pass false */
> -                  fragment_outputs += var->type->count_attribute_slots(false);
> +                  fragment_outputs += var->count_attribute_slots(false);
>              }
>           }
>        }
> --
> 2.11.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list