| Flutter Impeller |

Public Member Functions | Static Public Member Functions | List of all members
impeller::PlaygroundImplVK Class Referencefinal

`#include <playground_impl_vk.h>`

Inheritance diagram for impeller::PlaygroundImplVK:

## Public Member Functions
| PlaygroundImplVK (PlaygroundSwitches switches)
| ~PlaygroundImplVK ()
fml::Status | SetCapabilities (const std::shared_ptr< Capabilities > &capabilities) override
Public Member Functions inherited from impeller::PlaygroundImpl
virtual | ~PlaygroundImpl ()
Vector2 | GetContentScale () const

## Static Public Member Functions
static bool | IsVulkanDriverPresent ()
Static Public Member Functions inherited from impeller::PlaygroundImpl
static std::unique_ptr< PlaygroundImpl > | Create (PlaygroundBackend backend, PlaygroundSwitches switches)

## Additional Inherited Members
Public Types inherited from impeller::PlaygroundImpl
using | WindowHandle = void *
Protected Member Functions inherited from impeller::PlaygroundImpl
| PlaygroundImpl (PlaygroundSwitches switches)
Protected Attributes inherited from impeller::PlaygroundImpl
const PlaygroundSwitches | switches_

## Detailed Description

Definition at line 13 of file playground_impl_vk.h.

## Constructor & Destructor Documentation

## ◆ PlaygroundImplVK()

impeller::PlaygroundImplVK::PlaygroundImplVK | ( | PlaygroundSwitches | switches | ) |
| explicit

Definition at line 61 of file playground_impl_vk.cc.

62 : PlaygroundImpl(switches), handle_(nullptr, &DestroyWindowHandle) {
63 FML_CHECK(IsVulkanDriverPresent());
64
65 InitGlobalVulkanInstance();
66
67 ::glfwDefaultWindowHints();
68 ::glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
69 ::glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
70
71 auto window = ::glfwCreateWindow(1, 1, "Test", nullptr, nullptr);
72 if (!window) {
73 VALIDATION_LOG << "Unable to create glfw window";
74 return;
75 }
76
77 int width = 0;
78 int height = 0;
79 ::glfwGetWindowSize(window, &width, &height);
80 size_ = ISize{width, height};
81
82 handle_.reset(window);
83
84 ContextVK::Settings context_settings;
85 context_settings.proc_address_callback =
86 reinterpret_cast<PFN_vkGetInstanceProcAddr>(
87 &::glfwGetInstanceProcAddress);
88 context_settings.shader_libraries_data = ShaderLibraryMappingsForPlayground();
89 context_settings.cache_directory = fml::paths::GetCachesDirectory();
90 context_settings.enable_validation = switches_.enable_vulkan_validation;
91 context_settings.fatal_missing_validations =
92 switches_.enable_vulkan_validation;
93 ;
94
95 auto context_vk = ContextVK::Create(std::move(context_settings));
96 if (!context_vk || !context_vk->IsValid()) {
97 VALIDATION_LOG << "Could not create Vulkan context in the playground.";
98 return;
99 }
100
101 VkSurfaceKHR vk_surface;
102 auto res = vk::Result{::glfwCreateWindowSurface(
103 context_vk->GetInstance(), // instance
104 window, // window
105 nullptr, // allocator
106 &vk_surface // surface
107 )};
108 if (res != vk::Result::eSuccess) {
109 VALIDATION_LOG << "Could not create surface for GLFW window: "
110 << vk::to_string(res);
111 return;
112 }
113
114 vk::UniqueSurfaceKHR surface{vk_surface, context_vk->GetInstance()};
115 auto context = context_vk->CreateSurfaceContext();
116 if (!context->SetWindowSurface(std::move(surface), size_)) {
117 VALIDATION_LOG << "Could not set up surface for context.";
118 return;
119 }
120
121 context_ = std::move(context);
122 }

References impeller::ContextVK::Settings::cache_directory, impeller::ContextVK::Create(), impeller::ContextVK::Settings::enable_validation, impeller::PlaygroundSwitches::enable_vulkan_validation, impeller::ContextVK::Settings::fatal_missing_validations, IsVulkanDriverPresent(), impeller::ContextVK::Settings::proc_address_callback, impeller::ContextVK::Settings::shader_libraries_data, impeller::ShaderLibraryMappingsForPlayground(), impeller::PlaygroundImpl::switches_, and VALIDATION_LOG.

## ◆ ~PlaygroundImplVK()

impeller::PlaygroundImplVK::~PlaygroundImplVK | ( |  | ) |
| default

## Member Function Documentation

## ◆ IsVulkanDriverPresent()

bool impeller::PlaygroundImplVK::IsVulkanDriverPresent | ( |  | ) |
| static

Definition at line 219 of file playground_impl_vk.cc.

219 {
220 if (::glfwVulkanSupported()) {
221 return true;
222 }
223 #ifdef TARGET_OS_MAC
224 FML_LOG(ERROR) << "Attempting to initialize a Vulkan playground on macOS "
225 "where Vulkan cannot be found. It can be installed via "
226 "MoltenVK and make sure to install it globally so "
227 "dlopen can find it.";
228 #else // TARGET_OS_MAC
229 FML_LOG(ERROR) << "Attempting to initialize a Vulkan playground on a system "
230 "that does not support Vulkan.";
231 #endif // TARGET_OS_MAC
232 return false;
233 }

Referenced by impeller::PlaygroundImpl::Create(), PlaygroundImplVK(), and impeller::Playground::SupportsBackend().

## ◆ SetCapabilities()

fml::Status impeller::PlaygroundImplVK::SetCapabilities | ( | const std::shared_ptr< Capabilities > & | capabilities | ) |
| override virtual

Implements impeller::PlaygroundImpl.

Definition at line 212 of file playground_impl_vk.cc.

213 {
214 return fml::Status(
215 fml::StatusCode::kUnimplemented,
216 "PlaygroundImplVK doesn't support setting the capabilities.");
217 }

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

- impeller/playground/backend/vulkan/playground_impl_vk.h
- impeller/playground/backend/vulkan/playground_impl_vk.cc

impeller::ISize
ISize64 ISize
Definition: size.h:140
impeller::PlaygroundImplVK::IsVulkanDriverPresent
static bool IsVulkanDriverPresent()
Definition: playground_impl_vk.cc:219
impeller::ShaderLibraryMappingsForPlayground
static std::vector< std::shared_ptr< fml::Mapping > > ShaderLibraryMappingsForPlayground()
Definition: playground_impl_gles.cc:106
impeller::ContextVK::Create
static std::shared_ptr< ContextVK > Create(Settings settings)
Definition: context_vk.cc:100
impeller::PlaygroundImpl::switches_
const PlaygroundSwitches switches_
Definition: playground_impl.h:39
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:73
impeller::PlaygroundSwitches::enable_vulkan_validation
bool enable_vulkan_validation
Definition: switches.h:21
impeller::PlaygroundImpl::PlaygroundImpl
PlaygroundImpl(PlaygroundSwitches switches)
Definition: playground_impl.cc:55