1 /* 2 * Copyright © 2022 Collabora Ltd. and Red Hat Inc. 3 * SPDX-License-Identifier: MIT 4 */ 5 #ifndef NVK_PHYSICAL_DEVICE_H 6 #define NVK_PHYSICAL_DEVICE_H 1 7 8 #include "nvk_private.h" 9 10 #include "nvk_debug.h" 11 #include "nv_device_info.h" 12 13 #include "vk_physical_device.h" 14 #include "vk_sync.h" 15 16 #include "wsi_common.h" 17 18 #include <sys/types.h> 19 20 struct nak_compiler; 21 struct nvk_instance; 22 struct nvk_physical_device; 23 struct nvkmd_pdev; 24 25 struct nvk_queue_family { 26 VkQueueFlags queue_flags; 27 uint32_t queue_count; 28 }; 29 30 struct nvk_memory_heap { 31 uint64_t size; 32 uint64_t used; 33 VkMemoryHeapFlags flags; 34 uint64_t (*available)(struct nvk_physical_device *pdev); 35 }; 36 37 struct nvk_physical_device { 38 struct vk_physical_device vk; 39 struct nv_device_info info; 40 enum nvk_debug debug_flags; 41 42 struct nvkmd_pdev *nvkmd; 43 44 struct nak_compiler *nak; 45 struct wsi_device wsi_device; 46 47 uint8_t device_uuid[VK_UUID_SIZE]; 48 49 // TODO: add mapable VRAM heap if possible 50 struct nvk_memory_heap mem_heaps[3]; 51 VkMemoryType mem_types[3]; 52 uint8_t mem_heap_count; 53 uint8_t mem_type_count; 54 55 struct nvk_queue_family queue_families[3]; 56 uint8_t queue_family_count; 57 }; 58 59 static inline uint32_t nvk_min_cbuf_alignment(const struct nv_device_info * info)60nvk_min_cbuf_alignment(const struct nv_device_info *info) 61 { 62 return info->cls_eng3d >= 0xC597 /* TURING_A */ ? 64 : 256; 63 } 64 65 VK_DEFINE_HANDLE_CASTS(nvk_physical_device, 66 vk.base, 67 VkPhysicalDevice, 68 VK_OBJECT_TYPE_PHYSICAL_DEVICE) 69 70 static inline uint32_t nvk_use_edb_buffer_views(const struct nvk_physical_device * pdev)71nvk_use_edb_buffer_views(const struct nvk_physical_device *pdev) 72 { 73 return pdev->debug_flags & NVK_DEBUG_FORCE_EDB_BVIEW; 74 } 75 76 static inline struct nvk_instance * nvk_physical_device_instance(struct nvk_physical_device * pdev)77nvk_physical_device_instance(struct nvk_physical_device *pdev) 78 { 79 return (struct nvk_instance *)pdev->vk.instance; 80 } 81 82 VkResult nvk_create_drm_physical_device(struct vk_instance *vk_instance, 83 struct _drmDevice *drm_device, 84 struct vk_physical_device **pdev_out); 85 86 void nvk_physical_device_destroy(struct vk_physical_device *vk_device); 87 88 #if defined(VK_USE_PLATFORM_WAYLAND_KHR) || \ 89 defined(VK_USE_PLATFORM_XCB_KHR) || \ 90 defined(VK_USE_PLATFORM_XLIB_KHR) || \ 91 defined(VK_USE_PLATFORM_DISPLAY_KHR) 92 #define NVK_USE_WSI_PLATFORM 93 #endif 94 95 #endif 96