Flutter Impeller
impeller::ContextVK Class Referencefinal

#include <context_vk.h>

Inheritance diagram for impeller::ContextVK:
impeller::Context impeller::BackendCast< ContextVK, Context >

Classes

struct  EmbedderData
 Embedder Stuff. More...
 
struct  Settings
 

Public Member Functions

uint64_t GetHash () const
 
 ~ContextVK () override
 
BackendType GetBackendType () const override
 Get the graphics backend of an Impeller context. More...
 
std::string DescribeGpuModel () const override
 
bool IsValid () const override
 Determines if a context is valid. If the caller ever receives an invalid context, they must discard it and construct a new context. There is no recovery mechanism to repair a bad context. More...
 
std::shared_ptr< AllocatorGetResourceAllocator () const override
 Returns the allocator used to create textures and buffers on the device. More...
 
std::shared_ptr< ShaderLibraryGetShaderLibrary () const override
 Returns the library of shaders used to specify the programmable stages of a pipeline. More...
 
std::shared_ptr< SamplerLibraryGetSamplerLibrary () const override
 Returns the library of combined image samplers used in shaders. More...
 
std::shared_ptr< PipelineLibraryGetPipelineLibrary () const override
 Returns the library of pipelines used by render or compute commands. More...
 
std::shared_ptr< CommandBufferCreateCommandBuffer () const override
 Create a new command buffer. Command buffers can be used to encode graphics, blit, or compute commands to be submitted to the device. More...
 
const std::shared_ptr< const Capabilities > & GetCapabilities () const override
 Get the capabilities of Impeller context. All optionally supported feature of the platform, client-rendering API, and device can be queried using the Capabilities. More...
 
virtual bool SubmitOnscreen (std::shared_ptr< CommandBuffer > cmd_buffer) override
 Submit the command buffer that renders to the onscreen surface. More...
 
const std::shared_ptr< YUVConversionLibraryVK > & GetYUVConversionLibrary () const
 
void Shutdown () override
 Force all pending asynchronous work to finish. This is achieved by deleting all owned concurrent message loops. More...
 
const WorkaroundsVKGetWorkarounds () const
 
void SetOffscreenFormat (PixelFormat pixel_format)
 
template<typename T >
bool SetDebugName (T handle, std::string_view label) const
 
template<typename T >
bool SetDebugName (T handle, std::string_view label, std::string_view trailing) const
 
std::shared_ptr< DeviceHolderVKGetDeviceHolder () const
 
vk::Instance GetInstance () const
 
const vk::Device & GetDevice () const
 
const std::unique_ptr< DriverInfoVK > & GetDriverInfo () const
 
const std::shared_ptr< fml::ConcurrentTaskRunner > GetConcurrentWorkerTaskRunner () const
 
std::shared_ptr< SurfaceContextVKCreateSurfaceContext ()
 
const std::shared_ptr< QueueVK > & GetGraphicsQueue () const
 
vk::PhysicalDevice GetPhysicalDevice () const
 
std::shared_ptr< FenceWaiterVKGetFenceWaiter () const
 
std::shared_ptr< ResourceManagerVKGetResourceManager () const
 
std::shared_ptr< CommandPoolRecyclerVKGetCommandPoolRecycler () const
 
std::shared_ptr< DescriptorPoolRecyclerVKGetDescriptorPoolRecycler () const
 
std::shared_ptr< CommandQueueGetCommandQueue () const override
 Return the graphics queue for submitting command buffers. More...
 
std::shared_ptr< GPUTracerVKGetGPUTracer () const
 
void RecordFrameEndTime () const
 
void InitializeCommonlyUsedShadersIfNeeded () const override
 
void DisposeThreadLocalCachedResources () override
 
bool GetShouldEnableSurfaceControlSwapchain () const
 Whether the Android Surface control based swapchain should be enabled. More...
 
bool EnqueueCommandBuffer (std::shared_ptr< CommandBuffer > command_buffer) override
 Enqueue command_buffer for submission by the end of the frame. More...
 
bool FlushCommandBuffers () override
 Flush all pending command buffers. More...
 
RuntimeStageBackend GetRuntimeStageBackend () const override
 Retrieve the runtime stage for this context type. More...
 
std::shared_ptr< const IdleWaiterGetIdleWaiter () const override
 
