+/**
+ * Update the swapchain status with the result of an operation, and return
+ * the combined status. The chain status will eventually be returned from
+ * AcquireNextImage and QueuePresent.
+ *
+ * We make sure to 'stick' more pessimistic statuses: an out-of-date error
+ * is permanent once seen, and every subsequent call will return this. If
+ * this has not been seen, success will be returned.
+ */
+static VkResult
+x11_swapchain_result(struct x11_swapchain *chain, VkResult result)
+{
+ /* Prioritise returning existing errors for consistency. */
+ if (chain->status < 0)
+ return chain->status;
+
+ /* If we have a new error, mark it as permanent on the chain and return. */
+ if (result < 0) {
+ chain->status = result;
+ return result;
+ }
+
+ /* Return temporary errors, but don't persist them. */
+ if (result == VK_TIMEOUT || result == VK_NOT_READY)
+ return result;
+
+ /* No changes, so return the last status. */
+ return chain->status;
+}
+