@@ -146,13 +146,6 @@ void SwapchainInfoVk::Create()
146
146
UnrecoverableError (" Failed to create semaphore for swapchain acquire" );
147
147
}
148
148
149
- VkFenceCreateInfo fenceInfo = {};
150
- fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
151
- fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT;
152
- result = vkCreateFence (m_logicalDevice, &fenceInfo, nullptr , &m_imageAvailableFence);
153
- if (result != VK_SUCCESS)
154
- UnrecoverableError (" Failed to create fence for swapchain" );
155
-
156
149
m_acquireIndex = 0 ;
157
150
hasDefinedSwapchainImage = false ;
158
151
}
@@ -184,12 +177,6 @@ void SwapchainInfoVk::Cleanup()
184
177
m_swapchainFramebuffers.clear ();
185
178
186
179
187
- if (m_imageAvailableFence)
188
- {
189
- WaitAvailableFence ();
190
- vkDestroyFence (m_logicalDevice, m_imageAvailableFence, nullptr );
191
- m_imageAvailableFence = nullptr ;
192
- }
193
180
if (m_swapchain)
194
181
{
195
182
vkDestroySwapchainKHR (m_logicalDevice, m_swapchain, nullptr );
@@ -202,34 +189,25 @@ bool SwapchainInfoVk::IsValid() const
202
189
return m_swapchain && !m_acquireSemaphores.empty ();
203
190
}
204
191
205
- void SwapchainInfoVk::WaitAvailableFence ()
206
- {
207
- if (m_awaitableFence != VK_NULL_HANDLE)
208
- vkWaitForFences (m_logicalDevice, 1 , &m_awaitableFence, VK_TRUE, UINT64_MAX);
209
- m_awaitableFence = VK_NULL_HANDLE;
210
- }
211
-
212
- void SwapchainInfoVk::ResetAvailableFence () const
213
- {
214
- vkResetFences (m_logicalDevice, 1 , &m_imageAvailableFence);
215
- }
216
-
217
192
VkSemaphore SwapchainInfoVk::ConsumeAcquireSemaphore ()
218
193
{
219
194
VkSemaphore ret = m_currentSemaphore;
220
195
m_currentSemaphore = VK_NULL_HANDLE;
221
196
return ret;
222
197
}
223
198
224
- bool SwapchainInfoVk::AcquireImage (uint64 timeout )
199
+ bool SwapchainInfoVk::AcquireImage ()
225
200
{
226
- WaitAvailableFence ();
227
- ResetAvailableFence ();
228
-
229
201
VkSemaphore acquireSemaphore = m_acquireSemaphores[m_acquireIndex];
230
- VkResult result = vkAcquireNextImageKHR (m_logicalDevice, m_swapchain, timeout , acquireSemaphore, m_imageAvailableFence , &swapchainImageIndex);
202
+ VkResult result = vkAcquireNextImageKHR (m_logicalDevice, m_swapchain, 1'000'000'000 , acquireSemaphore, nullptr , &swapchainImageIndex);
231
203
if (result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_SUBOPTIMAL_KHR)
232
204
m_shouldRecreate = true ;
205
+ if (result == VK_TIMEOUT)
206
+ {
207
+ swapchainImageIndex = -1 ;
208
+ return false ;
209
+ }
210
+
233
211
if (result < 0 )
234
212
{
235
213
swapchainImageIndex = -1 ;
@@ -238,7 +216,6 @@ bool SwapchainInfoVk::AcquireImage(uint64 timeout)
238
216
return false ;
239
217
}
240
218
m_currentSemaphore = acquireSemaphore;
241
- m_awaitableFence = m_imageAvailableFence;
242
219
m_acquireIndex = (m_acquireIndex + 1 ) % m_swapchainImages.size ();
243
220
244
221
return true ;
0 commit comments