@@ -35,11 +35,11 @@ namespace AZ::RHI
35
35
return Interface<RHIMemoryStatisticsInterface>::Get ();
36
36
}
37
37
38
- ResultCode RHISystem::InitDevices (InitDevicesFlags initializationVariant )
38
+ ResultCode RHISystem::InitDevices (int deviceCount )
39
39
{
40
40
Interface<RHISystemInterface>::Register (this );
41
41
Interface<RHIMemoryStatisticsInterface>::Register (this );
42
- return InitInternalDevices (initializationVariant );
42
+ return InitInternalDevices (deviceCount );
43
43
}
44
44
45
45
void RHISystem::Init (RHI::Ptr<RHI::ShaderResourceGroupLayout> bindlessSrgLayout)
@@ -100,7 +100,7 @@ namespace AZ::RHI
100
100
RHISystemNotificationBus::Broadcast (&RHISystemNotificationBus::Events::OnRHISystemInitialized);
101
101
}
102
102
103
- ResultCode RHISystem::InitInternalDevices (InitDevicesFlags initializationVariant )
103
+ ResultCode RHISystem::InitInternalDevices (int deviceCount )
104
104
{
105
105
RHI::PhysicalDeviceList physicalDevices = RHI::Factory::Get ().EnumeratePhysicalDevices ();
106
106
@@ -114,7 +114,7 @@ namespace AZ::RHI
114
114
115
115
RHI::PhysicalDeviceList usePhysicalDevices;
116
116
117
- if (initializationVariant == InitDevicesFlags::MultiDevice )
117
+ if (deviceCount > 1 )
118
118
{
119
119
AZ_Printf (" RHISystem" , " \t Using multiple devices\n " );
120
120
@@ -197,6 +197,14 @@ namespace AZ::RHI
197
197
}
198
198
}
199
199
200
+ for (auto index{ 0 }; m_devices.size () < deviceCount; index++)
201
+ {
202
+ // We do not have enough physical devices for the requested device count
203
+ // Virtualize the existing devices up to the required number
204
+ auto deviceIndex{ AddVirtualDevice (m_devices[index]->GetDeviceIndex ()) };
205
+ AZ_Printf (" RHISystem" , " \t Virtualized device %d from device %d\n " , deviceIndex.value (), m_devices[index]->GetDeviceIndex ());
206
+ }
207
+
200
208
if (m_devices.empty ())
201
209
{
202
210
AZ_Error (" RHISystem" , false , " Failed to initialize RHI device." );
0 commit comments