| 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 | { |
| 2131 | uint32_t bytesPerPixel = bytesPerTexFormat(texFormat); |
| 2132 | |
| 2133 | VkDeviceSize layerSize = texWidth * texHeight * bytesPerPixel; |
| 2134 | VkDeviceSize imageSize = layerSize * layerCount; |
| 2135 | |
| 2136 | VkBuffer stagingBuffer; |
| 2137 | VkDeviceMemory stagingBufferMemory; |
| 2138 | createBuffer(vkDev.device, vkDev.physicalDevice, imageSize, VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, stagingBuffer, stagingBufferMemory); |
| 2139 | |
| 2140 | transitionImageLayout(vkDev, textureImage, texFormat, sourceImageLayout, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, layerCount); |
| 2141 | copyImageToBuffer(vkDev, textureImage, stagingBuffer, static_cast<uint32_t>(texWidth), static_cast<uint32_t>(texHeight), layerCount); |
| 2142 | transitionImageLayout(vkDev, textureImage, texFormat, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, sourceImageLayout, layerCount); |
| 2143 | |
| 2144 | downloadBufferData(vkDev, stagingBufferMemory, 0, imageData, imageSize); |
| 2145 | |
| 2146 | vkDestroyBuffer(vkDev.device, stagingBuffer, nullptr); |
| 2147 | vkFreeMemory(vkDev.device, stagingBufferMemory, nullptr); |
| 2148 | |
| 2149 | return true; |
| 2150 | } |
| 2151 | |
| 2152 | bool createDepthResources(VulkanRenderDevice& vkDev, uint32_t width, uint32_t height, VulkanImage& depth) |
| 2153 | { |
no test coverage detected