VulkanRenderer: Handle VulkanRenderPass destruction
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline VulkanRenderPass::VulkanRenderPass(Vk::Device& device, std::vector<Attachment> attachments, std::vector<SubpassDescription> subpassDescriptions, std::vector<SubpassDependency> subpassDependencies) :
|
||||
VulkanRenderPass::VulkanRenderPass(Vk::Device& device, std::vector<Attachment> attachments, std::vector<SubpassDescription> subpassDescriptions, std::vector<SubpassDependency> subpassDependencies) :
|
||||
RenderPass(std::move(attachments), std::move(subpassDescriptions), std::move(subpassDependencies))
|
||||
{
|
||||
std::size_t totalAttachmentReference = 0;
|
||||
@@ -128,4 +128,9 @@ namespace Nz
|
||||
if (!m_renderPass.Create(device, renderPassInfo))
|
||||
throw std::runtime_error("failed to instantiate Vulkan render pass: " + TranslateVulkanError(m_renderPass.GetLastErrorCode()));
|
||||
}
|
||||
|
||||
VulkanRenderPass::~VulkanRenderPass()
|
||||
{
|
||||
OnRenderPassRelease(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,19 +35,24 @@ namespace Nz
|
||||
std::pair<VkRenderPass, std::size_t> key = { renderPassHandle, colorAttachmentCount };
|
||||
|
||||
if (auto it = m_pipelines.find(key); it != m_pipelines.end())
|
||||
return it->second;
|
||||
return it->second.pipeline;
|
||||
|
||||
UpdateCreateInfo(colorAttachmentCount);
|
||||
|
||||
VkGraphicsPipelineCreateInfo pipelineCreateInfo = m_pipelineCreateInfo.pipelineInfo;
|
||||
pipelineCreateInfo.renderPass = renderPassHandle;
|
||||
|
||||
Vk::Pipeline newPipeline;
|
||||
if (!newPipeline.CreateGraphics(*m_device, pipelineCreateInfo))
|
||||
PipelineData pipelineData;
|
||||
pipelineData.onRenderPassRelease.Connect(renderPass.OnRenderPassRelease, [this, key](const VulkanRenderPass*)
|
||||
{
|
||||
m_pipelines.erase(key);
|
||||
});
|
||||
|
||||
if (!pipelineData.pipeline.CreateGraphics(*m_device, pipelineCreateInfo))
|
||||
return VK_NULL_HANDLE;
|
||||
|
||||
auto it = m_pipelines.emplace(key, std::move(newPipeline)).first;
|
||||
return it->second;
|
||||
auto it = m_pipelines.emplace(key, std::move(pipelineData)).first;
|
||||
return it->second.pipeline;
|
||||
}
|
||||
|
||||
std::vector<VkPipelineColorBlendAttachmentState> VulkanRenderPipeline::BuildColorBlendAttachmentStateList(const RenderPipelineInfo& pipelineInfo)
|
||||
|
||||
Reference in New Issue
Block a user