diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2016-05-29 10:21:21 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2016-05-29 10:21:21 +0000 |
commit | 99b70277b7a71ca729b7723c0be213c9db46702c (patch) | |
tree | 756afa5d954f14d117bad3856a5eb9d5ab1b1a0d /lib/mesa/src/gallium/drivers/freedreno/ir3 | |
parent | 3e40341f9dcd7c1bbc9afb8ddb812304820396cf (diff) |
Import Mesa 11.2.2
Diffstat (limited to 'lib/mesa/src/gallium/drivers/freedreno/ir3')
-rw-r--r-- | lib/mesa/src/gallium/drivers/freedreno/ir3/ir3_nir.c | 90 |
1 files changed, 27 insertions, 63 deletions
diff --git a/lib/mesa/src/gallium/drivers/freedreno/ir3/ir3_nir.c b/lib/mesa/src/gallium/drivers/freedreno/ir3/ir3_nir.c index 336fa95ee..565b9c32c 100644 --- a/lib/mesa/src/gallium/drivers/freedreno/ir3/ir3_nir.c +++ b/lib/mesa/src/gallium/drivers/freedreno/ir3/ir3_nir.c @@ -35,43 +35,27 @@ #include "nir/tgsi_to_nir.h" -static const nir_shader_compiler_options options = { - .lower_fpow = true, - .lower_fsat = true, - .lower_scmp = true, - .lower_flrp32 = true, - .lower_flrp64 = true, - .lower_ffract = true, - .lower_fmod32 = true, - .lower_fmod64 = true, - .lower_fdiv = true, - .fuse_ffma = true, - .native_integers = true, - .vertex_id_zero_based = true, - .lower_extract_byte = true, - .lower_extract_word = true, -}; - struct nir_shader * ir3_tgsi_to_nir(const struct tgsi_token *tokens) { + static const nir_shader_compiler_options options = { + .lower_fpow = true, + .lower_fsat = true, + .lower_scmp = true, + .lower_flrp = true, + .lower_ffract = true, + .native_integers = true, + }; return tgsi_to_nir(tokens, &options); } -const nir_shader_compiler_options * -ir3_get_compiler_options(void) -{ - return &options; -} - /* for given shader key, are any steps handled in nir? */ bool ir3_key_lowers_nir(const struct ir3_shader_key *key) { return key->fsaturate_s | key->fsaturate_t | key->fsaturate_r | key->vsaturate_s | key->vsaturate_t | key->vsaturate_r | - key->ucp_enables | key->color_two_side | - key->fclamp_color | key->vclamp_color; + key->ucp_enables | key->color_two_side; } #define OPT(nir, pass, ...) ({ \ @@ -82,27 +66,6 @@ ir3_key_lowers_nir(const struct ir3_shader_key *key) #define OPT_V(nir, pass, ...) NIR_PASS_V(nir, pass, ##__VA_ARGS__) -static void -ir3_optimize_loop(nir_shader *s) -{ - bool progress; - do { - progress = false; - - OPT_V(s, nir_lower_vars_to_ssa); - progress |= OPT(s, nir_lower_alu_to_scalar); - progress |= OPT(s, nir_lower_phis_to_scalar); - - progress |= OPT(s, nir_copy_prop); - progress |= OPT(s, nir_opt_dce); - progress |= OPT(s, nir_opt_cse); - progress |= OPT(s, ir3_nir_lower_if_else); - progress |= OPT(s, nir_opt_algebraic); - progress |= OPT(s, nir_opt_constant_folding); - - } while (progress); -} - struct nir_shader * ir3_optimize_nir(struct ir3_shader *shader, nir_shader *s, const struct ir3_shader_key *key) @@ -110,6 +73,7 @@ ir3_optimize_nir(struct ir3_shader *shader, nir_shader *s, struct nir_lower_tex_options tex_options = { .lower_rect = 0, }; + bool progress; if (key) { switch (shader->type) { @@ -142,40 +106,40 @@ ir3_optimize_nir(struct ir3_shader *shader, nir_shader *s, } OPT_V(s, nir_opt_global_to_local); - OPT_V(s, nir_lower_regs_to_ssa); + OPT_V(s, nir_convert_to_ssa); if (key) { if (s->stage == MESA_SHADER_VERTEX) { OPT_V(s, nir_lower_clip_vs, key->ucp_enables); - if (key->vclamp_color) - OPT_V(s, nir_lower_clamp_color_outputs); } else if (s->stage == MESA_SHADER_FRAGMENT) { OPT_V(s, nir_lower_clip_fs, key->ucp_enables); - if (key->fclamp_color) - OPT_V(s, nir_lower_clamp_color_outputs); } if (key->color_two_side) { OPT_V(s, nir_lower_two_sided_color); } - } else { - /* only want to do this the first time (when key is null) - * and not again on any potential 2nd variant lowering pass: - */ - OPT_V(s, ir3_nir_apply_trig_workarounds); } OPT_V(s, nir_lower_tex, &tex_options); + OPT_V(s, nir_lower_idiv); OPT_V(s, nir_lower_load_const_to_scalar); - ir3_optimize_loop(s); + do { + progress = false; + + OPT_V(s, nir_lower_vars_to_ssa); + OPT_V(s, nir_lower_alu_to_scalar); + OPT_V(s, nir_lower_phis_to_scalar); - /* do idiv lowering after first opt loop to give a chance for - * divide by immed power-of-two to be caught first: - */ - if (OPT(s, nir_lower_idiv)) - ir3_optimize_loop(s); + progress |= OPT(s, nir_copy_prop); + progress |= OPT(s, nir_opt_dce); + progress |= OPT(s, nir_opt_cse); + progress |= OPT(s, ir3_nir_lower_if_else); + progress |= OPT(s, nir_opt_algebraic); + progress |= OPT(s, nir_opt_constant_folding); + + } while (progress); - OPT_V(s, nir_remove_dead_variables, nir_var_local); + OPT_V(s, nir_remove_dead_variables); if (fd_mesa_debug & FD_DBG_DISASM) { debug_printf("----------------------\n"); |