Sergey Ulanov | 730a7f0 | 2019-04-02 20:49:37 | [diff] [blame] | 1 | // Copyright 2019 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | // |
| 5 | // This file defines some helper functions for Vulkan API. |
| 6 | |
| 7 | #ifndef GPU_VULKAN_VULKAN_UTIL_H_ |
| 8 | #define GPU_VULKAN_VULKAN_UTIL_H_ |
| 9 | |
| 10 | #include <vulkan/vulkan.h> |
| 11 | |
| 12 | #include <memory> |
| 13 | #include <vector> |
| 14 | |
Peng Huang | 96962eabf | 2019-04-24 03:48:30 | [diff] [blame] | 15 | #include "base/containers/span.h" |
Peng Huang | 8f3abd4 | 2020-04-03 20:07:24 | [diff] [blame^] | 16 | #include "gpu/vulkan/semaphore_handle.h" |
Sergey Ulanov | 730a7f0 | 2019-04-02 20:49:37 | [diff] [blame] | 17 | #include "gpu/vulkan/vulkan_export.h" |
| 18 | |
| 19 | namespace gpu { |
| 20 | |
Peng Huang | 96962eabf | 2019-04-24 03:48:30 | [diff] [blame] | 21 | // Submits semaphores to be signaled to the vulkan queue. Semaphores are |
| 22 | // signaled once this submission is executed. vk_fence is an optional handle |
| 23 | // to fence to be signaled once this submission completes execution. |
| 24 | VULKAN_EXPORT bool SubmitSignalVkSemaphores( |
| 25 | VkQueue vk_queue, |
| 26 | const base::span<VkSemaphore>& vk_semaphore, |
| 27 | VkFence vk_fence = VK_NULL_HANDLE); |
| 28 | |
Sergey Ulanov | 730a7f0 | 2019-04-02 20:49:37 | [diff] [blame] | 29 | // Submits a semaphore to be signaled to the vulkan queue. Semaphore is |
| 30 | // signaled once this submission is executed. vk_fence is an optional handle |
| 31 | // to fence to be signaled once this submission completes execution. |
| 32 | VULKAN_EXPORT bool SubmitSignalVkSemaphore(VkQueue vk_queue, |
| 33 | VkSemaphore vk_semaphore, |
| 34 | VkFence vk_fence = VK_NULL_HANDLE); |
| 35 | |
| 36 | // Submits semaphores to be waited upon to the vulkan queue. Semaphores are |
| 37 | // waited on before this submission is executed. vk_fence is an optional |
| 38 | // handle to fence to be signaled once this submission completes execution. |
| 39 | VULKAN_EXPORT bool SubmitWaitVkSemaphores( |
| 40 | VkQueue vk_queue, |
Peng Huang | 96962eabf | 2019-04-24 03:48:30 | [diff] [blame] | 41 | const base::span<VkSemaphore>& vk_semaphores, |
Sergey Ulanov | 730a7f0 | 2019-04-02 20:49:37 | [diff] [blame] | 42 | VkFence vk_fence = VK_NULL_HANDLE); |
| 43 | |
| 44 | // Submits a semaphore to be waited upon to the vulkan queue. Semaphore is |
| 45 | // waited on before this submission is executed. vk_fence is an optional |
| 46 | // handle to fence to be signaled once this submission completes execution. |
| 47 | VULKAN_EXPORT bool SubmitWaitVkSemaphore(VkQueue vk_queue, |
| 48 | VkSemaphore vk_semaphore, |
| 49 | VkFence vk_fence = VK_NULL_HANDLE); |
| 50 | |
| 51 | // Creates semaphore that can be exported to external handles of the specified |
| 52 | // |handle_types|. |
| 53 | VULKAN_EXPORT VkSemaphore |
| 54 | CreateExternalVkSemaphore(VkDevice vk_device, |
| 55 | VkExternalSemaphoreHandleTypeFlags handle_types); |
| 56 | |
Peng Huang | 8f3abd4 | 2020-04-03 20:07:24 | [diff] [blame^] | 57 | // Imports a semaphore from a handle. |
| 58 | VULKAN_EXPORT VkSemaphore ImportVkSemaphoreHandle(VkDevice vk_device, |
| 59 | SemaphoreHandle handle); |
| 60 | |
| 61 | // Gets a handle from a semaphore |
| 62 | VULKAN_EXPORT SemaphoreHandle |
| 63 | GetVkSemaphoreHandle(VkDevice vk_device, |
| 64 | VkSemaphore vk_semaphore, |
| 65 | VkExternalSemaphoreHandleTypeFlagBits handle_type); |
| 66 | |
Sergey Ulanov | 730a7f0 | 2019-04-02 20:49:37 | [diff] [blame] | 67 | } // namespace gpu |
| 68 | |
| 69 | #endif // GPU_VULKAN_VULKAN_UTIL_H_ |