intel/nir: Make brw_nir_apply_sampler_key more generic
authorJason Ekstrand <jason.ekstrand@intel.com>
Fri, 22 Feb 2019 17:15:21 +0000 (11:15 -0600)
committerJason Ekstrand <jason@jlekstrand.net>
Wed, 24 Jul 2019 17:55:40 +0000 (12:55 -0500)
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
src/intel/compiler/brw_fs.cpp
src/intel/compiler/brw_nir.c
src/intel/compiler/brw_nir.h
src/intel/compiler/brw_shader.cpp
src/intel/compiler/brw_vec4.cpp
src/intel/compiler/brw_vec4_gs_visitor.cpp
src/intel/compiler/brw_vec4_tcs.cpp

index 25e4dd9971c8190a95110c7cf3b41eff47b08427..30e04ddc318b94288a15dc6cdc4d03d11c696c57 100644 (file)
@@ -7967,7 +7967,7 @@ brw_compile_fs(const struct brw_compiler *compiler, void *log_data,
 {
    const struct gen_device_info *devinfo = compiler->devinfo;
 
-   brw_nir_apply_sampler_key(shader, compiler, &key->base.tex, true);
+   brw_nir_apply_key(shader, compiler, &key->base, true);
    brw_nir_lower_fs_inputs(shader, devinfo, key);
    brw_nir_lower_fs_outputs(shader);
 
@@ -8228,7 +8228,7 @@ compile_cs_to_nir(const struct brw_compiler *compiler,
                   unsigned dispatch_width)
 {
    nir_shader *shader = nir_shader_clone(mem_ctx, src_shader);
-   brw_nir_apply_sampler_key(shader, compiler, &key->base.tex, true);
+   brw_nir_apply_key(shader, compiler, &key->base, true);
 
    NIR_PASS_V(shader, brw_nir_lower_cs_intrinsics, dispatch_width);
 
index ae81c65b94a34a48a4eb692d1f4313db7693e1b5..62e5eb7c7261b5b7e64b7323de2142c91f9222e9 100644 (file)
@@ -919,11 +919,10 @@ brw_postprocess_nir(nir_shader *nir, const struct brw_compiler *compiler,
    }
 }
 
-void
+static bool
 brw_nir_apply_sampler_key(nir_shader *nir,
                           const struct brw_compiler *compiler,
-                          const struct brw_sampler_prog_key_data *key_tex,
-                          bool is_scalar)
+                          const struct brw_sampler_prog_key_data *key_tex)
 {
    const struct gen_device_info *devinfo = compiler->devinfo;
    nir_lower_tex_options tex_options = {
@@ -966,10 +965,21 @@ brw_nir_apply_sampler_key(nir_shader *nir,
    memcpy(&tex_options.scale_factors, &key_tex->scale_factors,
           sizeof(tex_options.scale_factors));
 
-   if (nir_lower_tex(nir, &tex_options)) {
-      nir_validate_shader(nir, "after nir_lower_tex");
+   return nir_lower_tex(nir, &tex_options);
+}
+
+void
+brw_nir_apply_key(nir_shader *nir,
+                  const struct brw_compiler *compiler,
+                  const struct brw_base_prog_key *key,
+                  bool is_scalar)
+{
+   bool progress = false;
+
+   OPT(brw_nir_apply_sampler_key, compiler, &key->tex);
+
+   if (progress)
       brw_nir_optimize(nir, compiler, is_scalar, false);
-   }
 }
 
 enum brw_reg_type
index 895b63bc4971003657240c1aca05ff60fd24b7f3..5f1843c628052f5530ad5d5772881ff49a5b30ae 100644 (file)
@@ -137,10 +137,10 @@ bool brw_nir_apply_trig_workarounds(nir_shader *nir);
 
 void brw_nir_apply_tcs_quads_workaround(nir_shader *nir);
 
-void brw_nir_apply_sampler_key(nir_shader *nir,
-                               const struct brw_compiler *compiler,
-                               const struct brw_sampler_prog_key_data *key,
-                               bool is_scalar);
+void brw_nir_apply_key(nir_shader *nir,
+                       const struct brw_compiler *compiler,
+                       const struct brw_base_prog_key *key,
+                       bool is_scalar);
 
 enum brw_reg_type brw_type_for_nir_type(const struct gen_device_info *devinfo,
                                         nir_alu_type type);
index 8403f19b831a5ead0c931080395880f461af96de..686c5c3a46d012c350e1f5bf80ed6c862fa77627 100644 (file)
@@ -1244,7 +1244,7 @@ brw_compile_tes(const struct brw_compiler *compiler,
    nir->info.inputs_read = key->inputs_read;
    nir->info.patch_inputs_read = key->patch_inputs_read;
 
-   brw_nir_apply_sampler_key(nir, compiler, &key->base.tex, is_scalar);
+   brw_nir_apply_key(nir, compiler, &key->base, is_scalar);
    brw_nir_lower_tes_inputs(nir, input_vue_map);
    brw_nir_lower_vue_outputs(nir);
    brw_postprocess_nir(nir, compiler, is_scalar);
index 16ae576de3723abc823dadb091c15b86a17b1961..5f7decd5410f7990118407ce8bd0e495fb40851a 100644 (file)
@@ -2845,7 +2845,7 @@ brw_compile_vs(const struct brw_compiler *compiler, void *log_data,
                char **error_str)
 {
    const bool is_scalar = compiler->scalar_stage[MESA_SHADER_VERTEX];
-   brw_nir_apply_sampler_key(shader, compiler, &key->base.tex, is_scalar);
+   brw_nir_apply_key(shader, compiler, &key->base, is_scalar);
 
    const unsigned *assembly = NULL;
 
index 208c0161657abf64f28f4cec487b454dc8c88b88..c45e284e07e940062673b84c3787e7c83280f220 100644 (file)
@@ -639,7 +639,7 @@ brw_compile_gs(const struct brw_compiler *compiler, void *log_data,
                        &c.input_vue_map, inputs_read,
                        shader->info.separate_shader);
 
-   brw_nir_apply_sampler_key(shader, compiler, &key->base.tex, is_scalar);
+   brw_nir_apply_key(shader, compiler, &key->base, is_scalar);
    brw_nir_lower_vue_inputs(shader, &c.input_vue_map);
    brw_nir_lower_vue_outputs(shader);
    brw_postprocess_nir(shader, compiler, is_scalar);
index b8f2a3bde0a0d052b5f4034994d15183ccf1ea63..d82439f277187416ee1929323591e3f7739c0057 100644 (file)
@@ -397,7 +397,7 @@ brw_compile_tcs(const struct brw_compiler *compiler,
                             nir->info.outputs_written,
                             nir->info.patch_outputs_written);
 
-   brw_nir_apply_sampler_key(nir, compiler, &key->base.tex, is_scalar);
+   brw_nir_apply_key(nir, compiler, &key->base, is_scalar);
    brw_nir_lower_vue_inputs(nir, &input_vue_map);
    brw_nir_lower_tcs_outputs(nir, &vue_prog_data->vue_map,
                              key->tes_primitive_mode);