Skip to content

Commit

Permalink
[Vk] fixed validation layer errors - using VkPhysicalDeviceIDProperti…
Browse files Browse the repository at this point in the history
…es with Vulkan 1.1 but without enabled VK_KHR_EXTERNAL_... extensions is not OK, VkPhysicalDeviceVulkan11Properties should be used
  • Loading branch information
eugenegff committed Nov 27, 2024
1 parent 6aaf380 commit e83e111
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions RenderSystems/Vulkan/src/OgreVulkanDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,21 +429,27 @@ namespace Ogre
PFN_vkEnumerateInstanceVersion enumerateInstanceVersion =
(PFN_vkEnumerateInstanceVersion)vkGetInstanceProcAddr( 0, "vkEnumerateInstanceVersion" );
uint32_t apiVersion = VK_API_VERSION_1_0;
bool hasVulkan11 = enumerateInstanceVersion &&
enumerateInstanceVersion( &apiVersion ) == VK_SUCCESS &&
apiVersion >= VK_API_VERSION_1_1;
bool hasDeviceIDProperties =
enumerateInstanceVersion && enumerateInstanceVersion( &apiVersion ) == VK_SUCCESS &&
apiVersion >= VK_API_VERSION_1_1 ||
hasExtension( VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME ) ||
hasExtension( VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_EXTENSION_NAME ) ||
hasExtension( VK_KHR_EXTERNAL_FENCE_CAPABILITIES_EXTENSION_NAME );
PFN_vkGetPhysicalDeviceProperties2KHR GetPhysicalDeviceProperties2KHR =
hasDeviceIDProperties ? (PFN_vkGetPhysicalDeviceProperties2KHR)vkGetInstanceProcAddr(
mVkInstance, "vkGetPhysicalDeviceProperties2KHR" )
: nullptr;
hasVulkan11 || hasDeviceIDProperties
? (PFN_vkGetPhysicalDeviceProperties2KHR)vkGetInstanceProcAddr(
mVkInstance, "vkGetPhysicalDeviceProperties2KHR" )
: nullptr;
VkPhysicalDeviceProperties2 deviceProps2;
VkPhysicalDeviceVulkan11Properties deviceVulkan11Props;
VkPhysicalDeviceIDProperties deviceIDProps;
makeVkStruct( deviceProps2, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2 );
makeVkStruct( deviceVulkan11Props, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_PROPERTIES );
makeVkStruct( deviceIDProps, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES );
if( hasDeviceIDProperties )
if( hasVulkan11 )
deviceProps2.pNext = &deviceVulkan11Props;
else if( hasDeviceIDProperties )
deviceProps2.pNext = &deviceIDProps;

// assign unique names, allowing reordering/inserting/removing
Expand All @@ -452,7 +458,7 @@ namespace Ogre
mVulkanPhysicalDevices.reserve( devices.size() );
for( VkPhysicalDevice device : devices )
{
if( hasDeviceIDProperties )
if( GetPhysicalDeviceProperties2KHR )
GetPhysicalDeviceProperties2KHR( device, &deviceProps2 );
else
vkGetPhysicalDeviceProperties( device, &deviceProps2.properties );
Expand All @@ -464,7 +470,11 @@ namespace Ogre

// use deviceLUID or deviceUUID if available
uint64 uid[2] = {};
if( hasDeviceIDProperties && deviceIDProps.deviceLUIDValid )
if( hasVulkan11 && deviceVulkan11Props.deviceLUIDValid )
memcpy( uid, deviceVulkan11Props.deviceLUID, VK_LUID_SIZE );
else if( hasVulkan11 )
memcpy( uid, deviceVulkan11Props.deviceUUID, VK_UUID_SIZE );
else if( hasDeviceIDProperties && deviceIDProps.deviceLUIDValid )
memcpy( uid, deviceIDProps.deviceLUID, VK_LUID_SIZE );
else if( hasDeviceIDProperties )
memcpy( uid, deviceIDProps.deviceUUID, VK_UUID_SIZE );
Expand Down

0 comments on commit e83e111

Please sign in to comment.