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 329 of file render_target.cc.

331 : 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 337 of file render_target.cc.

346 {
347 if (size.IsEmpty()) {
348 return {};
349 }
350
351 RenderTarget target;
352
353 std::shared_ptr<Texture> color0_tex;
354 if (existing_color_texture) {
355 color0_tex = existing_color_texture;
356 } else {
357 TextureDescriptor color0_tex_desc;
358 color0_tex_desc.storage_mode = color_attachment_config.storage_mode;
359 color0_tex_desc.format =
360 target_pixel_format.has_value()
361 ? target_pixel_format.value()
362 : context.GetCapabilities()->GetDefaultColorFormat();
363 color0_tex_desc.size = size;
364 color0_tex_desc.mip_count = mip_count;
365 color0_tex_desc.usage =
367 color0_tex = allocator_->CreateTexture(color0_tex_desc);
368 if (!color0_tex) {
369 return {};
370 }
371 }
372 color0_tex->SetLabel(label, "Color Texture");
373
374 ColorAttachment color0;
375 color0.clear_color = color_attachment_config.clear_color;
376 color0.load_action = color_attachment_config.load_action;
377 color0.store_action = color_attachment_config.store_action;
378 color0.texture = color0_tex;
379 target.SetColorAttachment(color0, 0u);
380
381 if (stencil_attachment_config.has_value()) {
382 target.SetupDepthStencilAttachments(
383 context, *allocator_, size, false, label,
384 stencil_attachment_config.value(), existing_depth_stencil_texture);
385 } else {
386 target.SetStencilAttachment(std::nullopt);
387 target.SetDepthAttachment(std::nullopt);
388 }
389
390 return target;
391}
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
std::shared_ptr< ContextGLES > context

References impeller::ColorAttachment::clear_color, impeller::RenderTarget::AttachmentConfig::clear_color, context, impeller::TextureDescriptor::format, 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(), impeller::DisplayListToTexture(), flutter::testing::DlSurfaceProviderImpeller::MakeOffscreenSurface(), and impeller::GoldenPlaygroundTest::OpenPlaygroundHere().

◆ 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 393 of file render_target.cc.

403 {
404 if (size.IsEmpty()) {
405 return {};
406 }
407
408 RenderTarget target;
409 PixelFormat pixel_format =
410 target_pixel_format.has_value()
411 ? target_pixel_format.value()
412 : context.GetCapabilities()->GetDefaultColorFormat();
413
414 // Create MSAA color texture.
415 std::shared_ptr<Texture> color0_msaa_tex;
416 if (existing_color_msaa_texture) {
417 color0_msaa_tex = existing_color_msaa_texture;
418 } else {
419 TextureDescriptor color0_tex_desc;
420 color0_tex_desc.storage_mode = color_attachment_config.storage_mode;
421 color0_tex_desc.type = TextureType::kTexture2DMultisample;
422 color0_tex_desc.sample_count = SampleCount::kCount4;
423 color0_tex_desc.format = pixel_format;
424 color0_tex_desc.size = size;
425 color0_tex_desc.usage = TextureUsage::kRenderTarget;
426 if (context.GetCapabilities()->SupportsImplicitResolvingMSAA()) {
427 // See below ("SupportsImplicitResolvingMSAA") for more details.
428 color0_tex_desc.storage_mode = StorageMode::kDevicePrivate;
429 }
430 color0_msaa_tex = allocator_->CreateTexture(color0_tex_desc);
431 if (!color0_msaa_tex) {
432 VALIDATION_LOG << "Could not create multisample color texture.";
433 return {};
434 }
435 }
436 color0_msaa_tex->SetLabel(label, "Color Texture (Multisample)");
437
438 // Create color resolve texture.
439 std::shared_ptr<Texture> color0_resolve_tex;
440 if (existing_color_resolve_texture) {
441 color0_resolve_tex = existing_color_resolve_texture;
442 } else {
443 TextureDescriptor color0_resolve_tex_desc;
444 color0_resolve_tex_desc.storage_mode =
445 color_attachment_config.resolve_storage_mode;
446 color0_resolve_tex_desc.format = pixel_format;
447 color0_resolve_tex_desc.size = size;
448 color0_resolve_tex_desc.compression_type = CompressionType::kLossy;
449 color0_resolve_tex_desc.usage =
451 color0_resolve_tex_desc.mip_count = mip_count;
452 color0_resolve_tex = allocator_->CreateTexture(color0_resolve_tex_desc);
453 if (!color0_resolve_tex) {
454 VALIDATION_LOG << "Could not create color texture.";
455 return {};
456 }
457 }
458 color0_resolve_tex->SetLabel(label, "Color Texture");
459
460 // Color attachment.
461
462 ColorAttachment color0;
463 color0.clear_color = color_attachment_config.clear_color;
464 color0.load_action = color_attachment_config.load_action;
465 color0.store_action = color_attachment_config.store_action;
466 color0.texture = color0_msaa_tex;
467 color0.resolve_texture = color0_resolve_tex;
468
469 if (context.GetCapabilities()->SupportsImplicitResolvingMSAA()) {
470 // If implicit MSAA is supported, then the resolve texture is not needed
471 // because the multisample texture is automatically resolved. We instead
472 // provide a view of the multisample texture as the resolve texture (because
473 // the HAL does expect a resolve texture).
474 //
475 // In practice, this is used for GLES 2.0 EXT_multisampled_render_to_texture
476 // https://registry.khronos.org/OpenGL/extensions/EXT/EXT_multisampled_render_to_texture.txt
477 color0.resolve_texture = color0_msaa_tex;
478 }
479
480 target.SetColorAttachment(color0, 0u);
481
482 // Create MSAA stencil texture.
483
484 if (stencil_attachment_config.has_value()) {
485 target.SetupDepthStencilAttachments(context, *allocator_, size, true, label,
486 stencil_attachment_config.value(),
487 existing_depth_stencil_texture);
488 } else {
489 target.SetDepthAttachment(std::nullopt);
490 target.SetStencilAttachment(std::nullopt);
491 }
492
493 return target;
494}
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, context, impeller::TextureDescriptor::format, 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(), impeller::ContextVK::InitializeCommonlyUsedShadersIfNeeded(), and flutter::testing::DlSurfaceProviderImpeller::MakeOffscreenSurface().

◆ 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 335 of file render_target.cc.

335{}

◆ 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 333 of file render_target.cc.

333{}

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