[Mesa-dev] [PATCH 07/78] i965/vec4: Overload make_reg_for_system_value() to allow reuse in NIR->vec4 pass

Jason Ekstrand jason at jlekstrand.net
Mon Jun 29 16:27:37 PDT 2015


On Fri, Jun 26, 2015 at 1:06 AM, Eduardo Lima Mitev <elima at igalia.com> wrote:
> From: Alejandro PiƱeiro <apinheiro at igalia.com>
>
> The new virtual method is more flexible, it has a signature:
>
> dst_reg *make_reg_for_system_value(int location, const glsl_type *type);
>
> so the current method will be chained through this one.

I just grepped the code.  This function is used exactly once in the
current fs_visitor code.  Let's just replace that use with a use of
the new one and avoid the overload.

>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89580

Also, let's not reference the same "make a vec4 visitor for NIR" bug
in every patch.  It's not really a bugfix.
--Jason

> ---
>  src/mesa/drivers/dri/i965/brw_vec4.cpp            | 6 ++++++
>  src/mesa/drivers/dri/i965/brw_vec4.h              | 5 ++++-
>  src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp | 7 ++++---
>  src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.h   | 3 ++-
>  src/mesa/drivers/dri/i965/brw_vec4_vs_visitor.cpp | 5 +++--
>  src/mesa/drivers/dri/i965/brw_vs.h                | 3 ++-
>  6 files changed, 21 insertions(+), 8 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp
> index dcffa04..ff1ef75 100644
> --- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
> @@ -1684,6 +1684,12 @@ vec4_visitor::emit_shader_time_end()
>     emit(BRW_OPCODE_ENDIF);
>  }
>
> +dst_reg *
> +vec4_visitor::make_reg_for_system_value(ir_variable *ir)
> +{
> +   return make_reg_for_system_value(ir->data.location, ir->type);
> +}
> +
>  void
>  vec4_visitor::emit_shader_time_write(int shader_time_subindex, src_reg value)
>  {
> diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h
> index 6535f19..2a53d9a 100644
> --- a/src/mesa/drivers/dri/i965/brw_vec4.h
> +++ b/src/mesa/drivers/dri/i965/brw_vec4.h
> @@ -411,6 +411,9 @@ public:
>     virtual void nir_emit_jump(nir_jump_instr *instr);
>     virtual void nir_emit_texture(nir_tex_instr *instr);
>
> +   virtual dst_reg *make_reg_for_system_value(int location,
> +                                              const glsl_type *type) = 0;
> +
>     src_reg *nir_inputs;
>     int *nir_outputs;
>     brw_reg_type *nir_output_types;
> @@ -423,7 +426,7 @@ protected:
>                                      bool interleaved);
>     void setup_payload_interference(struct ra_graph *g, int first_payload_node,
>                                     int reg_node_count);
> -   virtual dst_reg *make_reg_for_system_value(ir_variable *ir) = 0;
> +   virtual dst_reg *make_reg_for_system_value(ir_variable *ir);
>     virtual void assign_binding_table_offsets();
>     virtual void setup_payload() = 0;
>     virtual void emit_prolog() = 0;
> diff --git a/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp
> index 69bcf5a..91bc849 100644
> --- a/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp
> @@ -49,11 +49,12 @@ vec4_gs_visitor::vec4_gs_visitor(const struct brw_compiler *compiler,
>
>
>  dst_reg *
> -vec4_gs_visitor::make_reg_for_system_value(ir_variable *ir)
> +vec4_gs_visitor::make_reg_for_system_value(int location,
> +                                           const glsl_type *type)
>  {
> -   dst_reg *reg = new(mem_ctx) dst_reg(this, ir->type);
> +   dst_reg *reg = new(mem_ctx) dst_reg(this, type);
>
> -   switch (ir->data.location) {
> +   switch (location) {
>     case SYSTEM_VALUE_INVOCATION_ID:
>        this->current_annotation = "initialize gl_InvocationID";
>        emit(GS_OPCODE_GET_INSTANCE_ID, *reg);
> diff --git a/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.h b/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.h
> index e693c56..0f1c705 100644
> --- a/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.h
> +++ b/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.h
> @@ -76,7 +76,8 @@ public:
>                     int shader_time_index);
>
>  protected:
> -   virtual dst_reg *make_reg_for_system_value(ir_variable *ir);
> +   virtual dst_reg *make_reg_for_system_value(int location,
> +                                              const glsl_type *type);
>     virtual void setup_payload();
>     virtual void emit_prolog();
>     virtual void emit_program_code();
> diff --git a/src/mesa/drivers/dri/i965/brw_vec4_vs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_vs_visitor.cpp
> index f93062b..1fe23ba 100644
> --- a/src/mesa/drivers/dri/i965/brw_vec4_vs_visitor.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_vec4_vs_visitor.cpp
> @@ -143,7 +143,8 @@ vec4_vs_visitor::emit_prolog()
>
>
>  dst_reg *
> -vec4_vs_visitor::make_reg_for_system_value(ir_variable *ir)
> +vec4_vs_visitor::make_reg_for_system_value(int location,
> +                                           const glsl_type *type)
>  {
>     /* VertexID is stored by the VF as the last vertex element, but
>      * we don't represent it with a flag in inputs_read, so we call
> @@ -151,7 +152,7 @@ vec4_vs_visitor::make_reg_for_system_value(ir_variable *ir)
>      */
>     dst_reg *reg = new(mem_ctx) dst_reg(ATTR, VERT_ATTRIB_MAX);
>
> -   switch (ir->data.location) {
> +   switch (location) {
>     case SYSTEM_VALUE_BASE_VERTEX:
>        reg->writemask = WRITEMASK_X;
>        vs_prog_data->uses_vertexid = true;
> diff --git a/src/mesa/drivers/dri/i965/brw_vs.h b/src/mesa/drivers/dri/i965/brw_vs.h
> index 61f9b00..873ffb7 100644
> --- a/src/mesa/drivers/dri/i965/brw_vs.h
> +++ b/src/mesa/drivers/dri/i965/brw_vs.h
> @@ -99,7 +99,8 @@ public:
>                     bool use_legacy_snorm_formula);
>
>  protected:
> -   virtual dst_reg *make_reg_for_system_value(ir_variable *ir);
> +   virtual dst_reg *make_reg_for_system_value(int location,
> +                                              const glsl_type *type);
>     virtual void setup_payload();
>     virtual void emit_prolog();
>     virtual void emit_program_code();
> --
> 2.1.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list