diff --git a/framework/core/physical_device.h b/framework/core/physical_device.h index fb00e05bb..4ec56b09a 100644 --- a/framework/core/physical_device.h +++ b/framework/core/physical_device.h @@ -163,6 +163,7 @@ class PhysicalDevice template FeatureType get_extension_features_impl(); uint32_t get_memory_type_impl(uint32_t bits, vk::MemoryPropertyFlags properties, vk::Bool32 *memory_type_found = nullptr) const; + void init(); template void request_required_feature_impl(vk::Bool32 FeatureType::*flag, std::string const &featureName, std::string const &flagName); @@ -187,15 +188,28 @@ using PhysicalDeviceCpp = PhysicalDevice; #define REQUEST_OPTIONAL_FEATURE(gpu, Feature, flag) gpu.request_optional_feature(&Feature::flag, #Feature, #flag) #define REQUEST_REQUIRED_FEATURE(gpu, Feature, flag) gpu.request_required_feature(&Feature::flag, #Feature, #flag) -template -inline PhysicalDevice::PhysicalDevice(vkb::core::Instance &instance, PhysicalDeviceType physical_device) : +template <> +inline PhysicalDevice::PhysicalDevice(vkb::core::InstanceC &instance, VkPhysicalDevice physical_device) : + instance{reinterpret_cast(instance)}, handle{physical_device} +{ + init(); +} + +template <> +inline PhysicalDevice::PhysicalDevice(vkb::core::InstanceCpp &instance, vk::PhysicalDevice physical_device) : instance{instance}, handle{physical_device} { - features = physical_device.getFeatures(); - properties = physical_device.getProperties(); - memory_properties = physical_device.getMemoryProperties(); - queue_family_properties = physical_device.getQueueFamilyProperties(); - device_extensions = physical_device.enumerateDeviceExtensionProperties(); + init(); +} + +template +inline void PhysicalDevice::init() +{ + features = handle.getFeatures(); + properties = handle.getProperties(); + memory_properties = handle.getMemoryProperties(); + queue_family_properties = handle.getQueueFamilyProperties(); + device_extensions = handle.enumerateDeviceExtensionProperties(); LOGI("Found GPU: {}", properties.deviceName.data());