added mock image uploader

This commit is contained in:
turanszkij
2018-04-09 13:18:02 +01:00
parent 8d0408076c
commit bee2e7b74a
+47
View File
@@ -1383,6 +1383,10 @@ namespace wiGraphicsTypes
{
imageInfo.usage |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
}
if (pInitialData != nullptr)
{
imageInfo.usage |= VK_IMAGE_USAGE_TRANSFER_DST_BIT;
}
imageInfo.flags = 0;
if ((*ppTexture2D)->desc.MiscFlags & RESOURCE_MISC_TEXTURECUBE)
@@ -1418,6 +1422,49 @@ namespace wiGraphicsTypes
// Issue data copy on request:
if (pInitialData != nullptr)
{
uint8_t* dest = textureUploader->allocate(memRequirements.size, memRequirements.alignment);
VkBufferImageCopy copyRegions[16] = {};
assert(pDesc->ArraySize < 16);
uint32_t width = pDesc->Width;
uint32_t height = pDesc->Height;
for (UINT slice = 0; slice < pDesc->ArraySize; ++slice)
{
memcpy(dest, pInitialData[slice].pSysMem, pInitialData[slice].SysMemPitch * height); // double check!!
VkBufferImageCopy& copyRegion = copyRegions[slice];
copyRegion.bufferOffset = 0;
copyRegion.bufferRowLength = 0;
copyRegion.bufferImageHeight = 0;
// for now, only mips can be filled like this:
copyRegion.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
copyRegion.imageSubresource.mipLevel = slice;
copyRegion.imageSubresource.baseArrayLayer = 0;
copyRegion.imageSubresource.layerCount = 1;
copyRegion.imageOffset = { 0, 0, 0 };
copyRegion.imageExtent = {
width,
height,
1
};
width = max(1, width / 2);
height /= max(1, height / 2);
}
copyQueueLock.lock();
vkCmdCopyBufferToImage(copyCommandBuffer, textureUploader->resource, *static_cast<VkImage*>((*ppTexture2D)->resource_Vulkan), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, pDesc->ArraySize, copyRegions);
copyQueueLock.unlock();
}
// Issue creation of additional descriptors for the resource: