Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
impeller::RenderTargetAllocator Class Reference

a wrapper around the impeller [Allocator] instance that can be used to provide caching of allocated render target textures. More...

#include <render_target.h>

Inheritance diagram for impeller::RenderTargetAllocator:
impeller::RenderTargetCache

Public Member Functions

 RenderTargetAllocator (std::shared_ptr< Allocator > allocator)
 
virtual ~RenderTargetAllocator ()=default
 
virtual RenderTarget CreateOffscreen (const Context &context, ISize size, int mip_count, std::string_view label="Offscreen", RenderTarget::AttachmentConfig color_attachment_config=RenderTarget::kDefaultColorAttachmentConfig, std::optional< RenderTarget::AttachmentConfig > stencil_attachment_config=RenderTarget::kDefaultStencilAttachmentConfig, const std::shared_ptr< Texture > &existing_color_texture=nullptr, const std::shared_ptr< Texture > &existing_depth_stencil_texture=nullptr, std::optional< PixelFormat > target_pixel_format=std::nullopt)
 
virtual RenderTarget CreateOffscreenMSAA (const Context &context, ISize size, int mip_count, std::string_view label="Offscreen MSAA", RenderTarget::AttachmentConfigMSAA color_attachment_config=RenderTarget::kDefaultColorAttachmentConfigMSAA, std::optional< RenderTarget::AttachmentConfig > stencil_attachment_config=RenderTarget::kDefaultStencilAttachmentConfig, const std::shared_ptr< Texture > &existing_color_msaa_texture=nullptr, const std::shared_ptr< Texture > &existing_color_resolve_texture=nullptr, const std::shared_ptr< Texture > &existing_depth_stencil_texture=nullptr, std::optional< PixelFormat > target_pixel_format=std::nullopt)
 
virtual void DisableCache ()
 Disable any caching until the next call to EnabledCache.
 
virtual void EnableCache ()
 Re-enable any caching if disabled.
 
virtual void Start ()
 Mark the beginning of a frame workload.
 
virtual void End ()
 Mark the end of a frame workload.
 

Detailed Description

a wrapper around the impeller [Allocator] instance that can be used to provide caching of allocated render target textures.

Definition at line 149 of file render_target.h.

Constructor & Destructor Documentation

◆ RenderTargetAllocator()

impeller::RenderTargetAllocator::RenderTargetAllocator ( std::shared_ptr< Allocator allocator)
explicit

Definition at line 314 of file render_target.cc.

316 : allocator_(std::move(allocator)) {}
std::shared_ptr< ImpellerAllocator > allocator

◆ ~RenderTargetAllocator()

virtual impeller::RenderTargetAllocator::~RenderTargetAllocator ( )
virtualdefault

Member Function Documentation

◆ CreateOffscreen()

RenderTarget impeller::RenderTargetAllocator::CreateOffscreen ( const Context context,
ISize  size,
int  mip_count,
std::string_view  label = "Offscreen",
RenderTarget::AttachmentConfig  color_attachment_config = RenderTarget::kDefaultColorAttachmentConfig,
std::optional< RenderTarget::AttachmentConfig stencil_attachment_config = RenderTarget::kDefaultStencilAttachmentConfig,
const std::shared_ptr< Texture > &  existing_color_texture = nullptr,
const std::shared_ptr< Texture > &  existing_depth_stencil_texture = nullptr,
std::optional< PixelFormat target_pixel_format = std::nullopt 
)
virtual

Reimplemented in impeller::RenderTargetCache.

Definition at line 322 of file render_target.cc.

