Hash :
605af42e
Author :
Date :
2020-03-04T21:52:53
Vulkan: Move ICD overrides to a common place We also need the bundled ICDs and selection logic for certain tests that create a vulkan instance. If we don't, the tests will use default vulkan even if ANGLE is using swiftshader-vulkan. Tests of driver specific handle types (e..g opaque fd) will fail in this case. Bug: angleproject:4092 Change-Id: Iff089c9341b8b533ee8634923d0177c5dbcd5cc8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2088659 Commit-Queue: Michael Spang <spang@chromium.org> Reviewed-by: Tim Van Patten <timvp@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
//
// 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 "libANGLE/renderer/vulkan/vk_headers.h"
namespace angle
{
namespace vk
{
enum class ICD
{
Default,
Mock,
SwiftShader,
};
class ScopedVkLoaderEnvironment : angle::NonCopyable
{
public:
ScopedVkLoaderEnvironment(bool enableValidationLayers, vk::ICD icd);
~ScopedVkLoaderEnvironment();
bool canEnableValidationLayers() const { return mEnableValidationLayers; }
vk::ICD getEnabledICD() const { return mICD; }
private:
bool setICDEnvironment(const char *icd);
bool mEnableValidationLayers;
vk::ICD mICD;
bool mChangedCWD;
Optional<std::string> mPreviousCWD;
bool mChangedICDEnv;
Optional<std::string> mPreviousICDEnv;
};
void ChoosePhysicalDevice(const std::vector<VkPhysicalDevice> &physicalDevices,
vk::ICD preferredICD,
VkPhysicalDevice *physicalDeviceOut,
VkPhysicalDeviceProperties *physicalDevicePropertiesOut);
} // namespace vk
} // namespace angle
#endif // COMMON_VULKAN_VULKAN_ICD_H_