Hash :
06921c61
Author :
Date :
2024-07-08T12:13:40
vulkan: filter out devices with insufficient API version We weren't taking the version into consideration inside ChoosePhysicalDevice, but RendererVk really cares about that and will error out if the selected device doesn't meet the minimum API version requirements. Frontload some of that API version check work in ChoosePhysicalDevice, giving it the opportunity to find a device that matches the requirements. Bug: angleproject:351866412 Change-Id: I471e93b03eca5e18e98202f9848ba0fd1b55d5a8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5686556 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Auto-Submit: Steven Noonan <steven@uplinklabs.net> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// vulkan_icd.h : Helper for creating vulkan instances & selecting physical device.
#ifndef COMMON_VULKAN_VULKAN_ICD_H_
#define COMMON_VULKAN_VULKAN_ICD_H_
#include <string>
#include "common/Optional.h"
#include "common/angleutils.h"
#include "common/vulkan/vk_headers.h"
namespace angle
{
namespace vk
{
// The minimum version of Vulkan that ANGLE requires. If an instance or device below this version
// is encountered, initialization will skip the device if possible, or if no other suitable device
// is available then initialization will fail.
constexpr uint32_t kMinimumVulkanAPIVersion = VK_API_VERSION_1_1;
enum class ICD
{
Default,
Mock,
SwiftShader,
};
struct SimpleDisplayWindow
{
uint16_t width;
uint16_t height;
};
class [[nodiscard]] ScopedVkLoaderEnvironment : angle::NonCopyable
{
public:
ScopedVkLoaderEnvironment(bool enableDebugLayers, vk::ICD icd);
~ScopedVkLoaderEnvironment();
bool canEnableDebugLayers() const { return mEnableDebugLayers; }
vk::ICD getEnabledICD() const { return mICD; }
private:
bool setICDEnvironment(const char *icd);
bool mEnableDebugLayers;
vk::ICD mICD;
bool mChangedCWD;
Optional<std::string> mPreviousCWD;
bool mChangedICDEnv;
Optional<std::string> mPreviousICDEnv;
Optional<std::string> mPreviousCustomExtensionsEnv;
bool mChangedNoDeviceSelect;
Optional<std::string> mPreviousNoDeviceSelectEnv;
};
void ChoosePhysicalDevice(PFN_vkGetPhysicalDeviceProperties pGetPhysicalDeviceProperties,
const std::vector<VkPhysicalDevice> &physicalDevices,
vk::ICD preferredICD,
uint32_t preferredVendorID,
uint32_t preferredDeviceID,
VkPhysicalDevice *physicalDeviceOut,
VkPhysicalDeviceProperties *physicalDevicePropertiesOut);
} // namespace vk
} // namespace angle
#endif // COMMON_VULKAN_VULKAN_ICD_H_