Flutter Engine
 
Loading...
Searching...
No Matches
impeller::SwapchainTransientsMTL Class Reference

A cache for the onscreen texture attachments used in surface_mtl. More...

#include <swapchain_transients_mtl.h>

Public Member Functions

 SwapchainTransientsMTL (const std::shared_ptr< Allocator > &allocator)
 
 ~SwapchainTransientsMTL ()
 
void SetSizeAndFormat (ISize size, PixelFormat format)
 Update the size and pixel format of the onscreens.
 
std::shared_ptr< TextureGetResolveTexture ()
 Retrieve the resolve texture, creating one if needed.
 
std::shared_ptr< TextureGetMSAATexture ()
 Retrieve the MSAA texture, creating one if needed.
 
std::shared_ptr< TextureGetDepthStencilTexture ()
 Retrieve the depth+stencil texture, creating one if needed.
 

Detailed Description

A cache for the onscreen texture attachments used in surface_mtl.

Typically the onscreen resolve texture is created from a Metal drawable and this cache is only used for the MSAA texture and the depth+stencil attachment. When partial repaint is active, this class also provides a cache for an offscreen resolve texture that is blitted to the real onscreen during present.

Definition at line 25 of file swapchain_transients_mtl.h.

Constructor & Destructor Documentation

◆ SwapchainTransientsMTL()

impeller::SwapchainTransientsMTL::SwapchainTransientsMTL ( const std::shared_ptr< Allocator > &  allocator)
explicit

Definition at line 12 of file swapchain_transients_mtl.mm.

14 : allocator_(allocator) {}

◆ ~SwapchainTransientsMTL()

impeller::SwapchainTransientsMTL::~SwapchainTransientsMTL ( )
default

Member Function Documentation

◆ GetDepthStencilTexture()

std::shared_ptr< Texture > impeller::SwapchainTransientsMTL::GetDepthStencilTexture ( )

Retrieve the depth+stencil texture, creating one if needed.

Definition at line 71 of file swapchain_transients_mtl.mm.

71 {
72 if (!depth_stencil_tex_) {
73 TextureDescriptor desc;
74 desc.size = size_;
75 desc.sample_count = SampleCount::kCount4;
76 desc.format = PixelFormat::kD32FloatS8UInt;
77 desc.storage_mode = StorageMode::kDeviceTransient;
78 desc.usage = TextureUsage::kRenderTarget;
80
81 depth_stencil_tex_ = allocator_->CreateTexture(desc);
82 if (!depth_stencil_tex_) {
83 VALIDATION_LOG << "Failed to allocate depth-stencil texture.";
84 return nullptr;
85 }
86 depth_stencil_tex_->SetLabel("ImpellerOnscreenDepth+Stencil");
87 }
88
89 return depth_stencil_tex_;
90}
#define VALIDATION_LOG
Definition validation.h:91

References impeller::TextureDescriptor::format, impeller::kCount4, impeller::kD32FloatS8UInt, impeller::kDeviceTransient, impeller::kRenderTarget, impeller::kTexture2DMultisample, impeller::TextureDescriptor::sample_count, impeller::TextureDescriptor::size, impeller::TextureDescriptor::storage_mode, impeller::TextureDescriptor::type, impeller::TextureDescriptor::usage, and VALIDATION_LOG.

◆ GetMSAATexture()

std::shared_ptr< Texture > impeller::SwapchainTransientsMTL::GetMSAATexture ( )

Retrieve the MSAA texture, creating one if needed.

Definition at line 50 of file swapchain_transients_mtl.mm.

50 {
51 if (!msaa_tex_) {
52 TextureDescriptor desc;
53 desc.size = size_;
54 desc.sample_count = SampleCount::kCount4;
55 desc.format = format_;
56 desc.storage_mode = StorageMode::kDeviceTransient;
57 desc.usage = TextureUsage::kRenderTarget;
59
60 msaa_tex_ = allocator_->CreateTexture(desc);
61 if (!msaa_tex_) {
62 VALIDATION_LOG << "Failed to allocate MSAA texture.";
63 return nullptr;
64 }
65 msaa_tex_->SetLabel("ImpellerOnscreenMSAA");
66 }
67
68 return msaa_tex_;
69}

References impeller::TextureDescriptor::format, impeller::kCount4, impeller::kDeviceTransient, impeller::kRenderTarget, impeller::kTexture2DMultisample, impeller::TextureDescriptor::sample_count, impeller::TextureDescriptor::size, impeller::TextureDescriptor::storage_mode, impeller::TextureDescriptor::type, impeller::TextureDescriptor::usage, and VALIDATION_LOG.

◆ GetResolveTexture()

std::shared_ptr< Texture > impeller::SwapchainTransientsMTL::GetResolveTexture ( )

Retrieve the resolve texture, creating one if needed.

Definition at line 28 of file swapchain_transients_mtl.mm.

28 {
29 if (!resolve_tex_) {
30 TextureDescriptor desc;
31 desc.size = size_;
32 desc.sample_count = SampleCount::kCount1;
33 desc.format = format_;
34 desc.storage_mode = StorageMode::kDevicePrivate;
36 desc.compression_type = CompressionType::kLossy;
37 desc.type = TextureType::kTexture2D;
38
39 resolve_tex_ = allocator_->CreateTexture(desc);
40 if (!resolve_tex_) {
41 VALIDATION_LOG << "Failed to allocate resolve texture.";
42 return nullptr;
43 }
44 resolve_tex_->SetLabel("ImpellerOnscreenResolve");
45 }
46
47 return resolve_tex_;
48}

References impeller::TextureDescriptor::compression_type, impeller::TextureDescriptor::format, impeller::kCount1, impeller::kDevicePrivate, impeller::kLossy, impeller::kRenderTarget, impeller::kShaderRead, impeller::kTexture2D, impeller::TextureDescriptor::sample_count, impeller::TextureDescriptor::size, impeller::TextureDescriptor::storage_mode, impeller::TextureDescriptor::type, impeller::TextureDescriptor::usage, and VALIDATION_LOG.

◆ SetSizeAndFormat()

void impeller::SwapchainTransientsMTL::SetSizeAndFormat ( ISize  size,
PixelFormat  format 
)

Update the size and pixel format of the onscreens.

Note: this will invalidate any cached textures if either property changes.

Definition at line 18 of file swapchain_transients_mtl.mm.

18 {
19 if (size != size_ || format != format_) {
20 resolve_tex_ = nullptr;
21 msaa_tex_ = nullptr;
22 depth_stencil_tex_ = nullptr;
23 }
24 size_ = size;
25 format_ = format;
26}
uint32_t uint32_t * format
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size

References format.


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