Flutter Engine
The Flutter Engine
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:
impeller::PlaygroundImpl

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 ()
 
virtual WindowHandle GetWindowHandle () const =0
 
virtual std::shared_ptr< ContextGetContext () const =0
 
virtual std::unique_ptr< SurfaceAcquireSurfaceFrame (std::shared_ptr< Context > context)=0
 
Vector2 GetContentScale () const
 
virtual fml::Status SetCapabilities (const std::shared_ptr< Capabilities > &capabilities)=0
 

Static Public Member Functions

static bool IsVulkanDriverPresent ()
 
- Static Public Member Functions inherited from impeller::PlaygroundImpl
static std::unique_ptr< PlaygroundImplCreate (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) {
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 =
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}
static std::shared_ptr< ContextVK > Create(Settings settings)
Definition: context_vk.cc:100
PlaygroundImpl(PlaygroundSwitches switches)
const PlaygroundSwitches switches_
GLFWwindow * window
Definition: main.cc:45
VkSurfaceKHR surface
Definition: main.cc:49
#define GLFW_FALSE
Definition: flutter_glfw.cc:36
#define FML_CHECK(condition)
Definition: logging.h:85
fml::UniqueFD GetCachesDirectory()
static std::vector< std::shared_ptr< fml::Mapping > > ShaderLibraryMappingsForPlayground()
ISize64 ISize
Definition: size.h:140
static SkString to_string(int n)
Definition: nanobench.cpp:119
int32_t height
int32_t width
#define VALIDATION_LOG
Definition: validation.h:73
PFN_vkVoidFunction(VKAPI_PTR * PFN_vkGetInstanceProcAddr)(VkInstance instance, const char *pName)
Definition: vulkan_core.h:3989

◆ ~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}
#define FML_LOG(severity)
Definition: logging.h:82
#define ERROR(message)
Definition: elf_loader.cc:260

◆ SetCapabilities()

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

Implements impeller::PlaygroundImpl.

Definition at line 212 of file playground_impl_vk.cc.

213 {
214 return fml::Status(
216 "PlaygroundImplVK doesn't support setting the capabilities.");
217}
Task::Status Status
Definition: TaskList.cpp:15

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