diff --git a/examples/RenderTest/main.cpp b/examples/RenderTest/main.cpp index 6af94fa9f..0b6004ed1 100644 --- a/examples/RenderTest/main.cpp +++ b/examples/RenderTest/main.cpp @@ -81,14 +81,14 @@ int main() texParams.height = drfreakImage->GetHeight(); texParams.depth = drfreakImage->GetDepth(); - std::unique_ptr texture = device->InstantiateTexture(texParams); + std::shared_ptr texture = device->InstantiateTexture(texParams); if (!texture->Update(drfreakImage->GetConstPixels())) { NazaraError("Failed to update texture"); return __LINE__; } - std::unique_ptr textureSampler = device->InstantiateTextureSampler({}); + std::shared_ptr textureSampler = device->InstantiateTextureSampler({}); struct { @@ -120,7 +120,7 @@ int main() Nz::ShaderBindingPtr shaderBinding = renderPipelineLayout->AllocateShaderBinding(); - std::unique_ptr uniformBuffer = device->InstantiateBuffer(Nz::BufferType_Uniform); + std::shared_ptr uniformBuffer = device->InstantiateBuffer(Nz::BufferType_Uniform); if (!uniformBuffer->Initialize(uniformSize, Nz::BufferUsage_DeviceLocal | Nz::BufferUsage_Dynamic)) { NazaraError("Failed to create uniform buffer"); @@ -153,12 +153,12 @@ int main() vertexBuffer.binding = 0; vertexBuffer.declaration = drfreakVB->GetVertexDeclaration(); - std::unique_ptr pipeline = device->InstantiateRenderPipeline(pipelineInfo); + std::shared_ptr pipeline = device->InstantiateRenderPipeline(pipelineInfo); Nz::RenderDevice* renderDevice = window.GetRenderDevice().get(); Nz::RenderWindowImpl* windowImpl = window.GetImpl(); - std::unique_ptr commandPool = windowImpl->CreateCommandPool(Nz::QueueType::Graphics); + std::shared_ptr commandPool = windowImpl->CreateCommandPool(Nz::QueueType::Graphics); Nz::RenderBuffer* renderBufferIB = static_cast(drfreakIB->GetBuffer()->GetImpl()); Nz::RenderBuffer* renderBufferVB = static_cast(drfreakVB->GetBuffer()->GetImpl()); diff --git a/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp b/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp index 9d9b6adef..a75140840 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp @@ -32,13 +32,13 @@ namespace Nz inline const GL::Context& GetReferenceContext() const; - std::unique_ptr InstantiateBuffer(BufferType type) override; - std::unique_ptr InstantiateCommandPool(QueueType queueType) override; - std::unique_ptr InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo) override; + std::shared_ptr InstantiateBuffer(BufferType type) override; + std::shared_ptr InstantiateCommandPool(QueueType queueType) override; + std::shared_ptr InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo) override; std::shared_ptr InstantiateRenderPipelineLayout(RenderPipelineLayoutInfo pipelineLayoutInfo) override; std::shared_ptr InstantiateShaderStage(ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize) override; - std::unique_ptr InstantiateTexture(const TextureInfo& params) override; - std::unique_ptr InstantiateTextureSampler(const TextureSamplerInfo& params) override; + std::shared_ptr InstantiateTexture(const TextureInfo& params) override; + std::shared_ptr InstantiateTextureSampler(const TextureSamplerInfo& params) override; inline void NotifyBufferDestruction(GLuint buffer) const; inline void NotifyProgramDestruction(GLuint program) const; diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp b/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp index 61b0a69d8..2a74d2ff8 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp @@ -31,7 +31,7 @@ namespace Nz RenderFrame Acquire() override; bool Create(RendererImpl* renderer, RenderSurface* surface, const RenderWindowParameters& parameters) override; - std::unique_ptr CreateCommandPool(QueueType queueType) override; + std::shared_ptr CreateCommandPool(QueueType queueType) override; inline GL::Context& GetContext(); const OpenGLFramebuffer& GetFramebuffer() const override; diff --git a/include/Nazara/Renderer/RenderBuffer.hpp b/include/Nazara/Renderer/RenderBuffer.hpp index 897270ac2..a10fc7bc8 100644 --- a/include/Nazara/Renderer/RenderBuffer.hpp +++ b/include/Nazara/Renderer/RenderBuffer.hpp @@ -51,7 +51,7 @@ namespace Nz struct HardwareBuffer { - std::unique_ptr buffer; + std::shared_ptr buffer; bool synchronized = false; }; diff --git a/include/Nazara/Renderer/RenderDevice.hpp b/include/Nazara/Renderer/RenderDevice.hpp index df8029bf2..000aca2e2 100644 --- a/include/Nazara/Renderer/RenderDevice.hpp +++ b/include/Nazara/Renderer/RenderDevice.hpp @@ -29,14 +29,14 @@ namespace Nz RenderDevice() = default; virtual ~RenderDevice(); - virtual std::unique_ptr InstantiateBuffer(BufferType type) = 0; - virtual std::unique_ptr InstantiateCommandPool(QueueType queueType) = 0; - virtual std::unique_ptr InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo) = 0; + virtual std::shared_ptr InstantiateBuffer(BufferType type) = 0; + virtual std::shared_ptr InstantiateCommandPool(QueueType queueType) = 0; + virtual std::shared_ptr InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo) = 0; virtual std::shared_ptr InstantiateRenderPipelineLayout(RenderPipelineLayoutInfo pipelineLayoutInfo) = 0; virtual std::shared_ptr InstantiateShaderStage(ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize) = 0; std::shared_ptr InstantiateShaderStage(ShaderStageType type, ShaderLanguage lang, const std::filesystem::path& sourcePath); - virtual std::unique_ptr InstantiateTexture(const TextureInfo& params) = 0; - virtual std::unique_ptr InstantiateTextureSampler(const TextureSamplerInfo& params) = 0; + virtual std::shared_ptr InstantiateTexture(const TextureInfo& params) = 0; + virtual std::shared_ptr InstantiateTextureSampler(const TextureSamplerInfo& params) = 0; }; } diff --git a/include/Nazara/Renderer/RenderWindowImpl.hpp b/include/Nazara/Renderer/RenderWindowImpl.hpp index db8a15048..dec071274 100644 --- a/include/Nazara/Renderer/RenderWindowImpl.hpp +++ b/include/Nazara/Renderer/RenderWindowImpl.hpp @@ -32,7 +32,7 @@ namespace Nz virtual RenderFrame Acquire() = 0; virtual bool Create(RendererImpl* renderer, RenderSurface* surface, const RenderWindowParameters& parameters) = 0; - virtual std::unique_ptr CreateCommandPool(QueueType queueType) = 0; + virtual std::shared_ptr CreateCommandPool(QueueType queueType) = 0; virtual const Framebuffer& GetFramebuffer() const = 0; virtual std::shared_ptr GetRenderDevice() = 0; diff --git a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp index 6ad0eaae8..c14fc640d 100644 --- a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp +++ b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp @@ -46,7 +46,7 @@ namespace Nz bool Create(RendererImpl* renderer, RenderSurface* surface, const RenderWindowParameters& parameters) override; - std::unique_ptr CreateCommandPool(QueueType queueType) override; + std::shared_ptr CreateCommandPool(QueueType queueType) override; inline const VulkanMultipleFramebuffer& GetFramebuffer() const override; inline VulkanDevice& GetDevice(); diff --git a/include/Nazara/VulkanRenderer/VulkanDevice.hpp b/include/Nazara/VulkanRenderer/VulkanDevice.hpp index 88711ba57..b7d8e095c 100644 --- a/include/Nazara/VulkanRenderer/VulkanDevice.hpp +++ b/include/Nazara/VulkanRenderer/VulkanDevice.hpp @@ -23,13 +23,13 @@ namespace Nz VulkanDevice(VulkanDevice&&) = delete; ///TODO? ~VulkanDevice(); - std::unique_ptr InstantiateBuffer(BufferType type) override; - std::unique_ptr InstantiateCommandPool(QueueType queueType) override; - std::unique_ptr InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo) override; + std::shared_ptr InstantiateBuffer(BufferType type) override; + std::shared_ptr InstantiateCommandPool(QueueType queueType) override; + std::shared_ptr InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo) override; std::shared_ptr InstantiateRenderPipelineLayout(RenderPipelineLayoutInfo pipelineLayoutInfo) override; std::shared_ptr InstantiateShaderStage(ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize) override; - std::unique_ptr InstantiateTexture(const TextureInfo& params) override; - std::unique_ptr InstantiateTextureSampler(const TextureSamplerInfo& params) override; + std::shared_ptr InstantiateTexture(const TextureInfo& params) override; + std::shared_ptr InstantiateTextureSampler(const TextureSamplerInfo& params) override; VulkanDevice& operator=(const VulkanDevice&) = delete; VulkanDevice& operator=(VulkanDevice&&) = delete; ///TODO? diff --git a/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp b/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp index 0d9420ef3..e7c0c070f 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp @@ -48,19 +48,19 @@ namespace Nz return contextPtr; } - std::unique_ptr OpenGLDevice::InstantiateBuffer(BufferType type) + std::shared_ptr OpenGLDevice::InstantiateBuffer(BufferType type) { - return std::make_unique(*this, type); + return std::make_shared(*this, type); } - std::unique_ptr OpenGLDevice::InstantiateCommandPool(QueueType /*queueType*/) + std::shared_ptr OpenGLDevice::InstantiateCommandPool(QueueType /*queueType*/) { - return std::make_unique(); + return std::make_shared(); } - std::unique_ptr OpenGLDevice::InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo) + std::shared_ptr OpenGLDevice::InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo) { - return std::make_unique(*this, std::move(pipelineInfo)); + return std::make_shared(*this, std::move(pipelineInfo)); } std::shared_ptr OpenGLDevice::InstantiateRenderPipelineLayout(RenderPipelineLayoutInfo pipelineLayoutInfo) @@ -73,14 +73,14 @@ namespace Nz return std::make_shared(*this, type, lang, source, sourceSize); } - std::unique_ptr OpenGLDevice::InstantiateTexture(const TextureInfo& params) + std::shared_ptr OpenGLDevice::InstantiateTexture(const TextureInfo& params) { - return std::make_unique(*this, params); + return std::make_shared(*this, params); } - std::unique_ptr OpenGLDevice::InstantiateTextureSampler(const TextureSamplerInfo& params) + std::shared_ptr OpenGLDevice::InstantiateTextureSampler(const TextureSamplerInfo& params) { - return std::make_unique(*this, params); + return std::make_shared(*this, params); } } diff --git a/src/Nazara/OpenGLRenderer/OpenGLRenderWindow.cpp b/src/Nazara/OpenGLRenderer/OpenGLRenderWindow.cpp index 510e18f80..2489b8695 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLRenderWindow.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLRenderWindow.cpp @@ -59,7 +59,7 @@ namespace Nz return true; } - std::unique_ptr OpenGLRenderWindow::CreateCommandPool(QueueType /*queueType*/) + std::shared_ptr OpenGLRenderWindow::CreateCommandPool(QueueType /*queueType*/) { return std::make_unique(); } diff --git a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp index 3ed481a3e..5c7b6ee70 100644 --- a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp +++ b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp @@ -219,7 +219,7 @@ namespace Nz return true; } - std::unique_ptr VkRenderWindow::CreateCommandPool(QueueType queueType) + std::shared_ptr 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(*m_device, queueFamilyIndex); + return std::make_shared(*m_device, queueFamilyIndex); } void VkRenderWindow::Present(UInt32 imageIndex, VkSemaphore waitSemaphore) diff --git a/src/Nazara/VulkanRenderer/VulkanDevice.cpp b/src/Nazara/VulkanRenderer/VulkanDevice.cpp index b20932dda..adc23c0b8 100644 --- a/src/Nazara/VulkanRenderer/VulkanDevice.cpp +++ b/src/Nazara/VulkanRenderer/VulkanDevice.cpp @@ -15,19 +15,19 @@ namespace Nz { VulkanDevice::~VulkanDevice() = default; - std::unique_ptr VulkanDevice::InstantiateBuffer(BufferType type) + std::shared_ptr VulkanDevice::InstantiateBuffer(BufferType type) { - return std::make_unique(*this, type); + return std::make_shared(*this, type); } - std::unique_ptr VulkanDevice::InstantiateCommandPool(QueueType queueType) + std::shared_ptr VulkanDevice::InstantiateCommandPool(QueueType queueType) { - return std::make_unique(*this, queueType); + return std::make_shared(*this, queueType); } - std::unique_ptr VulkanDevice::InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo) + std::shared_ptr VulkanDevice::InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo) { - return std::make_unique(*this, std::move(pipelineInfo)); + return std::make_shared(*this, std::move(pipelineInfo)); } std::shared_ptr VulkanDevice::InstantiateRenderPipelineLayout(RenderPipelineLayoutInfo pipelineLayoutInfo) @@ -48,13 +48,13 @@ namespace Nz return stage; } - std::unique_ptr VulkanDevice::InstantiateTexture(const TextureInfo& params) + std::shared_ptr VulkanDevice::InstantiateTexture(const TextureInfo& params) { - return std::make_unique(*this, params); + return std::make_shared(*this, params); } - std::unique_ptr VulkanDevice::InstantiateTextureSampler(const TextureSamplerInfo& params) + std::shared_ptr VulkanDevice::InstantiateTextureSampler(const TextureSamplerInfo& params) { - return std::make_unique(*this, params); + return std::make_shared(*this, params); } } diff --git a/src/NazaraSDK/Systems/PhysicsSystem2D.cpp b/src/NazaraSDK/Systems/PhysicsSystem2D.cpp index 263296903..60ff8e437 100644 --- a/src/NazaraSDK/Systems/PhysicsSystem2D.cpp +++ b/src/NazaraSDK/Systems/PhysicsSystem2D.cpp @@ -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); };