| 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 | SetCachedFrameData (const FramebufferAndRenderPass &data, SampleCount sample_count)
const FramebufferAndRenderPass & | GetCachedFrameData (SampleCount sample_count) 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 33 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) {}
impeller::TextureSourceVK::desc_
const TextureDescriptor desc_
Definition: texture_source_vk.h:152

## Member Function Documentation

## ◆ GetCachedFrameData()

const FramebufferAndRenderPass & impeller::TextureSourceVK::GetCachedFrameData | ( | SampleCount | sample_count | ) | const

Retrieve the last framebuffer and render pass object used with this texture for a given sample count.

An empty FramebufferAndRenderPass is returned if there is no cached data for a particular sample count.

Definition at line 66 of file texture_source_vk.cc.

67 {
68 return frame_data_[static_cast<int>(sample_count) / 4];
69 }

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

## ◆ SetCachedFrameData()

void impeller::TextureSourceVK::SetCachedFrameData | ( | const FramebufferAndRenderPass & | data,
|  | SampleCount | sample_count
| ) |  |

Store the last framebuffer and render pass object used with this texture.

This method is only called 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 61 of file texture_source_vk.cc.

62 {
63 frame_data_[static_cast<int>(sample_count) / 4] = data;
64 }
data
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:69

References data.

## ◆ 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 vk::ImageLayout old_layout =
34 SetLayoutWithoutEncoding(barrier.new_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 =
46 desc_.mip_count - barrier.base_mip_level;
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 }
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:543
impeller::ToImageAspectFlags
constexpr vk::ImageAspectFlags ToImageAspectFlags(PixelFormat format)
Definition: formats_vk.h:590
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::base_mip_level, 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 152 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