// Copyright PICO Technology Co., Ltd. All rights reserved. // This plugin incorporates portions of the UnrealĀ® Engine. UnrealĀ® is a trademark or registered trademark of Epic Games, Inc. in the United States of America and elsewhere. // Copyright Epic Games, Inc. All Rights Reserved. #include "PXR_VulkanExtensions.h" #if PICO_HMD_SUPPORTED_PLATFORMS #include "PXR_HMDPrivateRHI.h" #include "PXR_HMDModule.h" //------------------------------------------------------------------------------------------------- // FVulkanExtensions //------------------------------------------------------------------------------------------------- bool FVulkanExtensions::GetVulkanInstanceExtensionsRequired(TArray& Out) { #if PICO_HMD_SUPPORTED_PLATFORMS_VULKAN TArray Properties; { uint32_t PropertyCount; VulkanRHI::vkEnumerateInstanceExtensionProperties(nullptr, &PropertyCount, nullptr); Properties.SetNum(PropertyCount); VulkanRHI::vkEnumerateInstanceExtensionProperties(nullptr, &PropertyCount, Properties.GetData()); } TArray Extensions; { uint32_t ExtensionCount = 0; FPICOXRHMDModule::GetPluginWrapper().GetInstanceExtensionsVk(nullptr, &ExtensionCount); Extensions.SetNum(ExtensionCount); FPICOXRHMDModule::GetPluginWrapper().GetInstanceExtensionsVk(Extensions.GetData(), &ExtensionCount); } int32 ExtensionsFound = 0; for (int32 ExtensionIndex = 0; ExtensionIndex < Extensions.Num(); ExtensionIndex++) { for (int32 PropertyIndex = 0; PropertyIndex < Properties.Num(); PropertyIndex++) { const char* PropertyExtensionName = Properties[PropertyIndex].extensionName; if (!FCStringAnsi::Strcmp(PropertyExtensionName, Extensions[ExtensionIndex])) { Out.Add(Extensions[ExtensionIndex]); ExtensionsFound++; break; } } } return ExtensionsFound == Extensions.Num(); #endif return true; } bool FVulkanExtensions::GetVulkanDeviceExtensionsRequired(struct VkPhysicalDevice_T *pPhysicalDevice, TArray& Out) { #if PICO_HMD_SUPPORTED_PLATFORMS_VULKAN TArray Properties; { uint32_t PropertyCount; VulkanRHI::vkEnumerateDeviceExtensionProperties((VkPhysicalDevice) pPhysicalDevice, nullptr, &PropertyCount, nullptr); Properties.SetNum(PropertyCount); VulkanRHI::vkEnumerateDeviceExtensionProperties((VkPhysicalDevice) pPhysicalDevice, nullptr, &PropertyCount, Properties.GetData()); } TArray Extensions; { uint32_t ExtensionCount = 0; FPICOXRHMDModule::GetPluginWrapper().GetDeviceExtensionsVk(nullptr, &ExtensionCount); Extensions.SetNum(ExtensionCount); FPICOXRHMDModule::GetPluginWrapper().GetDeviceExtensionsVk(Extensions.GetData(), &ExtensionCount); } int32 ExtensionsFound = 0; for (int32 ExtensionIndex = 0; ExtensionIndex < Extensions.Num(); ExtensionIndex++) { for (int32 PropertyIndex = 0; PropertyIndex < Properties.Num(); PropertyIndex++) { const char* PropertyExtensionName = Properties[PropertyIndex].extensionName; if (!FCStringAnsi::Strcmp(PropertyExtensionName, Extensions[ExtensionIndex])) { Out.Add(Extensions[ExtensionIndex]); ExtensionsFound++; break; } } } return ExtensionsFound == Extensions.Num(); #endif return true; } #endif //PICO_HMD_SUPPORTED_PLATFORMS