vulkan: texture initial data layers fix

This commit is contained in:
Turanszki Janos
2021-09-08 10:15:56 +02:00
parent 331f52e8c3
commit db1ed8db32
2 changed files with 39 additions and 37 deletions
+38 -36
View File
@@ -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));
}
{
+1 -1
View File
@@ -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);