Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
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:
flutter::WrappedTextureSourceVK impeller::AHBTextureSourceVK impeller::AllocatedTextureSourceVK impeller::KHRSwapchainImageVK

Public Member Functions

virtual ~TextureSourceVK ()
 
const TextureDescriptorGetTextureDescriptor () const
 Gets the texture descriptor for this image source.
 
virtual vk::Image GetImage () const =0
 Get the image handle for this texture source.
 
virtual vk::ImageView GetImageView () const =0
 Retrieve the image view used for sampling/blitting/compute with this texture source.
 
virtual vk::ImageView GetRenderTargetView (uint32_t mip_level, uint32_t array_layer) const =0
 Retrieve the image view used to attach a specific subresource of this texture as a render target.
 
fml::Status SetLayout (const BarrierVK &barrier) const
 Encodes the layout transition barrier to barrier.cmd_buffer for the image.
 
vk::ImageLayout SetLayoutWithoutEncoding (vk::ImageLayout layout) const
 Store the layout of the image.
 
vk::ImageLayout GetLayout () const
 Get the last layout assigned to the TextureSourceVK.
 
virtual std::shared_ptr< YUVConversionVKGetYUVConversion () 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.
 
virtual bool IsSwapchainImage () const =0
 Determines if swapchain image. That is, an image used as the root render target.
 
void SetCachedFrameData (const FramebufferAndRenderPass &data, SampleCount sample_count, uint32_t mip_level=0u, uint32_t slice=0u)
 
FramebufferAndRenderPass GetCachedFrameData (SampleCount sample_count, uint32_t mip_level=0u, uint32_t slice=0u) 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 36 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) {}
const TextureDescriptor desc_

Member Function Documentation

◆ GetCachedFrameData()

FramebufferAndRenderPass impeller::TextureSourceVK::GetCachedFrameData ( SampleCount  sample_count,
uint32_t  mip_level = 0u,
uint32_t  slice = 0u 
) const

Retrieve the cached framebuffer and render pass for the given (sample_count, mip_level, slice) subresource.

An empty FramebufferAndRenderPass is returned when no cached entry exists for that key. Entries are populated lazily on first use and live for the lifetime of the texture.

Definition at line 75 of file texture_source_vk.cc.

78 {
79 for (const auto& entry : frame_data_) {
80 if (entry.sample_count == sample_count && entry.mip_level == mip_level &&
81 entry.slice == slice) {
82 return entry.data;
83 }
84 }
85 return {};
86}

◆ GetImage()

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

Get the image handle for this texture source.

Returns
The image.

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

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::AllocatedTextureSourceVK, impeller::AHBTextureSourceVK, and impeller::KHRSwapchainImageVK.

◆ 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 ( uint32_t  mip_level,
uint32_t  array_layer 
) const
pure virtual

Retrieve the image view used to attach a specific subresource of this texture as a render target.

The returned view covers a single mip level and a single array layer (or cube map face), since attachment views cannot span multiple levels or layers.

Parameters
[in]mip_levelThe mip level to attach.
[in]array_layerThe array layer or cube map face to attach.
Returns
The render target view.

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

◆ 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::AllocatedTextureSourceVK, impeller::AHBTextureSourceVK, and impeller::KHRSwapchainImageVK.

◆ SetCachedFrameData()

void impeller::TextureSourceVK::SetCachedFrameData ( const FramebufferAndRenderPass data,
SampleCount  sample_count,
uint32_t  mip_level = 0u,
uint32_t  slice = 0u 
)

Store the framebuffer and render pass last used to render into the (sample_count, mip_level, slice) subresource of this texture.

This is only called when this texture is being used as the resolve (or non-MSAA color) target of a render pass. By construction, the cached objects are compatible with any future render pass that targets the same subresource.

Definition at line 61 of file texture_source_vk.cc.

64 {
65 for (auto& entry : frame_data_) {
66 if (entry.sample_count == sample_count && entry.mip_level == mip_level &&
67 entry.slice == slice) {
68 entry.data = data;
69 return;
70 }
71 }
72 frame_data_.push_back({sample_count, mip_level, slice, data});
73}
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switch_defs.h:36

◆ 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]barrierThe 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}
virtual vk::Image GetImage() const =0
Get the image handle for this texture source.
vk::ImageLayout SetLayoutWithoutEncoding(vk::ImageLayout layout) const
Store the layout of the image.
constexpr uint32_t ToArrayLayerCount(TextureType type)
Definition formats_vk.h:611
constexpr vk::ImageAspectFlags ToImageAspectFlags(PixelFormat format)
Definition formats_vk.h:658

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]layoutThe 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 164 of file texture_source_vk.h.

Referenced by GetTextureDescriptor(), and SetLayout().


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