blob: 4f37f655e3c27ad039dc0228b75a1cd736aaac30 [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"
26#include "dev.h"
27#include "queue.h"
28
29struct intel_queue *intel_queue_create(struct intel_dev *dev,
30 XGL_QUEUE_TYPE type)
31{
32 struct intel_queue *queue;
33
34 queue = icd_alloc(sizeof(*queue), 0, XGL_SYSTEM_ALLOC_API_OBJECT);
35 if (!queue)
36 return NULL;
37
38 memset(queue, 0, sizeof(*queue));
39 queue->dev = dev;
40
41 queue->base.dispatch = dev->base.dispatch;
42 if (dev->base.dbg) {
43 queue->base.dbg =
44 intel_base_dbg_create(XGL_DBG_OBJECT_QUEUE, NULL, 0);
45 if (!queue->base.dbg) {
46 icd_free(queue);
47 return NULL;
48 }
49 }
50
51 return queue;
52}
53
54void intel_queue_destroy(struct intel_queue *queue)
55{
56 if (queue->base.dbg)
57 intel_base_dbg_destroy(queue->base.dbg);
58 icd_free(queue);
59}
60
61XGL_RESULT intel_queue_wait(struct intel_queue *queue, int64_t timeout)
62{
63 struct intel_bo *bo = queue->last_submitted_bo;
64
65 return (!bo || intel_bo_wait(bo, timeout) == 0) ?
66 XGL_SUCCESS : XGL_ERROR_UNKNOWN;
67}
68
69XGL_RESULT XGLAPI intelQueueSetGlobalMemReferences(
70 XGL_QUEUE queue,
71 XGL_UINT memRefCount,
72 const XGL_MEMORY_REF* pMemRefs)
73{
74 /*
75 * The winwys maintains the list of memory references. These are ignored
76 * until we move away from the winsys.
77 */
78 return XGL_SUCCESS;
79}
80
81XGL_RESULT XGLAPI intelQueueWaitIdle(
82 XGL_QUEUE queue_)
83{
84 struct intel_queue *queue = intel_queue(queue_);
85
86 return intel_queue_wait(queue, -1);
87}