| 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 26 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:153

## 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 69 of file texture_source_vk.cc.

69 {
70 return framebuffer_;
71 }

## ◆ 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 73 of file texture_source_vk.cc.

73 {
74 return render_pass_;
75 }

## ◆ 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 return layout_;
23 }

## ◆ 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 59 of file texture_source_vk.cc.

60 {
61 framebuffer_ = framebuffer;
62 }

## ◆ 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 64 of file texture_source_vk.cc.

65 {
66 render_pass_ = render_pass;
67 }

## ◆ 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 32 of file texture_source_vk.cc.

32 {
33 const auto old_layout = SetLayoutWithoutEncoding(barrier.new_layout);
34 vk::ImageMemoryBarrier image_barrier;
35 image_barrier.srcAccessMask = barrier.src_access;
36 image_barrier.dstAccessMask = barrier.dst_access;
37 image_barrier.oldLayout = old_layout;
38 image_barrier.newLayout = barrier.new_layout;
39 image_barrier.image = GetImage();
40 image_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
41 image_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
42 image_barrier.subresourceRange.aspectMask = ToImageAspectFlags(desc_.format);
43 image_barrier.subresourceRange.baseMipLevel = 0u;
44 image_barrier.subresourceRange.levelCount = desc_.mip_count;
45 image_barrier.subresourceRange.baseArrayLayer = 0u;
46 image_barrier.subresourceRange.layerCount = ToArrayLayerCount(desc_.type);
47
48 barrier.cmd_buffer.pipelineBarrier(barrier.src_stage, // src stage
49 barrier.dst_stage, // dst stage
50 {}, // dependency flags
51 nullptr, // memory barriers
52 nullptr, // buffer barriers
53 image_barrier // image barriers
54 );
55
56 return {};
57 }
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:25
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 25 of file texture_source_vk.cc.

26 {
27 const auto old_layout = layout_;
28 layout_ = layout;
29 return old_layout;
30 }

Referenced by SetLayout().

## Member Data Documentation

## ◆ desc_

const TextureDescriptor impeller::TextureSourceVK::desc_
| protected

Definition at line 153 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