Flutter Impeller
impeller::interop::ContextVK Class Referencefinal

#include <context_vk.h>

Inheritance diagram for impeller::interop::ContextVK:
impeller::interop::Context impeller::interop::Object< Context, IMPELLER_INTERNAL_HANDLE_NAME(ImpellerContext)> impeller::interop::ObjectBase

Classes

struct  Settings
 

Public Member Functions

 ~ContextVK () override
 
 ContextVK (const ContextVK &)=delete
 
ContextVKoperator= (const ContextVK &)=delete
 
bool GetInfo (ImpellerContextVulkanInfo &info) const
 
- Public Member Functions inherited from impeller::interop::Context
 ~Context () override
 
 Context (const Context &)=delete
 
Contextoperator= (const Context &)=delete
 
bool IsValid () const
 
std::shared_ptr< impeller::ContextGetContext () const
 
AiksContextGetAiksContext ()
 
bool IsBackend (impeller::Context::BackendType type) const
 
bool IsGL () const
 
bool IsMetal () const
 
bool IsVulkan () const
 
- Public Member Functions inherited from impeller::interop::ObjectBase
 ObjectBase ()=default
 
virtual ~ObjectBase ()=default
 
 ObjectBase (const ObjectBase &)=delete
 
 ObjectBase (ObjectBase &&)=delete
 
ObjectBaseoperator= (const ObjectBase &)=delete
 
ObjectBaseoperator= (ObjectBase &&)=delete
 
void Retain ()
 
void Release ()
 
uint64_t GetRefCountForTests () const
 

Static Public Member Functions

static ScopedObject< ContextCreate (const Settings &settings)
 
static ScopedObject< ContextCreate (std::shared_ptr< impeller::Context > context)
 
- Static Public Member Functions inherited from impeller::interop::ObjectBase
static void SafeRetain (void *ptr)
 
static void SafeRelease (void *ptr)
 

Additional Inherited Members

- Public Types inherited from impeller::interop::Object< Context, IMPELLER_INTERNAL_HANDLE_NAME(ImpellerContext)>
using InteropClass = Context
 
using InteropCSibling = IMPELLER_INTERNAL_HANDLE_NAME(ImpellerContext)
 
- Protected Member Functions inherited from impeller::interop::Context
 Context (std::shared_ptr< impeller::Context > context)
 

Detailed Description

Definition at line 14 of file context_vk.h.

Constructor & Destructor Documentation

◆ ~ContextVK()

impeller::interop::ContextVK::~ContextVK ( )
overridedefault

◆ ContextVK()

impeller::interop::ContextVK::ContextVK ( const ContextVK )
delete

Referenced by Create().

Member Function Documentation

◆ Create() [1/2]

ScopedObject< Context > impeller::interop::ContextVK::Create ( const Settings settings)
static

Definition at line 45 of file context_vk.cc.

45  {
46  if (!settings.IsValid()) {
47  VALIDATION_LOG << "Invalid settings for Vulkan context creation.";
48  return {};
49  }
50  impeller::ContextVK::Settings impeller_settings;
52  impeller_settings.cache_directory = fml::paths::GetCachesDirectory();
53  impeller_settings.enable_validation = true;
54  sContextVKProcAddressCallback = settings.instance_proc_address_callback;
56  impeller_settings.flags = impeller::Flags{};
57  auto impeller_context =
58  impeller::ContextVK::Create(std::move(impeller_settings));
60  if (!impeller_context) {
61  VALIDATION_LOG << "Could not create Impeller context.";
62  return {};
63  }
64  return Create(std::move(impeller_context));
65 }
static std::shared_ptr< ContextVK > Create(Settings settings)
Definition: context_vk.cc:105
static ScopedObject< Context > Create(const Settings &settings)
Definition: context_vk.cc:45
thread_local std::function< PFN_vkVoidFunction(VkInstance instance, const char *proc_name)> sContextVKProcAddressCallback
Definition: context_vk.cc:34
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL ContextVKGetInstanceProcAddress(VkInstance instance, const char *proc_name)
Definition: context_vk.cc:36
static std::vector< std::shared_ptr< fml::Mapping > > CreateShaderLibraryMappings()
Definition: context_mtl.mm:17
std::vector< std::shared_ptr< fml::Mapping > > shader_libraries_data
Definition: context_vk.h:81
PFN_vkGetInstanceProcAddr proc_address_callback
Definition: context_vk.h:80
fml::UniqueFD cache_directory
Definition: context_vk.h:82
#define VALIDATION_LOG
Definition: validation.h:91

