Flutter Engine
vulkan::VulkanCommandBuffer Class Reference

#include <vulkan_command_buffer.h>

Public Member Functions

 VulkanCommandBuffer (const VulkanProcTable &vk, const VulkanHandle< VkDevice > &device, const VulkanHandle< VkCommandPool > &pool)
 
 ~VulkanCommandBuffer ()
 
bool IsValid () const
 
VkCommandBuffer Handle () const
 
bool Begin () const
 
bool End () const
 
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
 

Detailed Description

Definition at line 16 of file vulkan_command_buffer.h.

Constructor & Destructor Documentation

◆ VulkanCommandBuffer()

vulkan::VulkanCommandBuffer::VulkanCommandBuffer ( const VulkanProcTable vk,
const VulkanHandle< VkDevice > &  device,
const VulkanHandle< VkCommandPool > &  pool 
)

Definition at line 11 of file vulkan_command_buffer.cc.

References FML_DLOG, VK_CALL_LOG_ERROR, and ~VulkanCommandBuffer().

15  : vk(p_vk), device_(device), pool_(pool), valid_(false) {
16  const VkCommandBufferAllocateInfo allocate_info = {
17  .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
18  .pNext = nullptr,
19  .commandPool = pool_,
20  .level = VK_COMMAND_BUFFER_LEVEL_PRIMARY,
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_ = {buffer, buffer_collect};
37 
38  valid_ = true;
39 }
#define VK_CALL_LOG_ERROR(expression)
#define FML_DLOG(severity)
Definition: logging.h:85

◆ ~VulkanCommandBuffer()

vulkan::VulkanCommandBuffer::~VulkanCommandBuffer ( )
default

Referenced by VulkanCommandBuffer().

Member Function Documentation

◆ Begin()

bool vulkan::VulkanCommandBuffer::Begin ( ) const

Definition at line 51 of file vulkan_command_buffer.cc.

References VK_CALL_LOG_ERROR.

Referenced by flutter_runner::VulkanSurfaceProducer::OnSurfacesPresented().

51  {
52  const VkCommandBufferBeginInfo info{
53  .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
54  .pNext = nullptr,
55  .flags = 0,
56  .pInheritanceInfo = nullptr,
57  };
58 
59  return VK_CALL_LOG_ERROR(vk.BeginCommandBuffer(handle_, &info)) == VK_SUCCESS;
60 }
#define VK_CALL_LOG_ERROR(expression)

◆ End()

bool vulkan::VulkanCommandBuffer::End ( ) const

Definition at line 62 of file vulkan_command_buffer.cc.

References VK_CALL_LOG_ERROR.

Referenced by flutter_runner::VulkanSurfaceProducer::OnSurfacesPresented().

62  {
63  return VK_CALL_LOG_ERROR(vk.EndCommandBuffer(handle_)) == VK_SUCCESS;
64 }
#define VK_CALL_LOG_ERROR(expression)

◆ Handle()

VkCommandBuffer vulkan::VulkanCommandBuffer::Handle ( ) const

Definition at line 47 of file vulkan_command_buffer.cc.

47  {
48  return handle_;
49 }

◆ InsertPipelineBarrier()

bool vulkan::VulkanCommandBuffer::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

Definition at line 66 of file vulkan_command_buffer.cc.

Referenced by vulkan::VulkanImage::InsertImageMemoryBarrier(), and flutter_runner::VulkanSurfaceProducer::OnSurfacesPresented().

75  {
76  vk.CmdPipelineBarrier(handle_, src_stage_flags, dest_stage_flags,
77  dependency_flags, memory_barrier_count, memory_barriers,
78  buffer_memory_barrier_count, buffer_memory_barriers,
79  image_memory_barrier_count, image_memory_barriers);
80  return true;
81 }

◆ IsValid()

bool vulkan::VulkanCommandBuffer::IsValid ( ) const

Definition at line 43 of file vulkan_command_buffer.cc.

Referenced by vulkan::VulkanBackbuffer::VulkanBackbuffer().

43  {
44  return valid_;
45 }

The documentation for this class was generated from the following files: