From 315c8d75bcf22f7778cbccc63dffe4b39378bfab Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Fri, 28 Jun 2024 12:12:27 -0700 Subject: [PATCH] vk: repair transmission + MSAA That code was changed as part as what looked like a refactoring unrelated to the descriptor-set change itself. Reverting that thunk fixes the problem, however the revert doesn't have the layout transitions that were added. This PR reverts back to the old behavior, but adds the layout transitions. It looks like the refactored code didn't handle "auto resolve" anymore. --- filament/backend/src/vulkan/VulkanDriver.cpp | 30 +++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/filament/backend/src/vulkan/VulkanDriver.cpp b/filament/backend/src/vulkan/VulkanDriver.cpp index 83413208a1..a9e402e3ec 100644 --- a/filament/backend/src/vulkan/VulkanDriver.cpp +++ b/filament/backend/src/vulkan/VulkanDriver.cpp @@ -1328,28 +1328,36 @@ void VulkanDriver::beginRenderPass(Handle rth, const RenderPassP fbkey.resolve[i] = VK_NULL_HANDLE; continue; } - auto const& range = attachment.getSubresourceRange(); - attachment.texture->transitionLayout(&commands, range, VulkanLayout::COLOR_ATTACHMENT); - renderPassAttachments.insert(attachment); if (fbkey.samples == 1) { + auto const& range = attachment.getSubresourceRange(); + attachment.texture->transitionLayout(&commands, + range, VulkanLayout::COLOR_ATTACHMENT); + renderPassAttachments.insert(attachment); fbkey.color[i] = attachment.getImageView(); fbkey.resolve[i] = VK_NULL_HANDLE; assert_invariant(fbkey.color[i]); } else { auto& msaaColorAttachment = rt->getMsaaColor(i); auto const& msaaRange = attachment.getSubresourceRange(); + msaaColorAttachment.texture->transitionLayout(&commands, + msaaRange, VulkanLayout::COLOR_ATTACHMENT); renderPassAttachments.insert(msaaColorAttachment); - msaaColorAttachment.texture->transitionLayout(&commands, msaaRange, - VulkanLayout::COLOR_ATTACHMENT); + fbkey.color[i] = msaaColorAttachment.getImageView(); + + VulkanTexture* texture = attachment.texture; + if (texture->samples == 1) { + mRenderPassFboInfo.hasColorResolve = true; + + auto const& range = attachment.getSubresourceRange(); + attachment.texture->transitionLayout(&commands, + range, VulkanLayout::COLOR_ATTACHMENT); + renderPassAttachments.insert(attachment); + fbkey.resolve[i] = attachment.getImageView(); + assert_invariant(fbkey.resolve[i]); + } assert_invariant(fbkey.color[i]); - - assert_invariant(attachment.texture->samples == 1); - - mRenderPassFboInfo.hasColorResolve = true; - fbkey.resolve[i] = attachment.getImageView(); - assert_invariant(fbkey.resolve[i]); } } if (depth.texture) {