Flutter Engine
The 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 "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]] int ChooseSurfaceFormat(
60 const std::vector<VkFormat>& desired_formats,
62
63 [[nodiscard]] bool ChoosePresentMode(const VulkanSurface& surface,
64 VkPresentModeKHR* present_mode) const;
65
66 [[nodiscard]] bool QueueSubmit(
67 std::vector<VkPipelineStageFlags> wait_dest_pipeline_stages,
68 const std::vector<VkSemaphore>& wait_semaphores,
69 const std::vector<VkSemaphore>& signal_semaphores,
70 const std::vector<VkCommandBuffer>& command_buffers,
71 const VulkanHandle<VkFence>& fence) const;
72
73 [[nodiscard]] bool WaitIdle() const;
74
75 private:
76 VulkanProcTable& vk_;
77 VulkanHandle<VkPhysicalDevice> physical_device_;
80 VulkanHandle<VkCommandPool> command_pool_;
81 uint32_t graphics_queue_index_;
82 bool valid_;
83
84 bool InitializeCommandPool();
85 std::vector<VkQueueFamilyProperties> GetQueueFamilyProperties() const;
86
87 FML_DISALLOW_COPY_AND_ASSIGN(VulkanDevice);
88};
89
90} // namespace vulkan
91
92#endif // FLUTTER_VULKAN_VULKAN_DEVICE_H_
VulkanDevice(VulkanProcTable &vk, VulkanHandle< VkPhysicalDevice > physical_device, bool enable_validation_layers)
Create a new VkDevice with a resolved VkQueue suitable for rendering with Skia.
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: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
vk
Definition: malisc.py:42
VkPresentModeKHR
Definition: vulkan_core.h:7594