• 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_DEVICE_H_
6 #define FLUTTER_VULKAN_VULKAN_DEVICE_H_
7 
8 #include <vector>
9 
10 #ifndef RS_ENABLE_VK
11 #include "flutter/fml/compiler_specific.h"
12 #include "flutter/fml/macros.h"
13 #endif
14 #include "flutter/vulkan/vulkan_handle.h"
15 
16 namespace vulkan {
17 
18 class VulkanProcTable;
19 class VulkanSurface;
20 
21 class VulkanDevice {
22  public:
23   VulkanDevice(VulkanProcTable& vk,
24                VulkanHandle<VkPhysicalDevice> physical_device);
25 
26   ~VulkanDevice();
27 
28   bool IsValid() const;
29 
30   const VulkanHandle<VkDevice>& GetHandle() const;
31 
32   const VulkanHandle<VkPhysicalDevice>& GetPhysicalDeviceHandle() const;
33 
34   const VulkanHandle<VkQueue>& GetQueueHandle() const;
35 
36   const VulkanHandle<VkCommandPool>& GetCommandPool() const;
37 
38   uint32_t GetGraphicsQueueIndex() const;
39 
40   void ReleaseDeviceOwnership();
41 
42 #ifndef RS_ENABLE_VK
43   FML_WARN_UNUSED_RESULT
44 #endif
45   bool GetSurfaceCapabilities(const VulkanSurface& surface,
46                               VkSurfaceCapabilitiesKHR* capabilities) const;
47 
48 #ifndef RS_ENABLE_VK
49   FML_WARN_UNUSED_RESULT
50 #endif
51   bool GetPhysicalDeviceFeatures(VkPhysicalDeviceFeatures* features) const;
52 
53 #ifndef RS_ENABLE_VK
54   FML_WARN_UNUSED_RESULT
55 #endif
56   bool GetPhysicalDeviceFeaturesSkia(
57       uint32_t* /* mask of GrVkFeatureFlags */ features) const;
58 
59 #ifndef RS_ENABLE_VK
60   FML_WARN_UNUSED_RESULT
61 #endif
62   int ChooseSurfaceFormat(const VulkanSurface& surface,
63                           std::vector<VkFormat> desired_formats,
64                           VkSurfaceFormatKHR* format) const;
65 
66 #ifndef RS_ENABLE_VK
67   FML_WARN_UNUSED_RESULT
68 #endif
69   bool ChoosePresentMode(const VulkanSurface& surface,
70                          VkPresentModeKHR* present_mode) const;
71 
72 #ifndef RS_ENABLE_VK
73   FML_WARN_UNUSED_RESULT
74 #endif
75   bool QueueSubmit(std::vector<VkPipelineStageFlags> wait_dest_pipeline_stages,
76                    const std::vector<VkSemaphore>& wait_semaphores,
77                    const std::vector<VkSemaphore>& signal_semaphores,
78                    const std::vector<VkCommandBuffer>& command_buffers,
79                    const VulkanHandle<VkFence>& fence) const;
80 
81 #ifndef RS_ENABLE_VK
82   FML_WARN_UNUSED_RESULT
83 #endif
84   bool WaitIdle() const;
85 
86  private:
87   VulkanProcTable& vk;
88   VulkanHandle<VkPhysicalDevice> physical_device_;
89   VulkanHandle<VkDevice> device_;
90   VulkanHandle<VkQueue> queue_;
91   VulkanHandle<VkCommandPool> command_pool_;
92   uint32_t graphics_queue_index_;
93 #ifdef RS_ENABLE_VK
94   uint32_t compute_queue_index_;
95 #endif
96   bool valid_;
97 
98   std::vector<VkQueueFamilyProperties> GetQueueFamilyProperties() const;
99 
100 #ifndef RS_ENABLE_VK
101   FML_DISALLOW_COPY_AND_ASSIGN(VulkanDevice);
102 #endif
103 };
104 
105 }  // namespace vulkan
106 
107 #endif  // FLUTTER_VULKAN_VULKAN_DEVICE_H_
108