[Mesa-dev] [PATCH 1/2] nir: fill outputs_read field and add patch outputs read

Nicolai Hähnle nhaehnle at gmail.com
Wed Nov 15 11:14:23 UTC 2017


On 14.11.2017 06:18, Dave Airlie wrote:
> From: Dave Airlie <airlied at redhat.com>
> 
> This is to be used for TCS optimisations on radv.
> ---
>   src/compiler/nir/nir_gather_info.c | 29 ++++++++++++++++++++++-------
>   src/compiler/shader_info.h         |  2 ++
>   2 files changed, 24 insertions(+), 7 deletions(-)
> 
> diff --git a/src/compiler/nir/nir_gather_info.c b/src/compiler/nir/nir_gather_info.c
> index 13cdae3..ab2d519 100644
> --- a/src/compiler/nir/nir_gather_info.c
> +++ b/src/compiler/nir/nir_gather_info.c
> @@ -25,7 +25,8 @@
>   #include "nir.h"
>   
>   static void
> -set_io_mask(nir_shader *shader, nir_variable *var, int offset, int len)
> +set_io_mask(nir_shader *shader, nir_variable *var, int offset, int len,
> +            bool is_output_read)
>   {
>      for (int i = 0; i < len; i++) {
>         assert(var->data.location != -1);
> @@ -64,6 +65,14 @@ set_io_mask(nir_shader *shader, nir_variable *var, int offset, int len)
>               shader->info.outputs_written |= bitfield;
>            }
>   
> +         if (is_output_read) {
> +            if (is_patch_generic) {
> +               shader->info.patch_outputs_read |= bitfield;
> +            } else {
> +               shader->info.outputs_read |= bitfield;
> +            }
> +         }

This should probably not set {patch_}outputs_written when is_output_read 
== true...

Cheers,
Nicolai


> +
>            if (var->data.fb_fetch_output)
>               shader->info.outputs_read |= bitfield;
>         }
> @@ -75,7 +84,7 @@ set_io_mask(nir_shader *shader, nir_variable *var, int offset, int len)
>    * represents a shader input or output.
>    */
>   static void
> -mark_whole_variable(nir_shader *shader, nir_variable *var)
> +mark_whole_variable(nir_shader *shader, nir_variable *var, bool is_output_read)
>   {
>      const struct glsl_type *type = var->type;
>   
> @@ -88,7 +97,7 @@ mark_whole_variable(nir_shader *shader, nir_variable *var)
>         var->data.compact ? DIV_ROUND_UP(glsl_get_length(type), 4)
>                           : glsl_count_attribute_slots(type, false);
>   
> -   set_io_mask(shader, var, 0, slots);
> +   set_io_mask(shader, var, 0, slots, is_output_read);
>   }
>   
>   static unsigned
> @@ -124,7 +133,7 @@ get_io_offset(nir_deref_var *deref)
>    * occurs, then nothing will be marked and false will be returned.
>    */
>   static bool
> -try_mask_partial_io(nir_shader *shader, nir_deref_var *deref)
> +try_mask_partial_io(nir_shader *shader, nir_deref_var *deref, bool is_output_read)
>   {
>      nir_variable *var = deref->var;
>      const struct glsl_type *type = var->type;
> @@ -186,7 +195,7 @@ try_mask_partial_io(nir_shader *shader, nir_deref_var *deref)
>         return false;
>      }
>   
> -   set_io_mask(shader, var, offset, elem_width);
> +   set_io_mask(shader, var, offset, elem_width, is_output_read);
>      return true;
>   }
>   
> @@ -209,8 +218,13 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, nir_shader *shader)
>   
>         if (var->data.mode == nir_var_shader_in ||
>             var->data.mode == nir_var_shader_out) {
> -         if (!try_mask_partial_io(shader, instr->variables[0]))
> -            mark_whole_variable(shader, var);
> +         bool is_output_read = false;
> +         if (var->data.mode == nir_var_shader_out &&
> +             instr->intrinsic == nir_intrinsic_load_var)
> +            is_output_read = true;
> +
> +         if (!try_mask_partial_io(shader, instr->variables[0], is_output_read))
> +            mark_whole_variable(shader, var, is_output_read);
>   
>            /* We need to track which input_reads bits correspond to a
>             * dvec3/dvec4 input attribute */
> @@ -339,6 +353,7 @@ nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint)
>      shader->info.inputs_read = 0;
>      shader->info.outputs_written = 0;
>      shader->info.outputs_read = 0;
> +   shader->info.patch_outputs_read = 0;
>      shader->info.double_inputs_read = 0;
>      shader->info.patch_inputs_read = 0;
>      shader->info.patch_outputs_written = 0;
> diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h
> index 5f14ad1..bcb3f0f 100644
> --- a/src/compiler/shader_info.h
> +++ b/src/compiler/shader_info.h
> @@ -66,6 +66,8 @@ typedef struct shader_info {
>      uint32_t patch_inputs_read;
>      /* Which patch outputs are actually written */
>      uint32_t patch_outputs_written;
> +   /* Which patch outputs are read */
> +   uint32_t patch_outputs_read;
>   
>      /* Whether or not this shader ever uses textureGather() */
>      bool uses_texture_gather;
> 


-- 
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.


More information about the mesa-dev mailing list