Vulkan: Fix deferred clear vs robust init vs invalidate The DIRTY_OBJECT_DRAW_ATTACHMENTS bit, when handled, goes over framebuffer attachments and requests that they be cleared. This is done only with robust init. The DIRTY_OBJECT_DRAW_FRAMEBUFFER bit, when handled, results in staged updates to be applied to the attachments. When syncDirtyObjects is called, the above bits are handled. If we end up in a situation where DIRTY_OBJECT_DRAW_ATTACHMENTS is set, but not DIRTY_OBJECT_DRAW_FRAMEBUFFER, the following happens with Vulkan: - Handle DIRTY_OBJECT_DRAW_ATTACHMENTS - TextureVk::initializeContents - ImageHelper::stageResourceClearWithFormat - Observer message to TextureVk->Texture->Framebuffer->Context - Context sets DIRTY_OBJECT_DRAW_FRAMEBUFFER - However syncDirtyObjects does not notice this bit, as it has cached the dirty objects and is in the middle of looping over them In the above scenario, the call that results in syncDirtyObjects does not process the draw framebuffer (if not already dirty for some other reason), meaning the clear is not applied _before_ the current operation but after it (whenever framebuffer is synced next). In this change, I attempted to ensure that if DIRTY_OBJECT_DRAW_ATTACHMENTS is ever dirty, DIRTY_OBJECT_DRAW_FRAMEBUFFER is also dirty. There were a few operations that could theoretically lead to this which are fixed by this change. The particular one that revealed the bug was State::syncDirtyObject syncing only the FRAMEBUFFER bit and leaving the ATTACHMENTS bit for the unsuspecting following operation. The aforementioned assertion is not included in this change however, as it revealed one unresolved issue with the d3d backend where DIRTY_OBJECT_DRAW_ATTACHMENTS is not set, but processing DIRTY_OBJECT_DRAW_ATTACHMENTS sets it while dirty bits are being processed. Bug: b/381284577 Change-Id: If3c35fbade069ae75f66dd6d4df5d73882a08a93 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6621059 Reviewed-by: Yuxin Hu <yuxinhu@google.com> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>