- Public Member Functions inherited from impeller::Context
virtual ~Context ()
 Destroys an Impeller context. More...
 
virtual bool UpdateOffscreenLayerPixelFormat (PixelFormat format)
 
virtual void StoreTaskForGPU (const fml::closure &task, const fml::closure &failure)
 
virtual bool AddTrackingFence (const std::shared_ptr< Texture > &texture) const
 
virtual void ResetThreadLocalState () const
 

Static Public Member Functions

static size_t ChooseThreadCountForWorkers (size_t hardware_concurrency)
 
static std::shared_ptr< ContextVKCreate (Settings settings)
 
template<typename T >
static bool SetDebugName (const vk::Device &device, T handle, std::string_view label)
 
- Static Public Member Functions inherited from impeller::BackendCast< ContextVK, Context >
static ContextVKCast (Context &base)
 
static const ContextVKCast (const Context &base)
 
static ContextVKCast (Context *base)
 
static const ContextVKCast (const Context *base)
 

Additional Inherited Members

- Public Types inherited from impeller::Context
enum class  BackendType {
  kMetal ,
  kOpenGLES ,
  kVulkan
}
 
- Static Public Attributes inherited from impeller::Context
static constexpr int32_t kMaxTasksAwaitingGPU = 64
 
- Protected Member Functions inherited from impeller::Context
 Context ()
 
- Protected Attributes inherited from impeller::Context
std::vector< std::function< void()> > per_frame_task_
 

Detailed Description

Definition at line 64 of file context_vk.h.

Constructor & Destructor Documentation

◆ ~ContextVK()

impeller::ContextVK::~ContextVK ( )
override

Definition at line 132 of file context_vk.cc.

132  {
133  if (device_holder_ && device_holder_->device) {
134  [[maybe_unused]] auto result = device_holder_->device->waitIdle();
135  }
137 }
static void DestroyThreadLocalPools(const ContextVK *context)
Clean up resources held by all per-thread command pools associated with the given context.

References impeller::CommandPoolRecyclerVK::DestroyThreadLocalPools().

Member Function Documentation

◆ ChooseThreadCountForWorkers()

size_t impeller::ContextVK::ChooseThreadCountForWorkers ( size_t  hardware_concurrency)
static

Choose the number of worker threads the context_vk will create.

Visible for testing.

Definition at line 115 of file context_vk.cc.

115  {
116  // Never create more than 4 worker threads. Attempt to use up to
117  // half of the available concurrency.
118  return std::clamp(hardware_concurrency / 2ull, /*lo=*/1ull, /*hi=*/4ull);
119 }

Referenced by impeller::testing::TEST().

◆ Create()

std::shared_ptr< ContextVK > impeller::ContextVK::Create ( Settings  settings)
static

Definition at line 105 of file context_vk.cc.

105  {
106  auto context = std::shared_ptr<ContextVK>(new ContextVK());
107  context->Setup(std::move(settings));
108  if (!context->IsValid()) {
109  return nullptr;
110  }
111  return context;
112 }

Referenced by impeller::PlaygroundImplVK::PlaygroundImplVK().

◆ CreateCommandBuffer()

std::shared_ptr< CommandBuffer > impeller::ContextVK::CreateCommandBuffer ( ) const
overridevirtual

Create a new command buffer. Command buffers can be used to encode graphics, blit, or compute commands to be submitted to the device.

A command buffer can only be used on a single thread. Multi-threaded render, blit, or compute passes must create a new command buffer on each thread.

Returns
A new command buffer.

Implements impeller::Context.

Definition at line 533 of file context_vk.cc.

