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