Chia-I Wu | e09b536 | 2014-08-07 09:25:14 +0800 | [diff] [blame] | 1 | /* |
| 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 | |
Chia-I Wu | 9ae59c1 | 2014-08-07 10:08:49 +0800 | [diff] [blame] | 29 | XGL_RESULT intel_queue_create(struct intel_dev *dev, |
| 30 | XGL_QUEUE_TYPE type, |
| 31 | struct intel_queue **queue_ret) |
Chia-I Wu | e09b536 | 2014-08-07 09:25:14 +0800 | [diff] [blame] | 32 | { |
| 33 | struct intel_queue *queue; |
| 34 | |
Courtney Goeltzenleuchter | fb4fb53 | 2014-08-14 09:35:21 -0600 | [diff] [blame] | 35 | queue = (struct intel_queue *) intel_base_create(dev, sizeof(*queue), |
Chia-I Wu | bbf2c93 | 2014-08-07 12:20:08 +0800 | [diff] [blame] | 36 | dev->base.dbg, XGL_DBG_OBJECT_QUEUE, NULL, 0); |
Chia-I Wu | e09b536 | 2014-08-07 09:25:14 +0800 | [diff] [blame] | 37 | if (!queue) |
Chia-I Wu | 9ae59c1 | 2014-08-07 10:08:49 +0800 | [diff] [blame] | 38 | return XGL_ERROR_OUT_OF_MEMORY; |
Chia-I Wu | e09b536 | 2014-08-07 09:25:14 +0800 | [diff] [blame] | 39 | |
Chia-I Wu | e09b536 | 2014-08-07 09:25:14 +0800 | [diff] [blame] | 40 | queue->dev = dev; |
| 41 | |
Chia-I Wu | 9ae59c1 | 2014-08-07 10:08:49 +0800 | [diff] [blame] | 42 | *queue_ret = queue; |
| 43 | |
| 44 | return XGL_SUCCESS; |
Chia-I Wu | e09b536 | 2014-08-07 09:25:14 +0800 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | void intel_queue_destroy(struct intel_queue *queue) |
| 48 | { |
Chia-I Wu | bbf2c93 | 2014-08-07 12:20:08 +0800 | [diff] [blame] | 49 | intel_base_destroy(&queue->base); |
Chia-I Wu | e09b536 | 2014-08-07 09:25:14 +0800 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | XGL_RESULT intel_queue_wait(struct intel_queue *queue, int64_t timeout) |
| 53 | { |
| 54 | struct intel_bo *bo = queue->last_submitted_bo; |
| 55 | |
| 56 | return (!bo || intel_bo_wait(bo, timeout) == 0) ? |
| 57 | XGL_SUCCESS : XGL_ERROR_UNKNOWN; |
| 58 | } |
| 59 | |
| 60 | XGL_RESULT XGLAPI intelQueueSetGlobalMemReferences( |
| 61 | XGL_QUEUE queue, |
| 62 | XGL_UINT memRefCount, |
| 63 | const XGL_MEMORY_REF* pMemRefs) |
| 64 | { |
| 65 | /* |
| 66 | * The winwys maintains the list of memory references. These are ignored |
| 67 | * until we move away from the winsys. |
| 68 | */ |
| 69 | return XGL_SUCCESS; |
| 70 | } |
| 71 | |
| 72 | XGL_RESULT XGLAPI intelQueueWaitIdle( |
| 73 | XGL_QUEUE queue_) |
| 74 | { |
| 75 | struct intel_queue *queue = intel_queue(queue_); |
| 76 | |
| 77 | return intel_queue_wait(queue, -1); |
| 78 | } |
Chia-I Wu | 251e7d9 | 2014-08-19 13:35:42 +0800 | [diff] [blame^] | 79 | |
| 80 | XGL_RESULT XGLAPI intelQueueSubmit( |
| 81 | XGL_QUEUE queue, |
| 82 | XGL_UINT cmdBufferCount, |
| 83 | const XGL_CMD_BUFFER* pCmdBuffers, |
| 84 | XGL_UINT memRefCount, |
| 85 | const XGL_MEMORY_REF* pMemRefs, |
| 86 | XGL_FENCE fence) |
| 87 | { |
| 88 | /* need XGL_CMD_BUFFER first */ |
| 89 | return XGL_ERROR_UNAVAILABLE; |
| 90 | } |
| 91 | |
| 92 | XGL_RESULT XGLAPI intelOpenSharedQueueSemaphore( |
| 93 | XGL_DEVICE device, |
| 94 | const XGL_QUEUE_SEMAPHORE_OPEN_INFO* pOpenInfo, |
| 95 | XGL_QUEUE_SEMAPHORE* pSemaphore) |
| 96 | { |
| 97 | return XGL_ERROR_UNAVAILABLE; |
| 98 | } |
| 99 | |
| 100 | XGL_RESULT XGLAPI intelCreateQueueSemaphore( |
| 101 | XGL_DEVICE device, |
| 102 | const XGL_QUEUE_SEMAPHORE_CREATE_INFO* pCreateInfo, |
| 103 | XGL_QUEUE_SEMAPHORE* pSemaphore) |
| 104 | { |
| 105 | /* |
| 106 | * We want to find an unused semaphore register and initialize it. Signal |
| 107 | * will increment the register. Wait will atomically decrement it and |
| 108 | * block if the value is zero, or a large constant N if we do not want to |
| 109 | * go negative. |
| 110 | * |
| 111 | * XXX However, MI_SEMAPHORE_MBOX does not seem to have the flexibility. |
| 112 | */ |
| 113 | return XGL_ERROR_UNAVAILABLE; |
| 114 | } |
| 115 | |
| 116 | XGL_RESULT XGLAPI intelSignalQueueSemaphore( |
| 117 | XGL_QUEUE queue, |
| 118 | XGL_QUEUE_SEMAPHORE semaphore) |
| 119 | { |
| 120 | return XGL_ERROR_UNAVAILABLE; |
| 121 | } |
| 122 | |
| 123 | XGL_RESULT XGLAPI intelWaitQueueSemaphore( |
| 124 | XGL_QUEUE queue, |
| 125 | XGL_QUEUE_SEMAPHORE semaphore) |
| 126 | { |
| 127 | return XGL_ERROR_UNAVAILABLE; |
| 128 | } |