blob: 04bdaf763845c3778a0e6d9851a876a04e8bbcb5 [file] [log] [blame]
Chia-I Wue09b5362014-08-07 09:25:14 +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.
23 */
24
25#include "kmd/winsys.h"
Chia-I Wu34f45182014-08-19 14:02:59 +080026#include "cmd.h"
Chia-I Wue09b5362014-08-07 09:25:14 +080027#include "dev.h"
28#include "queue.h"
29
Chia-I Wu9ae59c12014-08-07 10:08:49 +080030XGL_RESULT intel_queue_create(struct intel_dev *dev,
31 XGL_QUEUE_TYPE type,
32 struct intel_queue **queue_ret)
Chia-I Wue09b5362014-08-07 09:25:14 +080033{
34 struct intel_queue *queue;
35
Courtney Goeltzenleuchterfb4fb532014-08-14 09:35:21 -060036 queue = (struct intel_queue *) intel_base_create(dev, sizeof(*queue),
Chia-I Wubbf2c932014-08-07 12:20:08 +080037 dev->base.dbg, XGL_DBG_OBJECT_QUEUE, NULL, 0);
Chia-I Wue09b5362014-08-07 09:25:14 +080038 if (!queue)
Chia-I Wu9ae59c12014-08-07 10:08:49 +080039 return XGL_ERROR_OUT_OF_MEMORY;
Chia-I Wue09b5362014-08-07 09:25:14 +080040
Chia-I Wue09b5362014-08-07 09:25:14 +080041 queue->dev = dev;
42
Chia-I Wu9ae59c12014-08-07 10:08:49 +080043 *queue_ret = queue;
44
45 return XGL_SUCCESS;
Chia-I Wue09b5362014-08-07 09:25:14 +080046}
47
48void intel_queue_destroy(struct intel_queue *queue)
49{
Chia-I Wubbf2c932014-08-07 12:20:08 +080050 intel_base_destroy(&queue->base);
Chia-I Wue09b5362014-08-07 09:25:14 +080051}
52
53XGL_RESULT intel_queue_wait(struct intel_queue *queue, int64_t timeout)
54{
Chia-I Wu34f45182014-08-19 14:02:59 +080055 struct intel_cmd *cmd = queue->last_submitted_cmd;
Chia-I Wue09b5362014-08-07 09:25:14 +080056
Chia-I Wu34f45182014-08-19 14:02:59 +080057 return (!cmd || intel_bo_wait(cmd->bo, timeout) == 0) ?
Chia-I Wue09b5362014-08-07 09:25:14 +080058 XGL_SUCCESS : XGL_ERROR_UNKNOWN;
59}
60
61XGL_RESULT XGLAPI intelQueueSetGlobalMemReferences(
62 XGL_QUEUE queue,
63 XGL_UINT memRefCount,
64 const XGL_MEMORY_REF* pMemRefs)
65{
66 /*
67 * The winwys maintains the list of memory references. These are ignored
68 * until we move away from the winsys.
69 */
70 return XGL_SUCCESS;
71}
72
73XGL_RESULT XGLAPI intelQueueWaitIdle(
74 XGL_QUEUE queue_)
75{
76 struct intel_queue *queue = intel_queue(queue_);
77
78 return intel_queue_wait(queue, -1);
79}
Chia-I Wu251e7d92014-08-19 13:35:42 +080080
81XGL_RESULT XGLAPI intelQueueSubmit(
82 XGL_QUEUE queue,
83 XGL_UINT cmdBufferCount,
84 const XGL_CMD_BUFFER* pCmdBuffers,
85 XGL_UINT memRefCount,
86 const XGL_MEMORY_REF* pMemRefs,
87 XGL_FENCE fence)
88{
89 /* need XGL_CMD_BUFFER first */
90 return XGL_ERROR_UNAVAILABLE;
91}
92
93XGL_RESULT XGLAPI intelOpenSharedQueueSemaphore(
94 XGL_DEVICE device,
95 const XGL_QUEUE_SEMAPHORE_OPEN_INFO* pOpenInfo,
96 XGL_QUEUE_SEMAPHORE* pSemaphore)
97{
98 return XGL_ERROR_UNAVAILABLE;
99}
100
101XGL_RESULT XGLAPI intelCreateQueueSemaphore(
102 XGL_DEVICE device,
103 const XGL_QUEUE_SEMAPHORE_CREATE_INFO* pCreateInfo,
104 XGL_QUEUE_SEMAPHORE* pSemaphore)
105{
106 /*
107 * We want to find an unused semaphore register and initialize it. Signal
108 * will increment the register. Wait will atomically decrement it and
109 * block if the value is zero, or a large constant N if we do not want to
110 * go negative.
111 *
112 * XXX However, MI_SEMAPHORE_MBOX does not seem to have the flexibility.
113 */
114 return XGL_ERROR_UNAVAILABLE;
115}
116
117XGL_RESULT XGLAPI intelSignalQueueSemaphore(
118 XGL_QUEUE queue,
119 XGL_QUEUE_SEMAPHORE semaphore)
120{
121 return XGL_ERROR_UNAVAILABLE;
122}
123
124XGL_RESULT XGLAPI intelWaitQueueSemaphore(
125 XGL_QUEUE queue,
126 XGL_QUEUE_SEMAPHORE semaphore)
127{
128 return XGL_ERROR_UNAVAILABLE;
129}