Added setImageLayout overload for passing image sub resource range, src access mask for VK_IMAGE_LAYOUT_PREINITIALIZED (#29)
This commit is contained in:
parent
a3ae911e27
commit
7b52dd7cc9
2 changed files with 35 additions and 9 deletions
|
|
@ -104,25 +104,28 @@ namespace vkTools
|
||||||
// Create an image memory barrier for changing the layout of
|
// Create an image memory barrier for changing the layout of
|
||||||
// an image and put it into an active command buffer
|
// an image and put it into an active command buffer
|
||||||
// See chapter 11.4 "Image Layout" for details
|
// See chapter 11.4 "Image Layout" for details
|
||||||
//todo : rename
|
|
||||||
void setImageLayout(VkCommandBuffer cmdbuffer, VkImage image, VkImageAspectFlags aspectMask, VkImageLayout oldImageLayout, VkImageLayout newImageLayout)
|
void setImageLayout(
|
||||||
|
VkCommandBuffer cmdbuffer,
|
||||||
|
VkImage image,
|
||||||
|
VkImageAspectFlags aspectMask,
|
||||||
|
VkImageLayout oldImageLayout,
|
||||||
|
VkImageLayout newImageLayout,
|
||||||
|
VkImageSubresourceRange subresourceRange)
|
||||||
{
|
{
|
||||||
// Create an image barrier object
|
// Create an image barrier object
|
||||||
VkImageMemoryBarrier imageMemoryBarrier = vkTools::initializers::imageMemoryBarrier();
|
VkImageMemoryBarrier imageMemoryBarrier = vkTools::initializers::imageMemoryBarrier();
|
||||||
imageMemoryBarrier.oldLayout = oldImageLayout;
|
imageMemoryBarrier.oldLayout = oldImageLayout;
|
||||||
imageMemoryBarrier.newLayout = newImageLayout;
|
imageMemoryBarrier.newLayout = newImageLayout;
|
||||||
imageMemoryBarrier.image = image;
|
imageMemoryBarrier.image = image;
|
||||||
imageMemoryBarrier.subresourceRange.aspectMask = aspectMask;
|
imageMemoryBarrier.subresourceRange = subresourceRange;
|
||||||
imageMemoryBarrier.subresourceRange.baseMipLevel = 0;
|
|
||||||
imageMemoryBarrier.subresourceRange.levelCount = 1;
|
|
||||||
imageMemoryBarrier.subresourceRange.layerCount = 1;
|
|
||||||
|
|
||||||
// Source layouts (old)
|
// Source layouts (old)
|
||||||
|
|
||||||
// Undefined layout
|
// Undefined layout
|
||||||
// Only allowed as initial layout!
|
// Only allowed as initial layout!
|
||||||
// Make sure any writes to the image have been finished
|
// Make sure any writes to the image have been finished
|
||||||
if (oldImageLayout == VK_IMAGE_LAYOUT_UNDEFINED)
|
if (oldImageLayout == VK_IMAGE_LAYOUT_PREINITIALIZED)
|
||||||
{
|
{
|
||||||
imageMemoryBarrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT | VK_ACCESS_TRANSFER_WRITE_BIT;
|
imageMemoryBarrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT | VK_ACCESS_TRANSFER_WRITE_BIT;
|
||||||
}
|
}
|
||||||
|
|
@ -195,7 +198,6 @@ namespace vkTools
|
||||||
imageMemoryBarrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT;
|
imageMemoryBarrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Put barrier on top
|
// Put barrier on top
|
||||||
VkPipelineStageFlags srcStageFlags = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
|
VkPipelineStageFlags srcStageFlags = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
|
||||||
VkPipelineStageFlags destStageFlags = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
|
VkPipelineStageFlags destStageFlags = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
|
||||||
|
|
@ -211,6 +213,22 @@ namespace vkTools
|
||||||
1, &imageMemoryBarrier);
|
1, &imageMemoryBarrier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fixed sub resource on first mip level and layer
|
||||||
|
void setImageLayout(
|
||||||
|
VkCommandBuffer cmdbuffer,
|
||||||
|
VkImage image,
|
||||||
|
VkImageAspectFlags aspectMask,
|
||||||
|
VkImageLayout oldImageLayout,
|
||||||
|
VkImageLayout newImageLayout)
|
||||||
|
{
|
||||||
|
VkImageSubresourceRange subresourceRange = {};
|
||||||
|
subresourceRange.aspectMask = aspectMask;
|
||||||
|
subresourceRange.baseMipLevel = 0;
|
||||||
|
subresourceRange.levelCount = 1;
|
||||||
|
subresourceRange.layerCount = 1;
|
||||||
|
setImageLayout(cmdbuffer, image, aspectMask, oldImageLayout, newImageLayout, subresourceRange);
|
||||||
|
}
|
||||||
|
|
||||||
void exitFatal(std::string message, std::string caption)
|
void exitFatal(std::string message, std::string caption)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,15 @@ namespace vkTools
|
||||||
// Returns false if none of the depth formats in the list is supported by the device
|
// Returns false if none of the depth formats in the list is supported by the device
|
||||||
VkBool32 getSupportedDepthFormat(VkPhysicalDevice physicalDevice, VkFormat *depthFormat);
|
VkBool32 getSupportedDepthFormat(VkPhysicalDevice physicalDevice, VkFormat *depthFormat);
|
||||||
|
|
||||||
// Put an image memory barrier for setting an image layout into the given command buffer
|
// Put an image memory barrier for setting an image layout on the sub resource into the given command buffer
|
||||||
|
void setImageLayout(
|
||||||
|
VkCommandBuffer cmdbuffer,
|
||||||
|
VkImage image,
|
||||||
|
VkImageAspectFlags aspectMask,
|
||||||
|
VkImageLayout oldImageLayout,
|
||||||
|
VkImageLayout newImageLayout,
|
||||||
|
VkImageSubresourceRange subresourceRange);
|
||||||
|
// Uses a fixed sub resource layout with first mip level and layer
|
||||||
void setImageLayout(
|
void setImageLayout(
|
||||||
VkCommandBuffer cmdbuffer,
|
VkCommandBuffer cmdbuffer,
|
||||||
VkImage image,
|
VkImage image,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue