aco: prevent invalid loads/stores vectorization if robustness is enabled
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 4 May 2020 14:03:35 +0000 (16:03 +0200)
committerMarge Bot <eric+marge@anholt.net>
Mon, 11 May 2020 07:25:16 +0000 (07:25 +0000)
Only UBO, SSBO, global and push constants accesses should matter.

This fixes a bunch of new robustness2 failures. Note that RADV/LLVM
isn't affected because it relies on LLVM for loads/stores
vectorization and LLVM doesn't vectorize in this situation as well.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4881>

src/amd/compiler/aco_instruction_selection_setup.cpp

index f1fde789e7b2787707f2d08c26ce05f361307960..44659b462294cf40f293a580d5f58100d8851180 100644 (file)
@@ -994,12 +994,20 @@ setup_nir(isel_context *ctx, nir_shader *nir)
 
    bool lower_to_scalar = false;
    bool lower_pack = false;
+   nir_variable_mode robust_modes = (nir_variable_mode)0;
+
+   if (ctx->options->robust_buffer_access) {
+      robust_modes = (nir_variable_mode)(nir_var_mem_ubo |
+                                         nir_var_mem_ssbo |
+                                         nir_var_mem_global |
+                                         nir_var_mem_push_const);
+   }
+
    if (nir_opt_load_store_vectorize(nir,
                                     (nir_variable_mode)(nir_var_mem_ssbo | nir_var_mem_ubo |
                                                         nir_var_mem_push_const | nir_var_mem_shared |
                                                         nir_var_mem_global),
-                                    mem_vectorize_callback,
-                                    (nir_variable_mode)0)) {
+                                    mem_vectorize_callback, robust_modes)) {
       lower_to_scalar = true;
       lower_pack = true;
    }