blob: b2921f820321ba8947f354cfd9d8360432ba87f6 (
plain)
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
|
//
// 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
{
enum class ICD
{
Default,
Mock,
SwiftShader,
};
struct SimpleDisplayWindow
{
uint16_t width;
uint16_t height;
};
class [[nodiscard]] 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 setCustomExtensionsEnvironment();
bool mEnableValidationLayers;
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_
|