vk/cmd_buffer: Move the remaining entrypoints into cmd_emit.c
authorJason Ekstrand <jason.ekstrand@intel.com>
Mon, 27 Jul 2015 22:14:31 +0000 (15:14 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Mon, 27 Jul 2015 22:14:31 +0000 (15:14 -0700)
src/vulkan/anv_cmd_buffer.c
src/vulkan/anv_cmd_emit.c
src/vulkan/anv_private.h

index 34916386b6a34eb75e01f0972c1afa8f84b7bbd6..bb58338c85f0515b0265928c453d218a4311dbc1 100644 (file)
@@ -453,62 +453,6 @@ anv_cmd_buffer_reset_batch_bo_chain(struct anv_cmd_buffer *cmd_buffer)
    cmd_buffer->surface_relocs.num_relocs = 0;
 }
 
-VkResult anv_CreateCommandBuffer(
-    VkDevice                                    _device,
-    const VkCmdBufferCreateInfo*                pCreateInfo,
-    VkCmdBuffer*                                pCmdBuffer)
-{
-   ANV_FROM_HANDLE(anv_device, device, _device);
-   struct anv_cmd_buffer *cmd_buffer;
-   VkResult result;
-
-   assert(pCreateInfo->level == VK_CMD_BUFFER_LEVEL_PRIMARY);
-
-   cmd_buffer = anv_device_alloc(device, sizeof(*cmd_buffer), 8,
-                                 VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
-   if (cmd_buffer == NULL)
-      return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
-
-   cmd_buffer->device = device;
-
-   result = anv_cmd_buffer_init_batch_bo_chain(cmd_buffer);
-   if (result != VK_SUCCESS)
-      goto fail;
-
-   anv_cmd_state_init(&cmd_buffer->state);
-
-   anv_state_stream_init(&cmd_buffer->surface_state_stream,
-                         &device->surface_state_block_pool);
-   anv_state_stream_init(&cmd_buffer->dynamic_state_stream,
-                         &device->dynamic_state_block_pool);
-
-   *pCmdBuffer = anv_cmd_buffer_to_handle(cmd_buffer);
-
-   return VK_SUCCESS;
-
- fail: anv_device_free(device, cmd_buffer);
-
-   return result;
-}
-
-VkResult anv_DestroyCommandBuffer(
-    VkDevice                                    _device,
-    VkCmdBuffer                                 _cmd_buffer)
-{
-   ANV_FROM_HANDLE(anv_device, device, _device);
-   ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, _cmd_buffer);
-
-   anv_cmd_state_fini(&cmd_buffer->state);
-
-   anv_cmd_buffer_fini_batch_bo_chain(cmd_buffer);
-
-   anv_state_stream_finish(&cmd_buffer->surface_state_stream);
-   anv_state_stream_finish(&cmd_buffer->dynamic_state_stream);
-   anv_device_free(device, cmd_buffer);
-
-   return VK_SUCCESS;
-}
-
 static VkResult
 anv_cmd_buffer_add_bo(struct anv_cmd_buffer *cmd_buffer,
                       struct anv_bo *bo,
@@ -673,36 +617,3 @@ anv_cmd_buffer_compute_validate_list(struct anv_cmd_buffer *cmd_buffer)
    cmd_buffer->execbuf.rsvd1 = cmd_buffer->device->context_id;
    cmd_buffer->execbuf.rsvd2 = 0;
 }
-
-VkResult anv_EndCommandBuffer(
-    VkCmdBuffer                                 cmdBuffer)
-{
-   ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer);
-   struct anv_device *device = cmd_buffer->device;
-
-   anv_cmd_buffer_emit_batch_buffer_end(cmd_buffer);
-
-   /* The algorithm used to compute the validate list is not threadsafe as
-    * it uses the bo->index field.  We have to lock the device around it.
-    * Fortunately, the chances for contention here are probably very low.
-    */
-   pthread_mutex_lock(&device->mutex);
-   anv_cmd_buffer_compute_validate_list(cmd_buffer);
-   pthread_mutex_unlock(&device->mutex);
-
-   return VK_SUCCESS;
-}
-
-VkResult anv_ResetCommandBuffer(
-    VkCmdBuffer                                 cmdBuffer,
-    VkCmdBufferResetFlags                       flags)
-{
-   ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer);
-
-   anv_cmd_buffer_reset_batch_bo_chain(cmd_buffer);
-
-   anv_cmd_state_fini(&cmd_buffer->state);
-   anv_cmd_state_init(&cmd_buffer->state);
-
-   return VK_SUCCESS;
-}
index 61d58be33a64656cec7cca0960a8de6407574a5b..c624906ae36c45bc5f40a853866bd93cf0fd1977 100644 (file)
@@ -38,7 +38,7 @@
  * is concerned, most of anv_cmd_buffer is magic.
  */
 
