| Flutter Impeller |

texture_source_vk.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 "impeller/renderer/backend/vulkan/texture_source_vk.h"
6
7 namespace impeller {
8
9 TextureSourceVK::TextureSourceVK(TextureDescriptor desc) : desc_(desc) {}
10
11 TextureSourceVK::~TextureSourceVK() = default;
12
13 const TextureDescriptor& TextureSourceVK::GetTextureDescriptor() const {
14 return desc_;
15 }
16
17 vk::ImageLayout TextureSourceVK::GetLayout() const {
18 ReaderLock lock(layout_mutex_);
19 return layout_;
20 }
21
22 vk::ImageLayout TextureSourceVK::SetLayoutWithoutEncoding(
23 vk::ImageLayout layout) const {
24 WriterLock lock(layout_mutex_);
25 const auto old_layout = layout_;
26 layout_ = layout;
27 return old_layout;
28 }
29
30 fml::Status TextureSourceVK::SetLayout(const BarrierVK& barrier) const {
31 const auto old_layout = SetLayoutWithoutEncoding(barrier.new_layout);
32 if (barrier.new_layout == old_layout) {
33 return {};
34 }
35
36 vk::ImageMemoryBarrier image_barrier;
37 image_barrier.srcAccessMask = barrier.src_access;
38 image_barrier.dstAccessMask = barrier.dst_access;
39 image_barrier.oldLayout = old_layout;
40 image_barrier.newLayout = barrier.new_layout;
41 image_barrier.image = GetImage();
42 image_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
43 image_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
44 image_barrier.subresourceRange.aspectMask = ToImageAspectFlags(desc_.format);
45 image_barrier.subresourceRange.baseMipLevel = 0u;
46 image_barrier.subresourceRange.levelCount = desc_.mip_count;
47 image_barrier.subresourceRange.baseArrayLayer = 0u;
48 image_barrier.subresourceRange.layerCount = ToArrayLayerCount(desc_.type);
49
50 barrier.cmd_buffer.pipelineBarrier(barrier.src_stage, // src stage
51 barrier.dst_stage, // dst stage
52 {}, // dependency flags
53 nullptr, // memory barriers
54 nullptr, // buffer barriers
55 image_barrier // image barriers
56 );
57
58 return {};
59 }
60
61 } // namespace impeller
impeller::BarrierVK::dst_access
vk::AccessFlags dst_access
Definition: barrier_vk.h:43
impeller::TextureSourceVK::TextureSourceVK
TextureSourceVK(TextureDescriptor desc)
Definition: texture_source_vk.cc:9
impeller::BarrierVK::new_layout
vk::ImageLayout new_layout
Definition: barrier_vk.h:23
impeller::WriterLock
Definition: thread.h:116
texture_source_vk.h
impeller::BarrierVK::cmd_buffer
vk::CommandBuffer cmd_buffer
Definition: barrier_vk.h:22
impeller::TextureDescriptor::format
PixelFormat format
Definition: texture_descriptor.h:40
impeller::ToArrayLayerCount
constexpr uint32_t ToArrayLayerCount(TextureType type)
Definition: formats_vk.h:594
impeller::TextureDescriptor::mip_count
size_t mip_count
Definition: texture_descriptor.h:42
impeller::TextureDescriptor::type
TextureType type
Definition: texture_descriptor.h:39
impeller::TextureSourceVK::desc_
const TextureDescriptor desc_
Definition: texture_source_vk.h:55
impeller::TextureSourceVK::SetLayoutWithoutEncoding
vk::ImageLayout SetLayoutWithoutEncoding(vk::ImageLayout layout) const
Definition: texture_source_vk.cc:22
impeller::BarrierVK
Defines an operations and memory access barrier on a resource.
Definition: barrier_vk.h:21
impeller::ReaderLock
Definition: thread.h:95
impeller::TextureSourceVK::~TextureSourceVK
virtual ~TextureSourceVK()
impeller::TextureSourceVK::GetLayout
vk::ImageLayout GetLayout() const
Definition: texture_source_vk.cc:17
impeller::BarrierVK::src_access
vk::AccessFlags src_access
Definition: barrier_vk.h:33
impeller::TextureSourceVK::GetImage
virtual vk::Image GetImage() const =0
impeller::TextureSourceVK::SetLayout
fml::Status SetLayout(const BarrierVK &barrier) const
Definition: texture_source_vk.cc:30
impeller::BarrierVK::dst_stage
vk::PipelineStageFlags dst_stage
Definition: barrier_vk.h:38
impeller::TextureDescriptor
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
Definition: texture_descriptor.h:37
impeller::TextureSourceVK::GetTextureDescriptor
const TextureDescriptor & GetTextureDescriptor() const
Definition: texture_source_vk.cc:13
impeller
Definition: aiks_context.cc:10
impeller::BarrierVK::src_stage
vk::PipelineStageFlags src_stage
Definition: barrier_vk.h:28
impeller::ToImageAspectFlags
constexpr vk::ImageAspectFlags ToImageAspectFlags(PixelFormat format)
Definition: formats_vk.h:641