Renderer: Replace unique_ptr by shared_ptr

This commit is contained in:
Jérôme Leclercq
2020-09-20 15:56:58 +02:00
parent 77b46e4811
commit f15709c8a3
13 changed files with 55 additions and 55 deletions

View File

@@ -48,19 +48,19 @@ namespace Nz
return contextPtr;
}
std::unique_ptr<AbstractBuffer> OpenGLDevice::InstantiateBuffer(BufferType type)
std::shared_ptr<AbstractBuffer> OpenGLDevice::InstantiateBuffer(BufferType type)
{
return std::make_unique<OpenGLBuffer>(*this, type);
return std::make_shared<OpenGLBuffer>(*this, type);
}
std::unique_ptr<CommandPool> OpenGLDevice::InstantiateCommandPool(QueueType /*queueType*/)
std::shared_ptr<CommandPool> OpenGLDevice::InstantiateCommandPool(QueueType /*queueType*/)
{
return std::make_unique<OpenGLCommandPool>();
return std::make_shared<OpenGLCommandPool>();
}
std::unique_ptr<RenderPipeline> OpenGLDevice::InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo)
std::shared_ptr<RenderPipeline> OpenGLDevice::InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo)
{
return std::make_unique<OpenGLRenderPipeline>(*this, std::move(pipelineInfo));
return std::make_shared<OpenGLRenderPipeline>(*this, std::move(pipelineInfo));
}
std::shared_ptr<RenderPipelineLayout> OpenGLDevice::InstantiateRenderPipelineLayout(RenderPipelineLayoutInfo pipelineLayoutInfo)
@@ -73,14 +73,14 @@ namespace Nz
return std::make_shared<OpenGLShaderStage>(*this, type, lang, source, sourceSize);
}
std::unique_ptr<Texture> OpenGLDevice::InstantiateTexture(const TextureInfo& params)
std::shared_ptr<Texture> OpenGLDevice::InstantiateTexture(const TextureInfo& params)
{
return std::make_unique<OpenGLTexture>(*this, params);
return std::make_shared<OpenGLTexture>(*this, params);
}
std::unique_ptr<TextureSampler> OpenGLDevice::InstantiateTextureSampler(const TextureSamplerInfo& params)
std::shared_ptr<TextureSampler> OpenGLDevice::InstantiateTextureSampler(const TextureSamplerInfo& params)
{
return std::make_unique<OpenGLTextureSampler>(*this, params);
return std::make_shared<OpenGLTextureSampler>(*this, params);
}
}

View File

@@ -59,7 +59,7 @@ namespace Nz
return true;
}
std::unique_ptr<CommandPool> OpenGLRenderWindow::CreateCommandPool(QueueType /*queueType*/)
std::shared_ptr<CommandPool> OpenGLRenderWindow::CreateCommandPool(QueueType /*queueType*/)
{
return std::make_unique<OpenGLCommandPool>();
}

View File

@@ -219,7 +219,7 @@ namespace Nz
return true;
}
std::unique_ptr<CommandPool> VkRenderWindow::CreateCommandPool(QueueType queueType)
std::shared_ptr<CommandPool> VkRenderWindow::CreateCommandPool(QueueType queueType)
{
UInt32 queueFamilyIndex = [&] {
switch (queueType)
@@ -237,7 +237,7 @@ namespace Nz
throw std::runtime_error("invalid queue type " + std::to_string(UnderlyingCast(queueType)));
}();
return std::make_unique<VulkanCommandPool>(*m_device, queueFamilyIndex);
return std::make_shared<VulkanCommandPool>(*m_device, queueFamilyIndex);
}
void VkRenderWindow::Present(UInt32 imageIndex, VkSemaphore waitSemaphore)

View File

