| Flutter Impeller |

Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
impeller::TextureSourceVK Class Referenceabstract

Abstract base class that represents a vkImage and an vkImageView. More...

`#include <texture_source_vk.h>`

Inheritance diagram for impeller::TextureSourceVK:

## Public Member Functions
virtual | ~TextureSourceVK ()
const TextureDescriptor & | GetTextureDescriptor () const
| Gets the texture descriptor for this image source. More...
virtual vk::Image | GetImage () const =0
| Get the image handle for this texture source. More...
virtual vk::ImageView | GetImageView () const =0
| Retrieve the image view used for sampling/blitting/compute with this texture source. More...
virtual vk::ImageView | GetRenderTargetView () const =0
| Retrieve the image view used for render target attachments with this texture source. More...
fml::Status | SetLayout (const BarrierVK &barrier) const
| Encodes the layout transition `barrier` to `barrier.cmd_buffer` for the image. More...
vk::ImageLayout | SetLayoutWithoutEncoding (vk::ImageLayout layout) const
| Store the layout of the image. More...
vk::ImageLayout | GetLayout () const
| Get the last layout assigned to the TextureSourceVK. More...
virtual std::shared_ptr< YUVConversionVK > | GetYUVConversion () const
| When sampling from textures whose formats are not known to Vulkan, a custom conversion is necessary to setup custom samplers. This accessor provides this conversion if one is present. Most texture source have none. More...
virtual bool | IsSwapchainImage () const =0
| Determines if swapchain image. That is, an image used as the root render target. More...
void | SetCachedFramebuffer (const SharedHandleVK< vk::Framebuffer > &framebuffer)
void | SetCachedRenderPass (const SharedHandleVK< vk::RenderPass > &render_pass)
SharedHandleVK< vk::Framebuffer > | GetCachedFramebuffer () const
SharedHandleVK< vk::RenderPass > | GetCachedRenderPass () 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, uploaded textures, Android Hardware Buffer backend textures, etc...

Definition at line 28 of file texture_source_vk.h.

## Constructor & Destructor Documentation

## ◆ ~TextureSourceVK()

impeller::TextureSourceVK::~TextureSourceVK | ( |  | ) |
| virtual default

## ◆ TextureSourceVK()

impeller::TextureSourceVK::TextureSourceVK | ( | TextureDescriptor | desc | ) |
| explicit protected

Definition at line 9 of file texture_source_vk.cc.

9 : desc_(desc) {}
impeller::TextureSourceVK::desc_
const TextureDescriptor desc_
Definition: texture_source_vk.h:155

## Member Function Documentation

## ◆ GetCachedFramebuffer()

SharedHandleVK< vk::Framebuffer > impeller::TextureSourceVK::GetCachedFramebuffer | ( |  | ) | const

Retrieve the last framebuffer object used with this texture.

May be nullptr if no previous framebuffer existed.

Definition at line 75 of file texture_source_vk.cc.

75 {
76 return framebuffer_;
77 }

## ◆ GetCachedRenderPass()

SharedHandleVK< vk::RenderPass > impeller::TextureSourceVK::GetCachedRenderPass | ( |  | ) | const

Retrieve the last render pass object used with this texture.

May be nullptr if no previous render pass existed.

Definition at line 79 of file texture_source_vk.cc.

79 {
80 return render_pass_;
81 }

## ◆ GetImage()

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

Get the image handle for this texture source.

Returns
  The image.

Implemented in impeller::KHRSwapchainImageVK, impeller::AHBTextureSourceVK, and impeller::AllocatedTextureSourceVK.

Referenced by SetLayout().

## ◆ GetImageView()

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

Retrieve the image view used for sampling/blitting/compute with this texture source.

Returns
  The image view.

Implemented in impeller::KHRSwapchainImageVK, impeller::AHBTextureSourceVK, and impeller::AllocatedTextureSourceVK.

## ◆ 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.

Returns
  The last known layout of the texture source.

Definition at line 21 of file texture_source_vk.cc.

21 {
22 ReaderLock lock(layout_mutex_);
23 return layout_;
24 }

## ◆ GetRenderTargetView()

virtual vk::ImageView impeller::TextureSourceVK::GetRenderTargetView | ( |  | ) | const
| pure virtual

Retrieve the image view used for render target attachments with this texture source.

ImageViews used as render target attachments cannot have any mip levels. In cases where we want to generate mipmaps with the result of this texture, we need to create multiple image views.

Returns
  The render target view.