-VkResult
+static void
 anv_cmd_state_init(struct anv_cmd_state *state)
 {
    state->rs_state = NULL;
@@ -55,14 +55,73 @@ anv_cmd_state_init(struct anv_cmd_state *state)
    state->vp_state = NULL;
    state->rs_state = NULL;
    state->ds_state = NULL;
+}
+
+VkResult anv_CreateCommandBuffer(
+    VkDevice                                    _device,
+    const VkCmdBufferCreateInfo*                pCreateInfo,
+    VkCmdBuffer*                                pCmdBuffer)
+{
+   ANV_FROM_HANDLE(anv_device, device, _device);
+   struct anv_cmd_buffer *cmd_buffer;
+   VkResult result;
+
+   assert(pCreateInfo->level == VK_CMD_BUFFER_LEVEL_PRIMARY);
+
+   cmd_buffer = anv_device_alloc(device, sizeof(*cmd_buffer), 8,
+                                 VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
+   if (cmd_buffer == NULL)
+      return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
+
+   cmd_buffer->device = device;
+
+   result = anv_cmd_buffer_init_batch_bo_chain(cmd_buffer);
+   if (result != VK_SUCCESS)
+      goto fail;
+
+   anv_state_stream_init(&cmd_buffer->surface_state_stream,
+                         &device->surface_state_block_pool);
+   anv_state_stream_init(&cmd_buffer->dynamic_state_stream,
+                         &device->dynamic_state_block_pool);
+
+   anv_cmd_state_init(&cmd_buffer->state);
+
+   *pCmdBuffer = anv_cmd_buffer_to_handle(cmd_buffer);
 
    return VK_SUCCESS;
+
+ fail: anv_device_free(device, cmd_buffer);
+
+   return result;
 }
 
-void
-anv_cmd_state_fini(struct anv_cmd_state *state)
+VkResult anv_DestroyCommandBuffer(
+    VkDevice                                    _device,
+    VkCmdBuffer                                 _cmd_buffer)
+{
+   ANV_FROM_HANDLE(anv_device, device, _device);
+   ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, _cmd_buffer);
+
+   anv_cmd_buffer_fini_batch_bo_chain(cmd_buffer);
+
+   anv_state_stream_finish(&cmd_buffer->surface_state_stream);
+   anv_state_stream_finish(&cmd_buffer->dynamic_state_stream);
+   anv_device_free(device, cmd_buffer);
+
+   return VK_SUCCESS;
+}
+
+VkResult anv_ResetCommandBuffer(
+    VkCmdBuffer                                 cmdBuffer,
+    VkCmdBufferResetFlags                       flags)
 {
-   /* Nothing we need to finish right now */
+   ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer);
+
+   anv_cmd_buffer_reset_batch_bo_chain(cmd_buffer);
+
+   anv_cmd_state_init(&cmd_buffer->state);
+
+   return VK_SUCCESS;
 }
 
 void
@@ -117,6 +176,25 @@ VkResult anv_BeginCommandBuffer(
    return VK_SUCCESS;
 }
 
+VkResult anv_EndCommandBuffer(
+    VkCmdBuffer                                 cmdBuffer)
+{
+   ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer);
+   struct anv_device *device = cmd_buffer->device;
+
+   anv_cmd_buffer_emit_batch_buffer_end(cmd_buffer);
+
+   /* The algorithm used to compute the validate list is not threadsafe as
+    * it uses the bo->index field.  We have to lock the device around it.
+    * Fortunately, the chances for contention here are probably very low.
+    */
+   pthread_mutex_lock(&device->mutex);
+   anv_cmd_buffer_compute_validate_list(cmd_buffer);
+   pthread_mutex_unlock(&device->mutex);
+
+   return VK_SUCCESS;
+}
+
 void anv_CmdBindPipeline(
     VkCmdBuffer                                 cmdBuffer,
     VkPipelineBindPoint                         pipelineBindPoint,
index 1ddc2722ceaa4cc0fd3e1d5d419a0b53667b98e8..f8def1108cb5224ccbff7a6cf5b162eb02664bfe 100644 (file)
@@ -690,9 +690,6 @@ struct anv_cmd_state {
    struct anv_descriptor_set_binding            descriptors[MAX_SETS];
 };
 
-VkResult anv_cmd_state_init(struct anv_cmd_state *state);
-void anv_cmd_state_fini(struct anv_cmd_state *state);
-
 struct anv_cmd_buffer {
    struct anv_device *                          device;