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);
}
}