Merge pull request #4423 from aws-lumberyard-dev/MakeUserAdapterNameMatchPartialNames

Allow user to specify a partial gpu name to the forceAdaptor commandline argument
This commit is contained in:
Jeremy Ong
2021-10-01 14:18:39 -06:00
committed by GitHub
+10 -4
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))
{