Vulkan: Add renderpass and framebuffers
This commit is contained in:
@@ -17,20 +17,27 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class Framebuffer;
|
||||
class RenderPass;
|
||||
class RenderPipeline;
|
||||
class ShaderBinding;
|
||||
|
||||
class NAZARA_RENDERER_API CommandBufferBuilder
|
||||
{
|
||||
public:
|
||||
struct ClearValues;
|
||||
|
||||
CommandBufferBuilder() = default;
|
||||
CommandBufferBuilder(const CommandBufferBuilder&) = delete;
|
||||
CommandBufferBuilder(CommandBufferBuilder&&) = default;
|
||||
virtual ~CommandBufferBuilder();
|
||||
|
||||
virtual void BeginDebugRegion(const std::string_view& regionName, const Nz::Color& color) = 0;
|
||||
virtual void BeginRenderPass(const Framebuffer& framebuffer, const RenderPass& renderPass, Nz::Recti renderRect, std::initializer_list<ClearValues> clearValues) = 0;
|
||||
|
||||
virtual void BindIndexBuffer(Nz::AbstractBuffer* indexBuffer, UInt64 offset = 0) = 0;
|
||||
virtual void BindShaderBinding(ShaderBinding& binding) = 0;
|
||||
virtual void BindPipeline(const RenderPipeline& pipeline) = 0;
|
||||
virtual void BindShaderBinding(const ShaderBinding& binding) = 0;
|
||||
virtual void BindVertexBuffer(UInt32 binding, Nz::AbstractBuffer* vertexBuffer, UInt64 offset = 0) = 0;
|
||||
|
||||
inline void CopyBuffer(const RenderBufferView& source, const RenderBufferView& target);
|
||||
@@ -42,6 +49,7 @@ namespace Nz
|
||||
virtual void DrawIndexed(UInt32 indexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, UInt32 firstInstance = 0) = 0;
|
||||
|
||||
virtual void EndDebugRegion() = 0;
|
||||
virtual void EndRenderPass() = 0;
|
||||
|
||||
virtual void PreTransferBarrier() = 0;
|
||||
virtual void PostTransferBarrier() = 0;
|
||||
@@ -51,6 +59,13 @@ namespace Nz
|
||||
|
||||
CommandBufferBuilder& operator=(const CommandBufferBuilder&) = delete;
|
||||
CommandBufferBuilder& operator=(CommandBufferBuilder&&) = default;
|
||||
|
||||
struct ClearValues
|
||||
{
|
||||
Nz::Color color;
|
||||
float depth;
|
||||
UInt32 stencil;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
30
include/Nazara/Renderer/Framebuffer.hpp
Normal file
30
include/Nazara/Renderer/Framebuffer.hpp
Normal file
@@ -0,0 +1,30 @@
|
||||
// Copyright (C) 2020 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_FRAMEBUFFER_HPP
|
||||
#define NAZARA_FRAMEBUFFER_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_RENDERER_API Framebuffer
|
||||
{
|
||||
public:
|
||||
Framebuffer() = default;
|
||||
Framebuffer(const Framebuffer&) = delete;
|
||||
Framebuffer(Framebuffer&&) noexcept = default;
|
||||
virtual ~Framebuffer();
|
||||
|
||||
Framebuffer& operator=(const Framebuffer&) = delete;
|
||||
Framebuffer& operator=(Framebuffer&&) noexcept = default;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/Framebuffer.inl>
|
||||
|
||||
#endif // NAZARA_FRAMEBUFFER_HPP
|
||||
12
include/Nazara/Renderer/Framebuffer.inl
Normal file
12
include/Nazara/Renderer/Framebuffer.inl
Normal file
@@ -0,0 +1,12 @@
|
||||
// Copyright (C) 2020 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Renderer/Framebuffer.hpp>
|
||||
#include <Nazara/Renderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/DebugOff.hpp>
|
||||
40
include/Nazara/Renderer/RenderPass.hpp
Normal file
40
include/Nazara/Renderer/RenderPass.hpp
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright (C) 2020 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_RENDERPASS_HPP
|
||||
#define NAZARA_RENDERPASS_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
#include <Nazara/Utility/PixelFormat.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_RENDERER_API RenderPass
|
||||
{
|
||||
public:
|
||||
struct Attachment;
|
||||
|
||||
RenderPass() = default;
|
||||
RenderPass(const RenderPass&) = delete;
|
||||
RenderPass(RenderPass&&) noexcept = default;
|
||||
virtual ~RenderPass();
|
||||
|
||||
RenderPass& operator=(const RenderPass&) = delete;
|
||||
RenderPass& operator=(RenderPass&&) noexcept = default;
|
||||
|
||||
struct Attachment
|
||||
{
|
||||
PixelFormat format;
|
||||
// TODO
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/RenderPass.inl>
|
||||
|
||||
#endif // NAZARA_RENDERPASS_HPP
|
||||
12
include/Nazara/Renderer/RenderPass.inl
Normal file
12
include/Nazara/Renderer/RenderPass.inl
Normal file
@@ -0,0 +1,12 @@
|
||||
// Copyright (C) 2020 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Renderer/RenderPass.hpp>
|
||||
#include <Nazara/Renderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/DebugOff.hpp>
|
||||
@@ -17,8 +17,10 @@
|
||||
namespace Nz
|
||||
{
|
||||
class CommandPool;
|
||||
class Framebuffer;
|
||||
class RendererImpl;
|
||||
class RenderImage;
|
||||
class RenderPass;
|
||||
class RenderSurface;
|
||||
|
||||
class NAZARA_RENDERER_API RenderWindowImpl
|
||||
@@ -32,7 +34,9 @@ namespace Nz
|
||||
virtual bool Create(RendererImpl* renderer, RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) = 0;
|
||||
virtual std::unique_ptr<CommandPool> CreateCommandPool(QueueType queueType) = 0;
|
||||
|
||||
virtual const Framebuffer& GetFramebuffer() const = 0;
|
||||
virtual std::shared_ptr<RenderDevice> GetRenderDevice() = 0;
|
||||
virtual const RenderPass& GetRenderPass() const = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -26,22 +26,12 @@ namespace Nz
|
||||
VkRenderTarget(VkRenderTarget&&) = delete; ///TOOD?
|
||||
virtual ~VkRenderTarget();
|
||||
|
||||
virtual const Vk::Framebuffer& GetFrameBuffer(UInt32 imageIndex) const = 0;
|
||||
virtual UInt32 GetFramebufferCount() const = 0;
|
||||
|
||||
inline const Vk::RenderPass& GetRenderPass() const;
|
||||
|
||||
VkRenderTarget& operator=(const VkRenderTarget&) = delete;
|
||||
VkRenderTarget& operator=(VkRenderTarget&&) = delete; ///TOOD?
|
||||
|
||||
// Signals:
|
||||
NazaraSignal(OnRenderTargetRelease, const VkRenderTarget* /*renderTarget*/);
|
||||
NazaraSignal(OnRenderTargetSizeChange, const VkRenderTarget* /*renderTarget*/);
|
||||
|
||||
protected:
|
||||
void Destroy();
|
||||
|
||||
Vk::RenderPass m_renderPass;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -7,10 +7,6 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline const Vk::RenderPass& VkRenderTarget::GetRenderPass() const
|
||||
{
|
||||
return m_renderPass;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/VulkanRenderer/DebugOff.hpp>
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
#include <Nazara/Renderer/RenderWindowImpl.hpp>
|
||||
#include <Nazara/VulkanRenderer/Config.hpp>
|
||||
#include <Nazara/VulkanRenderer/VulkanDevice.hpp>
|
||||
#include <Nazara/VulkanRenderer/VulkanMultipleFramebuffer.hpp>
|
||||
#include <Nazara/VulkanRenderer/VulkanRenderImage.hpp>
|
||||
#include <Nazara/VulkanRenderer/VulkanRenderPass.hpp>
|
||||
#include <Nazara/VulkanRenderer/VkRenderTarget.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/CommandPool.hpp>
|
||||
@@ -27,6 +29,7 @@
|
||||
#include <Nazara/VulkanRenderer/Wrapper/QueueHandle.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/Surface.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/Swapchain.hpp>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
namespace Nz
|
||||
@@ -44,11 +47,11 @@ namespace Nz
|
||||
bool Create(RendererImpl* renderer, RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) override;
|
||||
std::unique_ptr<CommandPool> CreateCommandPool(QueueType queueType) override;
|
||||
|
||||
inline const Vk::Framebuffer& GetFrameBuffer(UInt32 imageIndex) const override;
|
||||
inline UInt32 GetFramebufferCount() const override;
|
||||
inline const VulkanMultipleFramebuffer& GetFramebuffer() const override;
|
||||
inline VulkanDevice& GetDevice();
|
||||
inline const VulkanDevice& GetDevice() const;
|
||||
inline Vk::QueueHandle& GetGraphicsQueue();
|
||||
const VulkanRenderPass& GetRenderPass() const override;
|
||||
inline const Vk::Swapchain& GetSwapchain() const;
|
||||
|
||||
std::shared_ptr<RenderDevice> GetRenderDevice() override;
|
||||
@@ -63,19 +66,15 @@ namespace Nz
|
||||
bool SetupRenderPass();
|
||||
bool SetupSwapchain(const Vk::PhysicalDevice& deviceInfo, Vk::Surface& surface, const Vector2ui& size);
|
||||
|
||||
struct ImageData
|
||||
{
|
||||
Vk::Framebuffer framebuffer;
|
||||
Vk::Fence* inFlightFence = nullptr;
|
||||
};
|
||||
|
||||
std::size_t m_currentFrame;
|
||||
Clock m_clock;
|
||||
VkColorSpaceKHR m_colorSpace;
|
||||
VkFormat m_colorFormat;
|
||||
VkFormat m_depthStencilFormat;
|
||||
std::optional<VulkanMultipleFramebuffer> m_framebuffer;
|
||||
std::optional<VulkanRenderPass> m_renderPass;
|
||||
std::shared_ptr<VulkanDevice> m_device;
|
||||
std::vector<ImageData> m_imageData;
|
||||
std::vector<Vk::Fence*> m_inflightFences;
|
||||
std::vector<VulkanRenderImage> m_concurrentImageData;
|
||||
Vk::DeviceMemory m_depthBufferMemory;
|
||||
Vk::Image m_depthBuffer;
|
||||
|
||||
@@ -7,6 +7,11 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline const VulkanMultipleFramebuffer& VkRenderWindow::GetFramebuffer() const
|
||||
{
|
||||
return *m_framebuffer;
|
||||
}
|
||||
|
||||
inline VulkanDevice& VkRenderWindow::GetDevice()
|
||||
{
|
||||
return *m_device;
|
||||
@@ -22,16 +27,6 @@ namespace Nz
|
||||
return m_graphicsQueue;
|
||||
}
|
||||
|
||||
inline const Vk::Framebuffer& VkRenderWindow::GetFrameBuffer(UInt32 imageIndex) const
|
||||
{
|
||||
return m_imageData[imageIndex].framebuffer;
|
||||
}
|
||||
|
||||
inline UInt32 VkRenderWindow::GetFramebufferCount() const
|
||||
{
|
||||
return static_cast<UInt32>(m_imageData.size());
|
||||
}
|
||||
|
||||
inline const Vk::Swapchain& VkRenderWindow::GetSwapchain() const
|
||||
{
|
||||
return m_swapchain;
|
||||
@@ -44,11 +39,11 @@ namespace Nz
|
||||
|
||||
inline void VkRenderWindow::Present(UInt32 imageIndex, VkSemaphore waitSemaphore)
|
||||
{
|
||||
NazaraAssert(imageIndex < m_imageData.size(), "Invalid image index");
|
||||
NazaraAssert(imageIndex < m_inflightFences.size(), "Invalid image index");
|
||||
|
||||
m_presentQueue.Present(m_swapchain, imageIndex, waitSemaphore);
|
||||
|
||||
m_currentFrame = (m_currentFrame + 1) % m_imageData.size();
|
||||
m_currentFrame = (m_currentFrame + 1) % m_inflightFences.size();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <Nazara/Renderer/CommandBuffer.hpp>
|
||||
#include <Nazara/VulkanRenderer/Config.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
@@ -18,17 +19,18 @@ namespace Nz
|
||||
{
|
||||
public:
|
||||
inline VulkanCommandBuffer(Vk::AutoCommandBuffer commandBuffer);
|
||||
inline VulkanCommandBuffer(std::vector<Vk::AutoCommandBuffer> commandBuffers);
|
||||
VulkanCommandBuffer(const VulkanCommandBuffer&) = delete;
|
||||
VulkanCommandBuffer(VulkanCommandBuffer&&) noexcept = default;
|
||||
~VulkanCommandBuffer() = default;
|
||||
|
||||
inline Vk::CommandBuffer& GetCommandBuffer();
|
||||
inline Vk::CommandBuffer& GetCommandBuffer(std::size_t imageIndex = 0);
|
||||
|
||||
VulkanCommandBuffer& operator=(const VulkanCommandBuffer&) = delete;
|
||||
VulkanCommandBuffer& operator=(VulkanCommandBuffer&&) = delete;
|
||||
|
||||
private:
|
||||
Vk::AutoCommandBuffer m_commandBuffer;
|
||||
std::vector<Vk::AutoCommandBuffer> m_commandBuffers;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -7,14 +7,19 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline VulkanCommandBuffer::VulkanCommandBuffer(Vk::AutoCommandBuffer commandBuffer) :
|
||||
m_commandBuffer(std::move(commandBuffer))
|
||||
inline VulkanCommandBuffer::VulkanCommandBuffer(Vk::AutoCommandBuffer commandBuffer)
|
||||
{
|
||||
m_commandBuffers.push_back(std::move(commandBuffer));
|
||||
}
|
||||
|
||||
inline VulkanCommandBuffer::VulkanCommandBuffer(std::vector<Vk::AutoCommandBuffer> commandBuffers) :
|
||||
m_commandBuffers(std::move(commandBuffers))
|
||||
{
|
||||
}
|
||||
|
||||
inline Vk::CommandBuffer& VulkanCommandBuffer::GetCommandBuffer()
|
||||
inline Vk::CommandBuffer& VulkanCommandBuffer::GetCommandBuffer(std::size_t imageIndex)
|
||||
{
|
||||
return m_commandBuffer.Get();
|
||||
return m_commandBuffers[imageIndex].Get();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,18 +14,22 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class VulkanRenderPass;
|
||||
|
||||
class NAZARA_VULKANRENDERER_API VulkanCommandBufferBuilder final : public CommandBufferBuilder
|
||||
{
|
||||
public:
|
||||
inline VulkanCommandBufferBuilder(Vk::CommandBuffer& commandBuffer);
|
||||
inline VulkanCommandBufferBuilder(Vk::CommandBuffer& commandBuffer, std::size_t imageIndex = 0);
|
||||
VulkanCommandBufferBuilder(const VulkanCommandBufferBuilder&) = delete;
|
||||
VulkanCommandBufferBuilder(VulkanCommandBufferBuilder&&) noexcept = default;
|
||||
~VulkanCommandBufferBuilder() = default;
|
||||
|
||||
void BeginDebugRegion(const std::string_view& regionName, const Nz::Color& color) override;
|
||||
void BeginRenderPass(const Framebuffer& framebuffer, const RenderPass& renderPass, Nz::Recti renderRect, std::initializer_list<ClearValues> clearValues) override;
|
||||
|
||||
void BindIndexBuffer(AbstractBuffer* indexBuffer, UInt64 offset = 0) override;
|
||||
void BindShaderBinding(ShaderBinding& binding) override;
|
||||
void BindPipeline(const RenderPipeline& pipeline) override;
|
||||
void BindShaderBinding(const ShaderBinding& binding) override;
|
||||
void BindVertexBuffer(UInt32 binding, Nz::AbstractBuffer* vertexBuffer, UInt64 offset = 0) override;
|
||||
|
||||
void CopyBuffer(const RenderBufferView& source, const RenderBufferView& target, UInt64 size, UInt64 sourceOffset = 0, UInt64 targetOffset = 0) override;
|
||||
@@ -35,8 +39,10 @@ namespace Nz
|
||||
void DrawIndexed(UInt32 indexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, UInt32 firstInstance = 0) override;
|
||||
|
||||
void EndDebugRegion() override;
|
||||
void EndRenderPass() override;
|
||||
|
||||
inline Vk::CommandBuffer& GetCommandBuffer();
|
||||
inline std::size_t GetMaxFramebufferCount() const;
|
||||
|
||||
void PreTransferBarrier() override;
|
||||
void PostTransferBarrier() override;
|
||||
@@ -49,6 +55,9 @@ namespace Nz
|
||||
|
||||
private:
|
||||
Vk::CommandBuffer& m_commandBuffer;
|
||||
const VulkanRenderPass* m_currentRenderPass;
|
||||
std::size_t m_framebufferCount;
|
||||
std::size_t m_imageIndex;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,10 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline VulkanCommandBufferBuilder::VulkanCommandBufferBuilder(Vk::CommandBuffer& commandBuffer) :
|
||||
m_commandBuffer(commandBuffer)
|
||||
inline VulkanCommandBufferBuilder::VulkanCommandBufferBuilder(Vk::CommandBuffer& commandBuffer, std::size_t imageIndex) :
|
||||
m_commandBuffer(commandBuffer),
|
||||
m_framebufferCount(0),
|
||||
m_imageIndex(imageIndex)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -16,6 +18,11 @@ namespace Nz
|
||||
{
|
||||
return m_commandBuffer;
|
||||
}
|
||||
|
||||
inline std::size_t VulkanCommandBufferBuilder::GetMaxFramebufferCount() const
|
||||
{
|
||||
return m_framebufferCount;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/VulkanRenderer/DebugOff.hpp>
|
||||
|
||||
43
include/Nazara/VulkanRenderer/VulkanFramebuffer.hpp
Normal file
43
include/Nazara/VulkanRenderer/VulkanFramebuffer.hpp
Normal file
@@ -0,0 +1,43 @@
|
||||
// Copyright (C) 2020 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
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_VULKANRENDERER_VULKANFRAMEBUFFER_HPP
|
||||
#define NAZARA_VULKANRENDERER_VULKANFRAMEBUFFER_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Renderer/Framebuffer.hpp>
|
||||
#include <Nazara/VulkanRenderer/Config.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/Framebuffer.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_VULKANRENDERER_API VulkanFramebuffer : public Framebuffer
|
||||
{
|
||||
public:
|
||||
enum class Type
|
||||
{
|
||||
Multiple,
|
||||
Single
|
||||
};
|
||||
|
||||
inline VulkanFramebuffer(Type type);
|
||||
VulkanFramebuffer(const VulkanFramebuffer&) = delete;
|
||||
VulkanFramebuffer(VulkanFramebuffer&&) noexcept = default;
|
||||
~VulkanFramebuffer() = default;
|
||||
|
||||
inline Type GetType() const;
|
||||
|
||||
VulkanFramebuffer& operator=(const VulkanFramebuffer&) = delete;
|
||||
VulkanFramebuffer& operator=(VulkanFramebuffer&&) noexcept = default;
|
||||
|
||||
private:
|
||||
Type m_type;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/VulkanRenderer/VulkanFramebuffer.inl>
|
||||
|
||||
#endif // NAZARA_VULKANRENDERER_VULKANFRAMEBUFFER_HPP
|
||||
21
include/Nazara/VulkanRenderer/VulkanFramebuffer.inl
Normal file
21
include/Nazara/VulkanRenderer/VulkanFramebuffer.inl
Normal file
@@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2020 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/VulkanFramebuffer.hpp>
|
||||
#include <Nazara/VulkanRenderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline VulkanFramebuffer::VulkanFramebuffer(Type type) :
|
||||
m_type(type)
|
||||
{
|
||||
}
|
||||
|
||||
inline auto VulkanFramebuffer::GetType() const -> Type
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/VulkanRenderer/DebugOff.hpp>
|
||||
36
include/Nazara/VulkanRenderer/VulkanMultipleFramebuffer.hpp
Normal file
36
include/Nazara/VulkanRenderer/VulkanMultipleFramebuffer.hpp
Normal file
@@ -0,0 +1,36 @@
|
||||
// Copyright (C) 2020 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
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_VULKANRENDERER_VULKANMULTIPLEFRAMEBUFFER_HPP
|
||||
#define NAZARA_VULKANRENDERER_VULKANMULTIPLEFRAMEBUFFER_HPP
|
||||
|
||||
#include <Nazara/VulkanRenderer/VulkanFramebuffer.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_VULKANRENDERER_API VulkanMultipleFramebuffer final : public VulkanFramebuffer
|
||||
{
|
||||
public:
|
||||
inline VulkanMultipleFramebuffer(Vk::Framebuffer* framebuffers, std::size_t count);
|
||||
VulkanMultipleFramebuffer(const VulkanMultipleFramebuffer&) = delete;
|
||||
VulkanMultipleFramebuffer(VulkanMultipleFramebuffer&&) noexcept = default;
|
||||
~VulkanMultipleFramebuffer() = default;
|
||||
|
||||
inline const Vk::Framebuffer& GetFramebuffer(std::size_t index) const;
|
||||
inline std::size_t GetFramebufferCount() const;
|
||||
|
||||
VulkanMultipleFramebuffer& operator=(const VulkanMultipleFramebuffer&) = delete;
|
||||
VulkanMultipleFramebuffer& operator=(VulkanMultipleFramebuffer&&) noexcept = default;
|
||||
|
||||
private:
|
||||
std::vector<Vk::Framebuffer> m_framebuffers;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/VulkanRenderer/VulkanMultipleFramebuffer.inl>
|
||||
|
||||
#endif // NAZARA_VULKANRENDERER_VULKANMULTIPLEFRAMEBUFFER_HPP
|
||||
30
include/Nazara/VulkanRenderer/VulkanMultipleFramebuffer.inl
Normal file
30
include/Nazara/VulkanRenderer/VulkanMultipleFramebuffer.inl
Normal file
@@ -0,0 +1,30 @@
|
||||
// Copyright (C) 2020 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/VulkanMultipleFramebuffer.hpp>
|
||||
#include <Nazara/VulkanRenderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline VulkanMultipleFramebuffer::VulkanMultipleFramebuffer(Vk::Framebuffer* framebuffers, std::size_t count) :
|
||||
VulkanFramebuffer(Type::Multiple)
|
||||
{
|
||||
m_framebuffers.reserve(count);
|
||||
for (std::size_t i = 0; i < count; ++i)
|
||||
m_framebuffers.push_back(std::move(framebuffers[i]));
|
||||
}
|
||||
|
||||
inline const Vk::Framebuffer& Nz::VulkanMultipleFramebuffer::GetFramebuffer(std::size_t index) const
|
||||
{
|
||||
assert(index < m_framebuffers.size());
|
||||
return m_framebuffers[index];
|
||||
}
|
||||
|
||||
inline std::size_t VulkanMultipleFramebuffer::GetFramebufferCount() const
|
||||
{
|
||||
return m_framebuffers.size();
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/VulkanRenderer/DebugOff.hpp>
|
||||
41
include/Nazara/VulkanRenderer/VulkanRenderPass.hpp
Normal file
41
include/Nazara/VulkanRenderer/VulkanRenderPass.hpp
Normal file
@@ -0,0 +1,41 @@
|
||||
// Copyright (C) 2020 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
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_VULKANRENDERER_VULKANRENDERPASS_HPP
|
||||
#define NAZARA_VULKANRENDERER_VULKANRENDERPASS_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Renderer/RenderPass.hpp>
|
||||
#include <Nazara/VulkanRenderer/Config.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/RenderPass.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_VULKANRENDERER_API VulkanRenderPass final : public RenderPass
|
||||
{
|
||||
public:
|
||||
inline VulkanRenderPass(Vk::RenderPass renderPass, std::initializer_list<PixelFormat> formats); //< FIXME
|
||||
VulkanRenderPass(const VulkanRenderPass&) = delete;
|
||||
VulkanRenderPass(VulkanRenderPass&&) noexcept = default;
|
||||
~VulkanRenderPass() = default;
|
||||
|
||||
inline PixelFormat GetAttachmentFormat(std::size_t attachmentIndex) const;
|
||||
inline Vk::RenderPass& GetRenderPass();
|
||||
inline const Vk::RenderPass& GetRenderPass() const;
|
||||
|
||||
VulkanRenderPass& operator=(const VulkanRenderPass&) = delete;
|
||||
VulkanRenderPass& operator=(VulkanRenderPass&&) noexcept = default;
|
||||
|
||||
private:
|
||||
std::vector<PixelFormat> m_formats;
|
||||
Vk::RenderPass m_renderPass;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/VulkanRenderer/VulkanRenderPass.inl>
|
||||
|
||||
#endif // NAZARA_VULKANRENDERER_VULKANRENDERPASS_HPP
|
||||
32
include/Nazara/VulkanRenderer/VulkanRenderPass.inl
Normal file
32
include/Nazara/VulkanRenderer/VulkanRenderPass.inl
Normal file
@@ -0,0 +1,32 @@
|
||||
// Copyright (C) 2020 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/VulkanRenderPass.hpp>
|
||||
#include <Nazara/VulkanRenderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline VulkanRenderPass::VulkanRenderPass(Vk::RenderPass renderPass, std::initializer_list<PixelFormat> formats) :
|
||||
m_formats(std::begin(formats), std::end(formats)),
|
||||
m_renderPass(std::move(renderPass))
|
||||
{
|
||||
}
|
||||
|
||||
inline PixelFormat VulkanRenderPass::GetAttachmentFormat(std::size_t attachmentIndex) const
|
||||
{
|
||||
return m_formats[attachmentIndex];
|
||||
}
|
||||
|
||||
inline Vk::RenderPass& VulkanRenderPass::GetRenderPass()
|
||||
{
|
||||
return m_renderPass;
|
||||
}
|
||||
|
||||
inline const Vk::RenderPass& VulkanRenderPass::GetRenderPass() const
|
||||
{
|
||||
return m_renderPass;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/VulkanRenderer/DebugOff.hpp>
|
||||
@@ -26,7 +26,7 @@ namespace Nz
|
||||
VulkanRenderPipeline(Vk::Device& device, RenderPipelineInfo pipelineInfo);
|
||||
~VulkanRenderPipeline() = default;
|
||||
|
||||
VkPipeline Get(const Vk::RenderPass& renderPass);
|
||||
VkPipeline Get(const Vk::RenderPass& renderPass) const;
|
||||
|
||||
static std::vector<VkPipelineColorBlendAttachmentState> BuildColorBlendAttachmentStateList(const RenderPipelineInfo& pipelineInfo);
|
||||
static VkPipelineColorBlendStateCreateInfo BuildColorBlendInfo(const RenderPipelineInfo& pipelineInfo, const std::vector<VkPipelineColorBlendAttachmentState>& attachmentState);
|
||||
@@ -69,7 +69,7 @@ namespace Nz
|
||||
};
|
||||
|
||||
private:
|
||||
std::unordered_map<VkRenderPass, Vk::Pipeline> m_pipelines;
|
||||
mutable std::unordered_map<VkRenderPass, Vk::Pipeline> m_pipelines;
|
||||
MovablePtr<Vk::Device> m_device;
|
||||
CreateInfo m_pipelineCreateInfo;
|
||||
RenderPipelineInfo m_pipelineInfo;
|
||||
|
||||
@@ -24,9 +24,9 @@ namespace Nz
|
||||
~VulkanShaderBinding() = default;
|
||||
|
||||
inline std::size_t GetBindingIndex() const;
|
||||
inline Vk::DescriptorSet& GetDescriptorSet();
|
||||
inline const Vk::DescriptorSet& GetDescriptorSet() const;
|
||||
inline std::size_t GetPoolIndex() const;
|
||||
inline VulkanRenderPipelineLayout& GetOwner();
|
||||
inline const VulkanRenderPipelineLayout& GetOwner() const;
|
||||
|
||||
void Update(std::initializer_list<Binding> bindings) override;
|
||||
|
||||
|
||||
@@ -25,12 +25,12 @@ namespace Nz
|
||||
return m_poolIndex;
|
||||
}
|
||||
|
||||
inline Vk::DescriptorSet& VulkanShaderBinding::GetDescriptorSet()
|
||||
inline const Vk::DescriptorSet& VulkanShaderBinding::GetDescriptorSet() const
|
||||
{
|
||||
return m_descriptorSet;
|
||||
}
|
||||
|
||||
inline VulkanRenderPipelineLayout& VulkanShaderBinding::GetOwner()
|
||||
inline const VulkanRenderPipelineLayout& VulkanShaderBinding::GetOwner() const
|
||||
{
|
||||
return m_owner;
|
||||
}
|
||||
|
||||
35
include/Nazara/VulkanRenderer/VulkanSingleFramebuffer.hpp
Normal file
35
include/Nazara/VulkanRenderer/VulkanSingleFramebuffer.hpp
Normal file
@@ -0,0 +1,35 @@
|
||||
// Copyright (C) 2020 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
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_VULKANRENDERER_VULKANSINGLEFRAMEBUFFER_HPP
|
||||
#define NAZARA_VULKANRENDERER_VULKANSINGLEFRAMEBUFFER_HPP
|
||||
|
||||
#include <Nazara/VulkanRenderer/VulkanFramebuffer.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_VULKANRENDERER_API VulkanSingleFramebuffer final : public VulkanFramebuffer
|
||||
{
|
||||
public:
|
||||
inline VulkanSingleFramebuffer(Vk::Framebuffer renderPass);
|
||||
VulkanSingleFramebuffer(const VulkanSingleFramebuffer&) = delete;
|
||||
VulkanSingleFramebuffer(VulkanSingleFramebuffer&&) noexcept = default;
|
||||
~VulkanSingleFramebuffer() = default;
|
||||
|
||||
inline Vk::Framebuffer& GetFramebuffer();
|
||||
inline const Vk::Framebuffer& GetFramebuffer() const;
|
||||
|
||||
VulkanSingleFramebuffer& operator=(const VulkanSingleFramebuffer&) = delete;
|
||||
VulkanSingleFramebuffer& operator=(VulkanSingleFramebuffer&&) noexcept = default;
|
||||
|
||||
private:
|
||||
Vk::Framebuffer m_framebuffer;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/VulkanRenderer/VulkanSingleFramebuffer.inl>
|
||||
|
||||
#endif // NAZARA_VULKANRENDERER_VULKANSINGLEFRAMEBUFFER_HPP
|
||||
27
include/Nazara/VulkanRenderer/VulkanSingleFramebuffer.inl
Normal file
27
include/Nazara/VulkanRenderer/VulkanSingleFramebuffer.inl
Normal file
@@ -0,0 +1,27 @@
|
||||
// Copyright (C) 2020 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/VulkanSingleFramebuffer.hpp>
|
||||
#include <Nazara/VulkanRenderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline VulkanSingleFramebuffer::VulkanSingleFramebuffer(Vk::Framebuffer framebuffer) :
|
||||
VulkanFramebuffer(Type::Single),
|
||||
m_framebuffer(std::move(framebuffer))
|
||||
{
|
||||
}
|
||||
|
||||
inline Vk::Framebuffer& VulkanSingleFramebuffer::GetFramebuffer()
|
||||
{
|
||||
return m_framebuffer;
|
||||
}
|
||||
|
||||
inline const Vk::Framebuffer& VulkanSingleFramebuffer::GetFramebuffer() const
|
||||
{
|
||||
return m_framebuffer;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/VulkanRenderer/DebugOff.hpp>
|
||||
@@ -38,7 +38,7 @@ namespace Nz
|
||||
void SetDebugName(const std::string& name);
|
||||
|
||||
DeviceObject& operator=(const DeviceObject&) = delete;
|
||||
DeviceObject& operator=(DeviceObject&&) = delete;
|
||||
DeviceObject& operator=(DeviceObject&& object) noexcept;
|
||||
|
||||
operator VkType() const;
|
||||
|
||||
|
||||
@@ -103,6 +103,17 @@ namespace Nz
|
||||
return SetDebugName(name.data());
|
||||
}
|
||||
|
||||
template<typename C, typename VkType, typename CreateInfo, VkObjectType ObjectType>
|
||||
auto DeviceObject<C, VkType, CreateInfo, ObjectType>::operator=(DeviceObject&& object) noexcept -> DeviceObject&
|
||||
{
|
||||
std::swap(m_allocator, object.m_allocator);
|
||||
std::swap(m_device, object.m_device);
|
||||
std::swap(m_handle, object.m_handle);
|
||||
std::swap(m_lastErrorCode, object.m_lastErrorCode);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename C, typename VkType, typename CreateInfo, VkObjectType ObjectType>
|
||||
DeviceObject<C, VkType, CreateInfo, ObjectType>::operator VkType() const
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Nz
|
||||
~RenderPass() = default;
|
||||
|
||||
RenderPass& operator=(const RenderPass&) = delete;
|
||||
RenderPass& operator=(RenderPass&&) = delete;
|
||||
RenderPass& operator=(RenderPass&&) = default;
|
||||
|
||||
private:
|
||||
static inline VkResult CreateHelper(Device& device, const VkRenderPassCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkRenderPass* handle);
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
|
||||
#include <NazaraSDK/Components/PhysicsComponent3D.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include "PhysicsComponent3D.hpp"
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user