vk/0.210.0: Rework vkQueueSubmit
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 3 Dec 2015 01:18:41 +0000 (17:18 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 3 Dec 2015 21:44:02 +0000 (13:44 -0800)
include/vulkan/vulkan.h
src/vulkan/anv_device.c
src/vulkan/anv_dump.c

index 67ab34ddf23c5fe66b166b7009540bd7bfe5e3fe..a897a6efbc036b664d1087513411c99f16a1e643 100644 (file)
@@ -1377,6 +1377,17 @@ typedef struct VkLayerProperties {
     char                                        description[VK_MAX_DESCRIPTION_SIZE];
 } VkLayerProperties;
 
+typedef struct VkSubmitInfo {
+    VkStructureType                             sType;
+    const void*                                 pNext;
+    uint32_t                                    waitSemaphoreCount;
+    const VkSemaphore*                          pWaitSemaphores;
+    uint32_t                                    commandBufferCount;
+    const VkCommandBuffer*                      pCommandBuffers;
+    uint32_t                                    signalSemaphoreCount;
+    const VkSemaphore*                          pSignalSemaphores;
+} VkSubmitInfo;
+
 typedef struct VkMemoryAllocateInfo {
     VkStructureType                             sType;
     const void*                                 pNext;
@@ -2155,7 +2166,7 @@ typedef VkResult (VKAPI_PTR *PFN_vkEnumerateDeviceExtensionProperties)(VkPhysica
 typedef VkResult (VKAPI_PTR *PFN_vkEnumerateInstanceLayerProperties)(uint32_t* pPropertyCount, VkLayerProperties* pProperties);
 typedef VkResult (VKAPI_PTR *PFN_vkEnumerateDeviceLayerProperties)(VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount, VkLayerProperties* pProperties);
 typedef void (VKAPI_PTR *PFN_vkGetDeviceQueue)(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue* pQueue);
-typedef VkResult (VKAPI_PTR *PFN_vkQueueSubmit)(VkQueue queue, uint32_t commandBufferCount, const VkCommandBuffer* pCommandBuffers, VkFence fence);
+typedef VkResult (VKAPI_PTR *PFN_vkQueueSubmit)(VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmits, VkFence fence);
 typedef VkResult (VKAPI_PTR *PFN_vkQueueWaitIdle)(VkQueue queue);
 typedef VkResult (VKAPI_PTR *PFN_vkDeviceWaitIdle)(VkDevice device);
 typedef VkResult (VKAPI_PTR *PFN_vkAllocateMemory)(VkDevice device, const VkMemoryAllocateInfo* pAllocateInfo, const VkAllocationCallbacks* pAllocator, VkDeviceMemory* pMemory);
@@ -2367,8 +2378,8 @@ VKAPI_ATTR void VKAPI_CALL vkGetDeviceQueue(
 
 VKAPI_ATTR VkResult VKAPI_CALL vkQueueSubmit(
     VkQueue                                     queue,
-    uint32_t                                    commandBufferCount,
-    const VkCommandBuffer*                      pCommandBuffers,
+    uint32_t                                    submitCount,
+    const VkSubmitInfo*                         pSubmits,
     VkFence                                     fence);
 
 VKAPI_ATTR VkResult VKAPI_CALL vkQueueWaitIdle(
index 5b300afc0a80ca8c26bf4873576fbb135e034fca..e3b3541d2515ecfbd3495727ee9c5e15665a648a 100644 (file)
@@ -808,8 +808,8 @@ void anv_GetDeviceQueue(
 
 VkResult anv_QueueSubmit(
     VkQueue                                     _queue,
-    uint32_t                                    commandBufferCount,
-    const VkCommandBuffer*                      pCommandBuffers,
+    uint32_t                                    submitCount,
+    const VkSubmitInfo*                         pSubmits,
     VkFence                                     _fence)
 {
    ANV_FROM_HANDLE(anv_queue, queue, _queue);
@@ -817,29 +817,31 @@ VkResult anv_QueueSubmit(
    struct anv_device *device = queue->device;
    int ret;
 
-   for (uint32_t i = 0; i < commandBufferCount; i++) {
-      ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, pCommandBuffers[i]);
+   for (uint32_t i = 0; i < submitCount; i++) {
+      for (uint32_t j = 0; j < pSubmits[i].commandBufferCount; j++) {
+         ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer,
+                         pSubmits[i].pCommandBuffers[j]);
+         assert(cmd_buffer->level == VK_COMMAND_BUFFER_LEVEL_PRIMARY);
 
-      assert(cmd_buffer->level == VK_COMMAND_BUFFER_LEVEL_PRIMARY);
-
-      ret = anv_gem_execbuffer(device, &cmd_buffer->execbuf2.execbuf);
-      if (ret != 0) {
-         /* We don't know the real error. */
-         return vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY,
-                          "execbuf2 failed: %m");
-      }
-
-      if (fence) {
-         ret = anv_gem_execbuffer(device, &fence->execbuf);
+         ret = anv_gem_execbuffer(device, &cmd_buffer->execbuf2.execbuf);
          if (ret != 0) {
             /* We don't know the real error. */
             return vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY,
                              "execbuf2 failed: %m");
          }
-      }
 
-      for (uint32_t i = 0; i < cmd_buffer->execbuf2.bo_count; i++)
-         cmd_buffer->execbuf2.bos[i]->offset = cmd_buffer->execbuf2.objects[i].offset;
+         if (fence) {
+            ret = anv_gem_execbuffer(device, &fence->execbuf);
+            if (ret != 0) {
+               /* We don't know the real error. */
+               return vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY,
+                                "execbuf2 failed: %m");
+            }
+         }
+
+         for (uint32_t k = 0; k < cmd_buffer->execbuf2.bo_count; k++)
+            cmd_buffer->execbuf2.bos[k]->offset = cmd_buffer->execbuf2.objects[k].offset;
+      }
    }
 
    return VK_SUCCESS;
index 4db7c2539e15bd130b95852447342072ac152f9b..3a1430d49a0653d4333d28e6a00e75e76f6ced9e 100644 (file)
@@ -161,8 +161,12 @@ anv_dump_image_to_ppm(struct anv_device *device,
       }, NULL, &fence);
    assert(result == VK_SUCCESS);
 
-   result = anv_QueueSubmit(anv_queue_to_handle(&device->queue),
-                            1, &cmd, fence);
+   result = anv_QueueSubmit(anv_queue_to_handle(&device->queue), 1,
+      &(VkSubmitInfo) {
+         .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
+         .commandBufferCount = 1,
+         .pCommandBuffers = &cmd,
+      }, fence);
    assert(result == VK_SUCCESS);
 
    result = anv_WaitForFences(vk_device, 1, &fence, true, UINT64_MAX);