Flutter Impeller
impeller::PipelineVK Class Referencefinal

#include <pipeline_vk.h>

Inheritance diagram for impeller::PipelineVK:
impeller::Pipeline< PipelineDescriptor > impeller::BackendCast< PipelineVK, Pipeline< PipelineDescriptor > >

Public Member Functions

 ~PipelineVK () override
 
vk::Pipeline GetPipeline () const
 
const vk::PipelineLayout & GetPipelineLayout () const
 
const vk::DescriptorSetLayout & GetDescriptorSetLayout () const
 
std::shared_ptr< PipelineVKCreateVariantForImmutableSamplers (const std::shared_ptr< SamplerVK > &immutable_sampler) const
 
- Public Member Functions inherited from impeller::Pipeline< PipelineDescriptor >
virtual ~Pipeline ()
 
virtual bool IsValid () const=0
 
const PipelineDescriptorGetDescriptor () const
 Get the descriptor that was responsible for creating this pipeline. It may be copied and modified to create a pipeline variant. More...
 
PipelineFuture< PipelineDescriptorCreateVariant (bool async, std::function< void(PipelineDescriptor &desc)> descriptor_callback) const
 

Static Public Member Functions

static std::unique_ptr< PipelineVKCreate (const PipelineDescriptor &desc, const std::shared_ptr< DeviceHolderVK > &device_holder, const std::weak_ptr< PipelineLibrary > &weak_library, std::shared_ptr< SamplerVK > immutable_sampler={})
 
- Static Public Member Functions inherited from impeller::BackendCast< PipelineVK, Pipeline< PipelineDescriptor > >
static PipelineVKCast (Pipeline< PipelineDescriptor > &base)
 
static const PipelineVKCast (const Pipeline< PipelineDescriptor > &base)
 
static PipelineVKCast (Pipeline< PipelineDescriptor > *base)
 
static const PipelineVKCast (const Pipeline< PipelineDescriptor > *base)
 

Friends

class PipelineLibraryVK
 

Additional Inherited Members

- Protected Member Functions inherited from impeller::Pipeline< PipelineDescriptor >
 Pipeline (std::weak_ptr< PipelineLibrary > library, PipelineDescriptor desc)
 
- Protected Attributes inherited from impeller::Pipeline< PipelineDescriptor >
const std::weak_ptr< PipelineLibrarylibrary_
 
const PipelineDescriptor desc_
 

Detailed Description

Definition at line 28 of file pipeline_vk.h.

Constructor & Destructor Documentation

◆ ~PipelineVK()

impeller::PipelineVK::~PipelineVK ( )
override

Definition at line 526 of file pipeline_vk.cc.

526  {
527  if (auto device = device_holder_.lock(); !device) {
528  descriptor_set_layout_.release();
529  layout_.release();
530  render_pass_.release();
531  pipeline_.release();
532  }
533 }

Member Function Documentation

◆ Create()

std::unique_ptr< PipelineVK > impeller::PipelineVK::Create ( const PipelineDescriptor desc,
const std::shared_ptr< DeviceHolderVK > &  device_holder,
const std::weak_ptr< PipelineLibrary > &  weak_library,
std::shared_ptr< SamplerVK immutable_sampler = {} 
)
static

Definition at line 449 of file pipeline_vk.cc.

453  {
454  TRACE_EVENT1("flutter", "PipelineVK::Create", "Name",
455  desc.GetLabel().c_str());
456 
457  auto library = weak_library.lock();
458 
459  if (!device_holder || !library) {
460  return nullptr;
461  }
462 
463  const auto& pso_cache = PipelineLibraryVK::Cast(*library).GetPSOCache();
464 
465  fml::StatusOr<vk::UniqueDescriptorSetLayout> descs_layout =
466  MakeDescriptorSetLayout(desc, device_holder, immutable_sampler);
467  if (!descs_layout.ok()) {
468  return nullptr;
469  }
470 
471  fml::StatusOr<vk::UniquePipelineLayout> pipeline_layout =
472  MakePipelineLayout(desc, device_holder, descs_layout.value().get());
473  if (!pipeline_layout.ok()) {
474  return nullptr;
475  }
476 
477  vk::UniqueRenderPass render_pass =
478  CreateCompatRenderPassForPipeline(device_holder->GetDevice(), desc);
479  if (!render_pass) {
480  VALIDATION_LOG << "Could not create render pass for pipeline.";
481  return nullptr;
482  }
483 
484  fml::StatusOr<vk::UniquePipeline> pipeline =
485  MakePipeline(desc, device_holder, pso_cache,
486  pipeline_layout.value().get(), render_pass.get());
487  if (!pipeline.ok()) {
488  return nullptr;
489  }
490 
491  auto pipeline_vk = std::unique_ptr<PipelineVK>(new PipelineVK(
492  device_holder, //
493  library, //
494  desc, //
495  std::move(pipeline.value()), //
496  std::move(render_pass), //
497  std::move(pipeline_layout.value()), //
498  std::move(descs_layout.value()), //
499  std::move(immutable_sampler) //
500  ));
501  if (!pipeline_vk->IsValid()) {
502  VALIDATION_LOG << "Could not create a valid pipeline.";
503  return nullptr;
504  }
505  return pipeline_vk;
506 }

