From 734c428da23757a3de6d882c7c57d840a1238db5 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Fri, 14 Jun 2019 10:32:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86Vulkan=E9=87=8D=E5=BB=BA=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E7=BB=9F=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/hgl/graph/vulkan/VKDevice.h | 2 +- src/RenderDevice/Vulkan/VKDevice.cpp | 44 +++++++++++++--------------- 2 files changed, 21 insertions(+), 25 deletions(-) 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); }