From 49c451d17f494cd39f12dc8a9241d5986e56b9bb Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Wed, 27 Nov 2024 18:20:38 +0100 Subject: [PATCH] [Vk] Unfortunately deviceUUID is not random enough to xor parts together into 64bit value --- RenderSystems/Vulkan/include/OgreVulkanRenderSystem.h | 2 +- RenderSystems/Vulkan/src/OgreVulkanDevice.cpp | 5 ++--- RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp | 8 ++++---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/RenderSystems/Vulkan/include/OgreVulkanRenderSystem.h b/RenderSystems/Vulkan/include/OgreVulkanRenderSystem.h index 6a6dbf777a..1509e70f84 100644 --- a/RenderSystems/Vulkan/include/OgreVulkanRenderSystem.h +++ b/RenderSystems/Vulkan/include/OgreVulkanRenderSystem.h @@ -56,7 +56,7 @@ namespace Ogre struct VulkanPhysicalDevice { VkPhysicalDevice physicalDevice; - uint64 physicalDeviceID; // deviceLUID on Windows + uint64 physicalDeviceID[2]; // { deviceLUID, 0 } on Windows, deviceUUID or name hash otherwise String title; }; diff --git a/RenderSystems/Vulkan/src/OgreVulkanDevice.cpp b/RenderSystems/Vulkan/src/OgreVulkanDevice.cpp index 79968cd266..d6872c4b60 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanDevice.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanDevice.cpp @@ -468,7 +468,7 @@ namespace Ogre if( sameNameIndex != 0 ) name += " (" + Ogre::StringConverter::toString( sameNameIndex + 1 ) + ")"; - // use deviceLUID or deviceUUID if available + // { deviceLUID, 0 } on Windows, deviceUUID or name hash otherwise uint64 uid[2] = {}; if( hasVulkan11 && deviceVulkan11Props.deviceLUIDValid ) memcpy( uid, deviceVulkan11Props.deviceLUID, VK_LUID_SIZE ); @@ -480,10 +480,9 @@ namespace Ogre memcpy( uid, deviceIDProps.deviceUUID, VK_UUID_SIZE ); else OGRE_HASH128_FUNC( name.c_str(), (int)name.size(), IdString::Seed, uid ); - uint64 deviceLUID = uid[0] ^ uid[1]; LogManager::getSingleton().logMessage( "Vulkan: \"" + name + "\"" ); - mVulkanPhysicalDevices.push_back( { device, deviceLUID, name } ); + mVulkanPhysicalDevices.push_back( { device, { uid[0], uid[1] }, name } ); } LogManager::getSingleton().logMessage( "Vulkan: Device detection ends" ); diff --git a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp index 3dbf26fa1d..cc3092b6af 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp @@ -173,7 +173,7 @@ namespace Ogre mVulkanProgramFactory1( 0 ), mVulkanProgramFactory2( 0 ), mVulkanProgramFactory3( 0 ), - mActiveDevice( { 0, 0, String() } ), + mActiveDevice( { 0, {}, String() } ), mFirstUnflushedAutoParamsBuffer( 0 ), mAutoParamsBufferIdx( 0 ), mCurrentAutoParamsBufferPtr( 0 ), @@ -1091,9 +1091,9 @@ namespace Ogre dbgFunc, this ); } - mActiveDevice = externalDevice - ? VulkanPhysicalDevice( { externalDevice->physicalDevice, 0, String() } ) - : *mInstance->findByName( mVulkanSupport->getSelectedDeviceName() ); + mActiveDevice = + externalDevice ? VulkanPhysicalDevice( { externalDevice->physicalDevice, {}, String() } ) + : *mInstance->findByName( mVulkanSupport->getSelectedDeviceName() ); mDevice = new VulkanDevice( this ); mDevice->setPhysicalDevice( mInstance, mActiveDevice, externalDevice );