Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/HansKristian-Work/vkd3d-proton.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Kristian Arntzen <post@arntzen-software.no>2021-06-02 16:21:54 +0300
committerHans-Kristian Arntzen <post@arntzen-software.no>2021-06-02 20:26:43 +0300
commit72514a24cb96162d637995e84197454c3259765d (patch)
tree47e4b47f0769584667f8824628e2f7cb22cbf8a4
parent0cacf0948306207e40b13a736abac222ca607324 (diff)
vkd3d: Ensure that swapchain is eventually recreated.low-latency-present
Latch SUBOPTIMAL state. Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
-rw-r--r--libs/vkd3d/swapchain.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/libs/vkd3d/swapchain.c b/libs/vkd3d/swapchain.c
index 1838cc35..42c5f109 100644
--- a/libs/vkd3d/swapchain.c
+++ b/libs/vkd3d/swapchain.c
@@ -190,6 +190,7 @@ struct d3d12_swapchain
unsigned int vk_swapchain_width;
unsigned int vk_swapchain_height;
VkPresentModeKHR present_mode;
+ bool is_suboptimal;
struct
{
@@ -1499,6 +1500,7 @@ static HRESULT d3d12_swapchain_create_vulkan_swapchain(struct d3d12_swapchain *s
swapchain->vk_swapchain_height = height;
swapchain->vk_image_index = INVALID_VK_IMAGE_INDEX;
+ swapchain->is_suboptimal = false;
if (swapchain->vk_swapchain != VK_NULL_HANDLE)
{
@@ -1745,7 +1747,13 @@ static VkResult d3d12_swapchain_queue_present(struct d3d12_swapchain *swapchain,
VK_NULL_HANDLE, &swapchain->vk_image_index);
if (vr >= 0)
+ {
swapchain->vk_acquire_semaphores_signaled[swapchain->frame_id] = true;
+ /* If we have observed suboptimal once, guarantees that we keep observing it
+ * until we have recreated the swapchain. */
+ if (swapchain->is_suboptimal)
+ vr = VK_SUBOPTIMAL_KHR;
+ }
if (vr == VK_SUBOPTIMAL_KHR)
{
@@ -1810,6 +1818,14 @@ static VkResult d3d12_swapchain_queue_present(struct d3d12_swapchain *swapchain,
swapchain->frame_id = (swapchain->frame_id + 1) % swapchain->buffer_count;
swapchain->vk_image_index = INVALID_VK_IMAGE_INDEX;
+ if (vr == VK_SUBOPTIMAL_KHR)
+ swapchain->is_suboptimal = true;
+
+ /* If we have observed suboptimal once, guarantees that we keep observing it
+ * until we have recreated the swapchain. */
+ if (swapchain->is_suboptimal)
+ vr = VK_SUBOPTIMAL_KHR;
+
/* Could get SUBOPTIMAL here. Defer acquiring if we hit that path.
* On next present, we can recreate the swapchain. */
if (vr == VK_SUCCESS)
@@ -1823,6 +1839,12 @@ static VkResult d3d12_swapchain_queue_present(struct d3d12_swapchain *swapchain,
if (vr >= 0)
{
swapchain->vk_acquire_semaphores_signaled[swapchain->frame_id] = true;
+ /* If we observe suboptimal here, we cannot set INVALID_VK_IMAGE_INDEX yet,
+ * since the next present will acquire again, before we have had a chance to present.
+ * This can potentially deadlock, or cause other weirdness that we're not ready to handle.
+ * Mark the swapchain is suboptimal, so that we're guaranteed to recreate the swapchain in due time. */
+ if (vr == VK_SUBOPTIMAL_KHR)
+ swapchain->is_suboptimal = true;
}
else
{