Commit 12d18abf authored by Chia-I Wu's avatar Chia-I Wu Committed by Marge Bot
Browse files

venus: refactor vn_EndCommandBuffer



Add vn_cmd_submit as a wrapper to vn_instance_ring_submit.  It is also
designed such that it can be called from any of the vn_Cmd* functions.
Signed-off-by: Chia-I Wu's avatarChia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang's avatarYiwei Zhang <zzyiwei@chromium.org>
Part-of: <!11896>
parent f144d914
Pipeline #360419 waiting for manual action with stages
......@@ -654,6 +654,33 @@ vn_BeginCommandBuffer(VkCommandBuffer commandBuffer,
return VK_SUCCESS;
}
static VkResult
vn_cmd_submit(struct vn_command_buffer *cmd)
{
struct vn_instance *instance = cmd->device->instance;
if (cmd->state != VN_COMMAND_BUFFER_STATE_RECORDING)
return VK_ERROR_OUT_OF_HOST_MEMORY;
vn_cs_encoder_commit(&cmd->cs);
if (vn_cs_encoder_get_fatal(&cmd->cs)) {
cmd->state = VN_COMMAND_BUFFER_STATE_INVALID;
vn_cs_encoder_reset(&cmd->cs);
return VK_ERROR_OUT_OF_HOST_MEMORY;
}
vn_instance_wait_roundtrip(instance, cmd->cs.current_buffer_roundtrip);
VkResult result = vn_instance_ring_submit(instance, &cmd->cs);
if (result != VK_SUCCESS) {
cmd->state = VN_COMMAND_BUFFER_STATE_INVALID;
return result;
}
vn_cs_encoder_reset(&cmd->cs);
return VK_SUCCESS;
}
VkResult
vn_EndCommandBuffer(VkCommandBuffer commandBuffer)
{
......@@ -662,9 +689,6 @@ vn_EndCommandBuffer(VkCommandBuffer commandBuffer)
struct vn_instance *instance = cmd->device->instance;
size_t cmd_size;
if (cmd->state != VN_COMMAND_BUFFER_STATE_RECORDING)
return vn_error(instance, VK_ERROR_OUT_OF_HOST_MEMORY);
cmd_size = vn_sizeof_vkEndCommandBuffer(commandBuffer);
if (!vn_cs_encoder_reserve(&cmd->cs, cmd_size)) {
cmd->state = VN_COMMAND_BUFFER_STATE_INVALID;
......@@ -672,22 +696,13 @@ vn_EndCommandBuffer(VkCommandBuffer commandBuffer)
}
vn_encode_vkEndCommandBuffer(&cmd->cs, 0, commandBuffer);
vn_cs_encoder_commit(&cmd->cs);
if (vn_cs_encoder_get_fatal(&cmd->cs)) {
cmd->state = VN_COMMAND_BUFFER_STATE_INVALID;
return vn_error(instance, VK_ERROR_OUT_OF_HOST_MEMORY);
}
vn_instance_wait_roundtrip(instance, cmd->cs.current_buffer_roundtrip);
VkResult result = vn_instance_ring_submit(instance, &cmd->cs);
VkResult result = vn_cmd_submit(cmd);
if (result != VK_SUCCESS) {
cmd->state = VN_COMMAND_BUFFER_STATE_INVALID;
return vn_error(instance, result);
}
vn_cs_encoder_reset(&cmd->cs);
cmd->state = VN_COMMAND_BUFFER_STATE_EXECUTABLE;
return VK_SUCCESS;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment