• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2017 The Dawn Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef DAWNNATIVE_VULKAN_VULKANINFO_H_
16 #define DAWNNATIVE_VULKAN_VULKANINFO_H_
17 
18 #include "common/ityp_array.h"
19 #include "common/vulkan_platform.h"
20 #include "dawn_native/Error.h"
21 #include "dawn_native/vulkan/VulkanExtensions.h"
22 
23 #include <vector>
24 
25 namespace dawn_native { namespace vulkan {
26 
27     class Adapter;
28     class Backend;
29     struct VulkanFunctions;
30 
31     // Global information - gathered before the instance is created
32     struct VulkanGlobalKnobs {
33         VulkanLayerSet layers;
34         ityp::array<VulkanLayer, InstanceExtSet, static_cast<uint32_t>(VulkanLayer::EnumCount)>
35             layerExtensions;
36 
37         // During information gathering `extensions` only contains the instance's extensions but
38         // during the instance creation logic it becomes the OR of the instance's extensions and
39         // the selected layers' extensions.
40         InstanceExtSet extensions;
41         bool HasExt(InstanceExt ext) const;
42     };
43 
44     struct VulkanGlobalInfo : VulkanGlobalKnobs {
45         uint32_t apiVersion;
46     };
47 
48     // Device information - gathered before the device is created.
49     struct VulkanDeviceKnobs {
50         VkPhysicalDeviceFeatures features;
51         VkPhysicalDeviceShaderFloat16Int8FeaturesKHR shaderFloat16Int8Features;
52         VkPhysicalDevice16BitStorageFeaturesKHR _16BitStorageFeatures;
53         VkPhysicalDeviceSubgroupSizeControlFeaturesEXT subgroupSizeControlFeatures;
54 
55         bool HasExt(DeviceExt ext) const;
56         DeviceExtSet extensions;
57     };
58 
59     struct VulkanDeviceInfo : VulkanDeviceKnobs {
60         VkPhysicalDeviceProperties properties;
61         VkPhysicalDeviceDriverProperties driverProperties;
62         VkPhysicalDeviceSubgroupSizeControlPropertiesEXT subgroupSizeControlProperties;
63 
64         std::vector<VkQueueFamilyProperties> queueFamilies;
65 
66         std::vector<VkMemoryType> memoryTypes;
67         std::vector<VkMemoryHeap> memoryHeaps;
68 
69         std::vector<VkLayerProperties> layers;
70         // TODO(cwallez@chromium.org): layer instance extensions
71     };
72 
73     struct VulkanSurfaceInfo {
74         VkSurfaceCapabilitiesKHR capabilities;
75         std::vector<VkSurfaceFormatKHR> formats;
76         std::vector<VkPresentModeKHR> presentModes;
77         std::vector<bool> supportedQueueFamilies;
78     };
79 
80     ResultOrError<VulkanGlobalInfo> GatherGlobalInfo(const VulkanFunctions& vkFunctions);
81     ResultOrError<std::vector<VkPhysicalDevice>> GatherPhysicalDevices(
82         VkInstance instance,
83         const VulkanFunctions& vkFunctions);
84     ResultOrError<VulkanDeviceInfo> GatherDeviceInfo(const Adapter& adapter);
85     ResultOrError<VulkanSurfaceInfo> GatherSurfaceInfo(const Adapter& adapter,
86                                                        VkSurfaceKHR surface);
87 }}  // namespace dawn_native::vulkan
88 
89 #endif  // DAWNNATIVE_VULKAN_VULKANINFO_H_
90