X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fintel%2Fcompiler%2Fbrw_nir.c;h=dbddef0d04d93ef3f5d2a5e9372b82aa8606110c;hb=c0ef14f5b1a59d016369a0d3322b9e783009b308;hp=5ed36fe1bf7f2546948c25a01e6371aba6793cf2;hpb=ab9220edd69fcb7016e15d4d96186eac524b45a4;p=mesa.git diff --git a/src/intel/compiler/brw_nir.c b/src/intel/compiler/brw_nir.c index 5ed36fe1bf7..dbddef0d04d 100644 --- a/src/intel/compiler/brw_nir.c +++ b/src/intel/compiler/brw_nir.c @@ -211,7 +211,6 @@ remap_patch_urb_offsets(nir_block *block, nir_builder *b, void brw_nir_lower_vs_inputs(nir_shader *nir, - bool use_legacy_snorm_formula, const uint8_t *vs_attrib_wa_flags) { /* Start with the location of the variable's base. */ @@ -230,8 +229,7 @@ brw_nir_lower_vs_inputs(nir_shader *nir, add_const_offset_to_base(nir, nir_var_shader_in); - brw_nir_apply_attribute_workarounds(nir, use_legacy_snorm_formula, - vs_attrib_wa_flags); + brw_nir_apply_attribute_workarounds(nir, vs_attrib_wa_flags); /* The last step is to remap VERT_ATTRIB_* to actual registers */ @@ -521,18 +519,29 @@ brw_nir_lower_cs_shared(nir_shader *nir) this_progress; \ }) -nir_shader * -brw_nir_optimize(nir_shader *nir, const struct brw_compiler *compiler, - bool is_scalar) +static nir_variable_mode +brw_nir_no_indirect_mask(const struct brw_compiler *compiler, + gl_shader_stage stage) { nir_variable_mode indirect_mask = 0; - if (compiler->glsl_compiler_options[nir->info.stage].EmitNoIndirectInput) + + if (compiler->glsl_compiler_options[stage].EmitNoIndirectInput) indirect_mask |= nir_var_shader_in; - if (compiler->glsl_compiler_options[nir->info.stage].EmitNoIndirectOutput) + if (compiler->glsl_compiler_options[stage].EmitNoIndirectOutput) indirect_mask |= nir_var_shader_out; - if (compiler->glsl_compiler_options[nir->info.stage].EmitNoIndirectTemp) + if (compiler->glsl_compiler_options[stage].EmitNoIndirectTemp) indirect_mask |= nir_var_local; + return indirect_mask; +} + +nir_shader * +brw_nir_optimize(nir_shader *nir, const struct brw_compiler *compiler, + bool is_scalar) +{ + nir_variable_mode indirect_mask = + brw_nir_no_indirect_mask(compiler, nir->info.stage); + bool progress; do { progress = false; @@ -648,14 +657,8 @@ brw_preprocess_nir(const struct brw_compiler *compiler, nir_shader *nir) OPT(nir_lower_clip_cull_distance_arrays); - nir_variable_mode indirect_mask = 0; - if (compiler->glsl_compiler_options[nir->info.stage].EmitNoIndirectInput) - indirect_mask |= nir_var_shader_in; - if (compiler->glsl_compiler_options[nir->info.stage].EmitNoIndirectOutput) - indirect_mask |= nir_var_shader_out; - if (compiler->glsl_compiler_options[nir->info.stage].EmitNoIndirectTemp) - indirect_mask |= nir_var_local; - + nir_variable_mode indirect_mask = + brw_nir_no_indirect_mask(compiler, nir->info.stage); nir_lower_indirect_derefs(nir, indirect_mask); nir_lower_int64(nir, nir_lower_imul64 | @@ -670,6 +673,36 @@ brw_preprocess_nir(const struct brw_compiler *compiler, nir_shader *nir) return nir; } +void +brw_nir_link_shaders(const struct brw_compiler *compiler, + nir_shader **producer, nir_shader **consumer) +{ + NIR_PASS_V(*producer, nir_remove_dead_variables, nir_var_shader_out); + NIR_PASS_V(*consumer, nir_remove_dead_variables, nir_var_shader_in); + + if (nir_remove_unused_varyings(*producer, *consumer)) { + NIR_PASS_V(*producer, nir_lower_global_vars_to_local); + NIR_PASS_V(*consumer, nir_lower_global_vars_to_local); + + /* The backend might not be able to handle indirects on + * temporaries so we need to lower indirects on any of the + * varyings we have demoted here. + */ + NIR_PASS_V(*producer, nir_lower_indirect_derefs, + brw_nir_no_indirect_mask(compiler, (*producer)->info.stage)); + NIR_PASS_V(*consumer, nir_lower_indirect_derefs, + brw_nir_no_indirect_mask(compiler, (*consumer)->info.stage)); + + const bool p_is_scalar = + compiler->scalar_stage[(*producer)->info.stage]; + *producer = brw_nir_optimize(*producer, compiler, p_is_scalar); + + const bool c_is_scalar = + compiler->scalar_stage[(*producer)->info.stage]; + *consumer = brw_nir_optimize(*consumer, compiler, c_is_scalar); + } +} + /* Prepare the given shader for codegen * * This function is intended to be called right before going into the actual @@ -808,12 +841,18 @@ brw_type_for_nir_type(const struct gen_device_info *devinfo, nir_alu_type type) case nir_type_float: case nir_type_float32: return BRW_REGISTER_TYPE_F; + case nir_type_float16: + return BRW_REGISTER_TYPE_HF; case nir_type_float64: return BRW_REGISTER_TYPE_DF; case nir_type_int64: return devinfo->gen < 8 ? BRW_REGISTER_TYPE_DF : BRW_REGISTER_TYPE_Q; case nir_type_uint64: return devinfo->gen < 8 ? BRW_REGISTER_TYPE_DF : BRW_REGISTER_TYPE_UQ; + case nir_type_int16: + return BRW_REGISTER_TYPE_W; + case nir_type_uint16: + return BRW_REGISTER_TYPE_UW; default: unreachable("unknown type"); } @@ -832,6 +871,9 @@ brw_glsl_base_type_for_nir_type(nir_alu_type type) case nir_type_float32: return GLSL_TYPE_FLOAT; + case nir_type_float16: + return GLSL_TYPE_FLOAT16; + case nir_type_float64: return GLSL_TYPE_DOUBLE; @@ -843,6 +885,12 @@ brw_glsl_base_type_for_nir_type(nir_alu_type type) case nir_type_uint32: return GLSL_TYPE_UINT; + case nir_type_int16: + return GLSL_TYPE_INT16; + + case nir_type_uint16: + return GLSL_TYPE_UINT16; + default: unreachable("bad type"); }