Flutter Engine
The Flutter Engine
vulkan_image.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
5#include "vulkan_image.h"
6
7#include "flutter/vulkan/procs/vulkan_proc_table.h"
9
10namespace vulkan {
11
13 : handle_(std::move(image)),
15 access_flags_(0),
16 valid_(false) {
17 if (!handle_) {
18 return;
19 }
20
21 valid_ = true;
22}
23
25
27 return valid_;
28}
29
31 const VulkanCommandBuffer& command_buffer,
32 VkPipelineStageFlagBits src_pipline_bits,
33 VkPipelineStageFlagBits dest_pipline_bits,
34 VkAccessFlags dest_access_flags,
35 VkImageLayout dest_layout) {
36 const VkImageMemoryBarrier image_memory_barrier = {
38 .pNext = nullptr,
39 .srcAccessMask = access_flags_,
40 .dstAccessMask = dest_access_flags,
41 .oldLayout = layout_,
42 .newLayout = dest_layout,
43 .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
44 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
45 .image = handle_,
46 .subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1},
47 };
48
49 bool success = command_buffer.InsertPipelineBarrier(
50 src_pipline_bits, // src_stage_flags
51 dest_pipline_bits, // dest_stage_flags
52 0, // dependency_flags
53 0, // memory_barrier_count
54 nullptr, // memory_barriers
55 0, // buffer_memory_barrier_count
56 nullptr, // buffer_memory_barriers
57 1, // image_memory_barrier_count
58 &image_memory_barrier // image_memory_barriers
59 );
60
61 if (success) {
62 access_flags_ = dest_access_flags;
63 layout_ = dest_layout;
64 }
65
66 return success;
67}
68
69} // namespace vulkan
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
bool IsValid() const
Definition: vulkan_image.cc:26
bool InsertImageMemoryBarrier(const VulkanCommandBuffer &command_buffer, VkPipelineStageFlagBits src_pipline_bits, VkPipelineStageFlagBits dest_pipline_bits, VkAccessFlags dest_access_flags, VkImageLayout dest_layout)
Definition: vulkan_image.cc:30
VulkanImage(VulkanHandle< VkImage > image)
Definition: vulkan_image.cc:12
sk_sp< const SkImage > image
Definition: SkRecords.h:269
Definition: ref_ptr.h:256
fuchsia::ui::composition::LayoutInfo layout_
fuchsia::ui::composition::ParentViewportWatcherHandle handle_
VkStructureType sType
Definition: vulkan_core.h:2936
VkImageLayout
Definition: vulkan_core.h:1330
@ VK_IMAGE_LAYOUT_UNDEFINED
Definition: vulkan_core.h:1331
VkFlags VkAccessFlags
Definition: vulkan_core.h:2235
@ VK_IMAGE_ASPECT_COLOR_BIT
Definition: vulkan_core.h:2238
VkPipelineStageFlagBits
Definition: vulkan_core.h:2434
#define VK_QUEUE_FAMILY_IGNORED
Definition: vulkan_core.h:127
@ VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER
Definition: vulkan_core.h:247