Debian Codegraph @

tests/framework/util/vulkan_object_wrappers.h

raw
1 /*
2 * Copyright (c) 2025 The Khronos Group Inc.
3 * Copyright (c) 2025 Valve Corporation
4 * Copyright (c) 2025 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 */
26
27 #pragma once
28
29 #include <string>
30 #include <vector>
31
32 #include <vulkan/vulkan_core.h>
33
34 #include "builder_defines.h"
35
36 struct Extension {
37 BUILDER_VALUE(std::string, extensionName)
38 BUILDER_VALUE_WITH_DEFAULT(uint32_t, specVersion, VK_API_VERSION_1_0)
39
40 Extension(const char* name, uint32_t specVersion = VK_API_VERSION_1_0) noexcept
41 : extensionName(name), specVersion(specVersion) {}
42 Extension(std::string extensionName, uint32_t specVersion = VK_API_VERSION_1_0) noexcept
43 : extensionName(extensionName), specVersion(specVersion) {}
44
45 VkExtensionProperties get() const noexcept;
46 };
47
48 struct MockQueueFamilyProperties {
49 BUILDER_VALUE(VkQueueFamilyProperties, properties)
50 BUILDER_VALUE(bool, support_present)
51
52 VkQueueFamilyProperties get() const noexcept { return properties; }
53 };
54
55 struct InstanceCreateInfo {
56 BUILDER_VALUE(VkInstanceCreateInfo, instance_info)
57 BUILDER_VALUE(VkApplicationInfo, application_info)
58 BUILDER_VALUE(std::string, app_name)
59 BUILDER_VALUE(std::string, engine_name)
60 BUILDER_VALUE(uint32_t, flags)
61 BUILDER_VALUE(uint32_t, app_version)
62 BUILDER_VALUE(uint32_t, engine_version)
63 BUILDER_VALUE_WITH_DEFAULT(uint32_t, api_version, VK_API_VERSION_1_0)
64 BUILDER_VECTOR(const char*, enabled_layers, layer)
65 BUILDER_VECTOR(const char*, enabled_extensions, extension)
66 // tell the get() function to not provide `application_info`
67 BUILDER_VALUE_WITH_DEFAULT(bool, fill_in_application_info, true)
68
69 InstanceCreateInfo();
70
71 VkInstanceCreateInfo* get() noexcept;
72
73 InstanceCreateInfo& set_api_version(uint32_t major, uint32_t minor, uint32_t patch);
74
75 InstanceCreateInfo& setup_WSI(const char* api_selection = nullptr);
76 };
77
78 struct DeviceQueueCreateInfo {
79 DeviceQueueCreateInfo();
80 DeviceQueueCreateInfo(const VkDeviceQueueCreateInfo* create_info);
81
82 BUILDER_VALUE(VkDeviceQueueCreateInfo, queue_create_info)
83 BUILDER_VECTOR(float, priorities, priority)
84
85 VkDeviceQueueCreateInfo get() noexcept;
86 };
87
88 struct DeviceCreateInfo {
89 DeviceCreateInfo() = default;
90 DeviceCreateInfo(const VkDeviceCreateInfo* create_info);
91
92 BUILDER_VALUE(VkDeviceCreateInfo, dev)
93 BUILDER_VECTOR(const char*, enabled_extensions, extension)
94 BUILDER_VECTOR(const char*, enabled_layers, layer)
95 BUILDER_VECTOR(DeviceQueueCreateInfo, queue_info_details, device_queue)
96
97 VkDeviceCreateInfo* get() noexcept;
98
99 private:
100 std::vector<VkDeviceQueueCreateInfo> device_queue_infos;
101 };