331 {
332 if (size.IsEmpty()) {
333 return {};
334 }
335
336 RenderTarget target;
337
338 std::shared_ptr<Texture> color0_tex;
339 if (existing_color_texture) {
340 color0_tex = existing_color_texture;
341 } else {
342 TextureDescriptor color0_tex_desc;
343 color0_tex_desc.storage_mode = color_attachment_config.storage_mode;
344 color0_tex_desc.format =
345 target_pixel_format.has_value()
346 ? target_pixel_format.value()
347 : context.GetCapabilities()->GetDefaultColorFormat();
348 color0_tex_desc.size = size;
349 color0_tex_desc.mip_count = mip_count;
350 color0_tex_desc.usage =
352 color0_tex = allocator_->CreateTexture(color0_tex_desc);
353 if (!color0_tex) {
354 return {};
355 }
356 }
357 color0_tex->SetLabel(label, "Color Texture");
358
359 ColorAttachment color0;
360 color0.clear_color = color_attachment_config.clear_color;
361 color0.load_action = color_attachment_config.load_action;
362 color0.store_action = color_attachment_config.store_action;
363 color0.texture = color0_tex;
364 target.SetColorAttachment(color0, 0u);
365
366 if (stencil_attachment_config.has_value()) {
367 target.SetupDepthStencilAttachments(
368 context, *allocator_, size, false, label,
369 stencil_attachment_config.value(), existing_depth_stencil_texture);
370 } else {
371 target.SetStencilAttachment(std::nullopt);
372 target.SetDepthAttachment(std::nullopt);
373 }
374
375 return target;
376}
uint32_t * target
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 impeller::ColorAttachment::clear_color, impeller::RenderTarget::AttachmentConfig::clear_color, impeller::TextureDescriptor::format, impeller::Context::GetCapabilities(), impeller::kRenderTarget, impeller::kShaderRead, impeller::Attachment::load_action, impeller::RenderTarget::AttachmentConfig::load_action, impeller::TextureDescriptor::mip_count, impeller::TextureDescriptor::size, impeller::TextureDescriptor::storage_mode, impeller::RenderTarget::AttachmentConfig::storage_mode, impeller::Attachment::store_action, impeller::RenderTarget::AttachmentConfig::store_action, target, impeller::Attachment::texture, and impeller::TextureDescriptor::usage.

Referenced by impeller::RenderTargetCache::CreateOffscreen(), and impeller::DisplayListToTexture().

◆ CreateOffscreenMSAA()

RenderTarget impeller::RenderTargetAllocator::CreateOffscreenMSAA ( const Context context,
ISize  size,
int  mip_count,
std::string_view  label = "Offscreen MSAA",
RenderTarget::AttachmentConfigMSAA  color_attachment_config = RenderTarget::kDefaultColorAttachmentConfigMSAA,
std::optional< RenderTarget::AttachmentConfig stencil_attachment_config = RenderTarget::kDefaultStencilAttachmentConfig,
const std::shared_ptr< Texture > &  existing_color_msaa_texture = nullptr,
const std::shared_ptr< Texture > &  existing_color_resolve_texture = nullptr,
const std::shared_ptr< Texture > &  existing_depth_stencil_texture = nullptr,
std::optional< PixelFormat target_pixel_format = std::nullopt 
)
virtual

Reimplemented in impeller::RenderTargetCache.

Definition at line 378 of file render_target.cc.

388 {
389 if (size.IsEmpty()) {
390 return {};
391 }
392
393 RenderTarget target;
394 PixelFormat pixel_format =
395 target_pixel_format.has_value()
396 ? target_pixel_format.value()
397 : context.GetCapabilities()->GetDefaultColorFormat();
398
399 // Create MSAA color texture.
400 std::shared_ptr<Texture> color0_msaa_tex;
401 if (existing_color_msaa_texture) {
402 color0_msaa_tex = existing_color_msaa_texture;
403 } else {
404 TextureDescriptor color0_tex_desc;
405 color0_tex_desc.storage_mode = color_attachment_config.storage_mode;
406 color0_tex_desc.type = TextureType::kTexture2DMultisample;
407 color0_tex_desc.sample_count = SampleCount::kCount4;
408 color0_tex_desc.format = pixel_format;
409 color0_tex_desc.size = size;
410 color0_tex_desc.usage = TextureUsage::kRenderTarget;
411 if (context.GetCapabilities()->SupportsImplicitResolvingMSAA()) {
412 // See below ("SupportsImplicitResolvingMSAA") for more details.
413 color0_tex_desc.storage_mode = StorageMode::kDevicePrivate;
414 }
415 color0_msaa_tex = allocator_->CreateTexture(color0_tex_desc);
416 if (!color0_msaa_tex) {
417 VALIDATION_LOG << "Could not create multisample color texture.";
418 return {};
419 }
420 }
421 color0_msaa_tex->SetLabel(label, "Color Texture (Multisample)");
422
423 // Create color resolve texture.
424 std::shared_ptr<Texture> color0_resolve_tex;
425 if (existing_color_resolve_texture) {
426 color0_resolve_tex = existing_color_resolve_texture;
427 } else {
428 TextureDescriptor color0_resolve_tex_desc;
429 color0_resolve_tex_desc.storage_mode =
430 color_attachment_config.resolve_storage_mode;
431 color0_resolve_tex_desc.format = pixel_format;
432 color0_resolve_tex_desc.size = size;
433 color0_resolve_tex_desc.compression_type = CompressionType::kLossy;
434 color0_resolve_tex_desc.usage =
436 color0_resolve_tex_desc.mip_count = mip_count;
437 color0_resolve_tex = allocator_->CreateTexture(color0_resolve_tex_desc);
438 if (!color0_resolve_tex) {
439 VALIDATION_LOG << "Could not create color texture.";
440 return {};
441 }
442 }
443 color0_resolve_tex->SetLabel(label, "Color Texture");
444
445 // Color attachment.
446
447 ColorAttachment color0;
448 color0.clear_color = color_attachment_config.clear_color;
449 color0.load_action = color_attachment_config.load_action;
450 color0.store_action = color_attachment_config.store_action;
451 color0.texture = color0_msaa_tex;
452 color0.resolve_texture = color0_resolve_tex;
453
454 if (context.GetCapabilities()->SupportsImplicitResolvingMSAA()) {
455 // If implicit MSAA is supported, then the resolve texture is not needed
456 // because the multisample texture is automatically resolved. We instead
457 // provide a view of the multisample texture as the resolve texture (because
458 // the HAL does expect a resolve texture).
459 //
460 // In practice, this is used for GLES 2.0 EXT_multisampled_render_to_texture
461 // https://registry.khronos.org/OpenGL/extensions/EXT/EXT_multisampled_render_to_texture.txt
462 color0.resolve_texture = color0_msaa_tex;
463 }
464
465 target.SetColorAttachment(color0, 0u);
466
467 // Create MSAA stencil texture.
468
469 if (stencil_attachment_config.has_value()) {
470 target.SetupDepthStencilAttachments(context, *allocator_, size, true, label,
471 stencil_attachment_config.value(),
472 existing_depth_stencil_texture);
473 } else {
474 target.SetDepthAttachment(std::nullopt);
475 target.SetStencilAttachment(std::nullopt);
476 }
477
478 return target;
479}
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition formats.h:99
#define VALIDATION_LOG
Definition validation.h:91

