Explicit image memory barriers with access flags (Refs #288)
This commit is contained in:
parent
373f005d9a
commit
83df699dcf
1 changed files with 23 additions and 14 deletions
|
|
@ -259,8 +259,7 @@ public:
|
||||||
std::vector<VkVertexInputAttributeDescription> vertexInputAttributes = {
|
std::vector<VkVertexInputAttributeDescription> vertexInputAttributes = {
|
||||||
vks::initializers::vertexInputAttributeDescription(0, 0, VK_FORMAT_R32G32B32_SFLOAT, 0), // Position
|
vks::initializers::vertexInputAttributeDescription(0, 0, VK_FORMAT_R32G32B32_SFLOAT, 0), // Position
|
||||||
vks::initializers::vertexInputAttributeDescription(0, 1, VK_FORMAT_R32G32B32_SFLOAT, sizeof(float) * 3), // Normal
|
vks::initializers::vertexInputAttributeDescription(0, 1, VK_FORMAT_R32G32B32_SFLOAT, sizeof(float) * 3), // Normal
|
||||||
vks::initializers::vertexInputAttributeDescription(0, 2, VK_FORMAT_R32G32_SFLOAT, sizeof(float) * 6), // UV
|
vks::initializers::vertexInputAttributeDescription(0, 2, VK_FORMAT_R32G32B32_SFLOAT, sizeof(float) * 6), // Color
|
||||||
vks::initializers::vertexInputAttributeDescription(0, 3, VK_FORMAT_R32G32B32_SFLOAT, sizeof(float) * 8), // Color
|
|
||||||
};
|
};
|
||||||
|
|
||||||
VkPipelineVertexInputStateCreateInfo vertexInputState = vks::initializers::pipelineVertexInputStateCreateInfo();
|
VkPipelineVertexInputStateCreateInfo vertexInputState = vks::initializers::pipelineVertexInputStateCreateInfo();
|
||||||
|
|
@ -361,25 +360,31 @@ public:
|
||||||
// Do the actual blit from the swapchain image to our host visible destination image
|
// Do the actual blit from the swapchain image to our host visible destination image
|
||||||
VkCommandBuffer copyCmd = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
VkCommandBuffer copyCmd = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||||
|
|
||||||
|
VkImageMemoryBarrier imageMemoryBarrier = vks::initializers::imageMemoryBarrier();
|
||||||
|
|
||||||
// Transition destination image to transfer destination layout
|
// Transition destination image to transfer destination layout
|
||||||
vks::tools::setImageLayout(
|
vks::tools::insertImageMemoryBarrier(
|
||||||
copyCmd,
|
copyCmd,
|
||||||
dstImage,
|
dstImage,
|
||||||
VK_IMAGE_ASPECT_COLOR_BIT,
|
0,
|
||||||
|
VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||||
VK_IMAGE_LAYOUT_UNDEFINED,
|
VK_IMAGE_LAYOUT_UNDEFINED,
|
||||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||||
VK_PIPELINE_STAGE_TRANSFER_BIT,
|
VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||||
VK_PIPELINE_STAGE_TRANSFER_BIT);
|
VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||||
|
VkImageSubresourceRange{ VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 });
|
||||||
|
|
||||||
// Transition swapchain image from present to transfer source layout
|
// Transition swapchain image from present to transfer source layout
|
||||||
vks::tools::setImageLayout(
|
vks::tools::insertImageMemoryBarrier(
|
||||||
copyCmd,
|
copyCmd,
|
||||||
srcImage,
|
srcImage,
|
||||||
VK_IMAGE_ASPECT_COLOR_BIT,
|
VK_ACCESS_MEMORY_READ_BIT,
|
||||||
|
VK_ACCESS_TRANSFER_READ_BIT,
|
||||||
VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,
|
VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,
|
||||||
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||||
VK_PIPELINE_STAGE_TRANSFER_BIT,
|
VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||||
VK_PIPELINE_STAGE_TRANSFER_BIT);
|
VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||||
|
VkImageSubresourceRange{ VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 });
|
||||||
|
|
||||||
// If source and destination support blit we'll blit as this also does automatic format conversion (e.g. from BGR to RGB)
|
// If source and destination support blit we'll blit as this also does automatic format conversion (e.g. from BGR to RGB)
|
||||||
if (supportsBlit)
|
if (supportsBlit)
|
||||||
|
|
@ -428,24 +433,28 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transition destination image to general layout, which is the required layout for mapping the image memory later on
|
// Transition destination image to general layout, which is the required layout for mapping the image memory later on
|
||||||
vks::tools::setImageLayout(
|
vks::tools::insertImageMemoryBarrier(
|
||||||
copyCmd,
|
copyCmd,
|
||||||
dstImage,
|
dstImage,
|
||||||
VK_IMAGE_ASPECT_COLOR_BIT,
|
VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||||
|
VK_ACCESS_MEMORY_READ_BIT,
|
||||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||||
VK_IMAGE_LAYOUT_GENERAL,
|
VK_IMAGE_LAYOUT_GENERAL,
|
||||||
VK_PIPELINE_STAGE_TRANSFER_BIT,
|
VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||||
VK_PIPELINE_STAGE_TRANSFER_BIT);
|
VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||||
|
VkImageSubresourceRange{ VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 });
|
||||||
|
|
||||||
// Transition back the swap chain image after the blit is done
|
// Transition back the swap chain image after the blit is done
|
||||||
vks::tools::setImageLayout(
|
vks::tools::insertImageMemoryBarrier(
|
||||||
copyCmd,
|
copyCmd,
|
||||||
srcImage,
|
srcImage,
|
||||||
VK_IMAGE_ASPECT_COLOR_BIT,
|
VK_ACCESS_TRANSFER_READ_BIT,
|
||||||
|
VK_ACCESS_MEMORY_READ_BIT,
|
||||||
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||||
VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,
|
VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,
|
||||||
VK_PIPELINE_STAGE_TRANSFER_BIT,
|
VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||||
VK_PIPELINE_STAGE_TRANSFER_BIT);
|
VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||||
|
VkImageSubresourceRange{ VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 });
|
||||||
|
|
||||||
vulkanDevice->flushCommandBuffer(copyCmd, queue);
|
vulkanDevice->flushCommandBuffer(copyCmd, queue);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue