Fixing memory leak with RefPtr

This commit is contained in:
Dynamitos
2020-04-01 02:17:49 +02:00
parent 62c2d37cb3
commit 3ba8f2c2a0
37 changed files with 1675 additions and 270 deletions
@@ -0,0 +1,47 @@
#include "VulkanFramebuffer.h"
#include "VulkanGraphicsEnums.h"
#include "VulkanInitializer.h"
#include "VulkanRenderPass.h"
#include "VulkanGraphics.h"
using namespace Seele;
using namespace Seele::Vulkan;
Framebuffer::Framebuffer(PGraphics graphics, PRenderPass renderPass, Gfx::PRenderTargetLayout renderTargetLayout)
: graphics(graphics)
, layout(renderTargetLayout)
, renderPass(renderPass)
{
Array<VkImageView> attachments;
for(auto inputAttachment : layout->inputAttachments)
{
PTexture2D vkInputAttachment = inputAttachment.cast<Texture2D>();
attachments.add(vkInputAttachment->getView());
}
for(auto colorAttachment : layout->colorAttachments)
{
PTexture2D vkColorAttachment = colorAttachment.cast<Texture2D>();
attachments.add(vkColorAttachment->getView());
}
if(layout->depthAttachment != nullptr)
{
PTexture2D vkDepthAttachment = layout->depthAttachment.cast<Texture2D>();
attachments.add(vkDepthAttachment->getView());
}
VkFramebufferCreateInfo createInfo =
init::FramebufferCreateInfo(
renderPass->getHandle(),
attachments.size(),
attachments.data(),
renderPass->getRenderArea().extent.width,
renderPass->getRenderArea().extent.height,
1
);
VK_CHECK(vkCreateFramebuffer(graphics->getDevice(), &createInfo, nullptr, &handle));
}
Framebuffer::~Framebuffer()
{
vkDestroyFramebuffer(graphics->getDevice(), handle, nullptr);
}