Flutter Engine
The Flutter Engine
vulkan_command_buffer.cc
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
6
7#include "flutter/vulkan/procs/vulkan_proc_table.h"
8
9namespace vulkan {
10
12 const VulkanProcTable& p_vk,
15 : vk_(p_vk), device_(device), pool_(pool), valid_(false) {
16 const VkCommandBufferAllocateInfo allocate_info = {
18 .pNext = nullptr,
19 .commandPool = pool_,
21 .commandBufferCount = 1,
22 };
23
24 VkCommandBuffer buffer = VK_NULL_HANDLE;
25
26 if (VK_CALL_LOG_ERROR(vk_.AllocateCommandBuffers(device_, &allocate_info,
27 &buffer)) != VK_SUCCESS) {
28 FML_DLOG(INFO) << "Could not allocate command buffers.";
29 return;
30 }
31
32 auto buffer_collect = [this](VkCommandBuffer buffer) {
33 vk_.FreeCommandBuffers(device_, pool_, 1, &buffer);
34 };
35
36 handle_ = VulkanHandle<VkCommandBuffer>{buffer, buffer_collect};
37
38 valid_ = true;
39}
40
42
44 return valid_;
45}
46
47VkCommandBuffer VulkanCommandBuffer::Handle() const {
48 return handle_;
49}
50
54 .pNext = nullptr,
55 .flags = 0,
56 .pInheritanceInfo = nullptr,
57 };
58
59 return VK_CALL_LOG_ERROR(vk_.BeginCommandBuffer(handle_, &info)) ==
61}
62
64 return VK_CALL_LOG_ERROR(vk_.EndCommandBuffer(handle_)) == VK_SUCCESS;
65}
66
68 VkPipelineStageFlagBits src_stage_flags,
69 VkPipelineStageFlagBits dest_stage_flags,
70 uint32_t /* mask of VkDependencyFlagBits */ dependency_flags,
71 uint32_t memory_barrier_count,
72 const VkMemoryBarrier* memory_barriers,
73 uint32_t buffer_memory_barrier_count,
74 const VkBufferMemoryBarrier* buffer_memory_barriers,
75 uint32_t image_memory_barrier_count,
76 const VkImageMemoryBarrier* image_memory_barriers) const {
77 vk_.CmdPipelineBarrier(handle_, src_stage_flags, dest_stage_flags,
78 dependency_flags, memory_barrier_count,
79 memory_barriers, buffer_memory_barrier_count,
80 buffer_memory_barriers, image_memory_barrier_count,
81 image_memory_barriers);
82 return true;
83}
84
85} // namespace vulkan
AutoreleasePool pool
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
bool InsertPipelineBarrier(VkPipelineStageFlagBits src_stage_flags, VkPipelineStageFlagBits dest_stage_flags, uint32_t dependency_flags, uint32_t memory_barrier_count, const VkMemoryBarrier *memory_barriers, uint32_t buffer_memory_barrier_count, const VkBufferMemoryBarrier *buffer_memory_barriers, uint32_t image_memory_barrier_count, const VkImageMemoryBarrier *image_memory_barriers) const
VkCommandBuffer Handle() const
VulkanCommandBuffer(const VulkanProcTable &vk, const VulkanHandle< VkDevice > &device, const VulkanHandle< VkCommandPool > &pool)
VkDevice device
Definition: main.cc:53
#define FML_DLOG(severity)
Definition: logging.h:102
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
@ VK_COMMAND_BUFFER_LEVEL_PRIMARY
Definition: vulkan_core.h:2178
@ VK_SUCCESS
Definition: vulkan_core.h:141
#define VK_NULL_HANDLE
Definition: vulkan_core.h:46
VkPipelineStageFlagBits
Definition: vulkan_core.h:2434
@ VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO
Definition: vulkan_core.h:242
@ VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO
Definition: vulkan_core.h:244
#define VK_CALL_LOG_ERROR(expression)