1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Copyright 2019 Google LLC
3bf215546Sopenharmony_ci * SPDX-License-Identifier: MIT
4bf215546Sopenharmony_ci *
5bf215546Sopenharmony_ci * based in part on anv and radv which are:
6bf215546Sopenharmony_ci * Copyright © 2015 Intel Corporation
7bf215546Sopenharmony_ci * Copyright © 2016 Red Hat.
8bf215546Sopenharmony_ci * Copyright © 2016 Bas Nieuwenhuizen
9bf215546Sopenharmony_ci */
10bf215546Sopenharmony_ci
11bf215546Sopenharmony_ci#ifndef VN_QUEUE_H
12bf215546Sopenharmony_ci#define VN_QUEUE_H
13bf215546Sopenharmony_ci
14bf215546Sopenharmony_ci#include "vn_common.h"
15bf215546Sopenharmony_ci
16bf215546Sopenharmony_ci#include "vn_feedback.h"
17bf215546Sopenharmony_ci
18bf215546Sopenharmony_cistruct vn_queue {
19bf215546Sopenharmony_ci   struct vn_object_base base;
20bf215546Sopenharmony_ci
21bf215546Sopenharmony_ci   struct vn_device *device;
22bf215546Sopenharmony_ci   uint32_t family;
23bf215546Sopenharmony_ci   uint32_t index;
24bf215546Sopenharmony_ci   uint32_t flags;
25bf215546Sopenharmony_ci
26bf215546Sopenharmony_ci   VkFence wait_fence;
27bf215546Sopenharmony_ci};
28bf215546Sopenharmony_ciVK_DEFINE_HANDLE_CASTS(vn_queue, base.base, VkQueue, VK_OBJECT_TYPE_QUEUE)
29bf215546Sopenharmony_ci
30bf215546Sopenharmony_cienum vn_sync_type {
31bf215546Sopenharmony_ci   /* no payload */
32bf215546Sopenharmony_ci   VN_SYNC_TYPE_INVALID,
33bf215546Sopenharmony_ci
34bf215546Sopenharmony_ci   /* device object */
35bf215546Sopenharmony_ci   VN_SYNC_TYPE_DEVICE_ONLY,
36bf215546Sopenharmony_ci
37bf215546Sopenharmony_ci   /* already signaled by WSI */
38bf215546Sopenharmony_ci   VN_SYNC_TYPE_WSI_SIGNALED,
39bf215546Sopenharmony_ci};
40bf215546Sopenharmony_ci
41bf215546Sopenharmony_cistruct vn_sync_payload {
42bf215546Sopenharmony_ci   enum vn_sync_type type;
43bf215546Sopenharmony_ci};
44bf215546Sopenharmony_ci
45bf215546Sopenharmony_cistruct vn_fence {
46bf215546Sopenharmony_ci   struct vn_object_base base;
47bf215546Sopenharmony_ci
48bf215546Sopenharmony_ci   struct vn_sync_payload *payload;
49bf215546Sopenharmony_ci
50bf215546Sopenharmony_ci   struct vn_sync_payload permanent;
51bf215546Sopenharmony_ci   struct vn_sync_payload temporary;
52bf215546Sopenharmony_ci
53bf215546Sopenharmony_ci   struct {
54bf215546Sopenharmony_ci      /* non-NULL if VN_PERF_NO_FENCE_FEEDBACK is disabled */
55bf215546Sopenharmony_ci      struct vn_feedback_slot *slot;
56bf215546Sopenharmony_ci      VkCommandBuffer *commands;
57bf215546Sopenharmony_ci   } feedback;
58bf215546Sopenharmony_ci
59bf215546Sopenharmony_ci   bool is_external;
60bf215546Sopenharmony_ci};
61bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(vn_fence,
62bf215546Sopenharmony_ci                               base.base,
63bf215546Sopenharmony_ci                               VkFence,
64bf215546Sopenharmony_ci                               VK_OBJECT_TYPE_FENCE)
65bf215546Sopenharmony_ci
66bf215546Sopenharmony_cistruct vn_semaphore {
67bf215546Sopenharmony_ci   struct vn_object_base base;
68bf215546Sopenharmony_ci
69bf215546Sopenharmony_ci   VkSemaphoreType type;
70bf215546Sopenharmony_ci
71bf215546Sopenharmony_ci   struct vn_sync_payload *payload;
72bf215546Sopenharmony_ci
73bf215546Sopenharmony_ci   struct vn_sync_payload permanent;
74bf215546Sopenharmony_ci   struct vn_sync_payload temporary;
75bf215546Sopenharmony_ci};
76bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(vn_semaphore,
77bf215546Sopenharmony_ci                               base.base,
78bf215546Sopenharmony_ci                               VkSemaphore,
79bf215546Sopenharmony_ci                               VK_OBJECT_TYPE_SEMAPHORE)
80bf215546Sopenharmony_ci
81bf215546Sopenharmony_cistruct vn_event {
82bf215546Sopenharmony_ci   struct vn_object_base base;
83bf215546Sopenharmony_ci
84bf215546Sopenharmony_ci   /* non-NULL if below are satisfied:
85bf215546Sopenharmony_ci    * - event is created without VK_EVENT_CREATE_DEVICE_ONLY_BIT
86bf215546Sopenharmony_ci    * - VN_PERF_NO_EVENT_FEEDBACK is disabled
87bf215546Sopenharmony_ci    */
88bf215546Sopenharmony_ci   struct vn_feedback_slot *feedback_slot;
89bf215546Sopenharmony_ci};
90bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(vn_event,
91bf215546Sopenharmony_ci                               base.base,
92bf215546Sopenharmony_ci                               VkEvent,
93bf215546Sopenharmony_ci                               VK_OBJECT_TYPE_EVENT)
94bf215546Sopenharmony_ci
95bf215546Sopenharmony_civoid
96bf215546Sopenharmony_civn_fence_signal_wsi(struct vn_device *dev, struct vn_fence *fence);
97bf215546Sopenharmony_ci
98bf215546Sopenharmony_civoid
99bf215546Sopenharmony_civn_semaphore_signal_wsi(struct vn_device *dev, struct vn_semaphore *sem);
100bf215546Sopenharmony_ci
101bf215546Sopenharmony_ci#endif /* VN_QUEUE_H */
102