Renderer: Fix MRT support

This commit is contained in:
Jérôme Leclercq
2021-05-05 12:01:20 +02:00
parent 990193ebb4
commit 10aa7231b6
8 changed files with 74 additions and 10 deletions

View File

@@ -60,6 +60,7 @@ namespace Nz
private:
Vk::CommandBuffer& m_commandBuffer;
const VulkanRenderPass* m_currentRenderPass;
std::size_t m_currentSubpassIndex;
std::size_t m_framebufferCount;
std::size_t m_imageIndex;
};

View File

@@ -8,12 +8,13 @@
#define NAZARA_VULKANRENDERER_VULKANRENDERPIPELINE_HPP
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Core/Algorithm.hpp>
#include <Nazara/Core/MovablePtr.hpp>
#include <Nazara/Renderer/RenderPipeline.hpp>
#include <Nazara/VulkanRenderer/Config.hpp>
#include <Nazara/VulkanRenderer/VulkanRenderPass.hpp>
#include <Nazara/VulkanRenderer/Wrapper/Device.hpp>
#include <Nazara/VulkanRenderer/Wrapper/Pipeline.hpp>
#include <Nazara/VulkanRenderer/Wrapper/RenderPass.hpp>
#include <vector>
namespace Nz
@@ -26,7 +27,7 @@ namespace Nz
VulkanRenderPipeline(Vk::Device& device, RenderPipelineInfo pipelineInfo);
~VulkanRenderPipeline() = default;
VkPipeline Get(const Vk::RenderPass& renderPass) const;
VkPipeline Get(const VulkanRenderPass& renderPass, std::size_t subpassIndex) const;
inline const RenderPipelineInfo& GetPipelineInfo() const override;
@@ -71,9 +72,16 @@ namespace Nz
};
private:
mutable std::unordered_map<VkRenderPass, Vk::Pipeline> m_pipelines;
void UpdateCreateInfo(std::size_t colorBufferCount) const;
struct PipelineHasher
{
inline std::size_t operator()(const std::pair<VkRenderPass, std::size_t>& renderPass) const;
};
mutable std::unordered_map<std::pair<VkRenderPass, std::size_t>, Vk::Pipeline, PipelineHasher> m_pipelines;
MovablePtr<Vk::Device> m_device;
CreateInfo m_pipelineCreateInfo;
mutable CreateInfo m_pipelineCreateInfo;
RenderPipelineInfo m_pipelineInfo;
};
}

View File

@@ -7,6 +7,15 @@
namespace Nz
{
inline std::size_t VulkanRenderPipeline::PipelineHasher::operator()(const std::pair<VkRenderPass, std::size_t>& renderPass) const
{
std::size_t seed = 0;
HashCombine(seed, renderPass.first);
HashCombine(seed, renderPass.second);
return seed;
}
inline const RenderPipelineInfo& VulkanRenderPipeline::GetPipelineInfo() const
{
return m_pipelineInfo;