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 RenderTargetGetTargetRenderPassDescriptor () const
 

Static Public Member Functions

static std::unique_ptr< SurfaceVKWrapSwapchainImage (const std::shared_ptr< Context > &context, std::shared_ptr< SwapchainImageVK > &swapchain_image, SwapCallback swap_callback)
 

Detailed Description

Definition at line 16 of file surface_vk.h.

Member Typedef Documentation

◆ SwapCallback

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

Definition at line 18 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< Context > &  context,
std::shared_ptr< SwapchainImageVK > &  swapchain_image,
SwapCallback  swap_callback 
)
static

Definition at line 13 of file surface_vk.cc.

16  {
17  if (!context || !swapchain_image || !swap_callback) {
18  return nullptr;
19  }
20 
21  TextureDescriptor msaa_tex_desc;
22  msaa_tex_desc.storage_mode = StorageMode::kDeviceTransient;
23  msaa_tex_desc.type = TextureType::kTexture2DMultisample;
24  msaa_tex_desc.sample_count = SampleCount::kCount4;
25  msaa_tex_desc.format = swapchain_image->GetPixelFormat();
26  msaa_tex_desc.size = swapchain_image->GetSize();
27  msaa_tex_desc.usage = static_cast<uint64_t>(TextureUsage::kRenderTarget);
28 
29  std::shared_ptr<Texture> msaa_tex;
30  if (!swapchain_image->HasMSAATexture()) {
31  msaa_tex = context->GetResourceAllocator()->CreateTexture(msaa_tex_desc);
32  msaa_tex->SetLabel("ImpellerOnscreenColorMSAA");
33  if (!msaa_tex) {
34  VALIDATION_LOG << "Could not allocate MSAA color texture.";
35  return nullptr;
36  }
37  swapchain_image->SetMSAATexture(msaa_tex);
38  } else {
39  msaa_tex = swapchain_image->GetMSAATexture();
40  }
41 
42  TextureDescriptor resolve_tex_desc;
43  resolve_tex_desc.type = TextureType::kTexture2D;
44  resolve_tex_desc.format = swapchain_image->GetPixelFormat();
45  resolve_tex_desc.size = swapchain_image->GetSize();
46  resolve_tex_desc.usage =
48  resolve_tex_desc.sample_count = SampleCount::kCount1;
49  resolve_tex_desc.storage_mode = StorageMode::kDevicePrivate;
50 
51  std::shared_ptr<Texture> resolve_tex =
52  std::make_shared<TextureVK>(context, //
53  swapchain_image //
54  );
55 
56  if (!resolve_tex) {
57  VALIDATION_LOG << "Could not wrap resolve texture.";
58  return nullptr;
59  }
60  resolve_tex->SetLabel("ImpellerOnscreenResolve");
61 
62  ColorAttachment color0;
63  color0.texture = msaa_tex;
64  color0.clear_color = Color::DarkSlateGray();
65  color0.load_action = LoadAction::kClear;
66  color0.store_action = StoreAction::kMultisampleResolve;
67  color0.resolve_texture = resolve_tex;
68 
69  RenderTarget render_target_desc;
70  render_target_desc.SetColorAttachment(color0, 0u);
71 
72  // The constructor is private. So make_unique may not be used.
73  return std::unique_ptr<SurfaceVK>(
74  new SurfaceVK(render_target_desc, std::move(swap_callback)));
75 }

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


The documentation for this class was generated from the following files:
impeller::StoreAction::kMultisampleResolve
@ kMultisampleResolve
impeller::TextureUsageMask
uint64_t TextureUsageMask
Definition: formats.h:274
impeller::SampleCount::kCount1
@ kCount1
impeller::TextureUsage::kRenderTarget
@ kRenderTarget
impeller::SampleCount::kCount4
@ kCount4
impeller::TextureType::kTexture2DMultisample
@ kTexture2DMultisample
impeller::Color::DarkSlateGray
static constexpr Color DarkSlateGray()
Definition: color.h:408
impeller::LoadAction::kClear
@ kClear
impeller::StorageMode::kDeviceTransient
@ kDeviceTransient
impeller::StorageMode::kDevicePrivate
@ kDevicePrivate
impeller::TextureType::kTexture2D
@ kTexture2D
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:60