Commit 535cd538f3585b44855647339f04bae1c1acf63a

Shahbaz Youssefi 2022-03-29T16:29:58

Vulkan: Fix texture-after-framebuffer sync issues In TextureVk::syncState, for various reasons, the underlying image may need to be respecified. For example because base/max level changed, usage/create flags have changed, the format needs modification to become renderable, generate mipmap is adding levels, etc. Currently, ANGLE syncs FramebufferVk before TextureVk for the sake of the deferred clear optimization. This means that if the texture needs to recreate its underlying image, it needs to do so earlier than its own syncState, and do so in FramebufferVk::syncState through the TextureVk::getAttachmentRenderTarget function. Over time, TextureVk::getAttachmentRenderTarget was modified to do parts of what TextureVk::syncState did for this matter as bugs were discovered, and more continue to be discovered. The bug that prompted this change is missing image recreation when usage/create flags change. In this change, the relevant code in TextureVk::syncState is refactored in a helper that's called by TextureVk::getAttachmentRenderTarget. This way, the two functions should always be in agreement, avoiding TextureVk::syncState recreating the image after FramebufferVk::syncState, leading to use-after-free bugs. Bug: angleproject:4418 Bug: angleproject:6909 Bug: chromium:1266094 Bug: chromium:1296866 Change-Id: I856a34ca5cf573578c771f5adbeb9208420a3f62 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3557817 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>