533  {
534  const auto& recycler = GetCommandPoolRecycler();
535  auto tls_pool = recycler->Get();
536  if (!tls_pool) {
537  return nullptr;
538  }
539 
540  // look up a cached descriptor pool for the current frame and reuse it
541  // if it exists, otherwise create a new pool.
542  std::shared_ptr<DescriptorPoolVK> descriptor_pool;
543  {
544  Lock lock(desc_pool_mutex_);
545  DescriptorPoolMap::iterator current_pool =
546  cached_descriptor_pool_.find(std::this_thread::get_id());
547  if (current_pool == cached_descriptor_pool_.end()) {
548  descriptor_pool =
549  (cached_descriptor_pool_[std::this_thread::get_id()] =
550  std::make_shared<DescriptorPoolVK>(weak_from_this()));
551  } else {
552  descriptor_pool = current_pool->second;
553  }
554  }
555 
556  auto tracked_objects = std::make_shared<TrackedObjectsVK>(
557  weak_from_this(), std::move(tls_pool), std::move(descriptor_pool),
558  GetGPUTracer()->CreateGPUProbe());
559  auto queue = GetGraphicsQueue();
560 
561  if (!tracked_objects || !tracked_objects->IsValid() || !queue) {
562  return nullptr;
563  }
564 
565  vk::CommandBufferBeginInfo begin_info;
566  begin_info.flags = vk::CommandBufferUsageFlagBits::eOneTimeSubmit;
567  if (tracked_objects->GetCommandBuffer().begin(begin_info) !=
568  vk::Result::eSuccess) {
569  VALIDATION_LOG << "Could not begin command buffer.";
570  return nullptr;
571  }
572 
573  tracked_objects->GetGPUProbe().RecordCmdBufferStart(
574  tracked_objects->GetCommandBuffer());
575 
576  return std::shared_ptr<CommandBufferVK>(new CommandBufferVK(
577  shared_from_this(), //
578  GetDeviceHolder(), //
579  std::move(tracked_objects) //
580  ));
581 }
const std::shared_ptr< QueueVK > & GetGraphicsQueue() const
Definition: context_vk.cc:616
std::shared_ptr< CommandPoolRecyclerVK > GetCommandPoolRecycler() const
Definition: context_vk.cc:632
std::shared_ptr< GPUTracerVK > GetGPUTracer() const
Definition: context_vk.cc:637
std::shared_ptr< DeviceHolderVK > GetDeviceHolder() const
Definition: context_vk.h:190
#define VALIDATION_LOG
Definition: validation.h:91

References GetCommandPoolRecycler(), GetDeviceHolder(), GetGPUTracer(), GetGraphicsQueue(), and VALIDATION_LOG.

Referenced by impeller::GPUTracerVK::InitializeQueryPool().

◆ CreateSurfaceContext()

std::shared_ptr< SurfaceContextVK > impeller::ContextVK::CreateSurfaceContext ( )

Definition at line 608 of file context_vk.cc.

608  {
609  return std::make_shared<SurfaceContextVK>(shared_from_this());
610 }

◆ DescribeGpuModel()

std::string impeller::ContextVK::DescribeGpuModel ( ) const
overridevirtual

Implements impeller::Context.

Definition at line 509 of file context_vk.cc.

509  {
510  return device_name_;
511 }

◆ DisposeThreadLocalCachedResources()

void impeller::ContextVK::DisposeThreadLocalCachedResources ( )
overridevirtual

Dispose resources that are cached on behalf of the current thread.

Some backends such as Vulkan may cache resources that can be reused while executing a rendering operation. This API can be called after the operation completes in order to clear the cache.

Reimplemented from impeller::Context.

Definition at line 716 of file context_vk.cc.

716  {
717  {
718  Lock lock(desc_pool_mutex_);
719  cached_descriptor_pool_.erase(std::this_thread::get_id());
720  }
721  command_pool_recycler_->Dispose();
722 }

◆ EnqueueCommandBuffer()

bool impeller::ContextVK::EnqueueCommandBuffer ( std::shared_ptr< CommandBuffer command_buffer)
overridevirtual

Enqueue command_buffer for submission by the end of the frame.

Certain backends may immediately flush the command buffer if batch submission is not supported. This functionality is not thread safe and should only be used via the ContentContext for rendering a 2D workload.

Returns true if submission has succeeded. If the buffer is enqueued then no error may be returned until FlushCommandBuffers is called.

Reimplemented from impeller::Context.

Definition at line 650 of file context_vk.cc.

651  {
652  if (should_batch_cmd_buffers_) {
653  pending_command_buffers_.push_back(std::move(command_buffer));
654  return true;
655  } else {
656  return GetCommandQueue()->Submit({command_buffer}).ok();
657  }
658 }
std::shared_ptr< CommandQueue > GetCommandQueue() const override
Return the graphics queue for submitting command buffers.
Definition: context_vk.cc:646

References GetCommandQueue().

Referenced by SubmitOnscreen().

