blob: a284d562c4d1de3328ffb977b55a3b3d572e45e6 [file] [log] [blame]
Chia-I Wubdf4c562014-08-07 06:36:33 +08001/*
2 * XGL
3 *
4 * Copyright (C) 2014 LunarG, Inc.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
Chia-I Wu44e42362014-09-02 08:32:09 +080023 *
24 * Authors:
25 * Chia-I Wu <olv@lunarg.com>
Chia-I Wubdf4c562014-08-07 06:36:33 +080026 */
27
28#ifndef FENCE_H
29#define FENCE_H
30
31#include "intel.h"
32#include "obj.h"
33
Chia-I Wu34f45182014-08-19 14:02:59 +080034struct intel_cmd;
Chia-I Wubdf4c562014-08-07 06:36:33 +080035struct intel_dev;
Chia-I Wu1db76e02014-09-15 14:21:14 +080036struct intel_wsi_x11;
Chia-I Wubdf4c562014-08-07 06:36:33 +080037
38struct intel_fence {
39 struct intel_obj obj;
40
Chia-I Wu34f45182014-08-19 14:02:59 +080041 struct intel_cmd *cmd;
Chia-I Wu1db76e02014-09-15 14:21:14 +080042
43#ifdef ENABLE_WSI_X11
44 struct intel_wsi_x11 *x11;
45 uint32_t x11_serial;
46#endif
Chia-I Wubdf4c562014-08-07 06:36:33 +080047};
48
49static inline struct intel_fence *intel_fence(XGL_FENCE fence)
50{
51 return (struct intel_fence *) fence;
52}
53
54static inline struct intel_fence *intel_fence_from_obj(struct intel_obj *obj)
55{
56 return (struct intel_fence *) obj;
57}
58
59XGL_RESULT intel_fence_create(struct intel_dev *dev,
60 const XGL_FENCE_CREATE_INFO *info,
61 struct intel_fence **fence_ret);
62void intel_fence_destroy(struct intel_fence *fence);
63
Chia-I Wubdf4c562014-08-07 06:36:33 +080064XGL_RESULT intel_fence_wait(struct intel_fence *fence, int64_t timeout_ns);
65
Chia-I Wuc5438c22014-08-19 14:03:06 +080066static inline void intel_fence_set_cmd(struct intel_fence *fence,
67 struct intel_cmd *cmd)
68{
Chia-I Wu1db76e02014-09-15 14:21:14 +080069#ifdef ENABLE_WSI_X11
70 fence->x11 = NULL;
71#endif
72
Chia-I Wuc5438c22014-08-19 14:03:06 +080073 fence->cmd = cmd;
74}
75
Chia-I Wu1db76e02014-09-15 14:21:14 +080076static inline void intel_fence_set_x11(struct intel_fence *fence,
77 struct intel_wsi_x11 *x11,
78 uint32_t serial)
79{
80 fence->cmd = NULL;
81
82#ifdef ENABLE_WSI_X11
83 fence->x11 = x11;
84 fence->x11_serial = serial;
85#endif
86}
87
Chia-I Wubdf4c562014-08-07 06:36:33 +080088XGL_RESULT XGLAPI intelCreateFence(
89 XGL_DEVICE device,
90 const XGL_FENCE_CREATE_INFO* pCreateInfo,
91 XGL_FENCE* pFence);
92
93XGL_RESULT XGLAPI intelGetFenceStatus(
94 XGL_FENCE fence);
95
96XGL_RESULT XGLAPI intelWaitForFences(
97 XGL_DEVICE device,
98 XGL_UINT fenceCount,
99 const XGL_FENCE* pFences,
100 XGL_BOOL waitAll,
101 XGL_UINT64 timeout);
102
103#endif /* FENCE_H */