anv/batch_chain: Clean up the reloc list swapping code
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 24 Sep 2015 00:16:40 +0000 (17:16 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 24 Sep 2015 15:41:38 +0000 (08:41 -0700)
src/vulkan/anv_batch_chain.c

index 77a5bd6f9ece2a71469ec21bf84a24f0467ea9eb..b8f08b9cd8aeab5283828b1a2b83d09cdba387e5 100644 (file)
@@ -895,21 +895,19 @@ anv_cmd_buffer_prepare_execbuf(struct anv_cmd_buffer *cmd_buffer)
     */
    if (first_batch_bo->bo.index != cmd_buffer->execbuf2.bo_count - 1) {
       uint32_t idx = first_batch_bo->bo.index;
+      uint32_t last_idx = cmd_buffer->execbuf2.bo_count - 1;
 
       struct drm_i915_gem_exec_object2 tmp_obj =
          cmd_buffer->execbuf2.objects[idx];
       assert(cmd_buffer->execbuf2.bos[idx] == &first_batch_bo->bo);
 
-      cmd_buffer->execbuf2.objects[idx] =
-         cmd_buffer->execbuf2.objects[cmd_buffer->execbuf2.bo_count - 1];
-      cmd_buffer->execbuf2.bos[idx] =
-         cmd_buffer->execbuf2.bos[cmd_buffer->execbuf2.bo_count - 1];
+      cmd_buffer->execbuf2.objects[idx] = cmd_buffer->execbuf2.objects[last_idx];
+      cmd_buffer->execbuf2.bos[idx] = cmd_buffer->execbuf2.bos[last_idx];
       cmd_buffer->execbuf2.bos[idx]->index = idx;
 
-      cmd_buffer->execbuf2.objects[cmd_buffer->execbuf2.bo_count - 1] = tmp_obj;
-      cmd_buffer->execbuf2.bos[cmd_buffer->execbuf2.bo_count - 1] =
-         &first_batch_bo->bo;
-      first_batch_bo->bo.index = cmd_buffer->execbuf2.bo_count - 1;
+      cmd_buffer->execbuf2.objects[last_idx] = tmp_obj;
+      cmd_buffer->execbuf2.bos[last_idx] = &first_batch_bo->bo;
+      first_batch_bo->bo.index = last_idx;
    }
 
    /* Now we go through and fixup all of the relocation lists to point to