// Copyright (C) 2016 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan" // For conditions of distribution and use, see copyright notice in Config.hpp #include #include #include #include namespace Nz { namespace Vk { template inline DeviceObject::DeviceObject(Device& device) : m_device(device), m_handle(VK_NULL_HANDLE) { } template inline DeviceObject::~DeviceObject() { Destroy(); } template inline bool DeviceObject::Create(const CreateInfo& createInfo, const VkAllocationCallbacks* allocator) { m_lastErrorCode = C::CreateHelper(m_device, &createInfo, allocator, &m_handle); if (m_lastErrorCode != VkResult::VK_SUCCESS) { NazaraError("Failed to create Vulkan object"); return false; } // Store the allocator to access them when needed if (allocator) m_allocator = *allocator; else m_allocator.pfnAllocation = nullptr; return true; } template inline void DeviceObject::Destroy() { if (m_handle != VK_NULL_HANDLE) C::DestroyHelper(m_device, m_handle, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); } template inline VkResult DeviceObject::GetLastErrorCode() const { return m_lastErrorCode; } template inline DeviceObject::operator VkType() { return m_handle; } } } #include