nir/opt_vectorize: Add a callback for filtering of vectorizing.
[mesa.git] / src / gallium / drivers / lima / lima_program.c
index 19eef27f32028cd823842d77f9d03685f704098c..87029d3140a8d4ce7ffde72f4f5c6dd79f3a37fe 100644 (file)
@@ -101,7 +101,8 @@ lima_program_optimize_vs_nir(struct nir_shader *s)
 
    NIR_PASS_V(s, nir_lower_viewport_transform);
    NIR_PASS_V(s, nir_lower_point_size, 1.0f, 100.0f);
-   NIR_PASS_V(s, nir_lower_io, nir_var_all, type_size, 0);
+   NIR_PASS_V(s, nir_lower_io,
+             nir_var_shader_in | nir_var_shader_out, type_size, 0);
    NIR_PASS_V(s, nir_lower_load_const_to_scalar);
    NIR_PASS_V(s, lima_nir_lower_uniform_to_scalar);
    NIR_PASS_V(s, nir_lower_io_to_scalar,
@@ -138,7 +139,7 @@ lima_program_optimize_vs_nir(struct nir_shader *s)
    NIR_PASS_V(s, nir_opt_dce);
    NIR_PASS_V(s, nir_lower_locals_to_regs);
    NIR_PASS_V(s, nir_convert_from_ssa, true);
-   NIR_PASS_V(s, nir_remove_dead_variables, nir_var_function_temp);
+   NIR_PASS_V(s, nir_remove_dead_variables, nir_var_function_temp, NULL);
    nir_sweep(s);
 }
 
@@ -193,13 +194,14 @@ lima_program_optimize_fs_nir(struct nir_shader *s,
    bool progress;
 
    NIR_PASS_V(s, nir_lower_fragcoord_wtrans);
-   NIR_PASS_V(s, nir_lower_io, nir_var_all, type_size, 0);
+   NIR_PASS_V(s, nir_lower_io,
+             nir_var_shader_in | nir_var_shader_out, type_size, 0);
    NIR_PASS_V(s, nir_lower_regs_to_ssa);
    NIR_PASS_V(s, nir_lower_tex, tex_options);
 
    do {
       progress = false;
-      NIR_PASS(progress, s, nir_opt_vectorize);
+      NIR_PASS(progress, s, nir_opt_vectorize, NULL, NULL);
    } while (progress);
 
    do {
@@ -243,11 +245,15 @@ lima_program_optimize_fs_nir(struct nir_shader *s,
 
    NIR_PASS_V(s, nir_lower_locals_to_regs);
    NIR_PASS_V(s, nir_convert_from_ssa, true);
-   NIR_PASS_V(s, nir_remove_dead_variables, nir_var_function_temp);
+   NIR_PASS_V(s, nir_remove_dead_variables, nir_var_function_temp, NULL);
 
    NIR_PASS_V(s, nir_move_vec_src_uses_to_dest);
    NIR_PASS_V(s, nir_lower_vec_to_movs);
 
+   NIR_PASS_V(s, lima_nir_duplicate_load_uniforms);
+   NIR_PASS_V(s, lima_nir_duplicate_load_inputs);
+   NIR_PASS_V(s, lima_nir_duplicate_load_consts);
+
    nir_sweep(s);
 }
 
@@ -294,7 +300,7 @@ lima_create_fs_state(struct pipe_context *pctx,
    else {
       assert(cso->type == PIPE_SHADER_IR_TGSI);
 
-      nir = tgsi_to_nir(cso->tokens, pctx->screen);
+      nir = tgsi_to_nir(cso->tokens, pctx->screen, false);
    }
 
    so->base.type = PIPE_SHADER_IR_NIR;
@@ -450,7 +456,7 @@ lima_create_vs_state(struct pipe_context *pctx,
    else {
       assert(cso->type == PIPE_SHADER_IR_TGSI);
 
-      nir = tgsi_to_nir(cso->tokens, pctx->screen);
+      nir = tgsi_to_nir(cso->tokens, pctx->screen, false);
    }
 
    lima_program_optimize_vs_nir(nir);