I have a problem with my Vulkan app using Qt. I’m trying to release buffer resources, but this is the error message iam getting:
<code>vkDebug: Validation Error: [ VUID-vkDestroyBuffer-buffer-00922 ] | MessageID = 0xe4549c11 | vkDestroyBuffer(): can't be called on VkBuffer 0xd68cbb0000000091[] that is currently in use by VkCommandBuffer 0x4959c00[].
<code>vkDebug: Validation Error: [ VUID-vkDestroyBuffer-buffer-00922 ] | MessageID = 0xe4549c11 | vkDestroyBuffer(): can't be called on VkBuffer 0xd68cbb0000000091[] that is currently in use by VkCommandBuffer 0x4959c00[].
</code>
vkDebug: Validation Error: [ VUID-vkDestroyBuffer-buffer-00922 ] | MessageID = 0xe4549c11 | vkDestroyBuffer(): can't be called on VkBuffer 0xd68cbb0000000091[] that is currently in use by VkCommandBuffer 0x4959c00[].
I’ve got buffers that I use for every frame, and i need to release resources, when creating new text with same text name.:
<code>void TextModule::createText(const std::string &fontName, uint32_t fontSize, const std::string &textName, const std::string &text, float scale,
glm::vec2 middlePos, glm::vec2 windowSize, glm::vec4 color, e_TextRenderType renderType)
FontInfo fInfo = s_fontManager.loadedFont(fontName, fontSize);
if (m_texts.find(textName) != m_texts.end())
Window *vw = MainWindow::instance()->vulkanWindow();
for(int i = 0; i < m_instruments->concurrentFrameCount; i++)
m_texts[textName].bufArr[i].releaseResources();
for(int i = 0; i < m_instruments->concurrentFrameCount; i++)
textInfo.bufArr[i].createBuffer({textInfo.textVertices.size() * sizeof(base::graphics::ColorTexVertex)}, {BDSH::VX});
textInfo.bufArr[i].set(textInfo.textVertices.data(), textInfo.textVertices.size() * sizeof(base::graphics::ColorTexVertex));
textInfo.bufArr[i].mapWholeMemory();
textInfo.bufArr[i].update();
textInfo.bufArr[i].unMapMemory();
m_texts[textName] = textInfo;
<code>void TextModule::createText(const std::string &fontName, uint32_t fontSize, const std::string &textName, const std::string &text, float scale,
glm::vec2 middlePos, glm::vec2 windowSize, glm::vec4 color, e_TextRenderType renderType)
{
FontInfo fInfo = s_fontManager.loadedFont(fontName, fontSize);
if (m_texts.find(textName) != m_texts.end())
{
Window *vw = MainWindow::instance()->vulkanWindow();
for(int i = 0; i < m_instruments->concurrentFrameCount; i++)
{
m_texts[textName].bufArr[i].releaseResources();
}
}
//more code
for(int i = 0; i < m_instruments->concurrentFrameCount; i++)
{
textInfo.bufArr[i].createBuffer({textInfo.textVertices.size() * sizeof(base::graphics::ColorTexVertex)}, {BDSH::VX});
textInfo.bufArr[i].set(textInfo.textVertices.data(), textInfo.textVertices.size() * sizeof(base::graphics::ColorTexVertex));
textInfo.bufArr[i].mapWholeMemory();
textInfo.bufArr[i].update();
textInfo.bufArr[i].unMapMemory();
}
m_texts[textName] = textInfo;
</code>
void TextModule::createText(const std::string &fontName, uint32_t fontSize, const std::string &textName, const std::string &text, float scale,
glm::vec2 middlePos, glm::vec2 windowSize, glm::vec4 color, e_TextRenderType renderType)
{
FontInfo fInfo = s_fontManager.loadedFont(fontName, fontSize);
if (m_texts.find(textName) != m_texts.end())
{
Window *vw = MainWindow::instance()->vulkanWindow();
for(int i = 0; i < m_instruments->concurrentFrameCount; i++)
{
m_texts[textName].bufArr[i].releaseResources();
}
}
//more code
for(int i = 0; i < m_instruments->concurrentFrameCount; i++)
{
textInfo.bufArr[i].createBuffer({textInfo.textVertices.size() * sizeof(base::graphics::ColorTexVertex)}, {BDSH::VX});
textInfo.bufArr[i].set(textInfo.textVertices.data(), textInfo.textVertices.size() * sizeof(base::graphics::ColorTexVertex));
textInfo.bufArr[i].mapWholeMemory();
textInfo.bufArr[i].update();
textInfo.bufArr[i].unMapMemory();
}
m_texts[textName] = textInfo;
When i looked up Qt source code, it is waiting for fences for every frame. This is where problem occurs. I somehow need to wait for all fences, and then i can release the buffers. But Qt has it in private class, so i cant access it. I was thinking about changing Qt source code, so i can access fences or graphical queue, but first, i just want to ask you, if there is any better way, how to do it. Thank you in advance.
Qt source code: https://codebrowser.dev/qt5/qtbase/src/gui/vulkan/qvulkanwindow.cpp.html