From 992cd303a76cda6eba44469776050fd2d34290fc Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 17:59:52 +0200 Subject: [PATCH] Vulkan/DeviceObject: Add IsValid() Former-commit-id: 5ac734d6444206e36570f9b85d01920442913618 [formerly 677ce9e18ce84afae896bb98b0a4bbbf9eea8132] Former-commit-id: 2fc3167fba652add5a39860cbc95a7094671a6c7 --- include/Nazara/Vulkan/VkDeviceObject.hpp | 2 ++ include/Nazara/Vulkan/VkDeviceObject.inl | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Vulkan/VkDeviceObject.hpp b/include/Nazara/Vulkan/VkDeviceObject.hpp index afa6a4c55..eaa27d1ed 100644 --- a/include/Nazara/Vulkan/VkDeviceObject.hpp +++ b/include/Nazara/Vulkan/VkDeviceObject.hpp @@ -27,6 +27,8 @@ namespace Nz inline bool Create(const DeviceHandle& device, const CreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); inline void Destroy(); + inline bool IsValid() const; + inline const DeviceHandle& GetDevice() const; inline VkResult GetLastErrorCode() const; diff --git a/include/Nazara/Vulkan/VkDeviceObject.inl b/include/Nazara/Vulkan/VkDeviceObject.inl index ab08688bd..f59102dce 100644 --- a/include/Nazara/Vulkan/VkDeviceObject.inl +++ b/include/Nazara/Vulkan/VkDeviceObject.inl @@ -56,13 +56,19 @@ namespace Nz template inline void DeviceObject::Destroy() { - if (m_handle != VK_NULL_HANDLE) + if (IsValid()) { C::DestroyHelper(m_device, m_handle, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); m_handle = VK_NULL_HANDLE; } } + template + inline bool DeviceObject::IsValid() const + { + return m_handle != VK_NULL_HANDLE; + } + template inline const DeviceHandle& DeviceObject::GetDevice() const { @@ -84,3 +90,4 @@ namespace Nz } #include +#include "VkDeviceObject.hpp"