radv: only reset command buffers that are not in the initial state
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 6 Dec 2017 16:48:41 +0000 (17:48 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 8 Dec 2017 10:21:23 +0000 (11:21 +0100)
dota2 always calls vkResetCommandBuffer() before
vkBeginCommandBuffer() which is quite useless.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
src/amd/vulkan/radv_cmd_buffer.c

index 63a5eebab9dc3fbdbccfae001904afd8092f825d..8821fcacefe4f22f80ef9bcff642fd92e845c553 100644 (file)
@@ -2230,11 +2230,16 @@ VkResult radv_BeginCommandBuffer(
        const VkCommandBufferBeginInfo *pBeginInfo)
 {
        RADV_FROM_HANDLE(radv_cmd_buffer, cmd_buffer, commandBuffer);
-       VkResult result;
+       VkResult result = VK_SUCCESS;
 
-       result = radv_reset_cmd_buffer(cmd_buffer);
-       if (result != VK_SUCCESS)
-               return result;
+       if (cmd_buffer->status != RADV_CMD_BUFFER_STATUS_INITIAL) {
+               /* If the command buffer has already been resetted with
+                * vkResetCommandBuffer, no need to do it again.
+                */
+               result = radv_reset_cmd_buffer(cmd_buffer);
+               if (result != VK_SUCCESS)
+                       return result;
+       }
 
        memset(&cmd_buffer->state, 0, sizeof(cmd_buffer->state));
        cmd_buffer->state.last_primitive_reset_en = -1;