diff options
author | Jason Ekstrand <[email protected]> | 2015-07-27 15:14:31 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2015-07-27 15:14:31 -0700 |
commit | 4ced8650d492c8a346bdc51c494b2268d7bf473d (patch) | |
tree | 06ba2a9d834513c5751c9de7ff13255605df4385 | |
parent | d4c249364dc7049cf91d8f626b289d51a53b3bc1 (diff) |
vk/cmd_buffer: Move the remaining entrypoints into cmd_emit.c
-rw-r--r-- | src/vulkan/anv_cmd_buffer.c | 89 | ||||
-rw-r--r-- | src/vulkan/anv_cmd_emit.c | 86 | ||||
-rw-r--r-- | src/vulkan/anv_private.h | 3 |
3 files changed, 82 insertions, 96 deletions
diff --git a/src/vulkan/anv_cmd_buffer.c b/src/vulkan/anv_cmd_buffer.c index 34916386b6a..bb58338c85f 100644 --- a/src/vulkan/anv_cmd_buffer.c +++ b/src/vulkan/anv_cmd_buffer.c @@ -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; -} diff --git a/src/vulkan/anv_cmd_emit.c b/src/vulkan/anv_cmd_emit.c index 61d58be33a6..c624906ae36 100644 --- a/src/vulkan/anv_cmd_emit.c +++ b/src/vulkan/anv_cmd_emit.c @@ -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, diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h index 1ddc2722cea..f8def1108cb 100644 --- a/src/vulkan/anv_private.h +++ b/src/vulkan/anv_private.h @@ -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; |