| 690 | } |
| 691 | |
| 692 | void vulkan_queue::execute_indirect(const indirect_command_pipeline& indirect_cmd, |
| 693 | const indirect_execution_parameters_t& params, |
| 694 | kernel_completion_handler_f&& completion_handler, |
| 695 | const uint32_t command_offset, |
| 696 | const uint32_t command_count) const { |
| 697 | if (command_count == 0) { |
| 698 | return; |
| 699 | } |
| 700 | |
| 701 | #if defined(FLOOR_DEBUG) |
| 702 | if (indirect_cmd.get_description().command_type != indirect_command_description::COMMAND_TYPE::COMPUTE) { |
| 703 | log_error("specified indirect command pipeline \"$\" must be a compute pipeline", |
| 704 | indirect_cmd.get_description().debug_label); |
| 705 | return; |
| 706 | } |
| 707 | #endif |
| 708 | |
| 709 | const auto& vk_indirect_cmd = (const vulkan_indirect_command_pipeline&)indirect_cmd; |
| 710 | const auto vk_indirect_pipeline_entry = vk_indirect_cmd.get_vulkan_pipeline_entry(dev); |
| 711 | if (!vk_indirect_pipeline_entry) { |
| 712 | log_error("no indirect command pipeline state for device \"$\" in indirect command pipeline \"$\"", |
| 713 | dev.name, indirect_cmd.get_description().debug_label); |
| 714 | return; |
| 715 | } |
| 716 | |
| 717 | const auto range = vk_indirect_cmd.compute_and_validate_command_range(command_offset, command_count); |
| 718 | if (!range) { |
| 719 | return; |
| 720 | } |
| 721 | |
| 722 | // create and setup the compute encoder (primary command buffer) |
| 723 | const auto encoder_label = params.debug_label ? params.debug_label : "indirect_encoder"; |
| 724 | auto cmd_buffer = make_command_buffer(encoder_label); |
| 725 | if (!cmd_buffer.cmd_buffer) { |
| 726 | return; |
| 727 | } |
| 728 | const VkCommandBufferBeginInfo begin_info { |
| 729 | .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, |
| 730 | .pNext = nullptr, |
| 731 | .flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, |
| 732 | .pInheritanceInfo = nullptr, |
| 733 | }; |
| 734 | VK_CALL_RET(vkBeginCommandBuffer(cmd_buffer.cmd_buffer, &begin_info), |
| 735 | "failed to begin command buffer") |
| 736 | |
| 737 | #if defined(FLOOR_DEBUG) |
| 738 | vulkan_insert_cmd_debug_label(cmd_buffer.cmd_buffer, encoder_label); |
| 739 | #endif |
| 740 | |
| 741 | if (vk_indirect_pipeline_entry->printf_buffer) { |
| 742 | vk_indirect_pipeline_entry->printf_init(*this); |
| 743 | } |
| 744 | |
| 745 | const auto queue_data_index = (queue_type == QUEUE_TYPE::ALL ? 0u : 1u); |
| 746 | vkCmdExecuteCommands(cmd_buffer.cmd_buffer, range->count, |
| 747 | &vk_indirect_pipeline_entry->per_queue_data[queue_data_index].cmd_buffers[range->offset]); |
| 748 | |
| 749 | // all done here, end + submit |
nothing calls this directly
no test coverage detected