Flutter Engine
The 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/compiler_specific.h"
11#include "flutter/fml/macros.h"
12#include "flutter/vulkan/procs/vulkan_handle.h"
13
14namespace vulkan {
15
16class VulkanProcTable;
17class VulkanSurface;
18
20 public:
21 /// @brief Create a new VkDevice with a resolved VkQueue suitable for
22 /// rendering with Skia.
23 ///
26 bool enable_validation_layers);
27
28 /// @brief Wrap an existing VkDevice and VkQueue.
29 ///
33 uint32_t queue_family_index,
36
37 bool IsValid() const;
38
39 const VulkanHandle<VkDevice>& GetHandle() const;
40
42
44
46
47 uint32_t GetGraphicsQueueIndex() const;
48
50
51 [[nodiscard]] bool GetSurfaceCapabilities(
53 VkSurfaceCapabilitiesKHR* capabilities) const;
54
55 [[nodiscard]] bool GetPhysicalDeviceFeatures(
56 VkPhysicalDeviceFeatures* features) const;
57
58 [[nodiscard]] bool GetPhysicalDeviceFeaturesSkia(
59 uint32_t* /* mask of GrVkFeatureFlags */ features) const;
60
61 [[nodiscard]] int ChooseSurfaceFormat(
63 const std::vector<VkFormat>& desired_formats,
65
66 [[nodiscard]] bool ChoosePresentMode(const VulkanSurface& surface,
67 VkPresentModeKHR* present_mode) const;
68
69 [[nodiscard]] bool QueueSubmit(
70 std::vector<VkPipelineStageFlags> wait_dest_pipeline_stages,
71 const std::vector<VkSemaphore>& wait_semaphores,
72 const std::vector<VkSemaphore>& signal_semaphores,
73 const std::vector<VkCommandBuffer>& command_buffers,
74 const VulkanHandle<VkFence>& fence) const;
75
76 [[nodiscard]] bool WaitIdle() const;
77
78 private:
79 VulkanProcTable& vk_;
80 VulkanHandle<VkPhysicalDevice> physical_device_;
83 VulkanHandle<VkCommandPool> command_pool_;
84 uint32_t graphics_queue_index_;
85 bool valid_;
86
87 bool InitializeCommandPool();
88 std::vector<VkQueueFamilyProperties> GetQueueFamilyProperties() const;
89
91};
92
93} // namespace vulkan
94
95#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
bool GetPhysicalDeviceFeaturesSkia(uint32_t *features) 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:51
VkDevice device
Definition main.cc:53
VkQueue queue
Definition main.cc:55
uint32_t queue_family_index
Definition main.cc:54
VkSurfaceKHR surface
Definition main.cc:49
uint32_t uint32_t * format
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
VkPresentModeKHR