首页 > 解决方案 > 等待围栏会导致警告和应用程序冻结

问题描述

我提交了一个队列并指定了一个栅栏。就在提交之前,我打印了栅栏:

qDebug() << "submitting fence: " << cmdFence;
vkQueueSubmit(gfxQueue, 1, &submitInfo, cmdFence);

以下是最近 3 次提交的结果:

submitting fence:  0x145
submitting fence:  0x142
submitting fence:  0x145

在其他地方我有一个应该等待栅栏的代码:

qDebug() << "waiting for fences";
for(auto f : activeFences)
    qDebug() << "fence " << f;

if(vkWaitForFences(m_moduleData.deviceData.device,
                   static_cast<uint32_t>(activeFences.size()),
                   activeFences.data(),
                   VK_TRUE,
                   UINT64_MAX) != VK_SUCCESS)
{
    throw std::runtime_error{"failed to wait for fences"};
}

可以看出,在等待之前我也在打印围栏,这就是我在vkWaitForFences打电话之前得到的:

waiting for fences
fence  0x142

0x142之前提交的同一个栅栏!但是验证层会产生警告:

vkWaitForFences called for fence 0x142 which has not been submitted on a Queue or during acquire next image.

并且应用程序可能会在无限等待中冻结。但为什么?

标签: vulkan

解决方案


推荐阅读