• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 The Flutter 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 #ifndef FLUTTER_VULKAN_VULKAN_PROVIDER_H_
6 #define FLUTTER_VULKAN_VULKAN_PROVIDER_H_
7 
8 #include "flutter/vulkan/vulkan_handle.h"
9 #include "flutter/vulkan/vulkan_proc_table.h"
10 
11 namespace vulkan {
12 
13 class VulkanProvider {
14  public:
15   virtual const vulkan::VulkanProcTable& vk() = 0;
16   virtual const vulkan::VulkanHandle<VkDevice>& vk_device() = 0;
17 
CreateFence()18   vulkan::VulkanHandle<VkFence> CreateFence() {
19     const VkFenceCreateInfo create_info = {
20         .sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
21         .pNext = nullptr,
22         .flags = 0,
23     };
24     VkFence fence;
25     if (VK_CALL_LOG_ERROR(vk().CreateFence(vk_device(), &create_info, nullptr,
26                                            &fence)) != VK_SUCCESS)
27       return vulkan::VulkanHandle<VkFence>();
28 
29     return {fence, [this](VkFence fence) {
30               vk().DestroyFence(vk_device(), fence, nullptr);
31             }};
32   }
33 };
34 
35 }  // namespace vulkan
36 
37 #endif  // FLUTTER_VULKAN_VULKAN_PROVIDER_H_
38