summaryrefslogtreecommitdiffstats
path: root/src/amd/vulkan/radv_device.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/amd/vulkan/radv_device.c')
-rw-r--r--src/amd/vulkan/radv_device.c52
1 files changed, 41 insertions, 11 deletions
diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index c1438feb852..0cac5bc9893 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(