コード例 #1
0
        public unsafe void TransferImageLayout(
            VkImage image,
            VkFormat format,
            VkImageLayout oldLayout,
            VkImageLayout newLayout,
            uint mipLevel = 0
            )
        {
            var aspect           = GetAspectFlags(image.Handle, format, newLayout);
            var sourceFlags      = GetImageTransferFlags(oldLayout);
            var destinationFlags = GetImageTransferFlags(newLayout);

            var barrier = new VkImageMemoryBarrier
            {
                sType               = VkStructureType.ImageMemoryBarrier,
                oldLayout           = oldLayout,
                newLayout           = newLayout,
                srcQueueFamilyIndex = VulkanNative.QueueFamilyIgnored,
                dstQueueFamilyIndex = VulkanNative.QueueFamilyIgnored,
                image               = image.Handle,
                srcAccessMask       = sourceFlags.Key,
                dstAccessMask       = destinationFlags.Key,
                subresourceRange    = new VkImageSubresourceRange
                {
                    aspectMask     = aspect,
                    baseMipLevel   = mipLevel,
                    levelCount     = 1,
                    baseArrayLayer = 0,
                    layerCount     = 1,
                }
            };

            VulkanNative.vkCmdPipelineBarrier(
                _handle,
                sourceFlags.Value,
                destinationFlags.Value,
                0, 0, null, 0, null,
                1,
                &barrier
                );
        }