Begin work on RenderPipeline
This commit is contained in:
11
src/Nazara/Renderer/RenderPipeline.cpp
Normal file
11
src/Nazara/Renderer/RenderPipeline.cpp
Normal 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;
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
51
src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp
Normal file
51
src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user