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