vulkan: implement Buffer::copyTo

This commit is contained in:
niki
2022-07-30 01:41:37 +02:00
parent 7bbc042fce
commit ad8243f257
2 changed files with 14 additions and 2 deletions
+11 -1
View File
@@ -86,8 +86,18 @@ void Buffer::unmap(size_t usedoffset, size_t usedsize) {
}
void Buffer::copyTo(love::graphics::Buffer* dest, size_t sourceoffset, size_t destoffset, size_t size) {
throw love::Exception("not implemented yet");
Graphics* vgfx = (Graphics*)gfx;
vgfx->queueDatatransfer([buffer = buffer, dest = dest, sourceoffset, destoffset, size](VkCommandBuffer commandBuffer){
VkBufferCopy bufferCopy{};
bufferCopy.srcOffset = sourceoffset;
bufferCopy.dstOffset = destoffset;
bufferCopy.size = size;
vkCmdCopyBuffer(commandBuffer, buffer, (VkBuffer) dest->getHandle(), 1, &bufferCopy);
}, nullptr);
}
} // vulkan
} // graphics
} // love
+3 -1
View File
@@ -564,7 +564,9 @@ const PFN_vkCmdPushDescriptorSetKHR Graphics::getVkCmdPushDescriptorSetKHRFuncti
void Graphics::queueDatatransfer(std::function<void(VkCommandBuffer)> command, std::function<void()> cleanUp) {
command(dataTransferCommandBuffers.at(currentFrame));
cleanUpFunctions.at(currentFrame).push_back(std::move(cleanUp));
if (cleanUp) {
cleanUpFunctions.at(currentFrame).push_back(std::move(cleanUp));
}
}
void Graphics::queueCleanUp(std::function<void()> cleanUp) {