Flutter Engine
 
Loading...
Searching...
No Matches
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/macros.h"
12
13namespace vulkan {
14
15class VulkanProcTable;
16class VulkanSurface;
17
19 public:
20 /// @brief Create a new VkDevice with a resolved VkQueue suitable for
21 /// rendering with Skia.
22 ///
26
27 /// @brief Wrap an existing VkDevice and VkQueue.
28 ///
32 uint32_t queue_family_index,
35
36 bool IsValid() const;
37
38 const VulkanHandle<VkDevice>& GetHandle() const;
39
41
43
45
46 uint32_t GetGraphicsQueueIndex() const;
47
49
50 [[nodiscard]] bool GetSurfaceCapabilities(
52 VkSurfaceCapabilitiesKHR* capabilities) const;
53
54 [[nodiscard]] bool GetPhysicalDeviceFeatures(
55 VkPhysicalDeviceFeatures* features) const;
56
57 [[nodiscard]] int ChooseSurfaceFormat(
59 const std::vector<VkFormat>& desired_formats,
60 VkSurfaceFormatKHR* format) const;
61
62 [[nodiscard]] bool ChoosePresentMode(const VulkanSurface& surface,
63 VkPresentModeKHR* present_mode) const;
64
65 [[nodiscard]] bool QueueSubmit(
66 std::vector<VkPipelineStageFlags> wait_dest_pipeline_stages,
67 const std::vector<VkSemaphore>& wait_semaphores,
68 const std::vector<VkSemaphore>& signal_semaphores,
69 const std::vector<VkCommandBuffer>& command_buffers,
70 const VulkanHandle<VkFence>& fence) const;
71
72 [[nodiscard]] bool WaitIdle() const;
73
74 private:
75 VulkanProcTable& vk_;
76 VulkanHandle<VkPhysicalDevice> physical_device_;
79 VulkanHandle<VkCommandPool> command_pool_;
80 uint32_t graphics_queue_index_;
81 bool valid_;
82
83 bool InitializeCommandPool();
84 std::vector<VkQueueFamilyProperties> GetQueueFamilyProperties() const;
85
87};
88
89} // namespace vulkan
90
91#endif // FLUTTER_VULKAN_VULKAN_DEVICE_H_
const VulkanHandle< VkQueue > & GetQueueHandle() const
const VulkanHandle< VkPhysicalDevice > & GetPhysicalDeviceHandle() const
bool ChoosePresentMode(const VulkanSurface &surface, VkPresentModeKHR *present_mode) 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
bool GetSurfaceCapabilities(const VulkanSurface &surface, VkSurfaceCapabilitiesKHR *capabilities) const
const VulkanHandle< VkDevice > & GetHandle() const
int ChooseSurfaceFormat(const VulkanSurface &surface, const std::vector< VkFormat > &desired_formats, VkSurfaceFormatKHR *format) const
bool GetPhysicalDeviceFeatures(VkPhysicalDeviceFeatures *features) const
const VulkanHandle< VkCommandPool > & GetCommandPool() const
uint32_t GetGraphicsQueueIndex() const
VkPhysicalDevice physical_device
Definition main.cc:67
VkDevice device
Definition main.cc:69
bool enable_validation_layers
Definition main.cc:36
VkQueue queue
Definition main.cc:71
uint32_t queue_family_index
Definition main.cc:70
VkSurfaceKHR surface
Definition main.cc:65
uint32_t uint32_t * format
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27