MCPcopy Create free account
hub / github.com/PacktPublishing/3D-Graphics-Rendering-Cookbook / copyBufferToImage

Function copyBufferToImage

shared/UtilsVulkan.cpp:1938–1959  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1936}
1937
1938void copyBufferToImage(VulkanRenderDevice& vkDev, VkBuffer buffer, VkImage image, uint32_t width, uint32_t height, uint32_t layerCount)
1939{
1940 VkCommandBuffer commandBuffer = beginSingleTimeCommands(vkDev);
1941
1942 const VkBufferImageCopy region = {
1943 .bufferOffset = 0,
1944 .bufferRowLength = 0,
1945 .bufferImageHeight = 0,
1946 .imageSubresource = VkImageSubresourceLayers {
1947 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
1948 .mipLevel = 0,
1949 .baseArrayLayer = 0,
1950 .layerCount = layerCount
1951 },
1952 .imageOffset = VkOffset3D {.x = 0, .y = 0, .z = 0 },
1953 .imageExtent = VkExtent3D {.width = width, .height = height, .depth = 1 }
1954 };
1955
1956 vkCmdCopyBufferToImage(commandBuffer, buffer, image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &region);
1957
1958 endSingleTimeCommands(vkDev, commandBuffer);
1959}
1960
1961void copyMIPBufferToImage(VulkanRenderDevice& vkDev, VkBuffer buffer, VkImage image, uint32_t mipLevels, uint32_t width, uint32_t height, uint32_t bytesPP, uint32_t layerCount)
1962{

Callers 1

updateTextureImageFunction · 0.85

Calls 2

beginSingleTimeCommandsFunction · 0.85
endSingleTimeCommandsFunction · 0.85

Tested by

no test coverage detected