forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vulkan_provider.h
36 lines (28 loc) · 1.05 KB
/
vulkan_provider.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_VULKAN_VULKAN_PROVIDER_H_
#define FLUTTER_VULKAN_VULKAN_PROVIDER_H_
#include "flutter/vulkan/vulkan_handle.h"
namespace vulkan {
class VulkanProvider {
public:
virtual const vulkan::VulkanProcTable& vk() = 0;
virtual const vulkan::VulkanHandle<VkDevice>& vk_device() = 0;
vulkan::VulkanHandle<VkFence> CreateFence() {
const VkFenceCreateInfo create_info = {
.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
.pNext = nullptr,
.flags = 0,
};
VkFence fence;
if (VK_CALL_LOG_ERROR(vk().CreateFence(vk_device(), &create_info, nullptr,
&fence)) != VK_SUCCESS)
return vulkan::VulkanHandle<VkFence>();
return {fence, [this](VkFence fence) {
vk().DestroyFence(vk_device(), fence, nullptr);
}};
}
};
} // namespace vulkan
#endif // FLUTTER_VULKAN_VULKAN_PROVIDER_H_