remove main_rp value of SwapchainRenderTarget

This commit is contained in:
hyzboy 2020-10-26 21:51:30 +08:00
parent b4c385c40c
commit 40d91b5992
2 changed files with 32 additions and 32 deletions

View File

@ -14,13 +14,13 @@ class RenderTarget:public GPUQueue
{
protected:
RenderPass *rp;
Framebuffer *fb;
RenderPass *render_pass;
Framebuffer *fbo;
VkExtent2D extent;
GPUSemaphore * render_complete_semaphore =nullptr;
GPUCmdBuffer * command_buffer =nullptr;
GPUSemaphore *render_complete_semaphore =nullptr;
GPUCmdBuffer *command_buffer =nullptr;
protected:
@ -40,16 +40,18 @@ public:
virtual ~RenderTarget();
const VkExtent2D & GetExtent ()const {return extent;}
GPUSemaphore * GetCompleteSemaphore(){return render_complete_semaphore;}
GPUCmdBuffer * GetCommandBuffer () {return command_buffer;}
virtual const VkRenderPass GetRenderPass ()const {return fb->GetRenderPass();}
virtual const uint32_t GetColorCount ()const {return fb->GetColorCount();}
virtual const VkFramebuffer GetFramebuffer ()const {return fb->GetFramebuffer();}
virtual const VkRenderPass GetRenderPass ()const {return *render_pass;}
virtual const uint32_t GetColorCount ()const {return fbo->GetColorCount();}
virtual const VkFramebuffer GetFramebuffer ()const {return fbo->GetFramebuffer();}
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);
public:
GPUSemaphore * GetRenderCompleteSemaphore (){return render_complete_semaphore;}
GPUCmdBuffer * GetCommandBuffer (){return command_buffer;}
virtual bool Submit (GPUSemaphore *present_complete_semaphore=nullptr);
};//class RenderTarget
/**
@ -63,8 +65,6 @@ class SwapchainRenderTarget:public RenderTarget
GPUSemaphore *present_complete_semaphore=nullptr;
RenderPass *main_rp=nullptr;
uint32_t swap_chain_count;
uint32_t current_frame;
@ -75,18 +75,19 @@ public:
SwapchainRenderTarget(GPUDevice *dev,Swapchain *sc);
~SwapchainRenderTarget();
const VkRenderPass GetRenderPass ()const override {return *main_rp;}
const VkFramebuffer GetFramebuffer ()const override {return render_frame[current_frame]->GetFramebuffer();}
VkFramebuffer GetFramebuffer (const uint32_t index) {return render_frame[index]->GetFramebuffer();}
const VkFramebuffer GetFramebuffer ()const override {return render_frame[current_frame]->GetFramebuffer();}
VkFramebuffer GetFramebuffer (const uint32_t index) {return render_frame[index]->GetFramebuffer();}
const uint32_t GetColorCount ()const override {return 1;}
const uint32_t GetImageCount ()const {return swap_chain_count;}
const uint32_t GetColorCount ()const override {return 1;}
const uint32_t GetImageCount ()const {return swap_chain_count;}
const uint32_t GetCurrentFrameIndices()const{return current_frame;}
GPUSemaphore * GetPresentCompleteSemaphore(){return present_complete_semaphore;}
virtual Texture2D * GetColorTexture (const int index=0) override{return swapchain->GetColorTexture(index);}
virtual Texture2D * GetDepthTexture () override{return swapchain->GetDepthTexture();}
virtual Texture2D * GetColorTexture(const int index=0) override{return swapchain->GetColorTexture(index);}
virtual Texture2D * GetDepthTexture() override{return swapchain->GetDepthTexture();}
public:
const uint32_t GetCurrentFrameIndices ()const {return current_frame;}
GPUSemaphore * GetPresentCompleteSemaphore () {return present_complete_semaphore;}
public:

View File

@ -7,12 +7,12 @@
VK_NAMESPACE_BEGIN
RenderTarget::RenderTarget(GPUDevice *dev,Framebuffer *_fb,GPUCmdBuffer *_cb,const uint32_t fence_count):GPUQueue(dev,dev->GetGraphicsQueue(),fence_count)
{
rp=nullptr;
fb=_fb;
render_pass=nullptr;
fbo=_fb;
command_buffer=_cb;
if(fb)
color_count=fb->GetColorCount();
if(fbo)
color_count=fbo->GetColorCount();
else
color_count=0;
@ -23,8 +23,8 @@ RenderTarget::RenderTarget(GPUDevice *dev,Framebuffer *_fb,GPUCmdBuffer *_cb,con
RenderTarget::RenderTarget(GPUDevice *dev,RenderPass *_rp,Framebuffer *_fb,GPUCmdBuffer *_cb,Texture2D **ctl,const uint32_t cc,Texture2D *dt,const uint32_t fence_count):GPUQueue(dev,dev->GetGraphicsQueue(),fence_count)
{
rp=_rp;
fb=_fb;
render_pass=_rp;
fbo=_fb;
command_buffer=_cb;
depth_texture=dt;
@ -59,8 +59,8 @@ RenderTarget::~RenderTarget()
SAFE_CLEAR(render_complete_semaphore);
SAFE_CLEAR(command_buffer);
SAFE_CLEAR(fb);
SAFE_CLEAR(rp);
SAFE_CLEAR(fbo);
SAFE_CLEAR(render_pass);
}
bool RenderTarget::Submit(GPUSemaphore *present_complete_semaphore)
@ -82,7 +82,7 @@ SwapchainRenderTarget::SwapchainRenderTarget(GPUDevice *dev,Swapchain *sc):Rende
Texture2D **sc_color=swapchain->GetColorTextures();
Texture2D *sc_depth=swapchain->GetDepthTexture();
main_rp=device->CreateRenderPass((*sc_color)->GetFormat(),sc_depth->GetFormat(),VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
this->render_pass=device->CreateRenderPass((*sc_color)->GetFormat(),sc_depth->GetFormat(),VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
swap_chain_count=swapchain->GetImageCount();
@ -92,7 +92,7 @@ SwapchainRenderTarget::SwapchainRenderTarget(GPUDevice *dev,Swapchain *sc):Rende
for(uint i=0;i<swap_chain_count;i++)
{
render_frame[i]=device->CreateFramebuffer(main_rp,(*sc_color)->GetImageView(),sc_depth->GetImageView());
render_frame[i]=device->CreateFramebuffer(this->render_pass,(*sc_color)->GetImageView(),sc_depth->GetImageView());
++sc_color;
}
@ -106,7 +106,6 @@ SwapchainRenderTarget::~SwapchainRenderTarget()
SAFE_CLEAR_OBJECT_ARRAY(render_frame,swap_chain_count);
delete present_complete_semaphore;
delete main_rp;
}
int SwapchainRenderTarget::AcquireNextImage()