References impeller::ContextVK::Settings::cache_directory, impeller::interop::ContextVKGetInstanceProcAddress(), impeller::ContextVK::Create(), impeller::interop::CreateShaderLibraryMappings(), impeller::ContextVK::Settings::enable_validation, impeller::ContextVK::Settings::flags, impeller::interop::ContextVK::Settings::instance_proc_address_callback, impeller::interop::ContextVK::Settings::IsValid(), impeller::ContextVK::Settings::proc_address_callback, impeller::interop::sContextVKProcAddressCallback, impeller::ContextVK::Settings::shader_libraries_data, and VALIDATION_LOG.

Referenced by impeller::interop::testing::CreateSharedContext(), and impeller::interop::ImpellerContextCreateVulkanNew().

◆ Create() [2/2]

ScopedObject< Context > impeller::interop::ContextVK::Create ( std::shared_ptr< impeller::Context context)
static

Definition at line 67 of file context_vk.cc.

68  {
69  // Can't call Create because of private constructor. Adopt the raw pointer
70  // instead.
71  auto context = Adopt<Context>(new ContextVK(std::move(impeller_context)));
72  if (!context->IsValid()) {
73  VALIDATION_LOG << " Could not create valid context.";
74  return {};
75  }
76  return context;
77 }
ContextVK(const ContextVK &)=delete

References ContextVK(), and VALIDATION_LOG.

◆ GetInfo()

bool impeller::interop::ContextVK::GetInfo ( ImpellerContextVulkanInfo info) const

Definition at line 98 of file context_vk.cc.

98  {
99  if (!IsValid()) {
100  return false;
101  }
102  const auto& context = impeller::ContextVK::Cast(*GetContext());
103  // NOLINTBEGIN(google-readability-casting)
104  info.vk_instance = reinterpret_cast<void*>(VkInstance(context.GetInstance()));
105  info.vk_physical_device =
106  reinterpret_cast<void*>(VkPhysicalDevice(context.GetPhysicalDevice()));
107  info.vk_logical_device =
108  reinterpret_cast<void*>(VkDevice(context.GetDevice()));
109  // NOLINTEND(google-readability-casting)
111  context.GetGraphicsQueue()->GetIndex().family;
112  info.graphics_queue_index = context.GetGraphicsQueue()->GetIndex().index;
113  return true;
114 }
static ContextVK & Cast(Context &base)
Definition: backend_cast.h:13
std::shared_ptr< impeller::Context > GetContext() const
Definition: context.cc:20
bool IsValid() const
Definition: context.cc:16
uint32_t graphics_queue_index
Definition: impeller.h:643
uint32_t graphics_queue_family_index
Definition: impeller.h:642
void *IMPELLER_NULLABLE vk_instance
Definition: impeller.h:639
void *IMPELLER_NULLABLE vk_logical_device
Definition: impeller.h:641
void *IMPELLER_NULLABLE vk_physical_device
Definition: impeller.h:640

References impeller::BackendCast< ContextVK, Context >::Cast(), impeller::interop::Context::GetContext(), ImpellerContextVulkanInfo::graphics_queue_family_index, ImpellerContextVulkanInfo::graphics_queue_index, impeller::interop::Context::IsValid(), ImpellerContextVulkanInfo::vk_instance, ImpellerContextVulkanInfo::vk_logical_device, and ImpellerContextVulkanInfo::vk_physical_device.

◆ operator=()

ContextVK& impeller::interop::ContextVK::operator= ( const ContextVK )
delete

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