Flutter Engine
The Flutter Engine
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
6
7namespace impeller {
8
10
12
14 return desc_;
15}
16
17std::shared_ptr<YUVConversionVK> TextureSourceVK::GetYUVConversion() const {
18 return nullptr;
19}
20
21vk::ImageLayout TextureSourceVK::GetLayout() const {
22 ReaderLock lock(layout_mutex_);
23 return layout_;
24}
25
27 vk::ImageLayout layout) const {
28 WriterLock lock(layout_mutex_);
29 const auto old_layout = layout_;
30 layout_ = layout;
31 return old_layout;
32}
33
35 const auto old_layout = SetLayoutWithoutEncoding(barrier.new_layout);
36 if (barrier.new_layout == old_layout) {
37 return {};
38 }
39
40 vk::ImageMemoryBarrier image_barrier;
41 image_barrier.srcAccessMask = barrier.src_access;
42 image_barrier.dstAccessMask = barrier.dst_access;
43 image_barrier.oldLayout = old_layout;
44 image_barrier.newLayout = barrier.new_layout;
45 image_barrier.image = GetImage();
46 image_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
47 image_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
48 image_barrier.subresourceRange.aspectMask = ToImageAspectFlags(desc_.format);
49 image_barrier.subresourceRange.baseMipLevel = 0u;
50 image_barrier.subresourceRange.levelCount = desc_.mip_count;
51 image_barrier.subresourceRange.baseArrayLayer = 0u;
52 image_barrier.subresourceRange.layerCount = ToArrayLayerCount(desc_.type);
53
54 barrier.cmd_buffer.pipelineBarrier(barrier.src_stage, // src stage
55 barrier.dst_stage, // dst stage
56 {}, // dependency flags
57 nullptr, // memory barriers
58 nullptr, // buffer barriers
59 image_barrier // image barriers
60 );
61
62 return {};
63}
64
66 const SharedHandleVK<vk::Framebuffer>& framebuffer) {
67 framebuffer_ = framebuffer;
68}
69
71 const SharedHandleVK<vk::RenderPass>& render_pass) {
72 render_pass_ = render_pass;
73}
74
76 return framebuffer_;
77}
78
80 return render_pass_;
81}
82
83} // namespace impeller
TextureSourceVK(TextureDescriptor desc)
void SetCachedRenderPass(const SharedHandleVK< vk::RenderPass > &render_pass)
virtual std::shared_ptr< YUVConversionVK > GetYUVConversion() const
When sampling from textures whose formats are not known to Vulkan, a custom conversion is necessary t...
const TextureDescriptor & GetTextureDescriptor() const
Gets the texture descriptor for this image source.
SharedHandleVK< vk::Framebuffer > GetCachedFramebuffer() const
virtual vk::Image GetImage() const =0
Get the image handle for this texture source.
void SetCachedFramebuffer(const SharedHandleVK< vk::Framebuffer > &framebuffer)
SharedHandleVK< vk::RenderPass > GetCachedRenderPass() const
vk::ImageLayout GetLayout() const
Get the last layout assigned to the TextureSourceVK.
vk::ImageLayout SetLayoutWithoutEncoding(vk::ImageLayout layout) const
Store the layout of the image.
const TextureDescriptor desc_
fml::Status SetLayout(const BarrierVK &barrier) const
Encodes the layout transition barrier to barrier.cmd_buffer for the image.
std::shared_ptr< SharedObjectVKT< T > > SharedHandleVK
constexpr uint32_t ToArrayLayerCount(TextureType type)
Definition: formats_vk.h:516
constexpr vk::ImageAspectFlags ToImageAspectFlags(PixelFormat format)
Definition: formats_vk.h:563
fuchsia::ui::composition::LayoutInfo layout_
Defines an operations and memory access barrier on a resource.
Definition: barrier_vk.h:27
vk::CommandBuffer cmd_buffer
Definition: barrier_vk.h:28
vk::AccessFlags src_access
Definition: barrier_vk.h:39
vk::PipelineStageFlags dst_stage
Definition: barrier_vk.h:44
vk::ImageLayout new_layout
Definition: barrier_vk.h:29
vk::PipelineStageFlags src_stage
Definition: barrier_vk.h:34
vk::AccessFlags dst_access
Definition: barrier_vk.h:49
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
#define VK_QUEUE_FAMILY_IGNORED
Definition: vulkan_core.h:127