package net.halbear.Terrain4J.EngineCore.Vulkan.Structure.DeviceLayers.GPUSynchronisation;

import net.halbear.Terrain4J.EngineCore.Vulkan.Structure.DeviceLayers.CommandBuffer;
import net.halbear.Terrain4J.EngineCore.Vulkan.Util.VulkanBuffer;
import org.lwjgl.system.MemoryStack;
import org.lwjgl.vulkan.VkBufferCopy;

import static org.lwjgl.vulkan.VK13.vkCmdCopyBuffer;

public record TransferBuffer(VulkanBuffer SrcBuffer, VulkanBuffer DstBuffer) {
    public void RecordTransferCommand(CommandBuffer commandBuffer){
        try(var MemStack = MemoryStack.stackPush()){
            VkBufferCopy.Buffer CopyRegion = VkBufferCopy.calloc(1,MemStack)
                    .srcOffset(0).dstOffset(0).size(SrcBuffer.GetRequestedSize());
            vkCmdCopyBuffer(commandBuffer.GetVulkanCommandBuffer(),SrcBuffer.GetBuffer(),DstBuffer.GetBuffer(),CopyRegion);
        }
    }
}
