diff options
author | Dave Airlie <airlied@redhat.com> | 2016-11-30 04:30:06 +0000 |
---|---|---|
committer | Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl> | 2016-12-18 20:52:15 +0100 |
commit | c20701f4be953658cd000d6e075200ba9b26f814 (patch) | |
tree | 235e6d56d833dda64b55fdb10b8d2991d2af802d | |
parent | 59c9a131f480f005fdd8f2ebf8e07a500e23ee20 (diff) |
radv: start fixing up queue allocate for multiple queues
v2: Fix error handling and zero init the device (Bas)
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
-rw-r--r-- | src/amd/vulkan/radv_device.c | 52 | ||||
-rw-r--r-- | src/amd/vulkan/radv_private.h | 16 |
2 files changed, 53 insertions, 15 deletions
diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index c1438feb85..0cac5bc989 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -619,10 +619,13 @@ void radv_GetPhysicalDeviceMemoryProperties( } static void -radv_queue_init(struct radv_device *device, struct radv_queue *queue) +radv_queue_init(struct radv_device *device, struct radv_queue *queue, + int queue_family_index, int idx) { queue->_loader_data.loaderMagic = ICD_LOADER_MAGIC; queue->device = device; + queue->queue_family_index = queue_family_index; + queue->queue_idx = idx; } static void @@ -659,6 +662,8 @@ VkResult radv_CreateDevice( if (!device) return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); + memset(device, 0, sizeof(*device)); + device->_loader_data.loaderMagic = ICD_LOADER_MAGIC; device->instance = physical_device->instance; device->shader_stats_dump = false; @@ -669,18 +674,33 @@ VkResult radv_CreateDevice( else device->alloc = physical_device->instance->alloc; + for (unsigned i = 0; i < pCreateInfo->queueCreateInfoCount; i++) { + const VkDeviceQueueCreateInfo *queue_create = &pCreateInfo->pQueueCreateInfos[i]; + uint32_t qfi = queue_create->queueFamilyIndex; + + device->queues[qfi] = vk_alloc(&device->alloc, + queue_create->queueCount * sizeof(struct radv_queue), 8, VK_SYSTEM_ALLOCATION_SCOPE_DEVICE); + if (!device->queues[qfi]) { + result = VK_ERROR_OUT_OF_HOST_MEMORY; + goto fail; + } + + device->queue_count[qfi] = queue_create->queueCount; + + for (unsigned q = 0; q < queue_create->queueCount; q++) + radv_queue_init(device, &device->queues[qfi][q], qfi, q); + } + device->hw_ctx = device->ws->ctx_create(device->ws); if (!device->hw_ctx) { result = VK_ERROR_OUT_OF_HOST_MEMORY; - goto fail_free; + goto fail; } - radv_queue_init(device, &device->queue); - result = radv_device_init_meta(device); if (result != VK_SUCCESS) { device->ws->ctx_destroy(device->hw_ctx); - goto fail_free; + goto fail; } device->allow_fast_clears = env_var_as_boolean("RADV_FAST_CLEARS", false); device->allow_dcc = !env_var_as_boolean("RADV_DCC_DISABLE", false); @@ -697,7 +717,14 @@ VkResult radv_CreateDevice( device->ws->cs_finalize(device->empty_cs); *pDevice = radv_device_to_handle(device); return VK_SUCCESS; -fail_free: + +fail: + for (unsigned i = 0; i < RADV_MAX_QUEUE_FAMILIES; i++) { + for (unsigned q = 0; q < device->queue_count[i]; q++) + radv_queue_finish(&device->queues[i][q]); + if (device->queue_count[i]) + vk_free(&device->alloc, device->queues[i]); + } vk_free(&device->alloc, device); return result; } @@ -709,7 +736,12 @@ void radv_DestroyDevice( RADV_FROM_HANDLE(radv_device, device, _device); device->ws->ctx_destroy(device->hw_ctx); - radv_queue_finish(&device->queue); + for (unsigned i = 0; i < RADV_MAX_QUEUE_FAMILIES; i++) { + for (unsigned q = 0; q < device->queue_count[i]; q++) + radv_queue_finish(&device->queues[i][q]); + if (device->queue_count[i]) + vk_free(&device->alloc, device->queues[i]); + } radv_device_finish_meta(device); vk_free(&device->alloc, device); @@ -783,15 +815,13 @@ VkResult radv_EnumerateDeviceLayerProperties( void radv_GetDeviceQueue( VkDevice _device, - uint32_t queueNodeIndex, + uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue* pQueue) { RADV_FROM_HANDLE(radv_device, device, _device); - assert(queueIndex == 0); - - *pQueue = radv_queue_to_handle(&device->queue); + *pQueue = radv_queue_to_handle(&device->queues[queueFamilyIndex][queueIndex]); } VkResult radv_QueueSubmit( diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h index 3d4b111d25..aa5b477c19 100644 --- a/src/amd/vulkan/radv_private.h +++ b/src/amd/vulkan/radv_private.h @@ -434,12 +434,18 @@ struct radv_meta_state { } buffer; }; +/* queue types */ +#define RADV_QUEUE_GENERAL 0 +#define RADV_QUEUE_COMPUTE 1 +#define RADV_QUEUE_TRANSFER 2 + +#define RADV_MAX_QUEUE_FAMILIES 3 + struct radv_queue { VK_LOADER_DATA _loader_data; - struct radv_device * device; - - struct radv_state_pool * pool; + int queue_family_index; + int queue_idx; }; struct radv_device { @@ -452,7 +458,9 @@ struct radv_device { struct radeon_winsys_ctx *hw_ctx; struct radv_meta_state meta_state; - struct radv_queue queue; + + struct radv_queue *queues[RADV_MAX_QUEUE_FAMILIES]; + int queue_count[RADV_MAX_QUEUE_FAMILIES]; struct radeon_winsys_cs *empty_cs; bool allow_fast_clears; |