Vulkan: Fix MSAA swapchain resolve out of render pass .. vs the optimization that transitions the swapchain image to PRESENT_SRC as part of the render pass. When the swapchain image is the resolve attachment, its layout is decided when the render pass is closed (or through manual calls to finalizeImageLayout()). If the render area forbids the swapchain image from becoming the resolve attachment, it must be resolved after the render pass. Prior to this change, the swapchain image was still marked for transition to PRESENT_SRC by the render pass. This is inefficient, as the following out-of-render-pass resolve would have to transition the image back out of PRESENT_SRC. Nevertheless, this also had a bug exposed by an ASSERT in the dynamic rendering path: * Before the out-of-render-pass resolve, the image layouts are forcefully finalized. * The code in finalizeImageLayout() checks which image is being finalized; if the image is not any of the ones in the render pass, it was silently ignored. * The image marked for transition to PRESENT_SRC (mImageOptimizeForPresent) is not separately checked, as it is expected to be an attachment as well. The code that optimized the final render pass always marked the swapchain image for optimization, even if it was not going to become the resolve attachment. This change makes sure this optimization is done only if the image is definitely an attachment of the render pass. Bug: angleproject:389048224 Change-Id: I9f451d2698944111ac96bd97fefd6efa23859b7f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6168388 Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Yuxin Hu <yuxinhu@google.com>