radv,ac/nir: split global access using nir_lower_mem_access_bit_sizes

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31904>
This commit is contained in:
Rhys Perry 2024-10-24 14:15:58 +01:00 committed by Marge Bot
parent 17cc8a5a54
commit 7d4cc04156
2 changed files with 7 additions and 5 deletions

View file

@ -1758,8 +1758,13 @@ lower_mem_access_cb(nir_intrinsic_op intrin, uint8_t bytes, uint8_t bit_size, ui
if (is_load && bit_size == 8 && combined_align >= 2 && bytes % 2 == 0)
bit_size = 16;
unsigned max_components = 4;
if (cb_data->use_llvm && access & (ACCESS_COHERENT | ACCESS_VOLATILE) &&
(intrin == nir_intrinsic_load_global || intrin == nir_intrinsic_store_global))
max_components = 1;
nir_mem_access_size_align res;
res.num_components = MIN2(bytes / (bit_size / 8), 4);
res.num_components = MIN2(bytes / (bit_size / 8), max_components);
res.bit_size = bit_size;
res.align = MIN2(bit_size / 8, 4); /* 64-bit access only requires 4 byte alignment. */
res.shift = nir_mem_access_shift_method_shift64;
@ -1791,7 +1796,7 @@ lower_mem_access_cb(nir_intrinsic_op intrin, uint8_t bytes, uint8_t bit_size, ui
} else {
res.num_components = DIV_ROUND_UP(bytes + max_pad, 4);
}
res.num_components = MIN2(res.num_components, 4);
res.num_components = MIN2(res.num_components, max_components);
res.bit_size = 32;
res.align = 4;
res.shift = is_smem ? res.shift : nir_mem_access_shift_method_bytealign_amd;

View file

@ -563,9 +563,6 @@ radv_postprocess_nir(struct radv_device *device, const struct radv_graphics_stat
.allow_fp16 = gfx_level >= GFX9,
});
if (radv_use_llvm_for_stage(pdev, stage->stage))
NIR_PASS_V(stage->nir, nir_lower_io_to_scalar, nir_var_mem_global, NULL, NULL);
NIR_PASS(_, stage->nir, ac_nir_lower_global_access);
NIR_PASS_V(stage->nir, ac_nir_lower_intrinsics_to_args, gfx_level, radv_select_hw_stage(&stage->info, gfx_level),
&stage->args.ac);