intel/compiler: Add common function for CS dispatch info

We have this small calculations repeated in each Intel driver, so move
them to a single place to be reused.  Also includes "right_mask" since
is always used in the same context and depends on the dispatch info
values.

Reviewed-by: Marcin Ślusarz <marcin.slusarz@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10504>
This commit is contained in:
Caio Marcelo de Oliveira Filho
2021-04-28 10:54:53 -07:00
parent 7cc846788c
commit 5cc758558d
2 changed files with 48 additions and 0 deletions
+25
View File
@@ -9845,6 +9845,31 @@ brw_cs_simd_size_for_group_size(const struct intel_device_info *devinfo,
return 32;
}
struct brw_cs_dispatch_info
brw_cs_get_dispatch_info(const struct intel_device_info *devinfo,
const struct brw_cs_prog_data *prog_data,
const unsigned *override_local_size)
{
struct brw_cs_dispatch_info info = {};
const unsigned *sizes =
override_local_size ? override_local_size :
prog_data->local_size;
info.group_size = sizes[0] * sizes[1] * sizes[2];
info.simd_size =
brw_cs_simd_size_for_group_size(devinfo, prog_data, info.group_size);
info.threads = DIV_ROUND_UP(info.group_size, info.simd_size);
const uint32_t remainder = info.group_size & (info.simd_size - 1);
if (remainder > 0)
info.right_mask = ~0u >> (32 - remainder);
else
info.right_mask = ~0u >> (32 - info.simd_size);
return info;
}
const unsigned *
brw_compile_bs(const struct brw_compiler *compiler, void *log_data,
void *mem_ctx,