◆ FlushCommandBuffers()

bool impeller::ContextVK::FlushCommandBuffers ( )
overridevirtual

Flush all pending command buffers.

Returns whether or not submission was successful. This functionality is not threadsafe and should only be used via the ContentContext for rendering a 2D workload.

Reimplemented from impeller::Context.

Definition at line 660 of file context_vk.cc.

660  {
661  if (pending_command_buffers_.empty()) {
662  return true;
663  }
664 
665  if (should_batch_cmd_buffers_) {
666  bool result = GetCommandQueue()->Submit(pending_command_buffers_).ok();
667  pending_command_buffers_.clear();
668  return result;
669  } else {
670  return true;
671  }
672 }

References GetCommandQueue().

◆ GetBackendType()

Context::BackendType impeller::ContextVK::GetBackendType ( ) const
overridevirtual

Get the graphics backend of an Impeller context.

        This is useful for cases where a renderer needs to track and
        lookup backend-specific resources, like shaders or uniform
        layout information.

        It's not recommended to use this as a substitute for
        per-backend capability checking. Instead, check for specific
        capabilities via `GetCapabilities()`.
Returns
The graphics backend of the Context.

Implements impeller::Context.

Definition at line 139 of file context_vk.cc.

References impeller::Context::kVulkan.

◆ GetCapabilities()

const std::shared_ptr< const Capabilities > & impeller::ContextVK::GetCapabilities ( ) const
overridevirtual

Get the capabilities of Impeller context. All optionally supported feature of the platform, client-rendering API, and device can be queried using the Capabilities.

Returns
The capabilities. Can never be nullptr for a valid context.

Implements impeller::Context.

Definition at line 612 of file context_vk.cc.

612  {
613  return device_capabilities_;
614 }

Referenced by impeller::AllocatedTextureSourceVK::AllocatedTextureSourceVK().

◆ GetCommandPoolRecycler()

std::shared_ptr< CommandPoolRecyclerVK > impeller::ContextVK::GetCommandPoolRecycler ( ) const

Definition at line 632 of file context_vk.cc.

633  {
634  return command_pool_recycler_;
635 }

Referenced by CreateCommandBuffer().

◆ GetCommandQueue()

std::shared_ptr< CommandQueue > impeller::ContextVK::GetCommandQueue ( ) const
overridevirtual

Return the graphics queue for submitting command buffers.

Implements impeller::Context.

Definition at line 646 of file context_vk.cc.

646  {
647  return command_queue_vk_;
648 }

Referenced by EnqueueCommandBuffer(), FlushCommandBuffers(), and impeller::GPUTracerVK::InitializeQueryPool().

◆ GetConcurrentWorkerTaskRunner()

const std::shared_ptr< fml::ConcurrentTaskRunner > impeller::ContextVK::GetConcurrentWorkerTaskRunner ( ) const

Definition at line 592 of file context_vk.cc.

592  {
593  return raster_message_loop_->GetTaskRunner();
594 }

◆ GetDescriptorPoolRecycler()

std::shared_ptr< DescriptorPoolRecyclerVK > impeller::ContextVK::GetDescriptorPoolRecycler ( ) const

Definition at line 641 of file context_vk.cc.

642  {
643  return descriptor_pool_recycler_;
644 }

◆ GetDevice()

const vk::Device & impeller::ContextVK::GetDevice ( ) const

Definition at line 587 of file context_vk.cc.

587  {
588  return device_holder_->device.get();
589 }

Referenced by impeller::DescriptorPoolVK::AllocateDescriptorSets(), InitializeCommonlyUsedShadersIfNeeded(), impeller::GPUTracerVK::InitializeQueryPool(), and SetDebugName().

◆ GetDeviceHolder()

std::shared_ptr<DeviceHolderVK> impeller::ContextVK::GetDeviceHolder ( ) const
inline

Definition at line 190 of file context_vk.h.

190  {
191  return device_holder_;
192  }

Referenced by CreateCommandBuffer().

◆ GetDriverInfo()

const std::unique_ptr< DriverInfoVK > & impeller::ContextVK::GetDriverInfo ( ) const

Definition at line 729 of file context_vk.cc.

729  {
730  return driver_info_;
731 }

◆ GetFenceWaiter()

