Hello everybody.
So when I’m destroying VkDevice i get this error:
Exception thrown at 0x00007FFEF7D5FE34 (ntdll.dll) in Vulkan.exe: 0xC0000005: Access violation writing location 0x0000000000000024.
This is my disposeDevice function:
void RenderEngine::disposeDevice()
{
if (device != VK_NULL_HANDLE) {
vkDeviceWaitIdle(device);
std::cout << "Test" << std::endl;
vkDestroyDevice(device, nullptr);
std::cout << "Test" << std::endl;
}
}
In my console i get only one Test printed out.
I found workaround on this but i really want this to be fixed:
I have vsync boolean value. When it is true vkDestroyDevice fails. When it is false everything works.
vsync boolean value is only used when I create swapchain and i select presentation mode.
My presentation mode selection code:
VkPresentModeKHR selected_presentation_mode;
if (vsync) {
bool was_presentation_mode_found = false;
for (uint32_t i = 0; i < surface_presentation_modes_count; i++) {
if (surface_presentation_modes[i] == VK_PRESENT_MODE_MAILBOX_KHR) {
selected_presentation_mode = VK_PRESENT_MODE_MAILBOX_KHR;
was_presentation_mode_found = true;
break;
}
else if (surface_presentation_modes[i] == VK_PRESENT_MODE_FIFO_KHR) {
was_presentation_mode_found = true;
selected_presentation_mode = VK_PRESENT_MODE_FIFO_KHR;
}
}
if (!was_presentation_mode_found)
assert(0 && "Surface with v-sync isn't supported on your system. Please turn v-sync off!");
if (selected_presentation_mode == VK_PRESENT_MODE_FIFO_KHR) {
std::cout << "Vulkan presentation mode called MAILBOX is not supported on your system. Instead of it we are going to use FIFO presentation mode, which can lead to some ammount of delay." << std::endl << "You should turn vsync off!" << std::endl;
#if defined _WIN32
MessageBox(NULL, "Vulkan presentation mode called MAILBOX is not supported on your system.
Instead of it we are going to use FIFO presentation mode, which can lead to some ammount of delay.
You should turn vsync off!", "VISION engine warning", 0x00000030L);
#endif
}
}
else {
for (uint32_t i = 0; i < surface_presentation_modes_count; i++) {
bool was_immeadiate_mode_found = false;
if (surface_presentation_modes[i] == VK_PRESENT_MODE_IMMEDIATE_KHR) {
selected_presentation_mode = VK_PRESENT_MODE_IMMEDIATE_KHR;
was_immeadiate_mode_found = true;
break;
}
if (!was_immeadiate_mode_found) {
assert(0 && "Surface with no v-sync isn't supported on your system. Please turn v-sync on!");
}
}
}
(if it matters My pc falls for FIFO mode, because i run on amd graphics card)
Sorry for my bad english by the way!
-
-
- Updated - - -
-
I dont know what happened, but it works now. Could anyone explain me why I had this error?