blob: 3aa3a12e1406c0a43a9c324aa9708160680d09d8 [file] [log] [blame]
Sergey Ulanov730a7f02019-04-02 20:49:371// 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 Huang96962eabf2019-04-24 03:48:3015#include "base/containers/span.h"
Peng Huang8f3abd42020-04-03 20:07:2416#include "gpu/vulkan/semaphore_handle.h"
Sergey Ulanov730a7f02019-04-02 20:49:3717#include "gpu/vulkan/vulkan_export.h"
18
19namespace gpu {
20
Peng Huang96962eabf2019-04-24 03:48:3021// 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.
24VULKAN_EXPORT bool SubmitSignalVkSemaphores(
25 VkQueue vk_queue,
26 const base::span<VkSemaphore>& vk_semaphore,
27 VkFence vk_fence = VK_NULL_HANDLE);
28
Sergey Ulanov730a7f02019-04-02 20:49:3729// 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.
32VULKAN_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.
39VULKAN_EXPORT bool SubmitWaitVkSemaphores(
40 VkQueue vk_queue,
Peng Huang96962eabf2019-04-24 03:48:3041 const base::span<VkSemaphore>& vk_semaphores,
Sergey Ulanov730a7f02019-04-02 20:49:3742 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.
47VULKAN_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|.
53VULKAN_EXPORT VkSemaphore
54CreateExternalVkSemaphore(VkDevice vk_device,
55 VkExternalSemaphoreHandleTypeFlags handle_types);
56
Peng Huang8f3abd42020-04-03 20:07:2457// Imports a semaphore from a handle.
58VULKAN_EXPORT VkSemaphore ImportVkSemaphoreHandle(VkDevice vk_device,
59 SemaphoreHandle handle);
60
61// Gets a handle from a semaphore
62VULKAN_EXPORT SemaphoreHandle
63GetVkSemaphoreHandle(VkDevice vk_device,
64 VkSemaphore vk_semaphore,
65 VkExternalSemaphoreHandleTypeFlagBits handle_type);
66
Sergey Ulanov730a7f02019-04-02 20:49:3767} // namespace gpu
68
69#endif // GPU_VULKAN_VULKAN_UTIL_H_