Implemented in impeller::KHRSwapchainImageVK, impeller::AHBTextureSourceVK, and impeller::AllocatedTextureSourceVK.

## ◆ GetTextureDescriptor()

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

Gets the texture descriptor for this image source.

Warning
  Texture descriptors from texture sources whose capabilities are a superset of those that can be expressed with Vulkan (like Android Hardware Buffer) are inferred. Stuff like size, mip-counts, types is reliable. So use these descriptors as advisory. Creating copies of texture sources from these descriptors is usually not possible and depends on the allocator used.

Returns
  The texture descriptor.

Definition at line 13 of file texture_source_vk.cc.

13 {
14 return desc_;
15 }

References desc_.

Referenced by impeller::glvk::Trampoline::BlitTextureOpenGLToVulkan().

## ◆ GetYUVConversion()

std::shared_ptr< YUVConversionVK > impeller::TextureSourceVK::GetYUVConversion | ( |  | ) | const
| virtual

When sampling from textures whose formats are not known to Vulkan, a custom conversion is necessary to setup custom samplers. This accessor provides this conversion if one is present. Most texture source have none.

Returns
  The sampler conversion.

Reimplemented in impeller::AHBTextureSourceVK.

Definition at line 17 of file texture_source_vk.cc.

17 {
18 return nullptr;
19 }

## ◆ IsSwapchainImage()

virtual bool impeller::TextureSourceVK::IsSwapchainImage | ( |  | ) | const
| pure virtual

Determines if swapchain image. That is, an image used as the root render target.

Returns
  Whether or not this is a swapchain image.

Implemented in impeller::KHRSwapchainImageVK, impeller::AHBTextureSourceVK, and impeller::AllocatedTextureSourceVK.

## ◆ SetCachedFramebuffer()

void impeller::TextureSourceVK::SetCachedFramebuffer | ( | const SharedHandleVK< vk::Framebuffer > & | framebuffer | ) |

Store the last framebuffer object used with this texture.

This field is only set if this texture is used as the resolve texture of a render pass. By construction, this framebuffer should be compatible with any future render passes.

Definition at line 65 of file texture_source_vk.cc.

66 {
67 framebuffer_ = framebuffer;
68 }

## ◆ SetCachedRenderPass()

void impeller::TextureSourceVK::SetCachedRenderPass | ( | const SharedHandleVK< vk::RenderPass > & | render_pass | ) |

Store the last render pass object used with this texture.

This field is only set if this texture is used as the resolve texture of a render pass. By construction, this framebuffer should be compatible with any future render passes.

Definition at line 70 of file texture_source_vk.cc.

71 {
72 render_pass_ = render_pass;
73 }

## ◆ 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`.

Parameters

  [in] | barrier | The barrier.

Returns
  If the layout transition was successfully made.

Definition at line 34 of file texture_source_vk.cc.

34 {
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 }
impeller::TextureSourceVK::GetImage
virtual vk::Image GetImage() const =0
Get the image handle for this texture source.
impeller::TextureSourceVK::SetLayoutWithoutEncoding
vk::ImageLayout SetLayoutWithoutEncoding(vk::ImageLayout layout) const
Store the layout of the image.
Definition: texture_source_vk.cc:26
impeller::ToArrayLayerCount
constexpr uint32_t ToArrayLayerCount(TextureType type)
Definition: formats_vk.h:539
impeller::ToImageAspectFlags
constexpr vk::ImageAspectFlags ToImageAspectFlags(PixelFormat format)
Definition: formats_vk.h:586
impeller::TextureDescriptor::type
TextureType type
Definition: texture_descriptor.h:40
impeller::TextureDescriptor::mip_count
size_t mip_count
Definition: texture_descriptor.h:43
impeller::TextureDescriptor::format
PixelFormat format
Definition: texture_descriptor.h:41

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

  [in] | layout | The new layout.

Returns
  The old layout.

Definition at line 26 of file texture_source_vk.cc.

27 {
28 WriterLock lock(layout_mutex_);
29 const auto old_layout = layout_;
30 layout_ = layout;
31 return old_layout;
32 }

Referenced by SetLayout().

## Member Data Documentation

## ◆ desc_

const TextureDescriptor impeller::TextureSourceVK::desc_
| protected

Definition at line 155 of file texture_source_vk.h.

Referenced by GetTextureDescriptor(), and SetLayout().

The documentation for this class was generated from the following files:

- impeller/renderer/backend/vulkan/texture_source_vk.h
- impeller/renderer/backend/vulkan/texture_source_vk.cc