#Is there any reason why vkSubmitQueue would throw an error at runtime?

23 messages · Page 1 of 1 (latest)

worthy cosmos
#

I was trying to follow along with a tutorial to get started with vulkan, and then make more serious modifications from there. When I attempted to copy what they were doing in their drawFrame loop, however, I ran into an issue where my code wouldn't run past vkSubmitQueue.

#
logd("fence wait");
    vkWaitForFences(device, 1, &inFlightFences[currentFrame], VK_TRUE, UINT64_MAX);

    uint32_t imgIndex;

    VkResult result = vkAcquireNextImageKHR(device, swapchain, UINT64_MAX, 
        imgAvailableSemaphores[currentFrame], VK_NULL_HANDLE, &imgIndex);

    if (result == VK_ERROR_OUT_OF_DATE_KHR) {
        logd("recreating swapchain");
        recreateSwapchain();
        return;
    } else if (result != VK_SUCCESS && result != VK_SUBOPTIMAL_KHR) {
        logd("failing swapchain image acquisition?");
        processVkResult("Vulkan acquire next image", result);
    }

    logd("reseting fences");
    processVkResult("Vulkan reset fences",
        vkResetFences(device, 1, &inFlightFences[currentFrame]));

    logd("reseting cmd buffer");

    // TODO -- understand commented out part
    processVkResult("Vulkan reset command buffer",
        vkResetCommandBuffer(commandBuffers[currentFrame], /*VkCommandBufferResetFlagBits*/ 0));
    recordCommandBuffer(commandBuffers[currentFrame], imgIndex);

    VkSubmitInfo submitInfo {};
    submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;

    VkSemaphore waitSemaphores[] = {imgAvailableSemaphores[currentFrame]};
    VkPipelineStageFlags waitStages[] = {VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT};
    submitInfo.waitSemaphoreCount = 1;
    submitInfo.pWaitSemaphores = waitSemaphores;
    submitInfo.pWaitDstStageMask = waitStages;
    
    submitInfo.commandBufferCount = 1;
    submitInfo.pCommandBuffers = &commandBuffers[currentFrame];

    VkSemaphore signalSemaphores[] = {renderFinishedSemaphores[currentFrame]};
    submitInfo.signalSemaphoreCount = 1;
    submitInfo.pSignalSemaphores = signalSemaphores;

    logd("submitting queue to draw buffer");
    // processVkResult("Vulkan submit queue to draw buffer",
    //     vkQueueSubmit(graphicsQueue, 1, &submitInfo, inFlightFences[currentFrame]), false);
    vkQueueSubmit(graphicsQueue, 1, &submitInfo, inFlightFences[currentFrame]);
#

right after the last statement, there's another logd message that never gets printed. logd is just a macro i made that prints out the message as well as the file and line number

tawny spruce
#

What error code do you get?

worthy cosmos
#

I don't get an error code

tawny spruce
#

A failure at vkQueueSubmit is very common and may hint at undefined behaviour of your app.

worthy cosmos
#

but usually the failure would be in the form of a VkResult, right?

tawny spruce
#

Yes

feral hill
#

you need to check the return value of vkQueueSubmit(graphicsQueue, 1, &submitInfo, inFlightFences[currentFrame]);

tawny spruce
#

if you don't do it already: enable validation layers and check errors and warnings up to the error at submission time

feral hill
#

you can do that in vkconfig without any code changes

worthy cosmos
#

I have validation layers, and I've tried checking the resulting value

tawny spruce
#

and what result did you get?

worthy cosmos
#

If I do something like

logd("submitting queue to draw buffer");

    VkResult r = vkQueueSubmit(graphicsQueue, 1, &submitInfo, inFlightFences[currentFrame]);
   
logd("r: " << r);

the program still quits before the debug line is reached

feral hill
#

maybe run with a debugger

#

I suspect something is null and you're getting a seg fault

worthy cosmos
#

That's likely the case, I should probably check every argument there isn't secretly null, although i dont know how that'd happen

#

any debugger recommendations?

feral hill
#

you don't really have a choice in debuggers

#

gdb for gcc/clang

#

and whatever visual studio uses for msvc

worthy cosmos
#

thanks

jade linden
#

the chance of this is very low but, are you sure that vkQueueSubmit function loaded correctly?