• Breaking News

    Texture not transitioning on copy queue I cannot seem to eliminate some Vulkan debug layer errors regarding to incorrect texture layout (but the textures seem to work fine in practice). The debug layer is complaining that textures should be in VK_IMAGE_LAYOUT_GENERAL, but they are in VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL I am uploading texture data via vkCmdCopyBufferToImage using the copy queue, but later in the frame I will use those textures on the graphics queue. The textures are created with VK_IMAGE_LAYOUT_UNDEFINED initial layout, so before issuing vkCmdCopyBufferToImage , I transition them to VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, by inserting a barrier like this: VkImageMemoryBarrier barrier = {}; barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; barrier.image = (VkImage)pTexture2D->resource; barrier.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; barrier.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; barrier.srcAccessMask = 0; barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; barrier.subresourceRange.baseArrayLayer = 0; barrier.subresourceRange.layerCount = pDesc->ArraySize; barrier.subresourceRange.baseMipLevel = 0; barrier.subresourceRange.levelCount = pDesc->MipLevels; barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; vkCmdPipelineBarrier( copyCommandBuffer, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1, &barrier ); The src and dst queue families are ignored, because The following command using the texture is still executed on the copy queue: vkCmdCopyBufferToImage(copyCommandBuffer, textureUploader->resource, (VkImage)pTexture2D->resource, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, (uint32_t)copyRegions.size(), copyRegions.data()); Then I want to transition the texture from transferrable resource to VK_IMAGE_LAYOUT_GENERAL, to be used by the graphics pipeline, so I want to also transfer ownership to the graphics queue family with the barrier: barrier.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; barrier.newLayout = VK_IMAGE_LAYOUT_GENERAL; barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT; barrier.srcQueueFamilyIndex = queueIndices.copyFamily; barrier.dstQueueFamilyIndex = queueIndices.graphicsFamily; vkCmdPipelineBarrier( copyCommandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, 0, nullptr, 1, &barrier ); The texture that I create like this will be either sampled by shaders, or used as read-write texture from compute shaders. Did I miss something, or can I not transfer image layout like this between queues? https://ift.tt/eA8V8J

    I cannot seem to eliminate some Vulkan debug layer errors regarding to incorrect texture layout (but the textures seem to work fine in practice). The debug layer is complaining that textures should be in VK_IMAGE_LAYOUT_GENERAL, but they are in VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL I am uploading texture data via vkCmdCopyBufferToImage using the copy queue, but later in the frame I will use those textures on the graphics queue. The textures are created with VK_IMAGE_LAYOUT_UNDEFINED initial layout, so before issuing vkCmdCopyBufferToImage , I transition them to VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, by inserting a barrier like this: VkImageMemoryBarrier barrier = {}; barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; barrier.image = (VkImage)pTexture2D->resource; barrier.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; barrier.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; barrier.srcAccessMask = 0; barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; barrier.subresourceRange.baseArrayLayer = 0; barrier.subresourceRange.layerCount = pDesc->ArraySize; barrier.subresourceRange.baseMipLevel = 0; barrier.subresourceRange.levelCount = pDesc->MipLevels; barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; vkCmdPipelineBarrier( copyCommandBuffer, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1, &barrier ); The src and dst queue families are ignored, because The following command using the texture is still executed on the copy queue: vkCmdCopyBufferToImage(copyCommandBuffer, textureUploader->resource, (VkImage)pTexture2D->resource, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, (uint32_t)copyRegions.size(), copyRegions.data()); Then I want to transition the texture from transferrable resource to VK_IMAGE_LAYOUT_GENERAL, to be used by the graphics pipeline, so I want to also transfer ownership to the graphics queue family with the barrier: barrier.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; barrier.newLayout = VK_IMAGE_LAYOUT_GENERAL; barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT; barrier.srcQueueFamilyIndex = queueIndices.copyFamily; barrier.dstQueueFamilyIndex = queueIndices.graphicsFamily; vkCmdPipelineBarrier( copyCommandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, 0, nullptr, 1, &barrier ); The texture that I create like this will be either sampled by shaders, or used as read-write texture from compute shaders. Did I miss something, or can I not transfer image layout like this between queues?

    from GameDev.net https://ift.tt/2lti7mu

    ليست هناك تعليقات

    Post Top Ad

    ad728

    Post Bottom Ad

    ad728