std::shared_ptr< FenceWaiterVK > impeller::ContextVK::GetFenceWaiter ( ) const

Definition at line 624 of file context_vk.cc.

624  {
625  return fence_waiter_;
626 }

◆ GetGPUTracer()

std::shared_ptr< GPUTracerVK > impeller::ContextVK::GetGPUTracer ( ) const

Definition at line 637 of file context_vk.cc.

637  {
638  return gpu_tracer_;
639 }

Referenced by impeller::AHBSwapchainImplVK::AcquireNextDrawable(), and CreateCommandBuffer().

◆ GetGraphicsQueue()

const std::shared_ptr< QueueVK > & impeller::ContextVK::GetGraphicsQueue ( ) const

Definition at line 616 of file context_vk.cc.

616  {
617  return queues_.graphics_queue;
618 }
std::shared_ptr< QueueVK > graphics_queue
Definition: queue_vk.h:64

References impeller::QueuesVK::graphics_queue.

Referenced by CreateCommandBuffer().

◆ GetHash()

uint64_t impeller::ContextVK::GetHash ( ) const
inline

Definition at line 103 of file context_vk.h.

103 { return hash_; }

Referenced by impeller::CommandPoolRecyclerVK::DestroyThreadLocalPools().

◆ GetIdleWaiter()

std::shared_ptr<const IdleWaiter> impeller::ContextVK::GetIdleWaiter ( ) const
inlineoverridevirtual

Reimplemented from impeller::Context.

Definition at line 242 of file context_vk.h.

242  {
243  return idle_waiter_vk_;
244  }

◆ GetInstance()

vk::Instance impeller::ContextVK::GetInstance ( ) const

Definition at line 583 of file context_vk.cc.

583  {
584  return *device_holder_->instance;
585 }

◆ GetPhysicalDevice()

vk::PhysicalDevice impeller::ContextVK::GetPhysicalDevice ( ) const

Definition at line 620 of file context_vk.cc.

620  {
621  return device_holder_->physical_device;
622 }

◆ GetPipelineLibrary()

std::shared_ptr< PipelineLibrary > impeller::ContextVK::GetPipelineLibrary ( ) const
overridevirtual

Returns the library of pipelines used by render or compute commands.

Returns
The pipeline library. Can never be nullptr for a valid context.

Implements impeller::Context.

Definition at line 529 of file context_vk.cc.

529  {
530  return pipeline_library_;
531 }

◆ GetResourceAllocator()

std::shared_ptr< Allocator > impeller::ContextVK::GetResourceAllocator ( ) const
overridevirtual

Returns the allocator used to create textures and buffers on the device.

Returns
The resource allocator. Can never be nullptr for a valid context.

Implements impeller::Context.

Definition at line 517 of file context_vk.cc.

517  {
518  return allocator_;
519 }

Referenced by InitializeCommonlyUsedShadersIfNeeded().

◆ GetResourceManager()

std::shared_ptr< ResourceManagerVK > impeller::ContextVK::GetResourceManager ( ) const

Definition at line 628 of file context_vk.cc.

628  {
629  return resource_manager_;
630 }

◆ GetRuntimeStageBackend()

RuntimeStageBackend impeller::ContextVK::GetRuntimeStageBackend ( ) const
overridevirtual

Retrieve the runtime stage for this context type.

This is used by the engine shell and other subsystems for loading the correct shader types.

Implements impeller::Context.

Definition at line 737 of file context_vk.cc.

References impeller::kVulkan.

◆ GetSamplerLibrary()

std::shared_ptr< SamplerLibrary > impeller::ContextVK::GetSamplerLibrary ( ) const
overridevirtual

Returns the library of combined image samplers used in shaders.

Returns
The sampler library. Can never be nullptr for a valid context.

Implements impeller::Context.

Definition at line 525 of file context_vk.cc.

525  {
526  return sampler_library_;
527 }

◆ GetShaderLibrary()

std::shared_ptr< ShaderLibrary > impeller::ContextVK::GetShaderLibrary ( ) const
overridevirtual

Returns the library of shaders used to specify the programmable stages of a pipeline.

Returns
The shader library. Can never be nullptr for a valid context.

Implements impeller::Context.

Definition at line 521 of file context_vk.cc.

521  {
522  return shader_library_;
523 }

◆ GetShouldEnableSurfaceControlSwapchain()