References impeller::ColorAttachment::clear_color, impeller::RenderTarget::AttachmentConfigMSAA::clear_color, impeller::TextureDescriptor::compression_type, impeller::TextureDescriptor::format, impeller::Context::GetCapabilities(), impeller::kCount4, impeller::kDevicePrivate, impeller::kLossy, impeller::kRenderTarget, impeller::kShaderRead, impeller::kTexture2DMultisample, impeller::Attachment::load_action, impeller::RenderTarget::AttachmentConfigMSAA::load_action, impeller::TextureDescriptor::mip_count, impeller::RenderTarget::AttachmentConfigMSAA::resolve_storage_mode, impeller::Attachment::resolve_texture, impeller::TextureDescriptor::sample_count, impeller::TextureDescriptor::size, impeller::TextureDescriptor::storage_mode, impeller::RenderTarget::AttachmentConfigMSAA::storage_mode, impeller::Attachment::store_action, impeller::RenderTarget::AttachmentConfigMSAA::store_action, target, impeller::Attachment::texture, impeller::TextureDescriptor::type, impeller::TextureDescriptor::usage, and VALIDATION_LOG.

Referenced by impeller::RenderTargetCache::CreateOffscreenMSAA(), impeller::DisplayListToTexture(), and impeller::ContextVK::InitializeCommonlyUsedShadersIfNeeded().

◆ DisableCache()

virtual void impeller::RenderTargetAllocator::DisableCache ( )
inlinevirtual

Disable any caching until the next call to EnabledCache.

Reimplemented in impeller::RenderTargetCache.

Definition at line 183 of file render_target.h.

183{}

◆ EnableCache()

virtual void impeller::RenderTargetAllocator::EnableCache ( )
inlinevirtual

Re-enable any caching if disabled.

Reimplemented in impeller::RenderTargetCache.

Definition at line 186 of file render_target.h.

186{}

◆ End()

void impeller::RenderTargetAllocator::End ( )
virtual

Mark the end of a frame workload.

   This may be used to deallocate any unused textures. 

Reimplemented in impeller::RenderTargetCache.

Definition at line 320 of file render_target.cc.

320{}

◆ Start()

void impeller::RenderTargetAllocator::Start ( )
virtual

Mark the beginning of a frame workload.

  This may be used to reset any tracking state on whether or not a
  particular texture instance is still in use. 

Reimplemented in impeller::RenderTargetCache.

Definition at line 318 of file render_target.cc.

318{}

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