Flutter Engine
vulkan_application.h
Go to the documentation of this file.
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_APPLICATION_H_
6 #define FLUTTER_VULKAN_VULKAN_APPLICATION_H_
7 
8 #include <memory>
9 #include <string>
10 #include <vector>
11 
12 #include "flutter/fml/macros.h"
13 #include "vulkan_debug_report.h"
14 #include "vulkan_handle.h"
15 
16 namespace vulkan {
17 
18 static const int kGrCacheMaxCount = 8192;
19 static const size_t kGrCacheMaxByteSize = 512 * (1 << 20);
20 
21 class VulkanDevice;
22 class VulkanProcTable;
23 
24 /// Applications using Vulkan acquire a VulkanApplication that attempts to
25 /// create a VkInstance (with debug reporting optionally enabled).
27  public:
28  VulkanApplication(VulkanProcTable& vk, // NOLINT
29  const std::string& application_name,
30  std::vector<std::string> enabled_extensions,
31  uint32_t application_version = VK_MAKE_VERSION(1, 0, 0),
32  uint32_t api_version = VK_MAKE_VERSION(1, 0, 0),
33  bool enable_validation_layers = false);
34 
36 
37  bool IsValid() const;
38 
39  uint32_t GetAPIVersion() const;
40 
42 
44 
45  std::unique_ptr<VulkanDevice> AcquireFirstCompatibleLogicalDevice() const;
46 
47  private:
48  VulkanProcTable& vk;
49  VulkanHandle<VkInstance> instance_;
50  uint32_t api_version_;
51  std::unique_ptr<VulkanDebugReport> debug_report_;
52  bool valid_;
53  bool enable_validation_layers_;
54 
55  std::vector<VkPhysicalDevice> GetPhysicalDevices() const;
56  std::vector<VkExtensionProperties> GetSupportedInstanceExtensions(
57  const VulkanProcTable& vk) const;
58  bool ExtensionSupported(
59  const std::vector<VkExtensionProperties>& supported_extensions,
60  std::string extension_name);
61 
62  FML_DISALLOW_COPY_AND_ASSIGN(VulkanApplication);
63 };
64 
65 } // namespace vulkan
66 
67 #endif // FLUTTER_VULKAN_VULKAN_APPLICATION_H_
static const size_t kGrCacheMaxByteSize
VulkanApplication(VulkanProcTable &vk, const std::string &application_name, std::vector< std::string > enabled_extensions, uint32_t application_version=VK_MAKE_VERSION(1, 0, 0), uint32_t api_version=VK_MAKE_VERSION(1, 0, 0), bool enable_validation_layers=false)
std::unique_ptr< VulkanDevice > AcquireFirstCompatibleLogicalDevice() const
static const int kGrCacheMaxCount
const VulkanHandle< VkInstance > & GetInstance() const