I have a question about something I don’t understand: I have a thread that submits work to queues (either presenting or command buffers), and other threads can enqueue command buffers to be executed on certain queues (if available, one for graphics, one for presenting and one for transfer).
With a debug build, all runs fine, but in release mode, I get a device lost error when the submitter thread tries to submit a command buffer that copies a buffer to another, and the only way I found to solve that issue was to wait for the last present command to have been submitted (originally it did not wait for the commands to be submitted, but it would use fences to not overwhelm the queues).
Any idea why I get this device lost error? (And the problem does not show up if I don’t use the submitter thread.)
Do you have a minimal test case/test project with source code ?
it can help to find problem.
Unfortunately the project is quite big, here are the main parts though:
void CQueueSubmitter::Enqueue(vk::Queue & queue, CQueueSubmittable_ptr submittable)
auto & submittable = m_pending.front();
if (auto infos = m_submitInfos[m_currentFrame])
infos->Wait(); // Wait until: 1. Submitted 2. Fence signaled
auto & device = Ctx()->Device();
uint32_t image_index = 0;
const auto result = device.acquireNextImageKHR(*m_swapchain, UINT64_MAX, *m_imageAvailSemaphore[m_currentFrame], acquire_fence);
image_index = result.value;
catch (const vk::OutOfDateKHRError &)
if (auto submit_info = m_imageSubmitInfos[image_index])
auto submit_fence = m_fences[m_currentFrame];
auto submit_info = XCore::make_shared<CSubmitInfo>(encoder->CommandBuffer());
auto & queue = Ctx()->GetQueue(eQueueType::kGraphics);
m_submitInfos[m_currentFrame] = submit_info;
m_imageSubmitInfos[image_index] = submit_info;
auto present_info = std::make_shared<CPresentInfo>(m_swapchain, image_index);
auto & queue = Ctx()->GetQueue(eQueueType::kPresent);
m_currentFrame = (m_currentFrame + 1) % m_framesInFlight;
void CBuffer::CopyFrom(CBuffer_ptr src, size_t size, size_t src_offset, size_t dst_offset)
auto command_pool = New<CCommandPool>(Ctx()->TransferQueueIndex(), true);
auto command_buffer_ptr = command_pool->CreatePrimary();
vk::CommandBuffer & command_buffer = *command_buffer_ptr;
if (size == 0)
size = Size();
command_buffer.copyBuffer(*src, m_buffer, copy_region);
auto fence = New<CFence>();
CSubmitInfo_ptr submit_info = std::make_shared<CSubmitInfo>(command_buffer_ptr);
auto & queue = Ctx()->GetQueue(eQueueType::kTransfer);
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.