diff --git a/src/asahi/vulkan/hk_device.c b/src/asahi/vulkan/hk_device.c index c4e28789be1..66a22934bb2 100644 --- a/src/asahi/vulkan/hk_device.c +++ b/src/asahi/vulkan/hk_device.c @@ -388,10 +388,14 @@ hk_CreateDevice(VkPhysicalDevice physicalDevice, if (result != VK_SUCCESS) goto fail_internal_shaders; - result = - hk_queue_init(dev, &dev->queue, &pCreateInfo->pQueueCreateInfos[0], 0); - if (result != VK_SUCCESS) - goto fail_internal_shaders_2; + for (unsigned i = 0; i < pCreateInfo->queueCreateInfoCount; i++) { + for (unsigned q = 0; q < pCreateInfo->pQueueCreateInfos[i].queueCount; + q++) { + result = hk_queue_init(dev, &pCreateInfo->pQueueCreateInfos[i], q); + if (result != VK_SUCCESS) + goto fail_queues; + } + } struct vk_pipeline_cache_create_info cache_info = { .weak_ref = true, @@ -399,7 +403,7 @@ hk_CreateDevice(VkPhysicalDevice physicalDevice, dev->mem_cache = vk_pipeline_cache_create(&dev->vk, &cache_info, NULL); if (dev->mem_cache == NULL) { result = VK_ERROR_OUT_OF_HOST_MEMORY; - goto fail_queue; + goto fail_queues; } result = hk_device_init_meta(dev); @@ -440,16 +444,18 @@ fail_meta: hk_device_finish_meta(dev); fail_mem_cache: vk_pipeline_cache_destroy(dev->mem_cache, NULL); -fail_queue: - hk_queue_finish(dev, &dev->queue); -fail_rodata: - agx_bo_unreference(&dev->dev, dev->rodata.bo); -fail_bg_eot: - agx_bg_eot_cleanup(&dev->bg_eot); -fail_internal_shaders_2: +fail_queues: + vk_foreach_queue_safe(iter, &dev->vk) { + struct hk_queue *queue = container_of(iter, struct hk_queue, vk); + hk_queue_finish(dev, queue); + } hk_destroy_internal_shaders(dev, &dev->kernels, false); fail_internal_shaders: hk_destroy_internal_shaders(dev, &dev->prolog_epilog, true); +fail_bg_eot: + agx_bg_eot_cleanup(&dev->bg_eot); +fail_rodata: + agx_bo_unreference(&dev->dev, dev->rodata.bo); fail_queries: hk_descriptor_table_finish(dev, &dev->occlusion_queries); fail_samplers: @@ -482,7 +488,12 @@ hk_DestroyDevice(VkDevice _device, const VkAllocationCallbacks *pAllocator) hk_destroy_internal_shaders(dev, &dev->prolog_epilog, true); vk_pipeline_cache_destroy(dev->mem_cache, NULL); - hk_queue_finish(dev, &dev->queue); + + vk_foreach_queue_safe(iter, &dev->vk) { + struct hk_queue *queue = container_of(iter, struct hk_queue, vk); + hk_queue_finish(dev, queue); + } + vk_device_finish(&dev->vk); agx_scratch_fini(&dev->scratch.vs); diff --git a/src/asahi/vulkan/hk_device.h b/src/asahi/vulkan/hk_device.h index 29ecb74bea4..c91ac744c1d 100644 --- a/src/asahi/vulkan/hk_device.h +++ b/src/asahi/vulkan/hk_device.h @@ -69,8 +69,6 @@ struct hk_device { struct hk_descriptor_table occlusion_queries; struct hk_sampler_heap samplers; - struct hk_queue queue; - struct vk_pipeline_cache *mem_cache; struct vk_meta_device meta; diff --git a/src/asahi/vulkan/hk_queue.c b/src/asahi/vulkan/hk_queue.c index f1cecefd7a1..6cfffe81254 100644 --- a/src/asahi/vulkan/hk_queue.c +++ b/src/asahi/vulkan/hk_queue.c @@ -943,8 +943,7 @@ translate_priority(VkQueueGlobalPriorityKHR prio) } VkResult -hk_queue_init(struct hk_device *dev, struct hk_queue *queue, - const VkDeviceQueueCreateInfo *pCreateInfo, +hk_queue_init(struct hk_device *dev, const VkDeviceQueueCreateInfo *pCreateInfo, uint32_t index_in_family) { struct hk_physical_device *pdev = hk_device_physical(dev); @@ -952,6 +951,11 @@ hk_queue_init(struct hk_device *dev, struct hk_queue *queue, assert(pCreateInfo->queueFamilyIndex < pdev->queue_family_count); + struct hk_queue *queue = vk_zalloc(&dev->vk.alloc, sizeof(struct hk_queue), + 8, VK_SYSTEM_ALLOCATION_SCOPE_DEVICE); + if (!queue) + return VK_ERROR_OUT_OF_HOST_MEMORY; + const VkDeviceQueueGlobalPriorityCreateInfoKHR *priority_info = vk_find_struct_const(pCreateInfo->pNext, DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_KHR); @@ -1002,4 +1006,5 @@ hk_queue_finish(struct hk_device *dev, struct hk_queue *queue) drmSyncobjDestroy(dev->dev.fd, queue->drm.syncobj); agx_destroy_command_queue(&dev->dev, queue->drm.id); vk_queue_finish(&queue->vk); + vk_free(&dev->vk.alloc, queue); } diff --git a/src/asahi/vulkan/hk_queue.h b/src/asahi/vulkan/hk_queue.h index f45c8ed92e0..16338e8b416 100644 --- a/src/asahi/vulkan/hk_queue.h +++ b/src/asahi/vulkan/hk_queue.h @@ -38,7 +38,7 @@ hk_queue_device(struct hk_queue *queue) return (struct hk_device *)queue->vk.base.device; } -VkResult hk_queue_init(struct hk_device *dev, struct hk_queue *queue, +VkResult hk_queue_init(struct hk_device *dev, const VkDeviceQueueCreateInfo *pCreateInfo, uint32_t index_in_family);