Begin work on RenderPipeline

This commit is contained in:
Lynix
2020-02-25 22:56:08 +01:00
parent 7bbba14ba0
commit c05ea4095a
22 changed files with 284 additions and 173 deletions

View File

@@ -0,0 +1,11 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Renderer/RenderPipeline.hpp>
#include <Nazara/Renderer/Debug.hpp>
namespace Nz
{
RenderPipeline::~RenderPipeline() = default;
}

View File

@@ -28,6 +28,14 @@ namespace Nz
///TODO
}
std::shared_ptr<RenderDevice> RenderWindow::GetRenderDevice()
{
if (!m_impl)
return std::shared_ptr<RenderDevice>();
return m_impl->GetRenderDevice();
}
bool RenderWindow::OnWindowCreated()
{
RendererImpl* rendererImpl = Renderer::GetRendererImpl();

View File

@@ -3,6 +3,7 @@
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/VulkanRenderer/VulkanDevice.hpp>
#include <Nazara/VulkanRenderer/VulkanRenderPipeline.hpp>
#include <Nazara/VulkanRenderer/Debug.hpp>
namespace Nz
@@ -13,4 +14,9 @@ namespace Nz
{
return std::make_unique<VulkanBuffer>(shared_from_this(), parent, type);
}
std::unique_ptr<RenderPipeline> VulkanDevice::InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo)
{
return std::make_unique<VulkanRenderPipeline>(shared_from_this(), std::move(pipelineInfo));
}
}

View File

@@ -0,0 +1,51 @@
// Copyright (C) 2016 Jérôme Leclercq
// This file is part of the "Nazara Engine - Vulkan Renderer"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/VulkanRenderer/VulkanRenderPipeline.hpp>
#include <Nazara/Core/ErrorFlags.hpp>
#include <Nazara/VulkanRenderer/Utils.hpp>
#include <cassert>
#include <Nazara/VulkanRenderer/Debug.hpp>
namespace Nz
{
VulkanRenderPipeline::VulkanRenderPipeline(Vk::DeviceHandle device, RenderPipelineInfo pipelineInfo) :
m_device(std::move(device)),
m_pipelineInfo(std::move(pipelineInfo))
{
}
VkPipelineDepthStencilStateCreateInfo VulkanRenderPipeline::BuildDepthStencilInfo(const RenderPipelineInfo& pipelineInfo)
{
VkPipelineDepthStencilStateCreateInfo createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
createInfo.pNext = nullptr;
createInfo.flags = 0U;
createInfo.depthTestEnable = pipelineInfo.depthBuffer;
createInfo.depthWriteEnable = pipelineInfo.depthWrite;
createInfo.depthCompareOp = ToVulkan(pipelineInfo.depthCompare);
createInfo.depthBoundsTestEnable = VK_FALSE;
createInfo.stencilTestEnable = pipelineInfo.stencilTest;
createInfo.front = BuildStencilOp(pipelineInfo, true);
createInfo.back = BuildStencilOp(pipelineInfo, false);
return createInfo;
}
VkStencilOpState VulkanRenderPipeline::BuildStencilOp(const RenderPipelineInfo& pipelineInfo, bool front)
{
const auto& pipelineStencil = (front) ? pipelineInfo.stencilFront : pipelineInfo.stencilBack;
VkStencilOpState stencilStates;
stencilStates.compareMask = pipelineStencil.compareMask;
stencilStates.compareOp = ToVulkan(pipelineStencil.compare);
stencilStates.depthFailOp = ToVulkan(pipelineStencil.depthFail);
stencilStates.failOp = ToVulkan(pipelineStencil.fail);
stencilStates.passOp = ToVulkan(pipelineStencil.pass);
stencilStates.reference = pipelineStencil.reference;
stencilStates.writeMask = pipelineStencil.writeMask;
return stencilStates;
}
}