• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "nouveau_device.h"
11 #include "nv_device_info.h"
12 
13 #include "vulkan/runtime/vk_physical_device.h"
14 #include "vulkan/runtime/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 
24 struct nvk_queue_family {
25    VkQueueFlags queue_flags;
26    uint32_t queue_count;
27 };
28 
29 struct nvk_memory_heap {
30    uint64_t size;
31    uint64_t used;
32    VkMemoryHeapFlags flags;
33    uint64_t (*available)(struct nvk_physical_device *pdev);
34 };
35 
36 struct nvk_physical_device {
37    struct vk_physical_device vk;
38    struct nv_device_info info;
39    enum nvk_debug debug_flags;
40    dev_t render_dev;
41    int master_fd;
42 
43    /* Only used for VK_EXT_memory_budget */
44    struct nouveau_ws_device *ws_dev;
45 
46    struct nak_compiler *nak;
47    struct wsi_device wsi_device;
48 
49    uint8_t device_uuid[VK_UUID_SIZE];
50 
51    // TODO: add mapable VRAM heap if possible
52    struct nvk_memory_heap mem_heaps[2];
53    VkMemoryType mem_types[3];
54    uint8_t mem_heap_count;
55    uint8_t mem_type_count;
56 
57    struct nvk_queue_family queue_families[3];
58    uint8_t queue_family_count;
59 
60    struct vk_sync_type syncobj_sync_type;
61    const struct vk_sync_type *sync_types[2];
62 };
63 
64 uint32_t nvk_min_cbuf_alignment(const struct nv_device_info *info);
65 
66 VK_DEFINE_HANDLE_CASTS(nvk_physical_device,
67    vk.base,
68    VkPhysicalDevice,
69    VK_OBJECT_TYPE_PHYSICAL_DEVICE)
70 
71 static inline struct nvk_instance *
nvk_physical_device_instance(struct nvk_physical_device * pdev)72 nvk_physical_device_instance(struct nvk_physical_device *pdev)
73 {
74    return (struct nvk_instance *)pdev->vk.instance;
75 }
76 
77 VkResult nvk_create_drm_physical_device(struct vk_instance *vk_instance,
78                                         struct _drmDevice *drm_device,
79                                         struct vk_physical_device **pdev_out);
80 
81 void nvk_physical_device_destroy(struct vk_physical_device *vk_device);
82 
83 #if defined(VK_USE_PLATFORM_WAYLAND_KHR) || \
84     defined(VK_USE_PLATFORM_XCB_KHR) || \
85     defined(VK_USE_PLATFORM_XLIB_KHR) || \
86     defined(VK_USE_PLATFORM_DISPLAY_KHR)
87 #define NVK_USE_WSI_PLATFORM
88 #endif
89 
90 #endif
91