@@ -175,10 +175,38 @@ void PlaygroundImplVK::InitGlobalVulkanInstance() {
175175 application_info.setPEngineName (" PlaygroundImplVK" );
176176 application_info.setPApplicationName (" PlaygroundImplVK" );
177177
178- auto instance_result =
179- vk::createInstanceUnique (vk::InstanceCreateInfo ({}, &application_info));
178+ CapabilitiesVK caps (false );
179+ auto enabled_layers = caps.GetEnabledLayers ();
180+ auto enabled_extensions = caps.GetEnabledInstanceExtensions ();
181+
182+ FML_CHECK (enabled_layers.has_value () && enabled_extensions.has_value ());
183+
184+ std::vector<const char *> enabled_layers_c;
185+ std::vector<const char *> enabled_extensions_c;
186+
187+ for (const auto & layer : enabled_layers.value ()) {
188+ enabled_layers_c.push_back (layer.c_str ());
189+ }
190+
191+ for (const auto & ext : enabled_extensions.value ()) {
192+ enabled_extensions_c.push_back (ext.c_str ());
193+ }
194+
195+ vk::InstanceCreateInfo instance_info;
196+ instance_info.setPEnabledLayerNames (enabled_layers_c);
197+ instance_info.setPEnabledExtensionNames (enabled_extensions_c);
198+ instance_info.setPApplicationInfo (&application_info);
199+
200+ if (std::find (enabled_extensions->begin (), enabled_extensions->end (),
201+ " VK_KHR_portability_enumeration" ) !=
202+ enabled_extensions->end ()) {
203+ instance_info.flags |= vk::InstanceCreateFlagBits::eEnumeratePortabilityKHR;
204+ }
205+
206+ auto instance_result = vk::createInstanceUnique (instance_info);
180207 FML_CHECK (instance_result.result == vk::Result::eSuccess)
181- << " Unable to initialize global Vulkan instance" ;
208+ << " Unable to initialize global Vulkan instance: "
209+ << vk::to_string (instance_result.result );
182210 global_instance_ = std::move (instance_result.value );
183211}
184212
0 commit comments