vk/cmd_buffer: Move the remaining entrypoints into cmd_emit.c

This commit is contained in:
Jason Ekstrand
2015-07-27 15:14:31 -07:00
parent d4c249364d
commit 4ced8650d4
3 changed files with 82 additions and 96 deletions

View 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; 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 static VkResult
anv_cmd_buffer_add_bo(struct anv_cmd_buffer *cmd_buffer, anv_cmd_buffer_add_bo(struct anv_cmd_buffer *cmd_buffer,
struct anv_bo *bo, 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.rsvd1 = cmd_buffer->device->context_id;
cmd_buffer->execbuf.rsvd2 = 0; 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;
}

View File

@@ -38,7 +38,7 @@
* is concerned, most of anv_cmd_buffer is magic. * is concerned, most of anv_cmd_buffer is magic.
*/ */
VkResult static void
anv_cmd_state_init(struct anv_cmd_state *state) anv_cmd_state_init(struct anv_cmd_state *state)
{ {
state->rs_state = NULL; state->rs_state = NULL;
@@ -55,14 +55,73 @@ anv_cmd_state_init(struct anv_cmd_state *state)
state->vp_state = NULL; state->vp_state = NULL;
state->rs_state = NULL; state->rs_state = NULL;
state->ds_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;
}
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; return VK_SUCCESS;
} }
void VkResult anv_ResetCommandBuffer(
anv_cmd_state_fini(struct anv_cmd_state *state) 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 void
@@ -117,6 +176,25 @@ VkResult anv_BeginCommandBuffer(
return VK_SUCCESS; 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( void anv_CmdBindPipeline(
VkCmdBuffer cmdBuffer, VkCmdBuffer cmdBuffer,
VkPipelineBindPoint pipelineBindPoint, VkPipelineBindPoint pipelineBindPoint,

View File

@@ -690,9 +690,6 @@ struct anv_cmd_state {
struct anv_descriptor_set_binding descriptors[MAX_SETS]; 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_cmd_buffer {
struct anv_device * device; struct anv_device * device;