| 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
virtual Playground::GLProcAddressResolver | CreateGLProcAddressResolver () 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 62 of file playground_impl_vk.cc.

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

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 220 of file playground_impl_vk.cc.

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

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 213 of file playground_impl_vk.cc.

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

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:220
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:98
impeller::PlaygroundImpl::switches_
const PlaygroundSwitches switches_
Definition: playground_impl.h:42
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:91
impeller::PlaygroundSwitches::enable_vulkan_validation
bool enable_vulkan_validation
Definition: switches.h:21
impeller::PlaygroundImpl::PlaygroundImpl
PlaygroundImpl(PlaygroundSwitches switches)
Definition: playground_impl.cc:55