1 /*
2 * Copyright © 2015 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 */
23
24 /**
25 * This file implements VkQueue
26 */
27
28 #include "anv_private.h"
29
30 VkResult
anv_queue_init(struct anv_device * device,struct anv_queue * queue,uint32_t exec_flags,const VkDeviceQueueCreateInfo * pCreateInfo,uint32_t index_in_family)31 anv_queue_init(struct anv_device *device, struct anv_queue *queue,
32 uint32_t exec_flags,
33 const VkDeviceQueueCreateInfo *pCreateInfo,
34 uint32_t index_in_family)
35 {
36 struct anv_physical_device *pdevice = device->physical;
37 VkResult result;
38
39 result = vk_queue_init(&queue->vk, &device->vk, pCreateInfo,
40 index_in_family);
41 if (result != VK_SUCCESS)
42 return result;
43
44 if (INTEL_DEBUG(DEBUG_SYNC)) {
45 result = vk_sync_create(&device->vk,
46 &device->physical->sync_syncobj_type,
47 0, 0, &queue->sync);
48 if (result != VK_SUCCESS) {
49 vk_queue_finish(&queue->vk);
50 return result;
51 }
52 }
53
54 queue->vk.driver_submit = anv_queue_submit;
55
56 queue->device = device;
57
58 assert(queue->vk.queue_family_index < pdevice->queue.family_count);
59 queue->family = &pdevice->queue.families[queue->vk.queue_family_index];
60 queue->exec_flags = exec_flags;
61
62 return VK_SUCCESS;
63 }
64
65 void
anv_queue_finish(struct anv_queue * queue)66 anv_queue_finish(struct anv_queue *queue)
67 {
68 if (queue->sync)
69 vk_sync_destroy(&queue->device->vk, queue->sync);
70
71 vk_queue_finish(&queue->vk);
72 }
73