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 10 namespace vulkan { 11 12 class VulkanProvider { 13 public: 14 virtual const vulkan::VulkanProcTable& vk() = 0; 15 virtual const vulkan::VulkanHandle<VkDevice>& vk_device() = 0; 16 CreateFence()17 vulkan::VulkanHandle<VkFence> CreateFence() { 18 const VkFenceCreateInfo create_info = { 19 .sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, 20 .pNext = nullptr, 21 .flags = 0, 22 }; 23 VkFence fence; 24 if (VK_CALL_LOG_ERROR(vk().CreateFence(vk_device(), &create_info, nullptr, 25 &fence)) != VK_SUCCESS) 26 return vulkan::VulkanHandle<VkFence>(); 27 28 return {fence, [this](VkFence fence) { 29 vk().DestroyFence(vk_device(), fence, nullptr); 30 }}; 31 } 32 }; 33 34 } // namespace vulkan 35 36 #endif // FLUTTER_VULKAN_VULKAN_PROVIDER_H_ 37