@@ -15,19 +15,19 @@ namespace Nz
{
VulkanDevice::~VulkanDevice() = default;
std::unique_ptr<AbstractBuffer> VulkanDevice::InstantiateBuffer(BufferType type)
std::shared_ptr<AbstractBuffer> VulkanDevice::InstantiateBuffer(BufferType type)
{
return std::make_unique<VulkanBuffer>(*this, type);
return std::make_shared<VulkanBuffer>(*this, type);
}
std::unique_ptr<CommandPool> VulkanDevice::InstantiateCommandPool(QueueType queueType)
std::shared_ptr<CommandPool> VulkanDevice::InstantiateCommandPool(QueueType queueType)
{
return std::make_unique<VulkanCommandPool>(*this, queueType);
return std::make_shared<VulkanCommandPool>(*this, queueType);
}
std::unique_ptr<RenderPipeline> VulkanDevice::InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo)
std::shared_ptr<RenderPipeline> VulkanDevice::InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo)
{
return std::make_unique<VulkanRenderPipeline>(*this, std::move(pipelineInfo));
return std::make_shared<VulkanRenderPipeline>(*this, std::move(pipelineInfo));
}
std::shared_ptr<RenderPipelineLayout> VulkanDevice::InstantiateRenderPipelineLayout(RenderPipelineLayoutInfo pipelineLayoutInfo)
@@ -48,13 +48,13 @@ namespace Nz
return stage;
}
std::unique_ptr<Texture> VulkanDevice::InstantiateTexture(const TextureInfo& params)
std::shared_ptr<Texture> VulkanDevice::InstantiateTexture(const TextureInfo& params)
{
return std::make_unique<VulkanTexture>(*this, params);
return std::make_shared<VulkanTexture>(*this, params);
}
std::unique_ptr<TextureSampler> VulkanDevice::InstantiateTextureSampler(const TextureSamplerInfo& params)
std::shared_ptr<TextureSampler> VulkanDevice::InstantiateTextureSampler(const TextureSamplerInfo& params)
{
return std::make_unique<VulkanTextureSampler>(*this, params);
return std::make_shared<VulkanTextureSampler>(*this, params);
}
}

View File

