[Mesa-dev] [PATCH 07/11] i965: Move postprocess_nir to codegen time

Iago Toral itoral at igalia.com
Fri Nov 13 05:53:01 PST 2015


On Wed, 2015-11-11 at 17:26 -0800, Jason Ekstrand wrote:
> ---
>  src/mesa/drivers/dri/i965/brw_fs.cpp              | 11 +++++++++--
>  src/mesa/drivers/dri/i965/brw_nir.c               |  1 -
>  src/mesa/drivers/dri/i965/brw_vec4.cpp            |  5 ++++-
>  src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp |  6 +++++-
>  4 files changed, 18 insertions(+), 5 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
> index ad94fa4..b8713ab 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
> @@ -43,6 +43,7 @@
>  #include "brw_wm.h"
>  #include "brw_fs.h"
>  #include "brw_cs.h"
> +#include "brw_nir.h"
>  #include "brw_vec4_gs_visitor.h"
>  #include "brw_cfg.h"
>  #include "brw_dead_control_flow.h"
> @@ -5459,13 +5460,16 @@ brw_compile_fs(const struct brw_compiler *compiler, void *log_data,
>                 void *mem_ctx,
>                 const struct brw_wm_prog_key *key,
>                 struct brw_wm_prog_data *prog_data,
> -               const nir_shader *shader,
> +               const nir_shader *src_shader,
>                 struct gl_program *prog,
>                 int shader_time_index8, int shader_time_index16,
>                 bool use_rep_send,
>                 unsigned *final_assembly_size,
>                 char **error_str)
>  {
> +   nir_shader *shader = nir_shader_clone(mem_ctx, src_shader);
> +   brw_postprocess_nir(shader, compiler->devinfo, true);
> +

Maybe it is a silly question, but why do we need to clone the shader to
do this?

>     /* key->alpha_test_func means simulating alpha testing via discards,
>      * so the shader definitely kills pixels.
>      */
> @@ -5618,11 +5622,14 @@ brw_compile_cs(const struct brw_compiler *compiler, void *log_data,
>                 void *mem_ctx,
>                 const struct brw_cs_prog_key *key,
>                 struct brw_cs_prog_data *prog_data,
> -               const nir_shader *shader,
> +               const nir_shader *src_shader,
>                 int shader_time_index,
>                 unsigned *final_assembly_size,
>                 char **error_str)
>  {
> +   nir_shader *shader = nir_shader_clone(mem_ctx, src_shader);
> +   brw_postprocess_nir(shader, compiler->devinfo, true);
> +
>     prog_data->local_size[0] = shader->info.cs.local_size[0];
>     prog_data->local_size[1] = shader->info.cs.local_size[1];
>     prog_data->local_size[2] = shader->info.cs.local_size[2];
> diff --git a/src/mesa/drivers/dri/i965/brw_nir.c b/src/mesa/drivers/dri/i965/brw_nir.c
> index 21c2648..693b9cd 100644
> --- a/src/mesa/drivers/dri/i965/brw_nir.c
> +++ b/src/mesa/drivers/dri/i965/brw_nir.c
> @@ -391,7 +391,6 @@ brw_create_nir(struct brw_context *brw,
>  
>     brw_preprocess_nir(nir, is_scalar);
>     brw_lower_nir(nir, devinfo, shader_prog, is_scalar);
> -   brw_postprocess_nir(nir, devinfo, is_scalar);
>  
>     return nir;
>  }
> diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp
> index 8350a02..9f75bb6 100644
> --- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
> @@ -2028,13 +2028,16 @@ brw_compile_vs(const struct brw_compiler *compiler, void *log_data,
>                 void *mem_ctx,
>                 const struct brw_vs_prog_key *key,
>                 struct brw_vs_prog_data *prog_data,
> -               const nir_shader *shader,
> +               const nir_shader *src_shader,
>                 gl_clip_plane *clip_planes,
>                 bool use_legacy_snorm_formula,
>                 int shader_time_index,
>                 unsigned *final_assembly_size,
>                 char **error_str)
>  {
> +   nir_shader *shader = nir_shader_clone(mem_ctx, src_shader);
> +   brw_postprocess_nir(shader, compiler->devinfo, compiler->scalar_vs);
> +
>     const unsigned *assembly = NULL;
>  
>     unsigned nr_attributes = _mesa_bitcount_64(prog_data->inputs_read);
> 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 49c1083..92b15d9 100644
> --- a/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp
> @@ -30,6 +30,7 @@
>  #include "brw_vec4_gs_visitor.h"
>  #include "gen6_gs_visitor.h"
>  #include "brw_fs.h"
> +#include "brw_nir.h"
>  
>  namespace brw {
>  
> @@ -604,7 +605,7 @@ brw_compile_gs(const struct brw_compiler *compiler, void *log_data,
>                 void *mem_ctx,
>                 const struct brw_gs_prog_key *key,
>                 struct brw_gs_prog_data *prog_data,
> -               const nir_shader *shader,
> +               const nir_shader *src_shader,
>                 struct gl_shader_program *shader_prog,
>                 int shader_time_index,
>                 unsigned *final_assembly_size,
> @@ -614,6 +615,9 @@ brw_compile_gs(const struct brw_compiler *compiler, void *log_data,
>     memset(&c, 0, sizeof(c));
>     c.key = *key;
>  
> +   nir_shader *shader = nir_shader_clone(mem_ctx, src_shader);
> +   brw_postprocess_nir(shader, compiler->devinfo, compiler->scalar_gs);
> +
>     prog_data->include_primitive_id =
>        (shader->info.inputs_read & VARYING_BIT_PRIMITIVE_ID) != 0;
>  




More information about the mesa-dev mailing list