• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 The Khronos Group Inc.
3  * Copyright (c) 2021-2022 Valve Corporation
4  * Copyright (c) 2021-2022 LunarG, Inc.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and/or associated documentation files (the "Materials"), to
8  * deal in the Materials without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Materials, and to permit persons to whom the Materials are
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice(s) and this permission notice shall be included in
14  * all copies or substantial portions of the Materials.
15  *
16  * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  *
20  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
21  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE
23  * USE OR OTHER DEALINGS IN THE MATERIALS.
24  *
25  * Author: Charles Giessen <charles@lunarg.com>
26  */
27 
28 #pragma once
29 
30 #include "test_util.h"
31 
32 // Move only type because it holds a DispatchableHandle<VkPhysicalDevice>
33 struct PhysicalDevice {
PhysicalDevicePhysicalDevice34     PhysicalDevice() {}
PhysicalDevicePhysicalDevice35     PhysicalDevice(std::string name) : deviceName(name) {}
PhysicalDevicePhysicalDevice36     PhysicalDevice(const char* name) : deviceName(name) {}
PhysicalDevicePhysicalDevice37     PhysicalDevice(std::string name, uint32_t bus) : deviceName(name), pci_bus(bus) {}
PhysicalDevicePhysicalDevice38     PhysicalDevice(const char* name, uint32_t bus) : deviceName(name), pci_bus(bus) {}
39     DispatchableHandle<VkPhysicalDevice> vk_physical_device;
40     BUILDER_VALUE(PhysicalDevice, std::string, deviceName, "")
41     BUILDER_VALUE(PhysicalDevice, VkPhysicalDeviceProperties, properties, {})
42     BUILDER_VALUE(PhysicalDevice, VkPhysicalDeviceFeatures, features, {})
43     BUILDER_VALUE(PhysicalDevice, VkPhysicalDeviceMemoryProperties, memory_properties, {})
44     BUILDER_VALUE(PhysicalDevice, VkImageFormatProperties, image_format_properties, {})
45     BUILDER_VALUE(PhysicalDevice, VkExternalMemoryProperties, external_memory_properties, {})
46     BUILDER_VALUE(PhysicalDevice, VkExternalSemaphoreProperties, external_semaphore_properties, {})
47     BUILDER_VALUE(PhysicalDevice, VkExternalFenceProperties, external_fence_properties, {})
48     BUILDER_VALUE(PhysicalDevice, uint32_t, pci_bus, {})
49 
50     BUILDER_VECTOR(PhysicalDevice, MockQueueFamilyProperties, queue_family_properties, queue_family_properties)
51     BUILDER_VECTOR(PhysicalDevice, VkFormatProperties, format_properties, format_properties)
52     BUILDER_VECTOR(PhysicalDevice, VkSparseImageFormatProperties, sparse_image_format_properties, sparse_image_format_properties)
53 
54     BUILDER_VECTOR(PhysicalDevice, Extension, extensions, extension)
55 
56     BUILDER_VALUE(PhysicalDevice, VkSurfaceCapabilitiesKHR, surface_capabilities, {})
57     BUILDER_VECTOR(PhysicalDevice, VkSurfaceFormatKHR, surface_formats, surface_format)
58     BUILDER_VECTOR(PhysicalDevice, VkPresentModeKHR, surface_present_modes, surface_present_mode)
59 
60     BUILDER_VECTOR(PhysicalDevice, VkDisplayPropertiesKHR, display_properties, display_properties)
61     BUILDER_VECTOR(PhysicalDevice, VkDisplayPlanePropertiesKHR, display_plane_properties, display_plane_properties)
62     BUILDER_VECTOR(PhysicalDevice, VkDisplayKHR, displays, displays)
63     BUILDER_VECTOR(PhysicalDevice, VkDisplayModePropertiesKHR, display_mode_properties, display_mode_properties)
64     BUILDER_VALUE(PhysicalDevice, VkDisplayModeKHR, display_mode, {})
65     BUILDER_VALUE(PhysicalDevice, VkDisplayPlaneCapabilitiesKHR, display_plane_capabilities, {})
66 
67     // VkDevice handles created from this physical device
68     std::vector<VkDevice> device_handles;
69 
70     std::vector<DispatchableHandle<VkQueue>> queue_handles;
71 
72     // Unknown physical device functions. Add a `VulkanFunction` to this list which will be searched in
73     // vkGetInstanceProcAddr for custom_instance_functions and vk_icdGetPhysicalDeviceProcAddr for custom_physical_device_functions.
74     // To add unknown device functions, add it to the PhysicalDevice directly (in the known_device_functions member)
75     BUILDER_VECTOR(PhysicalDevice, VulkanFunction, custom_physical_device_functions, custom_physical_device_function)
76 
77     // List of function names which are 'known' to the physical device but have test defined implementations
78     // The purpose of this list is so that vkGetDeviceProcAddr returns 'a real function pointer' in tests
79     // without actually implementing any of the logic inside of it.
80     BUILDER_VECTOR(PhysicalDevice, VulkanFunction, known_device_functions, device_function)
81 };
82 
83 struct PhysicalDeviceGroup {
PhysicalDeviceGroupPhysicalDeviceGroup84     PhysicalDeviceGroup() {}
PhysicalDeviceGroupPhysicalDeviceGroup85     PhysicalDeviceGroup(PhysicalDevice const& physical_device) { physical_device_handles.push_back(&physical_device); }
PhysicalDeviceGroupPhysicalDeviceGroup86     PhysicalDeviceGroup(std::vector<PhysicalDevice*> const& physical_devices) {
87         physical_device_handles.insert(physical_device_handles.end(), physical_devices.begin(), physical_devices.end());
88     }
use_physical_devicePhysicalDeviceGroup89     PhysicalDeviceGroup& use_physical_device(PhysicalDevice const& physical_device) {
90         physical_device_handles.push_back(&physical_device);
91         return *this;
92     }
93 
94     std::vector<PhysicalDevice const*> physical_device_handles;
95     VkBool32 subset_allocation = false;
96 };
97