@@ -171,7 +171,10 @@ CVulkanSwapchain::CVulkanSwapchain(
171
171
const uint8_t maxAcquiresBeforePresent,
172
172
const uint8_t maxAcquiresInFlight)
173
173
: ISwapchain(std::move(logicalDevice),std::move(params),imageCount,std::move(oldSwapchain)),
174
- m_imgMemRequirements{.size =0 ,.memoryTypeBits =0x0u ,.alignmentLog2 =63 ,.prefersDedicatedAllocation =true ,.requiresDedicatedAllocation =true }, m_vkSwapchainKHR(swapchain), m_maxBlockingAcquiresBeforePresent(maxAcquiresBeforePresent)
174
+ m_imgMemRequirements{.size =0 ,.memoryTypeBits =0x0u ,.alignmentLog2 =63 ,.prefersDedicatedAllocation =true ,.requiresDedicatedAllocation =true },
175
+ m_vkSwapchainKHR (swapchain),
176
+ m_maxBlockingAcquiresBeforePresent (maxAcquiresBeforePresent),
177
+ m_maxAcquiresInFlight (maxAcquiresInFlight)
175
178
{
176
179
// we've got it from here!
177
180
if (m_oldSwapchain)
@@ -205,15 +208,15 @@ CVulkanSwapchain::~CVulkanSwapchain()
205
208
.sType = VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO,
206
209
.pNext = nullptr ,
207
210
.flags = 0 ,
208
- .semaphoreCount = getImageCount (),
211
+ .semaphoreCount = getMaxAcquiresInFlight (),
209
212
.pSemaphores = m_prePresentSemaphores,
210
213
.pValues = m_perImageAcquireCount
211
214
};
212
215
while (true ) // if you find yourself spinning here forever, it might be because you didn't present an already acquired image
213
216
if (vk.vkWaitSemaphores (vk_device,&info,~0ull )!=VK_TIMEOUT)
214
217
break ;
215
218
216
- for (auto i=0u ; i<getImageCount (); i++)
219
+ for (auto i=0u ; i<getMaxAcquiresInFlight (); i++)
217
220
{
218
221
vk.vkDestroySemaphore (vk_device,m_acquireAdaptorSemaphores[i],nullptr );
219
222
vk.vkDestroySemaphore (vk_device,m_prePresentSemaphores[i],nullptr );
@@ -248,7 +251,7 @@ auto CVulkanSwapchain::acquireNextImage_impl(const SAcquireInfo& info, uint32_t*
248
251
const VkSemaphoreSubmitInfo adaptorInfo = {
249
252
.sType = VK_STRUCTURE_TYPE_SEMAPHORE_SUBMIT_INFO,
250
253
.pNext = nullptr ,
251
- .semaphore = m_acquireAdaptorSemaphores[getAcquireCount ()%getImageCount ()],
254
+ .semaphore = m_acquireAdaptorSemaphores[getAcquireCount ()%getMaxAcquiresInFlight ()],
252
255
.value = 0 , // value is ignored because the adaptors are binary
253
256
.stageMask = VK_PIPELINE_STAGE_2_NONE,
254
257
.deviceIndex = 0u // TODO: later obtain device index from swapchain
0 commit comments