Skip to content

Commit d37770f

Browse files
committed
fix and remove assumption that imageCount == acquiresInFlight
1 parent 6c0b3cb commit d37770f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/nbl/video/CVulkanSwapchain.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,10 @@ CVulkanSwapchain::CVulkanSwapchain(
171171
const uint8_t maxAcquiresBeforePresent,
172172
const uint8_t maxAcquiresInFlight)
173173
: 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)
175178
{
176179
// we've got it from here!
177180
if (m_oldSwapchain)
@@ -205,15 +208,15 @@ CVulkanSwapchain::~CVulkanSwapchain()
205208
.sType = VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO,
206209
.pNext = nullptr,
207210
.flags = 0,
208-
.semaphoreCount = getImageCount(),
211+
.semaphoreCount = getMaxAcquiresInFlight(),
209212
.pSemaphores = m_prePresentSemaphores,
210213
.pValues = m_perImageAcquireCount
211214
};
212215
while (true) // if you find yourself spinning here forever, it might be because you didn't present an already acquired image
213216
if (vk.vkWaitSemaphores(vk_device,&info,~0ull)!=VK_TIMEOUT)
214217
break;
215218

216-
for (auto i=0u; i<getImageCount(); i++)
219+
for (auto i=0u; i<getMaxAcquiresInFlight(); i++)
217220
{
218221
vk.vkDestroySemaphore(vk_device,m_acquireAdaptorSemaphores[i],nullptr);
219222
vk.vkDestroySemaphore(vk_device,m_prePresentSemaphores[i],nullptr);
@@ -248,7 +251,7 @@ auto CVulkanSwapchain::acquireNextImage_impl(const SAcquireInfo& info, uint32_t*
248251
const VkSemaphoreSubmitInfo adaptorInfo = {
249252
.sType = VK_STRUCTURE_TYPE_SEMAPHORE_SUBMIT_INFO,
250253
.pNext = nullptr,
251-
.semaphore = m_acquireAdaptorSemaphores[getAcquireCount()%getImageCount()],
254+
.semaphore = m_acquireAdaptorSemaphores[getAcquireCount()%getMaxAcquiresInFlight()],
252255
.value = 0, // value is ignored because the adaptors are binary
253256
.stageMask = VK_PIPELINE_STAGE_2_NONE,
254257
.deviceIndex = 0u // TODO: later obtain device index from swapchain

0 commit comments

Comments
 (0)