From 427bbedcec9454e7155a2dd322372c5092354f65 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 17 Aug 2016 13:00:03 +0200 Subject: [PATCH] Remove Vulkan from master branch Former-commit-id: f8b920b86746690f4f0c40170f43ef30263dd9a5 [formerly a6671038c978ca76b86d45cb00552b027e6af9b6] [formerly e42912530fb1986eaec43a3f19e4791e0f04226f [formerly 54abe220c26a36ddad1db37aa4ec85f1078dca4d]] Former-commit-id: 52bc69afa7c072659a0ff4d0c97f522a9f886f11 [formerly d78eb693d63cd0bde6e55655405aa4400bc91531] Former-commit-id: e011ea3a03310be890ae7e3952982d7f7aa28279 --- include/Nazara/Vulkan/Config.hpp | 53 ---- include/Nazara/Vulkan/ConfigCheck.hpp | 22 -- include/Nazara/Vulkan/Debug.hpp | 8 - include/Nazara/Vulkan/DebugOff.hpp | 9 - include/Nazara/Vulkan/VkCommandBuffer.hpp | 58 ---- include/Nazara/Vulkan/VkCommandBuffer.inl | 150 ----------- include/Nazara/Vulkan/VkCommandPool.hpp | 53 ---- include/Nazara/Vulkan/VkCommandPool.inl | 53 ---- include/Nazara/Vulkan/VkDevice.hpp | 202 -------------- include/Nazara/Vulkan/VkDevice.inl | 96 ------- include/Nazara/Vulkan/VkDeviceObject.hpp | 50 ---- include/Nazara/Vulkan/VkDeviceObject.inl | 89 ------- include/Nazara/Vulkan/VkInstance.hpp | 141 ---------- include/Nazara/Vulkan/VkInstance.inl | 128 --------- include/Nazara/Vulkan/VkLoader.hpp | 52 ---- include/Nazara/Vulkan/VkLoader.inl | 19 -- include/Nazara/Vulkan/VkQueue.hpp | 52 ---- include/Nazara/Vulkan/VkQueue.inl | 102 ------- include/Nazara/Vulkan/VkSemaphore.hpp | 42 --- include/Nazara/Vulkan/VkSemaphore.inl | 41 --- include/Nazara/Vulkan/VkSurface.hpp | 94 ------- include/Nazara/Vulkan/VkSurface.inl | 311 ---------------------- include/Nazara/Vulkan/VkSwapchain.hpp | 51 ---- include/Nazara/Vulkan/VkSwapchain.inl | 90 ------- include/Nazara/Vulkan/Vulkan.hpp | 33 --- src/Nazara/Vulkan/Debug/NewOverload.cpp | 31 --- src/Nazara/Vulkan/VkCommandPool.cpp | 53 ---- src/Nazara/Vulkan/VkDevice.cpp | 178 ------------- src/Nazara/Vulkan/VkInstance.cpp | 193 -------------- src/Nazara/Vulkan/VkLoader.cpp | 117 -------- src/Nazara/Vulkan/Vulkan.cpp | 70 ----- 31 files changed, 2641 deletions(-) delete mode 100644 include/Nazara/Vulkan/Config.hpp delete mode 100644 include/Nazara/Vulkan/ConfigCheck.hpp delete mode 100644 include/Nazara/Vulkan/Debug.hpp delete mode 100644 include/Nazara/Vulkan/DebugOff.hpp delete mode 100644 include/Nazara/Vulkan/VkCommandBuffer.hpp delete mode 100644 include/Nazara/Vulkan/VkCommandBuffer.inl delete mode 100644 include/Nazara/Vulkan/VkCommandPool.hpp delete mode 100644 include/Nazara/Vulkan/VkCommandPool.inl delete mode 100644 include/Nazara/Vulkan/VkDevice.hpp delete mode 100644 include/Nazara/Vulkan/VkDevice.inl delete mode 100644 include/Nazara/Vulkan/VkDeviceObject.hpp delete mode 100644 include/Nazara/Vulkan/VkDeviceObject.inl delete mode 100644 include/Nazara/Vulkan/VkInstance.hpp delete mode 100644 include/Nazara/Vulkan/VkInstance.inl delete mode 100644 include/Nazara/Vulkan/VkLoader.hpp delete mode 100644 include/Nazara/Vulkan/VkLoader.inl delete mode 100644 include/Nazara/Vulkan/VkQueue.hpp delete mode 100644 include/Nazara/Vulkan/VkQueue.inl delete mode 100644 include/Nazara/Vulkan/VkSemaphore.hpp delete mode 100644 include/Nazara/Vulkan/VkSemaphore.inl delete mode 100644 include/Nazara/Vulkan/VkSurface.hpp delete mode 100644 include/Nazara/Vulkan/VkSurface.inl delete mode 100644 include/Nazara/Vulkan/VkSwapchain.hpp delete mode 100644 include/Nazara/Vulkan/VkSwapchain.inl delete mode 100644 include/Nazara/Vulkan/Vulkan.hpp delete mode 100644 src/Nazara/Vulkan/Debug/NewOverload.cpp delete mode 100644 src/Nazara/Vulkan/VkCommandPool.cpp delete mode 100644 src/Nazara/Vulkan/VkDevice.cpp delete mode 100644 src/Nazara/Vulkan/VkInstance.cpp delete mode 100644 src/Nazara/Vulkan/VkLoader.cpp delete mode 100644 src/Nazara/Vulkan/Vulkan.cpp diff --git a/include/Nazara/Vulkan/Config.hpp b/include/Nazara/Vulkan/Config.hpp deleted file mode 100644 index d5f616214..000000000 --- a/include/Nazara/Vulkan/Config.hpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - Nazara Engine - Vulkan - - Copyright (C) 2015 Jérôme "Lynix" Leclercq (Lynix680@gmail.com) - - Permission is hereby granted, free of charge, to any person obtaining a copy of - this software and associated documentation files (the "Software"), to deal in - the Software without restriction, including without limitation the rights to - use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - of the Software, and to permit persons to whom the Software is furnished to do - so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ - -#pragma once - -#ifndef NAZARA_CONFIG_VULKAN_HPP -#define NAZARA_CONFIG_VULKAN_HPP - -/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci - -// Utilise le MemoryManager pour gérer les allocations dynamiques (détecte les leaks au prix d'allocations/libérations dynamiques plus lentes) -#define NAZARA_VULKAN_MANAGE_MEMORY 0 - -// Active les tests de sécurité basés sur le code (Conseillé pour le développement) -#define NAZARA_VULKAN_SAFE 1 - -/// Chaque modification d'un paramètre ci-dessous implique une modification (souvent mineure) du code - -/// Vérification des valeurs et types de certaines constantes -#include - -#if !defined(NAZARA_STATIC) - #ifdef NAZARA_VULKAN_BUILD - #define NAZARA_VULKAN_API NAZARA_EXPORT - #else - #define NAZARA_VULKAN_API NAZARA_IMPORT - #endif -#else - #define NAZARA_VULKAN_API -#endif - -#endif // NAZARA_CONFIG_MODULENAME_HPP diff --git a/include/Nazara/Vulkan/ConfigCheck.hpp b/include/Nazara/Vulkan/ConfigCheck.hpp deleted file mode 100644 index 22f334c6f..000000000 --- a/include/Nazara/Vulkan/ConfigCheck.hpp +++ /dev/null @@ -1,22 +0,0 @@ -// 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 - -#pragma once - -#ifndef NAZARA_CONFIG_CHECK_VULKANE_HPP -#define NAZARA_CONFIG_CHECK_VULKANE_HPP - -/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp - -#include -#define CheckType(name, type, err) static_assert(std::is_ ##type ::value, #type err) -#define CheckTypeAndVal(name, type, op, val, err) static_assert(std::is_ ##type ::value && name op val, #type err) - -// On force la valeur de MANAGE_MEMORY en mode debug -#if defined(NAZARA_DEBUG) && !NAZARA_VULKAN_MANAGE_MEMORY - #undef NAZARA_MODULENAME_MANAGE_MEMORY - #define NAZARA_MODULENAME_MANAGE_MEMORY 0 -#endif - -#endif // NAZARA_CONFIG_CHECK_VULKAN_HPP diff --git a/include/Nazara/Vulkan/Debug.hpp b/include/Nazara/Vulkan/Debug.hpp deleted file mode 100644 index b5e44efae..000000000 --- a/include/Nazara/Vulkan/Debug.hpp +++ /dev/null @@ -1,8 +0,0 @@ -// 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 -#if NAZARA_MODULENAME_MANAGE_MEMORY - #include -#endif diff --git a/include/Nazara/Vulkan/DebugOff.hpp b/include/Nazara/Vulkan/DebugOff.hpp deleted file mode 100644 index e57a2b946..000000000 --- a/include/Nazara/Vulkan/DebugOff.hpp +++ /dev/null @@ -1,9 +0,0 @@ -// 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 - -// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp -#if NAZARA_MODULENAME_MANAGE_MEMORY - #undef delete - #undef new -#endif diff --git a/include/Nazara/Vulkan/VkCommandBuffer.hpp b/include/Nazara/Vulkan/VkCommandBuffer.hpp deleted file mode 100644 index 2dea341dd..000000000 --- a/include/Nazara/Vulkan/VkCommandBuffer.hpp +++ /dev/null @@ -1,58 +0,0 @@ -// 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 - -#pragma once - -#ifndef NAZARA_VULKAN_VKCOMMANDBUFFER_HPP -#define NAZARA_VULKAN_VKCOMMANDBUFFER_HPP - -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - class NAZARA_VULKAN_API CommandBuffer - { - friend CommandPool; - - public: - CommandBuffer(const CommandBuffer&) = delete; - CommandBuffer(CommandBuffer&& commandBuffer); - inline ~CommandBuffer(); - - inline bool Begin(const VkCommandBufferBeginInfo& info); - inline bool Begin(VkCommandBufferUsageFlags flags); - inline bool Begin(VkCommandBufferUsageFlags flags, const VkCommandBufferInheritanceInfo& inheritanceInfo); - inline bool Begin(VkCommandBufferUsageFlags flags, VkRenderPass renderPass, UInt32 subpass, VkFramebuffer framebuffer, bool occlusionQueryEnable, VkQueryControlFlags queryFlags, VkQueryPipelineStatisticFlags pipelineStatistics); - inline bool Begin(VkCommandBufferUsageFlags flags, bool occlusionQueryEnable, VkQueryControlFlags queryFlags, VkQueryPipelineStatisticFlags pipelineStatistics); - - inline bool End(); - - inline void Free(); - - inline VkResult GetLastErrorCode() const; - - CommandBuffer& operator=(const CommandBuffer&) = delete; - CommandBuffer& operator=(CommandBuffer&&) = delete; - - inline operator VkCommandBuffer(); - - private: - inline CommandBuffer(CommandPool& pool, VkCommandBuffer handle); - - CommandPoolHandle m_pool; - VkAllocationCallbacks m_allocator; - VkCommandBuffer m_handle; - VkResult m_lastErrorCode; - - }; - } -} - -#include - -#endif // NAZARA_VULKAN_VKCOMMANDBUFFER_HPP diff --git a/include/Nazara/Vulkan/VkCommandBuffer.inl b/include/Nazara/Vulkan/VkCommandBuffer.inl deleted file mode 100644 index d2d6f50d7..000000000 --- a/include/Nazara/Vulkan/VkCommandBuffer.inl +++ /dev/null @@ -1,150 +0,0 @@ -// 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 - { - inline CommandBuffer::CommandBuffer(CommandPool& pool, VkCommandBuffer handle) : - m_pool(&pool), - m_handle(handle) - { - } - - inline CommandBuffer::CommandBuffer(CommandBuffer&& commandBuffer) : - m_pool(std::move(commandBuffer.m_pool)), - m_allocator(commandBuffer.m_allocator), - m_handle(commandBuffer.m_handle), - m_lastErrorCode(commandBuffer.m_lastErrorCode) - { - commandBuffer.m_handle = VK_NULL_HANDLE; - } - - inline CommandBuffer::~CommandBuffer() - { - Free(); - } - - inline bool CommandBuffer::Begin(const VkCommandBufferBeginInfo& info) - { - m_lastErrorCode = m_pool->GetDevice().vkBeginCommandBuffer(m_handle, &info); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to begin command buffer"); - return false; - } - - return true; - } - - inline bool CommandBuffer::Begin(VkCommandBufferUsageFlags flags) - { - VkCommandBufferBeginInfo beginInfo = { - VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, - nullptr, - flags, - nullptr - }; - - return Begin(beginInfo); - } - - inline bool CommandBuffer::Begin(VkCommandBufferUsageFlags flags, const VkCommandBufferInheritanceInfo& inheritanceInfo) - { - VkCommandBufferBeginInfo beginInfo = { - VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, - nullptr, - flags, - &inheritanceInfo - }; - - return Begin(beginInfo); - } - - inline bool CommandBuffer::Begin(VkCommandBufferUsageFlags flags, VkRenderPass renderPass, UInt32 subpass, VkFramebuffer framebuffer, bool occlusionQueryEnable, VkQueryControlFlags queryFlags, VkQueryPipelineStatisticFlags pipelineStatistics) - { - NazaraAssert(flags & VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT, "Continue bit is required to ignore renderPass, subpass and framebuffer"); - - VkCommandBufferInheritanceInfo inheritanceInfo = { - VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, - nullptr, - renderPass, - subpass, - framebuffer, - VkBool32((occlusionQueryEnable) ? VK_TRUE : VK_FALSE), - queryFlags, - pipelineStatistics - }; - - VkCommandBufferBeginInfo beginInfo = { - VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, - nullptr, - flags, - &inheritanceInfo - }; - - return Begin(beginInfo); - } - - inline bool CommandBuffer::Begin(VkCommandBufferUsageFlags flags, bool occlusionQueryEnable, VkQueryControlFlags queryFlags, VkQueryPipelineStatisticFlags pipelineStatistics) - { - NazaraAssert(flags & VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT, "Continue bit is required to ignore renderPass, subpass and framebuffer"); - - VkCommandBufferInheritanceInfo inheritanceInfo = { - VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, - nullptr, - VK_NULL_HANDLE, - 0, - VK_NULL_HANDLE, - VkBool32((occlusionQueryEnable) ? VK_TRUE : VK_FALSE), - queryFlags, - pipelineStatistics - }; - - VkCommandBufferBeginInfo beginInfo = { - VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, - nullptr, - flags, - &inheritanceInfo - }; - - return Begin(beginInfo); - } - - inline bool CommandBuffer::End() - { - m_lastErrorCode = m_pool->GetDevice().vkEndCommandBuffer(m_handle); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to end command buffer"); - return false; - } - - return true; - } - - inline void CommandBuffer::Free() - { - if (m_handle) - m_pool->GetDevice().vkFreeCommandBuffers(m_pool->GetDevice(), *m_pool, 1, &m_handle); - } - - inline VkResult CommandBuffer::GetLastErrorCode() const - { - return m_lastErrorCode; - } - - inline CommandBuffer::operator VkCommandBuffer() - { - return m_handle; - } - } -} - -#include diff --git a/include/Nazara/Vulkan/VkCommandPool.hpp b/include/Nazara/Vulkan/VkCommandPool.hpp deleted file mode 100644 index b51061bb2..000000000 --- a/include/Nazara/Vulkan/VkCommandPool.hpp +++ /dev/null @@ -1,53 +0,0 @@ -// 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 - -#pragma once - -#ifndef NAZARA_VULKAN_VKCOMMANDPOOL_HPP -#define NAZARA_VULKAN_VKCOMMANDPOOL_HPP - -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - class CommandBuffer; - class CommandPool; - - using CommandPoolHandle = ObjectHandle; - - class NAZARA_VULKAN_API CommandPool : public DeviceObject, public HandledObject - { - friend DeviceObject; - - public: - inline CommandPool(Device& instance); - CommandPool(const CommandPool&) = delete; - CommandPool(CommandPool&&) = default; - ~CommandPool() = default; - - CommandBuffer AllocateCommandBuffer(VkCommandBufferLevel level); - std::vector AllocateCommandBuffers(UInt32 commandBufferCount, VkCommandBufferLevel level); - - using DeviceObject::Create; - inline bool Create(UInt32 queueFamilyIndex, VkCommandPoolCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); - - inline bool Reset(VkCommandPoolResetFlags flags); - - CommandPool& operator=(const CommandPool&) = delete; - CommandPool& operator=(CommandPool&&) = delete; - - private: - static inline VkResult CreateHelper(Device& device, const VkCommandPoolCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkCommandPool* handle); - static inline void DestroyHelper(Device& device, VkCommandPool handle, const VkAllocationCallbacks* allocator); - }; - } -} - -#include - -#endif // NAZARA_VULKAN_VKCOMMANDPOOL_HPP diff --git a/include/Nazara/Vulkan/VkCommandPool.inl b/include/Nazara/Vulkan/VkCommandPool.inl deleted file mode 100644 index 61cfeaa43..000000000 --- a/include/Nazara/Vulkan/VkCommandPool.inl +++ /dev/null @@ -1,53 +0,0 @@ -// 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 - { - inline CommandPool::CommandPool(Device& device) : - DeviceObject(device) - { - } - - inline bool CommandPool::Create(UInt32 queueFamilyIndex, VkCommandPoolCreateFlags flags, const VkAllocationCallbacks* allocator) - { - VkCommandPoolCreateInfo createInfo = - { - VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, - nullptr, - flags, - queueFamilyIndex - }; - - return Create(createInfo, allocator); - } - - inline bool CommandPool::Reset(VkCommandPoolResetFlags flags) - { - m_lastErrorCode = m_device.vkResetCommandPool(m_device, m_handle, flags); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - return false; - - return true; - } - - inline VkResult CommandPool::CreateHelper(Device& device, const VkCommandPoolCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkCommandPool* handle) - { - return device.vkCreateCommandPool(device, createInfo, allocator, handle); - } - - inline void CommandPool::DestroyHelper(Device& device, VkCommandPool handle, const VkAllocationCallbacks* allocator) - { - return device.vkDestroyCommandPool(device, handle, allocator); - } - } -} - -#include diff --git a/include/Nazara/Vulkan/VkDevice.hpp b/include/Nazara/Vulkan/VkDevice.hpp deleted file mode 100644 index 1b9d3a470..000000000 --- a/include/Nazara/Vulkan/VkDevice.hpp +++ /dev/null @@ -1,202 +0,0 @@ -// 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 - -#pragma once - -#ifndef NAZARA_VULKAN_VKDEVICE_HPP -#define NAZARA_VULKAN_VKDEVICE_HPP - -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - class Device; - class Queue; - class Instance; - - using DeviceHandle = ObjectHandle; - - class NAZARA_VULKAN_API Device : public HandledObject - { - public: - inline Device(Instance& instance); - Device(const Device&) = delete; - Device(Device&&) = delete; - inline ~Device(); - - bool Create(VkPhysicalDevice device, const VkDeviceCreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); - inline void Destroy(); - - inline Queue GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex); - inline Instance& GetInstance(); - inline const Instance& GetInstance() const; - inline VkResult GetLastErrorCode() const; - - inline bool IsExtensionLoaded(const String& extensionName); - inline bool IsLayerLoaded(const String& layerName); - - inline bool WaitForIdle(); - - Device& operator=(const Device&) = delete; - Device& operator=(Device&&) = delete; - - inline operator VkDevice(); - - // Vulkan functions - #define NAZARA_VULKAN_DEVICE_FUNCTION(func) PFN_##func func - - // Vulkan core - NAZARA_VULKAN_DEVICE_FUNCTION(vkAllocateCommandBuffers); - NAZARA_VULKAN_DEVICE_FUNCTION(vkAllocateMemory); - NAZARA_VULKAN_DEVICE_FUNCTION(vkBeginCommandBuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkBindBufferMemory); - NAZARA_VULKAN_DEVICE_FUNCTION(vkBindImageMemory); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdBeginQuery); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdBeginRenderPass); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdBindDescriptorSets); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdBindIndexBuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdBindPipeline); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdBindVertexBuffers); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdBlitImage); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdClearAttachments); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdClearColorImage); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdClearDepthStencilImage); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdCopyBuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdCopyBufferToImage); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdCopyImage); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdCopyImageToBuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdCopyQueryPoolResults); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdDispatch); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdDispatchIndirect); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdDraw); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdDrawIndexed); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdDrawIndexedIndirect); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdDrawIndirect); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdEndQuery); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdEndRenderPass); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdExecuteCommands); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdFillBuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdNextSubpass); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdPipelineBarrier); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdPushConstants); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdResetEvent); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdResetQueryPool); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdResolveImage); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdSetBlendConstants); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdSetDepthBias); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdSetDepthBounds); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdSetEvent); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdSetLineWidth); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdSetScissor); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdSetStencilCompareMask); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdSetStencilReference); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdSetStencilWriteMask); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdSetViewport); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdUpdateBuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdWaitEvents); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdWriteTimestamp); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateBuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateBufferView); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateCommandPool); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateComputePipelines); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateDescriptorPool); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateDescriptorSetLayout); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateEvent); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateFramebuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateGraphicsPipelines); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateImage); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateImageView); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreatePipelineLayout); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateRenderPass); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateSampler); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateSemaphore); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateShaderModule); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyBuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyBufferView); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyCommandPool); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyDescriptorPool); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyDescriptorSetLayout); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyDevice); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyEvent); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyFramebuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyImage); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyImageView); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyPipeline); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyPipelineLayout); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyRenderPass); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroySampler); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroySemaphore); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyShaderModule); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDeviceWaitIdle); - NAZARA_VULKAN_DEVICE_FUNCTION(vkEndCommandBuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkFreeCommandBuffers); - NAZARA_VULKAN_DEVICE_FUNCTION(vkFreeDescriptorSets); - NAZARA_VULKAN_DEVICE_FUNCTION(vkFreeMemory); - NAZARA_VULKAN_DEVICE_FUNCTION(vkFlushMappedMemoryRanges); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetBufferMemoryRequirements); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetDeviceMemoryCommitment); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetDeviceQueue); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetEventStatus); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetFenceStatus); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetImageMemoryRequirements); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetImageSparseMemoryRequirements); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetImageSubresourceLayout); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetRenderAreaGranularity); - NAZARA_VULKAN_DEVICE_FUNCTION(vkInvalidateMappedMemoryRanges); - NAZARA_VULKAN_DEVICE_FUNCTION(vkMapMemory); - NAZARA_VULKAN_DEVICE_FUNCTION(vkMergePipelineCaches); - NAZARA_VULKAN_DEVICE_FUNCTION(vkQueueSubmit); - NAZARA_VULKAN_DEVICE_FUNCTION(vkQueueWaitIdle); - NAZARA_VULKAN_DEVICE_FUNCTION(vkResetCommandBuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkResetCommandPool); - NAZARA_VULKAN_DEVICE_FUNCTION(vkResetDescriptorPool); - NAZARA_VULKAN_DEVICE_FUNCTION(vkResetFences); - NAZARA_VULKAN_DEVICE_FUNCTION(vkResetEvent); - NAZARA_VULKAN_DEVICE_FUNCTION(vkSetEvent); - NAZARA_VULKAN_DEVICE_FUNCTION(vkUnmapMemory); - NAZARA_VULKAN_DEVICE_FUNCTION(vkUpdateDescriptorSets); - NAZARA_VULKAN_DEVICE_FUNCTION(vkWaitForFences); - - // VK_KHR_display_swapchain - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateSharedSwapchainsKHR); - - // VK_KHR_surface - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroySurfaceKHR); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetPhysicalDeviceSurfaceCapabilitiesKHR); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetPhysicalDeviceSurfaceFormatsKHR); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetPhysicalDeviceSurfacePresentModesKHR); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetPhysicalDeviceSurfaceSupportKHR); - - // VK_KHR_swapchain - NAZARA_VULKAN_DEVICE_FUNCTION(vkAcquireNextImageKHR); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateSwapchainKHR); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroySwapchainKHR); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetSwapchainImagesKHR); - NAZARA_VULKAN_DEVICE_FUNCTION(vkQueuePresentKHR); - - #undef NAZARA_VULKAN_DEVICE_FUNCTION - - private: - inline PFN_vkVoidFunction GetProcAddr(const char* name); - - Instance& m_instance; - VkAllocationCallbacks m_allocator; - VkDevice m_device; - VkResult m_lastErrorCode; - std::unordered_set m_loadedExtensions; - std::unordered_set m_loadedLayers; - }; - } -} - -#include - -#endif // NAZARA_VULKAN_VKDEVICE_HPP diff --git a/include/Nazara/Vulkan/VkDevice.inl b/include/Nazara/Vulkan/VkDevice.inl deleted file mode 100644 index 77dc1e254..000000000 --- a/include/Nazara/Vulkan/VkDevice.inl +++ /dev/null @@ -1,96 +0,0 @@ -// 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 -#include - -namespace Nz -{ - namespace Vk - { - inline Device::Device(Instance& instance) : - m_instance(instance), - m_device(nullptr) - { - } - - inline Device::~Device() - { - Destroy(); - } - - inline void Device::Destroy() - { - if (m_device) - { - vkDeviceWaitIdle(m_device); - vkDestroyDevice(m_device, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); - } - } - - inline Queue Device::GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex) - { - VkQueue queue; - vkGetDeviceQueue(m_device, queueFamilyIndex, queueIndex, &queue); - - return Queue(*this, queue); - } - - inline Instance& Device::GetInstance() - { - return m_instance; - } - - inline const Instance& Device::GetInstance() const - { - return m_instance; - } - - inline VkResult Device::GetLastErrorCode() const - { - return m_lastErrorCode; - } - - inline bool Device::IsExtensionLoaded(const String& extensionName) - { - return m_loadedExtensions.count(extensionName) > 0; - } - - inline bool Device::IsLayerLoaded(const String& layerName) - { - return m_loadedLayers.count(layerName) > 0; - } - - inline bool Device::WaitForIdle() - { - m_lastErrorCode = vkDeviceWaitIdle(m_device); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to wait for device idle"); - return false; - } - - return true; - } - - inline Device::operator VkDevice() - { - return m_device; - } - - inline PFN_vkVoidFunction Device::GetProcAddr(const char* name) - { - PFN_vkVoidFunction func = m_instance.GetDeviceProcAddr(m_device, name); - if (!func) - NazaraError("Failed to get " + String(name) + " address"); - - return func; - } - } -} - -#include diff --git a/include/Nazara/Vulkan/VkDeviceObject.hpp b/include/Nazara/Vulkan/VkDeviceObject.hpp deleted file mode 100644 index dd9da38c9..000000000 --- a/include/Nazara/Vulkan/VkDeviceObject.hpp +++ /dev/null @@ -1,50 +0,0 @@ -// 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 - -#pragma once - -#ifndef NAZARA_VULKAN_VKDEVICEOBJECT_HPP -#define NAZARA_VULKAN_VKDEVICEOBJECT_HPP - -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - template - class DeviceObject - { - public: - inline DeviceObject(Device& instance); - DeviceObject(const DeviceObject&) = delete; - DeviceObject(DeviceObject&&); - inline ~DeviceObject(); - - inline bool Create(const CreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); - inline void Destroy(); - - inline Device& GetDevice(); - inline const Device& GetDevice() const; - inline VkResult GetLastErrorCode() const; - - DeviceObject& operator=(const DeviceObject&) = delete; - DeviceObject& operator=(DeviceObject&&) = delete; - - inline operator VkType(); - - protected: - Device& m_device; - VkAllocationCallbacks m_allocator; - VkType m_handle; - VkResult m_lastErrorCode; - }; - } -} - -#include - -#endif // NAZARA_VULKAN_VKDEVICEOBJECT_HPP diff --git a/include/Nazara/Vulkan/VkDeviceObject.inl b/include/Nazara/Vulkan/VkDeviceObject.inl deleted file mode 100644 index a3136156c..000000000 --- a/include/Nazara/Vulkan/VkDeviceObject.inl +++ /dev/null @@ -1,89 +0,0 @@ -// 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(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 - 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 Device& DeviceObject::GetDevice() - { - return m_device; - } - - template - inline const Device& DeviceObject::GetDevice() const - { - return m_device; - } - - template - inline VkResult DeviceObject::GetLastErrorCode() const - { - return m_lastErrorCode; - } - - template - inline DeviceObject::operator VkType() - { - return m_handle; - } - } -} - -#include diff --git a/include/Nazara/Vulkan/VkInstance.hpp b/include/Nazara/Vulkan/VkInstance.hpp deleted file mode 100644 index ded2b0ef7..000000000 --- a/include/Nazara/Vulkan/VkInstance.hpp +++ /dev/null @@ -1,141 +0,0 @@ -// 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 - -#pragma once - -#ifndef NAZARA_VULKAN_VKINSTANCE_HPP -#define NAZARA_VULKAN_VKINSTANCE_HPP - -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - class NAZARA_VULKAN_API Instance - { - public: - inline Instance(); - Instance(const Instance&) = delete; - Instance(Instance&&) = delete; - inline ~Instance(); - - bool Create(const VkInstanceCreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); - inline bool Create(const String& appName, UInt32 appVersion, const String& engineName, UInt32 engineVersion, const std::vector& layers, const std::vector& extensions, const VkAllocationCallbacks* allocator = nullptr); - inline void Destroy(); - - bool EnumeratePhysicalDevices(std::vector* physicalDevices); - - inline PFN_vkVoidFunction GetDeviceProcAddr(VkDevice device, const char* name); - - inline void GetPhysicalDeviceFeatures(VkPhysicalDevice device, VkPhysicalDeviceFeatures* features); - inline void GetPhysicalDeviceFormatProperties(VkPhysicalDevice device, VkFormat format, VkFormatProperties* formatProperties); - inline bool GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties* imageFormatProperties); - inline void GetPhysicalDeviceMemoryProperties(VkPhysicalDevice device, VkPhysicalDeviceMemoryProperties* properties); - inline void GetPhysicalDeviceProperties(VkPhysicalDevice device, VkPhysicalDeviceProperties* properties); - bool GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice device, std::vector* queueFamilyProperties); - - inline VkResult GetLastErrorCode() const; - - inline bool IsExtensionLoaded(const String& extensionName); - inline bool IsLayerLoaded(const String& layerName); - - Instance& operator=(const Instance&) = delete; - Instance& operator=(Instance&&) = delete; - - inline operator VkInstance(); - - // Vulkan functions - #define NAZARA_VULKAN_INSTANCE_FUNCTION(func) PFN_##func func - - // Vulkan core - NAZARA_VULKAN_INSTANCE_FUNCTION(vkCreateDevice); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkDestroyInstance); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkEnumeratePhysicalDevices); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetDeviceProcAddr); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceFeatures); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceFormatProperties); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceImageFormatProperties); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceMemoryProperties); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceProperties); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceQueueFamilyProperties); - - // VK_KHR_display - NAZARA_VULKAN_INSTANCE_FUNCTION(vkCreateDisplayModeKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkCreateDisplayPlaneSurfaceKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetDisplayModePropertiesKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetDisplayPlaneCapabilitiesKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetDisplayPlaneSupportedDisplaysKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceDisplayPlanePropertiesKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceDisplayPropertiesKHR); - - // VK_KHR_surface - NAZARA_VULKAN_INSTANCE_FUNCTION(vkDestroySurfaceKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfaceCapabilitiesKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfaceFormatsKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfacePresentModesKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfaceSupportKHR); - - // VK_EXT_debug_report - NAZARA_VULKAN_INSTANCE_FUNCTION(vkCreateDebugReportCallbackEXT); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkDestroyDebugReportCallbackEXT); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkDebugReportMessageEXT); - - #ifdef VK_USE_PLATFORM_ANDROID_KHR - // VK_KHR_android_surface - NAZARA_VULKAN_INSTANCE_FUNCTION(vkCreateAndroidSurfaceKHR); - #endif - - #ifdef VK_USE_PLATFORM_MIR_KHR - // VK_KHR_mir_surface - NAZARA_VULKAN_INSTANCE_FUNCTION(vkCreateMirSurfaceKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceMirPresentationSupportKHR); - #endif - - #ifdef VK_USE_PLATFORM_XCB_KHR - // VK_KHR_xcb_surface - NAZARA_VULKAN_INSTANCE_FUNCTION(vkCreateXcbSurfaceKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceXcbPresentationSupportKHR); - #endif - - #ifdef VK_USE_PLATFORM_XLIB_KHR - // VK_KHR_xlib_surface - NAZARA_VULKAN_INSTANCE_FUNCTION(vkCreateXlibSurfaceKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceXlibPresentationSupportKHR); - #endif - - #ifdef VK_USE_PLATFORM_WAYLAND_KHR - // VK_KHR_wayland_surface - NAZARA_VULKAN_INSTANCE_FUNCTION(vkCreateWaylandSurfaceKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceWaylandPresentationSupportKHR); - #endif - - #ifdef VK_USE_PLATFORM_WIN32_KHR - // VK_KHR_win32_surface - NAZARA_VULKAN_INSTANCE_FUNCTION(vkCreateWin32SurfaceKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceWin32PresentationSupportKHR); - #endif - - #undef NAZARA_VULKAN_INSTANCE_FUNCTION - - private: - inline PFN_vkVoidFunction GetProcAddr(const char* name); - - VkAllocationCallbacks m_allocator; - VkInstance m_instance; - VkResult m_lastErrorCode; - std::unordered_set m_loadedExtensions; - std::unordered_set m_loadedLayers; - }; - } -} - -#include - -#endif // NAZARA_VULKAN_VKINSTANCE_HPP diff --git a/include/Nazara/Vulkan/VkInstance.inl b/include/Nazara/Vulkan/VkInstance.inl deleted file mode 100644 index 801691855..000000000 --- a/include/Nazara/Vulkan/VkInstance.inl +++ /dev/null @@ -1,128 +0,0 @@ -// 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 - -namespace Nz -{ - namespace Vk - { - inline Instance::Instance() : - m_instance(nullptr) - { - } - - inline Instance::~Instance() - { - Destroy(); - } - - inline bool Instance::Create(const String& appName, UInt32 appVersion, const String& engineName, UInt32 engineVersion, const std::vector& layers, const std::vector& extensions, const VkAllocationCallbacks* allocator) - { - VkApplicationInfo appInfo = - { - VK_STRUCTURE_TYPE_APPLICATION_INFO, - nullptr, - appName.GetConstBuffer(), - appVersion, - engineName.GetConstBuffer(), - engineVersion - }; - - VkInstanceCreateInfo instanceInfo = - { - VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, - nullptr, - 0, - &appInfo, - static_cast(layers.size()), - (!layers.empty()) ? layers.data() : nullptr, - static_cast(extensions.size()), - (!extensions.empty()) ? extensions.data() : nullptr - }; - - return Create(instanceInfo, allocator); - } - - inline void Instance::Destroy() - { - if (m_instance) - vkDestroyInstance(m_instance, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); - } - - inline PFN_vkVoidFunction Instance::GetDeviceProcAddr(VkDevice device, const char* name) - { - PFN_vkVoidFunction func = vkGetDeviceProcAddr(device, name); - if (!func) - NazaraError("Failed to get " + String(name) + " address"); - - return func; - } - - inline VkResult Instance::GetLastErrorCode() const - { - return m_lastErrorCode; - } - - inline bool Instance::IsExtensionLoaded(const String& extensionName) - { - return m_loadedExtensions.count(extensionName) > 0; - } - - inline bool Instance::IsLayerLoaded(const String& layerName) - { - return m_loadedLayers.count(layerName) > 0; - } - - inline Instance::operator VkInstance() - { - return m_instance; - } - - inline void Instance::GetPhysicalDeviceFeatures(VkPhysicalDevice device, VkPhysicalDeviceFeatures* features) - { - return vkGetPhysicalDeviceFeatures(device, features); - } - - inline void Instance::GetPhysicalDeviceFormatProperties(VkPhysicalDevice device, VkFormat format, VkFormatProperties* formatProperties) - { - return vkGetPhysicalDeviceFormatProperties(device, format, formatProperties); - } - - inline bool Instance::GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties* imageFormatProperties) - { - m_lastErrorCode = vkGetPhysicalDeviceImageFormatProperties(physicalDevice, format, type, tiling, usage, flags, imageFormatProperties); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to get physical device image format properties"); - return false; - } - - return true; - } - - inline void Instance::GetPhysicalDeviceMemoryProperties(VkPhysicalDevice device, VkPhysicalDeviceMemoryProperties* memoryProperties) - { - return vkGetPhysicalDeviceMemoryProperties(device, memoryProperties); - } - - inline void Instance::GetPhysicalDeviceProperties(VkPhysicalDevice device, VkPhysicalDeviceProperties* properties) - { - return vkGetPhysicalDeviceProperties(device, properties); - } - - inline PFN_vkVoidFunction Instance::GetProcAddr(const char* name) - { - PFN_vkVoidFunction func = Loader::GetInstanceProcAddr(m_instance, name); - if (!func) - NazaraError("Failed to get " + String(name) + " address"); - - return func; - } - } -} - -#include diff --git a/include/Nazara/Vulkan/VkLoader.hpp b/include/Nazara/Vulkan/VkLoader.hpp deleted file mode 100644 index f12429b28..000000000 --- a/include/Nazara/Vulkan/VkLoader.hpp +++ /dev/null @@ -1,52 +0,0 @@ -// 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 - -#pragma once - -#ifndef NAZARA_VULKAN_VKLOADER_HPP -#define NAZARA_VULKAN_VKLOADER_HPP - -#include -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - class NAZARA_VULKAN_API Loader - { - public: - Loader() = delete; - ~Loader() = delete; - - static bool EnumerateInstanceExtensionProperties(std::vector* properties, const char* layerName = nullptr); - static bool EnumerateInstanceLayerProperties(std::vector* properties); - - static inline PFN_vkVoidFunction GetInstanceProcAddr(VkInstance instance, const char* name); - - static bool Initialize(); - static void Uninitialize(); - - // Vulkan functions - #define NAZARA_VULKAN_GLOBAL_FUNCTION(func) static PFN_##func func - - NAZARA_VULKAN_GLOBAL_FUNCTION(vkCreateInstance); - NAZARA_VULKAN_GLOBAL_FUNCTION(vkEnumerateInstanceExtensionProperties); - NAZARA_VULKAN_GLOBAL_FUNCTION(vkEnumerateInstanceLayerProperties); - NAZARA_VULKAN_GLOBAL_FUNCTION(vkGetInstanceProcAddr); - - #undef NAZARA_VULKAN_GLOBAL_FUNCTION - - private: - static DynLib s_vulkanLib; - static VkResult s_lastErrorCode; - }; - } -} - -#include - -#endif // NAZARA_VULKAN_VKLOADER_HPP diff --git a/include/Nazara/Vulkan/VkLoader.inl b/include/Nazara/Vulkan/VkLoader.inl deleted file mode 100644 index 49467366d..000000000 --- a/include/Nazara/Vulkan/VkLoader.inl +++ /dev/null @@ -1,19 +0,0 @@ -// 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 - -namespace Nz -{ - namespace Vk - { - inline PFN_vkVoidFunction Loader::GetInstanceProcAddr(VkInstance instance, const char* name) - { - return vkGetInstanceProcAddr(instance, name); - } - } -} - -#include diff --git a/include/Nazara/Vulkan/VkQueue.hpp b/include/Nazara/Vulkan/VkQueue.hpp deleted file mode 100644 index 35c8d16e0..000000000 --- a/include/Nazara/Vulkan/VkQueue.hpp +++ /dev/null @@ -1,52 +0,0 @@ -// 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 - -#pragma once - -#ifndef NAZARA_VULKAN_VKQUEUE_HPP -#define NAZARA_VULKAN_VKQUEUE_HPP - -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - class Queue - { - public: - inline Queue(Device& device, VkQueue queue); - inline Queue(const Queue& queue); - inline Queue(Queue&& queue); - inline ~Queue() = default; - - inline Device& GetDevice(); - inline VkResult GetLastErrorCode() const; - - inline bool Present(const VkPresentInfoKHR& presentInfo); - inline bool Present(VkSwapchainKHR swapchain, UInt32 imageIndex, VkSemaphore waitSemaphore = VK_NULL_HANDLE); - - inline bool Submit(const VkSubmitInfo& submit, VkFence fence = VK_NULL_HANDLE); - inline bool Submit(UInt32 submitCount, const VkSubmitInfo* submits, VkFence fence = VK_NULL_HANDLE); - - inline bool WaitIdle(); - - Queue& operator=(const Queue& queue) = delete; - Queue& operator=(Queue&&) = delete; - - inline operator VkQueue(); - - protected: - Device& m_device; - VkQueue m_handle; - VkResult m_lastErrorCode; - }; - } -} - -#include - -#endif // NAZARA_VULKAN_VKQUEUE_HPP diff --git a/include/Nazara/Vulkan/VkQueue.inl b/include/Nazara/Vulkan/VkQueue.inl deleted file mode 100644 index a47918da3..000000000 --- a/include/Nazara/Vulkan/VkQueue.inl +++ /dev/null @@ -1,102 +0,0 @@ -// 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 - { - inline Queue::Queue(Device& device, VkQueue queue) : - m_device(device), - m_handle(queue), - m_lastErrorCode(VkResult::VK_SUCCESS) - { - } - - inline Queue::Queue(const Queue& queue) : - m_device(queue.m_device), - m_handle(queue.m_handle), - m_lastErrorCode(queue.m_lastErrorCode) - { - } - - inline Queue::Queue(Queue&& queue) : - m_device(queue.m_device), - m_handle(queue.m_handle), - m_lastErrorCode(queue.m_lastErrorCode) - { - } - - inline Device& Queue::GetDevice() - { - return m_device; - } - - inline VkResult Queue::GetLastErrorCode() const - { - return m_lastErrorCode; - } - - inline bool Queue::Present(const VkPresentInfoKHR& presentInfo) - { - m_lastErrorCode = m_device.vkQueuePresentKHR(m_handle, &presentInfo); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - return false; - - return true; - } - - inline bool Queue::Present(VkSwapchainKHR swapchain, UInt32 imageIndex, VkSemaphore waitSemaphore) - { - VkPresentInfoKHR presentInfo = - { - VK_STRUCTURE_TYPE_PRESENT_INFO_KHR, - nullptr, - (waitSemaphore) ? 1U : 0U, - &waitSemaphore, - 1U, - &swapchain, - &imageIndex, - nullptr - }; - - return Present(presentInfo); - } - - inline bool Queue::Submit(const VkSubmitInfo& submit, VkFence fence) - { - return Submit(1, &submit, fence); - } - - inline bool Queue::Submit(UInt32 submitCount, const VkSubmitInfo* submits, VkFence fence) - { - m_lastErrorCode = m_device.vkQueueSubmit(m_handle, submitCount, submits, fence); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - return false; - - return true; - } - - inline bool Queue::WaitIdle() - { - m_lastErrorCode = m_device.vkQueueWaitIdle(m_handle); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - return false; - - return true; - } - - inline Queue::operator VkQueue() - { - return m_handle; - } - - } -} - -#include diff --git a/include/Nazara/Vulkan/VkSemaphore.hpp b/include/Nazara/Vulkan/VkSemaphore.hpp deleted file mode 100644 index 138d726be..000000000 --- a/include/Nazara/Vulkan/VkSemaphore.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// 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 - -#pragma once - -#ifndef NAZARA_VULKAN_VKSEMAPHORE_HPP -#define NAZARA_VULKAN_VKSEMAPHORE_HPP - -#include -#include - -namespace Nz -{ - namespace Vk - { - class Semaphore : public DeviceObject - { - friend DeviceObject; - - public: - inline Semaphore(Device& instance); - Semaphore(const Semaphore&) = delete; - Semaphore(Semaphore&&) = default; - ~Semaphore() = default; - - using DeviceObject::Create; - inline bool Create(VkSemaphoreCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); - - Semaphore& operator=(const Semaphore&) = delete; - Semaphore& operator=(Semaphore&&) = delete; - - private: - static VkResult CreateHelper(Device& device, const VkSemaphoreCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSemaphore* handle); - static void DestroyHelper(Device& device, VkSemaphore handle, const VkAllocationCallbacks* allocator); - }; - } -} - -#include - -#endif // NAZARA_VULKAN_VKSEMAPHORE_HPP diff --git a/include/Nazara/Vulkan/VkSemaphore.inl b/include/Nazara/Vulkan/VkSemaphore.inl deleted file mode 100644 index fd2bf3427..000000000 --- a/include/Nazara/Vulkan/VkSemaphore.inl +++ /dev/null @@ -1,41 +0,0 @@ -// 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 - -namespace Nz -{ - namespace Vk - { - inline Semaphore::Semaphore(Device& device) : - DeviceObject(device) - { - } - - inline bool Semaphore::Create(VkSemaphoreCreateFlags flags, const VkAllocationCallbacks* allocator) - { - VkSemaphoreCreateInfo createInfo = - { - VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO, - nullptr, - flags - }; - - return Create(createInfo, allocator); - } - - VkResult Semaphore::CreateHelper(Device& device, const VkSemaphoreCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSemaphore* handle) - { - return device.vkCreateSemaphore(device, createInfo, allocator, handle); - } - - void Semaphore::DestroyHelper(Device& device, VkSemaphore handle, const VkAllocationCallbacks* allocator) - { - return device.vkDestroySemaphore(device, handle, allocator); - } - } -} - -#include diff --git a/include/Nazara/Vulkan/VkSurface.hpp b/include/Nazara/Vulkan/VkSurface.hpp deleted file mode 100644 index 03a57d2fe..000000000 --- a/include/Nazara/Vulkan/VkSurface.hpp +++ /dev/null @@ -1,94 +0,0 @@ -// 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 - -#pragma once - -#ifndef NAZARA_VULKAN_VKSURFACE_HPP -#define NAZARA_VULKAN_VKSURFACE_HPP - -#include -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - class Instance; - - class Surface - { - public: - inline Surface(Instance& instance); - Surface(const Surface&) = delete; - Surface(Surface&& surface); - inline ~Surface(); - - #ifdef VK_USE_PLATFORM_ANDROID_KHR - // VK_KHR_android_surface - inline bool Create(const VkAndroidSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator = nullptr); - inline bool Create(ANativeWindow* window, VkAndroidSurfaceCreateFlagsKHR flags = 0, const VkAllocationCallbacks* allocator = nullptr); - #endif - - #ifdef VK_USE_PLATFORM_MIR_KHR - // VK_KHR_mir_surface - inline bool Create(const VkMirSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator = nullptr); - inline bool Create(MirConnection* connection, MirSurface* surface, VkMirSurfaceCreateFlagsKHR flags = 0, const VkAllocationCallbacks* allocator = nullptr); - #endif - - #ifdef VK_USE_PLATFORM_XCB_KHR - // VK_KHR_xcb_surface - inline bool Create(const VkXcbSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator = nullptr); - inline bool Create(xcb_connection_t* connection, xcb_window_t window, VkXcbSurfaceCreateFlagsKHR flags = 0, const VkAllocationCallbacks* allocator = nullptr); - #endif - - #ifdef VK_USE_PLATFORM_XLIB_KHR - // VK_KHR_xlib_surface - inline bool Create(const VkXlibSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator = nullptr); - inline bool Create(Display* display, Window window, VkXlibSurfaceCreateFlagsKHR flags = 0, const VkAllocationCallbacks* allocator = nullptr); - #endif - - #ifdef VK_USE_PLATFORM_WAYLAND_KHR - // VK_KHR_wayland_surface - inline bool Create(const VkWaylandSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator = nullptr); - inline bool Create(wl_display* display, wl_surface* surface, VkWaylandSurfaceCreateFlagsKHR flags = 0, const VkAllocationCallbacks* allocator = nullptr); - #endif - - #ifdef VK_USE_PLATFORM_WIN32_KHR - // VK_KHR_win32_surface - inline bool Create(const VkWin32SurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator = nullptr); - inline bool Create(HINSTANCE instance, HWND handle, VkWin32SurfaceCreateFlagsKHR flags = 0, const VkAllocationCallbacks* allocator = nullptr); - #endif - - inline void Destroy(); - - bool GetCapabilities(VkPhysicalDevice physicalDevice, VkSurfaceCapabilitiesKHR* surfaceCapabilities); - bool GetFormats(VkPhysicalDevice physicalDevice, std::vector* surfaceFormats); - bool GetPresentModes(VkPhysicalDevice physicalDevice, std::vector* presentModes); - bool GetSupportPresentation(VkPhysicalDevice physicalDevice, UInt32 queueFamilyIndex, bool* supported); - - inline bool IsSupported() const; - - inline VkResult GetLastErrorCode() const; - - Surface& operator=(const Surface&) = delete; - Surface& operator=(Surface&&) = delete; - - inline operator VkSurfaceKHR(); - - private: - inline bool Create(const VkAllocationCallbacks* allocator); - - Instance& m_instance; - VkAllocationCallbacks m_allocator; - VkSurfaceKHR m_surface; - VkResult m_lastErrorCode; - }; - } -} - -#include - -#endif // NAZARA_VULKAN_VKSURFACE_HPP diff --git a/include/Nazara/Vulkan/VkSurface.inl b/include/Nazara/Vulkan/VkSurface.inl deleted file mode 100644 index f64c24af0..000000000 --- a/include/Nazara/Vulkan/VkSurface.inl +++ /dev/null @@ -1,311 +0,0 @@ -// 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 - { - inline Surface::Surface(Instance& instance) : - m_instance(instance), - m_surface(VK_NULL_HANDLE) - { - } - - 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() - { - Destroy(); - } - - #ifdef VK_USE_PLATFORM_ANDROID_KHR - inline bool Surface::Create(const VkAndroidSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) - { - m_lastErrorCode = m_instance.vkCreateAndroidSurfaceKHR(m_instance, &createInfo, allocator, &m_surface); - return Create(allocator); - } - - inline bool Surface::Create(ANativeWindow* window, VkAndroidSurfaceCreateFlagsKHR flags, const VkAllocationCallbacks* allocator) - { - VkAndroidSurfaceCreateInfoKHR createInfo = - { - VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR, - nullptr, - flags, - window - }; - - return Create(createInfo, allocator); - } - #endif - - #ifdef VK_USE_PLATFORM_MIR_KHR - inline bool Surface::Create(const VkMirSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) - { - m_lastErrorCode = m_instance.vkCreateMirSurfaceKHR(m_instance, &createInfo, allocator, &m_surface); - return Create(allocator); - } - - inline bool Surface::Create(MirConnection* connection, MirSurface* surface, VkMirSurfaceCreateFlagsKHR flags, const VkAllocationCallbacks* allocator) - { - VkMirSurfaceCreateInfoKHR createInfo = - { - VK_STRUCTURE_TYPE_MIR_SURFACE_CREATE_INFO_KHR, - nullptr, - flags, - connection, - surface - }; - - return Create(createInfo, allocator); - } - #endif - - #ifdef VK_USE_PLATFORM_XCB_KHR - inline bool Surface::Create(const VkXcbSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) - { - m_lastErrorCode = m_instance.vkCreateXcbSurfaceKHR(m_instance, &createInfo, allocator, &m_surface); - return Create(allocator); - } - - inline bool Surface::Create(xcb_connection_t* connection, xcb_window_t window, VkXcbSurfaceCreateFlagsKHR flags, const VkAllocationCallbacks* allocator) - { - VkXcbSurfaceCreateInfoKHR createInfo = - { - VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR, - nullptr, - flags, - connection, - window - }; - - return Create(createInfo, allocator); - } - #endif - - #ifdef VK_USE_PLATFORM_XLIB_KHR - inline bool Surface::Create(const VkXlibSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) - { - m_lastErrorCode = m_instance.vkCreateXlibSurfaceKHR(m_instance, &createInfo, allocator, &m_surface); - return Create(allocator); - } - - inline bool Surface::Create(Display* display, Window window, VkXlibSurfaceCreateFlagsKHR flags, const VkAllocationCallbacks* allocator) - { - VkXlibSurfaceCreateInfoKHR createInfo = - { - VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR, - nullptr, - flags, - display, - window - }; - - return Create(createInfo, allocator); - } - #endif - - #ifdef VK_USE_PLATFORM_WAYLAND_KHR - inline bool Surface::Create(const VkWaylandSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) - { - m_lastErrorCode = m_instance.vkCreateWaylandSurfaceKHR(m_instance, &createInfo, allocator, &m_surface); - return Create(allocator); - } - - inline bool Surface::Create(wl_display* display, wl_surface* surface, VkWaylandSurfaceCreateFlagsKHR flags, const VkAllocationCallbacks* allocator) - { - VkWaylandSurfaceCreateInfoKHR createInfo = - { - VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR, - nullptr, - flags, - display, - surface - }; - - return Create(createInfo, allocator); - } - #endif - - #ifdef VK_USE_PLATFORM_WIN32_KHR - inline bool Surface::Create(const VkWin32SurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) - { - m_lastErrorCode = m_instance.vkCreateWin32SurfaceKHR(m_instance, &createInfo, allocator, &m_surface); - return Create(allocator); - } - - inline bool Surface::Create(HINSTANCE instance, HWND handle, VkWin32SurfaceCreateFlagsKHR flags, const VkAllocationCallbacks* allocator) - { - VkWin32SurfaceCreateInfoKHR createInfo = - { - VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR, - nullptr, - flags, - instance, - handle - }; - - return Create(createInfo, allocator); - } - #endif - - inline void Surface::Destroy() - { - if (m_surface != VK_NULL_HANDLE) - m_instance.vkDestroySurfaceKHR(m_instance, m_surface, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); - } - - inline VkResult Surface::GetLastErrorCode() const - { - return m_lastErrorCode; - } - - inline bool Surface::GetCapabilities(VkPhysicalDevice physicalDevice, VkSurfaceCapabilitiesKHR* surfaceCapabilities) - { - m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDevice, m_surface, surfaceCapabilities); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to query surface capabilities"); - return false; - } - - return true; - } - - inline bool Surface::GetFormats(VkPhysicalDevice physicalDevice, std::vector* surfaceFormats) - { - // First, query format count - UInt32 surfaceCount = 0; // Remember, Nz::UInt32 is a typedef on uint32_t - m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, m_surface, &surfaceCount, nullptr); - if (m_lastErrorCode != VkResult::VK_SUCCESS || surfaceCount == 0) - { - NazaraError("Failed to query format count"); - return false; - } - - // Now we can get the list of the available physical device - surfaceFormats->resize(surfaceCount); - m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, m_surface, &surfaceCount, surfaceFormats->data()); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to query formats"); - return false; - } - - return true; - } - - inline bool Surface::GetPresentModes(VkPhysicalDevice physicalDevice, std::vector* presentModes) - { - // First, query present modes count - UInt32 presentModeCount = 0; // Remember, Nz::UInt32 is a typedef on uint32_t - m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfacePresentModesKHR(physicalDevice, m_surface, &presentModeCount, nullptr); - if (m_lastErrorCode != VkResult::VK_SUCCESS || presentModeCount == 0) - { - NazaraError("Failed to query present mode count"); - return false; - } - - // Now we can get the list of the available physical device - presentModes->resize(presentModeCount); - m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfacePresentModesKHR(physicalDevice, m_surface, &presentModeCount, presentModes->data()); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to query present modes"); - return false; - } - - return true; - } - - inline bool Surface::GetSupportPresentation(VkPhysicalDevice physicalDevice, UInt32 queueFamilyIndex, bool* supported) - { - VkBool32 presentationSupported = VK_FALSE; - m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfaceSupportKHR(physicalDevice, queueFamilyIndex, m_surface, &presentationSupported); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to query surface capabilities"); - return false; - } - - *supported = (presentationSupported == VK_TRUE); - - return true; - } - - inline bool Surface::IsSupported() const - { - if (!m_instance.IsExtensionLoaded("VK_KHR_surface")) - return false; - - #ifdef VK_USE_PLATFORM_ANDROID_KHR - if (m_instance.IsExtensionLoaded("VK_KHR_android_surface")) - return true; - #endif - - #ifdef VK_USE_PLATFORM_MIR_KHR - if (m_instance.IsExtensionLoaded("VK_KHR_mir_surface")) - return true; - #endif - - #ifdef VK_USE_PLATFORM_XCB_KHR - if (m_instance.IsExtensionLoaded("VK_KHR_xcb_surface")) - return true; - #endif - - #ifdef VK_USE_PLATFORM_XLIB_KHR - if (m_instance.IsExtensionLoaded("VK_KHR_xlib_surface")) - return true; - #endif - - #ifdef VK_USE_PLATFORM_WAYLAND_KHR - if (m_instance.IsExtensionLoaded("VK_KHR_wayland_surface")) - return true; - #endif - - #ifdef VK_USE_PLATFORM_WIN32_KHR - if (m_instance.IsExtensionLoaded("VK_KHR_win32_surface")) - return true; - #endif - - return false; - } - - inline Surface::operator VkSurfaceKHR() - { - return m_surface; - } - - inline bool Surface::Create(const VkAllocationCallbacks* allocator) - { - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to create Vulkan surface"); - return false; - } - - // Store the allocator to access them when needed - if (allocator) - m_allocator = *allocator; - else - m_allocator.pfnAllocation = nullptr; - - return true; - } - } -} - -#include diff --git a/include/Nazara/Vulkan/VkSwapchain.hpp b/include/Nazara/Vulkan/VkSwapchain.hpp deleted file mode 100644 index 374ad88e6..000000000 --- a/include/Nazara/Vulkan/VkSwapchain.hpp +++ /dev/null @@ -1,51 +0,0 @@ -// 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 - -#pragma once - -#ifndef NAZARA_VULKAN_VKSWAPCHAIN_HPP -#define NAZARA_VULKAN_VKSWAPCHAIN_HPP - -#include -#include - -namespace Nz -{ - namespace Vk - { - class Swapchain : public DeviceObject - { - friend DeviceObject; - - public: - inline Swapchain(Device& instance); - Swapchain(const Swapchain&) = delete; - Swapchain(Swapchain&&) = default; - ~Swapchain() = default; - - inline bool AcquireNextImage(Nz::UInt64 timeout, VkSemaphore semaphore, VkFence fence, UInt32* imageIndex); - - inline bool Create(const VkSwapchainCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator = nullptr); - - inline VkImage GetImage(UInt32 index) const; - inline const std::vector& GetImages() const; - inline UInt32 GetImageCount() const; - - inline bool IsSupported() const; - - Swapchain& operator=(const Swapchain&) = delete; - Swapchain& operator=(Swapchain&&) = delete; - - private: - static VkResult CreateHelper(Device& device, const VkSwapchainCreateInfoKHR* createInfo, const VkAllocationCallbacks* allocator, VkSwapchainKHR* handle); - static void DestroyHelper(Device& device, VkSwapchainKHR handle, const VkAllocationCallbacks* allocator); - - std::vector m_images; - }; - } -} - -#include - -#endif // NAZARA_VULKAN_VKSWAPCHAIN_HPP diff --git a/include/Nazara/Vulkan/VkSwapchain.inl b/include/Nazara/Vulkan/VkSwapchain.inl deleted file mode 100644 index 8865012e4..000000000 --- a/include/Nazara/Vulkan/VkSwapchain.inl +++ /dev/null @@ -1,90 +0,0 @@ -// 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 - { - inline Swapchain::Swapchain(Device& device) : - DeviceObject(device) - { - } - - inline bool Swapchain::AcquireNextImage(Nz::UInt64 timeout, VkSemaphore semaphore, VkFence fence, UInt32* imageIndex) - { - m_lastErrorCode = m_device.vkAcquireNextImageKHR(m_device, m_handle, timeout, semaphore, fence, imageIndex); - switch (m_lastErrorCode) - { - case VkResult::VK_SUBOPTIMAL_KHR: - case VkResult::VK_SUCCESS: - return true; - - default: - return false; - } - } - - inline bool Swapchain::Create(const VkSwapchainCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) - { - if (!DeviceObject::Create(createInfo, allocator)) - return false; - - UInt32 imageCount = 0; - m_lastErrorCode = m_device.vkGetSwapchainImagesKHR(m_device, m_handle, &imageCount, nullptr); - if (m_lastErrorCode != VkResult::VK_SUCCESS || imageCount == 0) - { - NazaraError("Failed to query swapchain image count"); - return false; - } - - m_images.resize(imageCount); - m_lastErrorCode = m_device.vkGetSwapchainImagesKHR(m_device, m_handle, &imageCount, m_images.data()); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to query swapchain images"); - return false; - } - - return true; - } - - inline VkImage Swapchain::GetImage(UInt32 index) const - { - return m_images[index]; - } - - inline const std::vector& Swapchain::GetImages() const - { - return m_images; - } - - inline UInt32 Swapchain::GetImageCount() const - { - return m_images.size(); - } - - inline bool Swapchain::IsSupported() const - { - if (!m_device.IsExtensionLoaded("VK_KHR_swapchain")) - return false; - } - - VkResult Swapchain::CreateHelper(Device& device, const VkSwapchainCreateInfoKHR* createInfo, const VkAllocationCallbacks* allocator, VkSwapchainKHR* handle) - { - return device.vkCreateSwapchainKHR(device, createInfo, allocator, handle); - } - - void Swapchain::DestroyHelper(Device& device, VkSwapchainKHR handle, const VkAllocationCallbacks* allocator) - { - return device.vkDestroySwapchainKHR(device, handle, allocator); - } - } -} - -#include diff --git a/include/Nazara/Vulkan/Vulkan.hpp b/include/Nazara/Vulkan/Vulkan.hpp deleted file mode 100644 index 9d90202c2..000000000 --- a/include/Nazara/Vulkan/Vulkan.hpp +++ /dev/null @@ -1,33 +0,0 @@ -// 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 - -#pragma once - -#ifndef NAZARA_VULKAN_HPP -#define NAZARA_VULKAN_HPP - -#include -#include -#include - -namespace Nz -{ - class NAZARA_VULKAN_API Vulkan - { - public: - Vulkan() = delete; - ~Vulkan() = delete; - - static bool Initialize(); - - static bool IsInitialized(); - - static void Uninitialize(); - - private: - static unsigned int s_moduleReferenceCounter; - }; -} - -#endif // NAZARA_VULKAN_HPP diff --git a/src/Nazara/Vulkan/Debug/NewOverload.cpp b/src/Nazara/Vulkan/Debug/NewOverload.cpp deleted file mode 100644 index 410a53c76..000000000 --- a/src/Nazara/Vulkan/Debug/NewOverload.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2014 AUTHORS -// This file is part of the "Nazara Engine - Module name" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#if NAZARA_VULKAN_MANAGE_MEMORY - -#include -#include // Nécessaire ? - -void* operator new(std::size_t size) -{ - return Nz::MemoryManager::Allocate(size, false); -} - -void* operator new[](std::size_t size) -{ - return Nz::MemoryManager::Allocate(size, true); -} - -void operator delete(void* pointer) noexcept -{ - Nz::MemoryManager::Free(pointer, false); -} - -void operator delete[](void* pointer) noexcept -{ - Nz::MemoryManager::Free(pointer, true); -} - -#endif // NAZARA_VULKAN_MANAGE_MEMORY diff --git a/src/Nazara/Vulkan/VkCommandPool.cpp b/src/Nazara/Vulkan/VkCommandPool.cpp deleted file mode 100644 index 3ee53ab6f..000000000 --- a/src/Nazara/Vulkan/VkCommandPool.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// 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 - -namespace Nz -{ - namespace Vk - { - CommandBuffer CommandPool::AllocateCommandBuffer(VkCommandBufferLevel level) - { - VkCommandBufferAllocateInfo createInfo = - { - VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, - nullptr, - m_handle, - level, - 1U - }; - - VkCommandBuffer handle = VK_NULL_HANDLE; - m_lastErrorCode = m_device.vkAllocateCommandBuffers(m_device, &createInfo, &handle); - - return CommandBuffer(*this, handle); - } - - std::vector CommandPool::AllocateCommandBuffers(UInt32 commandBufferCount, VkCommandBufferLevel level) - { - VkCommandBufferAllocateInfo createInfo = - { - VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, - nullptr, - m_handle, - level, - 1U - }; - - std::vector handles(commandBufferCount, VK_NULL_HANDLE); - m_lastErrorCode = m_device.vkAllocateCommandBuffers(m_device, &createInfo, handles.data()); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - return std::vector(); - - std::vector commandBuffers; - for (UInt32 i = 0; i < commandBufferCount; ++i) - commandBuffers.emplace_back(CommandBuffer(*this, handles[i])); - - return commandBuffers; - } - } -} diff --git a/src/Nazara/Vulkan/VkDevice.cpp b/src/Nazara/Vulkan/VkDevice.cpp deleted file mode 100644 index c2f39da76..000000000 --- a/src/Nazara/Vulkan/VkDevice.cpp +++ /dev/null @@ -1,178 +0,0 @@ -// 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 - { - bool Device::Create(VkPhysicalDevice device, const VkDeviceCreateInfo& createInfo, const VkAllocationCallbacks* allocator) - { - m_lastErrorCode = m_instance.vkCreateDevice(device, &createInfo, allocator, &m_device); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to create Vulkan device"); - return false; - } - - // Store the allocator to access them when needed - if (allocator) - m_allocator = *allocator; - else - m_allocator.pfnAllocation = nullptr; - - // Parse extensions and layers - for (UInt32 i = 0; i < createInfo.enabledExtensionCount; ++i) - m_loadedExtensions.insert(createInfo.ppEnabledExtensionNames[i]); - - for (UInt32 i = 0; i < createInfo.enabledLayerCount; ++i) - m_loadedLayers.insert(createInfo.ppEnabledLayerNames[i]); - - #define NAZARA_VULKAN_LOAD_DEVICE(func) func = reinterpret_cast(GetProcAddr(#func)) - - try - { - ErrorFlags flags(ErrorFlag_ThrowException, true); - - NAZARA_VULKAN_LOAD_DEVICE(vkAllocateCommandBuffers); - NAZARA_VULKAN_LOAD_DEVICE(vkAllocateMemory); - NAZARA_VULKAN_LOAD_DEVICE(vkBeginCommandBuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkBindBufferMemory); - NAZARA_VULKAN_LOAD_DEVICE(vkBindImageMemory); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdBeginQuery); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdBeginRenderPass); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdBindDescriptorSets); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdBindIndexBuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdBindPipeline); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdBindVertexBuffers); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdBlitImage); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdClearAttachments); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdClearColorImage); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdClearDepthStencilImage); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdCopyBuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdCopyBufferToImage); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdCopyImage); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdCopyImageToBuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdCopyQueryPoolResults); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdDispatch); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdDispatchIndirect); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdDraw); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdDrawIndexed); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdDrawIndexedIndirect); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdDrawIndirect); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdEndQuery); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdEndRenderPass); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdExecuteCommands); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdFillBuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdNextSubpass); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdPipelineBarrier); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdPushConstants); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdResetEvent); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdResetQueryPool); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdResolveImage); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdSetBlendConstants); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdSetDepthBias); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdSetDepthBounds); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdSetEvent); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdSetLineWidth); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdSetScissor); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdSetStencilCompareMask); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdSetStencilReference); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdSetStencilWriteMask); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdSetViewport); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdUpdateBuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdWaitEvents); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdWriteTimestamp); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateBuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateBufferView); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateCommandPool); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateComputePipelines); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateDescriptorPool); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateDescriptorSetLayout); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateEvent); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateFramebuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateGraphicsPipelines); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateImage); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateImageView); - NAZARA_VULKAN_LOAD_DEVICE(vkCreatePipelineLayout); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateRenderPass); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateSampler); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateSemaphore); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateShaderModule); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyBuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyBufferView); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyCommandPool); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyDescriptorPool); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyDescriptorSetLayout); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyDevice); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyEvent); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyFramebuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyImage); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyImageView); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyPipeline); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyPipelineLayout); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyRenderPass); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroySampler); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroySemaphore); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyShaderModule); - NAZARA_VULKAN_LOAD_DEVICE(vkDeviceWaitIdle); - NAZARA_VULKAN_LOAD_DEVICE(vkEndCommandBuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkFreeCommandBuffers); - NAZARA_VULKAN_LOAD_DEVICE(vkFreeDescriptorSets); - NAZARA_VULKAN_LOAD_DEVICE(vkFreeMemory); - NAZARA_VULKAN_LOAD_DEVICE(vkFlushMappedMemoryRanges); - NAZARA_VULKAN_LOAD_DEVICE(vkGetBufferMemoryRequirements); - NAZARA_VULKAN_LOAD_DEVICE(vkGetDeviceMemoryCommitment); - NAZARA_VULKAN_LOAD_DEVICE(vkGetDeviceQueue); - NAZARA_VULKAN_LOAD_DEVICE(vkGetEventStatus); - NAZARA_VULKAN_LOAD_DEVICE(vkGetFenceStatus); - NAZARA_VULKAN_LOAD_DEVICE(vkGetImageMemoryRequirements); - NAZARA_VULKAN_LOAD_DEVICE(vkGetImageSparseMemoryRequirements); - NAZARA_VULKAN_LOAD_DEVICE(vkGetImageSubresourceLayout); - NAZARA_VULKAN_LOAD_DEVICE(vkGetRenderAreaGranularity); - NAZARA_VULKAN_LOAD_DEVICE(vkInvalidateMappedMemoryRanges); - NAZARA_VULKAN_LOAD_DEVICE(vkMapMemory); - NAZARA_VULKAN_LOAD_DEVICE(vkMergePipelineCaches); - NAZARA_VULKAN_LOAD_DEVICE(vkQueueSubmit); - NAZARA_VULKAN_LOAD_DEVICE(vkQueueWaitIdle); - NAZARA_VULKAN_LOAD_DEVICE(vkResetCommandBuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkResetCommandPool); - NAZARA_VULKAN_LOAD_DEVICE(vkResetDescriptorPool); - NAZARA_VULKAN_LOAD_DEVICE(vkResetFences); - NAZARA_VULKAN_LOAD_DEVICE(vkResetEvent); - NAZARA_VULKAN_LOAD_DEVICE(vkSetEvent); - NAZARA_VULKAN_LOAD_DEVICE(vkUnmapMemory); - NAZARA_VULKAN_LOAD_DEVICE(vkUpdateDescriptorSets); - NAZARA_VULKAN_LOAD_DEVICE(vkWaitForFences); - - // VK_KHR_display_swapchain - if (IsExtensionLoaded("VK_KHR_display_swapchain")) - NAZARA_VULKAN_LOAD_DEVICE(vkCreateSharedSwapchainsKHR); - - // VK_KHR_swapchain - if (IsExtensionLoaded("VK_KHR_swapchain")) - { - NAZARA_VULKAN_LOAD_DEVICE(vkAcquireNextImageKHR); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateSwapchainKHR); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroySwapchainKHR); - NAZARA_VULKAN_LOAD_DEVICE(vkGetSwapchainImagesKHR); - NAZARA_VULKAN_LOAD_DEVICE(vkQueuePresentKHR); - } - } - catch (const std::exception& e) - { - NazaraError(String("Failed to query device function: ") + e.what()); - return false; - } - - #undef NAZARA_VULKAN_LOAD_DEVICE - - return true; - } - } -} diff --git a/src/Nazara/Vulkan/VkInstance.cpp b/src/Nazara/Vulkan/VkInstance.cpp deleted file mode 100644 index 35378a699..000000000 --- a/src/Nazara/Vulkan/VkInstance.cpp +++ /dev/null @@ -1,193 +0,0 @@ -// 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 - { - bool Instance::Create(const VkInstanceCreateInfo& createInfo, const VkAllocationCallbacks* allocator) - { - m_lastErrorCode = Loader::vkCreateInstance(&createInfo, allocator, &m_instance); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to create Vulkan instance"); - return false; - } - - // Store the allocator to access them when needed - if (allocator) - m_allocator = *allocator; - else - m_allocator.pfnAllocation = nullptr; - - // Parse extensions and layers - for (UInt32 i = 0; i < createInfo.enabledExtensionCount; ++i) - m_loadedExtensions.insert(createInfo.ppEnabledExtensionNames[i]); - - for (UInt32 i = 0; i < createInfo.enabledLayerCount; ++i) - m_loadedLayers.insert(createInfo.ppEnabledLayerNames[i]); - - // And now load everything - #define NAZARA_VULKAN_LOAD_INSTANCE(func) func = reinterpret_cast(GetProcAddr(#func)) - - try - { - ErrorFlags flags(ErrorFlag_ThrowException, true); - - // Vulkan core - NAZARA_VULKAN_LOAD_INSTANCE(vkCreateDevice); - NAZARA_VULKAN_LOAD_INSTANCE(vkDestroyInstance); - NAZARA_VULKAN_LOAD_INSTANCE(vkEnumeratePhysicalDevices); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetDeviceProcAddr); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceFeatures); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceFormatProperties); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceImageFormatProperties); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceMemoryProperties); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceProperties); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceQueueFamilyProperties); - - // VK_KHR_display - if (IsExtensionLoaded("VK_KHR_display")) - { - NAZARA_VULKAN_LOAD_INSTANCE(vkCreateDisplayModeKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkCreateDisplayPlaneSurfaceKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetDisplayModePropertiesKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetDisplayPlaneCapabilitiesKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetDisplayPlaneSupportedDisplaysKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceDisplayPlanePropertiesKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceDisplayPropertiesKHR); - } - - // VK_KHR_surface - if (IsExtensionLoaded("VK_KHR_surface")) - { - NAZARA_VULKAN_LOAD_INSTANCE(vkDestroySurfaceKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceSurfaceCapabilitiesKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceSurfaceFormatsKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceSurfacePresentModesKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceSurfaceSupportKHR); - } - - // VK_EXT_debug_report - if (IsExtensionLoaded("VK_EXT_debug_report")) - { - NAZARA_VULKAN_LOAD_INSTANCE(vkCreateDebugReportCallbackEXT); - NAZARA_VULKAN_LOAD_INSTANCE(vkDestroyDebugReportCallbackEXT); - NAZARA_VULKAN_LOAD_INSTANCE(vkDebugReportMessageEXT); - } - - #ifdef VK_USE_PLATFORM_ANDROID_KHR - // VK_KHR_android_surface - if (IsExtensionLoaded("VK_KHR_android_surface")) - NAZARA_VULKAN_LOAD_INSTANCE(vkCreateAndroidSurfaceKHR); - #endif - - #ifdef VK_USE_PLATFORM_MIR_KHR - // VK_KHR_mir_surface - if (IsExtensionLoaded("VK_KHR_mir_surface")) - { - NAZARA_VULKAN_LOAD_INSTANCE(vkCreateMirSurfaceKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceMirPresentationSupportKHR); - } - #endif - - #ifdef VK_USE_PLATFORM_XCB_KHR - // VK_KHR_xcb_surface - if (IsExtensionLoaded("VK_KHR_xcb_surface")) - { - NAZARA_VULKAN_LOAD_INSTANCE(vkCreateXcbSurfaceKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceXcbPresentationSupportKHR); - } - #endif - - #ifdef VK_USE_PLATFORM_XLIB_KHR - // VK_KHR_xlib_surface - if (IsExtensionLoaded("VK_KHR_xlib_surface")) - { - NAZARA_VULKAN_LOAD_INSTANCE(vkCreateXlibSurfaceKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceXlibPresentationSupportKHR); - } - #endif - - #ifdef VK_USE_PLATFORM_WAYLAND_KHR - // VK_KHR_wayland_surface - if (IsExtensionLoaded("VK_KHR_wayland_surface")) - { - NAZARA_VULKAN_LOAD_INSTANCE(vkCreateWaylandSurfaceKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceWaylandPresentationSupportKHR); - } - #endif - - #ifdef VK_USE_PLATFORM_WIN32_KHR - // VK_KHR_win32_surface - if (IsExtensionLoaded("VK_KHR_win32_surface")) - { - NAZARA_VULKAN_LOAD_INSTANCE(vkCreateWin32SurfaceKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceWin32PresentationSupportKHR); - } - #endif - } - catch (const std::exception& e) - { - NazaraError(String("Failed to query instance function: ") + e.what()); - return false; - } - - #undef NAZARA_VULKAN_LOAD_INSTANCE - - return true; - } - - bool Instance::EnumeratePhysicalDevices(std::vector* devices) - { - NazaraAssert(devices, "Invalid device vector"); - - // First, query physical device count - UInt32 deviceCount = 0; // Remember, Nz::UInt32 is a typedef on uint32_t - m_lastErrorCode = vkEnumeratePhysicalDevices(m_instance, &deviceCount, nullptr); - if (m_lastErrorCode != VkResult::VK_SUCCESS || deviceCount == 0) - { - NazaraError("Failed to query physical device count"); - return false; - } - - // Now we can get the list of the available physical device - devices->resize(deviceCount); - m_lastErrorCode = vkEnumeratePhysicalDevices(m_instance, &deviceCount, devices->data()); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to query physical devices"); - return false; - } - - return true; - } - - bool Instance::GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice device, std::vector* queueFamilyProperties) - { - NazaraAssert(queueFamilyProperties, "Invalid device vector"); - - // First, query physical device count - UInt32 queueFamiliesCount = 0; // Remember, Nz::UInt32 is a typedef on uint32_t - vkGetPhysicalDeviceQueueFamilyProperties(device, &queueFamiliesCount, nullptr); - if (queueFamiliesCount == 0) - { - NazaraError("Failed to query physical device count"); - return false; - } - - // Now we can get the list of the available physical device - queueFamilyProperties->resize(queueFamiliesCount); - vkGetPhysicalDeviceQueueFamilyProperties(device, &queueFamiliesCount, queueFamilyProperties->data()); - - return true; - } - - } -} diff --git a/src/Nazara/Vulkan/VkLoader.cpp b/src/Nazara/Vulkan/VkLoader.cpp deleted file mode 100644 index c9d2a360d..000000000 --- a/src/Nazara/Vulkan/VkLoader.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// 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 - -namespace Nz -{ - namespace Vk - { - bool Loader::EnumerateInstanceExtensionProperties(std::vector* properties, const char* layerName) - { - NazaraAssert(properties, "Invalid device vector"); - - // First, query physical device count - UInt32 propertyCount = 0; // Remember, Nz::UInt32 is a typedef on uint32_t - s_lastErrorCode = vkEnumerateInstanceExtensionProperties(layerName, &propertyCount, properties->data()); - if (s_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to get instance extension properties count"); - return false; - } - - // Now we can get the list of the available physical device - properties->resize(propertyCount); - s_lastErrorCode = vkEnumerateInstanceExtensionProperties(layerName, &propertyCount, properties->data()); - if (s_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to enumerate instance extension properties"); - return false; - } - - return true; - } - - bool Loader::EnumerateInstanceLayerProperties(std::vector* properties) - { - NazaraAssert(properties, "Invalid device vector"); - - // First, query physical device count - UInt32 propertyCount = 0; // Remember, Nz::UInt32 is a typedef on uint32_t - s_lastErrorCode = vkEnumerateInstanceLayerProperties(&propertyCount, properties->data()); - if (s_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to get instance layer properties count"); - return false; - } - - // Now we can get the list of the available physical device - properties->resize(propertyCount); - s_lastErrorCode = vkEnumerateInstanceLayerProperties(&propertyCount, properties->data()); - if (s_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to enumerate instance layer properties"); - return false; - } - - return true; - } - - bool Loader::Initialize() - { - #ifdef NAZARA_PLATFORM_WINDOWS - s_vulkanLib.Load("vulkan-1.dll"); - #elif defined(NAZARA_PLATFORM_LINUX) - s_vulkanLib.Load("libvulkan.so"); - #else - #error Unhandled platform - #endif - - if (!s_vulkanLib.IsLoaded()) - { - NazaraError("Failed to open vulkan library: " + s_vulkanLib.GetLastError()); - return false; - } - - // vkGetInstanceProcAddr is the only function that's garantee to be exported - vkGetInstanceProcAddr = reinterpret_cast(s_vulkanLib.GetSymbol("vkGetInstanceProcAddr")); - if (!vkGetInstanceProcAddr) - { - NazaraError("Failed to get symbol \"vkGetInstanceProcAddr\": " + s_vulkanLib.GetLastError()); - return false; - } - - // all other functions should be loaded using vkGetInstanceProcAddr - #define NAZARA_VULKAN_LOAD_GLOBAL(func) func = reinterpret_cast(vkGetInstanceProcAddr(nullptr, #func)) - - NAZARA_VULKAN_LOAD_GLOBAL(vkCreateInstance); - NAZARA_VULKAN_LOAD_GLOBAL(vkEnumerateInstanceExtensionProperties); - NAZARA_VULKAN_LOAD_GLOBAL(vkEnumerateInstanceLayerProperties); - - #undef NAZARA_VULKAN_LOAD_GLOBAL - - s_lastErrorCode = VkResult::VK_SUCCESS; - - return true; - } - - #define NAZARA_VULKAN_GLOBAL_FUNCTION_IMPL(func) PFN_##func Loader::func = nullptr - - NAZARA_VULKAN_GLOBAL_FUNCTION_IMPL(vkCreateInstance); - NAZARA_VULKAN_GLOBAL_FUNCTION_IMPL(vkEnumerateInstanceExtensionProperties); - NAZARA_VULKAN_GLOBAL_FUNCTION_IMPL(vkEnumerateInstanceLayerProperties); - NAZARA_VULKAN_GLOBAL_FUNCTION_IMPL(vkGetInstanceProcAddr); - - #undef NAZARA_VULKAN_GLOBAL_FUNCTION_IMPL - - DynLib Loader::s_vulkanLib; - VkResult Loader::s_lastErrorCode; - - void Loader::Uninitialize() - { - s_vulkanLib.Unload(); - } - } -} diff --git a/src/Nazara/Vulkan/Vulkan.cpp b/src/Nazara/Vulkan/Vulkan.cpp deleted file mode 100644 index 00bb55337..000000000 --- a/src/Nazara/Vulkan/Vulkan.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// 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 -#include -#include -#include - -namespace Nz -{ - bool Vulkan::Initialize() - { - if (s_moduleReferenceCounter > 0) - { - s_moduleReferenceCounter++; - return true; // Already initialized - } - - // Initialize module dependencies - if (!Utility::Initialize()) - { - NazaraError("Failed to initialize utility module"); - return false; - } - - s_moduleReferenceCounter++; - - CallOnExit onExit(Vulkan::Uninitialize); - - // Initialize module here - - onExit.Reset(); - - NazaraNotice("Initialized: Vulkan module"); - return true; - } - - bool Vulkan::IsInitialized() - { - return s_moduleReferenceCounter != 0; - } - - void Vulkan::Uninitialize() - { - if (s_moduleReferenceCounter != 1) - { - // Either the module is not initialized, either it was initialized multiple times - if (s_moduleReferenceCounter > 1) - s_moduleReferenceCounter--; - - return; - } - - s_moduleReferenceCounter = 0; - - // Uninitialize module here - - NazaraNotice("Uninitialized: Vulkan module"); - - // Free module dependencies - Utility::Uninitialize(); - } - - unsigned int Vulkan::s_moduleReferenceCounter = 0; -} -