From d185eb8218cca2b0946e02f52223d38d966f90b9 Mon Sep 17 00:00:00 2001 From: Sasha Szpakowski Date: Fri, 27 Sep 2024 19:50:11 -0300 Subject: [PATCH] vulkan: fix validation errors when generating mipmaps for a compute-writable texture. --- src/modules/graphics/vulkan/Texture.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/modules/graphics/vulkan/Texture.cpp b/src/modules/graphics/vulkan/Texture.cpp index bd61566c9..ffc5be7fe 100644 --- a/src/modules/graphics/vulkan/Texture.cpp +++ b/src/modules/graphics/vulkan/Texture.cpp @@ -491,11 +491,22 @@ void Texture::generateMipmapsInternal() blit.dstSubresource.baseArrayLayer = rootView.startLayer; blit.dstSubresource.layerCount = static_cast(layerCount); - vkCmdBlitImage(commandBuffer, - textureImage, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, - textureImage, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, - 1, &blit, - VK_FILTER_LINEAR); + if (imageLayout != VK_IMAGE_LAYOUT_GENERAL) + { + vkCmdBlitImage(commandBuffer, + textureImage, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + textureImage, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, + 1, &blit, + VK_FILTER_LINEAR); + } + else + { + vkCmdBlitImage(commandBuffer, + textureImage, VK_IMAGE_LAYOUT_GENERAL, + textureImage, VK_IMAGE_LAYOUT_GENERAL, + 1, &blit, + VK_FILTER_LINEAR); + } barrier.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; barrier.newLayout = imageLayout;