Vulkan: Allow user to specify preferred device

On a platform with multiple graphics devices (e.g. laptop with
integrated and descrete devices) it's handy to be able
to specify the specific device we want ANGLE to use.
Setting the environment variable ANGLE_PREFERRED_DEVICE to the device
name as returned by VkPhysicalDeviceProperties.deviceName will select
that device.

Bug: angleproject:4305
Change-Id: Ib16895add2c36a59135942b52401ceb7b6bc0895
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2002737
Commit-Queue: Courtney Goeltzenleuchter <courtneygo@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
This commit is contained in:
Courtney Goeltzenleuchter 2020-01-16 09:38:28 -07:00 коммит произвёл Commit Bot
Родитель 2d1d9d3521
Коммит d0b4eaf6b9
3 изменённых файлов: 8 добавлений и 1 удалений

Просмотреть файл

@ -488,7 +488,12 @@ ICDFilterFunc GetFilterForICD(vk::ICD preferredICD)
strlen(kSwiftShaderDeviceName)) == 0));
};
default:
return [](const VkPhysicalDeviceProperties &deviceProperties) { return true; };
const std::string anglePreferredDevice =
angle::GetEnvironmentVar(vk::gANGLEPreferredDevice);
return [anglePreferredDevice](const VkPhysicalDeviceProperties &deviceProperties) {
return (anglePreferredDevice.empty() ||
anglePreferredDevice == deviceProperties.deviceName);
};
}
}

Просмотреть файл

@ -261,6 +261,7 @@ namespace vk
{
const char *gLoaderLayersPathEnv = "VK_LAYER_PATH";
const char *gLoaderICDFilenamesEnv = "VK_ICD_FILENAMES";
const char *gANGLEPreferredDevice = "ANGLE_PREFERRED_DEVICE";
VkImageAspectFlags GetDepthStencilAspectFlags(const angle::Format &format)
{

Просмотреть файл

@ -117,6 +117,7 @@ void AddToPNextChain(VulkanStruct1 *chainStart, VulkanStruct2 *ptr)
extern const char *gLoaderLayersPathEnv;
extern const char *gLoaderICDFilenamesEnv;
extern const char *gANGLEPreferredDevice;
enum class ICD
{