Debian Codegraph @

src/kosmickrisp/vulkan/kk_physical_device.h

raw symbols SCIP
1 /*
2 * Copyright © 2022 Collabora Ltd. and Red Hat Inc.
3 * Copyright 2025 LunarG, Inc.
4 * Copyright 2025 Google LLC
5 * SPDX-License-Identifier: MIT
6 */
7
8 #ifndef KK_PHYSICAL_DEVICE_H
9 #define KK_PHYSICAL_DEVICE_H 1
10
11 #include "kk_private.h"
12
13 #include "kosmickrisp/bridge/mtl_types.h"
14
15 #include "vk_physical_device.h"
16 #include "vk_sync.h"
17 #include "vk_sync_binary.h"
18
19 #include "wsi_common.h"
20
21 #include <sys/types.h>
22
23 struct kk_instance;
24 struct kk_physical_device;
25
26 struct kk_queue_family {
27 VkQueueFlags queue_flags;
28 uint32_t queue_count;
29 };
30
31 struct kk_memory_heap {
32 uint64_t size;
33 uint64_t used;
34 VkMemoryHeapFlags flags;
35 uint64_t (*available)(struct kk_physical_device *pdev);
36 };
37
38 struct kk_device_info {
39 uint32_t max_workgroup_count[3];
40 uint32_t max_workgroup_invocations;
41 };
42
43 struct kk_physical_device {
44 struct vk_physical_device vk;
45 mtl_device *mtl_dev_handle;
46 struct kk_device_info info;
47
48 struct wsi_device wsi_device;
49
50 uint8_t device_uuid[VK_UUID_SIZE];
51
52 // TODO: add mapable VRAM heap if possible
53 struct kk_memory_heap mem_heaps[3];
54 VkMemoryType mem_types[3];
55 uint8_t mem_heap_count;
56 uint8_t mem_type_count;
57
58 // Emulated binary sync type
59 struct vk_sync_binary_type sync_binary_type;
60 const struct vk_sync_type *sync_types[3];
61
62 struct kk_queue_family queue_families[3];
63 uint8_t queue_family_count;
64 };
65
66 static inline uint32_t
67 kk_min_cbuf_alignment()
68 {
69 /* Size of vec4 */
70 return 16;
71 }
72
73 VK_DEFINE_HANDLE_CASTS(kk_physical_device, vk.base, VkPhysicalDevice,
74 VK_OBJECT_TYPE_PHYSICAL_DEVICE)
75
76 static inline struct kk_instance *
77 kk_physical_device_instance(struct kk_physical_device *pdev)
78 {
79 return (struct kk_instance *)pdev->vk.instance;
80 }
81
82 VkResult kk_enumerate_physical_devices(struct vk_instance *_instance);
83 void kk_physical_device_destroy(struct vk_physical_device *vk_device);
84
85 #if defined(VK_USE_PLATFORM_WAYLAND_KHR) || \
86 defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR) || \
87 defined(VK_USE_PLATFORM_DISPLAY_KHR) || defined(VK_USE_PLATFORM_METAL_EXT)
88 #define KK_USE_WSI_PLATFORM
89 #endif
90
91 #endif // KK_PHYSICAL_DEVICE_H