| 2104 | } |
| 2105 | |
| 2106 | bool updateTextureImage(VulkanRenderDevice& vkDev, VkImage& textureImage, VkDeviceMemory& textureImageMemory, uint32_t texWidth, uint32_t texHeight, VkFormat texFormat, uint32_t layerCount, const void* imageData, VkImageLayout sourceImageLayout) |
| 2107 | { |
| 2108 | uint32_t bytesPerPixel = bytesPerTexFormat(texFormat); |
| 2109 | |
| 2110 | VkDeviceSize layerSize = texWidth * texHeight * bytesPerPixel; |
| 2111 | VkDeviceSize imageSize = layerSize * layerCount; |
| 2112 | |
| 2113 | VkBuffer stagingBuffer; |
| 2114 | VkDeviceMemory stagingBufferMemory; |
| 2115 | createBuffer(vkDev.device, vkDev.physicalDevice, imageSize, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, stagingBuffer, stagingBufferMemory); |
| 2116 | |
| 2117 | uploadBufferData(vkDev, stagingBufferMemory, 0, imageData, imageSize); |
| 2118 | |
| 2119 | transitionImageLayout(vkDev, textureImage, texFormat, sourceImageLayout, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, layerCount); |
| 2120 | copyBufferToImage(vkDev, stagingBuffer, textureImage, static_cast<uint32_t>(texWidth), static_cast<uint32_t>(texHeight), layerCount); |
| 2121 | transitionImageLayout(vkDev, textureImage, texFormat, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, layerCount); |
| 2122 | |
| 2123 | vkDestroyBuffer(vkDev.device, stagingBuffer, nullptr); |
| 2124 | vkFreeMemory(vkDev.device, stagingBufferMemory, nullptr); |
| 2125 | |
| 2126 | return true; |
| 2127 | } |
| 2128 | |
| 2129 | bool downloadImageData(VulkanRenderDevice& vkDev, VkImage& textureImage, uint32_t texWidth, uint32_t texHeight, VkFormat texFormat, uint32_t layerCount, void* imageData, VkImageLayout sourceImageLayout) |
| 2130 | { |
no test coverage detected