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< PipelineVK > CreateVariantForImmutableSamplers (const std::shared_ptr< SamplerVK > &immutable_sampler) const
 
PipelineKey GetPipelineKey () const
 
- Public Member Functions inherited from impeller::Pipeline< PipelineDescriptor >
virtual ~Pipeline ()
 
const PipelineDescriptor & GetDescriptor () const
 Get the descriptor that was responsible for creating this pipeline. It may be copied and modified to create a pipeline variant. More...
 
PipelineFuture< PipelineDescriptor > CreateVariant (bool async, const std::function< void(PipelineDescriptor &desc)> &descriptor_callback) const
 

Static Public Member Functions

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

Friends

class PipelineLibraryVK
 

Additional Inherited Members

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

Detailed Description

Definition at line 25 of file pipeline_vk.h.

Constructor & Destructor Documentation

◆ ~PipelineVK()

impeller::PipelineVK::~PipelineVK ( )
override

Definition at line 548 of file pipeline_vk.cc.

548  {
549  if (auto device = device_holder_.lock(); !device) {
550  descriptor_set_layout_.release();
551  layout_.release();
552  render_pass_.release();
553  pipeline_.release();
554  }
555 }

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,
PipelineKey  pipeline_key,
std::shared_ptr< SamplerVK >  immutable_sampler = {} 
)
static

Definition at line 467 of file pipeline_vk.cc.

472  {
473  TRACE_EVENT1("flutter", "PipelineVK::Create", "Name", desc.GetLabel().data());
474 
475  auto library = weak_library.lock();
476 
477  if (!device_holder || !library) {
478  return nullptr;
479  }
480 
481  const auto& pso_cache = PipelineLibraryVK::Cast(*library).GetPSOCache();
482 
483  fml::StatusOr<vk::UniqueDescriptorSetLayout> descs_layout =
484  MakeDescriptorSetLayout(desc, device_holder, immutable_sampler);
485  if (!descs_layout.ok()) {
486  return nullptr;
487  }
488 
489  fml::StatusOr<vk::UniquePipelineLayout> pipeline_layout =
490  MakePipelineLayout(desc, device_holder, descs_layout.value().get());
491  if (!pipeline_layout.ok()) {
492  return nullptr;
493  }
494 
495  vk::UniqueRenderPass render_pass =
496  CreateCompatRenderPassForPipeline(device_holder->GetDevice(), desc);
497  if (!render_pass) {
498  VALIDATION_LOG << "Could not create render pass for pipeline.";
499  return nullptr;
500  }
501 
502  fml::StatusOr<vk::UniquePipeline> pipeline =
503  MakePipeline(desc, device_holder, pso_cache,
504  pipeline_layout.value().get(), render_pass.get());
505  if (!pipeline.ok()) {
506  return nullptr;
507  }
508 
509  // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
510  auto pipeline_vk = std::unique_ptr<PipelineVK>(new PipelineVK(
511  device_holder, //
512  library, //
513  desc, //
514  std::move(pipeline.value()), //
515  std::move(render_pass), //
516  std::move(pipeline_layout.value()), //
517  std::move(descs_layout.value()), //
518  pipeline_key, //
519  std::move(immutable_sampler) //
520  ));
521  if (!pipeline_vk->IsValid()) {
522  VALIDATION_LOG << "Could not create a valid pipeline.";
523  return nullptr;
524  }
525  return pipeline_vk;
526 }
static PipelineLibraryVK & Cast(PipelineLibrary &base)
Definition: backend_cast.h:13
const std::shared_ptr< PipelineCacheVK > & GetPSOCache() const
static vk::UniqueRenderPass CreateCompatRenderPassForPipeline(const vk::Device &device, const PipelineDescriptor &desc)
Definition: pipeline_vk.cc:128
std::shared_ptr< RenderPass > render_pass
std::shared_ptr< PipelineGLES > pipeline
#define VALIDATION_LOG
Definition: validation.h:91

References impeller::BackendCast< PipelineLibraryVK, PipelineLibrary >::Cast(), impeller::CreateCompatRenderPassForPipeline(), impeller::PipelineDescriptor::GetLabel(), impeller::PipelineLibraryVK::GetPSOCache(), pipeline, render_pass, 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 573 of file pipeline_vk.cc.

574  {
575  if (!immutable_sampler) {
576  return nullptr;
577  }
578  auto cache_key = ImmutableSamplerKeyVK{*immutable_sampler};
579  Lock lock(immutable_sampler_variants_mutex_);
580  auto found = immutable_sampler_variants_.find(cache_key);
581  if (found != immutable_sampler_variants_.end()) {
582  return found->second;
583  }
584  auto device_holder = device_holder_.lock();
585  if (!device_holder) {
586  return nullptr;
587  }
588  // Note: immutable sampler variant of a pipeline is the negation of the
589  // existing pipeline key. This keeps the descriptors separate.
590  return (immutable_sampler_variants_[cache_key] =
591  Create(desc_, device_holder, library_, -1 * pipeline_key_,
592  immutable_sampler));
593 }
const std::weak_ptr< PipelineLibrary > library_
Definition: pipeline.h:73
const PipelineDescriptor desc_
Definition: pipeline.h:75
static std::unique_ptr< PipelineVK > Create(const PipelineDescriptor &desc, const std::shared_ptr< DeviceHolderVK > &device_holder, const std::weak_ptr< PipelineLibrary > &weak_library, PipelineKey pipeline_key, std::shared_ptr< SamplerVK > immutable_sampler={})
Definition: pipeline_vk.cc:467

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

◆ GetDescriptorSetLayout()

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

Definition at line 569 of file pipeline_vk.cc.

569  {
570  return *descriptor_set_layout_;
571 }

◆ GetPipeline()

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

Definition at line 561 of file pipeline_vk.cc.

561  {
562  return *pipeline_;
563 }

◆ GetPipelineKey()

PipelineKey impeller::PipelineVK::GetPipelineKey ( ) const
inline

Definition at line 48 of file pipeline_vk.h.

48 { return pipeline_key_; }

◆ GetPipelineLayout()

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

Definition at line 565 of file pipeline_vk.cc.

565  {
566  return *layout_;
567 }

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: