Home | History | Annotate | Line # | Download | only in util
      1 /*
      2  * Copyright  2021 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 #include "vk_queue.h"
     25 
     26 #include "vk_device.h"
     27 
     28 VkResult
     29 vk_queue_init(struct vk_queue *queue, struct vk_device *device,
     30               const VkDeviceQueueCreateInfo *pCreateInfo,
     31               uint32_t index_in_family)
     32 {
     33    memset(queue, 0, sizeof(*queue));
     34    vk_object_base_init(device, &queue->base, VK_OBJECT_TYPE_QUEUE);
     35 
     36    list_addtail(&queue->link, &device->queues);
     37 
     38    queue->flags = pCreateInfo->flags;
     39    queue->queue_family_index = pCreateInfo->queueFamilyIndex;
     40 
     41    assert(index_in_family < pCreateInfo->queueCount);
     42    queue->index_in_family = index_in_family;
     43 
     44    util_dynarray_init(&queue->labels, NULL);
     45    queue->region_begin = true;
     46 
     47    return VK_SUCCESS;
     48 }
     49 
     50 void
     51 vk_queue_finish(struct vk_queue *queue)
     52 {
     53    util_dynarray_fini(&queue->labels);
     54    list_del(&queue->link);
     55    vk_object_base_finish(&queue->base);
     56 }
     57