X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fbroadcom%2Fcompiler%2Fnir_to_vir.c;h=702e4bf15f811e67a542ef57ce9b7d8058927e59;hb=9b96ae69bc7f07d267e880fe77a389c2b944f019;hp=3e82f61d6ea33790b280e779f7ab293427ec6aab;hpb=d41cdef2a591930ad848b27f936aafcafc93b308;p=mesa.git diff --git a/src/broadcom/compiler/nir_to_vir.c b/src/broadcom/compiler/nir_to_vir.c index 3e82f61d6ea..702e4bf15f8 100644 --- a/src/broadcom/compiler/nir_to_vir.c +++ b/src/broadcom/compiler/nir_to_vir.c @@ -827,8 +827,7 @@ ntq_emit_alu(struct v3d_compile *c, nir_alu_instr *instr) struct qreg result; switch (instr->op) { - case nir_op_fmov: - case nir_op_imov: + case nir_op_mov: result = vir_MOV(c, src[0]); break; @@ -1310,7 +1309,7 @@ v3d_optimize_nir(struct nir_shader *s) progress = false; NIR_PASS_V(s, nir_lower_vars_to_ssa); - NIR_PASS(progress, s, nir_lower_alu_to_scalar); + NIR_PASS(progress, s, nir_lower_alu_to_scalar, NULL); NIR_PASS(progress, s, nir_lower_phis_to_scalar); NIR_PASS(progress, s, nir_copy_prop); NIR_PASS(progress, s, nir_opt_remove_phis); @@ -1322,7 +1321,7 @@ v3d_optimize_nir(struct nir_shader *s) NIR_PASS(progress, s, nir_opt_constant_folding); if (lower_flrp != 0) { - bool lower_flrp_progress; + bool lower_flrp_progress = false; NIR_PASS(lower_flrp_progress, s, nir_lower_flrp, lower_flrp, @@ -1454,6 +1453,26 @@ ntq_setup_vpm_inputs(struct v3d_compile *c) } } +static bool +var_needs_point_coord(struct v3d_compile *c, nir_variable *var) +{ + return (var->data.location == VARYING_SLOT_PNTC || + (var->data.location >= VARYING_SLOT_VAR0 && + (c->fs_key->point_sprite_mask & + (1 << (var->data.location - VARYING_SLOT_VAR0))))); +} + +static bool +program_reads_point_coord(struct v3d_compile *c) +{ + nir_foreach_variable(var, &c->s->inputs) { + if (var_needs_point_coord(c, var)) + return true; + } + + return false; +} + static void ntq_setup_fs_inputs(struct v3d_compile *c) { @@ -1487,11 +1506,7 @@ ntq_setup_fs_inputs(struct v3d_compile *c) if (var->data.location == VARYING_SLOT_POS) { emit_fragcoord_input(c, loc); - } else if (var->data.location == VARYING_SLOT_PNTC || - (var->data.location >= VARYING_SLOT_VAR0 && - (c->fs_key->point_sprite_mask & - (1 << (var->data.location - - VARYING_SLOT_VAR0))))) { + } else if (var_needs_point_coord(c, var)) { c->inputs[loc * 4 + 0] = c->point_x; c->inputs[loc * 4 + 1] = c->point_y; } else { @@ -2296,15 +2311,17 @@ nir_to_vir(struct v3d_compile *c) c->payload_w_centroid = vir_MOV(c, vir_reg(QFILE_REG, 1)); c->payload_z = vir_MOV(c, vir_reg(QFILE_REG, 2)); - /* XXX perf: We could set the "disable implicit point/line - * varyings" field in the shader record and not emit these, if - * they're not going to be used. + /* V3D 4.x can disable implicit point coordinate varyings if + * they are not used. */ - if (c->fs_key->is_points) { + if (c->fs_key->is_points && + (c->devinfo->ver < 40 || program_reads_point_coord(c))) { c->point_x = emit_fragment_varying(c, NULL, 0, 0); c->point_y = emit_fragment_varying(c, NULL, 0, 0); - } else if (c->fs_key->is_lines) { + c->uses_implicit_point_line_varyings = true; + } else if (c->fs_key->is_lines && c->devinfo->ver < 40) { c->line_x = emit_fragment_varying(c, NULL, 0, 0); + c->uses_implicit_point_line_varyings = true; } break; case MESA_SHADER_COMPUTE: @@ -2383,6 +2400,7 @@ const nir_shader_compiler_options v3d_nir_options = { .lower_bit_count = true, .lower_cs_local_id_from_index = true, .lower_ffract = true, + .lower_fmod = true, .lower_pack_unorm_2x16 = true, .lower_pack_snorm_2x16 = true, .lower_pack_unorm_4x8 = true,