Moved render_cmd_buffer to SwapchainImage

This commit is contained in:
2025-01-25 01:41:00 +08:00
parent 79b0b2ef76
commit c8adc9af24
7 changed files with 99 additions and 121 deletions

View File

@@ -77,15 +77,15 @@ public:
RTSwapchain(VkDevice dev,Swapchain *sc,DeviceQueue *q,Semaphore *rcs,Semaphore *pcs,RenderPass *rp);
~RTSwapchain();
Framebuffer * GetFramebuffer ()override {return swapchain->sc_fbo[current_frame];}
Framebuffer * GetFramebuffer (const uint32_t index) {return swapchain->sc_fbo[index];}
Framebuffer * GetFramebuffer ()override {return swapchain->sc_image[current_frame].fbo;}
Framebuffer * GetFramebuffer (const uint32_t index) {return swapchain->sc_image[index].fbo;}
const uint32_t GetColorCount ()const override {return 1;}
const uint32_t GetImageCount ()const {return swapchain->color_count;}
virtual Texture2D * GetColorTexture (const int index=0) override{return swapchain->sc_color[index];}
virtual Texture2D * GetDepthTexture () override{return swapchain->sc_depth;}
const uint32_t GetImageCount ()const {return swapchain->image_count;}
virtual Texture2D * GetColorTexture (const int index=0) override{return swapchain->sc_image[current_frame].color;}
virtual Texture2D * GetDepthTexture () override{return swapchain->sc_image[current_frame].depth;}
public:

View File

@@ -1,10 +1,33 @@
#ifndef HGL_GRAPH_VULKAN_SWAP_CHAIN_INCLUDE
#define HGL_GRAPH_VULKAN_SWAP_CHAIN_INCLUDE
#pragma once
#include<hgl/graph/VK.h>
#include<hgl/graph/VKTexture.h>
#include<hgl/type/List.h>
#include<hgl/graph/VKFramebuffer.h>
#include<hgl/graph/VKCommandBuffer.h>
VK_NAMESPACE_BEGIN
struct SwapchainImage
{
Texture2D * color =nullptr;
Texture2D * depth =nullptr;
Framebuffer * fbo =nullptr;
RenderCmdBuffer * cmd_buf =nullptr;
public:
~SwapchainImage()
{
delete cmd_buf;
delete fbo;
delete depth;
delete color;
}
};//struct SwapchainImage
struct Swapchain
{
public:
@@ -15,19 +38,17 @@ public:
VkSurfaceTransformFlagBitsKHR transform;
VkSwapchainKHR swap_chain =VK_NULL_HANDLE;
VkSurfaceFormatKHR surface_format;
VkFormat depth_format;
VkSurfaceFormatKHR surface_format {};
VkFormat depth_format =VK_FORMAT_UNDEFINED;
uint32_t color_count =0;
RenderPass * render_pass =nullptr;
Texture2D ** sc_color =nullptr;
Texture2D * sc_depth =nullptr;
uint32_t image_count =0;
Framebuffer ** sc_fbo =nullptr;
SwapchainImage * sc_image =nullptr;
public:
virtual ~Swapchain();
};//struct Swapchain
VK_NAMESPACE_END
#endif//HGL_GRAPH_VULKAN_SWAP_CHAIN_INCLUDE

View File

@@ -17,19 +17,12 @@ GRAPH_MODULE_CLASS(SwapchainModule)
RTSwapchain *swapchain_rt=nullptr;
RenderPass *swapchain_rp=nullptr;
RenderCmdBuffer **cmd_buf=nullptr;
protected:
bool CreateSwapchainFBO();
bool CreateSwapchain();
bool CreateSwapchainRenderTarget();
void InitRenderCmdBuffer();
void ClearRenderCmdBuffer();
public:
virtual void OnResize(const VkExtent2D &)override; ///<窗口大小改变