Freambuffer deleted VKFramebufferCreateInfo data;

This commit is contained in:
hyzboy 2020-10-17 14:18:09 +08:00
parent bfa7cf50e1
commit cf11ce6054
2 changed files with 13 additions and 23 deletions

View File

@ -7,36 +7,31 @@ class Framebuffer
{ {
VkDevice device; VkDevice device;
VkFramebuffer frame_buffer; VkFramebuffer frame_buffer;
VkFramebufferCreateInfo *fb_info; VkRenderPass render_pass;
VkExtent2D extent; VkExtent2D extent;
uint32_t attachment_count;
uint32_t color_count; uint32_t color_count;
bool has_depth; bool has_depth;
ObjectList<Texture2D> color_texture;
Texture2D *depth_texture;
private: private:
friend class Device; friend class Device;
Framebuffer(VkDevice dev,VkFramebuffer fb,VkFramebufferCreateInfo *fb_create_info,bool depth); Framebuffer(VkDevice,VkFramebuffer,const VkExtent2D &,VkRenderPass,uint32_t color_count,bool depth);
public: public:
~Framebuffer(); ~Framebuffer();
const VkFramebuffer GetFramebuffer ()const{return frame_buffer;} const VkFramebuffer GetFramebuffer ()const{return frame_buffer;}
const VkRenderPass GetRenderPass ()const{return fb_info->renderPass;} const VkRenderPass GetRenderPass ()const{return render_pass;}
const VkExtent2D & GetExtent ()const{return extent;} const VkExtent2D & GetExtent ()const{return extent;}
const uint32_t GetAttachmentCount ()const{return fb_info->attachmentCount;} ///<获取渲染目标成分数量 const uint32_t GetAttachmentCount ()const{return attachment_count;} ///<获取渲染目标成分数量
const uint32_t GetColorCount ()const{return color_count;} ///<取得颜色成分数量 const uint32_t GetColorCount ()const{return color_count;} ///<取得颜色成分数量
const bool HasDepth ()const{return has_depth;} ///<是否包含深度成分 const bool HasDepth ()const{return has_depth;} ///<是否包含深度成分
Texture2D * GetColorTexture (const int index=0){return color_texture[index];}
Texture2D * GetDepthTexture (){return depth_texture;}
};//class Framebuffer };//class Framebuffer
VK_NAMESPACE_END VK_NAMESPACE_END
#endif//HGL_GRAPH_VULKAN_FRAMEBUFFER_INCLUDE #endif//HGL_GRAPH_VULKAN_FRAMEBUFFER_INCLUDE

View File

@ -7,29 +7,24 @@
VK_NAMESPACE_BEGIN VK_NAMESPACE_BEGIN
Framebuffer::Framebuffer(VkDevice dev,VkFramebuffer fb,VkFramebufferCreateInfo *fb_create_info,bool depth) Framebuffer::Framebuffer(VkDevice dev,VkFramebuffer fb,const VkExtent2D &ext,VkRenderPass rp,uint32_t cc,bool depth)
{ {
device=dev; device=dev;
frame_buffer=fb; frame_buffer=fb;
fb_info=fb_create_info; render_pass=rp;
extent.width=fb_info->width;
extent.height=fb_info->height;
extent=ext;
color_count=cc;
has_depth=depth; has_depth=depth;
if(has_depth)
color_count=fb_info->attachmentCount-1;
else
color_count=fb_info->attachmentCount;
depth_texture=nullptr; attachment_count=color_count;
if(has_depth)
++attachment_count;
} }
Framebuffer::~Framebuffer() Framebuffer::~Framebuffer()
{ {
SAFE_CLEAR(depth_texture);
color_texture.Clear();
vkDestroyFramebuffer(device,frame_buffer,nullptr); vkDestroyFramebuffer(device,frame_buffer,nullptr);
} }
VK_NAMESPACE_END VK_NAMESPACE_END