96 lines
3.2 KiB
C++
96 lines
3.2 KiB
C++
|
|
// 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<const ANSICHAR*>& Out)
|
||
|
|
{
|
||
|
|
#if PICO_HMD_SUPPORTED_PLATFORMS_VULKAN
|
||
|
|
TArray<VkExtensionProperties> Properties;
|
||
|
|
{
|
||
|
|
uint32_t PropertyCount;
|
||
|
|
VulkanRHI::vkEnumerateInstanceExtensionProperties(nullptr, &PropertyCount, nullptr);
|
||
|
|
Properties.SetNum(PropertyCount);
|
||
|
|
VulkanRHI::vkEnumerateInstanceExtensionProperties(nullptr, &PropertyCount, Properties.GetData());
|
||
|
|
}
|
||
|
|
|
||
|
|
TArray<const char*> 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<const ANSICHAR*>& Out)
|
||
|
|
{
|
||
|
|
#if PICO_HMD_SUPPORTED_PLATFORMS_VULKAN
|
||
|
|
TArray<VkExtensionProperties> Properties;
|
||
|
|
{
|
||
|
|
uint32_t PropertyCount;
|
||
|
|
VulkanRHI::vkEnumerateDeviceExtensionProperties((VkPhysicalDevice) pPhysicalDevice, nullptr, &PropertyCount, nullptr);
|
||
|
|
Properties.SetNum(PropertyCount);
|
||
|
|
VulkanRHI::vkEnumerateDeviceExtensionProperties((VkPhysicalDevice) pPhysicalDevice, nullptr, &PropertyCount, Properties.GetData());
|
||
|
|
}
|
||
|
|
|
||
|
|
TArray<const char*> 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
|