• 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 "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    VkQueueGlobalPriority max_priority;
29 };
30 
31 struct nvk_memory_heap {
32    uint64_t size;
33    uint64_t used;
34    VkMemoryHeapFlags flags;
35    uint64_t (*available)(struct nvk_physical_device *pdev);
36 };
37 
38 struct nvk_physical_device {
39    struct vk_physical_device vk;
40    struct nv_device_info info;
41    enum nvk_debug debug_flags;
42 
43    struct nvkmd_pdev *nvkmd;
44 
45    struct nak_compiler *nak;
46    struct wsi_device wsi_device;
47 
48    uint8_t device_uuid[VK_UUID_SIZE];
49 
50    // TODO: add mapable VRAM heap if possible
51    struct nvk_memory_heap mem_heaps[3];
52    VkMemoryType mem_types[3];
53    uint8_t mem_heap_count;
54    uint8_t mem_type_count;
55 
56    struct nvk_queue_family queue_families[3];
57    uint8_t queue_family_count;
58 };
59 
60 static inline uint32_t
nvk_min_cbuf_alignment(const struct nv_device_info * info)61 nvk_min_cbuf_alignment(const struct nv_device_info *info)
62 {
63    return info->cls_eng3d >= 0xC597 /* TURING_A */ ? 64 : 256;
64 }
65 
66 VK_DEFINE_HANDLE_CASTS(nvk_physical_device,
67    vk.base,
68    VkPhysicalDevice,
69    VK_OBJECT_TYPE_PHYSICAL_DEVICE)
70 
71 static inline uint32_t
nvk_use_edb_buffer_views(const struct nvk_physical_device * pdev)72 nvk_use_edb_buffer_views(const struct nvk_physical_device *pdev)
73 {
74    return pdev->debug_flags & NVK_DEBUG_FORCE_EDB_BVIEW;
75 }
76 
77 static inline struct nvk_instance *
nvk_physical_device_instance(struct nvk_physical_device * pdev)78 nvk_physical_device_instance(struct nvk_physical_device *pdev)
79 {
80    return (struct nvk_instance *)pdev->vk.instance;
81 }
82 
83 VkResult nvk_create_drm_physical_device(struct vk_instance *vk_instance,
84                                         struct _drmDevice *drm_device,
85                                         struct vk_physical_device **pdev_out);
86 
87 void nvk_physical_device_destroy(struct vk_physical_device *vk_device);
88 
89 VkExtent2D nvk_max_shading_rate(const struct nvk_physical_device *pdev,
90                                 VkSampleCountFlagBits samples);
91 
92 #if defined(VK_USE_PLATFORM_WAYLAND_KHR) || \
93     defined(VK_USE_PLATFORM_XCB_KHR) || \
94     defined(VK_USE_PLATFORM_XLIB_KHR) || \
95     defined(VK_USE_PLATFORM_DISPLAY_KHR)
96 #define NVK_USE_WSI_PLATFORM
97 #endif
98 
99 #endif
100