1/*
2 * Copyright 2019 Google LLC
3 * SPDX-License-Identifier: MIT
4 *
5 * based in part on anv and radv which are:
6 * Copyright © 2015 Intel Corporation
7 * Copyright © 2016 Red Hat.
8 * Copyright © 2016 Bas Nieuwenhuizen
9 */
10
11#ifndef VN_QUEUE_H
12#define VN_QUEUE_H
13
14#include "vn_common.h"
15
16struct vn_queue {
17   struct vn_object_base base;
18
19   struct vn_device *device;
20   uint32_t family;
21   uint32_t index;
22   uint32_t flags;
23
24   VkFence wait_fence;
25};
26VK_DEFINE_HANDLE_CASTS(vn_queue, base.base, VkQueue, VK_OBJECT_TYPE_QUEUE)
27
28enum vn_sync_type {
29   /* no payload */
30   VN_SYNC_TYPE_INVALID,
31
32   /* device object */
33   VN_SYNC_TYPE_DEVICE_ONLY,
34
35   /* already signaled by WSI */
36   VN_SYNC_TYPE_WSI_SIGNALED,
37};
38
39struct vn_sync_payload {
40   enum vn_sync_type type;
41};
42
43struct vn_fence {
44   struct vn_object_base base;
45
46   struct vn_sync_payload *payload;
47
48   struct vn_sync_payload permanent;
49   struct vn_sync_payload temporary;
50};
51VK_DEFINE_NONDISP_HANDLE_CASTS(vn_fence,
52                               base.base,
53                               VkFence,
54                               VK_OBJECT_TYPE_FENCE)
55
56struct vn_semaphore {
57   struct vn_object_base base;
58
59   VkSemaphoreType type;
60
61   struct vn_sync_payload *payload;
62
63   struct vn_sync_payload permanent;
64   struct vn_sync_payload temporary;
65};
66VK_DEFINE_NONDISP_HANDLE_CASTS(vn_semaphore,
67                               base.base,
68                               VkSemaphore,
69                               VK_OBJECT_TYPE_SEMAPHORE)
70
71struct vn_event {
72   struct vn_object_base base;
73};
74VK_DEFINE_NONDISP_HANDLE_CASTS(vn_event,
75                               base.base,
76                               VkEvent,
77                               VK_OBJECT_TYPE_EVENT)
78
79void
80vn_fence_signal_wsi(struct vn_device *dev, struct vn_fence *fence);
81
82void
83vn_semaphore_signal_wsi(struct vn_device *dev, struct vn_semaphore *sem);
84
85#endif /* VN_QUEUE_H */
86