From a28d857b9656f8c58605e1f8dafe80877dd4581d Mon Sep 17 00:00:00 2001 From: hyzboy Date: Fri, 7 Jan 2022 11:57:34 +0800 Subject: [PATCH] added safe check codes. --- src/SceneGraph/Vulkan/VKDeviceSwapchain.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/SceneGraph/Vulkan/VKDeviceSwapchain.cpp b/src/SceneGraph/Vulkan/VKDeviceSwapchain.cpp index d3230d62..b72e995c 100644 --- a/src/SceneGraph/Vulkan/VKDeviceSwapchain.cpp +++ b/src/SceneGraph/Vulkan/VKDeviceSwapchain.cpp @@ -79,13 +79,20 @@ bool GPUDevice::CreateSwapchainFBO(Swapchain *swapchain) return(false); swapchain->sc_depth =CreateTexture2D(new SwapchainDepthTextureCreateInfo(attr->physical_device->GetDepthFormat(),swapchain->extent)); - swapchain->sc_color =new Texture2D *[swapchain->color_count]; - swapchain->render_frame =new Framebuffer *[swapchain->color_count]; + + if(!swapchain->sc_depth) + return(false); + + swapchain->sc_color =hgl_zero_new(swapchain->color_count); + swapchain->render_frame =hgl_zero_new(swapchain->color_count); for(uint32_t i=0;icolor_count;i++) { swapchain->sc_color[i]=CreateTexture2D(new SwapchainColorTextureCreateInfo(attr->surface_format.format,swapchain->extent,sc_images[i])); + if(!swapchain->sc_color[i]) + return(false); + swapchain->render_frame[i]=CreateFramebuffer( device_render_pass, swapchain->sc_color[i]->GetImageView(), swapchain->sc_depth->GetImageView());