diff options
author | Karol Herbst <[email protected]> | 2017-12-10 20:39:23 +0100 |
---|---|---|
committer | Karol Herbst <[email protected]> | 2019-03-17 10:33:28 +0100 |
commit | 9298664a5f8e81af6f7cd8bc1493c6d5a6b4ddb4 (patch) | |
tree | 656fd394dcb54ab3f73b57dc8faf2915fb30fe3a /src/gallium/drivers/nouveau | |
parent | 78c5336ca9b37e59ecb3d8f44c988dc87d595b9b (diff) |
nv50/ir/nir: run some passes to make the conversion easier
v2: add constant_folding
v6: print non final NIR only for verbose debugging
v8: add passes we will need for OpenCL compute shaders
v9: move type_size into anonymous namespace
convert to C++ style comments
lower bools to int32
Signed-off-by: Karol Herbst <[email protected]>
Acked-by: Pierre Moreau <[email protected]>
Diffstat (limited to 'src/gallium/drivers/nouveau')
-rw-r--r-- | src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp index b22c62fd434..9d2d16b97f5 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp @@ -35,6 +35,12 @@ namespace { using namespace nv50_ir; +int +type_size(const struct glsl_type *type) +{ + return glsl_count_attribute_slots(type, false); +} + class Converter : public ConverterCommon { public: @@ -52,6 +58,42 @@ Converter::Converter(Program *prog, nir_shader *nir, nv50_ir_prog_info *info) bool Converter::run() { + bool progress; + + if (prog->dbgFlags & NV50_IR_DEBUG_VERBOSE) + nir_print_shader(nir, stderr); + + NIR_PASS_V(nir, nir_lower_io, nir_var_all, type_size, (nir_lower_io_options)0); + NIR_PASS_V(nir, nir_lower_regs_to_ssa); + NIR_PASS_V(nir, nir_lower_load_const_to_scalar); + NIR_PASS_V(nir, nir_lower_vars_to_ssa); + NIR_PASS_V(nir, nir_lower_alu_to_scalar); + NIR_PASS_V(nir, nir_lower_phis_to_scalar); + + do { + progress = false; + NIR_PASS(progress, nir, nir_copy_prop); + NIR_PASS(progress, nir, nir_opt_remove_phis); + NIR_PASS(progress, nir, nir_opt_trivial_continues); + NIR_PASS(progress, nir, nir_opt_cse); + NIR_PASS(progress, nir, nir_opt_algebraic); + NIR_PASS(progress, nir, nir_opt_constant_folding); + NIR_PASS(progress, nir, nir_copy_prop); + NIR_PASS(progress, nir, nir_opt_dce); + NIR_PASS(progress, nir, nir_opt_dead_cf); + } while (progress); + + NIR_PASS_V(nir, nir_lower_bool_to_int32); + NIR_PASS_V(nir, nir_lower_locals_to_regs); + NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_function_temp); + NIR_PASS_V(nir, nir_convert_from_ssa, true); + + // Garbage collect dead instructions + nir_sweep(nir); + + if (prog->dbgFlags & NV50_IR_DEBUG_BASIC) + nir_print_shader(nir, stderr); + return false; } |