Vulkan/RenderTarget: Change interface to better suit needs
Former-commit-id: cc61462eca9a4b73821eb0c9bd10b74366e5a6ce [formerly 8e64df958d6b9ccd61b9df22456cd566947fcb0b] Former-commit-id: 750ea64ee603b0c52058eb93045310db4977dfdb
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include <Nazara/Vulkan/Config.hpp>
|
||||
#include <Nazara/Vulkan/VkFrameBuffer.hpp>
|
||||
#include <Nazara/Vulkan/VkRenderPass.hpp>
|
||||
#include <Nazara/Vulkan/VkSemaphore.hpp>
|
||||
#include <unordered_map>
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
@@ -29,11 +30,19 @@ namespace Nz
|
||||
RenderTarget(RenderTarget&&) = delete; ///TOOD?
|
||||
virtual ~RenderTarget();
|
||||
|
||||
virtual bool Acquire(const Vk::Framebuffer** framebuffer) const = 0;
|
||||
virtual bool Acquire(UInt32* imageIndex) const = 0;
|
||||
|
||||
virtual void BuildPreRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) = 0;
|
||||
virtual void BuildPostRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) = 0;
|
||||
|
||||
virtual const Vk::Framebuffer& GetFrameBuffer(UInt32 imageIndex) const = 0;
|
||||
virtual UInt32 GetFramebufferCount() const = 0;
|
||||
|
||||
const Vk::RenderPass& GetRenderPass() const { return m_renderPass; }
|
||||
|
||||
virtual void Present() = 0;
|
||||
const Vk::Semaphore& GetRenderSemaphore() const { return m_imageReadySemaphore; }
|
||||
|
||||
virtual void Present(UInt32 imageIndex) = 0;
|
||||
|
||||
RenderTarget& operator=(const RenderTarget&) = delete;
|
||||
RenderTarget& operator=(RenderTarget&&) = delete; ///TOOD?
|
||||
@@ -44,6 +53,7 @@ namespace Nz
|
||||
|
||||
protected:
|
||||
Vk::RenderPass m_renderPass;
|
||||
Vk::Semaphore m_imageReadySemaphore;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include <Nazara/Vulkan/VkCommandPool.hpp>
|
||||
#include <Nazara/Vulkan/VkDevice.hpp>
|
||||
#include <Nazara/Vulkan/VkFramebuffer.hpp>
|
||||
#include <Nazara/Vulkan/VkSemaphore.hpp>
|
||||
#include <Nazara/Vulkan/VkSurface.hpp>
|
||||
#include <Nazara/Vulkan/VkSwapchain.hpp>
|
||||
#include <Nazara/Utility/Window.hpp>
|
||||
@@ -35,7 +34,14 @@ namespace Nz
|
||||
RenderWindow(RenderWindow&&) = delete; ///TODO
|
||||
virtual ~RenderWindow();
|
||||
|
||||
bool Acquire(const Vk::Framebuffer** framebuffer) const override;
|
||||
bool Acquire(UInt32* index) const override;
|
||||
|
||||
void BuildPreRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) override;
|
||||
void BuildPostRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) override;
|
||||
|
||||
const Vk::Framebuffer& GetFrameBuffer(UInt32 imageIndex) const override;
|
||||
|
||||
UInt32 GetFramebufferCount() const;
|
||||
|
||||
bool Create(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default);
|
||||
bool Create(WindowHandle handle);
|
||||
@@ -45,7 +51,7 @@ namespace Nz
|
||||
const Vk::Surface& GetSurface() const;
|
||||
const Vk::Swapchain& GetSwapchain() const;
|
||||
|
||||
void Present() override;
|
||||
void Present(UInt32 imageIndex) override;
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
@@ -59,25 +65,20 @@ namespace Nz
|
||||
void OnWindowDestroy() override;
|
||||
void OnWindowResized() override;
|
||||
|
||||
bool SetupRenderPass(VkFormat colorFormat, VkFormat depthFormat);
|
||||
|
||||
struct ImageData
|
||||
{
|
||||
Vk::CommandBuffer drawToPresentCmd;
|
||||
Vk::CommandBuffer presentToDrawCmd;
|
||||
Vk::Framebuffer frameBuffer;
|
||||
};
|
||||
bool SetupCommandBuffers();
|
||||
bool SetupRenderPass();
|
||||
bool SetupSwapchain();
|
||||
|
||||
Clock m_clock;
|
||||
VkFormat m_colorFormat;
|
||||
VkFormat m_depthFormat;
|
||||
VkColorSpaceKHR m_colorSpace;
|
||||
VkPhysicalDevice m_forcedPhysicalDevice;
|
||||
std::vector<ImageData> m_images;
|
||||
Vk::CommandPool m_cmdPool;
|
||||
std::vector<Vk::Framebuffer> m_frameBuffers;
|
||||
Vk::DeviceHandle m_device;
|
||||
Vk::Queue m_presentQueue;
|
||||
Vk::Semaphore m_imageReadySemaphore;
|
||||
Vk::Surface m_surface;
|
||||
Vk::Swapchain m_swapchain;
|
||||
mutable UInt32 m_lastImageAcquired;
|
||||
UInt32 m_presentableFamilyQueue;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user