You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: image_primer_host_copy.go
    path of file: ./repos/gapid/gapis/api/vulkan
    
    the code of the file until where you have to start completion: // Copyright (C) 2019 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// U
    
func (kit ipHostCopyKit) BuildHostCopyCommands(sb *stateBuilder) *queueCommandBatch {
	cmdBatch := newQueueCommandBatch(kit.name.String())
	dataOffsetPieces := []hashedDataAndOffset{}
	copies := []VkBufferImageCopy{}
	bufferOffset := uint64(0)
	for _, p := range kit.pieces {
		copy := NewVkBufferImageCopy(sb.ta,
			VkDeviceSize(bufferOffset), // bufferOffset
			0,                          // bufferRowLength
			0,                          // bufferImageHeight
			NewVkImageSubresourceLayers(sb.ta, // imageSubresourceLayers
				VkImageAspectFlags(p.aspect),
				p.level, p.layer, 1,
			),
			NewVkOffset3D(sb.ta, int32(p.offsetX), int32(p.offsetY), int32(p.offsetZ)),
			NewVkExtent3D(sb.ta, p.extentWidth, p.extentHeight, p.extentDepth),
		)
		copies = append(copies, copy)
		dataWithOffset := newHashedDataAndOffset(p.data, bufferOffset)
		dataOffsetPieces = append(dataOffsetPieces, dataWithOffset)
		bufferOffset += p.data.size
		bufferOffset = nextMultipleOf(bufferOffset, 8)
	}
	bufferSize := bufferOffset
	dev := GetState(sb.newState).Images().Get(kit.dstImage).Device()
	scratchBuf := cmdBatch.NewScratchBuffer(sb, kit.name, kit.scratchMemory, dev,
		VkBufferUsageFlags(VkBufferUsageFlagBits_VK_BUFFER_USAGE_TRANSFER_SRC_BIT),
		dataOffsetPieces...,
	)
	cmdBatch.RecordCommandsOnCommit(func(commandBuffer VkCommandBuffer) {
		sb.write(sb.cb.VkCmdPipelineBarrier(
			commandBuffer,
			VkPipelineStageFlags(VkPipelineStageFlagBits_VK_PIPELINE_STAGE_ALL_COMMANDS_BIT),
			VkPipelineStageFlags(VkPipelineStageFlagBits_VK_PIPELINE_STAGE_ALL_COMMANDS_BIT),
			VkDependencyFlags(0),
			uint32(0),
			memory.Nullptr,
			uint32(1),
			sb.MustAllocReadData(
				NewVkBufferMemoryBarrier(sb.ta,
					VkStructureType_VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // sType
					0, // pNext
					VkAccessFlags((VkAccessFlagBits_VK_ACCESS_MEMORY_WRITE_BIT-1)|VkAccessFlagBits_VK_ACCESS_MEMORY_WRITE_BIT), // srcAccessMask
					VkAccessFlags((VkAccessFlagBits_VK_ACCESS_MEMORY_WRITE_BIT-1)|VkAccessFlagBits_VK_ACCESS_MEMORY_WRITE_BIT), // dstAccessMask
					queueFamilyIgnore,        // srcQueueFamilyIndex
					queueFamilyIgnore,        // dstQueueFamilyIndex
					scratchBuf,               // buffer
					0,                        // offset
					VkDeviceSize(bufferSize), // size
				)).Ptr(),
			uint32(0),
			memory.Nullptr,
		))
		sb.write(sb.cb.VkCmdCopyBufferToImage(
			commandBuffer,
			scratchBuf,
			kit.dstImage,
			ipHostCopyImageLayout,
			uint32(len(copies)),
			sb.MustAllocReadData(copies).Ptr(),
		))
	})
	return cmdBatch
}