vc4: Upload CS/VS UBO uniforms together.
[mesa.git] / src / freedreno / ir3 / ir3_nir.c
index 606e044d347d9b3ad82cae33ccb34afaf9141da5..d75df2feef4a2ec09f3f26570711c5a8ecfecabd 100644 (file)
@@ -49,8 +49,12 @@ static const nir_shader_compiler_options options = {
                .vertex_id_zero_based = true,
                .lower_extract_byte = true,
                .lower_extract_word = true,
-               .lower_all_io_to_temps = true,
+               .lower_all_io_to_elements = true,
                .lower_helper_invocation = true,
+               .lower_bitfield_insert_to_shifts = true,
+               .lower_bitfield_extract_to_shifts = true,
+               .lower_bfm = true,
+               .use_interpolated_input_intrinsics = true,
 };
 
 /* we don't want to lower vertex_id to _zero_based on newer gpus: */
@@ -72,8 +76,12 @@ static const nir_shader_compiler_options options_a6xx = {
                .vertex_id_zero_based = false,
                .lower_extract_byte = true,
                .lower_extract_word = true,
-               .lower_all_io_to_temps = true,
+               .lower_all_io_to_elements = true,
                .lower_helper_invocation = true,
+               .lower_bitfield_insert_to_shifts = true,
+               .lower_bitfield_extract_to_shifts = true,
+               .lower_bfm = true,
+               .use_interpolated_input_intrinsics = true,
 };
 
 const nir_shader_compiler_options *
@@ -139,7 +147,7 @@ ir3_optimize_loop(nir_shader *s)
                        OPT(s, nir_copy_prop);
                        OPT(s, nir_opt_dce);
                }
-               progress |= OPT(s, nir_opt_if);
+               progress |= OPT(s, nir_opt_if, false);
                progress |= OPT(s, nir_opt_remove_phis);
                progress |= OPT(s, nir_opt_undef);
 
@@ -187,7 +195,6 @@ ir3_optimize_nir(struct ir3_shader *shader, nir_shader *s,
                debug_printf("----------------------\n");
        }
 
-       OPT_V(s, nir_opt_global_to_local);
        OPT_V(s, nir_lower_regs_to_ssa);
        OPT_V(s, ir3_nir_lower_io_offsets);
 
@@ -218,10 +225,13 @@ ir3_optimize_nir(struct ir3_shader *shader, nir_shader *s,
 
        ir3_optimize_loop(s);
 
-       /* do idiv lowering after first opt loop to give a chance for
-        * divide by immed power-of-two to be caught first:
+       /* do ubo load and idiv lowering after first opt loop to get a chance to
+        * propagate constants for divide by immed power-of-two and constant ubo
+        * block/offsets:
         */
-       if (OPT(s, nir_lower_idiv))
+       const bool ubo_progress = OPT(s, ir3_nir_analyze_ubo_ranges, shader);
+       const bool idiv_progress = OPT(s, nir_lower_idiv);
+       if (ubo_progress || idiv_progress)
                ir3_optimize_loop(s);
 
        OPT_V(s, nir_remove_dead_variables, nir_var_function_temp);