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:
@@ -1777,6 +1777,29 @@ brw_cs_right_mask(unsigned group_size, unsigned simd_size)
|
|||||||
return ~0u >> (32 - simd_size);
|
return ~0u >> (32 - simd_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct brw_cs_dispatch_info {
|
||||||
|
uint32_t group_size;
|
||||||
|
uint32_t simd_size;
|
||||||
|
uint32_t threads;
|
||||||
|
|
||||||
|
/* RightExecutionMask field used in GPGPU_WALKER. */
|
||||||
|
uint32_t right_mask;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the dispatch information for a shader to be used with GPGPU_WALKER and
|
||||||
|
* similar instructions.
|
||||||
|
*
|
||||||
|
* If override_local_size is not NULL, it must to point to a 3-element that
|
||||||
|
* will override the value from prog_data->local_size. This is used by
|
||||||
|
* ARB_compute_variable_group_size, where the size is set only at dispatch
|
||||||
|
* time (so prog_data is outdated).
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if the given shader stage is dispatched contiguously by the
|
* Return true if the given shader stage is dispatched contiguously by the
|
||||||
* relevant fixed function starting from channel 0 of the SIMD thread, which
|
* relevant fixed function starting from channel 0 of the SIMD thread, which
|
||||||
|
@@ -9845,6 +9845,31 @@ brw_cs_simd_size_for_group_size(const struct intel_device_info *devinfo,
|
|||||||
return 32;
|
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 *
|
const unsigned *
|
||||||
brw_compile_bs(const struct brw_compiler *compiler, void *log_data,
|
brw_compile_bs(const struct brw_compiler *compiler, void *log_data,
|
||||||
void *mem_ctx,
|
void *mem_ctx,
|
||||||
|
Reference in New Issue
Block a user