Fix vkQueuePresentKHR is pResults is not null.

pResults was not getting filled in correctly.

As per the spec:

pResults is an array of VkResult typed elements with
swapchainCount entries. Applications that do not
need per-swapchain results can use NULL for pResults.
If non-NULL, each entry in pResults will be set to the VkResult
for presenting the swapchain corresponding to the same index
in pSwapchains.

Bug: b/144766511

Change-Id: I42fcb6d96218d4dbfa60e857226c0aed72e7d8ca
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/38369
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Presubmit-Ready: Chris Forbes <chrisforbes@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
Tested-by: Andrew Woloszyn <awoloszyn@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
diff --git a/src/Vulkan/VkQueue.cpp b/src/Vulkan/VkQueue.cpp
index c38b42c..25e30e9 100644
--- a/src/Vulkan/VkQueue.cpp
+++ b/src/Vulkan/VkQueue.cpp
@@ -219,7 +219,7 @@
 	// Need to correctly implement threading using VkSemaphore
 	// to get rid of it. b/132458423
 	waitIdle();
-
+	VkResult result = VK_SUCCESS;
 	for(uint32_t i = 0; i < presentInfo->waitSemaphoreCount; i++)
 	{
 		vk::Cast(presentInfo->pWaitSemaphores[i])->wait();
@@ -227,12 +227,16 @@
 
 	for(uint32_t i = 0; i < presentInfo->swapchainCount; i++)
 	{
-		VkResult result = vk::Cast(presentInfo->pSwapchains[i])->present(presentInfo->pImageIndices[i]);
-		if (result != VK_SUCCESS)
-			return result;
+		VkResult res = vk::Cast(presentInfo->pSwapchains[i])->present(presentInfo->pImageIndices[i]);
+		if (presentInfo->pResults != nullptr)
+		{
+			presentInfo->pResults[i] = res;
+		}
+		if (res != VK_SUCCESS)
+			result = res;
 	}
 
-	return VK_SUCCESS;
+	return result;
 }
 #endif