References impeller::BackendCast< PipelineLibraryVK, PipelineLibrary >::Cast(), impeller::CreateCompatRenderPassForPipeline(), impeller::PipelineDescriptor::GetLabel(), impeller::PipelineLibraryVK::GetPSOCache(), and VALIDATION_LOG.

Referenced by CreateVariantForImmutableSamplers().

◆ CreateVariantForImmutableSamplers()

std::shared_ptr< PipelineVK > impeller::PipelineVK::CreateVariantForImmutableSamplers ( const std::shared_ptr< SamplerVK > &  immutable_sampler) const

Definition at line 551 of file pipeline_vk.cc.

552  {
553  if (!immutable_sampler) {
554  return nullptr;
555  }
556  auto cache_key = ImmutableSamplerKeyVK{*immutable_sampler};
557  Lock lock(immutable_sampler_variants_mutex_);
558  auto found = immutable_sampler_variants_.find(cache_key);
559  if (found != immutable_sampler_variants_.end()) {
560  return found->second;
561  }
562  auto device_holder = device_holder_.lock();
563  if (!device_holder) {
564  return nullptr;
565  }
566  return (immutable_sampler_variants_[cache_key] =
567  Create(desc_, device_holder, library_, immutable_sampler));
568 }

References Create(), impeller::Pipeline< PipelineDescriptor >::desc_, and impeller::Pipeline< PipelineDescriptor >::library_.

◆ GetDescriptorSetLayout()

const vk::DescriptorSetLayout & impeller::PipelineVK::GetDescriptorSetLayout ( ) const

Definition at line 547 of file pipeline_vk.cc.

547  {
548  return *descriptor_set_layout_;
549 }

◆ GetPipeline()

vk::Pipeline impeller::PipelineVK::GetPipeline ( ) const

Definition at line 539 of file pipeline_vk.cc.

539  {
540  return *pipeline_;
541 }

◆ GetPipelineLayout()

const vk::PipelineLayout & impeller::PipelineVK::GetPipelineLayout ( ) const

Definition at line 543 of file pipeline_vk.cc.

543  {
544  return *layout_;
545 }

Friends And Related Function Documentation

◆ PipelineLibraryVK

friend class PipelineLibraryVK
friend

Definition at line 51 of file pipeline_vk.h.


The documentation for this class was generated from the following files:
impeller::CreateCompatRenderPassForPipeline
static vk::UniqueRenderPass CreateCompatRenderPassForPipeline(const vk::Device &device, const PipelineDescriptor &desc)
Definition: pipeline_vk.cc:126
impeller::PipelineVK::Create
static std::unique_ptr< PipelineVK > Create(const PipelineDescriptor &desc, const std::shared_ptr< DeviceHolderVK > &device_holder, const std::weak_ptr< PipelineLibrary > &weak_library, std::shared_ptr< SamplerVK > immutable_sampler={})
Definition: pipeline_vk.cc:449
impeller::PipelineLibraryVK::GetPSOCache
const std::shared_ptr< PipelineCacheVK > & GetPSOCache() const
Definition: pipeline_library_vk.cc:300
impeller::Pipeline< PipelineDescriptor >::desc_
const PipelineDescriptor desc_
Definition: pipeline.h:71
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:91
impeller::BackendCast< PipelineLibraryVK, PipelineLibrary >::Cast
static PipelineLibraryVK & Cast(PipelineLibrary &base)
Definition: backend_cast.h:13
impeller::Pipeline< PipelineDescriptor >::library_
const std::weak_ptr< PipelineLibrary > library_
Definition: pipeline.h:69