Synchronize before performing mid-subpass attachment clears

Bug: b/119620767
Test: dEQP-VK.renderpass*
Change-Id: I749c26e9924d69735f45ca981957016718fe5b0a
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/29708
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
diff --git a/src/Vulkan/VkCommandBuffer.cpp b/src/Vulkan/VkCommandBuffer.cpp
index f347421..9a25dad 100644
--- a/src/Vulkan/VkCommandBuffer.cpp
+++ b/src/Vulkan/VkCommandBuffer.cpp
@@ -765,6 +765,10 @@
 
 	void play(CommandBuffer::ExecutionState& executionState) override
 	{
+		// attachment clears are drawing operations, and so have rasterization-order guarantees.
+		// however, we don't do the clear through the rasterizer, so need to ensure prior drawing
+		// has completed first.
+		executionState.renderer->synchronize();
 		executionState.renderPassFramebuffer->clear(executionState.renderPass, attachment, rect);
 	}