Vulkan: Allow Device Objects to be move-constructed

Former-commit-id: c7fb30b30d2242e19d531a6860b856660b6b0c01
This commit is contained in:
Lynix 2016-05-14 21:28:59 +02:00
parent 1346c3e2c0
commit 68e3fd8db3
6 changed files with 23 additions and 4 deletions

View File

@ -21,7 +21,7 @@ namespace Nz
public: public:
inline DeviceObject(Device& instance); inline DeviceObject(Device& instance);
DeviceObject(const DeviceObject&) = delete; DeviceObject(const DeviceObject&) = delete;
DeviceObject(DeviceObject&&) = delete; DeviceObject(DeviceObject&&);
inline ~DeviceObject(); inline ~DeviceObject();
inline bool Create(const CreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); inline bool Create(const CreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr);

View File

@ -18,6 +18,16 @@ namespace Nz
{ {
} }
template<typename C, typename VkType, typename CreateInfo>
inline DeviceObject<C, VkType, CreateInfo>::DeviceObject(DeviceObject&& object) :
m_device(object.m_device),
m_allocator(object.m_allocator),
m_handle(object.m_handle),
m_lastErrorCode(object.m_lastErrorCode)
{
object.m_handle = VK_NULL_HANDLE;
}
template<typename C, typename VkType, typename CreateInfo> template<typename C, typename VkType, typename CreateInfo>
inline DeviceObject<C, VkType, CreateInfo>::~DeviceObject() inline DeviceObject<C, VkType, CreateInfo>::~DeviceObject()
{ {

View File

@ -21,7 +21,7 @@ namespace Nz
public: public:
inline Semaphore(Device& instance); inline Semaphore(Device& instance);
Semaphore(const Semaphore&) = delete; Semaphore(const Semaphore&) = delete;
Semaphore(Semaphore&&) = delete; Semaphore(Semaphore&&) = default;
~Semaphore() = default; ~Semaphore() = default;
using DeviceObject::Create; using DeviceObject::Create;

View File

@ -23,7 +23,7 @@ namespace Nz
public: public:
inline Surface(Instance& instance); inline Surface(Instance& instance);
Surface(const Surface&) = delete; Surface(const Surface&) = delete;
Surface(Surface&&) = delete; Surface(Surface&& surface);
inline ~Surface(); inline ~Surface();
#ifdef VK_USE_PLATFORM_ANDROID_KHR #ifdef VK_USE_PLATFORM_ANDROID_KHR

View File

@ -17,6 +17,15 @@ namespace Nz
{ {
} }
inline Surface::Surface(Surface&& surface) :
m_instance(surface.m_instance),
m_allocator(surface.m_allocator),
m_surface(surface.m_surface),
m_lastErrorCode(surface.m_lastErrorCode)
{
surface.m_surface = VK_NULL_HANDLE;
}
inline Surface::~Surface() inline Surface::~Surface()
{ {
Destroy(); Destroy();

View File

@ -21,7 +21,7 @@ namespace Nz
public: public:
inline Swapchain(Device& instance); inline Swapchain(Device& instance);
Swapchain(const Swapchain&) = delete; Swapchain(const Swapchain&) = delete;
Swapchain(Swapchain&&) = delete; Swapchain(Swapchain&&) = default;
~Swapchain() = default; ~Swapchain() = default;
inline bool IsSupported() const; inline bool IsSupported() const;