diff --git a/inc/hgl/graph/vulkan/VKRenderTarget.h b/inc/hgl/graph/vulkan/VKRenderTarget.h index d02da7b5..36849990 100644 --- a/inc/hgl/graph/vulkan/VKRenderTarget.h +++ b/inc/hgl/graph/vulkan/VKRenderTarget.h @@ -23,7 +23,8 @@ protected: protected: - ObjectList color_texture; + uint32_t color_count; + Texture2D **color_textures; Texture2D *depth_texture; protected: @@ -44,7 +45,7 @@ public: virtual const uint32_t GetColorCount ()const {return fb->GetColorCount();} virtual const VkFramebuffer GetFramebuffer ()const {return fb->GetFramebuffer();} - virtual Texture2D * GetColorTexture (const int index=0){return color_texture[index];} + virtual Texture2D * GetColorTexture (const int index=0){return color_textures[index];} virtual Texture2D * GetDepthTexture (){return depth_texture;} virtual bool Submit (GPUSemaphore *present_complete_semaphore=nullptr); @@ -66,7 +67,7 @@ class SwapchainRenderTarget:public RenderTarget uint32_t swap_chain_count; uint32_t current_frame; - ObjectList render_frame; + Framebuffer **render_frame; public: diff --git a/src/RenderDevice/Vulkan/VKRenderTarget.cpp b/src/RenderDevice/Vulkan/VKRenderTarget.cpp index e48cca91..085ef874 100644 --- a/src/RenderDevice/Vulkan/VKRenderTarget.cpp +++ b/src/RenderDevice/Vulkan/VKRenderTarget.cpp @@ -15,6 +15,12 @@ RenderTarget::RenderTarget(Device *dev,Framebuffer *_fb,CommandBuffer *_cb,const fb=_fb; command_buffer=_cb; + if(fb) + color_count=fb->GetColorCount(); + else + color_count=0; + + color_textures=nullptr; depth_texture=nullptr; render_complete_semaphore=dev->CreateSemaphore(); } @@ -24,7 +30,17 @@ RenderTarget::RenderTarget(Device *dev,Framebuffer *_fb,CommandBuffer *_cb,Textu fb=_fb; command_buffer=_cb; - color_texture.Add(ctl,cc); + color_count=cc; + if(color_count>0) + { + color_textures=new Texture2D *[color_count]; + hgl_cpy(color_textures,ctl,color_count); + } + else + { + color_textures=nullptr; + } + depth_texture=dt; render_complete_semaphore=dev->CreateSemaphore(); } @@ -32,7 +48,7 @@ RenderTarget::RenderTarget(Device *dev,Framebuffer *_fb,CommandBuffer *_cb,Textu RenderTarget::~RenderTarget() { SAFE_CLEAR(depth_texture); - color_texture.Clear(); + SAFE_CLEAR_OBJECT_ARRAY(color_textures,color_count); SAFE_CLEAR(render_complete_semaphore); SAFE_CLEAR(command_buffer); @@ -63,9 +79,11 @@ SwapchainRenderTarget::SwapchainRenderTarget(Device *dev,Swapchain *sc):RenderTa extent=swapchain->GetExtent(); + render_frame=new Framebuffer *[swap_chain_count]; + for(uint i=0;iCreateFramebuffer(main_rp,(*sc_color)->GetImageView(),sc_depth->GetImageView())); + render_frame[i]=device->CreateFramebuffer(main_rp,(*sc_color)->GetImageView(),sc_depth->GetImageView()); ++sc_color; } @@ -76,7 +94,7 @@ SwapchainRenderTarget::SwapchainRenderTarget(Device *dev,Swapchain *sc):RenderTa SwapchainRenderTarget::~SwapchainRenderTarget() { - render_frame.Clear(); + SAFE_CLEAR_OBJECT_ARRAY(render_frame,swap_chain_count); delete present_complete_semaphore; delete main_rp;