blob: 1f390615e65cabaec2f8d374a3eab1455ca28dd5 [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
Bruce Dawson4d1542b2021-09-30 20:44:3610#include <vulkan/vulkan_core.h>
Sergey Ulanov730a7f02019-04-02 20:49:3711
12#include <memory>
13#include <vector>
14
Peng Huang0a13bf52020-05-05 16:01:0515#include "base/component_export.h"
Peng Huang96962eabf2019-04-24 03:48:3016#include "base/containers/span.h"
Peng Huang8f3abd42020-04-03 20:07:2417#include "gpu/vulkan/semaphore_handle.h"
Sergey Ulanov730a7f02019-04-02 20:49:3718
19namespace gpu {
20
Jonathan Backer8e498192021-01-18 22:23:2921constexpr uint32_t kVendorARM = 0x13b5;
22constexpr uint32_t kVendorQualcomm = 0x5143;
23constexpr uint32_t kVendorImagination = 0x1010;
24
Peng Huange3df8ba2020-06-19 23:52:0025struct GPUInfo;
26class VulkanInfo;
27
Peng Huang96962eabf2019-04-24 03:48:3028// Submits semaphores to be signaled to the vulkan queue. Semaphores are
29// signaled once this submission is executed. vk_fence is an optional handle
30// to fence to be signaled once this submission completes execution.
Peng Huang0a13bf52020-05-05 16:01:0531COMPONENT_EXPORT(VULKAN)
32bool SubmitSignalVkSemaphores(VkQueue vk_queue,
33 const base::span<VkSemaphore>& vk_semaphore,
34 VkFence vk_fence = VK_NULL_HANDLE);
Peng Huang96962eabf2019-04-24 03:48:3035
Sergey Ulanov730a7f02019-04-02 20:49:3736// Submits a semaphore to be signaled to the vulkan queue. Semaphore is
37// signaled once this submission is executed. vk_fence is an optional handle
38// to fence to be signaled once this submission completes execution.
Peng Huang0a13bf52020-05-05 16:01:0539COMPONENT_EXPORT(VULKAN)
40bool SubmitSignalVkSemaphore(VkQueue vk_queue,
41 VkSemaphore vk_semaphore,
42 VkFence vk_fence = VK_NULL_HANDLE);
Sergey Ulanov730a7f02019-04-02 20:49:3743
44// Submits semaphores to be waited upon to the vulkan queue. Semaphores are
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.
Peng Huang0a13bf52020-05-05 16:01:0547COMPONENT_EXPORT(VULKAN)
48bool SubmitWaitVkSemaphores(VkQueue vk_queue,
49 const base::span<VkSemaphore>& vk_semaphores,
50 VkFence vk_fence = VK_NULL_HANDLE);
Sergey Ulanov730a7f02019-04-02 20:49:3751
52// Submits a semaphore to be waited upon to the vulkan queue. Semaphore is
53// waited on before this submission is executed. vk_fence is an optional
54// handle to fence to be signaled once this submission completes execution.
Peng Huang0a13bf52020-05-05 16:01:0555COMPONENT_EXPORT(VULKAN)
56bool SubmitWaitVkSemaphore(VkQueue vk_queue,
57 VkSemaphore vk_semaphore,
58 VkFence vk_fence = VK_NULL_HANDLE);
Sergey Ulanov730a7f02019-04-02 20:49:3759
60// Creates semaphore that can be exported to external handles of the specified
61// |handle_types|.
Peng Huang0a13bf52020-05-05 16:01:0562COMPONENT_EXPORT(VULKAN)
63VkSemaphore CreateExternalVkSemaphore(
64 VkDevice vk_device,
65 VkExternalSemaphoreHandleTypeFlags handle_types);
Sergey Ulanov730a7f02019-04-02 20:49:3766
Peng Huang8f3abd42020-04-03 20:07:2467// Imports a semaphore from a handle.
Peng Huang0a13bf52020-05-05 16:01:0568COMPONENT_EXPORT(VULKAN)
69VkSemaphore ImportVkSemaphoreHandle(VkDevice vk_device, SemaphoreHandle handle);
Peng Huang8f3abd42020-04-03 20:07:2470
71// Gets a handle from a semaphore
Peng Huang0a13bf52020-05-05 16:01:0572COMPONENT_EXPORT(VULKAN)
73SemaphoreHandle GetVkSemaphoreHandle(
74 VkDevice vk_device,
75 VkSemaphore vk_semaphore,
76 VkExternalSemaphoreHandleTypeFlagBits handle_type);
Peng Huang8f3abd42020-04-03 20:07:2477
Peng Huang0a13bf52020-05-05 16:01:0578COMPONENT_EXPORT(VULKAN)
Peng Huang60108c22020-05-04 16:25:2479std::string VkVersionToString(uint32_t version);
80
Peng Huangb49180ee2020-05-13 21:12:1581COMPONENT_EXPORT(VULKAN)
Vasiliy Telezhnikovea02d912021-02-01 20:24:5682VKAPI_ATTR VkResult VKAPI_CALL
83CreateGraphicsPipelinesHook(VkDevice device,
84 VkPipelineCache pipelineCache,
85 uint32_t createInfoCount,
86 const VkGraphicsPipelineCreateInfo* pCreateInfos,
87 const VkAllocationCallbacks* pAllocator,
88 VkPipeline* pPipelines);
89
Peng Huange3df8ba2020-06-19 23:52:0090COMPONENT_EXPORT(VULKAN)
91bool CheckVulkanCompabilities(const VulkanInfo& vulkan_info,
Jonathan Backerf48f9202021-01-14 18:39:4692 const GPUInfo& gpu_info,
93 std::string enable_by_device_name);
Peng Huange3df8ba2020-06-19 23:52:0094
Sergey Ulanov730a7f02019-04-02 20:49:3795} // namespace gpu
96
97#endif // GPU_VULKAN_VULKAN_UTIL_H_