Renderer: Blit texture to window instead of using a full renderpass
This may improve performance and allow for render targets to customize how they blit the final texture (allowing for render-to-texture)
This commit is contained in:
@@ -26,6 +26,7 @@ namespace Nz
|
||||
class RenderPipeline;
|
||||
class RenderPipelineLayout;
|
||||
class ShaderBinding;
|
||||
class Swapchain;
|
||||
class Texture;
|
||||
|
||||
class NAZARA_RENDERER_API CommandBufferBuilder
|
||||
@@ -53,6 +54,7 @@ namespace Nz
|
||||
virtual void BindVertexBuffer(UInt32 binding, const RenderBuffer& vertexBuffer, UInt64 offset = 0) = 0;
|
||||
|
||||
virtual void BlitTexture(const Texture& fromTexture, const Boxui& fromBox, TextureLayout fromLayout, const Texture& toTexture, const Boxui& toBox, TextureLayout toLayout, SamplerFilter filter) = 0;
|
||||
virtual void BlitTextureToSwapchain(const Texture& fromTexture, const Boxui& fromBox, TextureLayout fromLayout, const Swapchain& swapchain, std::size_t imageIndex) = 0;
|
||||
|
||||
virtual void BuildMipmaps(Texture& texture, UInt8 baseLevel, UInt8 levelCount, PipelineStageFlags srcStageMask, PipelineStageFlags dstStageMask, MemoryAccessFlags srcAccessMask, MemoryAccessFlags dstAccessMask, TextureLayout oldLayout, TextureLayout newLayout) = 0;
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace Nz
|
||||
{
|
||||
class CommandBuffer;
|
||||
class CommandBufferBuilder;
|
||||
class RenderDevice;
|
||||
class UploadPool;
|
||||
|
||||
class NAZARA_RENDERER_API RenderFrame
|
||||
@@ -30,11 +31,12 @@ namespace Nz
|
||||
RenderFrame(RenderFrame&&) = delete;
|
||||
~RenderFrame() = default;
|
||||
|
||||
void Execute(const FunctionRef<void(CommandBufferBuilder& builder)>& callback, QueueTypeFlags queueTypeFlags);
|
||||
inline void Execute(const FunctionRef<void(CommandBufferBuilder& builder)>& callback, QueueTypeFlags queueTypeFlags);
|
||||
|
||||
inline std::size_t GetFramebufferIndex() const;
|
||||
const Vector2ui& GetSize() const;
|
||||
UploadPool& GetUploadPool();
|
||||
inline RenderDevice& GetRenderDevice();
|
||||
inline UploadPool& GetUploadPool();
|
||||
|
||||
inline bool IsFramebufferInvalidated() const;
|
||||
|
||||
|
||||
@@ -37,6 +37,11 @@ namespace Nz
|
||||
return m_size;
|
||||
}
|
||||
|
||||
inline RenderDevice& RenderFrame::GetRenderDevice()
|
||||
{
|
||||
return m_image->GetRenderDevice();
|
||||
}
|
||||
|
||||
inline UploadPool& RenderFrame::GetUploadPool()
|
||||
{
|
||||
if NAZARA_UNLIKELY(!m_image)
|
||||
|
||||
@@ -15,6 +15,8 @@ namespace Nz
|
||||
class NAZARA_RENDERER_API RenderImage : public TransientResources
|
||||
{
|
||||
public:
|
||||
using TransientResources::TransientResources;
|
||||
|
||||
virtual void Present() = 0;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -14,8 +14,11 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class CommandBufferBuilder;
|
||||
class Framebuffer;
|
||||
class RenderFrame;
|
||||
class RenderPass;
|
||||
class Texture;
|
||||
|
||||
class NAZARA_RENDERER_API RenderTarget
|
||||
{
|
||||
@@ -23,6 +26,8 @@ namespace Nz
|
||||
RenderTarget() = default;
|
||||
virtual ~RenderTarget();
|
||||
|
||||
virtual void BlitTexture(RenderFrame& renderFrame, CommandBufferBuilder& builder, const Texture& texture) const = 0;
|
||||
|
||||
virtual const Framebuffer& GetFramebuffer(std::size_t i) const = 0;
|
||||
virtual std::size_t GetFramebufferCount() const = 0;
|
||||
virtual const RenderPass& GetRenderPass() const = 0;
|
||||
|
||||
@@ -29,6 +29,8 @@ namespace Nz
|
||||
|
||||
virtual RenderFrame AcquireFrame() = 0;
|
||||
|
||||
void BlitTexture(RenderFrame& renderFrame, CommandBufferBuilder& builder, const Texture& texture) const override;
|
||||
|
||||
virtual std::shared_ptr<CommandPool> CreateCommandPool(QueueType queueType) = 0;
|
||||
|
||||
virtual PresentMode GetPresentMode() const = 0;
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace Nz
|
||||
{
|
||||
class CommandBuffer;
|
||||
class CommandBufferBuilder;
|
||||
class RenderDevice;
|
||||
class UploadPool;
|
||||
|
||||
class NAZARA_RENDERER_API TransientResources
|
||||
@@ -33,6 +34,7 @@ namespace Nz
|
||||
|
||||
inline void FlushReleaseQueue();
|
||||
|
||||
inline RenderDevice& GetRenderDevice();
|
||||
virtual UploadPool& GetUploadPool() = 0;
|
||||
|
||||
template<typename T> void PushForRelease(const T& value) = delete;
|
||||
@@ -42,7 +44,7 @@ namespace Nz
|
||||
virtual void SubmitCommandBuffer(CommandBuffer* commandBuffer, QueueTypeFlags queueTypeFlags) = 0;
|
||||
|
||||
protected:
|
||||
TransientResources() = default;
|
||||
inline TransientResources(RenderDevice& renderDvice);
|
||||
TransientResources(const TransientResources&) = delete;
|
||||
TransientResources(TransientResources&&) = delete;
|
||||
|
||||
@@ -53,6 +55,7 @@ namespace Nz
|
||||
|
||||
std::vector<Releasable*> m_releaseQueue;
|
||||
std::vector<Block> m_releaseMemoryPool;
|
||||
RenderDevice& m_renderDevice;
|
||||
};
|
||||
|
||||
class NAZARA_RENDERER_API TransientResources::Releasable
|
||||
|
||||
@@ -8,6 +8,11 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline TransientResources::TransientResources(RenderDevice& renderDevice) :
|
||||
m_renderDevice(renderDevice)
|
||||
{
|
||||
}
|
||||
|
||||
inline void TransientResources::FlushReleaseQueue()
|
||||
{
|
||||
for (Releasable* releasable : m_releaseQueue)
|
||||
@@ -21,6 +26,11 @@ namespace Nz
|
||||
memoryblock.clear();
|
||||
}
|
||||
|
||||
inline RenderDevice& TransientResources::GetRenderDevice()
|
||||
{
|
||||
return m_renderDevice;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void TransientResources::PushForRelease(T&& value)
|
||||
{
|
||||
@@ -98,3 +108,4 @@ namespace Nz
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/DebugOff.hpp>
|
||||
#include "TransientResources.hpp"
|
||||
|
||||
@@ -29,6 +29,8 @@ namespace Nz
|
||||
|
||||
inline RenderFrame AcquireFrame();
|
||||
|
||||
inline void BlitTexture(RenderFrame& renderFrame, CommandBufferBuilder& builder, const Texture& texture) const override;
|
||||
|
||||
inline bool DoesRenderOnlyIfFocused() const;
|
||||
|
||||
inline void EnableRenderOnlyIfFocused(bool enable = true);
|
||||
|
||||
@@ -20,6 +20,11 @@ namespace Nz
|
||||
return m_swapchain->AcquireFrame();
|
||||
}
|
||||
|
||||
inline void WindowSwapchain::BlitTexture(RenderFrame& renderFrame, CommandBufferBuilder& builder, const Texture& texture) const
|
||||
{
|
||||
return m_swapchain->BlitTexture(renderFrame, builder, texture);
|
||||
}
|
||||
|
||||
inline bool WindowSwapchain::DoesRenderOnlyIfFocused() const
|
||||
{
|
||||
return m_renderOnlyIfFocused;
|
||||
|
||||
Reference in New Issue
Block a user