1 /*
2 * Copyright © 2022 Collabora Ltd. and Red Hat Inc.
3 * SPDX-License-Identifier: MIT
4 */
5 #ifndef NVK_QUEUE_H
6 #define NVK_QUEUE_H 1
7
8 #include "nvk_private.h"
9
10 #include "vk_queue.h"
11
12 struct novueau_ws_bo;
13 struct nouveau_ws_context;
14 struct novueau_ws_push;
15 struct nv_push;
16 struct nvk_device;
17
18 struct nvk_queue_state {
19 struct {
20 struct nouveau_ws_bo *bo;
21 uint32_t alloc_count;
22 } images;
23
24 struct {
25 struct nouveau_ws_bo *bo;
26 uint32_t alloc_count;
27 } samplers;
28
29 struct {
30 struct nouveau_ws_bo *bo;
31 uint32_t bytes_per_warp;
32 uint32_t bytes_per_tpc;
33 } slm;
34
35 struct {
36 struct nouveau_ws_bo *bo;
37 void *bo_map;
38 uint32_t dw_count;
39 } push;
40 };
41
42 VkResult nvk_queue_state_update(struct nvk_device *dev,
43 struct nvk_queue_state *qs);
44
45 struct nvk_queue {
46 struct vk_queue vk;
47
48 struct {
49 struct nouveau_ws_context *ws_ctx;
50 uint32_t syncobj;
51 } drm;
52
53 struct nvk_queue_state state;
54 };
55
56 static inline struct nvk_device *
nvk_queue_device(struct nvk_queue * queue)57 nvk_queue_device(struct nvk_queue *queue)
58 {
59 return (struct nvk_device *)queue->vk.base.device;
60 }
61
62 VkResult nvk_queue_init(struct nvk_device *dev, struct nvk_queue *queue,
63 const VkDeviceQueueCreateInfo *pCreateInfo,
64 uint32_t index_in_family);
65
66 void nvk_queue_finish(struct nvk_device *dev, struct nvk_queue *queue);
67
68 VkResult nvk_push_draw_state_init(struct nvk_device *dev,
69 struct nv_push *p);
70
71 VkResult nvk_push_dispatch_state_init(struct nvk_device *dev,
72 struct nv_push *p);
73
74 /* this always syncs, so only use when that doesn't matter */
75 VkResult nvk_queue_submit_simple(struct nvk_queue *queue,
76 uint32_t dw_count, const uint32_t *dw,
77 uint32_t extra_bo_count,
78 struct nouveau_ws_bo **extra_bos);
79
80 VkResult nvk_queue_init_drm_nouveau(struct nvk_device *dev,
81 struct nvk_queue *queue,
82 VkQueueFlags queue_flags);
83
84 void nvk_queue_finish_drm_nouveau(struct nvk_device *dev,
85 struct nvk_queue *queue);
86
87 VkResult nvk_queue_submit_simple_drm_nouveau(struct nvk_queue *queue,
88 uint32_t push_dw_count,
89 struct nouveau_ws_bo *push_bo,
90 uint32_t extra_bo_count,
91 struct nouveau_ws_bo **extra_bos);
92
93 VkResult nvk_queue_submit_drm_nouveau(struct nvk_queue *queue,
94 struct vk_queue_submit *submit,
95 bool sync);
96
97 #endif
98