mirror of
https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
synced 2024-11-25 16:14:35 +00:00
Fixed attachment layout transitions. #2
This commit is contained in:
parent
3bd398a373
commit
8eb9d8e253
Binary file not shown.
@ -754,64 +754,6 @@ static void CreateSwapchain()
|
||||
|
||||
ERR_GUARD_VULKAN( vkCreateImageView(g_hDevice, &depthImageViewInfo, nullptr, &g_hDepthImageView) );
|
||||
|
||||
BeginSingleTimeCommands();
|
||||
|
||||
// Transition image layout of g_SwapchainImages.
|
||||
for(uint32_t i = 0; i < swapchainImageCount; ++i)
|
||||
{
|
||||
VkImageMemoryBarrier imgMemBarrier = { VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER };
|
||||
imgMemBarrier.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
imgMemBarrier.newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
|
||||
imgMemBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
imgMemBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
imgMemBarrier.image = g_SwapchainImages[i];
|
||||
imgMemBarrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
imgMemBarrier.subresourceRange.baseMipLevel = 0;
|
||||
imgMemBarrier.subresourceRange.levelCount = 1;
|
||||
imgMemBarrier.subresourceRange.baseArrayLayer = 0;
|
||||
imgMemBarrier.subresourceRange.layerCount = 1;
|
||||
imgMemBarrier.srcAccessMask = 0;
|
||||
imgMemBarrier.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
||||
|
||||
vkCmdPipelineBarrier(
|
||||
g_hTemporaryCommandBuffer,
|
||||
VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
|
||||
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
||||
0,
|
||||
0, nullptr,
|
||||
0, nullptr,
|
||||
1, &imgMemBarrier);
|
||||
}
|
||||
|
||||
// Transition image layout of g_hDepthImage.
|
||||
|
||||
VkImageMemoryBarrier imgMemBarrier = { VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER };
|
||||
imgMemBarrier.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
imgMemBarrier.newLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
|
||||
imgMemBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
imgMemBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
imgMemBarrier.image = g_hDepthImage;
|
||||
imgMemBarrier.subresourceRange.aspectMask = g_DepthFormat == VK_FORMAT_D32_SFLOAT ?
|
||||
VK_IMAGE_ASPECT_DEPTH_BIT :
|
||||
VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
|
||||
imgMemBarrier.subresourceRange.baseMipLevel = 0;
|
||||
imgMemBarrier.subresourceRange.levelCount = 1;
|
||||
imgMemBarrier.subresourceRange.baseArrayLayer = 0;
|
||||
imgMemBarrier.subresourceRange.layerCount = 1;
|
||||
imgMemBarrier.srcAccessMask = 0;
|
||||
imgMemBarrier.dstAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
|
||||
|
||||
vkCmdPipelineBarrier(
|
||||
g_hTemporaryCommandBuffer,
|
||||
VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
|
||||
VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
|
||||
0,
|
||||
0, nullptr,
|
||||
0, nullptr,
|
||||
1, &imgMemBarrier);
|
||||
|
||||
EndSingleTimeCommands();
|
||||
|
||||
// Create pipeline layout
|
||||
{
|
||||
if(g_hPipelineLayout != VK_NULL_HANDLE)
|
||||
@ -852,7 +794,7 @@ static void CreateSwapchain()
|
||||
attachments[0].storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
||||
attachments[0].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||
attachments[0].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
attachments[0].initialLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
|
||||
attachments[0].initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
attachments[0].finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
|
||||
|
||||
attachments[1].format = g_DepthFormat;
|
||||
@ -861,7 +803,7 @@ static void CreateSwapchain()
|
||||
attachments[1].storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
attachments[1].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||
attachments[1].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
attachments[1].initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
|
||||
attachments[1].initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
attachments[1].finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
|
||||
|
||||
VkAttachmentReference colorAttachmentRef = {};
|
||||
|
Loading…
Reference in New Issue
Block a user