Skip to content

Commit

Permalink
[Vk] Unfortunately deviceUUID is not random enough to xor parts toget…
Browse files Browse the repository at this point in the history
…her into 64bit value
  • Loading branch information
eugenegff committed Nov 27, 2024
1 parent e83e111 commit 3abb14c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion RenderSystems/Vulkan/include/OgreVulkanRenderSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
5 changes: 2 additions & 3 deletions RenderSystems/Vulkan/src/OgreVulkanDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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" );
Expand Down
4 changes: 2 additions & 2 deletions RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ),
Expand Down Expand Up @@ -1092,7 +1092,7 @@ namespace Ogre
}

mActiveDevice = externalDevice
? VulkanPhysicalDevice( { externalDevice->physicalDevice, 0, String() } )
? VulkanPhysicalDevice( { externalDevice->physicalDevice, {}, String() } )
: *mInstance->findByName( mVulkanSupport->getSelectedDeviceName() );

mDevice = new VulkanDevice( this );
Expand Down

0 comments on commit 3abb14c

Please sign in to comment.