diff --git a/src/intel/compiler/brw_compiler.h b/src/intel/compiler/brw_compiler.h index 10d27120e05..bce586e98bc 100644 --- a/src/intel/compiler/brw_compiler.h +++ b/src/intel/compiler/brw_compiler.h @@ -1777,6 +1777,29 @@ brw_cs_right_mask(unsigned group_size, unsigned 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 * relevant fixed function starting from channel 0 of the SIMD thread, which diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp index a876aa42d0c..61251f44a0b 100644 --- a/src/intel/compiler/brw_fs.cpp +++ b/src/intel/compiler/brw_fs.cpp @@ -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,