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 49c451d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 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
8 changes: 4 additions & 4 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 @@ -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 );
Expand Down

0 comments on commit 49c451d

Please sign in to comment.