MCPcopy Create free account
hub / github.com/a2flo/floor / execute

Method execute

src/device/vulkan/vulkan_function.cpp:274–515  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

272}
273
274void vulkan_function::execute(const device_queue& cqueue,
275 vulkan_command_buffer* external_cmd_buffer,
276 const bool& is_cooperative,
277 const bool& wait_until_completion,
278 const uint32_t& dim floor_unused,
279 const uint3& global_work_size,
280 const uint3& local_work_size_,
281 const std::vector<device_function_arg>& args,
282 const std::vector<const device_fence*>& wait_fences_,
283 const std::vector<device_fence*>& signal_fences_,
284 const char* debug_label,
285 kernel_completion_handler_f&& completion_handler) const {
286 // no cooperative support yet
287 if (is_cooperative) {
288 log_error("cooperative kernel execution is not supported for Vulkan");
289 return;
290 }
291
292 // find entry for queue device
293 const auto function_iter = get_function(cqueue);
294 if (function_iter == functions.cend()) {
295 log_error("no function \"$\" for this compute queue/device exists!", function_name);
296 return;
297 }
298
299 const auto& vk_dev = *function_iter->first;
300 const auto& vk_queue = (const vulkan_queue&)cqueue;
301
302 // check work size
303 const uint3 block_dim = check_local_work_size(*function_iter->second, local_work_size_);
304 if (function_iter->second->info->has_valid_required_local_size() &&
305 (function_iter->second->info->required_local_size != local_work_size_.maxed(1u)).any()) {
306 log_error("function $ has fixed compiled required local size of $, it may not be executed with a different local size of $",
307 function_iter->second->info->name, function_iter->second->info->required_local_size, local_work_size_);
308 return;
309 }
310
311 const uint3 grid_dim_overflow {
312 global_work_size.x > 0 ? std::min(uint32_t(global_work_size.x % block_dim.x), 1u) : 0u,
313 global_work_size.y > 0 ? std::min(uint32_t(global_work_size.y % block_dim.y), 1u) : 0u,
314 global_work_size.z > 0 ? std::min(uint32_t(global_work_size.z % block_dim.z), 1u) : 0u
315 };
316 uint3 grid_dim { (global_work_size / block_dim) + grid_dim_overflow };
317 grid_dim.max(1u);
318
319 // create command buffer ("encoder") for this function execution
320 const std::vector<const vulkan_function_entry*> shader_entries {
321 function_iter->second.get()
322 };
323 bool encoder_success = false;
324 auto encoder = create_encoder(cqueue, external_cmd_buffer,
325 get_pipeline_spec(vk_dev, *function_iter->second, block_dim, {} /* use default or program defined */),
326 function_iter->second->pipeline_layout,
327 shader_entries, debug_label, encoder_success);
328 if (!encoder_success) {
329 log_error("failed to create Vulkan encoder / command buffer for function \"$\"", function_iter->second->info->name);
330 return;
331 }

Callers

nothing calls this directly

Calls 15

allocate_printf_bufferFunction · 0.85
initialize_printf_bufferFunction · 0.85
set_and_handle_argumentsFunction · 0.85
handle_printf_bufferFunction · 0.85
get_queue_typeMethod · 0.80
submit_command_bufferMethod · 0.80
releaseMethod · 0.80
minFunction · 0.50

Tested by

no test coverage detected