You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.2 KiB
35 lines
1.2 KiB
4 weeks ago
|
#include "VkImages.h"
|
||
|
#include "VkInitializers.h"
|
||
|
|
||
|
void vkutil::transition_image(VkCommandBuffer cmd, VkImage image, VkImageLayout currentLayout, VkImageLayout newLayout)
|
||
|
{
|
||
|
VkImageMemoryBarrier2 imageBarrier {.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER_2};
|
||
|
imageBarrier.pNext = nullptr;
|
||
|
|
||
|
imageBarrier.srcStageMask = VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT;
|
||
|
imageBarrier.srcAccessMask = VK_ACCESS_2_MEMORY_WRITE_BIT;
|
||
|
imageBarrier.dstStageMask = VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT;
|
||
|
imageBarrier.dstAccessMask = VK_ACCESS_2_MEMORY_WRITE_BIT | VK_ACCESS_2_MEMORY_READ_BIT;
|
||
|
|
||
|
imageBarrier.oldLayout = currentLayout;
|
||
|
imageBarrier.newLayout = newLayout;
|
||
|
|
||
|
VkImageAspectFlags aspectMask = (newLayout == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL) ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_COLOR_BIT;
|
||
|
imageBarrier.subresourceRange = vkinit::image_subresource_range(aspectMask);
|
||
|
imageBarrier.image = image;
|
||
|
|
||
|
VkDependencyInfo depInfo {};
|
||
|
depInfo.sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO;
|
||
|
depInfo.pNext = nullptr;
|
||
|
|
||
|
depInfo.imageMemoryBarrierCount = 1;
|
||
|
depInfo.pImageMemoryBarriers = &imageBarrier;
|
||
|
|
||
|
vkCmdPipelineBarrier2(cmd, &depInfo);
|
||
|
}
|
||
|
|
||
|
//VkImages::VkImages()
|
||
|
//{
|
||
|
|
||
|
//}
|