From bfec51d0a3fbc95d3b5f9d833a37a24b4753f38c Mon Sep 17 00:00:00 2001 From: hyzboy Date: Fri, 16 Oct 2020 19:26:28 +0800 Subject: [PATCH] update followed CreateFramebuffer&CreateRenderpass --- src/RenderDevice/Vulkan/CMakeLists.txt | 1 + src/RenderDevice/Vulkan/VKDeviceRenderTarget.cpp | 10 ++++------ src/RenderDevice/Vulkan/VKRenderTarget.cpp | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/RenderDevice/Vulkan/CMakeLists.txt b/src/RenderDevice/Vulkan/CMakeLists.txt index 1b2aeae2..531e8398 100644 --- a/src/RenderDevice/Vulkan/CMakeLists.txt +++ b/src/RenderDevice/Vulkan/CMakeLists.txt @@ -25,6 +25,7 @@ SET(VK_DEVICE_SOURCE ${RD_INCLUDE_PATH}/VKDevice.h VKDeviceBuffer.cpp VKDeviceImage.cpp VKDeviceTexture.cpp + VKDeviceFramebuffer.cpp VKDeviceSwapchain.cpp VKDeviceRenderPass.cpp VKDeviceRenderTarget.cpp) diff --git a/src/RenderDevice/Vulkan/VKDeviceRenderTarget.cpp b/src/RenderDevice/Vulkan/VKDeviceRenderTarget.cpp index 5de79578..19b49e9d 100644 --- a/src/RenderDevice/Vulkan/VKDeviceRenderTarget.cpp +++ b/src/RenderDevice/Vulkan/VKDeviceRenderTarget.cpp @@ -15,8 +15,8 @@ RenderTarget *Device::CreateRenderTarget( const uint w,const uint h, const VkImageLayout depth_layout) { if(w<=0||h<=0)return(nullptr); - if(IsDepthStencilFormat(color_format))return(nullptr); - if(!IsDepthFormat(depth_format))return(nullptr); + + RenderPass *rp=CreateRenderPass(color_format,depth_format,color_layout,depth_layout); //Renderpass内部会验证格式,所以不需要自己处理 if(!CheckTextureFormatSupport(color_format))return(nullptr); if(!CheckTextureFormatSupport(depth_format))return(nullptr); @@ -24,9 +24,7 @@ RenderTarget *Device::CreateRenderTarget( const uint w,const uint h, Texture2D *color_texture=CreateAttachmentTextureColor(color_format,w,h); Texture2D *depth_texture=CreateAttachmentTextureDepth(depth_format,w,h); - RenderPass *rp=CreateRenderPass(color_format,depth_format,color_layout,depth_layout); - - Framebuffer *fb=CreateFramebuffer(GetDevice(),rp,color_texture->GetImageView(),depth_texture->GetImageView()); + Framebuffer *fb=CreateFramebuffer(rp,color_texture->GetImageView(),depth_texture->GetImageView()); return(CreateRenderTarget(fb)); } @@ -83,7 +81,7 @@ RenderTarget *Device::CreateRenderTarget( const uint w,const uint h, // if(depth_count>0)CreateDepthAttachmentReference(&depth_ref,color_count); // if(color_count>0)CreateColorAttachmentReference(color_ref_list,0,color_count); // -// CreateAttachment(desc_list,color_format_list,depth_format,VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL); +// CreateAttachmentDescription(desc_list,color_format_list,depth_format,VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL); // // VkSubpassDescription sd; // diff --git a/src/RenderDevice/Vulkan/VKRenderTarget.cpp b/src/RenderDevice/Vulkan/VKRenderTarget.cpp index cc757dd2..220cebdb 100644 --- a/src/RenderDevice/Vulkan/VKRenderTarget.cpp +++ b/src/RenderDevice/Vulkan/VKRenderTarget.cpp @@ -124,7 +124,7 @@ SwapchainRenderTarget::SwapchainRenderTarget(Device *dev,Swapchain *sc):RenderTa for(uint i=0;iGetDevice(),main_rp,(*sc_color)->GetImageView(),sc_depth->GetImageView())); + render_frame.Add(device->CreateFramebuffer(main_rp,(*sc_color)->GetImageView(),sc_depth->GetImageView())); ++sc_color; }