15db71995Sopenharmony_ci/* 25db71995Sopenharmony_ci * Copyright (c) 2021-2022 The Khronos Group Inc. 35db71995Sopenharmony_ci * Copyright (c) 2021-2022 Valve Corporation 45db71995Sopenharmony_ci * Copyright (c) 2021-2022 LunarG, Inc. 55db71995Sopenharmony_ci * 65db71995Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a copy 75db71995Sopenharmony_ci * of this software and/or associated documentation files (the "Materials"), to 85db71995Sopenharmony_ci * deal in the Materials without restriction, including without limitation the 95db71995Sopenharmony_ci * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 105db71995Sopenharmony_ci * sell copies of the Materials, and to permit persons to whom the Materials are 115db71995Sopenharmony_ci * furnished to do so, subject to the following conditions: 125db71995Sopenharmony_ci * 135db71995Sopenharmony_ci * The above copyright notice(s) and this permission notice shall be included in 145db71995Sopenharmony_ci * all copies or substantial portions of the Materials. 155db71995Sopenharmony_ci * 165db71995Sopenharmony_ci * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 175db71995Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 185db71995Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 195db71995Sopenharmony_ci * 205db71995Sopenharmony_ci * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 215db71995Sopenharmony_ci * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 225db71995Sopenharmony_ci * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE 235db71995Sopenharmony_ci * USE OR OTHER DEALINGS IN THE MATERIALS. 245db71995Sopenharmony_ci * 255db71995Sopenharmony_ci * Author: Charles Giessen <charles@lunarg.com> 265db71995Sopenharmony_ci */ 275db71995Sopenharmony_ci 285db71995Sopenharmony_ci#pragma once 295db71995Sopenharmony_ci 305db71995Sopenharmony_ci#include "test_util.h" 315db71995Sopenharmony_ci 325db71995Sopenharmony_ci// Move only type because it holds a DispatchableHandle<VkPhysicalDevice> 335db71995Sopenharmony_cistruct PhysicalDevice { 345db71995Sopenharmony_ci PhysicalDevice() {} 355db71995Sopenharmony_ci PhysicalDevice(std::string name) : deviceName(name) {} 365db71995Sopenharmony_ci PhysicalDevice(const char* name) : deviceName(name) {} 375db71995Sopenharmony_ci 385db71995Sopenharmony_ci DispatchableHandle<VkPhysicalDevice> vk_physical_device; 395db71995Sopenharmony_ci BUILDER_VALUE(PhysicalDevice, std::string, deviceName, "") 405db71995Sopenharmony_ci BUILDER_VALUE(PhysicalDevice, VkPhysicalDeviceProperties, properties, {}) 415db71995Sopenharmony_ci BUILDER_VALUE(PhysicalDevice, VkPhysicalDeviceFeatures, features, {}) 425db71995Sopenharmony_ci BUILDER_VALUE(PhysicalDevice, VkPhysicalDeviceMemoryProperties, memory_properties, {}) 435db71995Sopenharmony_ci BUILDER_VALUE(PhysicalDevice, VkImageFormatProperties, image_format_properties, {}) 445db71995Sopenharmony_ci BUILDER_VALUE(PhysicalDevice, VkExternalMemoryProperties, external_memory_properties, {}) 455db71995Sopenharmony_ci BUILDER_VALUE(PhysicalDevice, VkExternalSemaphoreProperties, external_semaphore_properties, {}) 465db71995Sopenharmony_ci BUILDER_VALUE(PhysicalDevice, VkExternalFenceProperties, external_fence_properties, {}) 475db71995Sopenharmony_ci BUILDER_VALUE(PhysicalDevice, uint32_t, pci_bus, {}) 485db71995Sopenharmony_ci 495db71995Sopenharmony_ci BUILDER_VECTOR(PhysicalDevice, MockQueueFamilyProperties, queue_family_properties, queue_family_properties) 505db71995Sopenharmony_ci BUILDER_VECTOR(PhysicalDevice, VkFormatProperties, format_properties, format_properties) 515db71995Sopenharmony_ci BUILDER_VECTOR(PhysicalDevice, VkSparseImageFormatProperties, sparse_image_format_properties, sparse_image_format_properties) 525db71995Sopenharmony_ci 535db71995Sopenharmony_ci BUILDER_VECTOR(PhysicalDevice, Extension, extensions, extension) 545db71995Sopenharmony_ci 555db71995Sopenharmony_ci BUILDER_VALUE(PhysicalDevice, VkSurfaceCapabilitiesKHR, surface_capabilities, {}) 565db71995Sopenharmony_ci BUILDER_VECTOR(PhysicalDevice, VkSurfaceFormatKHR, surface_formats, surface_format) 575db71995Sopenharmony_ci BUILDER_VECTOR(PhysicalDevice, VkPresentModeKHR, surface_present_modes, surface_present_mode) 585db71995Sopenharmony_ci 595db71995Sopenharmony_ci BUILDER_VECTOR(PhysicalDevice, VkDisplayPropertiesKHR, display_properties, display_properties) 605db71995Sopenharmony_ci BUILDER_VECTOR(PhysicalDevice, VkDisplayPlanePropertiesKHR, display_plane_properties, display_plane_properties) 615db71995Sopenharmony_ci BUILDER_VECTOR(PhysicalDevice, VkDisplayKHR, displays, displays) 625db71995Sopenharmony_ci BUILDER_VECTOR(PhysicalDevice, VkDisplayModePropertiesKHR, display_mode_properties, display_mode_properties) 635db71995Sopenharmony_ci BUILDER_VALUE(PhysicalDevice, VkDisplayModeKHR, display_mode, {}) 645db71995Sopenharmony_ci BUILDER_VALUE(PhysicalDevice, VkDisplayPlaneCapabilitiesKHR, display_plane_capabilities, {}) 655db71995Sopenharmony_ci 665db71995Sopenharmony_ci BUILDER_VALUE(PhysicalDevice, VkLayeredDriverUnderlyingApiMSFT, layered_driver_underlying_api, 675db71995Sopenharmony_ci VK_LAYERED_DRIVER_UNDERLYING_API_NONE_MSFT) 685db71995Sopenharmony_ci 695db71995Sopenharmony_ci PhysicalDevice& set_api_version(uint32_t version) { 705db71995Sopenharmony_ci properties.apiVersion = version; 715db71995Sopenharmony_ci return *this; 725db71995Sopenharmony_ci } 735db71995Sopenharmony_ci 745db71995Sopenharmony_ci PhysicalDevice&& finish() { return std::move(*this); } 755db71995Sopenharmony_ci 765db71995Sopenharmony_ci // Objects created from this physical device 775db71995Sopenharmony_ci std::vector<VkDevice> device_handles; 785db71995Sopenharmony_ci std::vector<DeviceCreateInfo> device_create_infos; 795db71995Sopenharmony_ci std::vector<DispatchableHandle<VkQueue>> queue_handles; 805db71995Sopenharmony_ci 815db71995Sopenharmony_ci // Unknown physical device functions. Add a `VulkanFunction` to this list which will be searched in 825db71995Sopenharmony_ci // vkGetInstanceProcAddr for custom_instance_functions and vk_icdGetPhysicalDeviceProcAddr for custom_physical_device_functions. 835db71995Sopenharmony_ci // To add unknown device functions, add it to the PhysicalDevice directly (in the known_device_functions member) 845db71995Sopenharmony_ci BUILDER_VECTOR(PhysicalDevice, VulkanFunction, custom_physical_device_functions, custom_physical_device_function) 855db71995Sopenharmony_ci 865db71995Sopenharmony_ci // List of function names which are 'known' to the physical device but have test defined implementations 875db71995Sopenharmony_ci // The purpose of this list is so that vkGetDeviceProcAddr returns 'a real function pointer' in tests 885db71995Sopenharmony_ci // without actually implementing any of the logic inside of it. 895db71995Sopenharmony_ci BUILDER_VECTOR(PhysicalDevice, VulkanFunction, known_device_functions, device_function) 905db71995Sopenharmony_ci}; 915db71995Sopenharmony_ci 925db71995Sopenharmony_cistruct PhysicalDeviceGroup { 935db71995Sopenharmony_ci PhysicalDeviceGroup() {} 945db71995Sopenharmony_ci PhysicalDeviceGroup(PhysicalDevice const& physical_device) { physical_device_handles.push_back(&physical_device); } 955db71995Sopenharmony_ci PhysicalDeviceGroup(std::vector<PhysicalDevice*> const& physical_devices) { 965db71995Sopenharmony_ci physical_device_handles.insert(physical_device_handles.end(), physical_devices.begin(), physical_devices.end()); 975db71995Sopenharmony_ci } 985db71995Sopenharmony_ci PhysicalDeviceGroup& use_physical_device(PhysicalDevice const& physical_device) { 995db71995Sopenharmony_ci physical_device_handles.push_back(&physical_device); 1005db71995Sopenharmony_ci return *this; 1015db71995Sopenharmony_ci } 1025db71995Sopenharmony_ci 1035db71995Sopenharmony_ci std::vector<PhysicalDevice const*> physical_device_handles; 1045db71995Sopenharmony_ci VkBool32 subset_allocation = false; 1055db71995Sopenharmony_ci}; 106