Flutter Impeller
impeller::SurfaceVK Class Referencefinal

#include <surface_vk.h>

Inheritance diagram for impeller::SurfaceVK:
impeller::Surface

Public Types

using SwapCallback = std::function< bool(void)>
 

Public Member Functions

 ~SurfaceVK () override
 
- Public Member Functions inherited from impeller::Surface
 Surface ()
 
 Surface (const RenderTarget &target_desc)
 
virtual ~Surface ()
 
const ISizeGetSize () const
 
bool IsValid () const
 
const RenderTargetGetRenderTarget () const
 

Static Public Member Functions

static std::unique_ptr< SurfaceVKWrapSwapchainImage (const std::shared_ptr< SwapchainTransientsVK > &transients, const std::shared_ptr< TextureSourceVK > &swapchain_image, SwapCallback swap_callback)
 Wrap the swapchain image in a Surface, which provides the additional configuration required for usage as on onscreen render target by Impeller. More...
 

Detailed Description

Definition at line 17 of file surface_vk.h.

Member Typedef Documentation

◆ SwapCallback

using impeller::SurfaceVK::SwapCallback = std::function<bool(void)>

Definition at line 19 of file surface_vk.h.

Constructor & Destructor Documentation

◆ ~SurfaceVK()

impeller::SurfaceVK::~SurfaceVK ( )
overridedefault

Member Function Documentation

◆ WrapSwapchainImage()

std::unique_ptr< SurfaceVK > impeller::SurfaceVK::WrapSwapchainImage ( const std::shared_ptr< SwapchainTransientsVK > &  transients,
const std::shared_ptr< TextureSourceVK > &  swapchain_image,
SwapCallback  swap_callback 
)
static

Wrap the swapchain image in a Surface, which provides the additional configuration required for usage as on onscreen render target by Impeller.

This creates the associated MSAA and depth+stencil texture.

Definition at line 13 of file surface_vk.cc.

16  {
17  if (!transients || !swapchain_image || !swap_callback) {
18  return nullptr;
19  }
20 
21  auto context = transients->GetContext().lock();
22  if (!context) {
23  return nullptr;
24  }
25 
26  const auto enable_msaa = transients->IsMSAAEnabled();
27 
28  const auto swapchain_tex_desc = swapchain_image->GetTextureDescriptor();
29 
30  TextureDescriptor resolve_tex_desc;
31  resolve_tex_desc.type = TextureType::kTexture2D;
32  resolve_tex_desc.format = swapchain_tex_desc.format;
33  resolve_tex_desc.size = swapchain_tex_desc.size;
34  resolve_tex_desc.usage = TextureUsage::kRenderTarget;
35  resolve_tex_desc.sample_count = SampleCount::kCount1;
36  resolve_tex_desc.storage_mode = StorageMode::kDevicePrivate;
37 
38  std::shared_ptr<Texture> resolve_tex =
39  std::make_shared<TextureVK>(context, //
40  swapchain_image //
41  );
42 
43  if (!resolve_tex) {
44  return nullptr;
45  }
46  resolve_tex->SetLabel("ImpellerOnscreenResolve");
47 
48  ColorAttachment color0;
49  color0.clear_color = Color::DarkSlateGray();
50  color0.load_action = LoadAction::kClear;
51  if (enable_msaa) {
52  color0.texture = transients->GetMSAATexture();
53  color0.store_action = StoreAction::kMultisampleResolve;
54  color0.resolve_texture = resolve_tex;
55  } else {
56  color0.texture = resolve_tex;
57  color0.store_action = StoreAction::kStore;
58  }
59 
60  RenderTarget render_target_desc;
61  render_target_desc.SetColorAttachment(color0, 0u);
62  render_target_desc.SetupDepthStencilAttachments(
63  /*context=*/*context, //
64  /*allocator=*/*context->GetResourceAllocator(), //
65  /*size=*/swapchain_tex_desc.size, //
66  /*msaa=*/enable_msaa, //
67  /*label=*/"Onscreen", //
68  /*stencil_attachment_config=*/
70  /*depth_stencil_texture=*/transients->GetDepthStencilTexture() //
71  );
72 
73  // The constructor is private. So make_unique may not be used.
74  return std::unique_ptr<SurfaceVK>(
75  new SurfaceVK(render_target_desc, std::move(swap_callback)));
76 }
static constexpr AttachmentConfig kDefaultStencilAttachmentConfig
Definition: render_target.h:68
static constexpr Color DarkSlateGray()
Definition: color.h:418

References impeller::ColorAttachment::clear_color, impeller::Color::DarkSlateGray(), impeller::TextureDescriptor::format, impeller::kClear, impeller::kCount1, impeller::RenderTarget::kDefaultStencilAttachmentConfig, impeller::kDevicePrivate, impeller::kMultisampleResolve, impeller::kRenderTarget, impeller::kStore, impeller::kTexture2D, impeller::Attachment::load_action, impeller::Attachment::resolve_texture, impeller::TextureDescriptor::sample_count, impeller::RenderTarget::SetColorAttachment(), impeller::RenderTarget::SetupDepthStencilAttachments(), impeller::TextureDescriptor::size, impeller::TextureDescriptor::storage_mode, impeller::Attachment::store_action, impeller::Attachment::texture, impeller::TextureDescriptor::type, and impeller::TextureDescriptor::usage.

Referenced by impeller::AHBSwapchainImplVK::AcquireNextDrawable(), and impeller::KHRSwapchainImplVK::AcquireNextDrawable().


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