diff --git a/inc/hgl/graph/vulkan/VKDevice.h b/inc/hgl/graph/vulkan/VKDevice.h index a0f669f4..68f8d097 100644 --- a/inc/hgl/graph/vulkan/VKDevice.h +++ b/inc/hgl/graph/vulkan/VKDevice.h @@ -30,7 +30,7 @@ class Device private: - void CreateMainFramebuffer(); + void RecreateDevice(); private: diff --git a/src/RenderDevice/Vulkan/VKDevice.cpp b/src/RenderDevice/Vulkan/VKDevice.cpp index 48adb207..1a6a7c02 100644 --- a/src/RenderDevice/Vulkan/VKDevice.cpp +++ b/src/RenderDevice/Vulkan/VKDevice.cpp @@ -25,19 +25,10 @@ Device::Device(DeviceAttribute *da) hgl_zero(texture_submitInfo); texture_submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; - texture_cmd_buf=CreateCommandBuffer(); - present.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR; - present.pNext = nullptr; - present.swapchainCount = 1; - present.pSwapchains = &attr->swap_chain; - present.pWaitSemaphores = nullptr; - present.waitSemaphoreCount = 0; - present.pResults = nullptr; - - main_rp=CreateRenderPass(attr->sc_image_views[0]->GetFormat(),attr->depth.view->GetFormat()); - - CreateMainFramebuffer(); + main_rp=nullptr; + texture_cmd_buf=nullptr; + RecreateDevice(); } Device::~Device() @@ -55,30 +46,35 @@ Device::~Device() delete attr; } -void Device::CreateMainFramebuffer() +void Device::RecreateDevice() { + main_fb.Clear(); + if(main_rp)delete main_rp; + if(texture_cmd_buf)delete texture_cmd_buf; + + present.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR; + present.pNext = nullptr; + present.swapchainCount = 1; + present.pSwapchains = &attr->swap_chain; + present.pWaitSemaphores = nullptr; + present.waitSemaphoreCount = 0; + present.pResults = nullptr; + + main_rp=CreateRenderPass(attr->sc_image_views[0]->GetFormat(),attr->depth.view->GetFormat()); const int sc_count=attr->sc_image_views.GetCount(); for(int i=0;isc_image_views[i],attr->depth.view)); + + texture_cmd_buf=CreateCommandBuffer(); } bool Device::Resize(uint width,uint height) { - main_fb.Clear(); - delete main_rp; - - delete texture_cmd_buf; - if(!ResizeRenderDevice(attr,width,height)) return(false); - main_rp=CreateRenderPass(attr->sc_image_views[0]->GetFormat(),attr->depth.view->GetFormat()); - - CreateMainFramebuffer(); - - texture_cmd_buf=CreateCommandBuffer(); - + RecreateDevice(); return(true); }