diff options
author | Jason Ekstrand <[email protected]> | 2019-02-22 11:15:21 -0600 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2019-07-24 12:55:40 -0500 |
commit | f62227f2b7c4d69b9e0e3cd1e61c5959459a8334 (patch) | |
tree | 6867e2374b330865fe6cca155def8c48f8293fdd /src | |
parent | 87cef718e17bce15f1730beab74e414326992332 (diff) |
intel/nir: Make brw_nir_apply_sampler_key more generic
Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/intel/compiler/brw_fs.cpp | 4 | ||||
-rw-r--r-- | src/intel/compiler/brw_nir.c | 22 | ||||
-rw-r--r-- | src/intel/compiler/brw_nir.h | 8 | ||||
-rw-r--r-- | src/intel/compiler/brw_shader.cpp | 2 | ||||
-rw-r--r-- | src/intel/compiler/brw_vec4.cpp | 2 | ||||
-rw-r--r-- | src/intel/compiler/brw_vec4_gs_visitor.cpp | 2 | ||||
-rw-r--r-- | src/intel/compiler/brw_vec4_tcs.cpp | 2 |
7 files changed, 26 insertions, 16 deletions
diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp index 25e4dd9971c..30e04ddc318 100644 --- a/src/intel/compiler/brw_fs.cpp +++ b/src/intel/compiler/brw_fs.cpp @@ -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); diff --git a/src/intel/compiler/brw_nir.c b/src/intel/compiler/brw_nir.c index ae81c65b94a..62e5eb7c726 100644 --- a/src/intel/compiler/brw_nir.c +++ b/src/intel/compiler/brw_nir.c @@ -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 diff --git a/src/intel/compiler/brw_nir.h b/src/intel/compiler/brw_nir.h index 895b63bc497..5f1843c6280 100644 --- a/src/intel/compiler/brw_nir.h +++ b/src/intel/compiler/brw_nir.h @@ -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); diff --git a/src/intel/compiler/brw_shader.cpp b/src/intel/compiler/brw_shader.cpp index 8403f19b831..686c5c3a46d 100644 --- a/src/intel/compiler/brw_shader.cpp +++ b/src/intel/compiler/brw_shader.cpp @@ -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); diff --git a/src/intel/compiler/brw_vec4.cpp b/src/intel/compiler/brw_vec4.cpp index 16ae576de37..5f7decd5410 100644 --- a/src/intel/compiler/brw_vec4.cpp +++ b/src/intel/compiler/brw_vec4.cpp @@ -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; diff --git a/src/intel/compiler/brw_vec4_gs_visitor.cpp b/src/intel/compiler/brw_vec4_gs_visitor.cpp index 208c0161657..c45e284e07e 100644 --- a/src/intel/compiler/brw_vec4_gs_visitor.cpp +++ b/src/intel/compiler/brw_vec4_gs_visitor.cpp @@ -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); diff --git a/src/intel/compiler/brw_vec4_tcs.cpp b/src/intel/compiler/brw_vec4_tcs.cpp index b8f2a3bde0a..d82439f2771 100644 --- a/src/intel/compiler/brw_vec4_tcs.cpp +++ b/src/intel/compiler/brw_vec4_tcs.cpp @@ -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); |