Flutter Engine
 
Loading...
Searching...
No Matches
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
16
17std::shared_ptr<YUVConversionVK> TextureSourceVK::GetYUVConversion() const {
18 return nullptr;
19}
20
21vk::ImageLayout TextureSourceVK::GetLayout() const {
22 return layout_;
23}
24
26 vk::ImageLayout layout) const {
27 const auto old_layout = layout_;
28 layout_ = layout;
29 return old_layout;
30}
31
33 const vk::ImageLayout old_layout =
35 vk::ImageMemoryBarrier image_barrier;
36 image_barrier.srcAccessMask = barrier.src_access;
37 image_barrier.dstAccessMask = barrier.dst_access;
38 image_barrier.oldLayout = old_layout;
39 image_barrier.newLayout = barrier.new_layout;
40 image_barrier.image = GetImage();
41 image_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
42 image_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
43 image_barrier.subresourceRange.aspectMask = ToImageAspectFlags(desc_.format);
44 image_barrier.subresourceRange.baseMipLevel = barrier.base_mip_level;
45 image_barrier.subresourceRange.levelCount =
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
62 SampleCount sample_count) {
63 frame_data_[static_cast<int>(sample_count) / 4] = data;
64}
65
67 SampleCount sample_count) const {
68 return frame_data_[static_cast<int>(sample_count) / 4];
69}
70
71} // namespace impeller
TextureSourceVK(TextureDescriptor desc)
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.
const FramebufferAndRenderPass & GetCachedFrameData(SampleCount sample_count) const
virtual vk::Image GetImage() const =0
Get the image handle for this texture source.
void SetCachedFrameData(const FramebufferAndRenderPass &data, SampleCount sample_count)
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::optional< PipelineDescriptor > desc_
constexpr uint32_t ToArrayLayerCount(TextureType type)
Definition formats_vk.h:539
constexpr vk::ImageAspectFlags ToImageAspectFlags(PixelFormat format)
Definition formats_vk.h:586
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
uint32_t base_mip_level
The base mip level to apply the barrier to in the subresource range.
Definition barrier_vk.h:52
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...
std::shared_ptr< const fml::Mapping > data