1 /* 2 * Copyright 2024 Valve Corporation 3 * Copyright 2024 Alyssa Rosenzweig 4 * Copyright 2022-2023 Collabora Ltd. and Red Hat Inc. 5 * SPDX-License-Identifier: MIT 6 */ 7 8 #pragma once 9 10 #include "asahi/lib/agx_device.h" 11 #include <sys/types.h> 12 #include "hk_private.h" 13 #include "vk_physical_device.h" 14 #include "vk_sync.h" 15 #include "wsi_common.h" 16 17 struct hk_instance; 18 struct hk_physical_device; 19 20 struct hk_queue_family { 21 VkQueueFlags queue_flags; 22 uint32_t queue_count; 23 }; 24 25 struct hk_memory_heap { 26 uint64_t size; 27 uint64_t used; 28 VkMemoryHeapFlags flags; 29 uint64_t (*available)(struct hk_physical_device *pdev); 30 }; 31 32 struct hk_physical_device { 33 struct vk_physical_device vk; 34 dev_t render_dev; 35 int master_fd; 36 37 /* Only used for VK_EXT_memory_budget */ 38 struct agx_device dev; 39 40 struct wsi_device wsi_device; 41 42 uint8_t device_uuid[VK_UUID_SIZE]; 43 44 // TODO: add mapable VRAM heap if possible 45 struct hk_memory_heap mem_heaps[3]; 46 VkMemoryType mem_types[3]; 47 uint8_t mem_heap_count; 48 uint8_t mem_type_count; 49 50 struct hk_queue_family queue_families[3]; 51 uint8_t queue_family_count; 52 53 struct vk_sync_type syncobj_sync_type; 54 const struct vk_sync_type *sync_types[2]; 55 }; 56 57 VK_DEFINE_HANDLE_CASTS(hk_physical_device, vk.base, VkPhysicalDevice, 58 VK_OBJECT_TYPE_PHYSICAL_DEVICE) 59 60 static inline struct hk_instance * hk_physical_device_instance(struct hk_physical_device * pdev)61hk_physical_device_instance(struct hk_physical_device *pdev) 62 { 63 return (struct hk_instance *)pdev->vk.instance; 64 } 65 66 VkResult hk_create_drm_physical_device(struct vk_instance *vk_instance, 67 struct _drmDevice *drm_device, 68 struct vk_physical_device **pdev_out); 69 70 void hk_physical_device_destroy(struct vk_physical_device *vk_device); 71 72 #if defined(VK_USE_PLATFORM_WAYLAND_KHR) || \ 73 defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR) || \ 74 defined(VK_USE_PLATFORM_DISPLAY_KHR) 75 #define HK_USE_WSI_PLATFORM 76 #endif 77