Renderer/RenderFrame: Use FunctionRef instead of std::function to avoid allocations

This commit is contained in:
SirLynix
2023-01-01 19:48:51 +01:00
parent 8555b3d6ef
commit a8b6d9cb42
7 changed files with 9 additions and 7 deletions

View File

@@ -17,7 +17,7 @@ namespace Nz
{
}
void OpenGLRenderImage::Execute(const std::function<void(CommandBufferBuilder& builder)>& callback, QueueTypeFlags /*queueTypeFlags*/)
void OpenGLRenderImage::Execute(const FunctionRef<void(CommandBufferBuilder& builder)>& callback, QueueTypeFlags /*queueTypeFlags*/)
{
OpenGLCommandBuffer commandBuffer; //< TODO: Use a pool and remove default constructor
OpenGLCommandBufferBuilder builder(commandBuffer);

View File

@@ -9,7 +9,7 @@
namespace Nz
{
void RenderFrame::Execute(const std::function<void(CommandBufferBuilder& builder)>& callback, QueueTypeFlags queueTypeFlags)
void RenderFrame::Execute(const FunctionRef<void(CommandBufferBuilder& builder)>& callback, QueueTypeFlags queueTypeFlags)
{
if (!m_image)
throw std::runtime_error("frame is either invalid or has already been presented");

View File

@@ -34,7 +34,7 @@ namespace Nz
m_inFlightCommandBuffers.clear();
}
void VulkanRenderImage::Execute(const std::function<void(CommandBufferBuilder& builder)>& callback, QueueTypeFlags queueTypeFlags)
void VulkanRenderImage::Execute(const FunctionRef<void(CommandBufferBuilder& builder)>& callback, QueueTypeFlags queueTypeFlags)
{
Vk::CommandBuffer* commandBuffer;
if (m_currentCommandBuffer >= m_inFlightCommandBuffers.size())