| 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
virtual void | SetGPUDisabled (bool disabled) 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 66 of file playground_impl_vk.cc.

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

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, impeller::PlaygroundSwitches::flags, impeller::ContextVK::Settings::flags, 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 224 of file playground_impl_vk.cc.

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

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

218 {
219 return fml::Status(
220 fml::StatusCode::kUnimplemented,
221 "PlaygroundImplVK doesn't support setting the capabilities.");
222 }

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