broadcom/compiler: don't call nir_opt_load_store_vectorize on all v3d_optimize_nir calls

For compute shaders, to avoid a crash with that optimization, it requires
doing some optimizations and lowerings before. Example:

  static void
  lower_cs_shared(struct nir_shader *nir)
  {
     NIR_PASS_V(nir, nir_lower_vars_to_explicit_types,
                nir_var_mem_shared, shared_type_info);
     NIR_PASS_V(nir, nir_lower_explicit_io,
                nir_var_mem_shared, nir_address_format_32bit_offset);
  }

In the same way other drivers (like anv) calls
nir_opt_load_store_vectorize as part of their post-process-nir.

So one option would be to move nir_opt_load_store_vectorize outsize
the common v3d_nir_optimize, to a post-process nir method.

To make things simpler, this change calls that optimization only if we
have a v3d_compiler object, that is when each frontend has already
done their lowerings, and call the v3d_compiler to get the final
assembly (so we are already on a kind of post processing nir step).

This avoids dEQP-VK.memory_model.shared.basic_types.3 crashing if we
start to call v3d_optimize_nir on v3dv directly.

Slight shaderdb changes, but not significant.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17185>
This commit is contained in:
Alejandro Piñeiro 2022-06-13 14:26:17 +02:00 committed by Marge Bot
parent 16287ff87d
commit ec10a37a52

View file

@ -2164,12 +2164,22 @@ v3d_optimize_nir(struct v3d_compile *c, struct nir_shader *s)
.robust_modes = 0,
};
bool vectorize_progress = false;
NIR_PASS(vectorize_progress, s, nir_opt_load_store_vectorize,
&vectorize_opts);
if (vectorize_progress) {
NIR_PASS(progress, s, nir_lower_alu_to_scalar, NULL, NULL);
NIR_PASS(progress, s, nir_lower_pack);
progress = true;
/* This requires that we have called
* nir_lower_vars_to_explicit_types / nir_lower_explicit_io
* first, which we may not have done yet if we call here too
* early durign NIR pre-processing. We can detect this because
* in that case we won't have a compile object
*/
if (c) {
NIR_PASS(vectorize_progress, s, nir_opt_load_store_vectorize,
&vectorize_opts);
if (vectorize_progress) {
NIR_PASS(progress, s, nir_lower_alu_to_scalar, NULL, NULL);
NIR_PASS(progress, s, nir_lower_pack);
progress = true;
}
}
if (lower_flrp != 0) {