bool impeller::ContextVK::GetShouldEnableSurfaceControlSwapchain ( ) const

Whether the Android Surface control based swapchain should be enabled.

Definition at line 733 of file context_vk.cc.

733  {
734  return should_enable_surface_control_;
735 }

◆ GetWorkarounds()

const WorkaroundsVK & impeller::ContextVK::GetWorkarounds ( ) const

Definition at line 745 of file context_vk.cc.

745  {
746  return workarounds_;
747 }

◆ GetYUVConversionLibrary()

const std::shared_ptr< YUVConversionLibraryVK > & impeller::ContextVK::GetYUVConversionLibrary ( ) const

Definition at line 725 of file context_vk.cc.

725  {
726  return yuv_conversion_library_;
727 }

Referenced by impeller::CreateYUVConversion().

◆ InitializeCommonlyUsedShadersIfNeeded()

void impeller::ContextVK::InitializeCommonlyUsedShadersIfNeeded ( ) const
overridevirtual

Run backend specific additional setup and create common shader variants.

This bootstrap is intended to improve the performance of several first frame benchmarks that are tracked in the flutter device lab. The workload includes initializing commonly used but not default shader variants, as well as forcing driver initialization.

Reimplemented from impeller::Context.

Definition at line 677 of file context_vk.cc.

677  {
678  RenderTargetAllocator rt_allocator(GetResourceAllocator());
679  RenderTarget render_target =
680  rt_allocator.CreateOffscreenMSAA(*this, {1, 1}, 1);
681 
682  RenderPassBuilderVK builder;
683 
684  render_target.IterateAllColorAttachments(
685  [&builder](size_t index, const ColorAttachment& attachment) -> bool {
686  builder.SetColorAttachment(
687  index, //
688  attachment.texture->GetTextureDescriptor().format, //
689  attachment.texture->GetTextureDescriptor().sample_count, //
690  attachment.load_action, //
691  attachment.store_action //
692  );
693  return true;
694  });
695 
696  if (auto depth = render_target.GetDepthAttachment(); depth.has_value()) {
697  builder.SetDepthStencilAttachment(
698  depth->texture->GetTextureDescriptor().format, //
699  depth->texture->GetTextureDescriptor().sample_count, //
700  depth->load_action, //
701  depth->store_action //
702  );
703  } else if (auto stencil = render_target.GetStencilAttachment();
704  stencil.has_value()) {
705  builder.SetStencilAttachment(
706  stencil->texture->GetTextureDescriptor().format, //
707  stencil->texture->GetTextureDescriptor().sample_count, //
708  stencil->load_action, //
709  stencil->store_action //
710  );
711  }
712 
713  auto pass = builder.Build(GetDevice());
714 }
std::shared_ptr< Allocator > GetResourceAllocator() const override
Returns the allocator used to create textures and buffers on the device.
Definition: context_vk.cc:517
const vk::Device & GetDevice() const
Definition: context_vk.cc:587

References impeller::RenderPassBuilderVK::Build(), impeller::RenderTargetAllocator::CreateOffscreenMSAA(), impeller::RenderTarget::GetDepthAttachment(), GetDevice(), GetResourceAllocator(), impeller::RenderTarget::GetStencilAttachment(), impeller::RenderTarget::IterateAllColorAttachments(), impeller::Attachment::load_action, impeller::RenderPassBuilderVK::SetColorAttachment(), impeller::RenderPassBuilderVK::SetDepthStencilAttachment(), impeller::RenderPassBuilderVK::SetStencilAttachment(), impeller::Attachment::store_action, and impeller::Attachment::texture.

◆ IsValid()

bool impeller::ContextVK::IsValid ( ) const
overridevirtual

Determines if a context is valid. If the caller ever receives an invalid context, they must discard it and construct a new context. There is no recovery mechanism to repair a bad context.

It is convention in Impeller to never return an invalid context from a call that returns an pointer to a context. The call implementation performs validity checks itself and return a null context instead of a pointer to an invalid context.

How a context goes invalid is backend specific. It could happen due to device loss, or any other unrecoverable error.

Returns
If the context is valid.

Implements impeller::Context.

Definition at line 513 of file context_vk.cc.

513  {
514  return is_valid_;
515 }

◆ RecordFrameEndTime()

