From db1ed8db325103d0042a5e68bd4e69a2fc232e5f Mon Sep 17 00:00:00 2001 From: Turanszki Janos Date: Wed, 8 Sep 2021 10:15:56 +0200 Subject: [PATCH] vulkan: texture initial data layers fix --- WickedEngine/wiGraphicsDevice_Vulkan.cpp | 74 ++++++++++++------------ WickedEngine/wiVersion.cpp | 2 +- 2 files changed, 39 insertions(+), 37 deletions(-) diff --git a/WickedEngine/wiGraphicsDevice_Vulkan.cpp b/WickedEngine/wiGraphicsDevice_Vulkan.cpp index dc05d1a9d..d0cd2dcb4 100644 --- a/WickedEngine/wiGraphicsDevice_Vulkan.cpp +++ b/WickedEngine/wiGraphicsDevice_Vulkan.cpp @@ -3302,45 +3302,47 @@ using namespace Vulkan_Internal; VkDeviceSize copyOffset = 0; uint32_t initDataIdx = 0; - uint32_t width = imageInfo.extent.width; - uint32_t height = imageInfo.extent.height; - uint32_t depth = imageInfo.extent.depth; - uint32_t layers = pDesc->ArraySize; - for (uint32_t mip = 0; mip < pDesc->MipLevels; ++mip) + for (uint32_t layer = 0; layer < pDesc->ArraySize; ++layer) { - const SubresourceData& subresourceData = pInitialData[initDataIdx++]; - VkDeviceSize copySize = subresourceData.rowPitch * height * depth * layers; - if (IsFormatBlockCompressed(pDesc->Format)) + uint32_t width = imageInfo.extent.width; + uint32_t height = imageInfo.extent.height; + uint32_t depth = imageInfo.extent.depth; + for (uint32_t mip = 0; mip < pDesc->MipLevels; ++mip) { - copySize /= 4; + const SubresourceData& subresourceData = pInitialData[initDataIdx++]; + VkDeviceSize copySize = subresourceData.rowPitch * height * depth; + if (IsFormatBlockCompressed(pDesc->Format)) + { + copySize /= 4; + } + uint8_t* cpyaddr = (uint8_t*)cmd.uploadbuffer.mapped_data + copyOffset; + memcpy(cpyaddr, subresourceData.pData, copySize); + + VkBufferImageCopy copyRegion = {}; + copyRegion.bufferOffset = copyOffset; + copyRegion.bufferRowLength = 0; + copyRegion.bufferImageHeight = 0; + + copyRegion.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; + copyRegion.imageSubresource.mipLevel = mip; + copyRegion.imageSubresource.baseArrayLayer = layer; + copyRegion.imageSubresource.layerCount = 1; + + copyRegion.imageOffset = { 0, 0, 0 }; + copyRegion.imageExtent = { + width, + height, + depth + }; + + width = std::max(1u, width / 2); + height = std::max(1u, height / 2); + depth = std::max(1u, depth / 2); + + copyRegions.push_back(copyRegion); + + copyOffset += AlignTo(copySize, (VkDeviceSize)GetFormatStride(pDesc->Format)); } - uint8_t* cpyaddr = (uint8_t*)cmd.uploadbuffer.mapped_data + copyOffset; - memcpy(cpyaddr, subresourceData.pData, copySize); - - VkBufferImageCopy copyRegion = {}; - copyRegion.bufferOffset = copyOffset; - copyRegion.bufferRowLength = 0; - copyRegion.bufferImageHeight = 0; - - copyRegion.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; - copyRegion.imageSubresource.mipLevel = mip; - copyRegion.imageSubresource.baseArrayLayer = 0; - copyRegion.imageSubresource.layerCount = layers; - - copyRegion.imageOffset = { 0, 0, 0 }; - copyRegion.imageExtent = { - width, - height, - depth - }; - - width = std::max(1u, width / 2); - height = std::max(1u, height / 2); - depth = std::max(1u, depth / 2); - - copyRegions.push_back(copyRegion); - - copyOffset += AlignTo(copySize, (VkDeviceSize)GetFormatStride(pDesc->Format)); } { diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index e38032149..327854662 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wiVersion // minor features, major updates, breaking compatibility changes const int minor = 57; // minor bug fixes, alterations, refactors, updates - const int revision = 8; + const int revision = 9; const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);