radv: Store queue family in command buffers.
authorDave Airlie <airlied@redhat.com>
Thu, 1 Dec 2016 00:05:29 +0000 (00:05 +0000)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Sun, 18 Dec 2016 19:52:15 +0000 (20:52 +0100)
v2: Added helper (Bas)

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_cmd_buffer.c
src/amd/vulkan/radv_private.h

index 8e99fc0be9eaa9a6fc38dce4f3b49df6c4e3f6ba..798dd6aa17183886bd3063ac157d1d5c3abb1e27 100644 (file)
@@ -110,6 +110,25 @@ radv_dynamic_state_copy(struct radv_dynamic_state *dest,
                dest->stencil_reference = src->stencil_reference;
 }
 
+bool radv_cmd_buffer_uses_mec(struct radv_cmd_buffer *cmd_buffer)
+{
+       return cmd_buffer->queue_family_index == RADV_QUEUE_COMPUTE &&
+              cmd_buffer->device->instance->physicalDevice.rad_info.chip_class >= CIK;
+}
+
+enum ring_type radv_queue_family_to_ring(int f) {
+       switch (f) {
+       case RADV_QUEUE_GENERAL:
+               return RING_GFX;
+       case RADV_QUEUE_COMPUTE:
+               return RING_COMPUTE;
+       case RADV_QUEUE_TRANSFER:
+               return RING_DMA;
+       default:
+               unreachable("Unknown queue family");
+       }
+}
+
 static VkResult radv_create_cmd_buffer(
        struct radv_device *                         device,
        struct radv_cmd_pool *                       pool,
@@ -118,7 +137,7 @@ static VkResult radv_create_cmd_buffer(
 {
        struct radv_cmd_buffer *cmd_buffer;
        VkResult result;
-
+       unsigned ring;
        cmd_buffer = vk_alloc(&pool->alloc, sizeof(*cmd_buffer), 8,
                                VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
        if (cmd_buffer == NULL)
@@ -132,14 +151,19 @@ static VkResult radv_create_cmd_buffer(
 
        if (pool) {
                list_addtail(&cmd_buffer->pool_link, &pool->cmd_buffers);
+               cmd_buffer->queue_family_index = pool->queue_family_index;
+
        } else {
                /* Init the pool_link so we can safefly call list_del when we destroy
                 * the command buffer
                 */
                list_inithead(&cmd_buffer->pool_link);
+               cmd_buffer->queue_family_index = RADV_QUEUE_GENERAL;
        }
 
-       cmd_buffer->cs = device->ws->cs_create(device->ws, RING_GFX);
+       ring = radv_queue_family_to_ring(cmd_buffer->queue_family_index);
+
+       cmd_buffer->cs = device->ws->cs_create(device->ws, ring);
        if (!cmd_buffer->cs) {
                result = VK_ERROR_OUT_OF_HOST_MEMORY;
                goto fail;
@@ -1775,6 +1799,8 @@ VkResult radv_CreateCommandPool(
 
        list_inithead(&pool->cmd_buffers);
 
+       pool->queue_family_index = pCreateInfo->queueFamilyIndex;
+
        *pCmdPool = radv_cmd_pool_to_handle(pool);
 
        return VK_SUCCESS;
index aa5b477c19263f88d0819aa55d28f4badd0e5201..e58053b1be2333ad094436ca5bcdf5d64570dabd 100644 (file)
@@ -441,6 +441,8 @@ struct radv_meta_state {
 
 #define RADV_MAX_QUEUE_FAMILIES 3
 
+enum ring_type radv_queue_family_to_ring(int f);
+
 struct radv_queue {
        VK_LOADER_DATA                              _loader_data;
        struct radv_device *                         device;
@@ -666,9 +668,11 @@ struct radv_cmd_state {
        float                                        offset_scale;
        uint32_t                                      descriptors_dirty;
 };
+
 struct radv_cmd_pool {
        VkAllocationCallbacks                        alloc;
        struct list_head                             cmd_buffers;
+       uint32_t queue_family_index;
 };
 
 struct radv_cmd_buffer_upload {
@@ -691,6 +695,7 @@ struct radv_cmd_buffer {
        VkCommandBufferLevel                         level;
        struct radeon_winsys_cs *cs;
        struct radv_cmd_state state;
+       uint32_t queue_family_index;
 
        uint8_t push_constants[MAX_PUSH_CONSTANTS_SIZE];
        uint32_t dynamic_buffers[16 * MAX_DYNAMIC_BUFFERS];
@@ -703,6 +708,8 @@ struct radv_cmd_buffer {
 
 struct radv_image;
 
+bool radv_cmd_buffer_uses_mec(struct radv_cmd_buffer *cmd_buffer);
+
 void si_init_config(struct radv_physical_device *physical_device,
                    struct radv_cmd_buffer *cmd_buffer);
 void si_write_viewport(struct radeon_winsys_cs *cs, int first_vp,