Flutter Impeller
impeller::TextureSourceVK Class Referenceabstract

#include <texture_source_vk.h>

Inheritance diagram for impeller::TextureSourceVK:
impeller::AllocatedTextureSourceVK impeller::SwapchainImageVK

Public Member Functions

virtual ~TextureSourceVK ()
 
const TextureDescriptorGetTextureDescriptor () const
 
virtual vk::Image GetImage () const =0
 
virtual vk::ImageView GetImageView () const =0
 
fml::Status SetLayout (const BarrierVK &barrier) const
 
vk::ImageLayout SetLayoutWithoutEncoding (vk::ImageLayout layout) const
 
vk::ImageLayout GetLayout () const
 

Protected Member Functions

 TextureSourceVK (TextureDescriptor desc)
 

Protected Attributes

const TextureDescriptor desc_
 

Detailed Description

Abstract base class that represents a vkImage and an vkImageView.

This is intended to be used with an impeller::TextureVK. Example implementations represent swapchain images or uploaded textures.

Definition at line 21 of file texture_source_vk.h.

Constructor & Destructor Documentation

◆ ~TextureSourceVK()

impeller::TextureSourceVK::~TextureSourceVK ( )
virtualdefault

◆ TextureSourceVK()

impeller::TextureSourceVK::TextureSourceVK ( TextureDescriptor  desc)
explicitprotected

Definition at line 9 of file texture_source_vk.cc.

9 : desc_(desc) {}

Member Function Documentation

◆ GetImage()

virtual vk::Image impeller::TextureSourceVK::GetImage ( ) const
pure virtual

◆ GetImageView()

virtual vk::ImageView impeller::TextureSourceVK::GetImageView ( ) const
pure virtual

◆ GetLayout()

vk::ImageLayout impeller::TextureSourceVK::GetLayout ( ) const

Get the last layout assigned to the TextureSourceVK.

This value is synchronized with the GPU via SetLayout so it may not reflect the actual layout.

Definition at line 17 of file texture_source_vk.cc.

17  {
18  ReaderLock lock(layout_mutex_);
19  return layout_;
20 }

◆ GetTextureDescriptor()

const TextureDescriptor & impeller::TextureSourceVK::GetTextureDescriptor ( ) const

Definition at line 13 of file texture_source_vk.cc.

13  {
14  return desc_;
15 }

References desc_.

◆ SetLayout()

fml::Status impeller::TextureSourceVK::SetLayout ( const BarrierVK barrier) const

Encodes the layout transition barrier to barrier.cmd_buffer for the image.

The transition is from the layout stored via SetLayoutWithoutEncoding to barrier.new_layout.

Definition at line 30 of file texture_source_vk.cc.

30  {
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 }

References impeller::BarrierVK::cmd_buffer, desc_, impeller::BarrierVK::dst_access, impeller::BarrierVK::dst_stage, impeller::TextureDescriptor::format, GetImage(), impeller::TextureDescriptor::mip_count, impeller::BarrierVK::new_layout, SetLayoutWithoutEncoding(), impeller::BarrierVK::src_access, impeller::BarrierVK::src_stage, impeller::ToArrayLayerCount(), impeller::ToImageAspectFlags(), and impeller::TextureDescriptor::type.

◆ SetLayoutWithoutEncoding()

vk::ImageLayout impeller::TextureSourceVK::SetLayoutWithoutEncoding ( vk::ImageLayout  layout) const

Store the layout of the image.

This just is bookkeeping on the CPU, to actually set the layout use SetLayout.

Parameters
layoutThe new layout.
Returns
The old layout.

Definition at line 22 of file texture_source_vk.cc.

23  {
24  WriterLock lock(layout_mutex_);
25  const auto old_layout = layout_;
26  layout_ = layout;
27  return old_layout;
28 }

Referenced by SetLayout().

Member Data Documentation

◆ desc_

const TextureDescriptor impeller::TextureSourceVK::desc_
protected

The documentation for this class was generated from the following files:
impeller::TextureDescriptor::format
PixelFormat format
Definition: texture_descriptor.h:42
impeller::ToArrayLayerCount
constexpr uint32_t ToArrayLayerCount(TextureType type)
Definition: formats_vk.h:591
impeller::TextureDescriptor::mip_count
size_t mip_count
Definition: texture_descriptor.h:44
impeller::TextureDescriptor::type
TextureType type
Definition: texture_descriptor.h:41
impeller::TextureSourceVK::desc_
const TextureDescriptor desc_
Definition: texture_source_vk.h:54
impeller::TextureSourceVK::SetLayoutWithoutEncoding
vk::ImageLayout SetLayoutWithoutEncoding(vk::ImageLayout layout) const
Definition: texture_source_vk.cc:22
impeller::TextureSourceVK::GetImage
virtual vk::Image GetImage() const =0
impeller::ToImageAspectFlags
constexpr vk::ImageAspectFlags ToImageAspectFlags(PixelFormat format)
Definition: formats_vk.h:638