Puss sub resource range with mip level count to image transition barriers
This commit is contained in:
parent
72e6cd8ee5
commit
7719491f2c
1 changed files with 18 additions and 10 deletions
|
|
@ -172,6 +172,12 @@ namespace vkTools
|
||||||
err = vkBindImageMemory(device, texture->image, texture->deviceMemory, 0);
|
err = vkBindImageMemory(device, texture->image, texture->deviceMemory, 0);
|
||||||
assert(!err);
|
assert(!err);
|
||||||
|
|
||||||
|
VkImageSubresourceRange subresourceRange = {};
|
||||||
|
subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||||
|
subresourceRange.baseMipLevel = 0;
|
||||||
|
subresourceRange.levelCount = texture->mipLevels;
|
||||||
|
subresourceRange.layerCount = 1;
|
||||||
|
|
||||||
// Image barrier for optimal image (target)
|
// Image barrier for optimal image (target)
|
||||||
// Optimal image will be used as destination for the copy
|
// Optimal image will be used as destination for the copy
|
||||||
setImageLayout(
|
setImageLayout(
|
||||||
|
|
@ -179,7 +185,8 @@ namespace vkTools
|
||||||
texture->image,
|
texture->image,
|
||||||
VK_IMAGE_ASPECT_COLOR_BIT,
|
VK_IMAGE_ASPECT_COLOR_BIT,
|
||||||
VK_IMAGE_LAYOUT_PREINITIALIZED,
|
VK_IMAGE_LAYOUT_PREINITIALIZED,
|
||||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||||
|
subresourceRange);
|
||||||
|
|
||||||
// Copy mip levels one by one
|
// Copy mip levels one by one
|
||||||
for (uint32_t level = 0; level < texture->mipLevels; ++level)
|
for (uint32_t level = 0; level < texture->mipLevels; ++level)
|
||||||
|
|
@ -213,17 +220,18 @@ namespace vkTools
|
||||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||||
1,
|
1,
|
||||||
©Region);
|
©Region);
|
||||||
|
|
||||||
// Change texture image layout to shader read after the copy
|
|
||||||
texture->imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
|
||||||
setImageLayout(
|
|
||||||
cmdBuffer,
|
|
||||||
texture->image,
|
|
||||||
VK_IMAGE_ASPECT_COLOR_BIT,
|
|
||||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
|
||||||
texture->imageLayout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Change texture image layout to shader read for all mip levels after the copy
|
||||||
|
texture->imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||||
|
setImageLayout(
|
||||||
|
cmdBuffer,
|
||||||
|
texture->image,
|
||||||
|
VK_IMAGE_ASPECT_COLOR_BIT,
|
||||||
|
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||||
|
texture->imageLayout,
|
||||||
|
subresourceRange);
|
||||||
|
|
||||||
// Submit command buffer containing copy and image layout commands
|
// Submit command buffer containing copy and image layout commands
|
||||||
err = vkEndCommandBuffer(cmdBuffer);
|
err = vkEndCommandBuffer(cmdBuffer);
|
||||||
assert(!err);
|
assert(!err);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue