I am trying to follow a tutorial on creating my first triangle in Vulkan. This has been a pretty smooth and educational experience thus far, though I have now found myself at a roadblock. The tutorial I am following is the one at vulkan-tutorial dot com. The author of this tutorial explains things very well and has taught me a lot.
The roadblock in question is inside the draw loop, its the vkWaitForFences function and other fence related functions that throw an unhandled exception. This exception is complaining of a read access violation, which if I am correct, means there is a pointer to memory which is null. I have checks all along the way throughout the creation of the device, swapchain, fences, semaphores, etc. None of the checks fail all the way through to the draw loop.
The version of Vulkan I am using is 1.3, along with windows 11 pro, 32gb of ram and an rtx 3070 laptop graphics card. My graphics driver version is 535.98.0.0, api version 1.3.242. If there is more system information that is needed, please let me know and I will provide.
What makes me more stumped is that I was following the tutorial most of the time throughout this crucial process. I have received no errors from my validation layers, which appear to work, at least occasionally, but again they may not be perfect as well.
I am going to attach screenshots of the fence/semaphore creation as well as the error in the draw loop. I hope I was not horrible at describing my issue, as I hate posting questions about things, I have spent maybe 2 - 3 days looking for a solution and can’t find one. I appreciate any help I do get in advance!
I am not allowed to embed links since I am too new, so not sure what to do there. I will post the function code for fence/semaphore creation and the first relevant part of the draw loop instead.
Fence/Semaphore creation function
void Rendering::CreateVulkanSyncObjects()
{
VkSemaphoreCreateInfo SemaphoreInfo = {};
SemaphoreInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
VkFenceCreateInfo FenceInfo = {};
FenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
FenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT;
FenceInfo.pNext = nullptr;
VkResult result = vkCreateSemaphore(m_VulkanDevice, &SemaphoreInfo, nullptr, &m_VkImageAvailable);
if (result != VkResult::VK_SUCCESS)
{
AD_ASSERT(L"Failed to create image availability semaphore sync object!")
}
result = vkCreateSemaphore(m_VulkanDevice, &SemaphoreInfo, nullptr, &m_VkRenderFinished);
if (result != VkResult::VK_SUCCESS)
{
AD_ASSERT(L"Failed to create render semaphore sync object!")
}
result = vkCreateFence(m_VulkanDevice, &FenceInfo, nullptr, &m_VkInFlight);
if (result != VkResult::VK_SUCCESS)
{
AD_ASSERT(L"Failed to create in flight fence sync object!")
}
}
Top section of draw loop containing the error
else if (isVulkan)
{
VkResult result = VkResult::VK_SUCCESS;
// Waits for gpu to catch up // Seems fences are causing problems!
result = vkWaitForFences(m_VulkanDevice, 1, &m_VkInFlight, VK_TRUE, UINT64_MAX); // ERROR
if (result != VkResult::VK_SUCCESS)
{
AD_ASSERT(L"Failed to wait for fences!")
}
// After waiting, then reset the signal back to unsignaled for next time
result = vkResetFences(m_VulkanDevice, 1, &m_VkInFlight);
if (result != VkResult::VK_SUCCESS)
{
AD_ASSERT(L"Failed to reset fence signals!")
}
}