summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChad Versace <[email protected]>2016-01-14 13:12:35 -0800
committerChad Versace <[email protected]>2016-01-14 13:14:40 -0800
commited33ccde635eda9d6accf2ff69fcf805902ec082 (patch)
tree27cb4e453a1e47c91163bdf8cd82efa8ee045ee4 /src
parentea20389320b251f6498eb9c47e525ced10aab91d (diff)
anv: Make vkBeginCommandBuffer reset the command buffer
If its the command buffer's first call to vkBeginCommandBuffer, we must *initialize* the command buffer's state. Otherwise, we must *reset* its state. In both cases, let's use anv_ResetCommandBuffer. From the Vulkan 1.0 spec: If a command buffer is in the executable state and the command buffer was allocated from a command pool with the VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT flag set, then vkBeginCommandBuffer implicitly resets the command buffer, behaving as if vkResetCommandBuffer had been called with VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT not set. It then puts the command buffer in the recording state.
Diffstat (limited to 'src')
-rw-r--r--src/vulkan/anv_cmd_buffer.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/vulkan/anv_cmd_buffer.c b/src/vulkan/anv_cmd_buffer.c
index a888a542751..689bc53c93a 100644
--- a/src/vulkan/anv_cmd_buffer.c
+++ b/src/vulkan/anv_cmd_buffer.c
@@ -111,7 +111,7 @@ anv_dynamic_state_copy(struct anv_dynamic_state *dest,
}
static void
-anv_cmd_state_init(struct anv_cmd_state *state)
+anv_cmd_state_reset(struct anv_cmd_state *state)
{
memset(&state->descriptors, 0, sizeof(state->descriptors));
memset(&state->push_constants, 0, sizeof(state->push_constants));
@@ -172,6 +172,7 @@ static VkResult anv_create_cmd_buffer(
cmd_buffer->_loader_data.loaderMagic = ICD_LOADER_MAGIC;
cmd_buffer->device = device;
cmd_buffer->pool = pool;
+ cmd_buffer->level = level;
result = anv_cmd_buffer_init_batch_bo_chain(cmd_buffer);
if (result != VK_SUCCESS)
@@ -182,11 +183,6 @@ static VkResult anv_create_cmd_buffer(
anv_state_stream_init(&cmd_buffer->dynamic_state_stream,
&device->dynamic_state_block_pool);
- cmd_buffer->level = level;
- cmd_buffer->usage_flags = 0;
-
- anv_cmd_state_init(&cmd_buffer->state);
-
if (pool) {
list_addtail(&cmd_buffer->pool_link, &pool->cmd_buffers);
} else {
@@ -263,9 +259,10 @@ VkResult anv_ResetCommandBuffer(
{
ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
+ cmd_buffer->usage_flags = 0;
+ cmd_buffer->state.current_pipeline = UINT32_MAX;
anv_cmd_buffer_reset_batch_bo_chain(cmd_buffer);
-
- anv_cmd_state_init(&cmd_buffer->state);
+ anv_cmd_state_reset(&cmd_buffer->state);
return VK_SUCCESS;
}
@@ -294,7 +291,21 @@ VkResult anv_BeginCommandBuffer(
{
ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
- anv_cmd_buffer_reset_batch_bo_chain(cmd_buffer);
+ /* If this is the first vkBeginCommandBuffer, we must *initialize* the
+ * command buffer's state. Otherwise, we must *reset* its state. In both
+ * cases we reset it.
+ *
+ * From the Vulkan 1.0 spec:
+ *
+ * If a command buffer is in the executable state and the command buffer
+ * was allocated from a command pool with the
+ * VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT flag set, then
+ * vkBeginCommandBuffer implicitly resets the command buffer, behaving
+ * as if vkResetCommandBuffer had been called with
+ * VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT not set. It then puts
+ * the command buffer in the recording state.
+ */
+ anv_ResetCommandBuffer(commandBuffer, /*flags*/ 0);
cmd_buffer->usage_flags = pBeginInfo->flags;
@@ -315,7 +326,6 @@ VkResult anv_BeginCommandBuffer(
}
anv_cmd_buffer_emit_state_base_address(cmd_buffer);
- cmd_buffer->state.current_pipeline = UINT32_MAX;
return VK_SUCCESS;
}