void impeller::ContextVK::RecordFrameEndTime ( ) const

◆ SetDebugName() [1/3]

template<typename T >
static bool impeller::ContextVK::SetDebugName ( const vk::Device &  device,
handle,
std::string_view  label 
)
inlinestatic

Definition at line 167 of file context_vk.h.

169  {
170  if (!HasValidationLayers()) {
171  // No-op if validation layers are not enabled.
172  return true;
173  }
174 
175  auto c_handle = static_cast<typename T::CType>(handle);
176 
177  vk::DebugUtilsObjectNameInfoEXT info;
178  info.objectType = T::objectType;
179  info.pObjectName = label.data();
180  info.objectHandle = reinterpret_cast<decltype(info.objectHandle)>(c_handle);
181 
182  if (device.setDebugUtilsObjectNameEXT(info) != vk::Result::eSuccess) {
183  VALIDATION_LOG << "Unable to set debug name: " << label;
184  return false;
185  }
186 
187  return true;
188  }
bool HasValidationLayers()
Definition: context_vk.cc:53

References impeller::HasValidationLayers(), and VALIDATION_LOG.

◆ SetDebugName() [2/3]

template<typename T >
bool impeller::ContextVK::SetDebugName ( handle,
std::string_view  label 
) const
inline

Definition at line 150 of file context_vk.h.

150  {
151  return SetDebugName(GetDevice(), handle, label);
152  }
bool SetDebugName(T handle, std::string_view label) const
Definition: context_vk.h:150

References GetDevice().

Referenced by impeller::CreateCompatRenderPassForPipeline(), impeller::CreateSampler(), impeller::QueuesVK::FromQueueIndices(), and SetDebugName().

◆ SetDebugName() [3/3]

template<typename T >
bool impeller::ContextVK::SetDebugName ( handle,
std::string_view  label,
std::string_view  trailing 
) const
inline

Definition at line 155 of file context_vk.h.

157  {
158  if (!HasValidationLayers()) {
159  // No-op if validation layers are not enabled.
160  return true;
161  }
162  std::string combined = SPrintF("%s %s", label.data(), trailing.data());
163  return SetDebugName(GetDevice(), handle, combined);
164  }
std::string SPrintF(const char *format,...)
Definition: strings.cc:12

References GetDevice(), impeller::HasValidationLayers(), SetDebugName(), and impeller::SPrintF().

◆ SetOffscreenFormat()

void impeller::ContextVK::SetOffscreenFormat ( PixelFormat  pixel_format)

Definition at line 504 of file context_vk.cc.

504  {
505  CapabilitiesVK::Cast(*device_capabilities_).SetOffscreenFormat(pixel_format);
506 }
static CapabilitiesVK & Cast(Capabilities &base)
Definition: backend_cast.h:13
void SetOffscreenFormat(PixelFormat pixel_format) const

References impeller::BackendCast< CapabilitiesVK, Capabilities >::Cast(), and impeller::CapabilitiesVK::SetOffscreenFormat().

◆ Shutdown()

void impeller::ContextVK::Shutdown ( )
overridevirtual

Force all pending asynchronous work to finish. This is achieved by deleting all owned concurrent message loops.

Implements impeller::Context.

Definition at line 596 of file context_vk.cc.

596  {
597  // There are multiple objects, for example |CommandPoolVK|, that in their
598  // destructors make a strong reference to |ContextVK|. Resetting these shared
599  // pointers ensures that cleanup happens in a correct order.
600  //
601  // tl;dr: Without it, we get thread::join failures on shutdown.
602  fence_waiter_.reset();
603  resource_manager_.reset();
604 
605  raster_message_loop_->Terminate();
606 }

◆ SubmitOnscreen()

bool impeller::ContextVK::SubmitOnscreen ( std::shared_ptr< CommandBuffer cmd_buffer)
overridevirtual

Submit the command buffer that renders to the onscreen surface.

Reimplemented from impeller::Context.

Definition at line 741 of file context_vk.cc.

741  {
742  return EnqueueCommandBuffer(std::move(cmd_buffer));
743 }
bool EnqueueCommandBuffer(std::shared_ptr< CommandBuffer > command_buffer) override
Enqueue command_buffer for submission by the end of the frame.
Definition: context_vk.cc:650

References EnqueueCommandBuffer().


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