Allow user to specify a partial gpu name to the forceAdaptor command line argument

Signed-off-by: rgba16f <82187279+rgba16f@users.noreply.github.com>
This commit is contained in:
rgba16f
2021-07-26 13:28:54 -05:00
parent 8581b30260
commit 79dea539c4
3 changed files with 13 additions and 5 deletions
+11 -5
View File
@@ -18,6 +18,7 @@
#include <AzFramework/CommandLine/CommandLine.h>
#include <Atom/RHI.Reflect/PlatformLimitsDescriptor.h>
#include <AzCore/Settings/SettingsRegistryImpl.h>
#include <AzCore/std/string/conversions.h>
AZ_DEFINE_BUDGET(RHI);
@@ -101,6 +102,8 @@ namespace AZ
}
AZStd::string preferredUserAdapterName = RHI::GetCommandLineValue("forceAdapter");
AZStd::to_lower(preferredUserAdapterName.begin(), preferredUserAdapterName.end());
bool findPreferredUserDevice = preferredUserAdapterName.size() > 0;
RHI::PhysicalDevice* preferredUserDevice{};
RHI::PhysicalDevice* preferredVendorDevice{};
@@ -110,12 +113,15 @@ namespace AZ
const RHI::PhysicalDeviceDescriptor& descriptor = physicalDevice->GetDescriptor();
AZ_Printf("RHISystem", "\tEnumerated physical device: %s\n", descriptor.m_description.c_str());
if (!preferredUserDevice && descriptor.m_description == preferredUserAdapterName)
if (findPreferredUserDevice)
{
preferredUserDevice = physicalDevice.get();
AZStd::string descriptorLowerCase = descriptor.m_description;
AZStd::to_lower( descriptorLowerCase.begin(), descriptorLowerCase.end());
if (!preferredUserDevice && descriptorLowerCase.contains(preferredUserAdapterName))
{
preferredUserDevice = physicalDevice.get();
}
}
// Record the first nVidia or AMD device we find.
if (!preferredVendorDevice && (descriptor.m_vendorId == RHI::VendorId::AMD || descriptor.m_vendorId == RHI::VendorId::nVidia))
{
@@ -123,7 +129,7 @@ namespace AZ
}
}
AZ_Warning("RHISystem", preferredUserAdapterName.empty() || preferredUserDevice, "Specified adapter name not found: '%s'", preferredUserAdapterName.c_str());
AZ_Warning("RHI", preferredUserAdapterName.empty() || preferredUserDevice, "Specified adapter name not found: '%s'", preferredUserAdapterName.c_str());
RHI::PhysicalDevice* physicalDeviceFound{};
@@ -56,6 +56,7 @@ namespace AZ
void RPISystemComponent::GetRequiredServices(ComponentDescriptor::DependencyArrayType& required)
{
required.push_back(RHI::Factory::GetComponentService());
required.push_back(AZ_CRC_CE("LoggerService"));
}
void RPISystemComponent::GetProvidedServices(ComponentDescriptor::DependencyArrayType& provided)
@@ -79,6 +79,7 @@ namespace AZ
void RPISystem::Initialize(const RPISystemDescriptor& rpiSystemDescriptor)
{
AZ_Printf("RHI", "RPISystem Initialize\n");
m_rhiSystem.InitDevice();
// Gather asset handlers from sub-systems.