@@ -268,7 +268,7 @@ namespace Ndk
if (callbacks.endCallback)
{
worldCallbacks.endCallback = [this, cb = std::move(callbacks.endCallback)](Nz::PhysWorld2D& world, Nz::Arbiter2D& arbiter, Nz::RigidBody2D& bodyA, Nz::RigidBody2D& bodyB, void* userdata)
worldCallbacks.endCallback = [this, cb = std::move(callbacks.endCallback)](Nz::PhysWorld2D& /*world*/, Nz::Arbiter2D& arbiter, Nz::RigidBody2D& bodyA, Nz::RigidBody2D& bodyB, void* userdata)
{
cb(*this, arbiter, GetEntityFromBody(bodyA), GetEntityFromBody(bodyB), userdata);
};
@@ -276,7 +276,7 @@ namespace Ndk
if (callbacks.preSolveCallback)
{
worldCallbacks.preSolveCallback = [this, cb = std::move(callbacks.preSolveCallback)](Nz::PhysWorld2D& world, Nz::Arbiter2D& arbiter, Nz::RigidBody2D& bodyA, Nz::RigidBody2D& bodyB, void* userdata)
worldCallbacks.preSolveCallback = [this, cb = std::move(callbacks.preSolveCallback)](Nz::PhysWorld2D& /*world*/, Nz::Arbiter2D& arbiter, Nz::RigidBody2D& bodyA, Nz::RigidBody2D& bodyB, void* userdata)
{
return cb(*this, arbiter, GetEntityFromBody(bodyA), GetEntityFromBody(bodyB), userdata);
};
@@ -284,7 +284,7 @@ namespace Ndk
if (callbacks.postSolveCallback)
{
worldCallbacks.postSolveCallback = [this, cb = std::move(callbacks.postSolveCallback)](Nz::PhysWorld2D& world, Nz::Arbiter2D& arbiter, Nz::RigidBody2D& bodyA, Nz::RigidBody2D& bodyB, void* userdata)
worldCallbacks.postSolveCallback = [this, cb = std::move(callbacks.postSolveCallback)](Nz::PhysWorld2D& /*world*/, Nz::Arbiter2D& arbiter, Nz::RigidBody2D& bodyA, Nz::RigidBody2D& bodyB, void* userdata)
{
cb(*this, arbiter, GetEntityFromBody(bodyA), GetEntityFromBody(bodyB), userdata);
};
@@ -292,7 +292,7 @@ namespace Ndk
if (callbacks.startCallback)
{
worldCallbacks.startCallback = [this, cb = std::move(callbacks.startCallback)](Nz::PhysWorld2D& world, Nz::Arbiter2D& arbiter, Nz::RigidBody2D& bodyA, Nz::RigidBody2D& bodyB, void* userdata)
worldCallbacks.startCallback = [this, cb = std::move(callbacks.startCallback)](Nz::PhysWorld2D& /*world*/, Nz::Arbiter2D& arbiter, Nz::RigidBody2D& bodyA, Nz::RigidBody2D& bodyB, void* userdata)
{
return cb(*this, arbiter, GetEntityFromBody(bodyA), GetEntityFromBody(bodyB), userdata);
};
@@ -309,7 +309,7 @@ namespace Ndk
if (callbacks.endCallback)
{
worldCallbacks.endCallback = [this, cb = std::move(callbacks.endCallback)](Nz::PhysWorld2D& world, Nz::Arbiter2D& arbiter, Nz::RigidBody2D& bodyA, Nz::RigidBody2D& bodyB, void* userdata)
worldCallbacks.endCallback = [this, cb = std::move(callbacks.endCallback)](Nz::PhysWorld2D& /*world*/, Nz::Arbiter2D& arbiter, Nz::RigidBody2D& bodyA, Nz::RigidBody2D& bodyB, void* userdata)
{
cb(*this, arbiter, GetEntityFromBody(bodyA), GetEntityFromBody(bodyB), userdata);
};
@@ -317,7 +317,7 @@ namespace Ndk
if (callbacks.preSolveCallback)
{
worldCallbacks.preSolveCallback = [this, cb = std::move(callbacks.preSolveCallback)](Nz::PhysWorld2D& world, Nz::Arbiter2D& arbiter, Nz::RigidBody2D& bodyA, Nz::RigidBody2D& bodyB, void* userdata)
worldCallbacks.preSolveCallback = [this, cb = std::move(callbacks.preSolveCallback)](Nz::PhysWorld2D& /*world*/, Nz::Arbiter2D& arbiter, Nz::RigidBody2D& bodyA, Nz::RigidBody2D& bodyB, void* userdata)
{
return cb(*this, arbiter, GetEntityFromBody(bodyA), GetEntityFromBody(bodyB), userdata);
};
@@ -325,7 +325,7 @@ namespace Ndk
if (callbacks.postSolveCallback)
{
worldCallbacks.postSolveCallback = [this, cb = std::move(callbacks.postSolveCallback)](Nz::PhysWorld2D& world, Nz::Arbiter2D& arbiter, Nz::RigidBody2D& bodyA, Nz::RigidBody2D& bodyB, void* userdata)
worldCallbacks.postSolveCallback = [this, cb = std::move(callbacks.postSolveCallback)](Nz::PhysWorld2D& /*world*/, Nz::Arbiter2D& arbiter, Nz::RigidBody2D& bodyA, Nz::RigidBody2D& bodyB, void* userdata)
{
cb(*this, arbiter, GetEntityFromBody(bodyA), GetEntityFromBody(bodyB), userdata);
};
@@ -333,7 +333,7 @@ namespace Ndk
if (callbacks.startCallback)
{
worldCallbacks.startCallback = [this, cb = std::move(callbacks.startCallback)](Nz::PhysWorld2D& world, Nz::Arbiter2D& arbiter, Nz::RigidBody2D& bodyA, Nz::RigidBody2D& bodyB, void* userdata)
worldCallbacks.startCallback = [this, cb = std::move(callbacks.startCallback)](Nz::PhysWorld2D& /*world*/, Nz::Arbiter2D& arbiter, Nz::RigidBody2D& bodyA, Nz::RigidBody2D& bodyB, void* userdata)
{
return cb(*this, arbiter, GetEntityFromBody(bodyA), GetEntityFromBody(bodyB), userdata);
};