optimized RenderCmdBuffer::BindFramebuffer
This commit is contained in:
@@ -44,11 +44,12 @@ class RenderCmdBuffer:public GPUCmdBuffer
|
||||
VkRect2D render_area;
|
||||
VkViewport viewport;
|
||||
|
||||
Framebuffer *fbo;
|
||||
RenderPassBeginInfo rp_begin;
|
||||
VkPipelineLayout pipeline_layout;
|
||||
|
||||
void SetFBO(Framebuffer *);
|
||||
private:
|
||||
|
||||
void SetClear();
|
||||
|
||||
public:
|
||||
|
||||
@@ -78,7 +79,7 @@ public:
|
||||
|
||||
//以上设定在Begin开始后即不可改变
|
||||
|
||||
bool BindFramebuffer(RenderPass *rp,Framebuffer *fb);
|
||||
bool BindFramebuffer(Framebuffer *);
|
||||
|
||||
bool BeginRenderPass();
|
||||
void NextSubpass(){vkCmdNextSubpass(cmd_buf,VK_SUBPASS_CONTENTS_INLINE);}
|
||||
|
@@ -1,13 +1,13 @@
|
||||
#ifndef HGL_GRAPH_VULKAN_FRAMEBUFFER_INCLUDE
|
||||
#define HGL_GRAPH_VULKAN_FRAMEBUFFER_INCLUDE
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/graph/VKRenderPass.h>
|
||||
VK_NAMESPACE_BEGIN
|
||||
class Framebuffer
|
||||
{
|
||||
VkDevice device;
|
||||
VkFramebuffer frame_buffer;
|
||||
VkRenderPass render_pass;
|
||||
RenderPass *render_pass;
|
||||
|
||||
VkExtent2D extent;
|
||||
uint32_t attachment_count;
|
||||
@@ -18,7 +18,7 @@ private:
|
||||
|
||||
friend class GPUDevice;
|
||||
|
||||
Framebuffer(VkDevice,VkFramebuffer,const VkExtent2D &,VkRenderPass,uint32_t color_count,bool depth);
|
||||
Framebuffer(VkDevice,VkFramebuffer,const VkExtent2D &,RenderPass *,uint32_t color_count,bool depth);
|
||||
|
||||
public:
|
||||
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
operator VkFramebuffer(){return frame_buffer;}
|
||||
|
||||
const VkFramebuffer GetFramebuffer ()const{return frame_buffer;}
|
||||
const VkRenderPass GetRenderPass ()const{return render_pass;}
|
||||
RenderPass * GetRenderPass () {return render_pass;}
|
||||
|
||||
const VkExtent2D & GetExtent ()const{return extent;}
|
||||
|
||||
|
@@ -37,8 +37,10 @@ public:
|
||||
|
||||
virtual ~RenderPass();
|
||||
|
||||
VkRenderPass GetVkRenderPass(){return render_pass;}
|
||||
VkPipelineCache GetPipelineCache(){return pipeline_cache;}
|
||||
operator const VkRenderPass()const{return render_pass;}
|
||||
|
||||
const VkRenderPass GetVkRenderPass()const{return render_pass;}
|
||||
const VkPipelineCache GetPipelineCache()const{return pipeline_cache;}
|
||||
|
||||
const uint GetColorCount()const{return color_formats.GetCount();}
|
||||
const List<VkFormat> & GetColorFormat()const{return color_formats;}
|
||||
|
@@ -17,7 +17,6 @@ protected:
|
||||
|
||||
DeviceQueue *queue;
|
||||
|
||||
RenderPass *render_pass;
|
||||
Framebuffer *fbo;
|
||||
|
||||
VkExtent2D extent;
|
||||
@@ -35,7 +34,7 @@ protected:
|
||||
friend class GPUDevice;
|
||||
|
||||
RenderTarget(DeviceQueue *,Semaphore *);
|
||||
RenderTarget(DeviceQueue *,Semaphore *,RenderPass *_rp,Framebuffer *_fb,Texture2D **color_texture_list,const uint32_t color_count,Texture2D *depth_texture);
|
||||
RenderTarget(DeviceQueue *,Semaphore *,Framebuffer *_fb,Texture2D **color_texture_list,const uint32_t color_count,Texture2D *depth_texture);
|
||||
|
||||
public:
|
||||
|
||||
@@ -43,14 +42,12 @@ public:
|
||||
|
||||
DeviceQueue * GetQueue () {return queue;}
|
||||
const VkExtent2D & GetExtent ()const {return extent;}
|
||||
virtual RenderPass * GetRenderPass () {return render_pass;}
|
||||
virtual const VkRenderPass GetVkRenderPass ()const {return render_pass->GetVkRenderPass();}
|
||||
|
||||
virtual const uint32_t GetColorCount ()const {return fbo->GetColorCount();}
|
||||
virtual RenderPass * GetRenderPass () {return GetFramebuffer()->GetRenderPass();}
|
||||
virtual uint32_t GetColorCount () {return GetFramebuffer()->GetColorCount();}
|
||||
|
||||
virtual Framebuffer * GetFramebuffer () {return fbo;}
|
||||
virtual Texture2D * GetColorTexture (const int index=0){return color_textures[index];}
|
||||
virtual Texture2D * GetDepthTexture (){return depth_texture;}
|
||||
virtual Texture2D * GetDepthTexture () {return depth_texture;}
|
||||
|
||||
public: // command buffer
|
||||
|
||||
@@ -76,27 +73,24 @@ class RTSwapchain:public RenderTarget
|
||||
|
||||
public:
|
||||
|
||||
RTSwapchain(VkDevice dev,Swapchain *sc,DeviceQueue *q,Semaphore *rcs,Semaphore *pcs,RenderPass *rp);
|
||||
RTSwapchain(VkDevice dev,Swapchain *sc,DeviceQueue *q,Semaphore *rcs,Semaphore *pcs);
|
||||
~RTSwapchain();
|
||||
|
||||
uint32_t GetColorCount () override {return 1;}
|
||||
uint32_t GetImageCount ()const {return swapchain->image_count;}
|
||||
uint32_t GetCurrentFrameIndices ()const {return current_frame;}
|
||||
|
||||
const uint32_t GetColorCount ()const override {return 1;} ///Swapchain的FBO颜色成份只有一个
|
||||
const uint32_t GetImageCount ()const {return swapchain->image_count;}
|
||||
Framebuffer * GetFramebuffer ()override {return swapchain->sc_image[current_frame].fbo;}
|
||||
Framebuffer * GetFramebuffer (int index) {return swapchain->sc_image[index].fbo;}
|
||||
|
||||
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;}
|
||||
|
||||
Framebuffer * GetFramebuffer ()override {return swapchain->sc_image[current_frame].fbo;}
|
||||
Framebuffer * GetFramebuffer (const int index) {return swapchain->sc_image[index].fbo;}
|
||||
|
||||
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;}
|
||||
|
||||
RenderCmdBuffer *GetRenderCmdBuffer(const int index)
|
||||
{
|
||||
return swapchain->sc_image[index].cmd_buf;
|
||||
}
|
||||
RenderCmdBuffer * GetRenderCmdBuffer (int index) {return swapchain->sc_image[index].cmd_buf;}
|
||||
|
||||
public:
|
||||
|
||||
const uint32_t GetCurrentFrameIndices ()const {return current_frame;}
|
||||
Semaphore * GetPresentCompleteSemaphore () {return present_complete_semaphore;}
|
||||
Semaphore * GetPresentSemaphore () {return present_complete_semaphore;}
|
||||
|
||||
public:
|
||||
|
||||
|
Reference in New Issue
Block a user