Browse Source

vulkan: fix validation errors when generating mipmaps for a compute-writable texture.

Sasha Szpakowski 11 months ago
parent
commit
d185eb8218
1 changed files with 16 additions and 5 deletions
  1. 16 5
      src/modules/graphics/vulkan/Texture.cpp

+ 16 - 5
src/modules/graphics/vulkan/Texture.cpp

@@ -491,11 +491,22 @@ void Texture::generateMipmapsInternal()
 		blit.dstSubresource.baseArrayLayer = rootView.startLayer;
 		blit.dstSubresource.layerCount = static_cast<uint32_t>(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;