Support switching present modes with swapchain maintenance1

Bug: angleproject:7878
Change-Id: Iae34aa26674aaf2c25d58c64d77b8a949c8db96d
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/70688
Commit-Queue: Shahbaz Youssefi <syoussefi@google.com>
Presubmit-Ready: Shahbaz Youssefi <syoussefi@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Tested-by: Shahbaz Youssefi <syoussefi@google.com>
diff --git a/src/Vulkan/VkQueue.cpp b/src/Vulkan/VkQueue.cpp
index c8fd79c..d0e2965 100644
--- a/src/Vulkan/VkQueue.cpp
+++ b/src/Vulkan/VkQueue.cpp
@@ -197,6 +197,9 @@
 	// to get rid of it. b/132458423
 	waitIdle();
 
+	// Note: VkSwapchainPresentModeInfoEXT can be used to override the present mode, but present
+	// mode is currently ignored by SwiftShader.
+
 	for(uint32_t i = 0; i < presentInfo->waitSemaphoreCount; i++)
 	{
 		auto *semaphore = vk::DynamicCast<BinarySemaphore>(presentInfo->pWaitSemaphores[i]);
diff --git a/src/WSI/VkSurfaceKHR.cpp b/src/WSI/VkSurfaceKHR.cpp
index 05989df..09dac10 100644
--- a/src/WSI/VkSurfaceKHR.cpp
+++ b/src/WSI/VkSurfaceKHR.cpp
@@ -224,16 +224,22 @@
 				const auto *presentMode = vk::GetExtendedStruct<VkSurfacePresentModeEXT>(pSurfaceInfoPNext, VK_STRUCTURE_TYPE_SURFACE_PRESENT_MODE_EXT);
 				ASSERT(presentMode != nullptr);
 
-				// No support for switching between present modes; i.e. each mode is only compatible with itself.
+				// Present mode is ignored, so FIFO and MAILBOX are compatible.
 				if(presentModeCompatibility->pPresentModes == nullptr)
 				{
-					presentModeCompatibility->presentModeCount = 1;
+					presentModeCompatibility->presentModeCount = 2;
 				}
-				else if(presentModeCompatibility->presentModeCount >= 1)
+				else if(presentModeCompatibility->presentModeCount == 1)
 				{
 					presentModeCompatibility->pPresentModes[0] = presentMode->presentMode;
 					presentModeCompatibility->presentModeCount = 1;
 				}
+				else if(presentModeCompatibility->presentModeCount > 1)
+				{
+					presentModeCompatibility->pPresentModes[0] = presentModes[0];
+					presentModeCompatibility->pPresentModes[1] = presentModes[1];
+					presentModeCompatibility->presentModeCount = 2;
+				}
 				break;
 			}
 		default: