| 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 |
uint64_t sysmem; |
| 50 |
|
| 51 |
struct hk_queue_family queue_families[3]; |
| 52 |
uint8_t queue_family_count; |
| 53 |
|
| 54 |
struct vk_sync_type syncobj_sync_type; |
| 55 |
const struct vk_sync_type *sync_types[2]; |
| 56 |
|
| 57 |
simple_mtx_t debug_compile_lock; |
| 58 |
}; |
| 59 |
|
| 60 |
VK_DEFINE_HANDLE_CASTS(hk_physical_device, vk.base, VkPhysicalDevice, |
| 61 |
VK_OBJECT_TYPE_PHYSICAL_DEVICE) |
| 62 |
|
| 63 |
static inline struct hk_instance * |
| 64 |
hk_physical_device_instance(struct hk_physical_device *pdev) |
| 65 |
{ |
| 66 |
return (struct hk_instance *)pdev->vk.instance; |
| 67 |
} |
| 68 |
|
| 69 |
VkResult hk_create_drm_physical_device(struct vk_instance *vk_instance, |
| 70 |
struct _drmDevice *drm_device, |
| 71 |
struct vk_physical_device **pdev_out); |
| 72 |
|
| 73 |
void hk_physical_device_destroy(struct vk_physical_device *vk_device); |
| 74 |
|
| 75 |
#if defined(VK_USE_PLATFORM_WAYLAND_KHR) || \ |
| 76 |
defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR) || \ |
| 77 |
defined(VK_USE_PLATFORM_DISPLAY_KHR) |
| 78 |
#define HK_USE_WSI_PLATFORM |
| 79 |
#endif |